Package com.ardor3d.scenegraph
Class MeshData
java.lang.Object
com.ardor3d.scenegraph.MeshData
- All Implemented Interfaces:
Savable
MeshData contains all the commonly used buffers for rendering a mesh.
-
Field Summary
Modifier and TypeFieldDescriptionprotected FloatBufferData
protected FloatBufferData
protected IndexBufferData
<?> Index data.protected int[]
protected IndexMode[]
protected FloatBufferData
protected int[]
Number of primitives represented by this data.protected FloatBufferData
protected List
<FloatBufferData> protected FloatBufferData
Buffer data holding buffers and number of coordinates per vertexprotected int
Number of vertices represented by this data. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
copyTextureCoordinates
(int fromIndex, int toIndex, float factor) copyTextureCoords
copies the texture coordinates of a given texture unit to another location.void
copyTextureCoordinates
(int fromIndex, int toIndex, float factorS, float factorT) copyTextureCoords
copies the texture coordinates of a given texture unit to another location.Gets the color buffer.Gets the color coords.Gets the fog buffer.Gets the fog coords.Gets the index buffer.int[]
Gets the index lengths.Deprecated.getIndexMode
(int sectionIndex) Gets the index mode.Gets the index modes.Gets the indices.Gets the normal buffer.Gets the normal coords.int
getNumberOfUnits
returns the number of texture units this geometry is currently using.int
getPrimitiveCount
(int section) Gets the primitive count.int[]
getPrimitiveIndices
(int primitiveIndex, int section, int[] store) Returns the vertex indices of a specified primitive.Vector3[]
getPrimitiveNormals
(int primitiveIndex, int section, Vector3[] store) Gets the normals of the primitive.Vector2[]
getPrimitiveTextureCoords
(int primitiveIndex, int section, int textureIndex, Vector2[] store) Gets the texture coordinates of the primitive.Vector3[]
getPrimitiveVertices
(int primitiveIndex, int section, Vector3[] store) Gets the vertices that make up the given primitive.int
Gets the section count.Gets the tangent buffer.Gets the tangent coords.getTextureBuffer
(int index) Gets the FloatBuffer of the FloatBufferData set on a given texture unit.Gets the texture coords.getTextureCoords
(int index) Gets the texture coords assigned to a specific texture unit index of this MeshData.int
Gets the total primitive count.Gets the vertex buffer.Gets the vertex coords.int
Gets the vertex count.int
getVertexIndex
(int primitiveIndex, int point, int section) Gets the vertex index.makeCopy()
randomPointOnPrimitives
(Vector3 store) Random point on primitives.randomVertex
(Vector3 store) Random vertex.void
read
(InputCapsule capsule) void
rotateNormals
(Quaternion rotate) Rotate normals.void
rotatePoints
(Quaternion rotate) Rotate points.void
setColorBuffer
(FloatBuffer colorBuffer) Sets the color buffer.void
setColorCoords
(FloatBufferData bufferData) Sets the color coords.void
setFogBuffer
(FloatBuffer fogBuffer) Sets the fog buffer.void
setFogCoords
(FloatBufferData bufferData) Sets the fog coords.void
setIndexBuffer
(ByteBuffer indices) Sets the index buffer.void
setIndexBuffer
(IntBuffer indices) Sets the index buffer.void
setIndexBuffer
(ShortBuffer indices) Sets the index buffer.void
setIndexLengths
(int[] indexLengths) Sets the index lengths.void
setIndexMode
(IndexMode indexMode) Sets the index mode.void
setIndexModes
(IndexMode[] indexModes) Note: Also updates primitive counts.void
setIndices
(IndexBufferData<?> bufferData) Sets the indicesvoid
void
setNormalBuffer
(FloatBuffer normalBuffer) Sets the normal buffer.void
setNormalCoords
(FloatBufferData bufferData) Sets the normal coords.void
setTangentBuffer
(FloatBuffer tangentBuffer) Sets the tangent buffer.void
setTangentCoords
(FloatBufferData bufferData) Sets the tangent coords.void
setTextureBuffer
(FloatBuffer textureBuffer, int index) Sets the texture buffer for a given texture unit index.void
setTextureCoords
(FloatBufferData textureCoords, int index) Sets the texture coords of a specific texture unit index to the given FloatBufferData.void
setTextureCoords
(List<FloatBufferData> textureCoords) Sets all texture coords on this MeshData.void
setVertexBuffer
(FloatBuffer vertexBuffer) Sets the vertex buffer.void
setVertexCoords
(FloatBufferData bufferData) Sets the vertex coords.void
transformNormals
(Transform transform, boolean normalize) void
transformVertices
(Transform transform) void
translatePoints
(double x, double y, double z) Translate points.void
translatePoints
(Vector3 amount) Translate points.void
Update the vertex count based on the current limit of the vertex buffer.void
write
(OutputCapsule capsule)
-
Field Details
-
_vertexCount
protected int _vertexCountNumber of vertices represented by this data. -
_primitiveCounts
protected transient int[] _primitiveCountsNumber of primitives represented by this data. -
_vertexCoords
Buffer data holding buffers and number of coordinates per vertex -
_normalCoords
-
_colorCoords
-
_fogCoords
-
_tangentCoords
-
_textureCoords
-
_indexBuffer
Index data. -
_indexLengths
protected int[] _indexLengths -
_indexModes
-
-
Constructor Details
-
MeshData
public MeshData()
-
-
Method Details
-
getVertexCount
public int getVertexCount()Gets the vertex count.- Returns:
- the vertex count
-
getVertexBuffer
Gets the vertex buffer.- Returns:
- the vertex buffer
-
setVertexBuffer
Sets the vertex buffer.- Parameters:
vertexBuffer
- the new vertex buffer
-
getVertexCoords
Gets the vertex coords.- Returns:
- the vertex coords
-
setVertexCoords
Sets the vertex coords.- Parameters:
bufferData
- the new vertex coords
-
getNormalBuffer
Gets the normal buffer.- Returns:
- the normal buffer
-
setNormalBuffer
Sets the normal buffer.- Parameters:
normalBuffer
- the new normal buffer
-
getNormalCoords
Gets the normal coords.- Returns:
- the normal coords
-
setNormalCoords
Sets the normal coords.- Parameters:
bufferData
- the new normal coords
-
getColorBuffer
Gets the color buffer.- Returns:
- the color buffer
-
setColorBuffer
Sets the color buffer.- Parameters:
colorBuffer
- the new color buffer
-
getColorCoords
Gets the color coords.- Returns:
- the color coords
-
setColorCoords
Sets the color coords.- Parameters:
bufferData
- the new color coords
-
getFogBuffer
Gets the fog buffer.- Returns:
- the fog buffer
-
setFogBuffer
Sets the fog buffer.- Parameters:
fogBuffer
- the new fog buffer
-
getFogCoords
Gets the fog coords.- Returns:
- the fog coords
-
setFogCoords
Sets the fog coords.- Parameters:
bufferData
- the new fog coords
-
getTangentBuffer
Gets the tangent buffer.- Returns:
- the tangent buffer
-
setTangentBuffer
Sets the tangent buffer.- Parameters:
tangentBuffer
- the new tangent buffer
-
getTangentCoords
Gets the tangent coords.- Returns:
- the tangent coords
-
setTangentCoords
Sets the tangent coords.- Parameters:
bufferData
- the new tangent coords
-
getTextureBuffer
Gets the FloatBuffer of the FloatBufferData set on a given texture unit.- Parameters:
index
- the unit index- Returns:
- the texture buffer for the given index, or null if none was set.
-
setTextureBuffer
Sets the texture buffer for a given texture unit index. Interprets it as a 2 component float buffer data. If you need other sizes, use setTextureCoords instead.- Parameters:
textureBuffer
- the texture bufferindex
- the unit index- See Also:
-
getTextureCoords
Gets the texture coords.- Returns:
- the texture coords
-
getTextureCoords
Gets the texture coords assigned to a specific texture unit index of this MeshData.- Parameters:
index
- the texture unit index- Returns:
- the texture coords
-
setTextureCoords
Sets all texture coords on this MeshData.- Parameters:
textureCoords
- the new texture coords
-
setTextureCoords
Sets the texture coords of a specific texture unit index to the given FloatBufferData.- Parameters:
textureCoords
- the texture coordsindex
- the unit index
-
updateVertexCount
public void updateVertexCount()Update the vertex count based on the current limit of the vertex buffer. -
copyTextureCoordinates
public void copyTextureCoordinates(int fromIndex, int toIndex, float factor) copyTextureCoords
copies the texture coordinates of a given texture unit to another location. If the texture unit is not valid, then the coordinates are ignored. Coords are multiplied by the given factor.- Parameters:
fromIndex
- the coordinates to copy.toIndex
- the texture unit to set them to. Must not be the same as the fromIndex.factor
- a multiple to apply when copying
-
copyTextureCoordinates
public void copyTextureCoordinates(int fromIndex, int toIndex, float factorS, float factorT) copyTextureCoords
copies the texture coordinates of a given texture unit to another location. If the texture unit is not valid, then the coordinates are ignored. Coords are multiplied by the given S and T factors.- Parameters:
fromIndex
- the coordinates to copy.toIndex
- the texture unit to set them to. Must not be the same as the fromIndex.factorS
- a multiple to apply to the S channel when copyingfactorT
- a multiple to apply to the T channel when copying
-
getNumberOfUnits
public int getNumberOfUnits()getNumberOfUnits
returns the number of texture units this geometry is currently using.- Returns:
- the number of texture units in use.
-
getIndexBuffer
Gets the index buffer.- Returns:
- the index buffer
-
setIndexBuffer
Sets the index buffer.- Parameters:
indices
- the new index buffer
-
setIndexBuffer
Sets the index buffer.- Parameters:
indices
- the new index buffer
-
setIndexBuffer
Sets the index buffer.- Parameters:
indices
- the new index buffer
-
getIndices
Gets the indices.- Returns:
- the indices
-
setIndices
Sets the indices- Parameters:
bufferData
- the new indices
-
getIndexMode
Deprecated.Please switch togetIndexMode(int)
Gets the index mode.- Returns:
- the IndexMode of the first section of this MeshData.
-
setIndexMode
Sets the index mode.- Parameters:
indexMode
- the new IndexMode to use for the first section of this MeshData.
-
getIndexLengths
public int[] getIndexLengths()Gets the index lengths.- Returns:
- the index lengths
-
setIndexLengths
public void setIndexLengths(int[] indexLengths) Sets the index lengths.- Parameters:
indexLengths
- the new index lengths
-
getIndexModes
Gets the index modes.- Returns:
- the index modes
-
getIndexMode
Gets the index mode.- Parameters:
sectionIndex
- the section index- Returns:
- the index mode
-
setIndexModes
Note: Also updates primitive counts.- Parameters:
indexModes
- the index modes to use for this MeshData.
-
getSectionCount
public int getSectionCount()Gets the section count.- Returns:
- the number of sections (lengths, indexModes, etc.) this MeshData contains.
-
getTotalPrimitiveCount
public int getTotalPrimitiveCount()Gets the total primitive count.- Returns:
- the sum of the primitive counts on all sections of this mesh data.
-
getPrimitiveCount
public int getPrimitiveCount(int section) Gets the primitive count.- Parameters:
section
- the section- Returns:
- the number of primitives (triangles, quads, lines, points, etc.) on a given section of this mesh data.
-
getPrimitiveIndices
public int[] getPrimitiveIndices(int primitiveIndex, int section, int[] store) Returns the vertex indices of a specified primitive.- Parameters:
primitiveIndex
- which triangle, quad, etcsection
- which section to pull from (corresponds to array position in indexmodes and lengths)store
- an int array to store the results in. if null, or the length < the size of the primitive, a new array is created and returned.- Returns:
- the primitive's vertex indices as an array
- Throws:
IndexOutOfBoundsException
- if primitiveIndex is outside of range [0, count-1] where count is the number of primitives in the given section.ArrayIndexOutOfBoundsException
- if section is out of range [0, N-1] where N is the number of sections in this MeshData object.
-
getPrimitiveVertices
Gets the vertices that make up the given primitive.- Parameters:
primitiveIndex
- the primitive indexsection
- the sectionstore
- the store. If null or the wrong size, we'll make a new array and return that instead.- Returns:
- the primitive
-
getPrimitiveTextureCoords
public Vector2[] getPrimitiveTextureCoords(int primitiveIndex, int section, int textureIndex, Vector2[] store) Gets the texture coordinates of the primitive.- Parameters:
primitiveIndex
- the primitive indexsection
- the sectiontextureIndex
- the texture indexstore
- the store- Returns:
- the texture coordinates of the primitive
-
getPrimitiveNormals
Gets the normals of the primitive.- Parameters:
primitiveIndex
- the primitive indexsection
- the sectionstore
- the store- Returns:
- the normals of the primitive
-
getVertexIndex
public int getVertexIndex(int primitiveIndex, int point, int section) Gets the vertex index.- Parameters:
primitiveIndex
- which triangle, quad, etc.point
- which point on the triangle, quad, etc. (triangle has three points, so this would be 0-2, etc.)section
- which section to pull from (corresponds to array position in indexmodes and lengths)- Returns:
- the position you would expect to find the given point in the index buffer
-
randomVertex
Random vertex.- Parameters:
store
- the vector object to store the result in. if null, a new one is created.- Returns:
- a random vertex from the vertices stored in this MeshData. null is returned if there are no vertices.
-
randomPointOnPrimitives
Random point on primitives.- Parameters:
store
- the vector object to store the result in. if null, a new one is created.- Returns:
- a random point from the surface of a primitive stored in this MeshData. null is returned if there are no vertices or indices.
-
translatePoints
public void translatePoints(double x, double y, double z) Translate points.- Parameters:
x
- the xy
- the yz
- the z
-
translatePoints
Translate points.- Parameters:
amount
- the amount
-
transformVertices
-
transformNormals
-
rotatePoints
Rotate points.- Parameters:
rotate
- the rotate
-
rotateNormals
Rotate normals.- Parameters:
rotate
- the rotate
-
makeCopy
-
getClassTag
- Specified by:
getClassTag
in interfaceSavable
-
write
- Specified by:
write
in interfaceSavable
- Throws:
IOException
-
read
- Specified by:
read
in interfaceSavable
- Throws:
IOException
-
getInstancingManager
-
setInstancingManager
-
getIndexMode(int)