• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java PlaneCollisionShape类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.jme3.bullet.collision.shapes.PlaneCollisionShape的典型用法代码示例。如果您正苦于以下问题:Java PlaneCollisionShape类的具体用法?Java PlaneCollisionShape怎么用?Java PlaneCollisionShape使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



PlaneCollisionShape类属于com.jme3.bullet.collision.shapes包,在下文中一共展示了PlaneCollisionShape类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: simpleInitApp

import com.jme3.bullet.collision.shapes.PlaneCollisionShape; //导入依赖的package包/类
@Override
public void simpleInitApp() {
    //Add some entities
    EntityId plane = entityData.createEntity();
    entityData.setComponents(plane,
            new RigidBody(false, 0),
            new CustomShape(new PlaneCollisionShape(new Plane(Vector3f.UNIT_Y.clone(), 0))),
            new Name("floor"));

    EntityId box = entityData.createEntity();
    entityData.setComponents(box,
            new WarpPosition(new Vector3f(0,10,0), Quaternion.DIRECTION_Z.clone()),
            new RigidBody(false, 10),
            new BoxShape(),
            new Name("box1"));

    EntityId box2 = entityData.createEntity();
    entityData.setComponents(box2,
            new RigidBody(false, 0),
            new BoxShape(),
            new Name("box2"));

    entityData.setComponent(box, new Force(new Vector3f(100,100,100), new Vector3f()));

    colliding = entityData.getEntities(Collision.class, Name.class);
}
 
开发者ID:jvpichowski,项目名称:ZayES-Bullet,代码行数:27,代码来源:CollisionExample.java


示例2: simpleInitApp

import com.jme3.bullet.collision.shapes.PlaneCollisionShape; //导入依赖的package包/类
@Override
public void simpleInitApp() {
    //Same setup as in BasicExample
    EntityId plane = entityData.createEntity();
    entityData.setComponents(plane,
            new RigidBody(false, 0),
            new CustomShape(new PlaneCollisionShape(new Plane(Vector3f.UNIT_Y.clone(), 0))));

    EntityId box = entityData.createEntity();
    entityData.setComponents(box,
            new WarpPosition(new Vector3f(0,0,0), Quaternion.DIRECTION_Z.clone()),
            new RigidBody(false, 10),
            new BoxShape());


    //Add two custom impulses. They are only applied once. You could play with the values..
    entityData.setComponent(box, new CombinedImpulses(new Vector3f(100, 0,0), new Vector3f()));
    //for the second one we have to update the CombinedImpulses component.
    entityData.setComponent(box, entityData.getComponent(box, CombinedImpulses.class).addImpulse(new Vector3f(-150, 0, 0), new Vector3f()));

    ESBulletState esBulletState = stateManager.getState(ESBulletState.class);
    esBulletState.onInitialize(() -> {
        BulletDebugAppState debugAppState = new BulletDebugAppState(esBulletState.getPhysicsSpace());
        getStateManager().attach(debugAppState);
    });
}
 
开发者ID:jvpichowski,项目名称:ZayES-Bullet,代码行数:27,代码来源:CombinedImpulsesExample.java


示例3: loadLevel

import com.jme3.bullet.collision.shapes.PlaneCollisionShape; //导入依赖的package包/类
public void loadLevel() {
        worldRoot = (Node) assetManager.loadModel("Scenes/PillarArena.j3o");
//        worldRoot = (Node) assetManager.loadModel(
//                "Scenes/LavaArenaWithFogWalls.j3o");
        fakeWorldRoot = new Node("fake-world-root");

        RigidBodyControl physics = new RigidBodyControl(
                new PlaneCollisionShape(new Plane(Vector3f.UNIT_Y, 0)), 0);
        physics.setFriction(1f);
        physics.setRestitution(0f);
        physics.setCollideWithGroups(CollisionGroups.NONE);

        worldRoot.getChild("Ground").addControl(physics);

//        Spatial groundGeom = worldRoot.getChild("GroundGeom");
//        LodControl lod = groundGeom.getControl(LodControl.class);
//
//        if (lod == null) {
//            lod = new LodControl();
//            groundGeom.addControl(lod);
//            lod.setTrisPerPixel(0);
//        }
        worldRoot.setName("world-root");

        arena.readWorld(this, assetManager);
    }
 
