00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 #ifndef ROADGEOM_HH
00028 #define ROADGEOM_HH
00029 
00030 #include "Geom.hh"
00031 
00032 
00033 class RoadGeom : public Geom
00034 {
00036   public: RoadGeom(Body *body, dSpaceID spaceId);
00037   
00039   public: virtual ~RoadGeom();
00040 
00042   public: void SetTrackSpacing(double spacing) {this->trackScale = spacing;}
00043 
00045   public: void SetProfileSpacing(double spacing) {this->profileScale = spacing;}
00046 
00050   public: int AddTrackPoint(GzVector pos);
00051 
00055   public: void AddProfilePoint(int index, double pz);
00056 
00060   public: void AddSign(GzVector pos, const char *text);
00061 
00063   private: void InitMesh();
00064 
00066   public: void UpdateMesh(GzVector pos);
00067 
00069   private: void UpdateNormals();
00070 
00072   private: GzVector SplineCR(double t, GzVector p0, GzVector p1,
00073                              GzVector p2, GzVector p3);
00074 
00076   private: GzVector SplineCRtan(double t, GzVector p0, GzVector p1,
00077                                 GzVector p2, GzVector p3);
00078 
00080   public: virtual void Render(RenderOptions *opt);
00081 
00083   private: void RenderSigns(RenderOptions *opt, RenderOptions listOpt);
00084 
00086   private: dTriMeshDataID tridata;
00087 
00089   private: dGeomID trimesh;
00090 
00092   private: int stepsX, stepsY;
00093 
00095   private: double scale;
00096 
00098   private: struct TrackPoint
00099   {
00100     
00101     GzVector pos;
00102     
00104     int profilePointCount, profilePointMaxCount;
00105     GzVector *profilePoints;
00106   };
00107   
00109   private: double trackScale, profileScale;
00110   private: int trackPointCount, trackPointMaxCount;
00111   private: TrackPoint *trackPoints;
00112 
00114   private: struct SignData
00115   {
00117     GzVector pos;
00118 
00120     char *text;
00121   };
00122 
00124   private: int signCount, signMaxCount;
00125   private: SignData *signs;
00126 
00128   private: int vertexCount, vertexMaxCount;
00129   private: dVector3 *vertices;
00130   private: GzVector *normals;
00131 
00133   private: int indexCount, indexMaxCount;
00134   private: int *indices;
00135 
00138   private: double patchSize;
00139 };
00140 
00141 #endif