random_racer/src/ReloadPlane.h

Go to the documentation of this file.
00001 #ifndef _RR_RELOADPLANE_H_
00002 #define _RR_RELOADPLANE_H_
00003 
00004 #include <vrs/so.h>
00005 #include <vrs/vector.h>
00006 #include <vrs/callback.h>
00007 
00008 #include <vrsode/CollisionBody.h>
00009 
00010 #include <random_utils/ThreadSafeObject.h>
00011 
00012 namespace VRS
00013 {
00014 class SceneThing;
00015 } // namespace VRS
00016 
00017 namespace vrsode
00018 {
00019 class PlaneShape;
00020 } // namespace vrsode
00021 
00022 
00023 namespace random_racer
00024 {
00025 
00037 class ReloadPlane : public VRS::SharedObj,
00038                     public random_utils::ThreadSafeObject
00039 {
00045     class PlaneWrapper : public vrsode::CollisionBody
00046     {
00047         VRS::SO<ReloadPlane>    m_reloadPlane;
00048 
00049     public:
00057         PlaneWrapper(
00058             VRS::SO<VRS::SceneThing> parent,
00059             VRS::SO<vrsode::Shape> shape,
00060             VRS::SO<ReloadPlane> reloadPlane);
00061 
00065         virtual ~PlaneWrapper();
00066 
00067     protected:
00071         virtual void handleCollision(VRS::SO<vrsode::CollisionBody> partner);
00072     };
00073 
00074     VRS::SO<vrsode::CollisionBody>  m_car;
00075     VRS::SO<VRS::SceneThing>        m_parentThing, m_sceneThing;
00076     VRS::SO<vrsode::PlaneShape>     m_shape;
00077     VRS::SO<PlaneWrapper>           m_ownBody;
00078     unsigned int                    m_planeId;
00079     bool                            m_collidedRecently, m_propagate, m_gotIt;
00080 
00081     VRS::SO<VRS::Callback1<unsigned int> >   m_callback;
00082 
00083 public:
00103     ReloadPlane(
00104         VRS::SO<VRS::SceneThing> parentThing,
00105         VRS::SO<VRS::Callback1<unsigned int> > collisionCallback,
00106         unsigned int id,
00107         bool propagateToOtherThread = true);
00108 
00112     virtual ~ReloadPlane();
00113 
00117     inline void relocate(VRS::Vector normal, double distance)
00118     {
00119         m_shape->setNormalAndAnchor(normal, distance);
00120     }
00121 
00125     inline void relocate(double distance)
00126     {
00127         m_shape->setAnchor(distance);
00128     }
00129 
00133     inline void setDebug(bool enable = true)
00134     {
00135         m_ownBody->setDebugNode(enable);
00136     }
00137 
00143     void handleCollisionFromThread();
00144 
00149     void checkForCollision();
00150 };
00151 
00152 } // namespace random_racer
00153 
00154 #endif // _RR_RELOADPLANE_H_

Generated on Fri May 11 21:01:58 2007 for Random Racer by  doxygen 1.5.1