开发者ID:TripleSnail,项目名称:Arkhados,代码行数:27,代码来源:World.java


示例4: simpleInitApp

import com.jme3.bullet.collision.shapes.PlaneCollisionShape; //导入依赖的package包/类
@Override
public void simpleInitApp() {
    System.out.println("Press and hold SPACE to move box up!");
    //Add some entities
    EntityId plane = entityData.createEntity();
    entityData.setComponents(plane,
            new RigidBody(false, 0),
            new CustomShape(new PlaneCollisionShape(new Plane(Vector3f.UNIT_Y.clone(), 0))));

    EntityId box = entityData.createEntity();
    entityData.setComponents(box,
            new WarpPosition(new Vector3f(0,10,0), Quaternion.DIRECTION_Z.clone()),
            new RigidBody(false, 10),
            new BoxShape());

    EntityId box2 = entityData.createEntity();
    entityData.setComponents(box2,
            new RigidBody(false, 0),
            new BoxShape());

    getInputManager().addMapping("Push", new KeyTrigger(KeyInput.KEY_SPACE));
    getInputManager().addListener((AnalogListener) (name, time, tpf) -> {
        //100 Newton  are needed to lift the box up against the gravity (10kg * 9.81m/s^2 < 100N)
        entityData.setComponent(box, new Force(new Vector3f(0,100,0), new Vector3f()));
    }, "Push");

}
 
开发者ID:jvpichowski,项目名称:ZayES-Bullet,代码行数:28,代码来源:InputExample.java


示例5: simpleInitApp

import com.jme3.bullet.collision.shapes.PlaneCollisionShape; //导入依赖的package包/类
@Override
public void simpleInitApp() {
    getCamera().setLocation(new Vector3f(-5.6461415f, -0.026447738f, 5.5127993f));
    getCamera().setAxes(new Vector3f(-0.6044954f, 4.827976E-6f, -0.7966085f),
            new Vector3f(-0.19503751f, 0.9695639f, 0.14800741f),
            new Vector3f(0.7723636f, 0.24483837f, -0.5860959f));

    //Add some entities
    EntityId plane = entityData.createEntity();
    entityData.setComponents(plane,
            new RigidBody(false, 0),
            new CustomShape(new PlaneCollisionShape(new Plane(Vector3f.UNIT_Y.clone(), 0))));

    box = entityData.createEntity();
    entityData.setComponents(box,
            new WarpPosition(new Vector3f(0,10,0), Quaternion.DIRECTION_Z.clone()),
            new RigidBody(false, 10),
            new BoxShape());

    EntityId box2 = entityData.createEntity();
    entityData.setComponents(box2,
            new RigidBody(false, 0),
            new BoxShape());

    EntityId ghost = entityData.createEntity();
    entityData.setComponents(ghost,
            new SphereShape(1f),
            new GhostObject());

    //apply some force at the beginning
    entityData.setComponent(box, new Force(new Vector3f(100,100,100), new Vector3f()));

    ghostEntity = entityData.watchEntity(ghost, Collision.class);
}
 
开发者ID:jvpichowski,项目名称:ZayES-Bullet,代码行数:35,代码来源:GhostObjectExample.java


示例6: simpleInitApp

