com.jmex.terrain.util
Class AbstractBresenhamTracer
java.lang.Object
com.jmex.terrain.util.AbstractBresenhamTracer
- Direct Known Subclasses:
- BresenhamYUpGridTracer
public abstract class AbstractBresenhamTracer
- extends java.lang.Object
AbstractBresenhamTracer is a simple base class for using Bresenham's line
equation in jME. Bresenham's line equation is useful for doing various 3d
tasks that involve regularly spaced grids (such as picking against a
terrain.)
- Author:
- Joshua Slack
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
_gridOrigin
protected final Vector3f _gridOrigin
_gridSpacing
protected final Vector3f _gridSpacing
_gridLocation
protected final Vector2f _gridLocation
_rayLocation
protected final Vector3f _rayLocation
_walkRay
protected final Ray _walkRay
stepDirection
protected AbstractBresenhamTracer.Direction stepDirection
rayLength
protected float rayLength
AbstractBresenhamTracer
public AbstractBresenhamTracer()
getLastStepDirection
public AbstractBresenhamTracer.Direction getLastStepDirection()
- Returns:
- the direction of our last step on the grid.
getGridLocation
public Vector2f getGridLocation()
- Returns:
- the row and column we are currently in on the grid.
getRayTraveled
public float getRayTraveled()
- Returns:
- how far we traveled down the ray on our last call to next().
setGridOrigin
public void setGridOrigin(Vector3f origin)
- Set the world origin of our grid. This is useful to the tracer when doing
conversion between world coordinates and grid locations.
- Parameters:
origin
- our new origin (copied into the tracer)
getGridOrigin
public Vector3f getGridOrigin()
- Returns:
- the current grid origin
- See Also:
setGridOrigin(Vector3f)
setGridSpacing
public void setGridSpacing(Vector3f spacing)
- Set the world spacing (scale) of our grid. Also useful for converting
between world coordinates and grid location.
- Parameters:
spacing
- our new spacing (copied into the tracer)
getGridSpacing
public Vector3f getGridSpacing()
- Returns:
- the current grid spacing
- See Also:
setGridSpacing(Vector3f)
startWalk
public abstract void startWalk(Ray walkRay)
- Set up our position on the grid and initialize the tracer using the
provided ray.
- Parameters:
walkRay
- the world ray along which we we walk the grid.
next
public abstract void next()
- Move us along our walkRay to the next grid location.
isRayPerpendicularToGrid
public abstract boolean isRayPerpendicularToGrid()
- Returns:
- true if our walkRay, specified in startWalk, ended up being
perpendicular to the grid (and therefore can not move to a new
grid location on calls to next(). You should test this after
calling startWalk and before calling next().