Track::PathEdge Class Reference

Information to store along the edges. More...

#include <PathEdge.h>

Inheritance diagram for Track::PathEdge:

Track::UniqueIdentifier Track::EditAssist::Selectable Track::AABBDrawable Track::Drawable Track::AABBBounded List of all members.

Public Member Functions

 PathEdge (const Theme &theme)
 PathEdge (std::istream &source, const Theme &theme)
virtual ~PathEdge ()
void update (std::size_t start_vertex_name, std::size_t finish_vertex_name, const Path *graph)
 Update various internal records.
void update ()
 Update various internal records.
btScalar get_length () const
 Get the last calculated length.
unsigned int get_number_of_repetions () const
 Get the last calculated number of repetitions of the segment needed to fit the curve well.
btTransform get_transform (btScalar position) const
 Get the transformation at a specific point along the arc.
const boost::shared_ptr< DrawableMeshget_graphics_mesh (std::size_t index) const
 Get a mesh to draw part of the arc.
virtual bool is_here (btVector3 start, btVector3 stop, btScalar radius) const
 Check if the object lies along a given line segment.
btScalar get_nearest_s (btVector3 start, btVector3 stop) const
 Get the nearest point along the curve to a line segment.
const EditAssist::ControlPointget_control_point_here (btVector3 start_pos, btVector3 stop_pos, btScalar radius) const
 Find a control point under a mouse cursor.
void draw_control_points () const
 Draw all ControlPoint objects adjusting this edge.
std::size_t get_start_vertex_name ()
 Get the name of the source vertex.
std::size_t get_finish_vertex_name ()
 Get the name of the target vertex.
void add_collision_faces (btTriangleMesh &shape) const
 Add the faces you can collide with to a shape.
void add_floor_faces (btTriangleMesh &shape) const
 Add the faces you can drive on to a shape.
void add_ai_faces (MeshFaces &mesh) const
 Add the faces the AI considers driving on to a mesh.
virtual AxisAlignedBoundingBox get_bounds () const
 Get the minimal bounding box for the graphic meshes.
virtual void draw () const
 Draw the object.
virtual void conditional_draw (const OcclusionTester &occlusion_tester) const
 Draw the parts of the edge on screen.
void draw_attachments () const
 Draw the attachments on the edge.
void make_cache () const
 Load meshes into graphics memory.
void insert_attachment (boost::shared_ptr< TrackAttachment > attachment)
 Put an attachment on the edge.
void remove_attachment (std::size_t attachment_name)
 Remove an attachment from the edge.
const std::vector< boost::shared_ptr<
TrackAttachment > > & 
get_attachments () const
 Get a list of attachments on the edge.
const TrackAttachmentget_attachment (std::size_t attachment_name) const
 Get an attachment on the edge by name.
void set_attachment (std::size_t attachment_name, const TrackAttachment &attachment)
 Modify an attachment on the edge by name.

Public Attributes

std::size_t segment_index
 The index of the segment in the Theme.
const Segmentsegment
 The segment to repeat to fill space along the edge.
PathEdgeEnd start
 Information about the connection to the starting vertex.
PathEdgeEnd finish
 Information about the connection to the ending vertex.
DrawableMesh::RenderMode render_mode
 The draw style of the meshes produced.

Protected Member Functions

void recreate_attachment_handles ()

Protected Attributes

const unsigned int file_version
const Themetheme
std::vector< boost::shared_ptr<
TrackAttachment > > 
m_attachments
std::vector< boost::shared_ptr<
EditAssist::TrackAttachmentHandle > > 
m_attachment_handles
btScalar length
unsigned int number_of_repetions
std::vector< boost::shared_ptr<
DrawableMesh > > 
meshes
const Pathpath
std::size_t start_vertex_index
std::size_t finish_vertex_index
AxisAlignedBoundingBox bounds
 the minimal axis aligned bounding box of the edge including handles.
