|
||||||||||
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.jme.scene.SharedMesh
public class SharedMesh
SharedMesh
allows the sharing of data between multiple nodes.
A provided TriMesh is used as the model for this node. This allows the user
to place multiple copies of the same object throughout the scene without
having to duplicate data. It should be known that any change to the provided
target mesh will affect the appearance of this mesh, including animations.
Secondly, the SharedMesh is read only. Any attempt to write to the mesh data
via set* methods, will result in a warning being logged and nothing else. Any
changes to the mesh should happened to the target mesh being shared.
If you plan to use collisions with a SharedMesh
it is
recommended that you disable the passing of updateCollisionTree
calls to the target mesh. This is to prevent multiple calls to the target's
updateCollisionTree
method, from different shared meshes.
Instead of this method being called from the scenegraph, you can now invoke
it directly on the target mesh, thus ensuring it will only be invoked once.
Important: It is highly recommended that the Target mesh is NOT
placed into the scenegraph, as its translation, rotation and scale are
replaced by the shared meshes using it before they are rendered.
Note: Special thanks to Kevin Glass.
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 | |
---|---|
SharedMesh()
|
|
SharedMesh(java.lang.String name,
TriMesh target)
Constructor creates a new SharedMesh object. |
|
SharedMesh(TriMesh target)
Constructor creates a new SharedMesh object. |
Method Summary | |
---|---|
void |
clearBuffers()
clearBuffers is not supported by SharedMesh |
void |
copyTextureCoordinates(int fromIndex,
int toIndex,
float factor)
copyTextureCoords is not supported by SharedMesh. |
void |
draw(Renderer r)
draw renders the target mesh, at the translation, rotation and scale of this shared mesh. |
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 the target
trimesh that are being touched by the ray. |
java.nio.FloatBuffer |
getBinormalBuffer()
|
java.nio.FloatBuffer |
getColorBuffer()
getColorBuffer retrieves the float buffer that contains
the target geometry's color information. |
ColorRGBA |
getDefaultColor()
getDefaultColor returns the color used if no per vertex
colors are specified. |
java.nio.IntBuffer |
getIndexBuffer()
getIndexAsBuffer retrieves the target's indices array as
an IntBuffer . |
Vector3f[] |
getMeshAsTrianglesVertices(Vector3f[] verts)
retrieves the mesh as triangle vertices of the target mesh. |
BoundingVolume |
getModelBound()
returns the model bound of the target object. |
java.nio.FloatBuffer |
getNormalBuffer()
getNormalBuffer retrieves the target geometry's normal
information as a float buffer. |
java.nio.FloatBuffer |
getTangentBuffer()
|
TriMesh |
getTarget()
getTarget returns the mesh that is being shared by this
object. |
java.util.ArrayList<TexCoords> |
getTextureCoords()
getTextureBuffers retrieves the target geometry's texture
information contained within a float buffer array. |
TexCoords |
getTextureCoords(int textureUnit)
getTextureAsFloatBuffer retrieves the texture buffer of a
given texture unit. |
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 the target TriMesh contains. |
VBOInfo |
getVBOInfo()
getVBOInfo returns the target mesh's vbo info. |
java.nio.FloatBuffer |
getVertexBuffer()
getVertexBuffer returns the float buffer that contains the
target geometry's vertex information. |
int |
getVertexCount()
Returns the number of vertexes defined in the target's Geometry object. |
boolean |
hasDirtyVertices()
|
boolean |
hasTriangleCollision(TriMesh toCheck)
This function checks for intersection between the target trimesh and the given one. |
void |
lockMeshes(Renderer r)
Flags this spatial and those below it that any meshes in the specified scenegraph location or lower will not have changes in vertex, texcoord, normal or color data. |
Vector3f |
randomVertex(Vector3f fill)
randomVertex returns a random vertex from the list of
vertices set to this geometry. |
void |
read(JMEImporter e)
|
void |
reconstruct(java.nio.FloatBuffer vertices,
java.nio.FloatBuffer normals,
java.nio.FloatBuffer colors,
TexCoords textureCoords)
reconstruct is not supported in SharedMesh. |
void |
setBinormalBuffer(java.nio.FloatBuffer binormalBuf)
|
void |
setColorBuffer(java.nio.FloatBuffer buff)
setColorBuffer is not supported by SharedMesh. |
void |
setIndexBuffer(java.nio.IntBuffer indices)
setIndexBuffer is not supported by SharedMesh. |
void |
setModelBound(BoundingVolume modelBound)
setModelBound sets the bounding object for this geometry. |
void |
setNormalBuffer(java.nio.FloatBuffer buff)
setNormalBuffer is not supported by SharedMesh. |
void |
setRandomColors()
setRandomColors is not supported by SharedMesh. |
void |
setSolidColor(ColorRGBA color)
setSolidColor is not supported by SharedMesh. |
void |
setTangentBuffer(java.nio.FloatBuffer tangentBuf)
|
void |
setTarget(TriMesh target)
setTarget sets the shared data mesh. |
void |
setTextureCoords(TexCoords buff)
setTextureBuffer is not supported by SharedMesh. |
void |
setTextureCoords(TexCoords buff,
int position)
setTextureBuffer not supported by SharedMesh |
void |
setVBOInfo(VBOInfo info)
setVBOInfo is not supported in SharedMesh. |
void |
setVertexBuffer(java.nio.FloatBuffer buff)
setVertexBuffer is not supported by SharedMesh. |
void |
updateModelBound()
updateBound recalculates the bounding object assigned to
the geometry. |
void |
updateWorldBound()
updateWorldBound updates the bounding volume that contains
this geometry. |
void |
write(JMEExporter e)
|
Methods inherited from class com.jme.scene.TriMesh |
---|
findCollisions, getMaxIndex, getMeshAsTriangles, getMode, getTriangleIndices, getVertIndex, hasCollision, randomPointOnTriangles, recalcTriangleQuantity, reconstruct, 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 |
Constructor Detail |
---|
public SharedMesh()
public SharedMesh(TriMesh target)
SharedMesh
object. Uses the name
of the target.
target
- the TriMesh to share the data.public SharedMesh(java.lang.String name, TriMesh target)
SharedMesh
object.
name
- the name of this shared mesh.target
- the TriMesh to share the data.Method Detail |
---|
public void setTarget(TriMesh target)
setTarget
sets the shared data mesh.
target
- the TriMesh to share the data.public TriMesh getTarget()
getTarget
returns the mesh that is being shared by this
object.
public void reconstruct(java.nio.FloatBuffer vertices, java.nio.FloatBuffer normals, java.nio.FloatBuffer colors, TexCoords textureCoords)
reconstruct
is not supported in SharedMesh.
reconstruct
in class Geometry
vertices
- the new vertices to use.normals
- the new normals to use.colors
- the new colors to use.textureCoords
- the new texture coordinates to use (position 0).public void setVBOInfo(VBOInfo info)
setVBOInfo
is not supported in SharedMesh.
setVBOInfo
in class Geometry
info
- the VBO info to setVBOInfo
public VBOInfo getVBOInfo()
getVBOInfo
returns the target mesh's vbo info.
getVBOInfo
in class Geometry
VBOInfo
public void setSolidColor(ColorRGBA color)
setSolidColor
is not supported by SharedMesh.
setSolidColor
in class Geometry
color
- the color to set.public void setRandomColors()
setRandomColors
is not supported by SharedMesh.
setRandomColors
in class Geometry
public java.nio.FloatBuffer getVertexBuffer()
getVertexBuffer
returns the float buffer that contains the
target geometry's vertex information.
getVertexBuffer
in class Geometry
public void setVertexBuffer(java.nio.FloatBuffer buff)
setVertexBuffer
is not supported by SharedMesh.
setVertexBuffer
in class Geometry
buff
- the new vertex buffer.public int getVertexCount()
getVertexCount
in class Geometry
public java.nio.FloatBuffer getNormalBuffer()
getNormalBuffer
retrieves the target geometry's normal
information as a float buffer.
getNormalBuffer
in class Geometry
public void setNormalBuffer(java.nio.FloatBuffer buff)
setNormalBuffer
is not supported by SharedMesh.
setNormalBuffer
in class Geometry
buff
- the new normal buffer.public java.nio.FloatBuffer getColorBuffer()
getColorBuffer
retrieves the float buffer that contains
the target geometry's color information.
getColorBuffer
in class Geometry
public void setColorBuffer(java.nio.FloatBuffer buff)
setColorBuffer
is not supported by SharedMesh.
setColorBuffer
in class Geometry
buff
- the new color buffer.public java.nio.IntBuffer getIndexBuffer()
getIndexAsBuffer
retrieves the target's indices array as
an IntBuffer
.
getIndexBuffer
in class TriMesh
IntBuffer
.public void setIndexBuffer(java.nio.IntBuffer indices)
setIndexBuffer
is not supported by SharedMesh.
setIndexBuffer
in class TriMesh
indices
- the index array as an IntBuffer.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
getTriangle
in class TriMesh
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.
getTriangle
in class TriMesh
i
- vertices
- public int getTriangleCount()
getTriangleCount
in class TriMesh
public void copyTextureCoordinates(int fromIndex, int toIndex, float factor)
copyTextureCoords
is not supported by SharedMesh.
copyTextureCoordinates
in class Geometry
fromIndex
- the coordinates to copy.toIndex
- the texture unit to set them to.factor
- a multiple to apply when copyingpublic java.util.ArrayList<TexCoords> getTextureCoords()
getTextureBuffers
retrieves the target geometry's texture
information contained within a float buffer array.
getTextureCoords
in class Geometry
public TexCoords getTextureCoords(int textureUnit)
getTextureAsFloatBuffer
retrieves the texture buffer of a
given texture unit.
getTextureCoords
in class Geometry
textureUnit
- the texture unit to check.
public Vector3f[] getMeshAsTrianglesVertices(Vector3f[] verts)
getMeshAsTrianglesVertices
in class TriMesh
verts
- a storage array to place the results in
public void clearBuffers()
clearBuffers
in class TriMesh
public boolean hasTriangleCollision(TriMesh toCheck)
hasTriangleCollision
in class TriMesh
toCheck
- The intersection testing mesh.
public void findTriangleCollision(TriMesh toCheck, java.util.ArrayList<java.lang.Integer> thisIndex, java.util.ArrayList<java.lang.Integer> otherIndex)
findTriangleCollision
in class TriMesh
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 findTrianglePick(Ray toTest, java.util.ArrayList<java.lang.Integer> results)
findTrianglePick
determines the triangles of the target
trimesh that are being touched by the ray. The indices of the triangles
are stored in the provided ArrayList.
findTrianglePick
in class TriMesh
toTest
- the ray to test.results
- the indices to the triangles.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
public Vector3f randomVertex(Vector3f fill)
Geometry
randomVertex
returns a random vertex from the list of
vertices set to this geometry. If there are no vertices set, null is
returned.
randomVertex
in class Geometry
fill
- a Vector3f to fill with the results. If null, one is created.
It is more efficient to pass in a nonnull vector.
Geometry.randomVertex(Vector3f)
public void setTextureCoords(TexCoords buff)
setTextureBuffer
is not supported by SharedMesh.
setTextureCoords
in class Geometry
buff
- the new vertex buffer.public void setTextureCoords(TexCoords buff, int position)
setTextureBuffer
not supported by SharedMesh
setTextureCoords
in class Geometry
buff
- the new vertex buffer.position
- the texture unit we are providing coordinates for.public void setTangentBuffer(java.nio.FloatBuffer tangentBuf)
setTangentBuffer
in class Geometry
public java.nio.FloatBuffer getTangentBuffer()
getTangentBuffer
in class Geometry
public void setBinormalBuffer(java.nio.FloatBuffer binormalBuf)
setBinormalBuffer
in class Geometry
public java.nio.FloatBuffer getBinormalBuffer()
getBinormalBuffer
in class Geometry
public void updateWorldBound()
updateWorldBound
updates the bounding volume that contains
this geometry. The location of the geometry is based on the location of
all this node's parents.
updateWorldBound
in class Geometry
Spatial.updateWorldBound()
public void setModelBound(BoundingVolume modelBound)
setModelBound
sets the bounding object for this geometry.
setModelBound
in class Geometry
modelBound
- the bounding object for this geometry.public void updateModelBound()
updateBound
recalculates the bounding object assigned to
the geometry. This resets it parameters to adjust for any changes to the
vertex information.
updateModelBound
in class Geometry
public BoundingVolume getModelBound()
getModelBound
in class Geometry
public void draw(Renderer r)
draw
in class TriMesh
r
- the renderer to displaySpatial.draw(com.jme.renderer.Renderer)
public void lockMeshes(Renderer r)
Spatial
lockMeshes
in class Geometry
r
- A renderer to lock against.Spatial.unlockMeshes(Renderer)
public boolean hasDirtyVertices()
hasDirtyVertices
in class Geometry
public ColorRGBA getDefaultColor()
Geometry
getDefaultColor
returns the color used if no per vertex
colors are specified.
getDefaultColor
in class Geometry
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |