de.rico.engine.path
Class Path

java.lang.Object
  extended by de.rico.engine.path.Path

public class Path
extends java.lang.Object

This class represents a path. A path is a number of coordinates that get travelled sequencially.

Author:
Frank Bruns

Constructor Summary
Path()
          Creates a new empty path.
Path(java.lang.String file)
          Creates a path object from a file that contains stored path data.
 
Method Summary
 void addPoint(float x, float z)
          Adds a point to the path.
 void draw(javax.media.opengl.GL gl)
          This method can be used to visualize the path by connected lines from the start point to the destination point.
 Point3D getCurrentPoint()
          Returns the current point of the path.
 Point3D getNextPoint()
          Returns the next point in the path.
 java.util.LinkedList<Point3D> getPoints()
          Returns the list of points of the path.
 Point3D getPreviousPoint()
          Returns the point previous to the current one of the path if there exits one, otherwise null is returned.
 void next()
          Sets the next point of the path as the active one
 void reset()
          Resets the path to it's first point.
 void save(java.lang.String pathToFile)
          Saves the path to a file with the specified file path.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Path

public Path()
Creates a new empty path.


Path

public Path(java.lang.String file)
Creates a path object from a file that contains stored path data.

Parameters:
file - path to file with stored path data.
Method Detail

addPoint

public void addPoint(float x,
                     float z)
Adds a point to the path. The y coordinate of the point is always set to 0, because it is irrelevant for the path across the XZ plane search grid. If the y coordinate is needed for a mesh, you should retrieve it by finding the height over the ground mesh for the mesh that the path is applied to. If you attach the mesh to the ground then the y coordinate is set automatically.

Parameters:
x - x coordinate
z - z coordinate

getCurrentPoint

public Point3D getCurrentPoint()
Returns the current point of the path. Returns null if no point is available. Note: The y coordinate of the point is always set to 0.

Returns:
current point of the path

getNextPoint

public Point3D getNextPoint()
Returns the next point in the path. If there is no next point the current point will be returned. Note: The y coordinate of the point is always set to 0.

Returns:
next point in the path, if available

getPreviousPoint

public Point3D getPreviousPoint()
Returns the point previous to the current one of the path if there exits one, otherwise null is returned. Note: The y coordinate of the point is always set to 0.

Returns:
point previous to the current one of the path

getPoints

public java.util.LinkedList<Point3D> getPoints()
Returns the list of points of the path. Note: The y coordinate of the points is always set to 0.

Returns:
list of points of the path

next

public void next()
Sets the next point of the path as the active one


reset

public void reset()
Resets the path to it's first point.


draw

public void draw(javax.media.opengl.GL gl)
This method can be used to visualize the path by connected lines from the start point to the destination point.

Parameters:
gl -

save

public void save(java.lang.String pathToFile)
Saves the path to a file with the specified file path. There will only be saved something if there are points assigned to the path.

Parameters:
pathToFile - path to the file into which the path data gets saved