Package com.jme3.terrain.geomipmap
Class LODGeomap
java.lang.Object
com.jme3.terrain.GeoMap
com.jme3.terrain.geomipmap.LODGeomap
- All Implemented Interfaces:
- Savable
Produces the mesh for the TerrainPatch.
 This LOD algorithm generates a single triangle strip by first building the center of the
 mesh, minus one outer edge around it. Then it builds the edges in counter-clockwise order,
 starting at the bottom right and working up, then left across the top, then down across the
 left, then right across the bottom.
 It needs to know what its neighbour's LODs are, so it can stitch the edges.
 It creates degenerate polygons in order to keep the winding order of the polygons and to move
 the strip to a new position while still maintaining the continuity of the overall mesh. These
 degenerates are removed quickly by the video card.
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionclassKeeps a count of the number of indexes, good for debugging
- 
Field Summary
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic Vector3fcalculateTangent(Vector3f[] v, Vector2f[] t, Vector3f tangent, Vector3f binormal) createMesh(Vector3f scale, Vector2f tcScale, Vector2f tcOffset, float offsetAmount, int totalSize, boolean center) createMesh(Vector3f scale, Vector2f tcScale, Vector2f tcOffset, float offsetAmount, int totalSize, boolean center, int lod, boolean rightLod, boolean topLod, boolean leftLod, boolean bottomLod) protected intfindClosestHeightIndex(int x, int z) protected Triangle[]getGridTrianglesAtPoint(float x, float z) Get the two triangles that make up the grid section at the specified point.protected Triangle[]getGridTrianglesAtPoint(float x, float z, Vector3f scale, Vector3f translation) Get the two triangles that make up the grid section at the specified point, translated to world coordinates.protected floatgetHeight(int x, int z, float xm, float zm) Get the two triangles that make up the grid section at the specified point.protected TrianglegetTriangleAtPoint(float x, float z) Get the triangle that the point is on.protected TrianglegetTriangleAtPoint(float x, float z, Vector3f scale, Vector3f translation) Get a representation of the underlying triangle at the given point, translated to world coordinates.voidread(JmeImporter im) voidwrite(JmeExporter ex) writeIndexArrayLodDiff(int lod, boolean rightLod, boolean topLod, boolean leftLod, boolean bottomLod, int totalSize) Create the LOD index array that will seam its edges with its neighbour's LOD.writeIndexArrayLodVariable(int lod, int rightLod, int topLod, int leftLod, int bottomLod, int totalSize) writeNormalArray(FloatBuffer store, Vector3f scale) Creates a normal array from the normal data in this GeomapwriteTangentArray(FloatBuffer normalBuffer, FloatBuffer tangentStore, FloatBuffer binormalStore, FloatBuffer textureBuffer, Vector3f scale) writeTexCoordArray(FloatBuffer store, Vector2f offset, Vector2f scale, float offsetAmount, int totalSize) Methods inherited from class com.jme3.terrain.GeoMapcreateMesh, getHeight, getHeightArray, getMaximumValue, getUV, getUV, getValue, getValue, getWidth, isLoaded, writeIndexArray, writeTexCoordArray, writeVertexArray
- 
Constructor Details- 
LODGeomappublic LODGeomap()
- 
LODGeomappublic LODGeomap(int size, float[] heightMap) 
 
- 
- 
Method Details- 
createMesh
- 
createMesh
- 
writeTexCoordArraypublic FloatBuffer writeTexCoordArray(FloatBuffer store, Vector2f offset, Vector2f scale, float offsetAmount, int totalSize) 
- 
getUV
- 
writeIndexArrayLodDiffpublic IndexBuffer writeIndexArrayLodDiff(int lod, boolean rightLod, boolean topLod, boolean leftLod, boolean bottomLod, int totalSize) Create the LOD index array that will seam its edges with its neighbour's LOD. This is a scary method!!! It will break your mind.- Parameters:
- lod- level of detail of the mesh
- rightLod- LOD of the right neighbour
- topLod- LOD of the top neighbour
- leftLod- LOD of the left neighbour
- bottomLod- LOD of the bottom neighbour
- Returns:
- the LOD-ified index buffer
 
- 
writeIndexArrayLodVariablepublic IndexBuffer writeIndexArrayLodVariable(int lod, int rightLod, int topLod, int leftLod, int bottomLod, int totalSize) 
- 
writeTangentArraypublic FloatBuffer[] writeTangentArray(FloatBuffer normalBuffer, FloatBuffer tangentStore, FloatBuffer binormalStore, FloatBuffer textureBuffer, Vector3f scale) 
- 
calculateTangentpublic static Vector3f calculateTangent(Vector3f[] v, Vector2f[] t, Vector3f tangent, Vector3f binormal) - Parameters:
- v- Takes 3 vertices: root, right, bottom
- t- Takes 3 tex coords: root, right, bottom
- tangent- that will store the result
- Returns:
- the tangent store
 
- 
writeNormalArrayDescription copied from class:GeoMapCreates a normal array from the normal data in this Geomap- Overrides:
- writeNormalArrayin class- GeoMap
- Parameters:
- store- A preallocated FloatBuffer where to store the data (optional), size must be >= getWidth()*getHeight()*3
- Returns:
- store, or a new FloatBuffer if store is null
 
- 
getHeightprotected float getHeight(int x, int z, float xm, float zm) Get the two triangles that make up the grid section at the specified point. For every grid space there are two triangles oriented like this: *----* |a / | | / b| *----* The corners of the mesh have differently oriented triangles. The two corners that we have to special-case are the top left and bottom right corners. They are oriented inversely: *----* | \ b| |a \ | *----*
- 
getTriangleAtPointGet a representation of the underlying triangle at the given point, translated to world coordinates.- Parameters:
- x- local x coordinate
- z- local z coordinate
- Returns:
- a triangle in world space not local space
 
- 
getGridTrianglesAtPointprotected Triangle[] getGridTrianglesAtPoint(float x, float z, Vector3f scale, Vector3f translation) Get the two triangles that make up the grid section at the specified point, translated to world coordinates.- Parameters:
- x- local x coordinate
- z- local z coordinate
- scale-
- translation-
- Returns:
- two triangles in world space not local space
 
- 
getGridTrianglesAtPointGet the two triangles that make up the grid section at the specified point. For every grid space there are two triangles oriented like this: *----* |a / | | / b| *----* The corners of the mesh have differently oriented triangles. The two corners that we have to special-case are the top left and bottom right corners. They are oriented inversely: *----* | \ b| |a \ | *----*- Parameters:
- x- local x coordinate
- z- local z coordinate
- Returns:
- a new array or null
 
- 
getTriangleAtPointGet the triangle that the point is on.- Parameters:
- x- coordinate in local space to the geomap
- z- coordinate in local space to the geomap
- Returns:
- triangle in local space to the geomap
 
- 
findClosestHeightIndexprotected int findClosestHeightIndex(int x, int z) 
- 
write- Specified by:
- writein interface- Savable
- Overrides:
- writein class- GeoMap
- Throws:
- IOException
 
- 
read- Specified by:
- readin interface- Savable
- Overrides:
- readin class- GeoMap
- Throws:
- IOException
 
 
-