- remove deprecated bullet classes git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7065 75d07b2b-3a1a-0410-a2c5-0572b91ccdca3.0
parent
7aae9615ca
commit
34863f926e
@ -1,205 +0,0 @@ |
|||||||
/* |
|
||||||
* Copyright (c) 2009-2010 jMonkeyEngine |
|
||||||
* All rights reserved. |
|
||||||
* |
|
||||||
* Redistribution and use in source and binary forms, with or without |
|
||||||
* modification, are permitted provided that the following conditions are |
|
||||||
* met: |
|
||||||
* |
|
||||||
* * Redistributions of source code must retain the above copyright |
|
||||||
* notice, this list of conditions and the following disclaimer. |
|
||||||
* |
|
||||||
* * Redistributions in binary form must reproduce the above copyright |
|
||||||
* notice, this list of conditions and the following disclaimer in the |
|
||||||
* documentation and/or other materials provided with the distribution. |
|
||||||
* |
|
||||||
* * Neither the name of 'jMonkeyEngine' nor the names of its contributors |
|
||||||
* may be used to endorse or promote products derived from this software |
|
||||||
* without specific prior written permission. |
|
||||||
* |
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
|
||||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
|
||||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
||||||
*/ |
|
||||||
package com.jme3.bullet.nodes; |
|
||||||
|
|
||||||
import com.jme3.asset.AssetManager; |
|
||||||
import com.jme3.bullet.collision.PhysicsCollisionObject; |
|
||||||
import com.jme3.bullet.collision.shapes.CollisionShape; |
|
||||||
import com.jme3.export.InputCapsule; |
|
||||||
import com.jme3.export.JmeExporter; |
|
||||||
import com.jme3.export.JmeImporter; |
|
||||||
import com.jme3.export.OutputCapsule; |
|
||||||
import com.jme3.material.Material; |
|
||||||
import com.jme3.math.Quaternion; |
|
||||||
import com.jme3.math.Vector3f; |
|
||||||
import com.jme3.scene.Node; |
|
||||||
import java.io.IOException; |
|
||||||
|
|
||||||
/** |
|
||||||
* Base class for Physics Nodes (PhysicsNode, PhysicsGhostNode) |
|
||||||
* @author normenhansen |
|
||||||
* @deprecated in favor of physics Controls |
|
||||||
*/ |
|
||||||
@Deprecated |
|
||||||
public abstract class PhysicsBaseNode extends Node { |
|
||||||
|
|
||||||
protected PhysicsCollisionObject collisionObject; |
|
||||||
protected Quaternion tmp_inverseWorldRotation = new Quaternion(); |
|
||||||
|
|
||||||
public void updatePhysicsState() { |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Sets a CollisionShape to this physics object, note that the object should |
|
||||||
* not be in the physics space when adding a new collision shape as it is rebuilt |
|
||||||
* on the physics side. |
|
||||||
* @param collisionShape the CollisionShape to set |
|
||||||
*/ |
|
||||||
public void setCollisionShape(CollisionShape collisionShape) { |
|
||||||
collisionObject.setCollisionShape(collisionShape); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @return the CollisionShape of this PhysicsNode, to be able to reuse it with |
|
||||||
* other physics nodes (increases performance) |
|
||||||
*/ |
|
||||||
public CollisionShape getCollisionShape() { |
|
||||||
return collisionObject.getCollisionShape(); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Returns the collision group for this collision shape |
|
||||||
* @return |
|
||||||
*/ |
|
||||||
public int getCollisionGroup() { |
|
||||||
return collisionObject.getCollisionGroup(); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Sets the collision group number for this physics object. <br> |
|
||||||
* The groups are integer bit masks and some pre-made variables are available in CollisionObject. |
|
||||||
* All physics objects are by default in COLLISION_GROUP_01.<br> |
|
||||||
* Two object will collide when <b>one</b> of the partys has the |
|
||||||
* collisionGroup of the other in its collideWithGroups set. |
|
||||||
* @param collisionGroup the collisionGroup to set |
|
||||||
*/ |
|
||||||
public void setCollisionGroup(int collisionGroup) { |
|
||||||
collisionObject.setCollisionGroup(collisionGroup); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Add a group that this object will collide with.<br> |
|
||||||
* Two object will collide when <b>one</b> of the partys has the |
|
||||||
* collisionGroup of the other in its collideWithGroups set.<br> |
|
||||||
* @param collisionGroup |
|
||||||
*/ |
|
||||||
public void addCollideWithGroup(int collisionGroup) { |
|
||||||
collisionObject.addCollideWithGroup(collisionGroup); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Remove a group from the list this object collides with. |
|
||||||
* @param collisionGroup |
|
||||||
*/ |
|
||||||
public void removeCollideWithGroup(int collisionGroup) { |
|
||||||
collisionObject.removeCollideWithGroup(collisionGroup); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Directly set the bitmask for collision groups that this object collides with. |
|
||||||
* @param collisionGroup |
|
||||||
*/ |
|
||||||
public void setCollideWithGroups(int collisionGroups) { |
|
||||||
collisionObject.setCollideWithGroups(collisionGroups); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Gets the bitmask of collision groups that this object collides with. |
|
||||||
* @return |
|
||||||
*/ |
|
||||||
public int getCollideWithGroups() { |
|
||||||
return collisionObject.getCollideWithGroups(); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* computes the local translation from the parameter translation and sets it as new |
|
||||||
* local translation<br> |
|
||||||
* This should only be called from the physics thread to update the jme spatial |
|
||||||
* @param translation new world translation of this spatial. |
|
||||||
* @return the computed local translation |
|
||||||
*/ |
|
||||||
public Vector3f setWorldTranslation(Vector3f translation) { |
|
||||||
Vector3f localTranslation = super.getLocalTranslation(); |
|
||||||
if (parent != null) { |
|
||||||
localTranslation.set(translation).subtractLocal(parent.getWorldTranslation()); |
|
||||||
localTranslation.divideLocal(parent.getWorldScale()); |
|
||||||
tmp_inverseWorldRotation.set(parent.getWorldRotation()).inverseLocal().multLocal(localTranslation); |
|
||||||
} else { |
|
||||||
localTranslation.set(translation); |
|
||||||
} |
|
||||||
super.setLocalTranslation(localTranslation); |
|
||||||
return localTranslation; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* computes the local rotation from the parameter rot and sets it as new |
|
||||||
* local rotation<br> |
|
||||||
* This should only be called from the physics thread to update the jme spatial |
|
||||||
* @param rot new world rotation of this spatial. |
|
||||||
* @return the computed local rotation |
|
||||||
*/ |
|
||||||
public Quaternion setWorldRotation(Quaternion rot) { |
|
||||||
Quaternion localRotation = super.getLocalRotation(); |
|
||||||
if (parent != null) { |
|
||||||
tmp_inverseWorldRotation.set(parent.getWorldRotation()).inverseLocal().mult(rot, localRotation); |
|
||||||
} else { |
|
||||||
localRotation.set(rot); |
|
||||||
} |
|
||||||
super.setLocalRotation(localRotation); |
|
||||||
return localRotation; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Attaches a visual debug shape of the current collision shape to this physics object<br/> |
|
||||||
* <b>Does not work with detached physics, please switch to PARALLEL or SEQUENTIAL for debugging</b> |
|
||||||
* @param manager AssetManager to load the default wireframe material for the debug shape |
|
||||||
*/ |
|
||||||
public void attachDebugShape(AssetManager manager) { |
|
||||||
collisionObject.attachDebugShape(manager); |
|
||||||
} |
|
||||||
|
|
||||||
public void attachDebugShape(Material material) { |
|
||||||
collisionObject.attachDebugShape(material); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Detaches the debug shape |
|
||||||
*/ |
|
||||||
public void detachDebugShape() { |
|
||||||
collisionObject.detachDebugShape(); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void write(JmeExporter e) throws IOException { |
|
||||||
super.write(e); |
|
||||||
OutputCapsule capsule = e.getCapsule(this); |
|
||||||
capsule.write(collisionObject, "collisionObject", null); |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void read(JmeImporter e) throws IOException { |
|
||||||
super.read(e); |
|
||||||
InputCapsule capsule = e.getCapsule(this); |
|
||||||
collisionObject = (PhysicsCollisionObject) capsule.readSavable("collisionObject", null); |
|
||||||
} |
|
||||||
} |
|
@ -1,182 +0,0 @@ |
|||||||
/* |
|
||||||
* Copyright (c) 2009-2010 jMonkeyEngine |
|
||||||
* All rights reserved. |
|
||||||
* |
|
||||||
* Redistribution and use in source and binary forms, with or without |
|
||||||
* modification, are permitted provided that the following conditions are |
|
||||||
* met: |
|
||||||
* |
|
||||||
* * Redistributions of source code must retain the above copyright |
|
||||||
* notice, this list of conditions and the following disclaimer. |
|
||||||
* |
|
||||||
* * Redistributions in binary form must reproduce the above copyright |
|
||||||
* notice, this list of conditions and the following disclaimer in the |
|
||||||
* documentation and/or other materials provided with the distribution. |
|
||||||
* |
|
||||||
* * Neither the name of 'jMonkeyEngine' nor the names of its contributors |
|
||||||
* may be used to endorse or promote products derived from this software |
|
||||||
* without specific prior written permission. |
|
||||||
* |
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
|
||||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
|
||||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
||||||
*/ |
|
||||||
package com.jme3.bullet.nodes; |
|
||||||
|
|
||||||
import com.jme3.math.Vector3f; |
|
||||||
import com.jme3.scene.Spatial; |
|
||||||
import com.jme3.bullet.collision.shapes.CollisionShape; |
|
||||||
import com.jme3.bullet.control.CharacterControl; |
|
||||||
import com.jme3.bullet.objects.PhysicsCharacter; |
|
||||||
import com.jme3.bullet.objects.PhysicsGhostObject; |
|
||||||
import com.jme3.export.InputCapsule; |
|
||||||
import com.jme3.export.JmeExporter; |
|
||||||
import com.jme3.export.JmeImporter; |
|
||||||
import com.jme3.export.OutputCapsule; |
|
||||||
import com.jme3.math.Matrix3f; |
|
||||||
import com.jme3.math.Quaternion; |
|
||||||
import com.jme3.math.Transform; |
|
||||||
import java.io.IOException; |
|
||||||
|
|
||||||
/** |
|
||||||
* |
|
||||||
* @author normenhansen |
|
||||||
* @deprecated in favor of physics Controls |
|
||||||
*/ |
|
||||||
@Deprecated |
|
||||||
public class PhysicsCharacterNode extends PhysicsBaseNode { |
|
||||||
|
|
||||||
public PhysicsCharacterNode() { |
|
||||||
} |
|
||||||
|
|
||||||
public PhysicsCharacterNode(CollisionShape shape, float stepHeight) { |
|
||||||
collisionObject = new CharacterControl(shape, stepHeight); |
|
||||||
addControl((CharacterControl)collisionObject); |
|
||||||
} |
|
||||||
|
|
||||||
public PhysicsCharacterNode(Spatial spat, CollisionShape shape, float stepHeight) { |
|
||||||
collisionObject = new CharacterControl(shape, stepHeight); |
|
||||||
addControl((CharacterControl)collisionObject); |
|
||||||
attachChild(spat); |
|
||||||
} |
|
||||||
|
|
||||||
public void warp(Vector3f location) { |
|
||||||
((PhysicsCharacter)collisionObject).warp(location); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void setLocalTransform(Transform t) { |
|
||||||
super.setLocalTransform(t); |
|
||||||
((CharacterControl)collisionObject).setPhysicsLocation(getWorldTranslation()); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void setLocalTranslation(Vector3f localTranslation) { |
|
||||||
super.setLocalTranslation(localTranslation); |
|
||||||
((CharacterControl)collisionObject).setPhysicsLocation(getWorldTranslation()); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void setLocalTranslation(float x, float y, float z) { |
|
||||||
super.setLocalTranslation(x, y, z); |
|
||||||
((CharacterControl)collisionObject).setPhysicsLocation(getWorldTranslation()); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void setLocalRotation(Matrix3f rotation) { |
|
||||||
super.setLocalRotation(rotation); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void setLocalRotation(Quaternion quaternion) { |
|
||||||
super.setLocalRotation(quaternion); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* set the walk direction, works continuously |
|
||||||
* @param vec the walk direction to set |
|
||||||
*/ |
|
||||||
public void setWalkDirection(Vector3f vec) { |
|
||||||
((PhysicsCharacter)collisionObject).setWalkDirection(vec); |
|
||||||
} |
|
||||||
|
|
||||||
public void setUpAxis(int axis) { |
|
||||||
((PhysicsCharacter)collisionObject).setUpAxis(axis); |
|
||||||
} |
|
||||||
|
|
||||||
public int getUpAxis() { |
|
||||||
return ((PhysicsCharacter)collisionObject).getUpAxis(); |
|
||||||
} |
|
||||||
|
|
||||||
public void setFallSpeed(float fallSpeed) { |
|
||||||
((PhysicsCharacter)collisionObject).setFallSpeed(fallSpeed); |
|
||||||
} |
|
||||||
|
|
||||||
public float getFallSpeed() { |
|
||||||
return ((PhysicsCharacter)collisionObject).getFallSpeed(); |
|
||||||
} |
|
||||||
|
|
||||||
public void setJumpSpeed(float jumpSpeed) { |
|
||||||
((PhysicsCharacter)collisionObject).setJumpSpeed(jumpSpeed); |
|
||||||
} |
|
||||||
|
|
||||||
public float getJumpSpeed() { |
|
||||||
return ((PhysicsCharacter)collisionObject).getJumpSpeed(); |
|
||||||
} |
|
||||||
|
|
||||||
public void setGravity(float value) { |
|
||||||
((PhysicsCharacter)collisionObject).setGravity(value); |
|
||||||
} |
|
||||||
|
|
||||||
public float getGravity() { |
|
||||||
return ((PhysicsCharacter)collisionObject).getGravity(); |
|
||||||
} |
|
||||||
|
|
||||||
public void setMaxSlope(float slopeRadians) { |
|
||||||
((PhysicsCharacter)collisionObject).setMaxSlope(slopeRadians); |
|
||||||
} |
|
||||||
|
|
||||||
public float getMaxSlope() { |
|
||||||
return ((PhysicsCharacter)collisionObject).getMaxSlope(); |
|
||||||
} |
|
||||||
|
|
||||||
public boolean onGround() { |
|
||||||
return ((PhysicsCharacter)collisionObject).onGround(); |
|
||||||
} |
|
||||||
|
|
||||||
public void jump() { |
|
||||||
((PhysicsCharacter)collisionObject).jump(); |
|
||||||
} |
|
||||||
|
|
||||||
public void setCollisionShape(CollisionShape collisionShape) { |
|
||||||
((PhysicsCharacter)collisionObject).setCollisionShape(collisionShape); |
|
||||||
} |
|
||||||
|
|
||||||
public PhysicsCharacter getPhysicsCharacter() { |
|
||||||
return ((PhysicsCharacter)collisionObject); |
|
||||||
} |
|
||||||
|
|
||||||
public void destroy() { |
|
||||||
((PhysicsCharacter)collisionObject).destroy(); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void write(JmeExporter e) throws IOException { |
|
||||||
super.write(e); |
|
||||||
OutputCapsule capsule = e.getCapsule(this); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void read(JmeImporter e) throws IOException { |
|
||||||
super.read(e); |
|
||||||
InputCapsule capsule = e.getCapsule(this); |
|
||||||
} |
|
||||||
} |
|
@ -1,186 +0,0 @@ |
|||||||
/* |
|
||||||
* Copyright (c) 2009-2010 jMonkeyEngine |
|
||||||
* All rights reserved. |
|
||||||
* |
|
||||||
* Redistribution and use in source and binary forms, with or without |
|
||||||
* modification, are permitted provided that the following conditions are |
|
||||||
* met: |
|
||||||
* |
|
||||||
* * Redistributions of source code must retain the above copyright |
|
||||||
* notice, this list of conditions and the following disclaimer. |
|
||||||
* |
|
||||||
* * Redistributions in binary form must reproduce the above copyright |
|
||||||
* notice, this list of conditions and the following disclaimer in the |
|
||||||
* documentation and/or other materials provided with the distribution. |
|
||||||
* |
|
||||||
* * Neither the name of 'jMonkeyEngine' nor the names of its contributors |
|
||||||
* may be used to endorse or promote products derived from this software |
|
||||||
* without specific prior written permission. |
|
||||||
* |
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
|
||||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
|
||||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
||||||
*/ |
|
||||||
package com.jme3.bullet.nodes; |
|
||||||
|
|
||||||
import com.jme3.scene.Spatial; |
|
||||||
import com.jme3.bullet.collision.PhysicsCollisionObject; |
|
||||||
import com.jme3.bullet.collision.shapes.CollisionShape; |
|
||||||
import com.jme3.bullet.control.GhostControl; |
|
||||||
import com.jme3.bullet.objects.PhysicsGhostObject; |
|
||||||
import com.jme3.export.InputCapsule; |
|
||||||
import com.jme3.export.JmeExporter; |
|
||||||
import com.jme3.export.JmeImporter; |
|
||||||
import com.jme3.export.OutputCapsule; |
|
||||||
import com.jme3.math.Matrix3f; |
|
||||||
import com.jme3.math.Quaternion; |
|
||||||
import com.jme3.math.Transform; |
|
||||||
import com.jme3.math.Vector3f; |
|
||||||
import java.io.IOException; |
|
||||||
import java.util.List; |
|
||||||
|
|
||||||
/** |
|
||||||
* <i>From Bullet manual:</i><br> |
|
||||||
* GhostObject can keep track of all objects that are overlapping. |
|
||||||
* By default, this overlap is based on the AABB. |
|
||||||
* This is useful for creating a character controller, |
|
||||||
* collision sensors/triggers, explosions etc.<br> |
|
||||||
* @author normenhansen |
|
||||||
* @deprecated in favor of physics Controls |
|
||||||
*/ |
|
||||||
@Deprecated |
|
||||||
public class PhysicsGhostNode extends PhysicsBaseNode { |
|
||||||
|
|
||||||
// protected PhysicsGhostControl gObject;
|
|
||||||
|
|
||||||
public PhysicsGhostNode() { |
|
||||||
} |
|
||||||
|
|
||||||
public PhysicsGhostNode(CollisionShape shape) { |
|
||||||
collisionObject=new GhostControl(shape); |
|
||||||
addControl(((GhostControl)collisionObject)); |
|
||||||
} |
|
||||||
|
|
||||||
public PhysicsGhostNode(Spatial child, CollisionShape shape) { |
|
||||||
collisionObject=new GhostControl(shape); |
|
||||||
addControl(((GhostControl)collisionObject)); |
|
||||||
attachChild(child); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void setCollisionShape(CollisionShape collisionShape) { |
|
||||||
((GhostControl)collisionObject).setCollisionShape(collisionShape); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void setLocalTransform(Transform t) { |
|
||||||
super.setLocalTransform(t); |
|
||||||
((PhysicsGhostObject)collisionObject).setPhysicsLocation(getWorldTranslation()); |
|
||||||
((PhysicsGhostObject)collisionObject).setPhysicsRotation(getWorldRotation().toRotationMatrix()); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void setLocalTranslation(Vector3f localTranslation) { |
|
||||||
super.setLocalTranslation(localTranslation); |
|
||||||
((PhysicsGhostObject)collisionObject).setPhysicsLocation(getWorldTranslation()); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void setLocalTranslation(float x, float y, float z) { |
|
||||||
super.setLocalTranslation(x, y, z); |
|
||||||
((PhysicsGhostObject)collisionObject).setPhysicsLocation(getWorldTranslation()); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void setLocalRotation(Matrix3f rotation) { |
|
||||||
super.setLocalRotation(rotation); |
|
||||||
((PhysicsGhostObject)collisionObject).setPhysicsRotation(getWorldRotation().toRotationMatrix()); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void setLocalRotation(Quaternion quaternion) { |
|
||||||
super.setLocalRotation(quaternion); |
|
||||||
((PhysicsGhostObject)collisionObject).setPhysicsRotation(getWorldRotation().toRotationMatrix()); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* used internally |
|
||||||
*/ |
|
||||||
public PhysicsGhostObject getGhostObject() { |
|
||||||
return ((GhostControl)collisionObject); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* destroys this PhysicsGhostNode and removes it from memory |
|
||||||
*/ |
|
||||||
public void destroy() { |
|
||||||
((GhostControl)collisionObject).destroy(); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Another Object is overlapping with this GhostNode, |
|
||||||
* if and if only there CollisionShapes overlaps. |
|
||||||
* They could be both regular PhysicsNodes or PhysicsGhostNode. |
|
||||||
* @return All CollisionObjects overlapping with this GhostNode. |
|
||||||
*/ |
|
||||||
public List<PhysicsCollisionObject> getOverlappingObjects() { |
|
||||||
return ((GhostControl)collisionObject).getOverlappingObjects(); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* |
|
||||||
* @return With how many other CollisionObjects this GhostNode is currently overlapping. |
|
||||||
*/ |
|
||||||
public int getOverlappingCount() { |
|
||||||
return ((GhostControl)collisionObject).getOverlappingCount(); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* |
|
||||||
* @param index The index of the overlapping Node to retrieve. |
|
||||||
* @return The Overlapping CollisionObject at the given index. |
|
||||||
*/ |
|
||||||
public PhysicsCollisionObject getOverlapping(int index) { |
|
||||||
return ((GhostControl)collisionObject).getOverlapping(index); |
|
||||||
} |
|
||||||
|
|
||||||
public void setCcdSweptSphereRadius(float radius) { |
|
||||||
((GhostControl)collisionObject).setCcdSweptSphereRadius(radius); |
|
||||||
} |
|
||||||
|
|
||||||
public void setCcdMotionThreshold(float threshold) { |
|
||||||
((GhostControl)collisionObject).setCcdMotionThreshold(threshold); |
|
||||||
} |
|
||||||
|
|
||||||
public float getCcdSweptSphereRadius() { |
|
||||||
return ((GhostControl)collisionObject).getCcdSweptSphereRadius(); |
|
||||||
} |
|
||||||
|
|
||||||
public float getCcdMotionThreshold() { |
|
||||||
return ((GhostControl)collisionObject).getCcdMotionThreshold(); |
|
||||||
} |
|
||||||
|
|
||||||
public float getCcdSquareMotionThreshold() { |
|
||||||
return ((GhostControl)collisionObject).getCcdSquareMotionThreshold(); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void write(JmeExporter e) throws IOException { |
|
||||||
super.write(e); |
|
||||||
OutputCapsule capsule = e.getCapsule(this); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void read(JmeImporter e) throws IOException { |
|
||||||
super.read(e); |
|
||||||
InputCapsule capsule = e.getCapsule(this); |
|
||||||
} |
|
||||||
} |
|
@ -1,624 +0,0 @@ |
|||||||
/* |
|
||||||
* Copyright (c) 2009-2010 jMonkeyEngine |
|
||||||
* All rights reserved. |
|
||||||
* |
|
||||||
* Redistribution and use in source and binary forms, with or without |
|
||||||
* modification, are permitted provided that the following conditions are |
|
||||||
* met: |
|
||||||
* |
|
||||||
* * Redistributions of source code must retain the above copyright |
|
||||||
* notice, this list of conditions and the following disclaimer. |
|
||||||
* |
|
||||||
* * Redistributions in binary form must reproduce the above copyright |
|
||||||
* notice, this list of conditions and the following disclaimer in the |
|
||||||
* documentation and/or other materials provided with the distribution. |
|
||||||
* |
|
||||||
* * Neither the name of 'jMonkeyEngine' nor the names of its contributors |
|
||||||
* may be used to endorse or promote products derived from this software |
|
||||||
* without specific prior written permission. |
|
||||||
* |
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
|
||||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
|
||||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
||||||
*/ |
|
||||||
package com.jme3.bullet.nodes; |
|
||||||
|
|
||||||
import com.jme3.asset.AssetManager; |
|
||||||
import com.jme3.math.Quaternion; |
|
||||||
import com.jme3.math.Transform; |
|
||||||
import com.jme3.math.Vector3f; |
|
||||||
import com.jme3.scene.Spatial; |
|
||||||
import com.jme3.bullet.collision.shapes.CollisionShape; |
|
||||||
import com.jme3.bullet.control.RigidBodyControl; |
|
||||||
import com.jme3.bullet.joints.PhysicsJoint; |
|
||||||
import com.jme3.bullet.objects.PhysicsRigidBody; |
|
||||||
import com.jme3.export.InputCapsule; |
|
||||||
import com.jme3.export.JmeExporter; |
|
||||||
import com.jme3.export.JmeImporter; |
|
||||||
import com.jme3.export.OutputCapsule; |
|
||||||
import com.jme3.material.Material; |
|
||||||
import com.jme3.math.Matrix3f; |
|
||||||
import java.io.IOException; |
|
||||||
import java.util.List; |
|
||||||
|
|
||||||
/** |
|
||||||
* <p>PhysicsNode - Basic physics object</p> |
|
||||||
* @author normenhansen |
|
||||||
* @deprecated in favor of physics Controls |
|
||||||
*/ |
|
||||||
@Deprecated |
|
||||||
public class PhysicsNode extends PhysicsBaseNode { |
|
||||||
|
|
||||||
protected Vector3f continuousForce = new Vector3f(); |
|
||||||
protected Vector3f continuousForceLocation = new Vector3f(); |
|
||||||
protected Vector3f continuousTorque = new Vector3f(); |
|
||||||
protected boolean applyForce = false; |
|
||||||
protected boolean applyTorque = false; |
|
||||||
|
|
||||||
public PhysicsNode() { |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Creates a new PhysicsNode with the supplied collision shape |
|
||||||
* @param child |
|
||||||
* @param shape |
|
||||||
*/ |
|
||||||
public PhysicsNode(CollisionShape shape) { |
|
||||||
collisionObject = new RigidBodyControl(shape); |
|
||||||
addControl(((RigidBodyControl)collisionObject)); |
|
||||||
} |
|
||||||
|
|
||||||
public PhysicsNode(CollisionShape shape, float mass) { |
|
||||||
collisionObject = new RigidBodyControl(shape, mass); |
|
||||||
addControl(((RigidBodyControl)collisionObject)); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Creates a new PhysicsNode with the supplied child node or geometry and |
|
||||||
* sets the supplied collision shape to the PhysicsNode |
|
||||||
* @param child |
|
||||||
* @param shape |
|
||||||
*/ |
|
||||||
public PhysicsNode(Spatial child, CollisionShape shape) { |
|
||||||
this(child, shape, 1.0f); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Creates a new PhysicsNode with the supplied child node or geometry and |
|
||||||
* uses the supplied collision shape for that PhysicsNode<br> |
|
||||||
* @param child |
|
||||||
* @param shape |
|
||||||
*/ |
|
||||||
public PhysicsNode(Spatial child, CollisionShape shape, float mass) { |
|
||||||
collisionObject = new RigidBodyControl(shape, mass); |
|
||||||
addControl(((RigidBodyControl)collisionObject)); |
|
||||||
attachChild(child); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void setLocalTransform(Transform t) { |
|
||||||
super.setLocalTransform(t); |
|
||||||
((PhysicsRigidBody)collisionObject).setPhysicsLocation(getWorldTranslation()); |
|
||||||
((PhysicsRigidBody)collisionObject).setPhysicsRotation(getWorldRotation().toRotationMatrix()); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void setLocalTranslation(Vector3f localTranslation) { |
|
||||||
super.setLocalTranslation(localTranslation); |
|
||||||
((PhysicsRigidBody)collisionObject).setPhysicsLocation(getWorldTranslation()); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void setLocalTranslation(float x, float y, float z) { |
|
||||||
super.setLocalTranslation(x, y, z); |
|
||||||
((PhysicsRigidBody)collisionObject).setPhysicsLocation(getWorldTranslation()); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void setLocalRotation(Matrix3f rotation) { |
|
||||||
super.setLocalRotation(rotation); |
|
||||||
((PhysicsRigidBody)collisionObject).setPhysicsRotation(getWorldRotation().toRotationMatrix()); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void setLocalRotation(Quaternion quaternion) { |
|
||||||
super.setLocalRotation(quaternion); |
|
||||||
((PhysicsRigidBody)collisionObject).setPhysicsRotation(getWorldRotation().toRotationMatrix()); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* This is normally only needed when using detached physics |
|
||||||
* @param location the location of the actual physics object |
|
||||||
*/ |
|
||||||
public void setPhysicsLocation(Vector3f location) { |
|
||||||
((PhysicsRigidBody)collisionObject).setPhysicsLocation(location); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* This is normally only needed when using detached physics |
|
||||||
* @param rotation the rotation of the actual physics object |
|
||||||
*/ |
|
||||||
public void setPhysicsRotation(Matrix3f rotation) { |
|
||||||
((PhysicsRigidBody)collisionObject).setPhysicsRotation(rotation); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* This is normally only needed when using detached physics |
|
||||||
* @param location the location of the actual physics object is stored in this Vector3f |
|
||||||
*/ |
|
||||||
public void getPhysicsLocation(Vector3f location) { |
|
||||||
((PhysicsRigidBody)collisionObject).getPhysicsLocation(location); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* This is normally only needed when using detached physics |
|
||||||
* @param rotation the rotation of the actual physics object is stored in this Matrix3f |
|
||||||
*/ |
|
||||||
public void getPhysicsRotation(Matrix3f rotation) { |
|
||||||
((PhysicsRigidBody)collisionObject).getPhysicsRotationMatrix(rotation); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Sets the node to kinematic mode. in this mode the node is not affected by physics |
|
||||||
* but affects other physics objects. Iits kinetic force is calculated by the amount |
|
||||||
* of movement it is exposed to and its weight. |
|
||||||
* @param kinematic |
|
||||||
*/ |
|
||||||
public void setKinematic(boolean kinematic) { |
|
||||||
((PhysicsRigidBody)collisionObject).setKinematic(kinematic); |
|
||||||
} |
|
||||||
|
|
||||||
public boolean isKinematic() { |
|
||||||
return ((PhysicsRigidBody)collisionObject).isKinematic(); |
|
||||||
} |
|
||||||
|
|
||||||
public void setCcdSweptSphereRadius(float radius) { |
|
||||||
((PhysicsRigidBody)collisionObject).setCcdSweptSphereRadius(radius); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Sets the amount of motion that has to happen in one physics tick to trigger the continuous motion detection<br/> |
|
||||||
* Set to zero to disable (default) |
|
||||||
* @param threshold |
|
||||||
*/ |
|
||||||
public void setCcdMotionThreshold(float threshold) { |
|
||||||
((PhysicsRigidBody)collisionObject).setCcdMotionThreshold(threshold); |
|
||||||
} |
|
||||||
|
|
||||||
public float getCcdSweptSphereRadius() { |
|
||||||
return ((PhysicsRigidBody)collisionObject).getCcdSweptSphereRadius(); |
|
||||||
} |
|
||||||
|
|
||||||
public float getCcdMotionThreshold() { |
|
||||||
return ((PhysicsRigidBody)collisionObject).getCcdMotionThreshold(); |
|
||||||
} |
|
||||||
|
|
||||||
public float getCcdSquareMotionThreshold() { |
|
||||||
return ((PhysicsRigidBody)collisionObject).getCcdSquareMotionThreshold(); |
|
||||||
} |
|
||||||
|
|
||||||
public float getMass() { |
|
||||||
return ((PhysicsRigidBody)collisionObject).getMass(); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Sets the mass of this PhysicsNode, objects with mass=0 are static. |
|
||||||
* @param mass |
|
||||||
*/ |
|
||||||
public void setMass(float mass) { |
|
||||||
((PhysicsRigidBody)collisionObject).setMass(mass); |
|
||||||
} |
|
||||||
|
|
||||||
public Vector3f getGravity() { |
|
||||||
return ((PhysicsRigidBody)collisionObject).getGravity(); |
|
||||||
} |
|
||||||
|
|
||||||
public Vector3f getGravity(Vector3f gravity) { |
|
||||||
return ((PhysicsRigidBody)collisionObject).getGravity(gravity); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Set the local gravity of this PhysicsNode<br/> |
|
||||||
* Set this after adding the node to the PhysicsSpace, |
|
||||||
* the PhysicsSpace assigns its current gravity to the physics node when its added. |
|
||||||
* @param gravity the gravity vector to set |
|
||||||
*/ |
|
||||||
public void setGravity(Vector3f gravity) { |
|
||||||
((PhysicsRigidBody)collisionObject).setGravity(gravity); |
|
||||||
} |
|
||||||
|
|
||||||
public float getFriction() { |
|
||||||
return ((PhysicsRigidBody)collisionObject).getFriction(); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Sets the friction of this physics object |
|
||||||
* @param friction the friction of this physics object |
|
||||||
*/ |
|
||||||
public void setFriction(float friction) { |
|
||||||
((PhysicsRigidBody)collisionObject).setFriction(friction); |
|
||||||
} |
|
||||||
|
|
||||||
public void setDamping(float linearDamping, float angularDamping) { |
|
||||||
((PhysicsRigidBody)collisionObject).setDamping(linearDamping, angularDamping); |
|
||||||
} |
|
||||||
|
|
||||||
public void setLinearDamping(float linearDamping) { |
|
||||||
((PhysicsRigidBody)collisionObject).setLinearDamping(linearDamping); |
|
||||||
} |
|
||||||
|
|
||||||
public void setAngularDamping(float angularDamping) { |
|
||||||
((PhysicsRigidBody)collisionObject).setAngularDamping(angularDamping); |
|
||||||
} |
|
||||||
|
|
||||||
public float getLinearDamping() { |
|
||||||
return ((PhysicsRigidBody)collisionObject).getLinearDamping(); |
|
||||||
} |
|
||||||
|
|
||||||
public float getAngularDamping() { |
|
||||||
return ((PhysicsRigidBody)collisionObject).getAngularDamping(); |
|
||||||
} |
|
||||||
|
|
||||||
public float getRestitution() { |
|
||||||
return ((PhysicsRigidBody)collisionObject).getRestitution(); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* The "bouncyness" of the PhysicsNode, best performance if restitution=0 |
|
||||||
* @param restitution |
|
||||||
*/ |
|
||||||
public void setRestitution(float restitution) { |
|
||||||
((PhysicsRigidBody)collisionObject).setRestitution(restitution); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Get the current angular velocity of this PhysicsNode |
|
||||||
* @return the current linear velocity |
|
||||||
*/ |
|
||||||
public Vector3f getAngularVelocity() { |
|
||||||
return ((PhysicsRigidBody)collisionObject).getAngularVelocity(); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Get the current angular velocity of this PhysicsNode |
|
||||||
* @param vec the vector to store the velocity in |
|
||||||
*/ |
|
||||||
public void getAngularVelocity(Vector3f vec) { |
|
||||||
((PhysicsRigidBody)collisionObject).getAngularVelocity(vec); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Sets the angular velocity of this PhysicsNode |
|
||||||
* @param vec the angular velocity of this PhysicsNode |
|
||||||
*/ |
|
||||||
public void setAngularVelocity(Vector3f vec) { |
|
||||||
((PhysicsRigidBody)collisionObject).setAngularVelocity(vec); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Get the current linear velocity of this PhysicsNode |
|
||||||
* @return the current linear velocity |
|
||||||
*/ |
|
||||||
public Vector3f getLinearVelocity() { |
|
||||||
return ((PhysicsRigidBody)collisionObject).getLinearVelocity(); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Get the current linear velocity of this PhysicsNode |
|
||||||
* @param vec the vector to store the velocity in |
|
||||||
*/ |
|
||||||
public void getLinearVelocity(Vector3f vec) { |
|
||||||
((PhysicsRigidBody)collisionObject).getLinearVelocity(vec); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Sets the linear velocity of this PhysicsNode |
|
||||||
* @param vec the linear velocity of this PhysicsNode |
|
||||||
*/ |
|
||||||
public void setLinearVelocity(Vector3f vec) { |
|
||||||
((PhysicsRigidBody)collisionObject).setLinearVelocity(vec); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void updateLogicalState(float tpf) { |
|
||||||
super.updateLogicalState(tpf); |
|
||||||
if (applyForce) { |
|
||||||
((PhysicsRigidBody)collisionObject).applyForce(continuousForce,continuousForceLocation); |
|
||||||
} |
|
||||||
if (applyTorque) { |
|
||||||
((PhysicsRigidBody)collisionObject).applyTorque(continuousTorque); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Get the currently applied continuous force |
|
||||||
* @param vec the vector to store the continuous force in |
|
||||||
* @return null if no force is applied |
|
||||||
*/ |
|
||||||
public synchronized Vector3f getContinuousForce(Vector3f vec) { |
|
||||||
if (applyForce) { |
|
||||||
return vec.set(continuousForce); |
|
||||||
} else { |
|
||||||
return null; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* get the currently applied continuous force |
|
||||||
* @return null if no force is applied |
|
||||||
*/ |
|
||||||
public synchronized Vector3f getContinuousForce() { |
|
||||||
if (applyForce) { |
|
||||||
return continuousForce; |
|
||||||
} else { |
|
||||||
return null; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Get the currently applied continuous force location |
|
||||||
* @return null if no force is applied |
|
||||||
*/ |
|
||||||
public synchronized Vector3f getContinuousForceLocation() { |
|
||||||
if (applyForce) { |
|
||||||
return continuousForceLocation; |
|
||||||
} else { |
|
||||||
return null; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Apply a continuous force to this PhysicsNode, the force is updated automatically each |
|
||||||
* tick so you only need to set it once and then set it to false to stop applying |
|
||||||
* the force. |
|
||||||
* @param apply true if the force should be applied each physics tick |
|
||||||
* @param force the vector of the force to apply |
|
||||||
*/ |
|
||||||
public synchronized void applyContinuousForce(boolean apply, Vector3f force) { |
|
||||||
if (force != null) { |
|
||||||
continuousForce.set(force); |
|
||||||
} |
|
||||||
continuousForceLocation.set(0, 0, 0); |
|
||||||
applyForce = apply; |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Apply a continuous force to this PhysicsNode, the force is updated automatically each |
|
||||||
* tick so you only need to set it once and then set it to false to stop applying |
|
||||||
* the force. |
|
||||||
* @param apply true if the force should be applied each physics tick |
|
||||||
* @param force the offset of the force |
|
||||||
*/ |
|
||||||
public synchronized void applyContinuousForce(boolean apply, Vector3f force, Vector3f location) { |
|
||||||
if (force != null) { |
|
||||||
continuousForce.set(force); |
|
||||||
} |
|
||||||
if (location != null) { |
|
||||||
continuousForceLocation.set(location); |
|
||||||
} |
|
||||||
applyForce = apply; |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Use to enable/disable continuous force |
|
||||||
* @param apply set to false to disable |
|
||||||
*/ |
|
||||||
public synchronized void applyContinuousForce(boolean apply) { |
|
||||||
applyForce = apply; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Get the currently applied continuous torque |
|
||||||
* @return null if no torque is applied |
|
||||||
*/ |
|
||||||
public synchronized Vector3f getContinuousTorque() { |
|
||||||
if (applyTorque) { |
|
||||||
return continuousTorque; |
|
||||||
} else { |
|
||||||
return null; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Get the currently applied continuous torque |
|
||||||
* @param vec the vector to store the continuous torque in |
|
||||||
* @return null if no torque is applied |
|
||||||
*/ |
|
||||||
public synchronized Vector3f getContinuousTorque(Vector3f vec) { |
|
||||||
if (applyTorque) { |
|
||||||
return vec.set(continuousTorque); |
|
||||||
} else { |
|
||||||
return null; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Apply a continuous torque to this PhysicsNode. The torque is updated automatically each |
|
||||||
* tick so you only need to set it once and then set it to false to stop applying |
|
||||||
* the torque. |
|
||||||
* @param apply true if the force should be applied each physics tick |
|
||||||
* @param vec the vector of the force to apply |
|
||||||
*/ |
|
||||||
public synchronized void applyContinuousTorque(boolean apply, Vector3f vec) { |
|
||||||
if (vec != null) { |
|
||||||
continuousTorque.set(vec); |
|
||||||
} |
|
||||||
applyTorque = apply; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Use to enable/disable continuous torque |
|
||||||
* @param apply set to false to disable |
|
||||||
*/ |
|
||||||
public synchronized void applyContinuousTorque(boolean apply) { |
|
||||||
applyTorque = apply; |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** |
|
||||||
* Apply a force to the PhysicsNode, only applies force if the next physics update call |
|
||||||
* updates the physics space.<br> |
|
||||||
* To apply an impulse, use applyImpulse, use applyContinuousForce to apply continuous force. |
|
||||||
* @param force the force |
|
||||||
* @param location the location of the force |
|
||||||
*/ |
|
||||||
public void applyForce(final Vector3f force, final Vector3f location) { |
|
||||||
((PhysicsRigidBody)collisionObject).applyForce(force, location); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Apply a force to the PhysicsNode, only applies force if the next physics update call |
|
||||||
* updates the physics space.<br> |
|
||||||
* To apply an impulse, use applyImpulse, use applyContinuousForce to apply continuous force. |
|
||||||
* |
|
||||||
* @param force the force |
|
||||||
*/ |
|
||||||
public void applyCentralForce(final Vector3f force) { |
|
||||||
((PhysicsRigidBody)collisionObject).applyCentralForce(force); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Apply a force to the PhysicsNode, only applies force if the next physics update call |
|
||||||
* updates the physics space.<br> |
|
||||||
* To apply an impulse, use applyImpulse, use applyContinuousForce to apply continuous force. |
|
||||||
* |
|
||||||
* @param torque the torque |
|
||||||
*/ |
|
||||||
public void applyTorque(final Vector3f torque) { |
|
||||||
((PhysicsRigidBody)collisionObject).applyTorque(torque); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Apply an impulse to the PhysicsNode in the next physics update. |
|
||||||
* @param impulse applied impulse |
|
||||||
* @param rel_pos location relative to object |
|
||||||
*/ |
|
||||||
public void applyImpulse(final Vector3f impulse, final Vector3f rel_pos) { |
|
||||||
((PhysicsRigidBody)collisionObject).applyImpulse(impulse, rel_pos); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Apply a torque impulse to the PhysicsNode in the next physics update. |
|
||||||
* @param vec |
|
||||||
*/ |
|
||||||
public void applyTorqueImpulse(final Vector3f vec) { |
|
||||||
((PhysicsRigidBody)collisionObject).applyTorqueImpulse(vec); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Clear all forces from the PhysicsNode |
|
||||||
* |
|
||||||
*/ |
|
||||||
public void clearForces() { |
|
||||||
((PhysicsRigidBody)collisionObject).clearForces(); |
|
||||||
} |
|
||||||
|
|
||||||
public void setCollisionShape(CollisionShape collisionShape) { |
|
||||||
((PhysicsRigidBody)collisionObject).setCollisionShape(collisionShape); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* reactivates this PhysicsNode when it has been deactivated because it was not moving |
|
||||||
*/ |
|
||||||
public void activate() { |
|
||||||
((PhysicsRigidBody)collisionObject).activate(); |
|
||||||
} |
|
||||||
|
|
||||||
public boolean isActive() { |
|
||||||
return ((PhysicsRigidBody)collisionObject).isActive(); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* sets the sleeping thresholds, these define when the object gets deactivated |
|
||||||
* to save ressources. Low values keep the object active when it barely moves |
|
||||||
* @param linear the linear sleeping threshold |
|
||||||
* @param angular the angular sleeping threshold |
|
||||||
*/ |
|
||||||
public void setSleepingThresholds(float linear, float angular) { |
|
||||||
((PhysicsRigidBody)collisionObject).setSleepingThresholds(linear, angular); |
|
||||||
} |
|
||||||
|
|
||||||
public void setLinearSleepingThreshold(float linearSleepingThreshold) { |
|
||||||
((PhysicsRigidBody)collisionObject).setLinearSleepingThreshold(linearSleepingThreshold); |
|
||||||
} |
|
||||||
|
|
||||||
public void setAngularSleepingThreshold(float angularSleepingThreshold) { |
|
||||||
((PhysicsRigidBody)collisionObject).setAngularSleepingThreshold(angularSleepingThreshold); |
|
||||||
} |
|
||||||
|
|
||||||
public float getLinearSleepingThreshold() { |
|
||||||
return ((PhysicsRigidBody)collisionObject).getLinearSleepingThreshold(); |
|
||||||
} |
|
||||||
|
|
||||||
public float getAngularSleepingThreshold() { |
|
||||||
return ((PhysicsRigidBody)collisionObject).getAngularSleepingThreshold(); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* do not use manually, joints are added automatically |
|
||||||
*/ |
|
||||||
public void addJoint(PhysicsJoint joint) { |
|
||||||
((PhysicsRigidBody)collisionObject).addJoint(joint); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* |
|
||||||
*/ |
|
||||||
public void removeJoint(PhysicsJoint joint) { |
|
||||||
((PhysicsRigidBody)collisionObject).removeJoint(joint); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Returns a list of connected joints. This list is only filled when |
|
||||||
* the PhysicsNode is actually added to the physics space or loaded from disk. |
|
||||||
* @return list of active joints connected to this physicsnode |
|
||||||
*/ |
|
||||||
public List<PhysicsJoint> getJoints() { |
|
||||||
return ((PhysicsRigidBody)collisionObject).getJoints(); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* used internally |
|
||||||
*/ |
|
||||||
public PhysicsRigidBody getRigidBody() { |
|
||||||
return ((PhysicsRigidBody)collisionObject); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* destroys this PhysicsNode and removes it from memory |
|
||||||
*/ |
|
||||||
public void destroy() { |
|
||||||
((PhysicsRigidBody)collisionObject).destroy(); |
|
||||||
} |
|
||||||
|
|
||||||
public void attachDebugShape(AssetManager manager) { |
|
||||||
collisionObject.attachDebugShape(manager); |
|
||||||
} |
|
||||||
|
|
||||||
public void attachDebugShape(Material mat) { |
|
||||||
collisionObject.attachDebugShape(mat); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void write(JmeExporter e) throws IOException { |
|
||||||
super.write(e); |
|
||||||
OutputCapsule capsule = e.getCapsule(this); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void read(JmeImporter e) throws IOException { |
|
||||||
super.read(e); |
|
||||||
InputCapsule capsule = e.getCapsule(this); |
|
||||||
} |
|
||||||
} |
|
@ -1,412 +0,0 @@ |
|||||||
/* |
|
||||||
* Copyright (c) 2009-2010 jMonkeyEngine |
|
||||||
* All rights reserved. |
|
||||||
* |
|
||||||
* Redistribution and use in source and binary forms, with or without |
|
||||||
* modification, are permitted provided that the following conditions are |
|
||||||
* met: |
|
||||||
* |
|
||||||
* * Redistributions of source code must retain the above copyright |
|
||||||
* notice, this list of conditions and the following disclaimer. |
|
||||||
* |
|
||||||
* * Redistributions in binary form must reproduce the above copyright |
|
||||||
* notice, this list of conditions and the following disclaimer in the |
|
||||||
* documentation and/or other materials provided with the distribution. |
|
||||||
* |
|
||||||
* * Neither the name of 'jMonkeyEngine' nor the names of its contributors |
|
||||||
* may be used to endorse or promote products derived from this software |
|
||||||
* without specific prior written permission. |
|
||||||
* |
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
|
||||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
|
||||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
||||||
*/ |
|
||||||
package com.jme3.bullet.nodes; |
|
||||||
|
|
||||||
import com.jme3.bullet.objects.VehicleWheel; |
|
||||||
import com.jme3.export.JmeExporter; |
|
||||||
import com.jme3.export.JmeImporter; |
|
||||||
import com.jme3.math.Vector3f; |
|
||||||
import com.jme3.scene.Spatial; |
|
||||||
import com.jme3.bullet.collision.shapes.CollisionShape; |
|
||||||
import com.jme3.bullet.control.VehicleControl; |
|
||||||
import com.jme3.bullet.objects.PhysicsVehicle; |
|
||||||
import com.jme3.export.InputCapsule; |
|
||||||
import com.jme3.export.OutputCapsule; |
|
||||||
import com.jme3.scene.Node; |
|
||||||
import java.io.IOException; |
|
||||||
|
|
||||||
/** |
|
||||||
* <p>PhysicsVehicleNode - Special PhysicsNode that implements vehicle functions</p> |
|
||||||
* <p> |
|
||||||
* <i>From bullet manual:</i><br> |
|
||||||
* For most vehicle simulations, it is recommended to use the simplified Bullet |
|
||||||
* vehicle model as provided in btRaycast((PhysicsVehicleControl)collisionObject). Instead of simulation each wheel |
|
||||||
* and chassis as separate rigid bodies, connected by constraints, it uses a simplified model. |
|
||||||
* This simplified model has many benefits, and is widely used in commercial driving games.<br> |
|
||||||
* The entire vehicle is represented as a single rigidbody, the chassis. |
|
||||||
* The collision detection of the wheels is approximated by ray casts, |
|
||||||
* and the tire friction is a basic anisotropic friction model. |
|
||||||
* </p> |
|
||||||
* @see com.jmex.jbullet.nodes.PhysicsNode |
|
||||||
* @see com.jmex.jbullet.PhysicsSpace |
|
||||||
* @author normenhansen |
|
||||||
* @deprecated in favor of physics Controls |
|
||||||
*/ |
|
||||||
@Deprecated |
|
||||||
public class PhysicsVehicleNode extends PhysicsNode { |
|
||||||
|
|
||||||
public PhysicsVehicleNode() { |
|
||||||
} |
|
||||||
|
|
||||||
public PhysicsVehicleNode(CollisionShape shape) { |
|
||||||
collisionObject = new VehicleControl(shape); |
|
||||||
addControl(((VehicleControl) collisionObject)); |
|
||||||
} |
|
||||||
|
|
||||||
public PhysicsVehicleNode(Spatial child, CollisionShape shape) { |
|
||||||
collisionObject = new VehicleControl(shape); |
|
||||||
attachChild(child); |
|
||||||
addControl(((VehicleControl) collisionObject)); |
|
||||||
} |
|
||||||
|
|
||||||
public PhysicsVehicleNode(Spatial child, CollisionShape shape, float mass) { |
|
||||||
collisionObject = new VehicleControl(shape); |
|
||||||
((VehicleControl) collisionObject).setMass(mass); |
|
||||||
attachChild(child); |
|
||||||
addControl(((VehicleControl) collisionObject)); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Add a wheel to this vehicle |
|
||||||
* @param connectionPoint The starting point of the ray, where the suspension connects to the chassis (chassis space) |
|
||||||
* @param direction the direction of the wheel (should be -Y / 0,-1,0 for a normal car) |
|
||||||
* @param axle The axis of the wheel, pointing right in vehicle direction (should be -X / -1,0,0 for a normal car) |
|
||||||
* @param suspensionRestLength The current length of the suspension (metres) |
|
||||||
* @param wheelRadius the wheel radius |
|
||||||
* @param isFrontWheel sets if this wheel is a front wheel (steering) |
|
||||||
* @return the PhysicsVehicleWheel object to get/set infos on the wheel |
|
||||||
*/ |
|
||||||
public VehicleWheel addWheel(Vector3f connectionPoint, Vector3f direction, Vector3f axle, float suspensionRestLength, float wheelRadius, boolean isFrontWheel) { |
|
||||||
return addWheel(null, connectionPoint, direction, axle, suspensionRestLength, wheelRadius, isFrontWheel); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Add a wheel to this vehicle |
|
||||||
* @param spat the wheel Geometry |
|
||||||
* @param connectionPoint The starting point of the ray, where the suspension connects to the chassis (chassis space) |
|
||||||
* @param direction the direction of the wheel (should be -Y / 0,-1,0 for a normal car) |
|
||||||
* @param axle The axis of the wheel, pointing right in vehicle direction (should be -X / -1,0,0 for a normal car) |
|
||||||
* @param suspensionRestLength The current length of the suspension (metres) |
|
||||||
* @param wheelRadius the wheel radius |
|
||||||
* @param isFrontWheel sets if this wheel is a front wheel (steering) |
|
||||||
* @return the PhysicsVehicleWheel object to get/set infos on the wheel |
|
||||||
*/ |
|
||||||
public VehicleWheel addWheel(Spatial spat, Vector3f connectionPoint, Vector3f direction, Vector3f axle, float suspensionRestLength, float wheelRadius, boolean isFrontWheel) { |
|
||||||
if (spat != null) { |
|
||||||
Node wheelNode=new Node("wheelNode"); |
|
||||||
wheelNode.attachChild(spat); |
|
||||||
attachChild(wheelNode); |
|
||||||
return ((VehicleControl) collisionObject).addWheel(wheelNode, connectionPoint, direction, axle, suspensionRestLength, wheelRadius, isFrontWheel); |
|
||||||
} |
|
||||||
return ((VehicleControl) collisionObject).addWheel(spat, connectionPoint, direction, axle, suspensionRestLength, wheelRadius, isFrontWheel); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* This rebuilds the vehicle as there is no way in bullet to remove a wheel. |
|
||||||
* @param wheel |
|
||||||
*/ |
|
||||||
public void removeWheel(int wheel) { |
|
||||||
((VehicleControl) collisionObject).removeWheel(wheel); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* You can get access to the single wheels via this method. |
|
||||||
* @param wheel the wheel index |
|
||||||
* @return the WheelInfo of the selected wheel |
|
||||||
*/ |
|
||||||
public VehicleWheel getWheel(int wheel) { |
|
||||||
return ((VehicleControl) collisionObject).getWheel(wheel); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @return the frictionSlip |
|
||||||
*/ |
|
||||||
public float getFrictionSlip() { |
|
||||||
return ((VehicleControl) collisionObject).getFrictionSlip(); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Use before adding wheels, this is the default used when adding wheels. |
|
||||||
* After adding the wheel, use direct wheel access.<br> |
|
||||||
* The coefficient of friction between the tyre and the ground. |
|
||||||
* Should be about 0.8 for realistic cars, but can increased for better handling. |
|
||||||
* Set large (10000.0) for kart racers |
|
||||||
* @param frictionSlip the frictionSlip to set |
|
||||||
*/ |
|
||||||
public void setFrictionSlip(float frictionSlip) { |
|
||||||
((VehicleControl) collisionObject).setFrictionSlip(frictionSlip); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* The coefficient of friction between the tyre and the ground. |
|
||||||
* Should be about 0.8 for realistic cars, but can increased for better handling. |
|
||||||
* Set large (10000.0) for kart racers |
|
||||||
* @param wheel |
|
||||||
* @param frictionSlip |
|
||||||
*/ |
|
||||||
public void setFrictionSlip(int wheel, float frictionSlip) { |
|
||||||
((VehicleControl) collisionObject).setFrictionSlip(wheel, frictionSlip); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Reduces the rolling torque applied from the wheels that cause the vehicle to roll over. |
|
||||||
* This is a bit of a hack, but it's quite effective. 0.0 = no roll, 1.0 = physical behaviour. |
|
||||||
* If m_frictionSlip is too high, you'll need to reduce this to stop the vehicle rolling over. |
|
||||||
* You should also try lowering the vehicle's centre of mass |
|
||||||
*/ |
|
||||||
public void setRollInfluence(int wheel, float rollInfluence) { |
|
||||||
((VehicleControl) collisionObject).setRollInfluence(wheel, rollInfluence); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @return the maxSuspensionTravelCm |
|
||||||
*/ |
|
||||||
public float getMaxSuspensionTravelCm() { |
|
||||||
return ((VehicleControl) collisionObject).getMaxSuspensionTravelCm(); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Use before adding wheels, this is the default used when adding wheels. |
|
||||||
* After adding the wheel, use direct wheel access.<br> |
|
||||||
* The maximum distance the suspension can be compressed (centimetres) |
|
||||||
* @param maxSuspensionTravelCm the maxSuspensionTravelCm to set |
|
||||||
*/ |
|
||||||
public void setMaxSuspensionTravelCm(float maxSuspensionTravelCm) { |
|
||||||
((VehicleControl) collisionObject).setMaxSuspensionTravelCm(maxSuspensionTravelCm); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* The maximum distance the suspension can be compressed (centimetres) |
|
||||||
* @param wheel |
|
||||||
* @param maxSuspensionTravelCm |
|
||||||
*/ |
|
||||||
public void setMaxSuspensionTravelCm(int wheel, float maxSuspensionTravelCm) { |
|
||||||
((VehicleControl) collisionObject).setMaxSuspensionForce(wheel, maxSuspensionTravelCm); |
|
||||||
} |
|
||||||
|
|
||||||
public float getMaxSuspensionForce() { |
|
||||||
return ((VehicleControl) collisionObject).getMaxSuspensionForce(); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* This vaue caps the maximum suspension force, raise this above the default 6000 if your suspension cannot |
|
||||||
* handle the weight of your vehcile. |
|
||||||
* @param maxSuspensionForce |
|
||||||
*/ |
|
||||||
public void setMaxSuspensionForce(float maxSuspensionForce) { |
|
||||||
((VehicleControl) collisionObject).setMaxSuspensionForce(maxSuspensionForce); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* This vaue caps the maximum suspension force, raise this above the default 6000 if your suspension cannot |
|
||||||
* handle the weight of your vehcile. |
|
||||||
* @param wheel |
|
||||||
* @param maxSuspensionForce |
|
||||||
*/ |
|
||||||
public void setMaxSuspensionForce(int wheel, float maxSuspensionForce) { |
|
||||||
((VehicleControl) collisionObject).setMaxSuspensionForce(wheel, maxSuspensionForce); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @return the suspensionCompression |
|
||||||
*/ |
|
||||||
public float getSuspensionCompression() { |
|
||||||
return ((VehicleControl) collisionObject).getSuspensionCompression(); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Use before adding wheels, this is the default used when adding wheels. |
|
||||||
* After adding the wheel, use direct wheel access.<br> |
|
||||||
* The damping coefficient for when the suspension is compressed. |
|
||||||
* Set to k * 2.0 * FastMath.sqrt(m_suspensionStiffness) so k is proportional to critical damping.<br> |
|
||||||
* k = 0.0 undamped & bouncy, k = 1.0 critical damping<br> |
|
||||||
* 0.1 to 0.3 are good values |
|
||||||
* @param suspensionCompression the suspensionCompression to set |
|
||||||
*/ |
|
||||||
public void setSuspensionCompression(float suspensionCompression) { |
|
||||||
((VehicleControl) collisionObject).setSuspensionCompression(suspensionCompression); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* The damping coefficient for when the suspension is compressed. |
|
||||||
* Set to k * 2.0 * FastMath.sqrt(m_suspensionStiffness) so k is proportional to critical damping.<br> |
|
||||||
* k = 0.0 undamped & bouncy, k = 1.0 critical damping<br> |
|
||||||
* 0.1 to 0.3 are good values |
|
||||||
* @param wheel |
|
||||||
* @param suspensionCompression |
|
||||||
*/ |
|
||||||
public void setSuspensionCompression(int wheel, float suspensionCompression) { |
|
||||||
((VehicleControl) collisionObject).setSuspensionCompression(wheel, suspensionCompression); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @return the suspensionDamping |
|
||||||
*/ |
|
||||||
public float getSuspensionDamping() { |
|
||||||
return ((VehicleControl) collisionObject).getSuspensionDamping(); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Use before adding wheels, this is the default used when adding wheels. |
|
||||||
* After adding the wheel, use direct wheel access.<br> |
|
||||||
* The damping coefficient for when the suspension is expanding. |
|
||||||
* See the comments for setSuspensionCompression for how to set k. |
|
||||||
* @param suspensionDamping the suspensionDamping to set |
|
||||||
*/ |
|
||||||
public void setSuspensionDamping(float suspensionDamping) { |
|
||||||
((VehicleControl) collisionObject).setSuspensionDamping(suspensionDamping); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* The damping coefficient for when the suspension is expanding. |
|
||||||
* See the comments for setSuspensionCompression for how to set k. |
|
||||||
* @param wheel |
|
||||||
* @param suspensionDamping |
|
||||||
*/ |
|
||||||
public void setSuspensionDamping(int wheel, float suspensionDamping) { |
|
||||||
((VehicleControl) collisionObject).setSuspensionDamping(wheel, suspensionDamping); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @return the suspensionStiffness |
|
||||||
*/ |
|
||||||
public float getSuspensionStiffness() { |
|
||||||
return ((VehicleControl) collisionObject).getSuspensionStiffness(); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Use before adding wheels, this is the default used when adding wheels. |
|
||||||
* After adding the wheel, use direct wheel access.<br> |
|
||||||
* The stiffness constant for the suspension. 10.0 - Offroad buggy, 50.0 - Sports car, 200.0 - F1 Car |
|
||||||
* @param suspensionStiffness |
|
||||||
*/ |
|
||||||
public void setSuspensionStiffness(float suspensionStiffness) { |
|
||||||
((VehicleControl) collisionObject).setSuspensionStiffness(suspensionStiffness); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* The stiffness constant for the suspension. 10.0 - Offroad buggy, 50.0 - Sports car, 200.0 - F1 Car |
|
||||||
* @param wheel |
|
||||||
* @param suspensionStiffness |
|
||||||
*/ |
|
||||||
public void setSuspensionStiffness(int wheel, float suspensionStiffness) { |
|
||||||
((VehicleControl) collisionObject).setSuspensionStiffness(wheel, suspensionStiffness); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Reset the suspension |
|
||||||
*/ |
|
||||||
public void resetSuspension() { |
|
||||||
((VehicleControl) collisionObject).resetSuspension(); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Apply the given engine force to all wheels, works continuously |
|
||||||
* @param force the force |
|
||||||
*/ |
|
||||||
public void accelerate(float force) { |
|
||||||
((VehicleControl) collisionObject).accelerate(force); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Apply the given engine force, works continuously |
|
||||||
* @param wheel the wheel to apply the force on |
|
||||||
* @param force the force |
|
||||||
*/ |
|
||||||
public void accelerate(int wheel, float force) { |
|
||||||
((VehicleControl) collisionObject).accelerate(wheel, force); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Set the given steering value to all front wheels (0 = forward) |
|
||||||
* @param value the steering angle of the front wheels (Pi = 360deg) |
|
||||||
*/ |
|
||||||
public void steer(float value) { |
|
||||||
((VehicleControl) collisionObject).steer(value); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Set the given steering value to the given wheel (0 = forward) |
|
||||||
* @param wheel the wheel to set the steering on |
|
||||||
* @param value the steering angle of the front wheels (Pi = 360deg) |
|
||||||
*/ |
|
||||||
public void steer(int wheel, float value) { |
|
||||||
((VehicleControl) collisionObject).steer(wheel, value); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Apply the given brake force to all wheels, works continuously |
|
||||||
* @param force the force |
|
||||||
*/ |
|
||||||
public void brake(float force) { |
|
||||||
((VehicleControl) collisionObject).brake(force); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Apply the given brake force, works continuously |
|
||||||
* @param wheel the wheel to apply the force on |
|
||||||
* @param force the force |
|
||||||
*/ |
|
||||||
public void brake(int wheel, float force) { |
|
||||||
((VehicleControl) collisionObject).brake(wheel, force); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Get the current speed of the vehicle in km/h |
|
||||||
* @return |
|
||||||
*/ |
|
||||||
public float getCurrentVehicleSpeedKmHour() { |
|
||||||
return ((VehicleControl) collisionObject).getCurrentVehicleSpeedKmHour(); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Get the current forward vector of the vehicle in world coordinates |
|
||||||
* @param vector |
|
||||||
* @return |
|
||||||
*/ |
|
||||||
public Vector3f getForwardVector(Vector3f vector) { |
|
||||||
return ((VehicleControl) collisionObject).getForwardVector(vector); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* used internally |
|
||||||
*/ |
|
||||||
public PhysicsVehicle getVehicle() { |
|
||||||
return ((VehicleControl) collisionObject); |
|
||||||
} |
|
||||||
|
|
||||||
public void destroy() { |
|
||||||
((VehicleControl) collisionObject).destroy(); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void read(JmeImporter im) throws IOException { |
|
||||||
super.read(im); |
|
||||||
InputCapsule capsule = im.getCapsule(this); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void write(JmeExporter ex) throws IOException { |
|
||||||
super.write(ex); |
|
||||||
OutputCapsule capsule = ex.getCapsule(this); |
|
||||||
} |
|
||||||
} |
|
Loading…
Reference in new issue