cz.cuni.amis.pogamut.ut2004.agent.navigation.navmesh
Class NavMesh

Package class diagram package NavMesh
java.lang.Object
  extended by cz.cuni.amis.pogamut.ut2004.agent.navigation.navmesh.NavMesh
All Implemented Interfaces:
IPathPlanner<ILocated>

public class NavMesh
extends Object
implements IPathPlanner<ILocated>

Main class of Navigation Mesh module

Author:
Jakub Tomek

Field Summary
 Random random
           
 
Constructor Summary
NavMesh()
          Overload for constructor
NavMesh(boolean loadLevelGeometry)
          Reads Navmesh from file - creates data structure
 
Method Summary
 IPathFuture<ILocated> computePath(ILocated from, ILocated to)
          Computes and returns a path between two points anywhere on the map.
 void draw()
          Draws navmesh in game
 void draw(String lines, Location color)
          Draws given lines
 void drawLevelGeometry(Location color)
           
 void drawOnePolygon(int i)
          Draws one polygon with default color (yellow)
 void drawOnePolygon(int i, Location color)
          Draws one polygon with the color set in color
 void drawOnlyBiggestLeaf()
          Debug method: Draws only the polygons in the biggeswt leaf so that we can see whe they could not have been split any further
 void drawPath(IPathFuture<ILocated> path, Location color)
          Draws the given path
 void drawPolygonPath(List<INavMeshAtom> polygonPath, Location location)
          Draws entire list of polygons
 double getDistanceFromEdge(Location location, javax.vecmath.Vector2d vector)
          Returns distance of the location from the navmesh's edge in the given direction.
 double getDistanceFromEdge(Location location, javax.vecmath.Vector2d vector, double rayLength)
          A simple implementation of NavMesh's 2D raycasting.
 LevelGeometry getLevelGeometry()
          Returns levelGeometry object
 ArrayList getNeighbourIdsToPolygon(int i)
          gets an array of polygon ids by an polygon id
 int getNumberOfPolygonsInBiggestLeaf()
          Debug method: helps to describe BSP tree by telling the number of polygons in the biggest leaf (this should not bee too big. 5 is a good number.)
 List<OffMeshPoint> getOffMeshPoinsOnPolygon(int pId)
          Returns a List of offmeshpoints that are located on target polygon
 List<ILocated> getPath(ILocated from, ILocated to)
          Computes and returns a path between two points anywhere on the map.
 int[] getPolygon(int i)
          gets a polygon by its order
 int getPolygonIdByLocation(Location location)
          Gets the id of a polygon that contains this location
 int getPolygonIdByPoint3D(math.geom3d.Point3D point3D)
           
 List<INavMeshAtom> getPolygonPath(INavMeshAtom fromAtom, INavMeshAtom toAtom)
          Gets a List of polygons on which the path should go.
 List<INavMeshAtom> getPolygonPath(Location from, Location to)
          Calls the method with the same name but polygons as arguments and returns result
 ArrayList getPolygonsByVertex(int i)
          gets a list of polygons containing this vertex
 double[] getVertex(int i)
          gets a vertex by its order
 int polyCount()
          Returns the number of polygons in navmesh
 String polygonToDebugString(int polygonNumber)
          Restricted alternative to toDebugString() - returns only one polygon as string
 void setBiggestLeafInTree(BSPNode node)
          Debug method: sets the biggest leaf so it can be easily found.
 String toDebugString()
          Returns all lines in one long string.
 void unDraw()
          Undraws all currently drawn lines
 int vertCount()
          Returns the number of vertices in navmesh
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

random

public Random random
Constructor Detail

NavMesh

public NavMesh(boolean loadLevelGeometry)
        throws FileNotFoundException,
               IOException
Reads Navmesh from file - creates data structure

Throws:
FileNotFoundException
IOException

NavMesh

public NavMesh()
        throws FileNotFoundException,
               IOException
Overload for constructor

Throws:
FileNotFoundException
IOException
Method Detail

toDebugString

public String toDebugString()
Returns all lines in one long string.


polygonToDebugString

public String polygonToDebugString(int polygonNumber)
Restricted alternative to toDebugString() - returns only one polygon as string


draw

