com.jmex.physics
Class PhysicsCollisionGeometry

java.lang.Object
  extended by com.jme.scene.Spatial
      extended by com.jmex.physics.PhysicsCollisionGeometry
All Implemented Interfaces:
com.jme.util.export.Savable, PhysicsSpatial, java.io.Serializable
Direct Known Subclasses:
PhysicsBox, PhysicsCapsule, PhysicsCylinder, PhysicsMesh, PhysicsRay, PhysicsSphere

public abstract class PhysicsCollisionGeometry
extends com.jme.scene.Spatial
implements PhysicsSpatial

Subclasses of this class are used to specify the physical geometry of a PhysicsNode. The physical geometry defines the collision bounds for the physics simulation. Advanced implementation may even use them for mass distribution of dynamic nodes.

PhysicsCollisionGeometries are created via the create* methods in PhysicsNode.

TODO: Cylinder, Cone, Capsule, TriMesh, Plane?, Ray?

Author:
Irrisor
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class com.jme.scene.Spatial
com.jme.scene.Spatial.CullHint, com.jme.scene.Spatial.LightCombineMode, com.jme.scene.Spatial.NormalsMode, com.jme.scene.Spatial.TextureCombineMode
 
Field Summary
static java.lang.String MATERIAL_PROPERTY
           
static java.lang.String PHYSICS_NODE_PROPERTY
           
 
Fields inherited from class com.jme.scene.Spatial
cullHint, frustrumIntersects, geometricalControllers, isCollidable, lightCombineMode, localRotation, localScale, localTranslation, LOCKED_BOUNDS, LOCKED_BRANCH, LOCKED_MESH_DATA, LOCKED_NONE, LOCKED_SHADOWS, LOCKED_TRANSFORMS, lockedMode, name, normalsMode, parent, queueDistance, renderQueueMode, renderStateList, textureCombineMode, worldBound, worldRotation, worldScale, worldTranslation, zOrder
 
Constructor Summary
protected PhysicsCollisionGeometry(PhysicsNode node)
           
protected PhysicsCollisionGeometry(PhysicsNode node, java.lang.String name)
           
 
Method Summary
 void draw(com.jme.renderer.Renderer r)
           
protected abstract  void drawDebugShape(PhysicsNode physicsNode, com.jme.renderer.Renderer renderer)
          Draw a visual representation of this physical collision bound.
 void findCollisions(com.jme.scene.Spatial scene, com.jme.intersection.CollisionResults results)
           
 void findPick(com.jme.math.Ray toTest, com.jme.intersection.PickResults results)
           
 com.jme.input.util.SyntheticButton getCollisionEventHandler()
          Creates a synthetic button that is triggered when this node collides with another node.
 Material getMaterial()
          Query material of this geometry.
 PhysicsNode getPhysicsNode()
           
 int getTriangleCount()
           
 int getVertexCount()
           
abstract  float getVolume()
          Query the volume of this geometry.
 boolean hasCollision(com.jme.scene.Spatial scene, boolean checkTriangles)
           
 void read(com.jme.util.export.JMEImporter im)
           
static PhysicsNode readPhysicsNodeFromInputCapsule(com.jme.util.export.InputCapsule inputCapsule)
           
 void setMaterial(Material value)
          Change material of this geometry.
 void setModelBound(com.jme.bounding.BoundingVolume modelBound)
           
protected  void setNode(PhysicsNode node)
          Allow to change the associated node by the implementation
protected  void setParent(com.jme.scene.Node parent)
          Allow only PhysicsNodes as parent.
 void updateModelBound()
           
 void updateWorldBound()
           
 void write(com.jme.util.export.JMEExporter ex)
           
 
Methods inherited from class com.jme.scene.Spatial
addController, applyRenderState, calculateCollisions, calculatePick, clearControllers, clearRenderState, clearRenderState, getClassTag, getController, getControllerCount, getControllers, getCullHint, getLastFrustumIntersection, getLightCombineMode, getLocalCullHint, getLocalLightCombineMode, getLocalNormalsMode, getLocalRenderQueueMode, getLocalRotation, getLocalScale, getLocalTextureCombineMode, getLocalToWorldMatrix, getLocalTranslation, getLocks, getName, getNormalsMode, getParent, getRenderQueueMode, getRenderState, getRenderState, getTextureCombineMode, getUserData, getWorldBound, getWorldRotation, getWorldScale, getWorldTranslation, getZOrder, hasAncestor, isCollidable, localToWorld, lock, lock, lockBounds, lockBranch, lockMeshes, lockMeshes, lockShadows, lockTransforms, lookAt, onDraw, propagateBoundToRoot, propagateStatesFromRoot, removeController, removeController, removeFromParent, removeUserData, rotateUpTo, setCullHint, setIsCollidable, setLastFrustumIntersection, setLightCombineMode, setLocalRotation, setLocalRotation, setLocalScale, setLocalScale, setLocalTranslation, setLocalTranslation, setLocks, setLocks, setName, setNormalsMode, setRenderQueueMode, setRenderState, setTextureCombineMode, setUserData, setZOrder, setZOrder, sortLights, toString, unlock, unlock, unlockBounds, unlockBranch, unlockMeshes, unlockMeshes, unlockShadows, unlockTransforms, updateGeometricState, updateRenderState, updateRenderState, updateWorldData, updateWorldRotation, updateWorldScale, updateWorldTranslation, updateWorldVectors, updateWorldVectors, worldToLocal
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PHYSICS_NODE_PROPERTY

