#include <SvgLoader.h>
Public Member Functions | |
| SvgLoader () | |
| ~SvgLoader () | |
| Level2D * | loadLevel (const char *fileName, int interpolationSteps=4, bool debug=false) |
| int | calcResultSize (int interpolationSteps) |
| int | calcResultSize (Body2D< Element2D > *source, int interpolationSteps) |
| void | interpolateBezierBody (Body2D< Element2D > *source, Body2D< Vector2D > *target, int interpolationSteps=4) |
| Vector2D * | interpolateBezierBody (Body2D< Element2D > *source, int interpolationSteps=4) |
| int | interpolateBezier (Bezier2D *b, Vector2D *v, int interpolationSteps=4) |
| void | parseSvg (const char *pFilename) |
| char * | addDivisor (const char *source, char insertBefore, char insertSign) |
| double * | tokenizeSvgCommandInputs (const char *command, int amountCoordinates) |
| void | executeSvgCommandString (const char *sourceString, Body2D< Element2D > *targetBody) |
Loads a SVG ("Scalable Vector Graphics") file containing the game level and formats it to make it accessible for other modules.
filename: SvgLoader.h
double vectors (see note above) The (private) variables SvgLoader::worldBezier and SvgLoader::worldVector could possibly be left out and the data could be directly saved into the corresponding worldBezier2D and worldVector2D objects of the appropriate Level2D object.
Make the SvgLoader more compatible to slight differences in the SVG XML code. It is not very flexible/usable for example when using other programs to generate the SVGs. It should at least be able to take Inkscape (free tool) SVG files.
| sonus::SvgLoader::SvgLoader | ( | ) |
Default constructor
| sonus::SvgLoader::~SvgLoader | ( | ) |
Destructor
| Level2D* sonus::SvgLoader::loadLevel | ( | const char * | fileName, | |
| int | interpolationSteps = 4, |
|||
| bool | debug = false | |||
| ) |
Creates a Level2D object from an SVG file and returns a pointer to it. Interpolation steps is set to 4 by default when no explicit number of steps is given.
| fileName | A string name of the SVG file that is to be loaded. | |
| interpolationSteps | The number of recursive interpolation steps. |
| int sonus::SvgLoader::calcResultSize | ( | int | interpolationSteps | ) |
Calculate how many Vectors would result from interpolating a single Bezier2D depending on the amount of interpolation steps.
| interpolationSteps | The number of interpolation steps as a base for the calculation. |
Calculate how many elements would result from interpolating every Bezier2D in a specific Body2D.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
| source | Pointer to a Body2D object that contains all the Bezier2D objects to be counted. | |
| interpolationSteps | The number of interpolation steps as a base for the calculation. |
| void sonus::SvgLoader::interpolateBezierBody | ( | Body2D< Element2D > * | source, | |
| Body2D< Vector2D > * | target, | |||
| int | interpolationSteps = 4 | |||
| ) |
Transforms all of a Body2D objects Bezier2Ds into Vector2Ds. Size of resulting Array depends on the given amount of interpolationSteps. Adds every resulting Vector2D into target.
| source | Pointer to a Body2D object that contains all the Bezier2D objects to be interpolated. | |
| target | Pointer to a Body2D object in which the Vector2D objects are to be saved in during the interpolation process. | |
| interpolationSteps | The amount of times the Beziers are to be interpolated. |
| Vector2D* sonus::SvgLoader::interpolateBezierBody | ( | Body2D< Element2D > * | source, | |
| int | interpolationSteps = 4 | |||
| ) |
Takes a Body2D and transforms all of it's Bezier2Ds into Vector2Ds. Size of returned array depends on the given amount of interpolationSteps.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
| source | Pointer to a Body2D object that contains all the Bezier2D objects to be interpolated. | |
| interpolationSteps | The amount of times the Bezier2D objects are to be interpolated. |
Recursive. Takes a Bezier2D and splits it into Vector2Ds as many times as requested. Returns the size of the Array that is added into the given position. This is only the size that results from splitting the single given Bezier2D.
| b | Pointer to a single Bezier2D object that is to be interpolated. | |
| v | Address of the position in a Vector2D array where the generated Vector2D objects (which are also stored in an array) are to be added in. | |
| interpolationSteps | The amount of times the Bezier2D is to be interpolated. |
| void sonus::SvgLoader::parseSvg | ( | const char * | pFilename | ) |
Parses an SVG at fileName, reads it's commands and executes them. Adds all paths to the object at SvgLoader::level
| pFilename | A string containing the name of the SVG file that will be parsed. |
| char* sonus::SvgLoader::addDivisor | ( | const char * | source, | |
| char | insertBefore, | |||
| char | insertSign | |||
| ) |
Takes a string and adds a certain char insertSign before the given char insertBefore. Returns a new, extended string
| source | The string that is to be processed. | |
| insertBefore | The character this function will look out for and add insertSign before each time. | |
| insertSign | The character to be added before every character defined in insertBefore. |
string containing the result being the new extended version of source. | double* sonus::SvgLoader::tokenizeSvgCommandInputs | ( | const char * | command, | |
| int | amountCoordinates | |||
| ) |
Returns an array with the input values for each SVG command. In that array are all coordinates as doubles for the first command starting at the pointer command.
| command | The string containing the command from the SVG file containing all the data to be processed. | |
| amountCoordinates | The amount of coordinates will define the size of the returned array. |
double array with the input values for each SVG command. | void sonus::SvgLoader::executeSvgCommandString | ( | const char * | sourceString, | |
| Body2D< Element2D > * | targetBody | |||
| ) |
Executes the SVG-Path-Commands contained in sourceString, using a BodyBuilder on targetBody.
1.5.4