use of com.jme3.scene.Node in project jmonkeyengine by jMonkeyEngine.
the class TestRagDoll method createLimb.
private Node createLimb(float width, float height, Vector3f location, boolean rotate) {
int axis = rotate ? PhysicsSpace.AXIS_X : PhysicsSpace.AXIS_Y;
CapsuleCollisionShape shape = new CapsuleCollisionShape(width, height, axis);
Node node = new Node("Limb");
RigidBodyControl rigidBodyControl = new RigidBodyControl(shape, 1);
node.setLocalTranslation(location);
node.addControl(rigidBodyControl);
return node;
}
use of com.jme3.scene.Node in project jmonkeyengine by jMonkeyEngine.
the class TestRagDoll method join.
private PhysicsJoint join(Node A, Node B, Vector3f connectionPoint) {
Vector3f pivotA = A.worldToLocal(connectionPoint, new Vector3f());
Vector3f pivotB = B.worldToLocal(connectionPoint, new Vector3f());
ConeJoint joint = new ConeJoint(A.getControl(RigidBodyControl.class), B.getControl(RigidBodyControl.class), pivotA, pivotB);
joint.setLimit(1f, 1f, 0);
return joint;
}
use of com.jme3.scene.Node in project jmonkeyengine by jMonkeyEngine.
the class TestRagdollCharacter method simpleInitApp.
public void simpleInitApp() {
setupKeys();
bulletAppState = new BulletAppState();
bulletAppState.setEnabled(true);
stateManager.attach(bulletAppState);
// bulletAppState.getPhysicsSpace().enableDebug(assetManager);
PhysicsTestHelper.createPhysicsTestWorld(rootNode, assetManager, bulletAppState.getPhysicsSpace());
initWall(2, 1, 1);
setupLight();
cam.setLocation(new Vector3f(-8, 0, -4));
cam.lookAt(new Vector3f(4, 0, -7), Vector3f.UNIT_Y);
model = (Node) assetManager.loadModel("Models/Sinbad/Sinbad.mesh.xml");
model.lookAt(new Vector3f(0, 0, -1), Vector3f.UNIT_Y);
model.setLocalTranslation(4, 0, -7f);
ragdoll = new KinematicRagdollControl(0.5f);
model.addControl(ragdoll);
getPhysicsSpace().add(ragdoll);
speed = 1.3f;
rootNode.attachChild(model);
AnimControl control = model.getControl(AnimControl.class);
animChannel = control.createChannel();
animChannel.setAnim("IdleTop");
control.addListener(this);
}
use of com.jme3.scene.Node in project jmonkeyengine by jMonkeyEngine.
the class TestSweepTest method simpleInitApp.
@Override
public void simpleInitApp() {
obstacleCollisionShape = new CapsuleCollisionShape(0.3f, 0.5f);
capsuleCollisionShape = new CapsuleCollisionShape(1f, 1f);
stateManager.attach(bulletAppState);
capsule = new Node("capsule");
capsule.move(-2, 0, 0);
capsule.addControl(new RigidBodyControl(capsuleCollisionShape, 1));
capsule.getControl(RigidBodyControl.class).setKinematic(true);
bulletAppState.getPhysicsSpace().add(capsule);
rootNode.attachChild(capsule);
obstacle = new Node("obstacle");
obstacle.move(2, 0, 0);
RigidBodyControl bodyControl = new RigidBodyControl(obstacleCollisionShape, 0);
obstacle.addControl(bodyControl);
bulletAppState.getPhysicsSpace().add(obstacle);
rootNode.attachChild(obstacle);
bulletAppState.setDebugEnabled(true);
}
use of com.jme3.scene.Node in project jmonkeyengine by jMonkeyEngine.
the class TestPhysicsRayCast method simpleInitApp.
@Override
public void simpleInitApp() {
stateManager.attach(bulletAppState);
initCrossHair();
Spatial s = assetManager.loadModel("Models/Elephant/Elephant.mesh.xml");
s.setLocalScale(0.1f);
CollisionShape collisionShape = CollisionShapeFactory.createMeshShape(s);
Node n = new Node("elephant");
n.addControl(new RigidBodyControl(collisionShape, 1));
n.getControl(RigidBodyControl.class).setKinematic(true);
bulletAppState.getPhysicsSpace().add(n);
rootNode.attachChild(n);
bulletAppState.setDebugEnabled(true);
}
Aggregations