00001
00026 #ifndef _SVGLOADER_
00027 #define _SVGLOADER_
00028
00029
00030 #include <Windows.h>
00031 #include <cmath>
00032 #include <stdlib.h>
00033 #include <string.h>
00034 #include <ctype.h>
00035
00036 #include <disableWarnings.h>
00037 #include <Element2D.h>
00038 #include <Vector2D.h>
00039 #include <Bezier2D.h>
00040 #include <Body2D.h>
00041 #include <BodyBuilder.h>
00042 #include <World2D.h>
00043 #include <Level2D.h>
00044
00045 #include <tinyxml.h>
00046
00047 #define TIXML_USE_STL
00048
00049 namespace sonus
00050 {
00051
00078 class SvgLoader
00079 {
00080
00081 public:
00082
00086 SvgLoader();
00087
00091 ~SvgLoader();
00092
00104 Level2D* loadLevel( const char* fileName, int interpolationSteps = 4, bool debug = false );
00105
00114 int calcResultSize( int interpolationSteps );
00115
00125 int calcResultSize( Body2D<Element2D>* source, int interpolationSteps );
00126
00136 void interpolateBezierBody( Body2D<Element2D>* source, Body2D<Vector2D>* target, int interpolationSteps = 4 );
00137
00149 Vector2D* interpolateBezierBody( Body2D<Element2D>* source, int interpolationSteps = 4 );
00150
00161 int interpolateBezier( Bezier2D* b, Vector2D* v, int interpolationSteps = 4 );
00162
00169 void parseSvg(const char* pFilename);
00170
00180 char* addDivisor( const char* source, char insertBefore, char insertSign );
00181
00190 double* tokenizeSvgCommandInputs( const char* command, int amountCoordinates );
00191
00198 void executeSvgCommandString( const char* sourceString, Body2D<Element2D>* targetBody );
00199
00200 private:
00201
00202 bool debug;
00203
00204 const char* fileName;
00205 int interpolationSteps;
00206 int interpolVectorCounter;
00207
00208 int obstacleNodeCount;
00209 Player* player;
00210 Vector2D* portal;
00211 Body2D<Element2D>* borderBezier;
00212 Body2D<Vector2D>* borderVector;
00213 Body2D<Element2D>** obstacleBezierBodies;
00214 Body2D<Vector2D>** obstacleVectorBodies;
00215
00216 BodyBuilder* builder;
00217 Level2D* level;
00218
00219 World2D<Element2D>* worldBezier;
00220 World2D<Vector2D>* worldVector;
00221 };
00222
00223 }
00224
00225 #endif