com.jme.scene.shape
Class Capsule

java.lang.Object
  extended by com.jme.scene.Spatial
      extended by com.jme.scene.Geometry
          extended by com.jme.scene.TriMesh
              extended by com.jme.scene.shape.Capsule
All Implemented Interfaces:
Savable, java.io.Serializable

public class Capsule
extends TriMesh

A capsule is a cylindrical section capped with a dome at either end.

Capsules are defined by their height and radius, and the sampling granularity.

Version:
$Revision: 4131 $, $Date: 2009-03-19 20:15:28 +0000 (Thu, 19 Mar 2009) $
Author:
Joshua Slack
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class com.jme.scene.TriMesh
TriMesh.Mode
 
Nested classes/interfaces inherited from class com.jme.scene.Spatial
Spatial.CullHint, Spatial.LightCombineMode, Spatial.NormalsMode, Spatial.TextureCombineMode
 
Field Summary
 
Fields inherited from class com.jme.scene.TriMesh
indexBuffer, mode, triangleQuantity
 
Fields inherited from class com.jme.scene.Geometry
binormalBuf, bound, castsShadows, colorBuf, compVect, defaultColor, displayListID, enabled, fogBuf, hasDirtyVertices, normBuf, states, tangentBuf, texBuf, vboInfo, vertBuf, vertQuantity
 
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
Capsule()
           
Capsule(java.lang.String name, int axisSamples, int radialSamples, int sphereSamples, float radius, float height)
          Creates a new capsule.
 
Method Summary
 int getAxisSamples()
          Get the sampling frequency lengthwise along the capsules main axis.
 float getHeight()
           
 int getRadialSamples()
          Get the sampling frequency radially around the capsules main axis.
 float getRadius()
           
 int getSphereSamples()
          Get the sampling frequency used for the domes at either end of the capsule.
 void read(JMEImporter e)
           
 void reconstruct(Vector3f top, Vector3f bottom, float radius)
          Deprecated. use @{link updateGeometry(Vector3f, Vector3f, float).
 void updateGeometry(int axisSamples, int radialSamples, int sphereSamples, float radius, float height)
          Rebuilds this capsule based on a new set of parameters.
 void updateGeometry(Vector3f top, Vector3f bottom, float radius)
          Rebuilds this capsule based on a new set of parameters.
 void write(JMEExporter e)
           
 
Methods inherited from class com.jme.scene.TriMesh
clearBuffers, draw, findCollisions, findTriangleCollision, findTrianglePick, getIndexBuffer, getMaxIndex, getMeshAsTriangles, getMeshAsTrianglesVertices, getMode, getTriangle, getTriangle, getTriangleCount, getTriangleIndices, getVertIndex, hasCollision, hasTriangleCollision, randomPointOnTriangles, recalcTriangleQuantity, reconstruct, setIndexBuffer, setMode, setTriangleQuantity
 
Methods inherited from class com.jme.scene.Geometry
addTextureCoordinates, addTextureCoordinates, applyRenderState, checkTextureCoordinates, clearTextureBuffers, copyTextureCoordinates, copyTextureCoordinates, findPick, getBinormalBuffer, getColorBuffer, getDefaultColor, getDisplayListID, getFogBuffer, getLightState, getModelBound, getNormalBuffer, getNumberOfUnits, getTangentBuffer, getTextureCoords, getTextureCoords, getVBOInfo, getVertexBuffer, getVertexCount, getWorldCoords, getWorldNormals, hasDirtyVertices, isCastsShadows, lockMeshes, postdraw, predraw, randomVertex, reconstruct, resizeTextureIds, rotateNormals, rotatePoints, scaleTextureCoordinates, scaleTextureCoordinates, setBinormalBuffer, setCastsShadows, setColorBuffer, setDefaultColor, setDisplayListID, setFogCoordBuffer, setHasDirtyVertices, setLightState, setModelBound, setNormalBuffer, setRandomColors, setSolidColor, setTangentBuffer, setTextureCoords, setTextureCoords, setTextureCoords, setVBOInfo, setVertexBuffer, setVertexCount, sortLights, translatePoints, translatePoints, unlockMeshes, updateModelBound, updateWorldBound
 
Methods inherited from class com.jme.scene.Spatial
addController, 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, 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, setParent, setRenderQueueMode, setRenderState, setTextureCombineMode, setUserData, setZOrder, setZOrder, toString, unlock, unlock, unlockBounds, unlockBranch, 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
 
Methods inherited from interface com.jme.util.export.Savable
getClassTag
 

Constructor Detail

Capsule

public Capsule()

Capsule

public Capsule(java.lang.String name,
               int axisSamples,
               int radialSamples,
               int sphereSamples,
               float radius,
               float height)
Creates a new capsule.

By default its center is the origin. Usually, a higher sample number creates a better looking cylinder, but at the cost of more vertex information.

If the cylinder is closed the texture is split into axisSamples parts: top most and bottom most part is used for top and bottom of the cylinder, rest of the texture for the cylinder wall. The middle of the top is mapped to texture coordinates (0.5, 1), bottom to (0.5, 0). Thus you need a suited distorted texture.

Parameters:
name - the name of this capsule.
axisSamples - the number of samples along the axis.
radialSamples - the number of samples sround the radial.
radius - the radius of the cylinder.
height - the cylinder’s height.
Method Detail

getAxisSamples

public int getAxisSamples()
Get the sampling frequency lengthwise along the capsules main axis.


getHeight

public float getHeight()
Returns:
Returns the height.

getRadialSamples

public int getRadialSamples()
Get the sampling frequency radially around the capsules main axis.


getRadius

public float getRadius()
Returns:
Returns the radius.

getSphereSamples

public int getSphereSamples()
Get the sampling frequency used for the domes at either end of the capsule.


read

public void read(JMEImporter e)
          throws java.io.IOException
Specified by:
read in interface Savable
Overrides:
read in class TriMesh
Throws:
java.io.IOException

reconstruct

public void reconstruct(Vector3f top,
                        Vector3f bottom,
                        float radius)
Deprecated. use @{link updateGeometry(Vector3f, Vector3f, float).


updateGeometry

public void updateGeometry(int axisSamples,
                           int radialSamples,
                           int sphereSamples,
                           float radius,
                           float height)
Rebuilds this capsule based on a new set of parameters.

Parameters:
axisSamples - the number of samples along the axis.
radialSamples - the number of samples along the radial.
sphereSamples - the number of samples for the dom end caps.
radius - the radius of the cylinder.
height - the cylinder's height.

updateGeometry

public void updateGeometry(Vector3f top,
                           Vector3f bottom,
                           float radius)
Rebuilds this capsule based on a new set of parameters.

Parameters:
top - the top of the casule.
bottom - the bottom of the capsule.
radius - the radius of the cylinder.

write

public void write(JMEExporter e)
           throws java.io.IOException
Specified by:
write in interface Savable
Overrides:
write in class TriMesh
Throws:
java.io.IOException