Assimp  v3.1.1 (June 2014)
jassimp.AiMesh Class Reference

A mesh represents a geometry or model with a single material. More...

Public Member Functions

FloatBuffer getBitangentBuffer ()
 Returns a buffer containing bitangents. More...
 
float getBitangentX (int vertex)
 Returns the x-coordinate of a vertex tangent. More...
 
float getBitangentY (int vertex)
 Returns the y-coordinate of a vertex tangent. More...
 
float getBitangentZ (int vertex)
 Returns the z-coordinate of a vertex tangent. More...
 
List< AiBonegetBones ()
 Returns the bones of this mesh. More...
 
float getColorA (int vertex, int colorset)
 Returns the alpha color component of a color from a vertex color set. More...
 
float getColorB (int vertex, int colorset)
 Returns the blue color component of a color from a vertex color set. More...
 
FloatBuffer getColorBuffer (int colorset)
 Returns a buffer containing vertex colors for a color set. More...
 
float getColorG (int vertex, int colorset)
 Returns the green color component of a color from a vertex color set. More...
 
float getColorR (int vertex, int colorset)
 Returns the red color component of a color from a vertex color set. More...
 
IntBuffer getFaceBuffer ()
 Returns a buffer containing face data. More...
 
int getFaceNumIndices (int face)
 Returns the number of vertex indices for a single face. More...
 
IntBuffer getFaceOffsets ()
 Returns an index structure for the buffer returned by getFaceBuffer(). More...
 
int getFaceVertex (int face, int n)
 Returns a vertex reference from a face. More...
 
IntBuffer getIndexBuffer ()
 Returns a buffer containing vertex indices for the mesh's faces. More...
 
int getMaterialIndex ()
 Returns the material used by this mesh. More...
 
String getName ()
 Returns the name of the mesh. More...
 
FloatBuffer getNormalBuffer ()
 Returns a buffer containing normals. More...
 
float getNormalX (int vertex)
 Returns the x-coordinate of a vertex normal. More...
 
float getNormalY (int vertex)
 Returns the y-coordinate of a vertex normal. More...
 
float getNormalZ (int vertex)
 Returns the z-coordinate of a vertex normal. More...
 
int getNumFaces ()
 Returns the number of faces in the mesh. More...
 
int getNumUVComponents (int coords)
 Returns the number of UV components for a texture coordinate set. More...
 
int getNumVertices ()
 Returns the number of vertices in this mesh. More...
 
FloatBuffer getPositionBuffer ()
 Returns a buffer containing vertex positions. More...
 
float getPositionX (int vertex)
 Returns the x-coordinate of a vertex position. More...
 
float getPositionY (int vertex)
 Returns the y-coordinate of a vertex position. More...
 
float getPositionZ (int vertex)
 Returns the z-coordinate of a vertex position. More...
 
Set< AiPrimitiveTypegetPrimitiveTypes ()
 Returns the primitive types used by this mesh. More...
 
FloatBuffer getTangentBuffer ()
 Returns a buffer containing tangents. More...
 
float getTangentX (int vertex)
 Returns the x-coordinate of a vertex tangent. More...
 
float getTangentY (int vertex)
 Returns the y-coordinate of a vertex bitangent. More...
 
float getTangentZ (int vertex)
 Returns the z-coordinate of a vertex tangent. More...
 
FloatBuffer getTexCoordBuffer (int coords)
 Returns a buffer containing coordinates for a texture coordinate set. More...
 
float getTexCoordU (int vertex, int coords)
 Returns the u component of a coordinate from a texture coordinate set. More...
 
float getTexCoordV (int vertex, int coords)
 Returns the v component of a coordinate from a texture coordinate set. More...
 
float getTexCoordW (int vertex, int coords)
 Returns the w component of a coordinate from a texture coordinate set. More...
 
boolean hasBones ()
 Tells whether the mesh has bones. More...
 
