use of com.jme3.bullet.control.RigidBodyControl in project jmonkeyengine by jMonkeyEngine.
the class TestBrickWall method initFloor.
public void initFloor() {
Box floorBox = new Box(10f, 0.1f, 5f);
floorBox.scaleTextureCoordinates(new Vector2f(3, 6));
Geometry floor = new Geometry("floor", floorBox);
floor.setMaterial(mat3);
floor.setShadowMode(ShadowMode.Receive);
floor.setLocalTranslation(0, -0.1f, 0);
floor.addControl(new RigidBodyControl(new BoxCollisionShape(new Vector3f(10f, 0.1f, 5f)), 0));
this.rootNode.attachChild(floor);
this.getPhysicsSpace().add(floor);
}
use of com.jme3.bullet.control.RigidBodyControl in project jmonkeyengine by jMonkeyEngine.
the class TestBrickWall method addBrick.
public void addBrick(Vector3f ori) {
Geometry reBoxg = new Geometry("brick", brick);
reBoxg.setMaterial(mat);
reBoxg.setLocalTranslation(ori);
//for geometry with sphere mesh the physics system automatically uses a sphere collision shape
reBoxg.addControl(new RigidBodyControl(1.5f));
reBoxg.setShadowMode(ShadowMode.CastAndReceive);
reBoxg.getControl(RigidBodyControl.class).setFriction(0.6f);
this.rootNode.attachChild(reBoxg);
this.getPhysicsSpace().add(reBoxg);
}
use of com.jme3.bullet.control.RigidBodyControl in project jmonkeyengine by jMonkeyEngine.
the class TestCcd method simpleInitApp.
@Override
public void simpleInitApp() {
bulletAppState = new BulletAppState();
stateManager.attach(bulletAppState);
bulletAppState.setDebugEnabled(true);
bullet = new Sphere(32, 32, 0.4f, true, false);
bullet.setTextureMode(TextureMode.Projected);
bulletCollisionShape = new SphereCollisionShape(0.1f);
setupKeys();
mat = new Material(getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
mat.getAdditionalRenderState().setWireframe(true);
mat.setColor("Color", ColorRGBA.Green);
mat2 = new Material(getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
mat2.getAdditionalRenderState().setWireframe(true);
mat2.setColor("Color", ColorRGBA.Red);
// An obstacle mesh, does not move (mass=0)
Node node2 = new Node();
node2.setName("mesh");
node2.setLocalTranslation(new Vector3f(2.5f, 0, 0f));
node2.addControl(new RigidBodyControl(new MeshCollisionShape(new Box(4, 4, 0.1f)), 0));
rootNode.attachChild(node2);
getPhysicsSpace().add(node2);
// The floor, does not move (mass=0)
Node node3 = new Node();
node3.setLocalTranslation(new Vector3f(0f, -6, 0f));
node3.addControl(new RigidBodyControl(new BoxCollisionShape(new Vector3f(100, 1, 100)), 0));
rootNode.attachChild(node3);
getPhysicsSpace().add(node3);
}
use of com.jme3.bullet.control.RigidBodyControl in project jmonkeyengine by jMonkeyEngine.
the class TestCollisionShapeFactory method simpleInitApp.
@Override
public void simpleInitApp() {
bulletAppState = new BulletAppState();
stateManager.attach(bulletAppState);
bulletAppState.setDebugEnabled(true);
createMaterial();
Node node = new Node("node1");
attachRandomGeometry(node, mat1);
randomizeTransform(node);
Node node2 = new Node("node2");
attachRandomGeometry(node2, mat2);
randomizeTransform(node2);
node.attachChild(node2);
rootNode.attachChild(node);
RigidBodyControl control = new RigidBodyControl(0);
node.addControl(control);
getPhysicsSpace().add(control);
//test single geometry too
Geometry myGeom = new Geometry("cylinder", new Cylinder(16, 16, 0.5f, 1));
myGeom.setMaterial(mat3);
randomizeTransform(myGeom);
rootNode.attachChild(myGeom);
RigidBodyControl control3 = new RigidBodyControl(0);
myGeom.addControl(control3);
getPhysicsSpace().add(control3);
}
use of com.jme3.bullet.control.RigidBodyControl in project jmonkeyengine by jMonkeyEngine.
the class TestWalkingChar method bulletControl.
private void bulletControl() {
shootingChannel.setAnim("Dodge", 0.1f);
shootingChannel.setLoopMode(LoopMode.DontLoop);
Geometry bulletg = new Geometry("bullet", bullet);
bulletg.setMaterial(matBullet);
bulletg.setShadowMode(ShadowMode.CastAndReceive);
bulletg.setLocalTranslation(character.getPhysicsLocation().add(cam.getDirection().mult(5)));
RigidBodyControl bulletControl = new BombControl(bulletCollisionShape, 1);
bulletControl.setCcdMotionThreshold(0.1f);
bulletControl.setLinearVelocity(cam.getDirection().mult(80));
bulletg.addControl(bulletControl);
rootNode.attachChild(bulletg);
getPhysicsSpace().add(bulletControl);
}
Aggregations