Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

collide.H

Go to the documentation of this file.
00001 #ifndef COLLIDE_H_IS_INCLUDED
00002 #define COLLIDE_H_IS_INCLUDED
00003 
00004 #include "sps/sps.H"
00005 #include "disp/view.H"
00006 #include "disp/gel.H"
00007 #include "disp/base_collide.H"
00008 #include "std/stop_watch.H"
00009 
00010 /*****************************************************************
00011  * Collide:
00012  *
00013  *      Animates a camera to Cruise around a object
00014  *****************************************************************/
00015 
00016 class Collide : public BaseCollide {
00017  public :
00018    virtual ~Collide() {}
00019                          
00020    Collide(double s,int h,double r,double m) : BaseCollide() {
00021       assert(_instance == 0);
00022       _instance = this;
00023       _size = s;
00024       _height = h;
00025       _regularity = r;
00026       _min_dist = m; 
00027       _objs = 0;
00028 
00029       _BSphere = new BMESH;
00030       _BSphere->Sphere(_BSphere->new_patch());
00031       _BSphere->transform(Wtransf::scaling(_size,_size,_size));
00032 
00033 
00034       _DestSphere = new BMESH;
00035       _DestSphere->Sphere(_DestSphere->new_patch());
00036       _DestSphere->transform(Wtransf::scaling(_size,_size,_size));
00037 
00038 
00039    }
00040 
00041 
00042 
00043   
00044    static mlib::CWvec get_move(mlib::CWpt& p, mlib::CWvec& v); 
00045    static void set_size(double); 
00046 
00047 
00048    bool buildCollisionList(OctreeNode*);
00049    double intersect(mlib::CWpt&, mlib::CWvec&, mlib::CWpt&, mlib::CWvec&);
00050    double intersectSphere(mlib::CWpt& rO, mlib::CWvec& rV, mlib::CWpt& sO, double sR);
00051 
00052  protected:
00053         
00054    stop_watch   _clock;
00055    Bface_list   _hitFaces;                              //list of potential colliders
00056    BMESHptr             _BSphere;                               //bounding sphere around the camera
00057    BMESHptr     _DestSphere;                    //bounding sphere around the destination point
00058    double               _size;                                  //size of the camera's bounding sphere
00059    int                  _height;                                
00060    double               _regularity;
00061    double               _min_dist;
00062    int                  _objs;
00063    BBOX         _polyBox;
00064    ARRAY<OctreeNode*> _RootNodes;
00065 
00066    virtual mlib::CWvec _get_move(mlib::CWpt& p, mlib::CWvec& v);
00067    virtual bool _update_scene(); 
00068 };
00069 
00070 
00071 /*****************************************************************
00072  * Gravity:
00073  *
00074  *      Creates a artificial gravity vector to "ground" the
00075  *              camera on a surface
00076  *****************************************************************/
00077 
00078 class Gravity : public BaseGravity {
00079  public :
00080                          
00081    Gravity() : BaseGravity() {
00082       assert(_instance == 0);
00083       _instance = this;
00084 
00085       _currentGrav = 0;
00086       _ground = NULL;
00087       _strength = 1;
00088       _globe = false;
00089       _landscape = false;
00090       _world = false;
00091    }         
00092 //CAMptr &p, 
00093    virtual ~Gravity() {}
00094     
00095    static mlib::Wvec       get_dir(mlib::CWpt& p);
00096         
00097    bool set_grav(GEOMptr g, mlib::CWvec& d, int t);
00098    void set_globe(GEOMptr);
00099    void set_landscape(GEOMptr);
00100    void set_world(mlib::Wvec);
00101 
00102  protected:
00103 
00104 
00105    virtual mlib::CWvec      _get_dir(mlib::CWpt& p);
00106 
00107    enum _gtypes {
00108       GLOBE = 0,
00109       LANDSCAPE,
00110       WORLD
00111    };
00112 
00113    GEOMptr      _ground;                //object the camera will "walk" on
00114    mlib::Wvec   _world_dir;         //direction of world gravity            
00115    double       _strength;              //strength of the gravity
00116    int          _currentGrav;   //
00117    bool         _globe;                 
00118    bool         _landscape;
00119    bool         _world;
00120 };
00121 
00122 #endif // COLLIDE_H_IS_INCLUDED
00123 
00124 /* end of file collide.H */

Generated on Mon Sep 18 11:39:29 2006 for jot by  doxygen 1.4.4