com.jme3.terrain.geomipmap
クラス TerrainPatch

java.lang.Object
  上位を拡張 com.jme3.scene.Spatial
      上位を拡張 com.jme3.scene.Geometry
          上位を拡張 com.jme3.terrain.geomipmap.TerrainPatch
すべての実装されたインタフェース:
Asset, Collidable, Savable, java.lang.Cloneable

public class TerrainPatch
extends Geometry

A terrain patch is a leaf in the terrain quad tree. It has a mesh that can change levels of detail (LOD) whenever the view point, or camera, changes. The actual terrain mesh is created by the LODGeomap class. That uses a geo-mipmapping algorithm to change the index buffer of the mesh. The mesh is a triangle strip. In wireframe mode you might notice some strange lines, these are degenerate triangles generated by the geoMipMap algorithm and can be ignored. The video card removes them at almost no cost. Each patch needs to know its neighbour's LOD so it can seam its edges with them, in case the neighbour has a different LOD. If this doesn't happen, you will see gaps. The LOD value is most detailed at zero. It gets less detailed the higher the LOD value until you reach maxLod, which is a mathematical limit on the number of times the 'size' of the patch can be divided by two. However there is a -1 to that for now until I add in a custom index buffer calculation for that max level, the current algorithm does not go that far. You can supply a LodThresholdCalculator for use in determining when the LOD should change. It's API will no doubt change in the near future. Right now it defaults to just changing LOD every two patch sizes. So if a patch has a size of 65, then the LOD changes every 130 units away.


入れ子のクラスの概要
 
クラス com.jme3.scene.Spatial から継承された入れ子のクラス/インタフェース
Spatial.CullHint
 
フィールドの概要
 
クラス com.jme3.scene.Spatial から継承されたフィールド
queueDistance
 
コンストラクタの概要
TerrainPatch()
           
TerrainPatch(java.lang.String name)
           
TerrainPatch(java.lang.String name, int size)
           
TerrainPatch(java.lang.String name, int size, Vector3f stepScale, float[] heightMap, Vector3f origin)
          Constructor instantiates a new TerrainPatch object.
TerrainPatch(java.lang.String name, int size, Vector3f stepScale, float[] heightMap, Vector3f origin, int totalSize, Vector2f offset, float offsetAmount)
          Constructor instantiates a new TerrainPatch object.
 
メソッドの概要
 TerrainPatch clone()
          This version of clone is a shallow clone, in other words, the same mesh is referenced as the original geometry.
 int collideWith(Collidable other, CollisionResults results)
          Check collision with another Collidable.
 void generateLodEntropies()
          This calculation is slow, so don't use it often.
 Triangle[] getGridTriangles(float x, float z)
          Get the triangles at the specified grid point.
 java.nio.FloatBuffer getHeightmap()
           
 float getHeightmapHeight(float x, float z)
           
 int getLod()
           
 LodCalculator getLodCalculator()
           
 float[] getLodEntropies()
           
 int getMaxLod()
          The maximum lod supported by this terrain patch.
 Vector2f getOffset()
          Returns the current offset amount.
 float getOffsetAmount()
          Returns the offset amount this terrain patch uses for textures.
 int getPreviousLod()
           
 short getQuadrant()
           
 int getSize()
          Returns the size of this terrain patch.
 Vector3f getStepScale()
          Returns the step scale that stretches the height map.
 Vector2f getTex(float x, float z, Vector2f store)
           
 int getTotalSize()
          Returns the total size of the terrain.
 Triangle getTriangle(float x, float z)
          Get the triangle of this geometry at the specified local coordinate.
 void lockMesh()
          Locks the mesh (sets it static) to improve performance.
 void read(JmeImporter im)
           
 void setLod(int lod)
           
 void setLodCalculator(LodCalculator lodCalculator)
           
 void setLodCalculator(LodCalculatorFactory lodCalculatorFactory)
           
 void setOffset(Vector2f offset)
          Sets the value for the current offset amount to use when building texture coordinates.
 void setOffsetAmount(float offsetAmount)
          Sets the offset of this terrain texture map.
 void setPreviousLod(int previousLod)
           
 void setQuadrant(short quadrant)
           
 void setSize(int size)
          Sets the size of this terrain patch.
 void setStepScale(Vector3f stepScale)
          Sets the step scale of this terrain patch's height map.
 void setTotalSize(int totalSize)
          Sets the total size of the terrain .
 void unlockMesh()
          Unlocks the mesh (sets it dynamic) to make it editable.
 void write(JmeExporter ex)
           
 