boolean hasColors (int colorset)
 Tells whether the mesh has a vertex color set. More...
 
boolean hasFaces ()
 Tells whether the mesh has faces. More...
 
boolean hasNormals ()
 Tells whether the mesh has normals. More...
 
boolean hasPositions ()
 Tells whether the mesh has vertex positions. More...
 
boolean hasTangentsAndBitangents ()
 Tells whether the mesh has tangents and bitangents. More...
 
boolean hasTexCoords (int coords)
 Tells whether the mesh has a texture coordinate set. More...
 
boolean hasTexCoords ()
 Tells whether the mesh has any texture coordinate sets. More...
 
boolean hasVertexColors ()
 Tells whether the mesh has any vertex colors. More...
 
boolean isPureTriangle ()
 Tells whether the mesh is a pure triangle mesh, i.e., contains only triangular faces. More...
 
String toString ()
 

Detailed Description

A mesh represents a geometry or model with a single material.

Data

Meshes usually consist of a number of vertices and a series of faces referencing the vertices. In addition there might be a series of bones, each of them addressing a number of vertices with a certain weight. Vertex data is presented in channels with each channel containing a single per-vertex information such as a set of texture coordinates or a normal vector.

Faces consist of one or more references to vertices, called vertex indices. The getPrimitiveTypes() method can be used to check what face types are present in the mesh. Note that a single mesh can possess faces of different types. The number of indices used by a specific face can be retrieved with the getFaceNumIndices(int) method.

API for vertex and face data

The jassimp interface for accessing vertex and face data is not a one-to-one mapping of the c/c++ interface. The c/c++ interface uses an object-oriented approach to represent data, which provides a considerable overhead using a naive java based realization (cache locality would be unpredictable and most likely bad, bulk data transfer would be impossible).

The jassimp interface uses flat byte buffers to store vertex and face data. This data can be accessed through three APIs:

  • Buffer API: the getXXXBuffer() methods return raw data buffers.
  • Direct API: the getXXX() methods allow reading and writing of individual data values.
  • Wrapped API: the getWrappedXXX() methods provide an object oriented view on the data.

The Buffer API is optimized for use in conjunction with rendering APIs such as LWJGL. The returned buffers are guaranteed to have native byte order and to be direct byte buffers. They can be passed directly to LWJGL methods, e.g., to fill VBOs with data. Each invocation of a getXXXBuffer() method will return a new view of the internal buffer, i.e., if is safe to use the relative byte buffer operations. The Buffer API provides the best performance of all three APIs, especially if large data volumes have to be processed.

The Direct API provides an easy to use interface for reading and writing individual data values. Its performance is comparable to the Buffer API's performance for these operations. The main difference to the Buffer API is the missing support for bulk operations. If you intend to retrieve or modify large subsets of the raw data consider using the Buffer API, especially if the subsets are contiguous.

The Wrapped API offers an object oriented interface for accessing and modifying mesh data. As the name implies, this interface is realized through wrapper objects that provide a view on the raw data. For each invocation of a getWrappedXXX() method, a new wrapper object is created. Iterating over mesh data via this interface will create many short-lived wrapper objects which -depending on usage and virtual machine- may cause considerable garbage collection overhead. The Wrapped API provides the worst performance of all three APIs, which may nevertheless still be good enough to warrant its usage. See AiWrapperProvider for more details on wrappers.

API for bones

As there is no standardized way for doing skinning in different graphics engines, bones are not represented as flat buffers but as object structure. Users of this library should convert this structure to the format required by the specific graphics engine.

Changing Data

This class is designed to be mutable, i.e., the returned objects and buffers may be modified. It is not possible to add/remove vertices as this would require reallocation of the data buffers. Wrapped objects may or may not propagate changes to the underlying data buffers. Consult the documentation of your wrapper provider for details. The built in wrappers will propagate changes.

