00001
00026 #ifndef _PHYSICS_
00027 #define _PHYSICS_
00028 #define BOX_WIDTH 1
00029
00030 #include <Level2D.h>
00031 #include <disableWarnings.h>
00032 #include <Box2D.h>
00033 #include <Windows.h>
00034 #include <Integrator.h>
00035 #include <stdlib.h>
00036 #include <limits.h>
00037
00038 #include <Graphics.h>
00039
00040 namespace sonus
00041 {
00042
00078 class Physics
00079 {
00080
00081 public:
00082
00086 Physics();
00087
00100 Physics( double timeStep = 0.0166667, int iterations = 10 );
00101
00107 ~Physics();
00108
00115 void cleanForInit();
00116
00125 void initLevel( Level2D* level );
00126
00135 void update( Level2D* level );
00136
00143 void createPlayer( Player* player );
00144
00152 void createPortal( Vector2D* portal, double radius );
00153
00163 void createBody( Body2D<Vector2D>* body, b2Body** storeBodies, int* bodyCounter );
00164
00177 void addBodyToWorld( Body2D<Vector2D>* body, Vector2D transformationVector, double scaleFactor, b2Body** b2BodyStorage, int* storagePosition );
00178
00194 b2BodyDef* createBodyDef( Body2D<Vector2D>* body, Vector2D transformationVector, double scaleFactor, int* startAt, int* elementsAdded );
00195
00203 void debugToGraphics();
00204
00205 private:
00206
00207 float unitMeter;
00208 bool drawShapes;
00209 double timeStep;
00210 int iterations;
00211
00212 b2Body* ray;
00213
00214 Vector2D* transform;
00215 double scale;
00216
00217 Level2D* level;
00218 b2World* world;
00219 b2Body* playerBody;
00220 b2Body* portalBody;
00221 b2Body** borderBody;
00222 int borderBodyCount;
00223 int shapeCount;
00224
00225 b2Body*** obstacles;
00226 int* obstaclesBodyCount;
00227 b2BoxDef** tempBoxPointers;
00228
00229
00230 Vector2D** borderForDrawing;
00231 int countVectorsForDrawing;
00232
00233
00234 scene::ISceneNode* rayBox;
00235 };
00236 }
00237
00238 #endif