Class AbstractBresenhamTracer
java.lang.Object
com.ardor3d.extension.terrain.util.AbstractBresenhamTracer
- Direct Known Subclasses:
BresenhamYUpGridTracer
,BresenhamZUpGridTracer
AbstractBresenhamTracer is a simple base class for using Bresenham's line equation. Bresenham's line equation is
useful for doing various tasks that involve regularly spaced grids (such as picking against a height-map.) This class
is not intended to do any picking, only traveling and reporting the grid squares traversed.
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionprotected final int[]
protected final Vector3
protected final Vector3
protected final Vector3
protected AbstractBresenhamTracer.Direction
protected double
protected final Ray3
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract Vector2
get2DPoint
(ReadOnlyVector3 worldLocation, Vector2 store) Casts a world location to the local plane of this tracer.abstract Vector3
get3DPoint
(double gridX, double gridY, double height, Vector3 store) Turns a point on a 2D grid and a height into a 3D point based on the world up of this tracer.int[]
double
abstract boolean
abstract void
next()
Move us along our walkRay to the next grid location.void
setGridOrigin
(Vector3 origin) Set the world origin of our grid.void
setGridSpacing
(Vector3 spacing) Set the world spacing (scale) of our grid.abstract void
Set up our position on the grid and initialize the tracer using the provided ray.
-
Field Details
-
_gridOrigin
-
_gridSpacing
-
_gridLocation
protected final int[] _gridLocation -
_rayLocation
-
_walkRay
-
_stepDirection
-
_totalTravel
protected double _totalTravel
-
-
Constructor Details
-
AbstractBresenhamTracer
public AbstractBresenhamTracer()
-
-
Method Details
-
getLastStepDirection
- Returns:
- the direction of our last step on the grid.
-
getGridLocation
public int[] getGridLocation()- Returns:
- the row and column we are currently in on the grid.
-
getTotalTraveled
public double getTotalTraveled()- Returns:
- the total length we have traveled from the origin of our ray set in startWalk.
-
setGridOrigin
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
- Returns:
- the current grid origin
- See Also:
-
setGridSpacing
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
- Returns:
- the current grid spacing
- See Also:
-
startWalk
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().
-
get3DPoint
Turns a point on a 2D grid and a height into a 3D point based on the world up of this tracer.- Parameters:
gridX
- the abscissa of the gridgridY
- the ordinate of the gridheight
- the heightstore
- the vector to store our result in. if null a new vector is created and returned.- Returns:
- the vertex
-
get2DPoint
Casts a world location to the local plane of this tracer.- Parameters:
worldLocation
- the world locationstore
- the store- Returns:
- the point on the plane used by this tracer.
-