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
00012
00013
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;
00056 BMESHptr _BSphere;
00057 BMESHptr _DestSphere;
00058 double _size;
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
00073
00074
00075
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
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;
00114 mlib::Wvec _world_dir;
00115 double _strength;
00116 int _currentGrav;
00117 bool _globe;
00118 bool _landscape;
00119 bool _world;
00120 };
00121
00122 #endif // COLLIDE_H_IS_INCLUDED
00123
00124