Class AbstractBresenhamTracer

java.lang.Object
com.ardor3d.extension.terrain.util.AbstractBresenhamTracer
Direct Known Subclasses:
BresenhamYUpGridTracer, BresenhamZUpGridTracer

public abstract class AbstractBresenhamTracer extends Object
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.
  • Field Details

    • _gridOrigin

      protected final Vector3 _gridOrigin
    • _gridSpacing

      protected final Vector3 _gridSpacing
    • _gridLocation

      protected final int[] _gridLocation
    • _rayLocation

      protected final Vector3 _rayLocation
    • _walkRay

      protected final Ray3 _walkRay
    • _stepDirection

      protected AbstractBresenhamTracer.Direction _stepDirection
    • _totalTravel

      protected double _totalTravel
  • Constructor Details

    • AbstractBresenhamTracer

      public AbstractBresenhamTracer()
  • Method Details

    • getLastStepDirection

      public AbstractBresenhamTracer.Direction 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

      public void setGridOrigin(Vector3 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 Vector3 getGridOrigin()
      Returns:
      the current grid origin
      See Also:
    • setGridSpacing

      public void setGridSpacing(Vector3 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 Vector3 getGridSpacing()
      Returns:
      the current grid spacing
      See Also:
    • startWalk

      public abstract void startWalk(Ray3 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().
    • get3DPoint

      public 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.
      Parameters:
      gridX - the abscissa of the grid
      gridY - the ordinate of the grid
      height - the height
      store - the vector to store our result in. if null a new vector is created and returned.
      Returns:
      the vertex
    • get2DPoint

      public abstract Vector2 get2DPoint(ReadOnlyVector3 worldLocation, Vector2 store)
      Casts a world location to the local plane of this tracer.
      Parameters:
      worldLocation - the world location
      store - the store
      Returns:
      the point on the plane used by this tracer.