import com.jme3.bullet.collision.shapes.PlaneCollisionShape; //导入依赖的package包/类
@Override
public void simpleInitApp() {
    //Same setup as in BasicExample
    EntityId plane = entityData.createEntity();
    entityData.setComponents(plane,
            new RigidBody(false, 0),
            new CustomShape(new PlaneCollisionShape(new Plane(Vector3f.UNIT_Y.clone(), 0))));

    EntityId box = entityData.createEntity();
    entityData.setComponents(box,
            new WarpPosition(new Vector3f(0,10,0), Quaternion.DIRECTION_Z.clone()),
            new RigidBody(false, 10),
            new BoxShape());

    //Add two custom forces. You could play with the values..
    entityData.setComponents(box, new PushForce(10), new PullForce(10));

    ESBulletState esBulletState = stateManager.getState(ESBulletState.class);
    esBulletState.onInitialize(() -> {
        BulletDebugAppState debugAppState = new BulletDebugAppState(esBulletState.getPhysicsSpace());
        getStateManager().attach(debugAppState);

        //register the component definitions to make the physics system aware of them
        esBulletState.getBulletSystem().getForceSystem().registerForce(PullForce.class);
        esBulletState.getBulletSystem().getForceSystem().registerForce(PushForce.class);
    });
}
 
开发者ID:jvpichowski,项目名称:ZayES-Bullet,代码行数:28,代码来源:CustomForceExample.java


示例7: simpleInitApp

import com.jme3.bullet.collision.shapes.PlaneCollisionShape; //导入依赖的package包/类
@Override
public void simpleInitApp() {
    EntityId plane = entityData.createEntity();
    entityData.setComponents(plane,
            new Friction(0),
            new RigidBody(false, 0),
            new CustomShape(new PlaneCollisionShape(new Plane(Vector3f.UNIT_Y.clone(), 0))));

    EntityId box = entityData.createEntity();
    entityData.setComponents(box,
            new Friction(0),
            new WarpPosition(new Vector3f(0,1,0), Quaternion.DIRECTION_Z.clone()),
            new RigidBody(false, 10),
            new BoxShape(),
            new WarpVelocity(new Vector3f(1,0,0), new Vector3f()));

    ESBulletState esBulletState = stateManager.getState(ESBulletState.class);
    esBulletState.onInitialize(() -> {
        BulletDebugAppState debugAppState = new BulletDebugAppState(esBulletState.getPhysicsSpace());
        getStateManager().attach(debugAppState);
    });

    getInputManager().addMapping("JUMP", new KeyTrigger(KeyInput.KEY_SPACE));
    getInputManager().addListener((ActionListener) (name, isPressed, tpf) -> {
        if(isPressed){
            entityData.setComponent(box, new Impulse(new Vector3f(0, 20,0), new Vector3f()));
        }
    }, "JUMP");
}
 
开发者ID:jvpichowski,项目名称:ZayES-Bullet,代码行数:30,代码来源:VelocityImpulseTest.java


示例8: simpleInitApp

