public final class Mesh
In a Mesh, jPCT stores the actual vertex and triangle information for an
object. Mesh can't be instantiated directly. Meshes are shareable between
objects. This means that more than one object may use the same instance of
Mesh. This saves memory and is more cache-friendly. Meshes are also used for
implementing keyframe animation.
Sets the VertexController for this Mesh. A VertexController is the only
way for an application to modify the vertex data of jPCT's meshes after
Usually, a custom VertexController extend the GenericVertexController the
API provides. An instance can only be assigned to one mesh at a time.
This mesh should include vertex normals, i.e. it has to belong to an
object for which build() has been called already. If that's not the case,
jPCT will print out a warning message.
controller - the controller
modify - the mode, i.e. if the modifications are cumulative or not
Executes the apply() method of the assigned VertexController and updates
the mesh's vertex data with the new values generated by the controller.
public void removeVertexController()
Removes the VertexController from this mesh. When doing so, the
controller's destroy() method will be called.
public void strip()
Removes triangle information from this mesh. This is useful to save some
memory for meshes that are used for keyframing only (triangle information
are not needed in that case). For any other meshes: Don't call this
method. It will break your mesh!
public void setLocked(boolean locked)
Locks a mesh. A locked mesh can't and won't be stripped even if you call
the corresponding methods. This can be used to strip Object3Ds that are
locked - should it be locked?
public boolean isLocked()
Returns if this mesh has been locked or not!
public void compress()
Compresses the mesh by removing unused information from it. When creating
a mesh, it is usually not known how many unique vertices it may contain,
so space is reserved for the extreme case that no vertex-sharing is
possible within this mesh (the vertex sharing is something that jPCT
automatically takes care of). The more vertices are sharable between the
triangles of the mesh, the more space remains unused. compress() frees
this space at the cost that no additional vertices can be added to the
mesh after compressing it. If one is sure that this is not required,
compressing a mesh can be helpful to save memory. Meshes of loaded MD2-
and 3DS-models are compressed by default.
Returns a copy of this mesh. A copy of a mesh can be used to take a mesh
from an existing object and modify it without modifying the source mesh.
With this, you can also use meshes from existing objects (not only
temporary ones) as meshes for a keyframe animation [like:
Animation.addKeyFrame(obj.getMesh().cloneMesh(...))]. Cloning a
compressed mesh without letting cloneMesh compress it again will result
in an uncompressed one (eats up more memory, but triangles may be added
to such a mesh again).
compressed - indicates if compress() should by called after cloning the
mesh or not
Returns the number of vertices this mesh consists of
the number of vertices
public int getUniqueVertexCount()
Returns the number of unique vertices. Unlike getVertexCount(), this
number takes into account that vertices are shared between triangles
whenever possible to lower geometry processing time. jPCT does only
transform as many vertices as this number indicates.
the number of unique vertices
public int getTriangleCount()
The number of triangles for this mesh.
the number of triangles
public float getBoundingBox()
Returns the bounding box in object space of this mesh in a float array.
Format is minX, maxX, minY, maxY, minZ, maxZ. Calculation is done
everytime this method is being called, so don't call it without need.