Track::NearTrack Class Reference

An object which has an attachment point to an AI mesh. More...

#include <NearTrack.h>

Inheritance diagram for Track::NearTrack:

Engine::GameObjects::Car List of all members.

Public Types

 AS_VERTEX
 Attachted to a Track::PathVertex.
 AS_EDGE
 Attached to a Track::PathEdge.
 AS_UNKOWN
 Not correctly attached to anything.
enum  AttachSource { AS_VERTEX, AS_EDGE, AS_UNKOWN }
 The types of objects Track::NearTrack can attach to. More...

Public Member Functions

 NearTrack (const MeshFaces::Graph &graph, btVector3 position)
 Construct with an initial position.
virtual ~NearTrack ()
btScalar move_towards (btVector3 position)
 Move the attach point closer to a position.
btScalar jump_to (btVector3 position)
 Set the attach point to the closest point on the AI navigation mesh.
btVector3 get_position () const
 Return the position in world space.
MeshFaces::Graph::vertex_descriptor get_face_descriptor () const
 Return the face the position is on.
AttachSource get_object_type () const
 Return the type of object the point is attached to.
unsigned long int get_object_name () const
 Get the identifier for the object the point is attached to.
void scan_direction (btVector3 glob, btScalar *results) const
 Calculate statistics about potential movement in a given direction.

Protected Member Functions

void set_info ()
 Set m_object_coord m_object_name m_object_type, m_face_s/t from m_face.
void move_towards_recursive (btVector3 position)

Static Protected Member Functions

static btScalar face_u_interpolation (MeshFaces::FaceGraph face, btVector3 point)
 Find a u texture coordinate at a point on a face.

Protected Attributes

btVector3 m_object_coord
 Relative coordinates for edge or vertex attached to.
AttachSource m_object_type
 The type of object the Track::NearTrack is attached to.
unsigned long int m_object_name
btVector3 m_world_coord
 World coordinates.
MeshFaces::Graph::vertex_descriptor m_face
 AI mesh face attached to.
btScalar m_face_s
 Coordinates in the direction of m_face's fv1 -> fv2 edge.
btScalar m_face_t
 Coordinates in the direction of m_face's fv1 -> fv3 edge.
const MeshFaces::Graphm_graph
 The mesh we can navigate over.
std::set< MeshFaces::Graph::vertex_descriptor > examined
 The vertices examined in move_towards().
btScalar best_distance
 The lowest distance reached in move_towards().
MeshFaces::Graph::vertex_descriptor best_face
 The face with the lowest distance reached in move_towards().
btVector3 best_world_coords
 The world coordianates of the solution with the lowest distance reached by move_towards().

Detailed Description

An object which has an attachment point to an AI mesh.

Definition at line 37 of file NearTrack.h.


Member Enumeration Documentation

enum Track::NearTrack::AttachSource

The types of objects Track::NearTrack can attach to.

Enumerator:
AS_VERTEX  Attachted to a Track::PathVertex.
AS_EDGE  Attached to a Track::PathEdge.
AS_UNKOWN  Not correctly attached to anything.

Definition at line 85 of file NearTrack.h.


Constructor & Destructor Documentation

Track::NearTrack::NearTrack ( const MeshFaces::Graph graph,
btVector3  position 
)

Construct with an initial position.

Parameters:
graph The navigation grap to constrain too. Cannot be changed or deleted until the NearTrack is deleted.
position The nearest world space coordinates to the desired starting position.

Definition at line 20 of file NearTrack.cpp.

Track::NearTrack::~NearTrack (  )  [virtual]

Definition at line 26 of file NearTrack.cpp.


Member Function Documentation

btScalar Track::NearTrack::face_u_interpolation ( MeshFaces::FaceGraph  face,
btVector3  point 
) [static, protected]

Find a u texture coordinate at a point on a face.

The u texture coordinate is used for lap distance.

Parameters:
face The face to inspect.
point The point in global coordinates to inspect.
Returns:
Value of u texture coordinate at point, linearly interpolated across the face.

Definition at line 354 of file NearTrack.cpp.

MeshFaces::Graph::vertex_descriptor Track::NearTrack::get_face_descriptor (  )  const

Return the face the position is on.

Definition at line 148 of file NearTrack.cpp.

unsigned long int Track::NearTrack::get_object_name (  )  const

Get the identifier for the object the point is attached to.

Useful when combined with get_source_type.

Definition at line 158 of file NearTrack.cpp.

NearTrack::AttachSource Track::NearTrack::get_object_type (  )  const

Return the type of object the point is attached to.

Definition at line 153 of file NearTrack.cpp.

btVector3 Track::NearTrack::get_position (  )  const

Return the position in world space.

Definition at line 143 of file NearTrack.cpp.

btScalar Track::NearTrack::jump_to ( btVector3  position  ) 

Set the attach point to the closest point on the AI navigation mesh.