import com.jme3.bullet.collision.shapes.PlaneCollisionShape; //导入依赖的package包/类
@Override
public void simpleInitApp() {
    //Add some entities

    //This should be a rigid body with mass 0 and it should be dynamic (not kinematic).
    //The definition is the same as in bullet.
    //Every rigid body needs a collision shape. There exists no shape component for
    //planes yet. As a consequence we have to create a CustomShape component and attach
    //a PlaneCollisionShape to it. There is a factory in the background which converts this
    //collision shapes automatically to rigid objects. This collision shape could be very heavy (e.g. Terrain).
    //To circumvent this situation you could attach a custom factory and use small definition
    //objects. Examples concerning custom shape factories and more shape components will come.
    EntityId plane = entityData.createEntity();
    entityData.setComponents(plane,
            new RigidBody(false, 0),
            new CustomShape(new PlaneCollisionShape(new Plane(Vector3f.UNIT_Y.clone(), 0))));

    //Here a simple box is created. The box should fall down and therefore it has a mass of 10kg.
    //It will be spawned at the WarpPosition. The shape is a simple box with size 1x1x1m.
    EntityId box = entityData.createEntity();
    entityData.setComponents(box,
            new WarpPosition(new Vector3f(0,10,0), Quaternion.DIRECTION_Z.clone()),
            new RigidBody(false, 10),
            new BoxShape());

    //This is nearly the same as above. The box is spawned at (0,0,0) and it will be static
    //because it has no mass. It will have the same size as the other box because the half extents are
    //equal to the default ones.
    EntityId box2 = entityData.createEntity();
    entityData.setComponents(box2,
            new RigidBody(false, 0),
            new BoxShape(new Vector3f(0.5f, 0.5f, 0.5f)));

    //We could add a little force at the beginning to push the falling box slightly away.
    //The force is 10m/s^2 in each direction because the mass of the box is 10kg.
    //uncomment this line and notice the difference
    //entityData.setComponent(box, new Force(new Vector3f(100,100,100), new Vector3f()));

    //As you can see the whole system works unnoticeable in the background.
    //You add components and read components (e.g. PhysicsPosition) and you don't need to care anymore
    //how the physics is processed. Of course the physics system is accessible and
    //modifiable if you have advanced needs.

    //To see something we have to attach the bullet debug view. I didn't spend time to add fancy objects
    //which made things more complicated but there is a fancy debug view.
    //This is a very dirty way to attach the bullet debug view but we have to wait until
    //the ESBulletState is initialized. The task is called right after initialization of the esBulletState.
    ESBulletState esBulletState = stateManager.getState(ESBulletState.class);
    esBulletState.onInitialize(() -> {
        //Add Debug State to debug physics
        //As you see there are getters for physics space and so on.
        BulletDebugAppState debugAppState = new BulletDebugAppState(esBulletState.getPhysicsSpace());
        getStateManager().attach(debugAppState);
    });
}
 
开发者ID:jvpichowski,项目名称:ZayES-Bullet,代码行数:56,代码来源:BasicExample.java


示例9: PlaneCollisionShapeTreeNode

import com.jme3.bullet.collision.shapes.PlaneCollisionShape; //导入依赖的package包/类
public PlaneCollisionShapeTreeNode(@NotNull final PlaneCollisionShape element, final long objectId) {
    super(element, objectId);
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:4,代码来源:PlaneCollisionShapeTreeNode.java


示例10: simpleInitApp

import com.jme3.bullet.collision.shapes.PlaneCollisionShape; //导入依赖的package包/类
@Override
    public void simpleInitApp() {
        bulletAppState = new BulletAppState();
        stateManager.attach(bulletAppState);
        bulletAppState.getPhysicsSpace().enableDebug(assetManager);

        // Add a physics sphere to the world
        Node physicsSphere = PhysicsTestHelper.createPhysicsTestNode(assetManager, new SphereCollisionShape(1), 1);
        physicsSphere.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(3, 6, 0));
        rootNode.attachChild(physicsSphere);
        getPhysicsSpace().add(physicsSphere);

        // Add a physics sphere to the world using the collision shape from sphere one
        Node physicsSphere2 = PhysicsTestHelper.createPhysicsTestNode(assetManager, physicsSphere.getControl(RigidBodyControl.class).getCollisionShape(), 1);
        physicsSphere2.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(4, 8, 0));
        rootNode.attachChild(physicsSphere2);
        getPhysicsSpace().add(physicsSphere2);

        // Add a physics box to the world
        Node physicsBox = PhysicsTestHelper.createPhysicsTestNode(assetManager, new BoxCollisionShape(new Vector3f(1, 1, 1)), 1);
        physicsBox.getControl(RigidBodyControl.class).setFriction(0.1f);
        physicsBox.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(.6f, 4, .5f));
        rootNode.attachChild(physicsBox);
        getPhysicsSpace().add(physicsBox);

        // Add a physics cylinder to the world
        Node physicsCylinder = PhysicsTestHelper.createPhysicsTestNode(assetManager, new CylinderCollisionShape(new Vector3f(1f, 1f, 1.5f)), 1);
        physicsCylinder.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(2, 2, 0));
        rootNode.attachChild(physicsCylinder);
        getPhysicsSpace().add(physicsCylinder);

        // an obstacle mesh, does not move (mass=0)
        Node node2 = PhysicsTestHelper.createPhysicsTestNode(assetManager, new MeshCollisionShape(new Sphere(16, 16, 1.2f)), 0);
        node2.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(2.5f, -4, 0f));
        rootNode.attachChild(node2);
        getPhysicsSpace().add(node2);

        // the floor mesh, does not move (mass=0)
        Node node3 = PhysicsTestHelper.createPhysicsTestNode(assetManager, new PlaneCollisionShape(new Plane(new Vector3f(0, 1, 0), 0)), 0);
        node3.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(0f, -6, 0f));
        rootNode.attachChild(node3);
        getPhysicsSpace().add(node3);

        // Join the physics objects with a Point2Point joint
