00001 00005 /* Copyright © 2009, 2010 James Legg. 00006 This program is free software: you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation, either version 3 of the License, or 00009 (at your option) any later version. 00010 */ 00011 00012 #ifndef LIBTRACK_PATH_PATH_H_ 00013 #define LIBTRACK_PATH_PATH_H_ 00014 00015 #include <istream> 00016 #include <ostream> 00017 00018 /* gcc >= 4.3 Depreciates hash_set & hash_map, causing warnings to be emited 00019 * when including boost graph library headers. 00020 * We don't need the hash-based storage selectors anyway, so turn them off. 00021 */ 00022 #define BOOST_NO_HASH 00023 #include <boost/graph/adjacency_list.hpp> 00024 #undef BOOST_NO_HASH 00025 00026 #include <LinearMath/btScalar.h> 00027 #include <BulletCollision/CollisionShapes/btTriangleMesh.h> 00028 00029 #include "../Theme.h" 00030 #include "../AxisAlignedBoundingBox.h" 00031 #include "../Drawable.h" 00032 00033 #include "PathEdge.h" 00034 #include "PathVertex.h" 00035 00036 namespace Track 00037 { 00038 00039 class Track; 00040 00043 class Path 00044 : public Drawable 00045 , public AABBBounded 00046 { 00047 friend std::ostream & operator<<(std::ostream & destination, 00048 const Path & path); 00049 public: 00051 Path(std::istream & source, const Theme & theme, const Track * track, bool editor = false); 00053 Path(const Theme & theme, const Track * track, bool editor = false); 00054 virtual ~Path(); 00055 00057 typedef boost::adjacency_list <boost::vecS, boost::vecS, 00058 boost::bidirectionalS, 00059 PathVertex, PathEdge> Graph; 00060 Graph graph; 00061 00068 AxisAlignedBoundingBox get_bounding_box() const; 00069 00071 PathVertex & get_node(const std::size_t index); 00073 const PathVertex & get_node(const std::size_t index) const; 00074 00076 Path::Graph::vertex_descriptor get_node_descriptor(const std::size_t index); 00078 const Path::Graph::vertex_descriptor get_node_descriptor(const std::size_t index) const; 00079 00080 00082 PathEdge & get_edge(const std::size_t index); 00084 const PathEdge & get_edge(const std::size_t index) const; 00085 00087 Path::Graph::edge_descriptor get_edge_descriptor(const std::size_t index); 00089 const Path::Graph::edge_descriptor get_edge_descriptor(const std::size_t index) const; 00090 00096 void set_handle_lengths(btScalar handle_length); 00097 00104 void update_connected_edges(Path::Graph::vertex_descriptor vertex_descriptor); 00105 00108 const EditAssist::SegmentConnectionHandle *get_nearest_segment_connection_handle(btVector3 position) const; 00109 00114 const EditAssist::SegmentConnectionHandle *get_nearest_segment_connection_handle(btVector3 position, btVector3 normal) const; 00115 00117 bool editor; 00118 00120 void add_collision_faces(btTriangleMesh & shape) const; 00122 void add_floor_faces(btTriangleMesh & shape) const; 00124 void add_ai_faces(MeshFaces & mesh) const; 00125 00131 unsigned long int get_starting_edge() const; 00132 00134 void set_starting_edge(unsigned long int new_edge_name); 00135 00141 void find_start_plane(btVector3 & normal, btScalar & distance) const; 00143 btVector3 find_start_position() const; 00144 00145 // for Track::Drawable. 00146 virtual void draw() const; 00147 virtual void conditional_draw(const OcclusionTester & occlusion_tester) const; 00148 // for AABBBounded. 00149 virtual AxisAlignedBoundingBox get_bounds() const; 00150 private: 00151 const unsigned int file_version; 00152 const Theme & theme; 00153 Path::Graph::vertex_descriptor get_node_descriptor_internal(const std::size_t index) const; 00154 Path::Graph::edge_descriptor get_edge_descriptor_internal(const std::size_t index) const; 00156 unsigned long int starting_edge; 00157 }; 00158 00159 std::ostream & operator<<(std::ostream & destination, 00160 const Path & path); 00161 00162 } 00163 00164 #endif // LIBTRACK_PATH_PATH_H_
Generated at Mon Sep 6 00:41:12 2010 by Doxygen version 1.4.7 for Racer version svn335.