AxisAlignedBoundingBox graphics_bounds
 The minimal axis aligned bounding box of the edge's graphical meshes.
MeshFaces m_nav_mesh
 The navigation mesh.
MeshFaces::Graph m_navigation_graph

Friends

std::ostream & operator<< (std::ostream &destination, const PathEdge &path_edge)
AxisAlignedBoundingBoxoperator|= (AxisAlignedBoundingBox &box, const PathEdge &path_edge)
 Expand an AxisAlignedBoundingBox minimally to contain a PathEdge with control points.

Detailed Description

Information to store along the edges.

Definition at line 44 of file PathEdge.h.


Constructor & Destructor Documentation

Track::PathEdge::PathEdge ( const Theme theme  ) 

Definition at line 22 of file PathEdge.cpp.

Track::PathEdge::PathEdge ( std::istream &  source,
const Theme theme 
)

Definition at line 34 of file PathEdge.cpp.

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

Definition at line 58 of file PathEdge.cpp.


Member Function Documentation

void Track::PathEdge::add_ai_faces ( MeshFaces mesh  )  const

Add the faces the AI considers driving on to a mesh.

Definition at line 389 of file PathEdge.cpp.

void Track::PathEdge::add_collision_faces ( btTriangleMesh &  shape  )  const

Add the faces you can collide with to a shape.

Definition at line 366 of file PathEdge.cpp.

void Track::PathEdge::add_floor_faces ( btTriangleMesh &  shape  )  const

Add the faces you can drive on to a shape.

Definition at line 378 of file PathEdge.cpp.

void Track::PathEdge::conditional_draw ( const OcclusionTester occlusion_tester  )  const [virtual]

Draw the parts of the edge on screen.

Efficently decide what to draw and draw it.

Parameters:
occlusion_tester The bounds of the visible area.

Todo:
Make Attachment an AABBDrawable, and include attachment in graphics_bounds. Then attachments will not be unnecessarily drawn. Requires monitoring changes in attachments.

Reimplemented from Track::AABBDrawable.

Definition at line 411 of file PathEdge.cpp.

void Track::PathEdge::draw (  )  const [virtual]

Draw the object.

Called indirectly by draw(const OcclusionTester &) const when it is on the screen, but can also be called manually if view bounds are not known.

Implements Track::Drawable.

Definition at line 399 of file PathEdge.cpp.

void Track::PathEdge::draw_attachments (  )  const

Draw the attachments on the edge.

Definition at line 441 of file PathEdge.cpp.

void Track::PathEdge::draw_control_points (  )  const

Draw all ControlPoint objects adjusting this edge.

See also:
void Track::EditAssist::ControlPoint::draw() const

Definition at line 350 of file PathEdge.cpp.

const TrackAttachment & Track::PathEdge::get_attachment ( std::size_t  attachment_name  )  const

Get an attachment on the edge by name.

Precondition: attachment added with given name.

Definition at line 496 of file PathEdge.cpp.

const std::vector< boost::shared_ptr< TrackAttachment > > & Track::PathEdge::get_attachments (  )  const

Get a list of attachments on the edge.

Definition at line 557 of file PathEdge.cpp.

AxisAlignedBoundingBox Track::PathEdge::get_bounds (  )  const [virtual]

Get the minimal bounding box for the graphic meshes.

Implements Track::AABBBounded.

Definition at line 394 of file PathEdge.cpp.

const EditAssist::ControlPoint * Track::PathEdge::get_control_point_here ( btVector3  start_pos,
btVector3  stop_pos,
btScalar  radius 
) const

Find a control point under a mouse cursor.

Returns:
0 if none near control point, otherwise an apropriate edge handle.

Definition at line 323 of file PathEdge.cpp.

std::size_t Track::PathEdge::get_finish_vertex_name (  ) 

Get the name of the target vertex.

The source and target vertices must have been set with update(const PathVertex & source, const PathVertex & target).