//        PhysicsPoint2PointJoint joint=new PhysicsPoint2PointJoint(physicsSphere, physicsBox, new Vector3f(-2,0,0), new Vector3f(2,0,0));
//        PhysicsHingeJoint joint=new PhysicsHingeJoint(physicsSphere, physicsBox, new Vector3f(-2,0,0), new Vector3f(2,0,0), Vector3f.UNIT_Z,Vector3f.UNIT_Z);
//        getPhysicsSpace().add(joint);

    }
 
开发者ID:mleoking,项目名称:PhET,代码行数:50,代码来源:TestSimplePhysics.java


示例11: simpleInitApp

import com.jme3.bullet.collision.shapes.PlaneCollisionShape; //导入依赖的package包/类
@Override
public void simpleInitApp() {
    bulletAppState = new BulletAppState();
    stateManager.attach(bulletAppState);
    bulletAppState.getPhysicsSpace().enableDebug(assetManager);
    physicsRootNode=new Node("PhysicsRootNode");
    rootNode.attachChild(physicsRootNode);

    // Add a physics sphere to the world
    Node physicsSphere = PhysicsTestHelper.createPhysicsTestNode(assetManager, new SphereCollisionShape(1), 1);
    physicsSphere.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(3, 6, 0));
    rootNode.attachChild(physicsSphere);
    getPhysicsSpace().add(physicsSphere);

    // Add a physics sphere to the world using the collision shape from sphere one
    Node physicsSphere2 = PhysicsTestHelper.createPhysicsTestNode(assetManager, physicsSphere.getControl(RigidBodyControl.class).getCollisionShape(), 1);
    physicsSphere2.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(4, 8, 0));
    rootNode.attachChild(physicsSphere2);
    getPhysicsSpace().add(physicsSphere2);

    // Add a physics box to the world
    Node physicsBox = PhysicsTestHelper.createPhysicsTestNode(assetManager, new BoxCollisionShape(new Vector3f(1, 1, 1)), 1);
    physicsBox.getControl(RigidBodyControl.class).setFriction(0.1f);
    physicsBox.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(.6f, 4, .5f));
    rootNode.attachChild(physicsBox);
    getPhysicsSpace().add(physicsBox);

    // Add a physics cylinder to the world
    Node physicsCylinder = PhysicsTestHelper.createPhysicsTestNode(assetManager, new CylinderCollisionShape(new Vector3f(1f, 1f, 1.5f)), 1);
    physicsCylinder.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(2, 2, 0));
    rootNode.attachChild(physicsCylinder);
    getPhysicsSpace().add(physicsCylinder);

    // an obstacle mesh, does not move (mass=0)
    Node node2 = PhysicsTestHelper.createPhysicsTestNode(assetManager, new MeshCollisionShape(new Sphere(16, 16, 1.2f)), 0);
    node2.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(2.5f, -4, 0f));
    rootNode.attachChild(node2);
    getPhysicsSpace().add(node2);

    // the floor mesh, does not move (mass=0)
    Node node3 = PhysicsTestHelper.createPhysicsTestNode(assetManager, new PlaneCollisionShape(new Plane(new Vector3f(0, 1, 0), 0)), 0);
    node3.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(0f, -6, 0f));
    rootNode.attachChild(node3);
    getPhysicsSpace().add(node3);

    // Join the physics objects with a Point2Point joint
    HingeJoint joint=new HingeJoint(physicsSphere.getControl(RigidBodyControl.class), physicsBox.getControl(RigidBodyControl.class), new Vector3f(-2,0,0), new Vector3f(2,0,0), Vector3f.UNIT_Z,Vector3f.UNIT_Z);
    getPhysicsSpace().add(joint);

    //save and load the physicsRootNode
    try {
        //remove all physics objects from physics space
        getPhysicsSpace().removeAll(physicsRootNode);
        physicsRootNode.removeFromParent();
        //export to byte array
        ByteArrayOutputStream bout=new ByteArrayOutputStream();
        BinaryExporter.getInstance().save(physicsRootNode, bout);
        //import from byte array
        ByteArrayInputStream bin=new ByteArrayInputStream(bout.toByteArray());
        BinaryImporter imp=BinaryImporter.getInstance();
        imp.setAssetManager(assetManager);
        Node newPhysicsRootNode=(Node)imp.load(bin);
        //add all physics objects to physics space
        getPhysicsSpace().addAll(newPhysicsRootNode);
        rootNode.attachChild(newPhysicsRootNode);
    } catch (IOException ex) {
        Logger.getLogger(TestPhysicsReadWrite.class.getName()).log(Level.SEVERE, null, ex);
    }

}
 