クラス com.jme3.scene.Geometry から継承されたメソッド
clone, computeWorldMatrix, deepClone, depthFirstTraversal, getLodLevel, getMaterial, getMesh, getModelBound, getTriangleCount, getVertexCount, getWorldMatrix, isIgnoreTransform, setIgnoreTransform, setLodLevel, setMaterial, setMesh, setModelBound, updateModelBound
 
クラス com.jme3.scene.Spatial から継承されたメソッド
addControl, addLight, breadthFirstTraversal, center, checkCulling, getControl, getControl, getCullHint, getKey, getLastFrustumIntersection, getLocalCullHint, getLocalLightList, getLocalQueueBucket, getLocalRotation, getLocalScale, getLocalShadowMode, getLocalToWorldMatrix, getLocalTransform, getLocalTranslation, getName, getNumControls, getParent, getQueueBucket, getShadowMode, getUserData, getUserDataKeys, getWorldBound, getWorldLightList, getWorldRotation, getWorldScale, getWorldTransform, getWorldTranslation, hasAncestor, localToWorld, lookAt, matches, move, move, removeControl, removeControl, removeFromParent, removeLight, rotate, rotate, rotateUpTo, runControlRender, scale, scale, setCullHint, setKey, setLastFrustumIntersection, setLocalRotation, setLocalRotation, setLocalScale, setLocalScale, setLocalScale, setLocalTransform, setLocalTranslation, setLocalTranslation, setName, setQueueBucket, setShadowMode, setUserData, toString, updateGeometricState, updateLogicalState, worldToLocal
 
クラス java.lang.Object から継承されたメソッド
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

コンストラクタの詳細

TerrainPatch

public TerrainPatch()

TerrainPatch

public TerrainPatch(java.lang.String name)

TerrainPatch

public TerrainPatch(java.lang.String name,
                    int size)

TerrainPatch

public TerrainPatch(java.lang.String name,
                    int size,
                    Vector3f stepScale,
                    float[] heightMap,
                    Vector3f origin)
Constructor instantiates a new TerrainPatch object. The parameters and heightmap data are then processed to generate a TriMesh object for rendering.

パラメータ:
name - the name of the terrain patch.
size - the size of the heightmap.
stepScale - the scale for the axes.
heightMap - the height data.
origin - the origin offset of the patch.

TerrainPatch

public TerrainPatch(java.lang.String name,
                    int size,
                    Vector3f stepScale,
                    float[] heightMap,
                    Vector3f origin,
                    int totalSize,
                    Vector2f offset,
                    float offsetAmount)
Constructor instantiates a new TerrainPatch object. The parameters and heightmap data are then processed to generate a TriMesh object for renderering.