Definition at line 361 of file PathEdge.cpp.

const boost::shared_ptr< DrawableMesh > Track::PathEdge::get_graphics_mesh ( std::size_t  index  )  const

Get a mesh to draw part of the arc.

The number of meshes is the number returned by get_number_of_repetitions(). The meshes are only created when update() is called.

Parameters:
index The 0 based index specifying which mesh to get. It is an error to use a higher index than the value returned by get_number_of_repetitions().
Todo:
write similar functions for the other meshes.

Definition at line 225 of file PathEdge.cpp.

btScalar Track::PathEdge::get_length (  )  const

Get the last calculated length.

Use calculate_length() instead if the Edge or the vertices it connects have been modified since the last time it was called. If get_length is called before calculate_length, the result is undefined.

Returns:
the last value calculated by calculate_length().

Definition at line 166 of file PathEdge.cpp.

float Track::PathEdge::get_nearest_s ( btVector3  start,
btVector3  stop 
) const

Get the nearest point along the curve to a line segment.

Parameters:
start one end of the line segment.
stop the other end of the line segment.
Returns:
scalar s between 0 and 1 such that get_transform(s).origin() is the closest to the line segment for any value of s between 0 and 1.

Todo:
should share more code with is_here. Calculate positions in update?

Todo:
we only need the position, not the full transformation.

Definition at line 273 of file PathEdge.cpp.

unsigned int Track::PathEdge::get_number_of_repetions (  )  const

Get the last calculated number of repetitions of the segment needed to fit the curve well.

Call calculate_length() to update the value returned if the segment or curve's path has changed since the last call to calculate_length(). If calculate_length() has never been called, the returned value is undefined.

Definition at line 171 of file PathEdge.cpp.

std::size_t Track::PathEdge::get_start_vertex_name (  ) 

Get the name of the source vertex.

The source and target vertices must have been set with update(const PathVertex & source, const PathVertex & target).

Definition at line 356 of file PathEdge.cpp.

btTransform Track::PathEdge::get_transform ( btScalar  position  )  const

Get the transformation at a specific point along the arc.

update() must have been called previously to set the source and target PathVertex.

Parameters:
position point along the length of the arc from 0 (start) to 1 (finish).
Returns:
transformation to apply to a vertex along the path.

Todo:
improve up direction.

Definition at line 176 of file PathEdge.cpp.

void Track::PathEdge::insert_attachment ( boost::shared_ptr< TrackAttachment attachment  ) 

Put an attachment on the edge.

Precondition: Attachment removed. Postcondition: Attachment added.

Definition at line 475 of file PathEdge.cpp.

bool Track::PathEdge::is_here ( btVector3  start,
btVector3  stop,
btScalar  radius 
) const [virtual]

Check if the object lies along a given line segment.

Parameters:
start The start position of the line in world space.
stop The end position of the line in world space
radius to consider points near the line
Returns:
true if it is on or near the line, false otherwise.

Implements Track::EditAssist::Selectable.

Definition at line 231 of file PathEdge.cpp.

void Track::PathEdge::make_cache (  )  const

Load meshes into graphics memory.

Definition at line 466 of file PathEdge.cpp.

void Track::PathEdge::recreate_attachment_handles (  )  [protected]

Definition at line 534 of file PathEdge.cpp.

void Track::PathEdge::remove_attachment ( std::size_t  attachment_name  ) 

Remove an attachment from the edge.

Precondition: aattachment added with given name. Postcondition: attachment removed.

Definition at line 481 of file PathEdge.cpp.

void Track::PathEdge::set_attachment ( std::size_t  attachment_name,
const TrackAttachment attachment 
)

Modify an attachment on the edge by name.

Precondition: attachment added with given name.

Definition at line 509 of file PathEdge.cpp.

void Track::PathEdge::update (  ) 

Update various internal records.

