@Override public Object jmeClone() { CharacterControl control = new CharacterControl(collisionShape, stepHeight); control.setCcdMotionThreshold(getCcdMotionThreshold()); control.setCcdSweptSphereRadius(getCcdSweptSphereRadius()); control.setCollideWithGroups(getCollideWithGroups()); control.setCollisionGroup(getCollisionGroup()); control.setContactResponse(isContactResponse()); control.setFallSpeed(getFallSpeed()); control.setGravity(getGravity()); control.setJumpSpeed(getJumpSpeed()); control.setMaxSlope(getMaxSlope()); control.setPhysicsLocation(getPhysicsLocation()); control.setUpAxis(getUpAxis()); control.setApplyPhysicsLocal(isApplyPhysicsLocal()); control.spatial = this.spatial; control.setEnabled(isEnabled()); return control; }
public void setSpatial(Spatial spatial) { this.spatial = spatial; setUserObject(spatial); if (spatial == null) { return; } setPhysicsLocation(getSpatialTranslation()); }
TerrainGridTileLoaderTest.this.player3.jump(); } else if (name.equals("pick") && keyPressed) { System.out.println("** cell "+player3.getPhysicsLocation()+" picked terrain: "+picked);
player = new CharacterControl(capsuleShape, 0.05f); player.setJumpSpeed(20); player.setFallSpeed(30); player.setGravity(30); player.setPhysicsLocation(new Vector3f(0, 10, 0));
@Override public void simpleUpdate(final float tpf) { Vector3f camDir = this.cam.getDirection().clone().multLocal(0.6f); Vector3f camLeft = this.cam.getLeft().clone().multLocal(0.4f); this.walkDirection.set(0, 0, 0); if (this.left) { this.walkDirection.addLocal(camLeft); } if (this.right) { this.walkDirection.addLocal(camLeft.negate()); } if (this.up) { this.walkDirection.addLocal(camDir); } if (this.down) { this.walkDirection.addLocal(camDir.negate()); } if (usePhysics) { this.player3.setWalkDirection(this.walkDirection); this.cam.setLocation(this.player3.getPhysicsLocation()); } }
public void setSpatial(Spatial spatial) { if (getUserObject() == null || getUserObject() == this.spatial) { setUserObject(spatial); } this.spatial = spatial; if (spatial == null) { if (getUserObject() == spatial) { setUserObject(null); } return; } setPhysicsLocation(getSpatialTranslation()); }
private void createCharacter() { CapsuleCollisionShape capsule = new CapsuleCollisionShape(3f, 4f); character = new CharacterControl(capsule, 0.01f); model = (Node) assetManager.loadModel("Models/Oto/OtoOldAnim.j3o"); //model.setLocalScale(0.5f); model.addControl(character); character.setPhysicsLocation(new Vector3f(-140, 40, -10)); rootNode.attachChild(model); getPhysicsSpace().add(character); }
public void update(float tpf) { if (enabled && spatial != null) { Quaternion localRotationQuat = spatial.getLocalRotation(); Vector3f localLocation = spatial.getLocalTranslation(); if (!applyLocal && spatial.getParent() != null) { getPhysicsLocation(localLocation); localLocation.subtractLocal(spatial.getParent().getWorldTranslation()); localLocation.divideLocal(spatial.getParent().getWorldScale()); tmp_inverseWorldRotation.set(spatial.getParent().getWorldRotation()).inverseLocal().multLocal(localLocation); spatial.setLocalTranslation(localLocation); if (useViewDirection) { localRotationQuat.lookAt(viewDirection, Vector3f.UNIT_Y); spatial.setLocalRotation(localRotationQuat); } } else { spatial.setLocalTranslation(getPhysicsLocation()); localRotationQuat.lookAt(viewDirection, Vector3f.UNIT_Y); spatial.setLocalRotation(localRotationQuat); } } }
public void render(RenderManager rm, ViewPort vp) { if (enabled && space != null && space.getDebugManager() != null) { if (debugShape == null) { attachDebugShape(space.getDebugManager()); } debugShape.setLocalTranslation(getPhysicsLocation()); debugShape.updateLogicalState(0); debugShape.updateGeometricState(); rm.renderScene(debugShape, vp); } }
player3 = new CharacterControl(capsuleShape, 0.5f); player3.setJumpSpeed(20); player3.setFallSpeed(10); player3.setGravity(10); player3.setPhysicsLocation(new Vector3f(cam.getLocation().x, 256, cam.getLocation().z));
public void setSpatial(Spatial spatial) { this.spatial = spatial; setUserObject(spatial); if (spatial == null) { return; } setPhysicsLocation(getSpatialTranslation()); }
@Override public void simpleUpdate(final float tpf) { Vector3f camDir = this.cam.getDirection().clone().multLocal(0.6f); Vector3f camLeft = this.cam.getLeft().clone().multLocal(0.4f); this.walkDirection.set(0, 0, 0); if (this.left) { this.walkDirection.addLocal(camLeft); } if (this.right) { this.walkDirection.addLocal(camLeft.negate()); } if (this.up) { this.walkDirection.addLocal(camDir); } if (this.down) { this.walkDirection.addLocal(camDir.negate()); } if (usePhysics) { this.player3.setWalkDirection(this.walkDirection); this.cam.setLocation(this.player3.getPhysicsLocation()); } } }
@Override public void simpleInitApp() { // activate physics bulletAppState = new BulletAppState(); stateManager.attach(bulletAppState); // init a physical test scene PhysicsTestHelper.createPhysicsTestWorldSoccer(rootNode, assetManager, bulletAppState.getPhysicsSpace()); setupKeys(); // Add a physics character to the world physicsCharacter = new CharacterControl(new CapsuleCollisionShape(0.5f, 1.8f), .1f); physicsCharacter.setPhysicsLocation(new Vector3f(0, 1, 0)); characterNode = new Node("character node"); Spatial model = assetManager.loadModel("Models/Sinbad/Sinbad.mesh.xml"); model.scale(0.25f); characterNode.addControl(physicsCharacter); getPhysicsSpace().add(physicsCharacter); rootNode.attachChild(characterNode); characterNode.attachChild(model); // set forward camera node that follows the character camNode = new CameraNode("CamNode", cam); camNode.setControlDir(ControlDirection.SpatialToCamera); camNode.setLocalTranslation(new Vector3f(0, 1, -5)); camNode.lookAt(model.getLocalTranslation(), Vector3f.UNIT_Y); characterNode.attachChild(camNode); //disable the default 1st-person flyCam (don't forget this!!) flyCam.setEnabled(false); }
public void update(float tpf) { if (enabled && spatial != null) { Quaternion localRotationQuat = spatial.getLocalRotation(); Vector3f localLocation = spatial.getLocalTranslation(); if (!applyLocal && spatial.getParent() != null) { getPhysicsLocation(localLocation); localLocation.subtractLocal(spatial.getParent().getWorldTranslation()); localLocation.divideLocal(spatial.getParent().getWorldScale()); tmp_inverseWorldRotation.set(spatial.getParent().getWorldRotation()).inverseLocal().multLocal(localLocation); spatial.setLocalTranslation(localLocation); if (useViewDirection) { localRotationQuat.lookAt(viewDirection, Vector3f.UNIT_Y); spatial.setLocalRotation(localRotationQuat); } } else { spatial.setLocalTranslation(getPhysicsLocation()); localRotationQuat.lookAt(viewDirection, Vector3f.UNIT_Y); spatial.setLocalRotation(localRotationQuat); } } }
@Override public Object jmeClone() { CharacterControl control = new CharacterControl(collisionShape, stepHeight); control.setCcdMotionThreshold(getCcdMotionThreshold()); control.setCcdSweptSphereRadius(getCcdSweptSphereRadius()); control.setCollideWithGroups(getCollideWithGroups()); control.setCollisionGroup(getCollisionGroup()); control.setContactResponse(isContactResponse()); control.setFallSpeed(getFallSpeed()); control.setGravity(getGravity()); control.setJumpSpeed(getJumpSpeed()); control.setMaxSlope(getMaxSlope()); control.setPhysicsLocation(getPhysicsLocation()); control.setUpAxis(getUpAxis()); control.setApplyPhysicsLocal(isApplyPhysicsLocal()); control.spatial = this.spatial; control.setEnabled(isEnabled()); return control; }
player = new CharacterControl(capsuleShape, 0.05f); player.setJumpSpeed(20); player.setFallSpeed(30); player.setGravity(30); player.setPhysicsLocation(new Vector3f(-10, 10, 10));
public void setSpatial(Spatial spatial) { this.spatial = spatial; setUserObject(spatial); if (spatial == null) { return; } setPhysicsLocation(getSpatialTranslation()); }
@Override public void simpleUpdate(final float tpf) { Vector3f camDir = this.cam.getDirection().clone().multLocal(0.6f); Vector3f camLeft = this.cam.getLeft().clone().multLocal(0.4f); this.walkDirection.set(0, 0, 0); if (this.left) { this.walkDirection.addLocal(camLeft); } if (this.right) { this.walkDirection.addLocal(camLeft.negate()); } if (this.up) { this.walkDirection.addLocal(camDir); } if (this.down) { this.walkDirection.addLocal(camDir.negate()); } if (usePhysics) { this.player3.setWalkDirection(this.walkDirection); this.cam.setLocation(this.player3.getPhysicsLocation()); } } }
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); }
@Override public Control cloneForSpatial(Spatial spatial) { CharacterControl control = new CharacterControl(collisionShape, stepHeight); control.setCcdMotionThreshold(getCcdMotionThreshold()); control.setCcdSweptSphereRadius(getCcdSweptSphereRadius()); control.setCollideWithGroups(getCollideWithGroups()); control.setCollisionGroup(getCollisionGroup()); control.setFallSpeed(getFallSpeed()); control.setGravity(getGravity()); control.setJumpSpeed(getJumpSpeed()); control.setMaxSlope(getMaxSlope()); control.setPhysicsLocation(getPhysicsLocation()); control.setUpAxis(getUpAxis()); control.setApplyPhysicsLocal(isApplyPhysicsLocal()); return control; }