Modification of face data is theoretically possible by modifying the face buffer and the faceOffset buffer however it is strongly disadvised to do so because it might break all algorithms that depend on the internal consistency of these two data structures.

Member Function Documentation

FloatBuffer jassimp.AiMesh.getBitangentBuffer ( )
inline

Returns a buffer containing bitangents.

A bitangent consists of a triple of floats, the buffer will therefore contain 3 * getNumVertices() floats

Returns
a native-order direct buffer
float jassimp.AiMesh.getBitangentX ( int  vertex)
inline

Returns the x-coordinate of a vertex tangent.

Parameters
vertexthe vertex index
Returns
the x coordinate
float jassimp.AiMesh.getBitangentY ( int  vertex)
inline

Returns the y-coordinate of a vertex tangent.

Parameters
vertexthe vertex index
Returns
the y coordinate
float jassimp.AiMesh.getBitangentZ ( int  vertex)
inline

Returns the z-coordinate of a vertex tangent.

Parameters
vertexthe vertex index
Returns
the z coordinate
List<AiBone> jassimp.AiMesh.getBones ( )
inline

Returns the bones of this mesh.

Returns
a list of bones
float jassimp.AiMesh.getColorA ( int  vertex,
int  colorset 
)
inline

Returns the alpha color component of a color from a vertex color set.

Parameters
vertexthe vertex index
colorsetthe color set
Returns
the alpha color component
float jassimp.AiMesh.getColorB ( int  vertex,
int  colorset 
)
inline

Returns the blue color component of a color from a vertex color set.

Parameters
vertexthe vertex index
colorsetthe color set
Returns
the blue color component
FloatBuffer jassimp.AiMesh.getColorBuffer ( int  colorset)
inline

Returns a buffer containing vertex colors for a color set.

A vertex color consists of 4 floats (red, green, blue and alpha), the buffer will therefore contain 4 * getNumVertices() floats

Parameters
colorsetthe color set
Returns
a native-order direct buffer, or null if no data is available
float jassimp.AiMesh.getColorG ( int  vertex,
int  colorset 
)
inline

Returns the green color component of a color from a vertex color set.

Parameters
vertexthe vertex index
colorsetthe color set
Returns
the green color component
float jassimp.AiMesh.getColorR ( int  vertex,
int  colorset 
)
inline

Returns the red color component of a color from a vertex color set.

Parameters
vertexthe vertex index
colorsetthe color set
Returns
the red color component
IntBuffer jassimp.AiMesh.getFaceBuffer ( )
inline

Returns a buffer containing face data.

You should use the getIndexBuffer() method if you are interested in getting an index buffer used by graphics APIs such as LWJGL.

The buffer contains all vertex indices from all faces as a flat list. If the mesh is a pure triangle mesh, the buffer returned by this method is identical to the buffer returned by getIndexBuffer(). For other meshes, the getFaceOffsets() method can be used to retrieve an index structure that allows addressing individual faces in the list.

Returns
a native-order direct buffer, or null if no data is available
int jassimp.AiMesh.getFaceNumIndices ( int  face)
inline

Returns the number of vertex indices for a single face.

Parameters
facethe face
Returns
the number of indices
IntBuffer jassimp.AiMesh.getFaceOffsets ( )
inline

Returns an index structure for the buffer returned by getFaceBuffer().

You should use the getIndexBuffer() method if you are interested in getting an index buffer used by graphics APIs such as LWJGL.

The returned buffer contains one integer entry for each face. This entry specifies the offset at which the face's data is located inside the face buffer. The difference between two subsequent entries can be used to determine how many vertices belong to a given face (the last face contains all entries between the offset and the end of the face buffer).

Returns
a native-order direct buffer, or null if no data is available
int jassimp.AiMesh.getFaceVertex ( int  face,
int  n 
)
inline

Returns a vertex reference from a face.

A face contains getFaceNumIndices(face) vertex references. This method returns the n'th of these. The returned index can be passed directly to the vertex oriented methods, such as getPosition() etc.