Behaves like update(const PathVertex & source, const PathVertex & target), except it uses the reuses the same source and target previously passed in. The other version must have been used first to set source and target.

Definition at line 87 of file PathEdge.cpp.

void Track::PathEdge::update ( std::size_t  start_vertex_name,
std::size_t  finish_vertex_name,
const Path graph 
)

Update various internal records.

You should call this after changing any related geometry: the vertices at the ends of the arc, the gradient in the PathEdgeEnds, or the Segment that runs along the arc. After this has been called, the length, repetitions, and nav mesh, and graphical meshes will be up to date. The objects referenced by the parameters must not be freed when this object is still being used, unless this function is called again.

Parameters:
start_vertex_name The name of the vertex at the start of the edge.
finish_vertex_name The name of the vertex at the finish end of the edge.
graph The Track::Path::Graph where this edge and the vertices are.

Definition at line 77 of file PathEdge.cpp.


Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  destination,
const PathEdge path_edge 
) [friend]

Definition at line 562 of file PathEdge.cpp.

AxisAlignedBoundingBox& operator|= ( AxisAlignedBoundingBox box,
const PathEdge path_edge 
) [friend]

Expand an AxisAlignedBoundingBox minimally to contain a PathEdge with control points.

Definition at line 573 of file PathEdge.cpp.


Member Data Documentation

AxisAlignedBoundingBox Track::PathEdge::bounds [protected]

the minimal axis aligned bounding box of the edge including handles.

Definition at line 225 of file PathEdge.h.

const unsigned int Track::PathEdge::file_version [protected]

Definition at line 58 of file PathEdge.h.

PathEdgeEnd Track::PathEdge::finish

Information about the connection to the ending vertex.

Definition at line 69 of file PathEdge.h.

std::size_t Track::PathEdge::finish_vertex_index [protected]

Definition at line 223 of file PathEdge.h.

AxisAlignedBoundingBox Track::PathEdge::graphics_bounds [protected]

The minimal axis aligned bounding box of the edge's graphical meshes.

Definition at line 227 of file PathEdge.h.

btScalar Track::PathEdge::length [protected]

Definition at line 218 of file PathEdge.h.

std::vector<boost::shared_ptr<EditAssist::TrackAttachmentHandle> > Track::PathEdge::m_attachment_handles [protected]

Definition at line 217 of file PathEdge.h.

std::vector<boost::shared_ptr<TrackAttachment> > Track::PathEdge::m_attachments [protected]

Definition at line 216 of file PathEdge.h.

MeshFaces Track::PathEdge::m_nav_mesh [protected]

The navigation mesh.

Definition at line 229 of file PathEdge.h.

MeshFaces::Graph Track::PathEdge::m_navigation_graph [protected]

Definition at line 230 of file PathEdge.h.

std::vector<boost::shared_ptr<DrawableMesh> > Track::PathEdge::meshes [protected]

Definition at line 220 of file PathEdge.h.

unsigned int Track::PathEdge::number_of_repetions [protected]

Definition at line 219 of file PathEdge.h.

const Path* Track::PathEdge::path [protected]

Definition at line 221 of file PathEdge.h.

DrawableMesh::RenderMode Track::PathEdge::render_mode

The draw style of the meshes produced.

Should be set before update is called. Defaults to RM_SOLID.

Definition at line 75 of file PathEdge.h.

const Segment* Track::PathEdge::segment

The segment to repeat to fill space along the edge.

Definition at line 64 of file PathEdge.h.

std::size_t Track::PathEdge::segment_index

The index of the segment in the Theme.

Definition at line 62 of file PathEdge.h.

PathEdgeEnd Track::PathEdge::start

Information about the connection to the starting vertex.

Definition at line 67 of file PathEdge.h.

std::size_t Track::PathEdge::start_vertex_index [protected]

Definition at line 222 of file PathEdge.h.

const Theme& Track::PathEdge::theme [protected]

Definition at line 59 of file PathEdge.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.