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); }
public void onAction(String binding, boolean value, float tpf) { if (binding.equals("shoot") && !value) { Geometry bulletg = new Geometry("bullet", bullet); bulletg.setMaterial(mat); bulletg.setName("bullet"); bulletg.setLocalTranslation(cam.getLocation()); bulletg.setShadowMode(ShadowMode.CastAndReceive); bulletg.addControl(new RigidBodyControl(bulletCollisionShape, 1)); bulletg.getControl(RigidBodyControl.class).setCcdMotionThreshold(0.1f); bulletg.getControl(RigidBodyControl.class).setLinearVelocity(cam.getDirection().mult(40)); rootNode.attachChild(bulletg); getPhysicsSpace().add(bulletg); } else if (binding.equals("shoot2") && !value) { Geometry bulletg = new Geometry("bullet", bullet); bulletg.setMaterial(mat2); bulletg.setName("bullet"); bulletg.setLocalTranslation(cam.getLocation()); bulletg.setShadowMode(ShadowMode.CastAndReceive); bulletg.addControl(new RigidBodyControl(bulletCollisionShape, 1)); bulletg.getControl(RigidBodyControl.class).setLinearVelocity(cam.getDirection().mult(40)); rootNode.attachChild(bulletg); getPhysicsSpace().add(bulletg); } } }
bulletCollisionShape = new SphereCollisionShape(bulletSize); RigidBodyControl bulletNode = new RigidBodyControl(bulletCollisionShape, bulletSize * 10); bulletNode.setCcdMotionThreshold(0.001f); bulletNode.setLinearVelocity(cam.getDirection().mult(80)); bulletg.addControl(bulletNode);
control.setAngularFactor(getAngularFactor()); control.setAngularSleepingThreshold(getAngularSleepingThreshold()); control.setCcdMotionThreshold(getCcdMotionThreshold()); control.setCcdSweptSphereRadius(getCcdSweptSphereRadius()); control.setCollideWithGroups(getCollideWithGroups());
control.setAngularFactor(getAngularFactor()); control.setAngularSleepingThreshold(getAngularSleepingThreshold()); control.setCcdMotionThreshold(getCcdMotionThreshold()); control.setCcdSweptSphereRadius(getCcdSweptSphereRadius()); control.setCollideWithGroups(getCollideWithGroups());
private RigidBodyControl makeRegularProjectileCollider() { SphereCollisionShape projCollisionShape = new SphereCollisionShape(myProjectileSize); float projectileMass = 10 * myProjectileSize; RigidBodyControl prjctlRBC = new RigidBodyControl(projCollisionShape, projectileMass); prjctlRBC.setCcdMotionThreshold(CCD_MOTION_THRESH); return prjctlRBC; } public void cmdBiggerProjectile() {
@Override public void visit(Spatial spat) { RigidBodyControl rbc = spat.getControl(RigidBodyControl.class); if (rbc != null) { rbc.setSleepingThresholds(linear, angular); rbc.setCcdMotionThreshold(threshold); rbc.setCcdSweptSphereRadius(radius); } } };
@Override public Control cloneForSpatial(Spatial spatial) { RigidBodyControl control = new RigidBodyControl(collisionShape, mass); control.setAngularFactor(getAngularFactor()); control.setAngularSleepingThreshold(getAngularSleepingThreshold()); control.setCcdMotionThreshold(getCcdMotionThreshold()); control.setCcdSweptSphereRadius(getCcdSweptSphereRadius()); control.setCollideWithGroups(getCollideWithGroups()); control.setCollisionGroup(getCollisionGroup()); control.setDamping(getLinearDamping(), getAngularDamping()); control.setFriction(getFriction()); control.setGravity(getGravity()); control.setKinematic(isKinematic()); control.setKinematicSpatial(isKinematicSpatial()); control.setLinearSleepingThreshold(getLinearSleepingThreshold()); control.setPhysicsLocation(getPhysicsLocation(null)); control.setPhysicsRotation(getPhysicsRotationMatrix(null)); control.setRestitution(getRestitution()); if (mass > 0) { control.setAngularVelocity(getAngularVelocity()); control.setLinearVelocity(getLinearVelocity()); } control.setApplyPhysicsLocal(isApplyPhysicsLocal()); return control; }
public Control cloneForSpatial(Spatial spatial) { RigidBodyControl control = new RigidBodyControl(collisionShape, mass); control.setAngularFactor(getAngularFactor()); control.setAngularSleepingThreshold(getAngularSleepingThreshold()); control.setCcdMotionThreshold(getCcdMotionThreshold()); control.setCcdSweptSphereRadius(getCcdSweptSphereRadius()); control.setCollideWithGroups(getCollideWithGroups()); control.setCollisionGroup(getCollisionGroup()); control.setDamping(getLinearDamping(), getAngularDamping()); control.setFriction(getFriction()); control.setGravity(getGravity()); control.setKinematic(isKinematic()); control.setKinematicSpatial(isKinematicSpatial()); control.setLinearSleepingThreshold(getLinearSleepingThreshold()); control.setPhysicsLocation(getPhysicsLocation(null)); control.setPhysicsRotation(getPhysicsRotationMatrix(null)); control.setRestitution(getRestitution()); if (mass > 0) { control.setAngularVelocity(getAngularVelocity()); control.setLinearVelocity(getLinearVelocity()); } control.setApplyPhysicsLocal(isApplyPhysicsLocal()); control.setSpatial(spatial); return control; }
control.setAngularFactor(getAngularFactor()); control.setAngularSleepingThreshold(getAngularSleepingThreshold()); control.setCcdMotionThreshold(getCcdMotionThreshold()); control.setCcdSweptSphereRadius(getCcdSweptSphereRadius()); control.setCollideWithGroups(getCollideWithGroups());
@Override public Object jmeClone() { RigidBodyControl control = new RigidBodyControl(collisionShape, mass); control.setAngularFactor(getAngularFactor()); control.setAngularSleepingThreshold(getAngularSleepingThreshold()); control.setCcdMotionThreshold(getCcdMotionThreshold()); control.setCcdSweptSphereRadius(getCcdSweptSphereRadius()); control.setCollideWithGroups(getCollideWithGroups()); control.setCollisionGroup(getCollisionGroup()); control.setDamping(getLinearDamping(), getAngularDamping()); control.setFriction(getFriction()); control.setGravity(getGravity()); control.setKinematic(isKinematic()); control.setKinematicSpatial(isKinematicSpatial()); control.setLinearSleepingThreshold(getLinearSleepingThreshold()); control.setPhysicsLocation(getPhysicsLocation(null)); control.setPhysicsRotation(getPhysicsRotationMatrix(null)); control.setRestitution(getRestitution()); if (mass > 0) { control.setAngularVelocity(getAngularVelocity()); control.setLinearVelocity(getLinearVelocity()); } control.setApplyPhysicsLocal(isApplyPhysicsLocal()); control.spatial = this.spatial; control.setEnabled(isEnabled()); return control; }
control.setAngularFactor(getAngularFactor()); control.setAngularSleepingThreshold(getAngularSleepingThreshold()); control.setCcdMotionThreshold(getCcdMotionThreshold()); control.setCcdSweptSphereRadius(getCcdSweptSphereRadius()); control.setCollideWithGroups(getCollideWithGroups());