Parameters
facethe face
nthe reference
Returns
a vertex index
IntBuffer jassimp.AiMesh.getIndexBuffer ( )
inline

Returns a buffer containing vertex indices for the mesh's faces.

This method may only be called on pure triangle meshes, i.e., meshes containing only triangles. The isPureTriangle() method can be used to check whether this is the case.

Indices are stored as integers, the buffer will therefore contain 3 * getNumVertices() integers (3 indices per triangle)

Returns
a native-order direct buffer
Exceptions
UnsupportedOperationExceptionif the mesh is not a pure triangle mesh
int jassimp.AiMesh.getMaterialIndex ( )
inline

Returns the material used by this mesh.

A mesh does use only a single material. If an imported model uses multiple materials, the import splits up the mesh. Use this value as index into the scene's material list.

Returns
the material index
String jassimp.AiMesh.getName ( )
inline

Returns the name of the mesh.

Not all meshes have a name, if no name is set an empty string is returned.

Returns
the name or an empty string if no name is set
FloatBuffer jassimp.AiMesh.getNormalBuffer ( )
inline

Returns a buffer containing normals.

A normal consists of a triple of floats, the buffer will therefore contain 3 * getNumVertices() floats

Returns
a native-order direct buffer
float jassimp.AiMesh.getNormalX ( int  vertex)
inline

Returns the x-coordinate of a vertex normal.

Parameters
vertexthe vertex index
Returns
the x coordinate
float jassimp.AiMesh.getNormalY ( int  vertex)
inline

Returns the y-coordinate of a vertex normal.

Parameters
vertexthe vertex index
Returns
the y coordinate
float jassimp.AiMesh.getNormalZ ( int  vertex)
inline

Returns the z-coordinate of a vertex normal.

Parameters
vertexthe vertex index
Returns
the z coordinate
int jassimp.AiMesh.getNumFaces ( )
inline

Returns the number of faces in the mesh.

Returns
the number of faces
int jassimp.AiMesh.getNumUVComponents ( int  coords)
inline

Returns the number of UV components for a texture coordinate set.

Possible values range from 1 to 3 (1D to 3D texture coordinates)

Parameters
coordsthe coordinate set
Returns
the number of components
int jassimp.AiMesh.getNumVertices ( )
inline

Returns the number of vertices in this mesh.

Returns
the number of vertices.
FloatBuffer jassimp.AiMesh.getPositionBuffer ( )
inline

Returns a buffer containing vertex positions.

A vertex position consists of a triple of floats, the buffer will therefore contain 3 * getNumVertices() floats

Returns
a native-order direct buffer, or null if no data is available
float jassimp.AiMesh.getPositionX ( int  vertex)
inline

Returns the x-coordinate of a vertex position.

Parameters
vertexthe vertex index
Returns
the x coordinate
float jassimp.AiMesh.getPositionY ( int  vertex)
inline

Returns the y-coordinate of a vertex position.

Parameters
vertexthe vertex index
Returns
the y coordinate
float jassimp.AiMesh.getPositionZ ( int  vertex)
inline

Returns the z-coordinate of a vertex position.

Parameters
vertexthe vertex index
Returns
the z coordinate
Set<AiPrimitiveType> jassimp.AiMesh.getPrimitiveTypes ( )
inline

Returns the primitive types used by this mesh.

Returns
a set of primitive types used by this mesh
FloatBuffer jassimp.AiMesh.getTangentBuffer ( )
inline

Returns a buffer containing tangents.

A tangent consists of a triple of floats, the buffer will therefore contain 3 * getNumVertices() floats

Returns
a native-order direct buffer
float jassimp.AiMesh.getTangentX ( int  vertex)
inline

Returns the x-coordinate of a vertex tangent.

Parameters
vertexthe vertex index
Returns
the x coordinate
float jassimp.AiMesh.getTangentY ( int  vertex)
inline

