|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.jme3.scene.Mesh
public class Mesh
Mesh
is used to store rendering data.
All visible elements in a scene are represented by meshes. Meshes may contain three types of geometric primitives:
setPointSize(float)
.
Points can also be used for point
sprite
mode.setLineWidth(float)
.
Nested Class Summary | |
---|---|
static class |
Mesh.Mode
The mode of the Mesh specifies both the type of primitive represented by the mesh and how the data should be interpreted. |
Constructor Summary | |
---|---|
Mesh()
Creates a new mesh with no vertex buffers . |
Method Summary | |
---|---|
void |
clearBuffer(VertexBuffer.Type type)
Unsets the VertexBuffer set on this mesh
with the given type. |
Mesh |
clone()
Create a shallow clone of this Mesh. |
Mesh |
cloneForAnim()
Clone the mesh for animation use. |
int |
collideWith(Collidable other,
Matrix4f worldMatrix,
BoundingVolume worldBound,
CollisionResults results)
Handles collision detection, internal use only. |
void |
createCollisionData()
Generates a collision tree for the mesh. |
Mesh |
deepClone()
Creates a deep clone of this mesh. |
void |
extractVertexData(Mesh other)
Extracts the vertex attributes from the given mesh into this mesh, by using this mesh's index buffer
to index into the attributes of the other mesh. |
void |
generateBindPose(boolean forSoftwareAnim)
Generates the VertexBuffer.Type.BindPosePosition , VertexBuffer.Type.BindPoseNormal ,
and VertexBuffer.Type.BindPoseTangent
buffers for this mesh by duplicating them based on the position and normal
buffers already set on the mesh. |
BoundingVolume |
getBound()
Returns the BoundingVolume of this Mesh. |
VertexBuffer |
getBuffer(VertexBuffer.Type type)
Get the VertexBuffer stored on this mesh with the given
type. |
SafeArrayList<VertexBuffer> |
getBufferList()
Returns a list of all vertex buffers on this Mesh. |
IntMap<VertexBuffer> |
getBuffers()
Returns a map of all vertex buffers on this Mesh. |
int[] |
getElementLengths()
Get the element lengths for Mesh.Mode.Hybrid mesh mode. |
java.nio.FloatBuffer |
getFloatBuffer(VertexBuffer.Type type)
Get the VertexBuffer data stored on this mesh in float
format. |
int |
getId()
Returns the mesh's VAO ID. |
IndexBuffer |
getIndexBuffer()
Get the index buffer for this mesh. |
IndexBuffer |
getIndicesAsList()
Acquires an index buffer that will read the vertices on the mesh as a list. |
float |
getLineWidth()
Returns the line width for line meshes. |
VertexBuffer |
getLodLevel(int lod)
Returns the lod level at the given index. |
int |
getMaxNumWeights()
Returns the maximum number of weights per vertex on this mesh. |
Mesh.Mode |
getMode()
Returns the mesh mode |
int[] |
getModeStart()
Set the mode start indices for Mesh.Mode.Hybrid mesh mode. |
int |
getNumLodLevels()
|
float |
getPointSize()
Returns the size of points for point meshes |
java.nio.ShortBuffer |
getShortBuffer(VertexBuffer.Type type)
Get the VertexBuffer data stored on this mesh in short
format. |
void |
getTriangle(int index,
int[] indices)
Gets the triangle vertex indices at the given triangle index and stores them into the given int array. |
void |
getTriangle(int index,
Triangle tri)
Gets the triangle vertex positions at the given triangle index and stores them into the Triangle argument. |
void |
getTriangle(int index,
Vector3f v1,
Vector3f v2,
Vector3f v3)
Gets the triangle vertex positions at the given triangle index and stores them into the v1, v2, v3 arguments. |
int |
getTriangleCount()
Returns how many triangles or elements are on this Mesh. |
int |
getTriangleCount(int lod)
Returns the triangle count for the given LOD level. |
int |
getVertexCount()
Returns the number of vertices on this mesh. |
void |
prepareForAnim(boolean forSoftwareAnim)
Prepares the mesh for software skinning by converting the bone index and weight buffers to heap buffers. |
void |
read(JmeImporter im)
|
void |
scaleTextureCoordinates(Vector2f scaleFactor)
Scales the texture coordinate buffer on this mesh by the given scale factor. |
void |
setBound(BoundingVolume modelBound)
Sets the BoundingVolume for this Mesh. |
void |
setBuffer(VertexBuffer.Type type,
int components,
byte[] buf)
|
void |
setBuffer(VertexBuffer.Type type,
int components,
java.nio.ByteBuffer buf)
|
void |
setBuffer(VertexBuffer.Type type,
int components,
float[] buf)
|
void |
setBuffer(VertexBuffer.Type type,
int components,
java.nio.FloatBuffer buf)
Set a floating point VertexBuffer on the mesh. |
void |
setBuffer(VertexBuffer.Type type,
int components,
int[] buf)
|
void |
setBuffer(VertexBuffer.Type type,
int components,
java.nio.IntBuffer buf)
|
void |
setBuffer(VertexBuffer.Type type,
int components,
short[] buf)
|
void |
setBuffer(VertexBuffer.Type type,
int components,
java.nio.ShortBuffer buf)
|
void |
setBuffer(VertexBuffer.Type type,
int components,
VertexBuffer.Format format,
java.nio.Buffer buf)
Creates a VertexBuffer for the mesh or modifies
the existing one per the parameters given. |
void |
setBuffer(VertexBuffer vb)
Sets the VertexBuffer on the mesh. |
void |
setDynamic()
Indicates to the GPU that this mesh will be modified occasionally (a hint). |
void |
setElementLengths(int[] elementLengths)
Set the element lengths for Mesh.Mode.Hybrid mesh mode. |
void |
setId(int id)
Sets the mesh's VAO ID. |
void |
setInterleaved()
Deprecated. |
void |
setLineWidth(float lineWidth)
Specify the line width for meshes of the line modes, such as Mesh.Mode.Lines . |
void |
setLodLevels(VertexBuffer[] lodLevels)
Set the LOD (level of detail) index buffers on this mesh. |
void |
setMaxNumWeights(int maxNumWeights)
Set the maximum number of weights per vertex on this mesh. |
void |
setMode(Mesh.Mode mode)
Change the Mesh's mode. |
void |
setModeStart(int[] modeStart)
Get the mode start indices for Mesh.Mode.Hybrid mesh mode. |
void |
setPointSize(float pointSize)
Set the size of points for meshes of mode Mesh.Mode.Points . |
void |
setStatic()
Indicates to the GPU that this mesh will not be modified (a hint). |
void |
setStreamed()
Indicates to the GPU that this mesh will be modified every frame (a hint). |
void |
updateBound()
Updates the bounding volume of this mesh. |
void |
updateCounts()
Update the vertex and
triangle counts for this mesh
based on the current data. |
void |
write(JmeExporter ex)
|
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Mesh()
vertex buffers
.
Method Detail |
---|
public Mesh clone()
vertex
buffers
are shared between this and the clone mesh, the rest
of the data is cloned.
clone
in class java.lang.Object
public Mesh deepClone()
vertex buffers
and the data inside them
is cloned.
public Mesh cloneForAnim()
vertex buffer
data, however the
VertexBuffer.Type.Position
, VertexBuffer.Type.Normal
, and VertexBuffer.Type.Tangent
buffers
are deeply cloned.
public void generateBindPose(boolean forSoftwareAnim)
VertexBuffer.Type.BindPosePosition
, VertexBuffer.Type.BindPoseNormal
,
and VertexBuffer.Type.BindPoseTangent
buffers for this mesh by duplicating them based on the position and normal
buffers already set on the mesh.
This method does nothing if the mesh has no bone weight or index
buffers.
forSoftwareAnim
- Should be true if the bind pose is to be generated.public void prepareForAnim(boolean forSoftwareAnim)
forSoftwareAnim
- Should be true to enable the conversion.public void setLodLevels(VertexBuffer[] lodLevels)
lodLevels
- The LOD levels to setpublic int getNumLodLevels()
public VertexBuffer getLodLevel(int lod)
lod
- The lod level index, this does not include
the main index buffer.
java.lang.IndexOutOfBoundsException
- If the index is outside of the
range [0, getNumLodLevels()
].setLodLevels(com.jme3.scene.VertexBuffer[])
public int[] getElementLengths()
Mesh.Mode.Hybrid
mesh mode.
public void setElementLengths(int[] elementLengths)
Mesh.Mode.Hybrid
mesh mode.
elementLengths
- The element lengths to setpublic int[] getModeStart()
Mesh.Mode.Hybrid
mesh mode.
public void setModeStart(int[] modeStart)
Mesh.Mode.Hybrid
mesh mode.
public Mesh.Mode getMode()
setMode(com.jme3.scene.Mesh.Mode)
public void setMode(Mesh.Mode mode)
Mesh.Mode.Triangles
.
mode
- The new mode to setMesh.Mode
public int getMaxNumWeights()
setMaxNumWeights(int)
public void setMaxNumWeights(int maxNumWeights)
maxNumWeights
- public float getPointSize()
setPointSize(float)
public void setPointSize(float pointSize)
Mesh.Mode.Points
.
The point size is specified as on-screen pixels, the default
value is 1.0. The point size
does nothing if point sprite
render state is enabled, in that case, the vertex shader must specify the
point size by writing to gl_PointSize
.
pointSize
- The size of pointspublic float getLineWidth()
public void setLineWidth(float lineWidth)
Mesh.Mode.Lines
. The line width is specified as on-screen pixels,
the default value is 1.0.
lineWidth
- The line widthpublic void setStatic()
VertexBuffer.Usage.Static
for all vertex buffers
on this Mesh.
public void setDynamic()
VertexBuffer.Usage.Dynamic
for all vertex buffers
on this Mesh.
public void setStreamed()
VertexBuffer.Usage.Stream
for all vertex buffers
on this Mesh.
@Deprecated public void setInterleaved()
public void updateCounts()
vertex
and
triangle
counts for this mesh
based on the current data. This method should be called
after the capacities
of the mesh's
vertex buffers
has been altered.
java.lang.IllegalStateException
- If this mesh is in
interleaved
format.public int getTriangleCount(int lod)
lod
- The lod level to look up
public int getTriangleCount()
updateCounts()
is called.
If the mesh mode is not a triangle mode, then this returns the
number of elements/primitives, e.g. how many lines or how many points,
instead of how many triangles.
public int getVertexCount()
public void getTriangle(int index, Vector3f v1, Vector3f v2, Vector3f v3)
index
- The index of the triangle.
Should be between 0 and getTriangleCount()
.v1
- Vector to contain first vertex positionv2
- Vector to contain second vertex positionv3
- Vector to contain third vertex positionpublic void getTriangle(int index, Triangle tri)
Triangle
argument.
Also sets the triangle index to the index
argument.
index
- The index of the triangle.
Should be between 0 and getTriangleCount()
.tri
- The triangle to store the positions inpublic void getTriangle(int index, int[] indices)
index
- The index of the triangle.
Should be between 0 and getTriangleCount()
.indices
- Indices of the triangle's verticespublic int getId()
public void setId(int id)
public void createCollisionData()
collideWith(com.jme3.collision.Collidable,
com.jme3.math.Matrix4f,
com.jme3.bounding.BoundingVolume,
com.jme3.collision.CollisionResults)
.
public int collideWith(Collidable other, Matrix4f worldMatrix, BoundingVolume worldBound, CollisionResults results)
Spatial
s.
public void setBuffer(VertexBuffer vb)
VertexBuffer
on the mesh.
This will update the vertex/triangle counts if needed.
vb
- The buffer to set
java.lang.IllegalArgumentException
- If the buffer type is already setpublic void clearBuffer(VertexBuffer.Type type)
VertexBuffer
set on this mesh
with the given type. Does nothing if the vertex buffer type is not set
initially.
type
- The buffer type to removepublic void setBuffer(VertexBuffer.Type type, int components, VertexBuffer.Format format, java.nio.Buffer buf)
VertexBuffer
for the mesh or modifies
the existing one per the parameters given.
type
- The type of the buffercomponents
- Number of componentsformat
- Data formatbuf
- The buffer data
java.lang.UnsupportedOperationException
- If the buffer already set is
incompatible with the parameters given.public void setBuffer(VertexBuffer.Type type, int components, java.nio.FloatBuffer buf)
VertexBuffer
on the mesh.
type
- The type of VertexBuffer
,
e.g. VertexBuffer.Type.Position
, VertexBuffer.Type.Normal
, etc.components
- Number of components on the vertex buffer, should
be between 1 and 4.buf
- The floating point data to containpublic void setBuffer(VertexBuffer.Type type, int components, float[] buf)
public void setBuffer(VertexBuffer.Type type, int components, java.nio.IntBuffer buf)
public void setBuffer(VertexBuffer.Type type, int components, int[] buf)
public void setBuffer(VertexBuffer.Type type, int components, java.nio.ShortBuffer buf)
public void setBuffer(VertexBuffer.Type type, int components, byte[] buf)
public void setBuffer(VertexBuffer.Type type, int components, java.nio.ByteBuffer buf)
public void setBuffer(VertexBuffer.Type type, int components, short[] buf)
public VertexBuffer getBuffer(VertexBuffer.Type type)
VertexBuffer
stored on this mesh with the given
type.
type
- The type of VertexBuffer
public java.nio.FloatBuffer getFloatBuffer(VertexBuffer.Type type)
VertexBuffer
data stored on this mesh in float
format.
type
- The type of VertexBuffer
public java.nio.ShortBuffer getShortBuffer(VertexBuffer.Type type)
VertexBuffer
data stored on this mesh in short
format.
type
- The type of VertexBuffer
public IndexBuffer getIndicesAsList()
public IndexBuffer getIndexBuffer()
null
if no index buffer is set.
VertexBuffer.Type.Index
public void extractVertexData(Mesh other)
index buffer
to index into the attributes of the other mesh.
Note that this will also change this mesh's index buffer so that
the references to the vertex data match the new indices.
other
- The mesh to extract the vertex data frompublic void scaleTextureCoordinates(Vector2f scaleFactor)
Note that values above 1 will cause the texture to tile, while values below 1 will cause the texture to stretch.
scaleFactor
- The scale factor to scale by. Every texture
coordinate is multiplied by this vector to get the result.
java.lang.IllegalStateException
- If there's no texture coordinate
buffer on the mesh
java.lang.UnsupportedOperationException
- If the texture coordinate
buffer is not in 2D float format.public void updateBound()
VertexBuffer.Type.Position
buffer.
It is expected that the position buffer is a float buffer with 3 components.
public BoundingVolume getBound()
BoundingVolume
of this Mesh.
By default the bounding volume is a BoundingBox
.
public void setBound(BoundingVolume modelBound)
BoundingVolume
for this Mesh.
The bounding volume is recomputed by calling updateBound()
.
modelBound
- The model bound to setpublic IntMap<VertexBuffer> getBuffers()
vertex buffers
on this Mesh.
The integer key for the map is the ordinal
of the vertex buffer's VertexBuffer.Type
.
Note that the returned map is a reference to the map used internally,
modifying it will cause undefined results.
public SafeArrayList<VertexBuffer> getBufferList()
vertex buffers
on this Mesh.
Using a list instead an IntMap via the getBuffers()
method is
better for iteration as there's no need to create an iterator instance.
Note that the returned list is a reference to the list used internally,
modifying it will cause undefined results.
public void write(JmeExporter ex) throws java.io.IOException
write
in interface Savable
java.io.IOException
public void read(JmeImporter im) throws java.io.IOException
read
in interface Savable
java.io.IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |