/** * Instantiate an enabled control to visualize the specified character. * * @param debugAppState which app state (not null, alias created) * @param body the character to visualize (not null, alias created) */ public BulletCharacterDebugControl(BulletDebugAppState debugAppState, PhysicsCharacter body) { super(debugAppState); this.body = body; myShape = body.getCollisionShape(); oldScale.set(myShape.getScale()); this.geom = DebugShapeFactory.getDebugShape(myShape); this.geom.setName(body.toString()); geom.setMaterial(debugAppState.DEBUG_PINK); }
/** * Instantiate an enabled control to visualize the specified character. * * @param debugAppState which app state (not null, alias created) * @param body the character to visualize (not null, alias created) */ public BulletCharacterDebugControl(BulletDebugAppState debugAppState, PhysicsCharacter body) { super(debugAppState); this.body = body; myShape = body.getCollisionShape(); oldScale.set(myShape.getScale()); this.geom = DebugShapeFactory.getDebugShape(myShape); this.geom.setName(body.toString()); geom.setMaterial(debugAppState.DEBUG_PINK); }
/** * Instantiate an enabled control to visualize the specified ghost object. * * @param debugAppState which app state (not null, alias created) * @param body which object to visualize (not null, alias created) */ public BulletGhostObjectDebugControl(BulletDebugAppState debugAppState, PhysicsGhostObject body) { super(debugAppState); this.body = body; myShape = body.getCollisionShape(); oldScale.set(myShape.getScale()); this.geom = DebugShapeFactory.getDebugShape(myShape); this.geom.setName(body.toString()); geom.setMaterial(debugAppState.DEBUG_YELLOW); }
/** * Instantiate an enabled control to visualize the specified body. * * @param debugAppState which app state (not null, alias created) * @param body which body to visualize (not null, alias created) */ public BulletRigidBodyDebugControl(BulletDebugAppState debugAppState, PhysicsRigidBody body) { super(debugAppState); this.body = body; myShape = body.getCollisionShape(); oldScale.set(myShape.getScale()); this.geom = DebugShapeFactory.getDebugShape(myShape); this.geom.setName(body.toString()); geom.setMaterial(debugAppState.DEBUG_BLUE); }
/** * Instantiate an enabled control to visualize the specified ghost object. * * @param debugAppState which app state (not null, alias created) * @param body which object to visualize (not null, alias created) */ public BulletGhostObjectDebugControl(BulletDebugAppState debugAppState, PhysicsGhostObject body) { super(debugAppState); this.body = body; myShape = body.getCollisionShape(); oldScale.set(myShape.getScale()); this.geom = DebugShapeFactory.getDebugShape(myShape); this.geom.setName(body.toString()); geom.setMaterial(debugAppState.DEBUG_YELLOW); }
/** * Instantiate an enabled control to visualize the specified body. * * @param debugAppState which app state (not null, alias created) * @param body which body to visualize (not null, alias created) */ public BulletRigidBodyDebugControl(BulletDebugAppState debugAppState, PhysicsRigidBody body) { super(debugAppState); this.body = body; myShape = body.getCollisionShape(); oldScale.set(myShape.getScale()); this.geom = DebugShapeFactory.getDebugShape(myShape); this.geom.setName(body.toString()); geom.setMaterial(debugAppState.DEBUG_BLUE); }
/** * Update this control. Invoked once per frame during the logical-state * update, provided the control is enabled and added to a scene. Should be * invoked only by a subclass or by AbstractControl. * * @param tpf the time interval between frames (in seconds, ≥0) */ @Override protected void controlUpdate(float tpf) { CollisionShape newShape = body.getCollisionShape(); Vector3f newScale = newShape.getScale(); if (myShape != newShape || !oldScale.equals(newScale)) { myShape = newShape; oldScale.set(newScale); Node node = (Node) spatial; node.detachChild(geom); geom = DebugShapeFactory.getDebugShape(myShape); geom.setName(body.toString()); node.attachChild(geom); } geom.setMaterial(debugAppState.DEBUG_PINK); body.getPhysicsLocation(location); applyPhysicsTransform(location, Quaternion.IDENTITY); }
/** * Update this control. Invoked once per frame during the logical-state * update, provided the control is enabled and added to a scene. Should be * invoked only by a subclass or by AbstractControl. * * @param tpf the time interval between frames (in seconds, ≥0) */ @Override protected void controlUpdate(float tpf) { CollisionShape newShape = body.getCollisionShape(); Vector3f newScale = newShape.getScale(); if (myShape != newShape || !oldScale.equals(newScale)) { myShape = newShape; oldScale.set(newScale); Node node = (Node) spatial; node.detachChild(geom); geom = DebugShapeFactory.getDebugShape(myShape); geom.setName(body.toString()); node.attachChild(geom); } geom.setMaterial(debugAppState.DEBUG_PINK); body.getPhysicsLocation(location); applyPhysicsTransform(location, Quaternion.IDENTITY); }
/** * Update this control. Invoked once per frame during the logical-state * update, provided the control is enabled and added to a scene. Should be * invoked only by a subclass or by AbstractControl. * * @param tpf the time interval between frames (in seconds, ≥0) */ @Override protected void controlUpdate(float tpf) { CollisionShape newShape = body.getCollisionShape(); Vector3f newScale = newShape.getScale(); if (myShape != newShape || !oldScale.equals(newScale)) { myShape = newShape; oldScale.set(newScale); Node node = (Node) spatial; node.detachChild(geom); geom = DebugShapeFactory.getDebugShape(myShape); geom.setName(body.toString()); node.attachChild(geom); } geom.setMaterial(debugAppState.DEBUG_YELLOW); body.getPhysicsLocation(location); body.getPhysicsRotation(rotation); applyPhysicsTransform(location, rotation); }
/** * Update this control. Invoked once per frame during the logical-state * update, provided the control is enabled and added to a scene. Should be * invoked only by a subclass or by AbstractControl. * * @param tpf the time interval between frames (in seconds, ≥0) */ @Override protected void controlUpdate(float tpf) { CollisionShape newShape = body.getCollisionShape(); Vector3f newScale = newShape.getScale(); if (myShape != newShape || !oldScale.equals(newScale)) { myShape = newShape; oldScale.set(newScale); Node node = (Node) spatial; node.detachChild(geom); geom = DebugShapeFactory.getDebugShape(myShape); geom.setName(body.toString()); node.attachChild(geom); } geom.setMaterial(debugAppState.DEBUG_YELLOW); body.getPhysicsLocation(location); body.getPhysicsRotation(rotation); applyPhysicsTransform(location, rotation); }
/** * Update this control. Invoked once per frame during the logical-state * update, provided the control is enabled and added to a scene. Should be * invoked only by a subclass or by AbstractControl. * * @param tpf the time interval between frames (in seconds, ≥0) */ @Override protected void controlUpdate(float tpf) { CollisionShape newShape = body.getCollisionShape(); Vector3f newScale = newShape.getScale(); if (myShape != newShape || !oldScale.equals(newScale)) { myShape = newShape; oldScale.set(newScale); Node node = (Node) spatial; node.detachChild(geom); geom = DebugShapeFactory.getDebugShape(myShape); geom.setName(body.toString()); node.attachChild(geom); } if(body.isActive()){ geom.setMaterial(debugAppState.DEBUG_MAGENTA); }else{ geom.setMaterial(debugAppState.DEBUG_BLUE); } body.getPhysicsLocation(location); body.getPhysicsRotation(rotation); applyPhysicsTransform(location, rotation); }
/** * Update this control. Invoked once per frame during the logical-state * update, provided the control is enabled and added to a scene. Should be * invoked only by a subclass or by AbstractControl. * * @param tpf the time interval between frames (in seconds, ≥0) */ @Override protected void controlUpdate(float tpf) { CollisionShape newShape = body.getCollisionShape(); Vector3f newScale = newShape.getScale(); if (myShape != newShape || !oldScale.equals(newScale)) { myShape = newShape; oldScale.set(newScale); Node node = (Node) spatial; node.detachChild(geom); geom = DebugShapeFactory.getDebugShape(myShape); geom.setName(body.toString()); node.attachChild(geom); } if(body.isActive()){ geom.setMaterial(debugAppState.DEBUG_MAGENTA); }else{ geom.setMaterial(debugAppState.DEBUG_BLUE); } body.getPhysicsLocation(location); body.getPhysicsRotation(rotation); applyPhysicsTransform(location, rotation); }
public void makeMissile() { Vector3f pos = spaceCraft.getWorldTranslation().clone(); Quaternion rot = spaceCraft.getWorldRotation(); Vector3f dir = rot.getRotationColumn(2); Spatial missile = assetManager.loadModel("Models/SpaceCraft/Rocket.mesh.xml"); missile.scale(0.5f); missile.rotate(0, FastMath.PI, 0); missile.updateGeometricState(); BoundingBox box = (BoundingBox) missile.getWorldBound(); final Vector3f extent = box.getExtent(null); BoxCollisionShape boxShape = new BoxCollisionShape(extent); missile.setName("Missile"); missile.rotate(rot); missile.setLocalTranslation(pos.addLocal(0, extent.y * 4.5f, 0)); missile.setLocalRotation(hoverControl.getPhysicsRotation()); missile.setShadowMode(ShadowMode.Cast); RigidBodyControl control = new BombControl(assetManager, boxShape, 20); control.setLinearVelocity(dir.mult(100)); control.setCollisionGroup(PhysicsCollisionObject.COLLISION_GROUP_03); missile.addControl(control); rootNode.attachChild(missile); getPhysicsSpace().add(missile); }
private void createScene() { Material mat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md"); mat.setFloat("Shininess", 1f); mat.setBoolean("UseMaterialColors", true); mat.setColor("Ambient", ColorRGBA.Black); mat.setColor("Diffuse", ColorRGBA.DarkGray); mat.setColor("Specular", ColorRGBA.White.mult(0.6f)); Material matSoil = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md"); matSoil.setBoolean("UseMaterialColors", true); matSoil.setColor("Ambient", ColorRGBA.Black); matSoil.setColor("Diffuse", ColorRGBA.Black); matSoil.setColor("Specular", ColorRGBA.Black); teapot = assetManager.loadModel("Models/Teapot/Teapot.obj"); teapot.setName("Teapot"); teapot.setLocalScale(3); teapot.setMaterial(mat); rootNode.attachChild(teapot); Geometry soil = new Geometry("soil", new Box(50, 1, 50)); soil.setLocalTranslation(0, -1, 0); soil.setMaterial(matSoil); rootNode.attachChild(soil); DirectionalLight light = new DirectionalLight(); light.setDirection(new Vector3f(0, -1, 0).normalizeLocal()); light.setColor(ColorRGBA.White.mult(1.5f)); rootNode.addLight(light); }
public BulletGhostObjectDebugControl(BulletDebugAppState debugAppState, PhysicsGhostObject body) { super(debugAppState); this.body = body; myShape = body.getCollisionShape(); this.geom = DebugShapeFactory.getDebugShape(body.getCollisionShape()); this.geom.setName(body.toString()); this.geom.setName(body.toString()); geom.setMaterial(debugAppState.DEBUG_YELLOW); }
public BulletRigidBodyDebugControl(BulletDebugAppState debugAppState, PhysicsRigidBody body) { super(debugAppState); this.body = body; myShape = body.getCollisionShape(); this.geom = DebugShapeFactory.getDebugShape(body.getCollisionShape()); this.geom.setName(body.toString()); geom.setMaterial(debugAppState.DEBUG_BLUE); }
/** * Instantiate an enabled control to visualize the specified body. * * @param debugAppState which app state (not null, alias created) * @param body which body to visualize (not null, alias created) */ public BulletRigidBodyDebugControl(BulletDebugAppState debugAppState, PhysicsRigidBody body) { super(debugAppState); this.body = body; myShape = body.getCollisionShape(); oldScale.set(myShape.getScale()); this.geom = DebugShapeFactory.getDebugShape(myShape); this.geom.setName(body.toString()); geom.setMaterial(debugAppState.DEBUG_BLUE); }
/** * Instantiate an enabled control to visualize the specified ghost object. * * @param debugAppState which app state (not null, alias created) * @param body which object to visualize (not null, alias created) */ public BulletGhostObjectDebugControl(BulletDebugAppState debugAppState, PhysicsGhostObject body) { super(debugAppState); this.body = body; myShape = body.getCollisionShape(); oldScale.set(myShape.getScale()); this.geom = DebugShapeFactory.getDebugShape(myShape); this.geom.setName(body.toString()); geom.setMaterial(debugAppState.DEBUG_YELLOW); }
/** * Instantiate an enabled control to visualize the specified character. * * @param debugAppState which app state (not null, alias created) * @param body the character to visualize (not null, alias created) */ public BulletCharacterDebugControl(BulletDebugAppState debugAppState, PhysicsCharacter body) { super(debugAppState); this.body = body; myShape = body.getCollisionShape(); oldScale.set(myShape.getScale()); this.geom = DebugShapeFactory.getDebugShape(myShape); this.geom.setName(body.toString()); geom.setMaterial(debugAppState.DEBUG_PINK); }