Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

path.h

Go to the documentation of this file.
00001 #ifndef __PATH_H
00002 #define __PATH_H
00003 
00004 // path flags
00005 #define  PATH_LEVEL            (1<<0) // path is relative to (0,0) of level
00006 #define  PATH_LOOPING          (1<<1) // looping (last pt = 1st pt)
00007 
00008 // path endpoint flags
00009 #define  PATHEND_RAND_SELECT   (1<<0) // select random connection
00010 #define  PATHEND_BOUNCE        (1<<1) // bounce back in other direction
00011 
00012 // path endpoint identification
00013 #define  AT_NONE   0
00014 #define  AT_BEG    1
00015 #define  AT_END    2
00016 
00017 // convenient bundle for path interactions
00018 struct TraverseDetails;
00019 class Object;
00020 
00021 struct PathTableRow
00022 {
00023   float d;       // distance along path
00024   float x, y;
00025 };
00026 
00027 typedef float PathDist;
00028 
00029 struct PathMark
00030 {
00031   int   pt;    // pt index that the mark annotates.
00032   int   id;    // bus mark signal #, or -1 if speed recommendation
00033   float speed; // recommended speed at path point (if id is -1)
00034 };
00035 
00036 class Path // path information
00037 {
00038 private:
00039   string name;          
00040   int id;               
00041   int flags;            
00042   int num_pts;
00043   int num_dists;
00044   int num_marks;
00045   Path **pts;
00046   Path **dists;
00047   PathMark *marks;      
00048   int end_flags;        
00049   int beg_flags;        
00050   int num_ptsdists;
00051   int path_flags;
00052   int table_size;
00053   PathTableRow* table;
00054   // Recommended paths:
00055   // If PATHEND_RAND_SELECT isn't on, then recommendations
00056   // are suggested to the path traverser when it reaches the
00057   // endpoint. The traverser can accept the recommendation,
00058   // or it can ignore it, and choose another path.
00059   // calculated
00060   float path_length; 
00061   int num_end_cxs;      
00062   int num_beg_cxs;      
00063   Path **end_cxs;       
00064   Path **beg_cxs;       
00065   Path *end_rec;        
00066   Path *beg_rec;        
00068 public:
00069   Path( ifstream *f, int _id );         
00070   ~Path(void);
00071   // converts d to (x,y) coordinates
00072   // * d assumed to be in range [0,maxlength)
00073   //
00074   //      d  ---.______,--> x
00075   //            /     |---> y
00076   //      i  --'      `---> i
00077   void DtoXY( TraverseDetails* );
00078   // corrects a distance value "d"
00079   // into range [0,maxlength)
00080   void CorrectD( float* d );
00081   // Calculate a new "d" for a traverser,
00082   // stopping for end points.
00083   //
00084   //      d  ---.______,--> d
00085   //            /     |---> reminder
00086   //      dd --'      `---> end
00087   //
00088   // Returns true if attempting to go off an end.
00089   bool Traverse( TraverseDetails* );
00090   // Flip a traverser on a looping path's end.
00091   // Remainder -> dd.
00092   //
00093   //       end ---.______,--> end         (flipped)
00094   //              /     |---> d           (0 or path_length)
00095   //  reminder -'      `---> dd          (loaded w/ reminder)
00096   //                     `--> reminder   (zero'ed)
00097   void PerformLoop( TraverseDetails* );
00098   // Bounce a traverser, if bouncing flag present.
00099   // Remainder -> dd.
00100   //
00101   //       end ---.______,--> dd          (loaded w/ reminder)
00102   //  reminder --'      `--> reminder   (zero'ed)
00103   void PerformBounce( TraverseDetails* );
00104   // Snap a traverser to an end.
00105   // Remainder -> dd.
00106   //
00107   //      x ---._____,---> end         (AT_BEG or AT_END)
00108   //      y ---'     |---> i           (0 or table_size-1)
00109   //                 |---> d           (0 or path_length)
00110   //                 `---> dd          (loaded w/ reminder)
00111   //                  `--> reminder   (zero'ed)
00112   void SnapToEnd( TraverseDetails* );
00113   //TODO find implementation of that method
00114   void MoveTraverser(Object *obj, float speed);
00115   int GetNumEndCXS();
00116   int GetNumBegCXS();
00117   void SetEndCXS( int indx, Path *end_cxs_val );
00118   Path *GetEndCXS( int indx );
00119   void SetBegCXS( int indx, Path *beg_cxs_val );
00120   Path *GetBegCXS( int indx );
00121   void SetEndREC( Path *_end_rec );
00122   Path *GetEndREC();
00123   void SetBegREC( Path *_end_rec );
00124   Path *GetBegREC();
00125 };
00126 
00127 class TraverseDetails
00128 {
00129 private: 
00130   Path* path;           
00131   int table_index;
00132   int i;                
00133   double d;             
00134   float reminder;       
00135   float x, y;           
00136   int end;              
00137   float dd;             
00138 public:  
00139   TraverseDetails( Path* _path );
00140   int GetI();
00141   void SetI( int _i );
00142   double GetD();
00143   void SetD( double _d );
00144   float GetReminder();
00145   void SetReminder( float _der );
00146   float GetX();
00147   void SetX( float _x );
00148   float GetY();
00149   void SetY( float _y );
00150   float GetDD();
00151   void SetDD( float _dd );
00152   int GetEnd();
00153   void SetEnd( int _end );
00154 };
00155 
00156 #endif // __PATH_H

Generated on Sun Mar 2 18:50:27 2003 for eounicorn by doxygen1.3-rc3