public void draw()
Draws navmesh in game


draw

public void draw(String lines,
                 Location color)
Draws given lines

Parameters:
lines -

unDraw

public void unDraw()
Undraws all currently drawn lines


drawLevelGeometry

public void drawLevelGeometry(Location color)

drawOnePolygon

public void drawOnePolygon(int i,
                           Location color)
Draws one polygon with the color set in color


drawOnePolygon

public void drawOnePolygon(int i)
Draws one polygon with default color (yellow)


drawPolygonPath

public void drawPolygonPath(List<INavMeshAtom> polygonPath,
                            Location location)
Draws entire list of polygons

Parameters:
polygonPath -

drawPath

public void drawPath(IPathFuture<ILocated> path,
                     Location color)
Draws the given path

Parameters:
path -

drawOnlyBiggestLeaf

public void drawOnlyBiggestLeaf()
Debug method: Draws only the polygons in the biggeswt leaf so that we can see whe they could not have been split any further


polyCount

public int polyCount()
Returns the number of polygons in navmesh


vertCount

public int vertCount()
Returns the number of vertices in navmesh


getPolygon

public int[] getPolygon(int i)
gets a polygon by its order


getVertex

public double[] getVertex(int i)
gets a vertex by its order


getPolygonsByVertex

public ArrayList getPolygonsByVertex(int i)
gets a list of polygons containing this vertex


getNeighbourIdsToPolygon

public ArrayList getNeighbourIdsToPolygon(int i)
gets an array of polygon ids by an polygon id


getOffMeshPoinsOnPolygon

public List<OffMeshPoint> getOffMeshPoinsOnPolygon(int pId)
Returns a List of offmeshpoints that are located on target polygon

Parameters:
pId -
Returns:

getNumberOfPolygonsInBiggestLeaf

public int getNumberOfPolygonsInBiggestLeaf()
Debug method: helps to describe BSP tree by telling the number of polygons in the biggest leaf (this should not bee too big. 5 is a good number.)


setBiggestLeafInTree

public void setBiggestLeafInTree(BSPNode node)
Debug method: sets the biggest leaf so it can be easily found.


getPolygonIdByPoint3D

public int getPolygonIdByPoint3D(math.geom3d.Point3D point3D)
Parameters:
point3D -
Returns:
id of polygon on which is this point

getPolygonIdByLocation

public int getPolygonIdByLocation(Location location)
Gets the id of a polygon that contains this location

Parameters:
location -
Returns:
id of polygon or value < 0 if the is no such polygon

getPolygonPath

public List<INavMeshAtom> getPolygonPath(INavMeshAtom fromAtom,
                                         INavMeshAtom toAtom)
Gets a List of polygons on which the path should go.

Parameters:
from -
to -
Returns:

getPolygonPath

public List<INavMeshAtom> getPolygonPath(Location from,
                                         Location to)
Calls the method with the same name but polygons as arguments and returns result

Parameters:
from -
to -
Returns:

getPath

public List<ILocated> getPath(ILocated from,
                              ILocated to)
Computes and returns a path between two points anywhere on the map. If no such path is found, returns null;

Parameters:
from -
to -
Returns:

computePath

public IPathFuture<ILocated> computePath(ILocated from,
                                         ILocated to)
Computes and returns a path between two points anywhere on the map. If no such path is found, returns path of zero length;

Specified by:
computePath in interface IPathPlanner<ILocated>
Parameters:
from -
to -
Returns:

getLevelGeometry

public LevelGeometry getLevelGeometry()
Returns levelGeometry object

Returns:

getDistanceFromEdge

public double getDistanceFromEdge(Location location,
                                  javax.vecmath.Vector2d vector,
                                  double rayLength)
A simple implementation of NavMesh's 2D raycasting. Returns distance from the edge of navmesh in a direction from a location if the entrire ray is inside navmesh of there is no navmesh it returns 0;

Parameters:
location -
vector -
Returns:

getDistanceFromEdge

public double getDistanceFromEdge(Location location,
                                  javax.vecmath.Vector2d vector)
Returns distance of the location from the navmesh's edge in the given direction. If location is not not on navmesh, 0 is returned

Parameters:
location -
vector -
Returns:


Copyright © 2014 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.