开发者ID:mleoking,项目名称:PhET,代码行数:71,代码来源:TestPhysicsReadWrite.java


示例12: simpleInitApp

import com.jme3.bullet.collision.shapes.PlaneCollisionShape; //导入依赖的package包/类
@Override
public void simpleInitApp() {

    bulletAppState = new BulletAppState();
    stateManager.attach(bulletAppState);
    bulletAppState.getPhysicsSpace().enableDebug(assetManager);
    // Add a physics sphere to the world
    Node physicsSphere = PhysicsTestHelper.createPhysicsTestNode(assetManager, new SphereCollisionShape(1), 1);
    physicsSphere.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(3, 6, 0));
    rootNode.attachChild(physicsSphere);

    //Setting the rigidBody to kinematic before adding it to the physic space
    physicsSphere.getControl(RigidBodyControl.class).setKinematic(true);
    //adding it to the physic space
    getPhysicsSpace().add(physicsSphere);         
    //Making it not kinematic again, it should fall under gravity, it doesn't
    physicsSphere.getControl(RigidBodyControl.class).setKinematic(false);

    // Add a physics sphere to the world using the collision shape from sphere one
    Node physicsSphere2 = PhysicsTestHelper.createPhysicsTestNode(assetManager, new SphereCollisionShape(1), 1);
    physicsSphere2.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(5, 6, 0));
    rootNode.attachChild(physicsSphere2);
    
    //Adding the rigid body to physic space
    getPhysicsSpace().add(physicsSphere2);
    //making it kinematic
    physicsSphere2.getControl(RigidBodyControl.class).setKinematic(false);
    //Making it not kinematic again, it works properly, the rigidbody is affected by grvity.
    physicsSphere2.getControl(RigidBodyControl.class).setKinematic(false);

  

    // an obstacle mesh, does not move (mass=0)
    Node node2 = PhysicsTestHelper.createPhysicsTestNode(assetManager, new MeshCollisionShape(new Sphere(16, 16, 1.2f)), 0);
    node2.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(2.5f, -4, 0f));
    rootNode.attachChild(node2);
    getPhysicsSpace().add(node2);

    // the floor mesh, does not move (mass=0)
    Node node3 = PhysicsTestHelper.createPhysicsTestNode(assetManager, new PlaneCollisionShape(new Plane(new Vector3f(0, 1, 0), 0)), 0);
    node3.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(0f, -6, 0f));
    rootNode.attachChild(node3);
    getPhysicsSpace().add(node3);

}
 
开发者ID:mleoking,项目名称:PhET,代码行数:46,代码来源:TestKinematicAddToPhysicsSpaceIssue.java


示例13: simpleInitApp