パラメータ:
name - the name of the terrain patch.
size - the size of the patch.
stepScale - the scale for the axes.
heightMap - the height data.
origin - the origin offset of the patch.
totalSize - the total size of the terrain. (Higher if the patch is part of a TerrainQuad tree.
offset - the offset for texture coordinates.
offsetAmount - the total offset amount. Used for texture coordinates.
メソッドの詳細

generateLodEntropies

public void generateLodEntropies()
This calculation is slow, so don't use it often.


getLodEntropies

public float[] getLodEntropies()

getHeightmap

public java.nio.FloatBuffer getHeightmap()

getMaxLod

public int getMaxLod()
The maximum lod supported by this terrain patch. If the patch size is 32 then the returned value would be log2(32)-2 = 3 You can then use that value, 3, to see how many times you can divide 32 by 2 before the terrain gets too un-detailed (can't stitch it any further).

戻り値:

getTex

public Vector2f getTex(float x,
                       float z,
                       Vector2f store)

getHeightmapHeight

public float getHeightmapHeight(float x,
                                float z)

getTriangle

public Triangle getTriangle(float x,
                            float z)
Get the triangle of this geometry at the specified local coordinate.

パラメータ:
gridX - local to the terrain patch
gridY - local to the terrain patch
戻り値:
the triangle in world coordinates, or null if the point does intersect this patch on the XZ axis

getGridTriangles

public Triangle[] getGridTriangles(float x,
                                   float z)
Get the triangles at the specified grid point. Probably only 2 triangles

パラメータ:
gridX - local to the terrain patch
gridY - local to the terrain patch
戻り値:
the triangles in world coordinates, or null if the point does intersect this patch on the XZ axis

lockMesh

public void lockMesh()
Locks the mesh (sets it static) to improve performance. But it it not editable then. Set unlock to make it editable.


unlockMesh

public void unlockMesh()
Unlocks the mesh (sets it dynamic) to make it editable. It will be editable but performance will be reduced. Call lockMesh to improve performance.


getOffsetAmount

public float getOffsetAmount()
Returns the offset amount this terrain patch uses for textures.

戻り値:
The current offset amount.

getStepScale

public Vector3f getStepScale()
Returns the step scale that stretches the height map.

戻り値:
The current step scale.

getTotalSize

public int getTotalSize()
Returns the total size of the terrain.

戻り値:
The terrain's total size.

getSize

public int getSize()
Returns the size of this terrain patch.

戻り値:
The current patch size.

getOffset

public Vector2f getOffset()
Returns the current offset amount. This is used when building texture coordinates.

戻り値:
The current offset amount.

setOffset

public void setOffset(Vector2f offset)
Sets the value for the current offset amount to use when building texture coordinates. Note that this does NOT rebuild the terrain at all. This is mostly used for outside constructors of terrain patches.

パラメータ:
offset - The new texture offset.

setSize

public void setSize(int size)
Sets the size of this terrain patch. Note that this does NOT rebuild the terrain at all. This is mostly used for outside constructors of terrain patches.

パラメータ:
size - The new size.

setTotalSize

public void setTotalSize(int totalSize)
Sets the total size of the terrain . Note that this does NOT rebuild the terrain at all. This is mostly used for outside constructors of terrain patches.

パラメータ:
totalSize - The new total size.

setStepScale

public void setStepScale(Vector3f stepScale)
Sets the step scale of this terrain patch's height map. Note that this does NOT rebuild the terrain at all. This is mostly used for outside constructors of terrain patches.

パラメータ:
stepScale - The new step scale.

setOffsetAmount

public void setOffsetAmount(float offsetAmount)
Sets the offset of this terrain texture map. Note that this does NOT rebuild the terrain at all. This is mostly used for outside constructors of terrain patches.

パラメータ:
offsetAmount - The new texture offset.

getQuadrant

public short getQuadrant()
戻り値:
Returns the quadrant.

setQuadrant

public void setQuadrant(short quadrant)
パラメータ:
quadrant - The quadrant to set.

getLod

public int getLod()

setLod

public void setLod(int lod)

getPreviousLod

public int getPreviousLod()

setPreviousLod

public void setPreviousLod(int previousLod)

getLodCalculator

public LodCalculator getLodCalculator()

setLodCalculator

public void setLodCalculator(LodCalculator lodCalculator)

setLodCalculator

public void setLodCalculator(LodCalculatorFactory lodCalculatorFactory)

collideWith

public int collideWith(Collidable other,
                       CollisionResults results)
                throws UnsupportedCollisionException
インタフェース Collidable の記述:
Check collision with another Collidable.

定義:
インタフェース Collidable 内の collideWith
オーバーライド:
クラス Geometry 内の collideWith
パラメータ:
other - The object to check collision against
results - Will contain the list of CollisionResults.
戻り値:
how many collisions were found between this and other
例外:
UnsupportedCollisionException

write

public void write(JmeExporter ex)
           throws java.io.IOException
定義:
インタフェース Savable 内の write
オーバーライド:
クラス Geometry 内の write
例外:
java.io.IOException

read

public void read(JmeImporter im)
          throws java.io.IOException
定義:
インタフェース Savable 内の read
オーバーライド:
クラス Geometry 内の read
例外:
java.io.IOException

clone

public TerrainPatch clone()
クラス Geometry の記述:
This version of clone is a shallow clone, in other words, the same mesh is referenced as the original geometry. Exception: if the mesh is marked as being a software animated mesh, (bind pose is set) then the positions and normals are deep copied.

オーバーライド:
クラス Geometry 内の clone
戻り値:
A clone of this Spatial, the scene graph in its entirety is cloned and can be altered independently of the original scene graph. Note that meshes of geometries are not cloned explicitly, they are shared if static, or specially cloned if animated. All controls will be cloned using the Control.cloneForSpatial method on the clone.
関連項目:
Mesh.cloneForAnim()