PathEdge.h

Go to the documentation of this file.
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_EDGE_H
00013 #define LIBTRACK_PATH_PATH_EDGE_H
00014 
00015 #include <ostream>
00016 #include <istream>
00017 #include <vector>
00018 
00019 #include <boost/shared_ptr.hpp>
00020 
00021 #include <LinearMath/btScalar.h>
00022 #include <LinearMath/btTransform.h>
00023 #include <BulletCollision/CollisionShapes/btTriangleMesh.h>
00024 
00025 #include "../UniqueIdentifier.h"
00026 #include "../edit_base/Selectable.h"
00027 #include "../Segment.h"
00028 #include "../Mesh/DrawableMesh.h"
00029 
00030 #include "PathEdgeEnd.h"
00031 #include "PathVertex.h"
00032 #include "../AxisAlignedBoundingBox.h"
00033 #include "../AABBDrawable.h"
00034 #include "../TrackAttachment.h"
00035 #include "../edit_base/TrackAttachmentHandle.h"
00036 
00037 namespace Track
00038 {
00039 
00040 class Path;
00041 
00044 class PathEdge
00045     :   public UniqueIdentifier
00046     ,   public EditAssist::Selectable
00047     ,   public AABBDrawable
00048 {
00049     friend std::ostream & operator<<(std::ostream & destination,
00050                                      const PathEdge & path_edge);
00051     friend AxisAlignedBoundingBox & operator|=(AxisAlignedBoundingBox & box,
00052                                                const PathEdge & path_edge);
00053 public:
00054     PathEdge(const Theme & theme);
00055     PathEdge(std::istream & source, const Theme & theme);
00056     virtual ~PathEdge();
00057 protected:
00058     const unsigned int file_version;
00059     const Theme & theme;
00060 public:
00062     std::size_t segment_index;
00064     const Segment * segment;
00065     
00067     PathEdgeEnd start;
00069     PathEdgeEnd finish;
00070     
00075     DrawableMesh::RenderMode render_mode;
00076     
00078     
00095     void update(std::size_t start_vertex_name,
00096                 std::size_t finish_vertex_name,
00097                 const Path * graph);
00098     
00105     void update();
00106     
00113     btScalar get_length() const;
00114     
00121     unsigned int get_number_of_repetions() const;
00122     
00129     btTransform get_transform(btScalar position) const;
00130     
00139     const boost::shared_ptr<DrawableMesh> get_graphics_mesh(std::size_t index) const;
00140     
00141     virtual bool is_here(btVector3 start, btVector3 stop, btScalar radius) const;
00142     
00149     btScalar get_nearest_s(btVector3 start, btVector3 stop) const;
00150     
00155     const EditAssist::ControlPoint * get_control_point_here(btVector3 start_pos, btVector3 stop_pos, btScalar radius) const;
00156     
00160     void draw_control_points() const;
00161     
00166     std::size_t get_start_vertex_name();
00167     
00172     std::size_t get_finish_vertex_name();
00173     
00175     void add_collision_faces(btTriangleMesh & shape) const;
00177     void add_floor_faces(btTriangleMesh & shape) const;
00179     void add_ai_faces(MeshFaces & mesh) const;
00180     
00182     virtual AxisAlignedBoundingBox get_bounds() const;
00183     virtual void draw() const;
00188     virtual void conditional_draw(const OcclusionTester & occlusion_tester) const;
00190     void draw_attachments() const;
00192     void make_cache() const;
00193     
00198     void insert_attachment(boost::shared_ptr<TrackAttachment> attachment);
00203     void remove_attachment(std::size_t attachment_name);
00206     const std::vector<boost::shared_ptr<TrackAttachment> > & get_attachments() const;
00210     const TrackAttachment & get_attachment(std::size_t attachment_name) const;
00214     void set_attachment(std::size_t attachment_name, const TrackAttachment & attachment);
00215 protected:
00216     std::vector<boost::shared_ptr<TrackAttachment> > m_attachments;
00217     std::vector<boost::shared_ptr<EditAssist::TrackAttachmentHandle> > m_attachment_handles;
00218     btScalar length;
00219     unsigned int number_of_repetions;
00220     std::vector<boost::shared_ptr<DrawableMesh> > meshes;
00221     const Path * path;
00222     std::size_t start_vertex_index;
00223     std::size_t finish_vertex_index;
00225     AxisAlignedBoundingBox bounds;
00227     AxisAlignedBoundingBox graphics_bounds;
00229     MeshFaces m_nav_mesh;
00230     MeshFaces::Graph m_navigation_graph;
00231     
00232     void recreate_attachment_handles();
00233 };
00234 
00235 std::ostream & operator<<(std::ostream & destination,
00236                           const PathEdge & path_edge);
00237 
00239 AxisAlignedBoundingBox & operator|=(AxisAlignedBoundingBox & box,
00240                                     const PathEdge & path_edge);
00241 
00242 }
00243 
00244 #endif //LIBTRACK_PATH_PATH_EDGE_H

Get Racer at SourceForge.net. Fast, secure and Free Open Source software downloads

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