|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.jme.scene.Spatial
com.jme.scene.Geometry
com.jme.scene.TriMesh
com.jmex.effects.cloth.ClothPatch
public class ClothPatch
ClothPatch
is a rectangular trimesh representing a piece of
Cloth. It is backed up by and shares verts and normals with a SpringSystem.
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 | |
---|---|
protected int |
clothNodesX
width, number of nodes wide on x axis. |
protected int |
clothNodesY
height, number of nodes high on y axis. |
protected float |
sinceLast
Internal time watch used to track time since last update. |
protected float |
springLength
The initial spring length of structural springs. |
protected SpringSystem |
system
The underlying SpringSystem for this ClothPatch. |
protected float |
timeDilation
Dilation factor to multiply elapsed time by for use in updating underlying system. |
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 | |
---|---|
ClothPatch()
|
|
ClothPatch(java.lang.String name,
int nodesX,
int nodesY,
float springLength,
float nodeMass)
Public constructor. |
|
ClothPatch(java.lang.String name,
int nodesX,
int nodesY,
Vector3f upperLeft,
Vector3f lowerLeft,
Vector3f lowerRight,
Vector3f upperRight,
float nodeMass)
|
Method Summary | |
---|---|
void |
addForce(SpringPointForce force)
Add an external force to the underlying SpringSystem. |
protected void |
calcForces(float sinceLast)
Calculate the forces accting on this cloth. |
protected void |
doUpdate(float sinceLast)
Update the spring system underlying this cloth. |
int |
getClothNodesX()
Return how many nodes wide this cloth is. |
int |
getClothNodesY()
Return how many nodes high this cloth is. |
protected int |
getIndex(int x,
int y)
Convienence method for calculating the array index of a given node given it's x and y coordiates. |
float |
getSpringLength()
Return the preset length the structural springs are set to. |
SpringSystem |
getSystem()
Return the underlying SpringSystem. |
float |
getTimeDilation()
Get the time dilation factor. |
protected Vector3f |
getTriangleNormal(int vert1,
int vert2,
int vert3,
Vector3f store)
Get the normal of the triangle defined by the given vertices. |
protected void |
initCloth(float nodeMass)
Initialize the values of the vertex, normal and texture[0] arrays. |
protected void |
initCloth(float nodeMass,
Vector3f upperLeft,
Vector3f lowerLeft,
Vector3f lowerRight,
Vector3f upperRight)
Initialize the values of the vertex, normal and texture[0] arrays. |
void |
read(JMEImporter e)
|
boolean |
removeForce(SpringPointForce force)
Remove a force from the underlying SpringSystem. |
void |
setActive(boolean active)
Whether or not to update cloth patch |
void |
setTimeDilation(float timeDilation)
Set the timedilation factor used in updateWorldData(float)
Normally this is set to 1. |
void |
setUpdateFrequency(float fps)
set update frequency of flag motion |
protected void |
setupIndices()
Setup the triangle indices for this cloth. |
void |
updateNormals()
Update the normals in the system. |
protected void |
updateVertexBufferfer()
|
void |
updateWorldData(float dt)
Update the physics of this cloth. |
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 java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface com.jme.util.export.Savable |
---|
getClassTag |
Field Detail |
---|
protected int clothNodesX
protected int clothNodesY
protected float springLength
protected SpringSystem system
protected float sinceLast
protected float timeDilation
Constructor Detail |
---|
public ClothPatch()
public ClothPatch(java.lang.String name, int nodesX, int nodesY, float springLength, float nodeMass)
name
- StringnodesX
- number of nodes wide this cloth will be.nodesY
- number of nodes high this cloth will be.springLength
- distance between each nodenodeMass
- mass of an individual node in this Cloth.public ClothPatch(java.lang.String name, int nodesX, int nodesY, Vector3f upperLeft, Vector3f lowerLeft, Vector3f lowerRight, Vector3f upperRight, float nodeMass)
Method Detail |
---|
public void addForce(SpringPointForce force)
force
- SpringPointForcepublic boolean removeForce(SpringPointForce force)
force
- SpringPointForce
public void updateNormals()
protected Vector3f getTriangleNormal(int vert1, int vert2, int vert3, Vector3f store)
vert1
- triangle point #1vert2
- triangle point #2vert3
- triangle point #3store
- Vector3f to store result in
protected void initCloth(float nodeMass)
nodeMass
- mass of individual node.protected void initCloth(float nodeMass, Vector3f upperLeft, Vector3f lowerLeft, Vector3f lowerRight, Vector3f upperRight)
nodeMass
- mass of individual node.upperLeft
- the upper left corner of the rectangle.lowerLeft
- the lower left corner of the rectangle.lowerRight
- the lower right corner of the rectangle.upperRight
- the upper right corner of the rectangle.public SpringSystem getSystem()
public int getClothNodesY()
public int getClothNodesX()
public float getSpringLength()
public float getTimeDilation()
setTimeDilation(float)
for more.
public void setTimeDilation(float timeDilation)
updateWorldData(float)
Normally this is set to 1. If set at 2, for example, every 25 ms of real
time, the code will update the SpringSystem and cloth as if 50 ms had
passed.
timeDilation
- floatpublic void setUpdateFrequency(float fps)
fps
- frame per secondpublic void setActive(boolean active)
active
- if true, enable flag motionprotected void setupIndices()
protected int getIndex(int x, int y)
x
- inty
- int
public void updateWorldData(float dt)
updateWorldData
in class Spatial
dt
- time since last call to this method. Used to determine if
enough time has passed to require an update of the
SpringSystem and cloth data, normals, etc.protected void calcForces(float sinceLast)
updateWorldData(float)
sinceLast
- floatprotected void doUpdate(float sinceLast)
updateWorldData(float)
sinceLast
- floatprotected void updateVertexBufferfer()
public void write(JMEExporter e) throws java.io.IOException
write
in interface Savable
write
in class TriMesh
java.io.IOException
public void read(JMEImporter e) throws java.io.IOException
read
in interface Savable
read
in class TriMesh
java.io.IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |