Class BresenhamTerrainPicker
java.lang.Object
com.jme3.terrain.geomipmap.picking.BresenhamTerrainPicker
- All Implemented Interfaces:
TerrainPicker
It basically works by casting a pick ray
against the bounding volumes of the TerrainQuad and its children, gathering
all of the TerrainPatches hit (in distance order.) The triangles of each patch
are then tested using the BresenhamYUpGridTracer to determine which triangles
to test and in what order. When a hit is found, it is guaranteed to be the
first such hit and can immediately be returned.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
checkTriangles
(float gridX, float gridY, Ray pick, Vector3f intersection, TerrainPatch patch, Triangle store) protected int
findClosestHeightIndex
(Vector3f position, TerrainPatch patch) Finds the closest height point to a position.int
getTerrainIntersection
(Ray worldPick, CollisionResults results) Ask for the point of intersection between the given ray and the terrain.protected boolean
getTriangles
(float gridX, float gridY, TerrainPatch patch) Request the triangles (in world coord space) of a TerrainBlock that correspond to the given grid location.boolean
void
setSupportMultipleCollisions
(boolean multipleCollisions)
-
Constructor Details
-
BresenhamTerrainPicker
-
-
Method Details
-
setSupportMultipleCollisions
public void setSupportMultipleCollisions(boolean multipleCollisions) -
isSupportingMultipleCollisions
public boolean isSupportingMultipleCollisions() -
getTerrainIntersection
Description copied from interface:TerrainPicker
Ask for the point of intersection between the given ray and the terrain.- Specified by:
getTerrainIntersection
in interfaceTerrainPicker
- Parameters:
worldPick
- our pick ray, in world space.- Returns:
- The number of collisions found
-
checkTriangles
protected boolean checkTriangles(float gridX, float gridY, Ray pick, Vector3f intersection, TerrainPatch patch, Triangle store) -
getTriangles
Request the triangles (in world coord space) of a TerrainBlock that correspond to the given grid location. The triangles are stored in the class fields _gridTriA and _gridTriB.- Parameters:
gridX
- grid rowgridY
- grid columnpatch
- the TerrainPatch we are working with- Returns:
- true if the grid point is valid for the given block, false if it is off the block.
-
findClosestHeightIndex
Finds the closest height point to a position. Will always be left/above that position.- Parameters:
position
- the position to check atpatch
- the patch to get height values from- Returns:
- an index to the height position of the given block.
-