C:/Users/Mike/Documents/Visual Studio Projects/GameEngine/include/PhysicsManager.h

Go to the documentation of this file.
00001 /*
00002 -----------------------------------------------------------------------------
00003 Copyright (C) 2006 Michael Harnetty
00004 
00005 This program is free software; you can redistribute it and/or
00006 modify it under the terms of the GNU General Public License
00007 as published by the Free Software Foundation; either version 2
00008 of the License, or (at your option) any later version.
00009 
00010 This program is distributed in the hope that it will be useful,
00011 but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 GNU General Public License for more details.
00014 
00015 You should have received a copy of the GNU General Public License
00016 along with this program; if not, write to the Free Software
00017 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00018 -----------------------------------------------------------------------------
00019 */
00020 
00021 #ifndef PHYSICSMANAGER_H
00022 #define PHYSICSMANAGER_H
00023 
00024 #include "GameEnginePrerequisites.h"
00025 #include "GameObject.h"
00026 #include "Event.h"
00027 #include "EventManager.h"
00028 #include "Singleton.h"
00029 #include "Process.h"
00030 
00031 
00032 namespace GameEngine {
00033 
00036         class ENGINE_DECL PhysicsManager : public Process, public opal::MovementEventHandler, public opal::CollisionEventHandler {
00037 
00038         public:
00046                 PhysicsManager(const Real& worldWidth, const Real& worldHeight, const Real& worldDepth, const Vector3& gravity);
00047                 ~PhysicsManager();
00048 
00053                 void update(const double& dt);
00054 
00055 
00056 
00061                 virtual void OPAL_CALL handleMovementEvent( const opal::MovementEvent& event ); // Need to assign handler to solids when we create them
00062                 
00063 
00068                 virtual void OPAL_CALL handleCollisionEvent( const opal::CollisionEvent& event ); // Need to assign handler to solids when we create them
00069                 
00070 
00071                 opal::Simulator* mPhysicsSim;
00072 
00073         private:
00080                 Vector3& wrapCoords(Vector3& coords) const;
00081 
00082                 Real mWidth;
00083                 Real mHeight;
00084                 Real mDepth;
00085         };
00086 
00087 
00090         class ENGINE_DECL PhysicsMovementEventData : public IEventData
00091         {
00092         public:
00093                 PhysicsMovementEventData(boost::shared_ptr<GameObject> object, Vector3 pos, Quaternion ori) :   mObject(object),
00094                                                                                                                                                                                                                 mPosistion(pos),
00095                                                                                                                                                                                                                 mOrientation(ori) {}
00096 
00097                 boost::shared_ptr<GameObject> mObject;
00098                 Vector3 mPosistion;
00099                 Quaternion mOrientation;
00100         };
00101 
00104         class ENGINE_DECL PhysicsCollisionEventData : public IEventData
00105         {
00106         public:
00107                 PhysicsCollisionEventData(      boost::shared_ptr<GameObject> thisObject, 
00108                                                                         boost::shared_ptr<GameObject> otherObject, 
00109                                                                         opal::Point3r position) 
00110                                                                         :       mThisObject(thisObject), 
00111                                                                                 mOtherObject(otherObject),
00112                                                                                 mPosition(position)
00113                 {}
00114 
00115                 boost::shared_ptr<GameObject> mThisObject;
00116                 boost::shared_ptr<GameObject> mOtherObject;
00117                 opal::Point3r mPosition;
00118         };
00119 
00120 
00121 
00124         class ENGINE_DECL PhysicsMovementEvent : public Event
00125         {
00126                 static char const * const eventName;
00127 
00128         public:
00129                 PhysicsMovementEvent(boost::shared_ptr<GameObject> object, Vector3 pos, Quaternion ori) : Event(eventName, 0, IEventDataPtr(new PhysicsMovementEventData(object, pos, ori)) ) {}
00130 
00131         };
00132 
00133 
00136         class ENGINE_DECL PhysicsCollisionEvent : public Event
00137         {
00138                 static char const * const eventName;
00139 
00140         public:
00141                 PhysicsCollisionEvent(boost::shared_ptr<GameObject> thisObject, boost::shared_ptr<GameObject> otherObject, opal::Point3r position) : Event(eventName, 0, IEventDataPtr(new PhysicsCollisionEventData(thisObject, otherObject, position)) ) {}
00142 
00143         };
00144 
00145 }
00146 
00147 #endif

Generated on Thu Apr 19 09:47:02 2007 for GameEngine by  doxygen 1.5.2