All visible game elements in a scene, whether it is a Model or a Shape, are made up of polygon meshes. JME3 has a com.jme3.scene.Mesh class that represents all meshes.
Meshes are made up of triangles:
Each mesh has a unique ID:
Meshes have transformations: Location (local translation), rotation, scale.
Meshes have a bounding volume. jME3 can detect intersections (that is, non-physical collisions) between meshes, or between meshes and 2D elements such as rays:
Meshes are locked with
setStatic()and unlocked with
Static Meshes cannot be modified, but are more optimized and faster (they can be precalculated).
Dynamic Meshes can be modified live, but are not optimized and slower.
You have several options when creating Geometries from meshes:
The VertexBuffer contains a particular type of geometry data used by Meshes. Every VertexBuffer set on a Mesh is sent as an attribute to the vertex shader to be processed.
Mesh Vertex Buffers
Here is the list of VertexBuffer types.
|Vertex Buffer Type||Description|
Position of the vertex (3 floats)
Specifies the index buffer, must contain integer data.
Texture coordinate #2
Normal vector, normalized.
Tangent vector, normalized.
Binormal vector, normalized.
Color and Alpha (4 floats)
The size of the point when using point buffers.
Specifies the source data for various vertex buffers when interleaving is used.
Inital vertex position, used with animation.
Inital vertex normals, used with animation
Bone weights, used with animation
Bone indices, used with animation
Some Mesh properties from the Mesh class.
if you need to specifiy a custom optimized bounding volume
Locks the mesh so you cannot modify it anymore, thus optimizing its data (faster).
Unlocks the mesh so you can modified it, but this will un-optimize the data (slower).
Used to set mesh rendering modes, see below.
returns the Mesh ID, default value is -1
returns data of triangle number
How the texture will be stretched over the whole mesh.
Mesh Rendering Modes
Here is the list of Mesh rendering modes.
Show only corner points (vertices) of mesh
Show lines (edges) of mesh
Level of Detail
Optionally, custom meshes can have a LOD (level of detail optimization) that renders more or less detail, depending on the distance of the mesh from the camera. You have to specify several vertex buffers, one for each level of detail you want (very far away with few details, close up with all details, and something in the middle). Use