import com.jme3.bullet.collision.shapes.PlaneCollisionShape; //导入依赖的package包/类
@Override
    public void simpleInitApp() {
        bulletAppState = new BulletAppState();
        stateManager.attach(bulletAppState);
        bulletAppState.getPhysicsSpace().enableDebug(assetManager);

        // Add a physics sphere to the world
        Node physicsSphere = PhysicsTestHelper.createPhysicsTestNode(assetManager, new SphereCollisionShape(1), 1);
        physicsSphere.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(3, 6, 0));
        physicsSphere.getControl(RigidBodyControl.class).setApplyPhysicsLocal(true);
        rootNode.attachChild(physicsSphere);
        getPhysicsSpace().add(physicsSphere);

        // Add a physics sphere to the world using the collision shape from sphere one
        Node physicsSphere2 = PhysicsTestHelper.createPhysicsTestNode(assetManager, physicsSphere.getControl(RigidBodyControl.class).getCollisionShape(), 1);
        physicsSphere2.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(4, 8, 0));
        physicsSphere2.getControl(RigidBodyControl.class).setApplyPhysicsLocal(true);
        rootNode.attachChild(physicsSphere2);
        getPhysicsSpace().add(physicsSphere2);

        // Add a physics box to the world
        Node physicsBox = PhysicsTestHelper.createPhysicsTestNode(assetManager, new BoxCollisionShape(new Vector3f(1, 1, 1)), 1);
        physicsBox.getControl(RigidBodyControl.class).setFriction(0.1f);
        physicsBox.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(.6f, 4, .5f));
        physicsBox.getControl(RigidBodyControl.class).setApplyPhysicsLocal(true);
        rootNode.attachChild(physicsBox);
        getPhysicsSpace().add(physicsBox);

        // Add a physics cylinder to the world
        Node physicsCylinder = PhysicsTestHelper.createPhysicsTestNode(assetManager, new CylinderCollisionShape(new Vector3f(1f, 1f, 1.5f)), 1);
        physicsCylinder.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(2, 2, 0));
        physicsCylinder.getControl(RigidBodyControl.class).setApplyPhysicsLocal(true);
        rootNode.attachChild(physicsCylinder);
        getPhysicsSpace().add(physicsCylinder);

        // an obstacle mesh, does not move (mass=0)
        Node node2 = PhysicsTestHelper.createPhysicsTestNode(assetManager, new MeshCollisionShape(new Sphere(16, 16, 1.2f)), 0);
        node2.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(2.5f, -4, 0f));
        node2.getControl(RigidBodyControl.class).setApplyPhysicsLocal(true);
        rootNode.attachChild(node2);
        getPhysicsSpace().add(node2);

        // the floor mesh, does not move (mass=0)
        Node node3 = PhysicsTestHelper.createPhysicsTestNode(assetManager, new PlaneCollisionShape(new Plane(new Vector3f(0, 1, 0), 0)), 0);
        node3.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(0f, -6, 0f));
        node3.getControl(RigidBodyControl.class).setApplyPhysicsLocal(true);
        rootNode.attachChild(node3);
        getPhysicsSpace().add(node3);

        // Join the physics objects with a Point2Point joint
//        PhysicsPoint2PointJoint joint=new PhysicsPoint2PointJoint(physicsSphere, physicsBox, new Vector3f(-2,0,0), new Vector3f(2,0,0));
//        PhysicsHingeJoint joint=new PhysicsHingeJoint(physicsSphere, physicsBox, new Vector3f(-2,0,0), new Vector3f(2,0,0), Vector3f.UNIT_Z,Vector3f.UNIT_Z);
//        getPhysicsSpace().add(joint);

    }
 
开发者ID:mleoking,项目名称:PhET,代码行数:56,代码来源:TestLocalPhysics.java



注:本文中的com.jme3.bullet.collision.shapes.PlaneCollisionShape类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java RequestHandler类代码示例发布时间:2022-05-23
下一篇:
Java ChannelBufferBytesReference类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap