00001 #ifndef BASE_COLLIDE_H_IS_INCLUDED 00002 #define BASE_COLLIDE_H_IS_INCLUDED 00003 00004 #include "mlib/points.H" 00005 00006 /***************************************************************** 00007 * BaseCollide: 00008 * 00009 * Checks for collisions with objects in space 00010 *****************************************************************/ 00011 00012 class BaseCollide { 00013 public : 00014 00015 virtual ~BaseCollide() {} 00016 BaseCollide() {} 00017 00018 static BaseCollide *instance() { return _instance; } 00019 static mlib::CWvec get_move(mlib::CWpt& p, mlib::CWvec& v) { 00020 return _instance ? _instance->_get_move(p,v) : v; 00021 } 00022 00023 static bool update_scene() { 00024 return _instance ? _instance->_update_scene() : false; 00025 } 00026 00027 protected: 00028 //static BaseCollide; 00029 static BaseCollide* _instance; 00030 00031 // given a proposed move in 3D, returns a possibly shortened 00032 // version of the vector that won't go through any objects 00033 // in the world... 00034 virtual mlib::CWvec _get_move(mlib::CWpt& p, mlib::CWvec& v) { 00035 return v; 00036 } 00037 00038 virtual bool _update_scene() = 0; 00039 }; 00040 00041 /***************************************************************** 00042 * BaseGravity: 00043 * 00044 * Adds artificial gravity to the scene 00045 *****************************************************************/ 00046 00047 class BaseGravity { 00048 public : 00049 00050 virtual ~BaseGravity() {} 00051 BaseGravity() {} 00052 00053 static BaseGravity *instance() { return _instance; } 00054 static mlib::CWvec get_dir(mlib::CWpt& p) { 00055 // cout << "GET_DIR" << endl; 00056 return _instance ? _instance->_get_dir(p) : mlib::CWvec(0,0,0); 00057 } 00058 00059 protected: 00060 //static BaseCollide; 00061 static BaseGravity* _instance; 00062 00063 virtual mlib::CWvec _get_dir(mlib::CWpt& p) { 00064 return mlib::CWvec(0,0,0); 00065 } 00066 }; 00067 00068 #endif // BASE_COLLIDE_H_IS_INCLUDED 00069 00070 /* end of file base_collide.H */