public static final java.lang.String PHYSICS_NODE_PROPERTY
See Also:
Constant Field Values

MATERIAL_PROPERTY

public static final java.lang.String MATERIAL_PROPERTY
See Also:
Constant Field Values
Constructor Detail

PhysicsCollisionGeometry

protected PhysicsCollisionGeometry(PhysicsNode node,
                                   java.lang.String name)

PhysicsCollisionGeometry

protected PhysicsCollisionGeometry(PhysicsNode node)
Method Detail

draw

public void draw(com.jme.renderer.Renderer r)
Specified by:
draw in class com.jme.scene.Spatial

getTriangleCount

public int getTriangleCount()
Specified by:
getTriangleCount in class com.jme.scene.Spatial

getVertexCount

public int getVertexCount()
Specified by:
getVertexCount in class com.jme.scene.Spatial

setNode

protected void setNode(PhysicsNode node)
Allow to change the associated node by the implementation

Parameters:
node - new phyiscs node of this geometry

read

public void read(com.jme.util.export.JMEImporter im)
          throws java.io.IOException
Specified by:
read in interface com.jme.util.export.Savable
Overrides:
read in class com.jme.scene.Spatial
Throws:
java.io.IOException

write

public void write(com.jme.util.export.JMEExporter ex)
           throws java.io.IOException
Specified by:
write in interface com.jme.util.export.Savable
Overrides:
write in class com.jme.scene.Spatial
Throws:
java.io.IOException

readPhysicsNodeFromInputCapsule

public static PhysicsNode readPhysicsNodeFromInputCapsule(com.jme.util.export.InputCapsule inputCapsule)
                                                   throws java.io.IOException
Throws:
java.io.IOException

setParent

protected void setParent(com.jme.scene.Node parent)
Allow only PhysicsNodes as parent.

Overrides:
setParent in class com.jme.scene.Spatial
Parameters:
parent - new parent
See Also:
Spatial.setParent(com.jme.scene.Node)

drawDebugShape

protected abstract void drawDebugShape(PhysicsNode physicsNode,
                                       com.jme.renderer.Renderer renderer)
Draw a visual representation of this physical collision bound.

Parameters:
physicsNode - node this geometry belongs to
renderer - where to draw to

findCollisions

public void findCollisions(com.jme.scene.Spatial scene,
                           com.jme.intersection.CollisionResults results)
Specified by:
findCollisions in class com.jme.scene.Spatial

findPick

public void findPick(com.jme.math.Ray toTest,
                     com.jme.intersection.PickResults results)
Specified by:
findPick in class com.jme.scene.Spatial

hasCollision

public boolean hasCollision(com.jme.scene.Spatial scene,
                            boolean checkTriangles)
Specified by:
hasCollision in class com.jme.scene.Spatial

updateWorldBound

public void updateWorldBound()
Specified by:
updateWorldBound in class com.jme.scene.Spatial

getPhysicsNode

public final PhysicsNode getPhysicsNode()
Specified by:
getPhysicsNode in interface PhysicsSpatial
Returns:
the PhysicsNode this collision geometry belongs to

getMaterial

public Material getMaterial()
Query material of this geometry. If no material was set for this geometry the material of the physics node is returned.

Returns:
material used for this geometry, not null
See Also:
PhysicsNode.getMaterial()

setMaterial

public void setMaterial(Material value)
Change material of this geometry. If the same material is specified for a geometry as the physics node currently has the material of this geometry is inherited. The same applies if no material is set for a geometry.

Parameters:
value - new material
See Also:
PhysicsNode.setMaterial(com.jmex.physics.material.Material)

getVolume

public abstract float getVolume()
Query the volume of this geometry. Commonly used for mass calculation.

Returns:
the current value of this geometry

getCollisionEventHandler

public com.jme.input.util.SyntheticButton getCollisionEventHandler()
Creates a synthetic button that is triggered when this node collides with another node.

Note: if this event handler is obtained it must be used with an InputHandler which is updated regularly

Returns:
a synthetic button that is triggered on a collision event that involves this node
See Also:
PhysicsSpace.getCollisionEventHandler()

updateModelBound

public void updateModelBound()
Specified by:
updateModelBound in class com.jme.scene.Spatial

setModelBound

public void setModelBound(com.jme.bounding.BoundingVolume modelBound)
Specified by:
setModelBound in class com.jme.scene.Spatial