com.jme3.bullet.collision.shapes.PlaneCollisionShape Java Examples
The following examples show how to use
com.jme3.bullet.collision.shapes.PlaneCollisionShape.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PlaneCollisionShapeTreeNode.java From jmonkeybuilder with Apache License 2.0 | 4 votes |
public PlaneCollisionShapeTreeNode(@NotNull final PlaneCollisionShape element, final long objectId) { super(element, objectId); }
Example #2
Source File: TestKinematicAddToPhysicsSpaceIssue.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public void simpleInitApp() { bulletAppState = new BulletAppState(); stateManager.attach(bulletAppState); bulletAppState.setDebugEnabled(true); // 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 physics space physicsSphere.getControl(RigidBodyControl.class).setKinematic(true); //adding it to the physics 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 physics 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); }
Example #3
Source File: TestSimplePhysics.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
@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); }
Example #4
Source File: TestPhysicsReadWrite.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
@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); } }
Example #5
Source File: TestKinematicAddToPhysicsSpaceIssue.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
@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); }
Example #6
Source File: TestLocalPhysics.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
@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); }