Returns the y-coordinate of a vertex bitangent.

Parameters
vertexthe vertex index
Returns
the y coordinate
float jassimp.AiMesh.getTangentZ ( int  vertex)
inline

Returns the z-coordinate of a vertex tangent.

Parameters
vertexthe vertex index
Returns
the z coordinate
FloatBuffer jassimp.AiMesh.getTexCoordBuffer ( int  coords)
inline

Returns a buffer containing coordinates for a texture coordinate set.

A texture coordinate consists of up to 3 floats (u, v, w). The actual number can be queried via getNumUVComponents(int). The buffer will contain getNumUVComponents(coords) * getNumVertices() floats

Parameters
coordsthe texture coordinate set
Returns
a native-order direct buffer, or null if no data is available
float jassimp.AiMesh.getTexCoordU ( int  vertex,
int  coords 
)
inline

Returns the u component of a coordinate from a texture coordinate set.

Parameters
vertexthe vertex index
coordsthe texture coordinate set
Returns
the u component
float jassimp.AiMesh.getTexCoordV ( int  vertex,
int  coords 
)
inline

Returns the v component of a coordinate from a texture coordinate set.

This method may only be called on 2- or 3-dimensional coordinate sets. Call getNumUVComponents(coords) to determine how may coordinate components are available.

Parameters
vertexthe vertex index
coordsthe texture coordinate set
Returns
the v component
float jassimp.AiMesh.getTexCoordW ( int  vertex,
int  coords 
)
inline

Returns the w component of a coordinate from a texture coordinate set.

This method may only be called on 3-dimensional coordinate sets. Call getNumUVComponents(coords) to determine how may coordinate components are available.

Parameters
vertexthe vertex index
coordsthe texture coordinate set
Returns
the w component
boolean jassimp.AiMesh.hasBones ( )
inline

Tells whether the mesh has bones.

Returns
true if bones are available
boolean jassimp.AiMesh.hasColors ( int  colorset)
inline

Tells whether the mesh has a vertex color set.

Parameters
colorsetindex of the color set
Returns
true if colors are available
boolean jassimp.AiMesh.hasFaces ( )
inline

Tells whether the mesh has faces.

Meshes almost always contain faces

Returns
true if faces are available
boolean jassimp.AiMesh.hasNormals ( )
inline

Tells whether the mesh has normals.

Returns
true if normals are available
boolean jassimp.AiMesh.hasPositions ( )
inline

Tells whether the mesh has vertex positions.

Meshes almost always contain position data

Returns
true if positions are available
boolean jassimp.AiMesh.hasTangentsAndBitangents ( )
inline

Tells whether the mesh has tangents and bitangents.

It is not possible that it contains tangents and no bitangents (or the other way round). The existence of one of them implies that the second is there, too.

Returns
true if tangents and bitangents are available
boolean jassimp.AiMesh.hasTexCoords ( int  coords)
inline

Tells whether the mesh has a texture coordinate set.

Parameters
coordsindex of the texture coordinate set
Returns
true if texture coordinates are available
boolean jassimp.AiMesh.hasTexCoords ( )
inline

Tells whether the mesh has any texture coordinate sets.

Use hasTexCoords(int) to check which texture coordinate sets are available

Returns
true if any texture coordinates are available
boolean jassimp.AiMesh.hasVertexColors ( )
inline

Tells whether the mesh has any vertex colors.

Use hasColors(int) to check which color sets are available.

Returns
true if any colors are available
boolean jassimp.AiMesh.isPureTriangle ( )
inline

Tells whether the mesh is a pure triangle mesh, i.e., contains only triangular faces.

To automatically triangulate meshes the AiPostProcessSteps#TRIANGULATE post processing option can be used when loading the scene

Returns
true if the mesh is a pure triangle mesh, false otherwise
String jassimp.AiMesh.toString ( )
inline

The documentation for this class was generated from the following file: