System.out.println("** cell "+player3.getPhysicsLocation()+" picked terrain: "+picked);
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 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); } } }
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 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 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 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 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()); } } }
/** * This is the main event loop--walking happens here. * We check in which direction the player is walking by interpreting * the camera direction forward (camDir) and to the side (camLeft). * The setWalkDirection() command is what lets a physics-controlled player walk. * We also make sure here that the camera moves with player. */ @Override public void simpleUpdate(float tpf) { camDir.set(cam.getDirection()).multLocal(0.6f); camLeft.set(cam.getLeft()).multLocal(0.4f); walkDirection.set(0, 0, 0); if (left) { walkDirection.addLocal(camLeft); } if (right) { walkDirection.addLocal(camLeft.negate()); } if (up) { walkDirection.addLocal(camDir); } if (down) { walkDirection.addLocal(camDir.negate()); } player.setWalkDirection(walkDirection); cam.setLocation(player.getPhysicsLocation()); } }
/** * This is the main event loop--walking happens here. * We check in which direction the player is walking by interpreting * the camera direction forward (camDir) and to the side (camLeft). * The setWalkDirection() command is what lets a physics-controlled player walk. * We also make sure here that the camera moves with player. */ @Override public void simpleUpdate(float tpf) { camDir.set(cam.getDirection()).multLocal(0.6f); camLeft.set(cam.getLeft()).multLocal(0.4f); walkDirection.set(0, 0, 0); if (left) { walkDirection.addLocal(camLeft); } if (right) { walkDirection.addLocal(camLeft.negate()); } if (up) { walkDirection.addLocal(camDir); } if (down) { walkDirection.addLocal(camDir.negate()); } player.setWalkDirection(walkDirection); cam.setLocation(player.getPhysicsLocation()); } }
@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; }
@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 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); } }
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 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 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; }
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()); control.setSpatial(spatial); return control; }
@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; }
@Override public Object jmeClone() { 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()); control.spatial = this.spatial; control.setEnabled(isEnabled()); return control; }
@Override public Object jmeClone() { 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()); control.spatial = this.spatial; control.setEnabled(isEnabled()); return control; }