This is much slower than move_towards(btVector3). Use that if you can help it.

Time complexity is O(n), where n is the number of triangles in the ai navigation mesh.

Parameters:
position. The world coordinate to jump to.
Returns:
square of the distance between the provided position and the found point.

Definition at line 115 of file NearTrack.cpp.

btScalar Track::NearTrack::move_towards ( btVector3  position  ) 

Move the attach point closer to a position.

Requires an up to date AI mesh in the track.

The path taken will be continuous. It won't move to the nearest point if the nearest point is not on a reasonable path from the current location.

Parameters:
position The world coordinate to move towards.
Returns:
square of the distance between the provided position and the found point.

Definition at line 38 of file NearTrack.cpp.

void Track::NearTrack::move_towards_recursive ( btVector3  position  )  [protected]

Definition at line 55 of file NearTrack.cpp.

void Track::NearTrack::scan_direction ( btVector3  glob,
btScalar *  results 
) const

Calculate statistics about potential movement in a given direction.

Projections the direction of the given vector onto the current face, then finds the furthest edge in that direction. If the edge is shared, project the face vector onto the next face recursively. When the edge is not shared, the total navigable distance in that direction is returned.

Parameters:
glob global vector giving the direction to scan. The length of the vector is the maximum distance to scan.
results address of the first of 4 btScalars to store the calculated statistics:
  • The inverse of the navigable distance (1.0 / distance covered by recursive projections starting in the requested direction up to the requested length),
  • unsigned total angle (the total change in angle, but each change in angle is positive rather than depending on direction)
  • the total scaled lap distance (ranging from 1 when the full distance is available and it is the shortest path around the lap, to -1 for the direct opposite), and
  • the immediate differential lap distance (the rate of change in lap distance on the current face in the requested direction).
Each result is indexed by the SensorIndex enum.

Todo:
handle crossing very close to a vertex properly

Bug:
This happens way to often.

Definition at line 163 of file NearTrack.cpp.

void Track::NearTrack::set_info (  )  [protected]

Set m_object_coord m_object_name m_object_type, m_face_s/t from m_face.

Finds relavent information from the graph face.

Todo:
Set m_object_coord correctly. It would make it easier to move correctly when the object it is attached to is moved.

Definition at line 362 of file NearTrack.cpp.


Member Data Documentation

btScalar Track::NearTrack::best_distance [protected]

The lowest distance reached in move_towards().

Definition at line 168 of file NearTrack.h.

MeshFaces::Graph::vertex_descriptor Track::NearTrack::best_face [protected]

The face with the lowest distance reached in move_towards().

Definition at line 170 of file NearTrack.h.

btVector3 Track::NearTrack::best_world_coords [protected]

The world coordianates of the solution with the lowest distance reached by move_towards().

Definition at line 172 of file NearTrack.h.

std::set<MeshFaces::Graph::vertex_descriptor> Track::NearTrack::examined [protected]

The vertices examined in move_towards().

Definition at line 166 of file NearTrack.h.

MeshFaces::Graph::vertex_descriptor Track::NearTrack::m_face [protected]

AI mesh face attached to.

Will be invalid when the track changes.

Definition at line 150 of file NearTrack.h.

btScalar Track::NearTrack::m_face_s [protected]

Coordinates in the direction of m_face's fv1 -> fv2 edge.

Will be invalid when the track changes.

Definition at line 155 of file NearTrack.h.

btScalar Track::NearTrack::m_face_t [protected]

Coordinates in the direction of m_face's fv1 -> fv3 edge.

Will be invalid when the track changes.

Definition at line 160 of file NearTrack.h.

const MeshFaces::Graph& Track::NearTrack::m_graph [protected]

The mesh we can navigate over.

Definition at line 163 of file NearTrack.h.

btVector3 Track::NearTrack::m_object_coord [protected]

Relative coordinates for edge or vertex attached to.

For an edge, this is distorted to lie along the edge. The y coordinate for an edge is between 0 (start) and 1 (finish) of the edge. The x and z coordinates are used like the edge's meshes.

For a vertex, it is in the vertex's local space.

Definition at line 133 of file NearTrack.h.

unsigned long int Track::NearTrack::m_object_name [protected]

Definition at line 140 of file NearTrack.h.

AttachSource Track::NearTrack::m_object_type [protected]

The type of object the Track::NearTrack is attached to.

May Unkown if the relavent object is deleted from the track.

Definition at line 138 of file NearTrack.h.

btVector3 Track::NearTrack::m_world_coord [protected]

World coordinates.

May become outdated when the track changes.

Definition at line 145 of file NearTrack.h.


The documentation for this class was generated from the following files:
Get Racer at SourceForge.net. Fast, secure and Free Open Source software downloads

Generated at Mon Sep 6 00:41:18 2010 by Doxygen version 1.4.7 for Racer version svn335.