mod_base_craft.hh

Go to the documentation of this file.
00001 /*
00008  * LEGAL:   COPYRIGHT (C) 2004 JIM E. BROOKS
00009  *          THIS SOURCE CODE IS RELEASED UNDER THE TERMS
00010  *          OF THE GNU GENERAL PUBLIC LICENSE VERSION 2 (GPL 2).
00011  *****************************************************************************/
00012 
00013 #if COMPILING_MODULE
00014 #ifndef MOD_BASE_CRAFT_HH
00015 #define MOD_BASE_CRAFT_HH 1
00016 
00017 #include "mod_base_dyna.hh"
00018 
00019 namespace mod_base {
00020 
00021 class ChasePlane;
00022 
00033 class Craft : public Dyna
00034 {
00035 
00036 typedef Dyna Parent;
00037 friend class Part;
00038 
00039 protected:
00041     struct ListenerAnimate : public Event<>::ListenerFunctor
00042     {
00043         ListenerAnimate( SharedPtr<Craft> craft ) : mCraft(craft) { }
00044         void operator()( Void nothing );
00045         SharedPtr<Craft> mCraft;
00046     };
00047 
00048 //-----------------
00049 // Object interface:
00050 private:                        Craft( shptr<Graph> graph );  // dummy Craft
00051 public:                         Craft( SharedPtr<Graph> graph, const WorldVertex& pos );
00052 public: virtual                 ~Craft();
00053 public: virtual bool            Reproducible( void ) { return false; }
00054 public: virtual const string    GetName( void ) { return string("Craft"); }
00055 public: virtual void            Draw( void );
00056 public: virtual void            SetPosition( const WorldVertex& position );
00057 
00058 //--------------------------
00059 // Craft-specific interface:
00060 public: CLASS_METHOD SharedPtr<Craft> MakeDummyCraft( void );
00061 public: virtual void            Reset( void );
00062 public: virtual bool            IfEyeCraft( void ) { return false; }
00063 
00064 // Control:
00065 public: virtual void            EnablePhysics( const bool enable );
00066 public: virtual void            SetThrottle( const fp throttle );
00067 public: virtual void            IncThrottle( const fp inc );
00068 public: virtual fp              GetThrottle( void ) { return mThrottle; }
00069 public: virtual void            SetStep( const fp step ) { mStep = step; }  // translation increment
00070 public: virtual fp              GetStep( void ) { return mStep; }           // which controls speed
00071 public: virtual void            SetAutoStep( int autoStep );  // {-1,+1} or 0 to disable
00072 public: virtual void            SetAutoRotate( uint axis, Radian radian );
00073 
00074 // Physics:
00075 public: virtual Physics&        GetPhysics( void ) { return mPhysics; }
00076 public: virtual fp              GetSpeedMach( void );
00077 public: virtual fp              GetMaxMach( void );
00078 public: virtual void            SetSpeedMach( const fp mach );
00079 public: virtual bool            IfStall( void );
00080 
00081 // Chase-plane (EyeCraft redefines as NOPs):
00082 public: virtual void            EnableChasePlane( const bool enable = true );
00083 public: virtual void            SyncChasePlane( void );
00084 public: virtual void            RotateChasePlane( uint axis, Radian rad );
00085 public: virtual void            TranslateChasePlane( uint axis, fp inc );
00086 public: virtual void            ResetChasePlane( void );
00087 
00088 // ----------
00089 // Animation:
00090 protected:
00091 protected:  virtual void        Animate( void );        // overridden by EyeCraft
00092 protected:  virtual void        AnimateStall( void );   // overridden by EyeCraft
00093 private:    void                AnimateAutoStep( void );
00094 private:    void                AnimateAutoRotate( void );
00095 
00096 protected:
00100     class Part
00101     {
00102     friend class Craft;
00103     public:
00104                 Part( Craft& craft, const string& partitionName, const Degree degreeMin, const Degree degreeMax );
00105         void    Enable( const bool enable = true );
00106         bool    IfEnabled( void ) const;
00107 
00108     public:
00109         bool                        mEnabled;
00110         Degree                      mDegree;
00111         const Degree                mDegreeMin;
00112         const Degree                mDegreeMax;
00113         const PartitionNode::Ptr    mPartitionNode;
00114         const Node::Ptr             mParentNode;
00115         const TransformNode::Ptr    mTransformNode;
00116     };
00117 
00118 protected:  PartitionNode::Ptr      FindPartitionNode( const string& partitionName );
00119 protected:  TransformNode::Ptr      FindTransformNode( const string& partitionName );
00120 
00121 protected:
00122     // shptr0 is necessary for dummy craft.
00123     shptr0<ListenerAnimate> mListenerAnimate;   
00124     SharedPtr0<ChasePlane>      mChasePlane;
00125     fp                      mThrottle;          
00126     fp                      mStep;              
00127     int                     mStepDir;           
00128     int                     mAutoStep;          
00129     uint                    mAutoRotateAxis;    
00130     Radian                  mAutoRotateRadian;
00131     Physics                 mPhysics;           
00132     fp                      mStallDeg;          
00133 
00134 public:
00135      
00136 };
00137 
00138 } // namespace mod_base
00139 
00140 #endif // MOD_BASE_CRAFT_HH
00141 #endif // COMPILING_MODULE
Palomino 3D Engine documents generated by doxygen 1.5.3 on Fri Nov 23 11:26:12 2007