|
||||||||||
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
public class TriMesh
TriMesh
defines a geometry mesh. This mesh defines a three
dimensional object via a collection of points, colors, normals and textures.
The points are referenced via a indices array. This array instructs the
renderer the order in which to draw the points, creating triangles based on the mode set.
Nested Class Summary | |
---|---|
static class |
TriMesh.Mode
|
Nested classes/interfaces inherited from class com.jme.scene.Spatial |
---|
Spatial.CullHint, Spatial.LightCombineMode, Spatial.NormalsMode, Spatial.TextureCombineMode |
Field Summary | |
---|---|
protected java.nio.IntBuffer |
indexBuffer
|
protected TriMesh.Mode |
mode
|
protected int |
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 | |
---|---|
TriMesh()
Empty Constructor to be used internally only. |
|
TriMesh(java.lang.String name)
Constructor instantiates a new TriMesh object. |
|
TriMesh(java.lang.String name,
java.nio.FloatBuffer vertices,
java.nio.FloatBuffer normal,
java.nio.FloatBuffer color,
TexCoords coords,
java.nio.IntBuffer indices)
Constructor instantiates a new TriMesh object. |
Method Summary | |
---|---|
void |
clearBuffers()
Clears the buffers of this TriMesh. |
void |
draw(Renderer r)
draw calls super to set the render state then passes
itself to the renderer. |
void |
findCollisions(Spatial scene,
CollisionResults results)
determines if this TriMesh has made contact with the give scene. |
void |
findTriangleCollision(TriMesh toCheck,
java.util.ArrayList<java.lang.Integer> thisIndex,
java.util.ArrayList<java.lang.Integer> otherIndex)
This function finds all intersections between this trimesh and the checking one. |
void |
findTrianglePick(Ray toTest,
java.util.ArrayList<java.lang.Integer> results)
findTrianglePick determines the triangles of this trimesh
that are being touched by the ray. |
java.nio.IntBuffer |
getIndexBuffer()
|
int |
getMaxIndex()
|
Triangle[] |
getMeshAsTriangles(Triangle[] tris)
|
Vector3f[] |
getMeshAsTrianglesVertices(Vector3f[] verts)
Return this mesh object as triangles. |
TriMesh.Mode |
getMode()
|
void |
getTriangle(int i,
int[] storage)
Stores in the storage array the indices of triangle
i . |
void |
getTriangle(int i,
Vector3f[] vertices)
Stores in the vertices array the vertex values of triangle
i . |
int |
getTriangleCount()
Returns the number of triangles contained in this mesh. |
int[] |
getTriangleIndices(int[] indices)
|
protected int |
getVertIndex(int triangle,
int point)
|
boolean |
hasCollision(Spatial scene,
boolean checkTriangles)
determines if a collision between this trimesh and a given spatial occurs if it has true is returned, otherwise false is returned. |
boolean |
hasTriangleCollision(TriMesh toCheck)
This function checks for intersection between this trimesh and the given one. |
Vector3f |
randomPointOnTriangles(Vector3f fill,
Vector3f work)
Returns a random point on the surface of a randomly selected triangle on the mesh |
void |
read(JMEImporter e)
|
protected void |
recalcTriangleQuantity()
|
void |
reconstruct(java.nio.FloatBuffer vertices,
java.nio.FloatBuffer normal,
java.nio.FloatBuffer color,
TexCoords coords,
java.nio.IntBuffer indices)
Recreates the geometric information of this TriMesh from scratch. |
void |
setIndexBuffer(java.nio.IntBuffer indices)
|
void |
setMode(TriMesh.Mode mode)
|
void |
setTriangleQuantity(int triangleQuantity)
|
void |
write(JMEExporter e)
|
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 transient java.nio.IntBuffer indexBuffer
protected TriMesh.Mode mode
protected int triangleQuantity
Constructor Detail |
---|
public TriMesh()
public TriMesh(java.lang.String name)
TriMesh
object.
name
- the name of the scene element. This is required for
identification and comparision purposes.public TriMesh(java.lang.String name, java.nio.FloatBuffer vertices, java.nio.FloatBuffer normal, java.nio.FloatBuffer color, TexCoords coords, java.nio.IntBuffer indices)
TriMesh
object. Provided
are the attributes that make up the mesh all attributes may be null,
except for vertices and indices.
name
- the name of the scene element. This is required for
identification and comparision purposes.vertices
- the vertices of the geometry.normal
- the normals of the geometry.color
- the colors of the geometry.coords
- the texture coordinates of the mesh.indices
- the indices of the vertex array.Method Detail |
---|
public void reconstruct(java.nio.FloatBuffer vertices, java.nio.FloatBuffer normal, java.nio.FloatBuffer color, TexCoords coords, java.nio.IntBuffer indices)
vertices
array that
refrences a vertex of a triangle.
vertices
- The vertex information for this TriMesh.normal
- The normal information for this TriMesh.color
- The color information for this TriMesh.coords
- The texture information for this TriMesh.indices
- The index information for this TriMesh.public void setMode(TriMesh.Mode mode)
public TriMesh.Mode getMode()
public java.nio.IntBuffer getIndexBuffer()
public void setIndexBuffer(java.nio.IntBuffer indices)
protected void recalcTriangleQuantity()
public int getTriangleCount()
getTriangleCount
in class Geometry
public void setTriangleQuantity(int triangleQuantity)
public void draw(Renderer r)
draw
calls super to set the render state then passes
itself to the renderer. LOGIC: 1. If we're not RenderQueue calling draw
goto 2, if we are, goto 3 2. If we are supposed to use queue, add to
queue and RETURN, else 3 3. call super draw 4. tell renderer to draw me.
draw
in class Geometry
r
- the renderer to displaySpatial.draw(com.jme.renderer.Renderer)
public void clearBuffers()
clearBuffers
in class Geometry
public boolean hasCollision(Spatial scene, boolean checkTriangles)
hasCollision
in class Spatial
scene
- the scene to test against.checkTriangles
- check for collisions on triangle accuracy level
public void findCollisions(Spatial scene, CollisionResults results)
findCollisions
in class Spatial
scene
- the scene to test against.results
- the results of the collisions.public boolean hasTriangleCollision(TriMesh toCheck)
toCheck
- The intersection testing mesh.
public void findTriangleCollision(TriMesh toCheck, java.util.ArrayList<java.lang.Integer> thisIndex, java.util.ArrayList<java.lang.Integer> otherIndex)
toCheck
- The TriMesh to check.thisIndex
- The array of triangle indexes intersecting in this mesh.otherIndex
- The array of triangle indexes intersecting in the given mesh.public void getTriangle(int i, int[] storage)
storage
array the indices of triangle
i
. If i
is an invalid index, or if
storage.length<3
, then nothing happens
i
- The index of the triangle to get.storage
- The array that will hold the i's indexes.public void getTriangle(int i, Vector3f[] vertices)
vertices
array the vertex values of triangle
i
. If i
is an invalid triangle index,
nothing happens.
i
- vertices
- public void findTrianglePick(Ray toTest, java.util.ArrayList<java.lang.Integer> results)
findTrianglePick
determines the triangles of this trimesh
that are being touched by the ray. The indices of the triangles are
stored in the provided ArrayList.
toTest
- the ray to test. The direction of the ray must be normalized
(length 1).results
- the indices to the triangles.public Vector3f[] getMeshAsTrianglesVertices(Vector3f[] verts)
verts
- a storage array to place the results in
protected int getVertIndex(int triangle, int point)
public int[] getTriangleIndices(int[] indices)
public Triangle[] getMeshAsTriangles(Triangle[] tris)
public int getMaxIndex()
public Vector3f randomPointOnTriangles(Vector3f fill, Vector3f work)
fill
- The resulting selected pointwork
- Used in calculations to minimize memory creation overhead
public void write(JMEExporter e) throws java.io.IOException
write
in interface Savable
write
in class Geometry
java.io.IOException
public void read(JMEImporter e) throws java.io.IOException
read
in interface Savable
read
in class Geometry
java.io.IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |