source: GTP/branches/IllumWPdeliver2008dec/IlluminationWP/demos/OgreDemos/src/Common/include/SceneSerializer.h @ 3255

Revision 3255, 1.9 KB checked in by szirmay, 15 years ago (diff)
Line 
1#include "Ogre.h"
2
3#ifdef NXOGRE
4#include "NXOgre.h"
5using namespace NxOgre;
6#endif
7
8using namespace Ogre;
9
10enum SceneScriptSection
11{
12        SSS_NONE,
13        SSS_MESH,
14        SSS_ENTITY             
15};
16
17struct SceneScriptContext
18{
19        SceneScriptSection section;
20        size_t lineNo;
21        String filename;
22        SceneManager* sceneManager;
23        String entityName;
24        String meshName;
25        Entity* entity;
26        String pathMapTextureName;
27        SceneNode* sceneNode;
28        std::map<String, String> meshFiles;     
29        std::map<String, unsigned int> pathMapResolutions;
30       
31#ifdef NXOGRE
32        std::map<String, String> meshPhysXShapes;
33        std::map<String, String> meshPhysXShapeParams;
34        //float physXMass;
35        //float physXDensity;
36        //bool physXKinematic;
37        //bool physXStatic;
38        Scene* scene;
39        World* world;
40        Body* physXBody;
41#endif
42};
43
44typedef bool (*SCENE_ATTRIBUTE_PARSER)(String& params, SceneScriptContext& context);
45
46class SceneSerializer
47{
48protected:
49        /// Keyword-mapped attribute parsers.
50    typedef std::map<String, SCENE_ATTRIBUTE_PARSER> AttribParserList;
51
52        SceneScriptContext mScriptContext;
53        /** internal method for parsing a material
54       @returns true if it expects the next line to be a {
55    */
56    bool parseScriptLine(String& line);
57        /** internal method for finding & invoking an attribute parser. */
58    bool invokeParser(String& line, AttribParserList& parsers);
59
60        /// Parsers for the root of the material script
61    AttribParserList mRootAttribParsers;
62    /// Parsers for the material section of a script
63    AttribParserList mMeshAttribParsers;
64    /// Parsers for the technique section of a script
65    AttribParserList mEntityAttribParsers;
66
67public:
68
69        SceneSerializer(SceneManager* sm);
70        void parseScript(DataStreamPtr& stream, const String& groupName);
71        void parseEntryPoints(String filename);
72
73        #ifdef NXOGRE
74                public:
75                        void setScene(Scene* scene){mScriptContext.scene = scene;}
76                        void setWorld(World* world){mScriptContext.world = world;}
77               
78        #endif
79
80};
Note: See TracBrowser for help on using the repository browser.