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_VERTEX_H 00013 #define LIBTRACK_PATH_PATH_VERTEX_H 00014 00015 #include <ostream> 00016 #include <istream> 00017 00018 #include <LinearMath/btVector3.h> 00019 #include <LinearMath/btQuaternion.h> 00020 #include <BulletCollision/CollisionShapes/btTriangleMesh.h> 00021 00022 #include "../UniqueIdentifier.h" 00023 #include "../Segment.h" 00024 #include "../edit_base/Dragable.h" 00025 #include "../Theme.h" 00026 #include "../edit_base/VertexRotationHandle.h" 00027 #include "../edit_base/SegmentConnectionHandle.h" 00028 00029 #include "../AxisAlignedBoundingBox.h" 00030 #include "../AABBDrawable.h" 00031 00032 namespace Track 00033 { 00034 00035 class Track; 00036 00039 class PathVertex 00040 : public UniqueIdentifier 00041 , public EditAssist::Dragable 00042 , public AABBDrawable 00043 { 00044 friend std::ostream & operator<<(std::ostream & destination, 00045 const PathVertex & path_vertex); 00046 friend AxisAlignedBoundingBox & operator|=(AxisAlignedBoundingBox & box, 00047 const PathVertex & path_vertex); 00048 public: 00054 PathVertex(); 00055 PathVertex(const Track * track); 00056 PathVertex(std::istream & source, const Theme & theme, const Track * track); 00057 virtual ~PathVertex(); 00058 00060 const btVector3 & get_position() const; 00061 00068 btVector3 get_position(std::size_t index) const; 00069 00070 void set_position(const btVector3 & position); 00071 00075 const btVector3 & get_gradient() const; 00076 00081 btVector3 get_gradient(std::size_t index) const; 00082 00086 const btVector3 & get_up() const; 00087 00092 btVector3 get_up(std::size_t index) const; 00093 00098 void set_angle(btQuaternion angle); 00099 00103 const btQuaternion & get_angle() const; 00104 00109 btQuaternion get_angle(std::size_t index) const; 00110 00111 std::size_t get_segment_index() const; 00112 00113 void set_segment(std::size_t new_segment_index, const Segment * new_segment); 00114 00115 const Segment * get_segment() const; 00116 00117 // Implement virtual functions from Selectable. 00118 virtual bool is_here(btVector3 start, btVector3 stop, btScalar radius) const; 00119 00125 virtual boost::shared_ptr<Document::DocumentDelta> make_delta(btVector3 new_position) const; 00126 00135 const EditAssist::ControlPoint * get_control_point_here(btVector3 start, btVector3 stop, btScalar radius) const; 00136 00140 void draw_control_points() const; 00141 00143 void set_handle_lengths(btScalar handle_length); 00144 00145 const std::vector<boost::shared_ptr<EditAssist::SegmentConnectionHandle> > & get_connection_handles() const; 00146 00147 void set_track(const Track * track); 00148 00150 void add_collision_faces(btTriangleMesh & shape) const; 00152 void add_floor_faces(btTriangleMesh & shape) const; 00154 void add_ai_faces(MeshFaces & mesh) const; 00155 00156 // from AABBBounded, to make class a not an abstract AABBDrawable. 00157 virtual AxisAlignedBoundingBox get_bounds() const; 00158 // from Drawable, to make class a not an abstract AABBDrawable. 00159 virtual void draw() const; 00160 protected: 00161 unsigned int file_version; 00163 btVector3 position; 00165 const Segment * segment; 00166 00168 std::size_t segment_index; 00170 btVector3 gradient; 00172 btVector3 up; 00174 btQuaternion angle; 00175 00177 std::vector<btQuaternion> connection_angles; 00178 00180 EditAssist::VertexRotationHandle up_handle; 00182 EditAssist::VertexRotationHandle forward_handle; 00183 00184 std::vector<boost::shared_ptr<EditAssist::SegmentConnectionHandle> > connection_handles; 00185 00186 const Track * track; 00187 00189 AxisAlignedBoundingBox m_bounds; 00191 btTransform m_transform; 00192 00194 MeshFaces m_nav_mesh; 00195 MeshFaces::Graph m_navigation_graph; 00196 00200 void calculate_bounds(); 00201 00203 void update_handles(); 00204 }; 00205 00206 std::ostream & operator<<(std::ostream & destination, 00207 const PathVertex & path_vertex); 00208 00210 AxisAlignedBoundingBox & operator|=(AxisAlignedBoundingBox & box, 00211 const PathVertex & path_vertex); 00212 00213 } 00214 00215 00216 #endif // LIBTRACK_PATH_PATH_VERTEX_H
Generated at Mon Sep 6 00:41:12 2010 by Doxygen version 1.4.7 for Racer version svn335.