Commits

Frederic De Groef committed aeea320

added ogremax/tinyxml as dependencies. added ogermax callback class to set loaded entities' material to gbuffer shader material

Comments (0)

Files changed (32)

Dependencies/OgreMax/inc/OgreMaxModel.hpp

+/*
+ * OgreMaxViewer - An Ogre 3D-based viewer for .scene and .mesh files
+ * Copyright 2008 Derek Nedelman
+ *
+ * This code is available under the OgreMax Free License:
+ *   -You may use this code for any purpose, commercial or non-commercial.
+ *   -If distributing derived works (that use this source code) in binary or source code form, 
+ *    you must give the following credit in your work's end-user documentation: 
+ *        "Portions of this work provided by OgreMax (www.ogremax.com)"
+ *
+ * Derek Nedelman assumes no responsibility for any harm caused by using this code.
+ * 
+ * OgreMaxViewer was written by Derek Nedelman and released at www.ogremax.com 
+ */
+
+#ifndef OgreMax_OgreMaxModel_INCLUDED
+#define OgreMax_OgreMaxModel_INCLUDED
+
+
+//Includes---------------------------------------------------------------------
+#include <OgreResourceGroupManager.h>
+#include <OgreEntity.h>
+#include <OgreCamera.h>
+#include <OgreLight.h>
+#include <OgreParticleSystem.h>
+#include <OgreMeshManager.h>
+#include <OgreBillboardSet.h>
+#include "OgreMaxPlatform.hpp"
+#include "OgreMaxTypes.hpp"
+
+
+//Classes----------------------------------------------------------------------
+namespace OgreMax
+{
+    class OgreMaxModelInstanceCallback;
+    class OgreMaxScene;
+
+    /**
+     * An OgreMax model describes a node hierarchy, including all of the contained
+     * objects within those nodes. There is one one root node in this hierarchy
+     *
+     * Instances of a model can be created within the scene
+     */
+    class _OgreMaxExport OgreMaxModel
+    {
+    public:
+        OgreMaxModel();
+        virtual ~OgreMaxModel();
+
+        /**
+         * Loads the model description from the specified file
+         * @param fileName [in] - The file name. This file must be within Ogre's
+         * configured file system
+         * @param resourceGroupName [in] - The resource group that the file is located in
+         */
+        void Load
+            (
+            const Ogre::String& fileName, 
+            const Ogre::String& resourceGroupName = Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME
+            );
+
+        /**
+         * Options that may be passed to CreateInstance()
+         */
+        typedef int InstanceOptions;
+        enum
+        {
+            NO_OPTIONS = 0,
+            
+            /** Indicates animation states should not be created for animation tracks */
+            NO_ANIMATION_STATES = 0x1,
+
+            /** 
+             * Indicates that the model's defined position/orientation/scale should not be used.
+             * This is used in the scene loading code since scene instances have their own transformation
+             */
+            NO_INITIAL_TRANSFORMATION = 0x2
+        };
+
+        /** 
+         * Creates an instance of the model description within the scene
+         * @param sceneManager [in] - The scene manager that will contain the new objects
+         * @param baseName [in] - The base name that will be used when generating new object names
+         * @param callback [in] - Object-creation callback
+         * @param options [in] - Options that control the behavior of the object creation
+         * @param parentNode [in] - Optional parent node to which the model becomes a child of. 
+         * If null, the model is created as a child of the scene's root node
+         * @param defaultResourceGroupName [in] - Name of the default resource group to use when loading/creating meshes
+         * @param node [in] - The node into which the instance is created
+         * @param scene [in] - The scene that owns all the models
+         * @return The instance's root node is returned. This is the 'node' parameter
+         */
+        Ogre::SceneNode* CreateInstance
+            (
+            Ogre::SceneManager* sceneManager, 
+            const Ogre::String& baseName = Ogre::StringUtil::BLANK,
+            OgreMaxModelInstanceCallback* callback = 0,
+            InstanceOptions options = NO_OPTIONS,
+            Ogre::SceneNode* parentNode = 0,
+            const Ogre::String& defaultResourceGroupName = Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
+            Ogre::SceneNode* node = 0,
+            OgreMaxScene* scene = 0
+            ) const;
+
+    private:
+        Ogre::SceneNode* CreateInstance
+            (
+            Ogre::SceneManager* sceneManager, 
+            const Ogre::String& baseName,
+            OgreMaxModelInstanceCallback* callback, 
+            InstanceOptions options,
+            const Types::NodeParameters& nodeParams, 
+            Ogre::SceneNode* parentNode,
+            const Ogre::String& defaultResourceGroupName,
+            Ogre::SceneNode* node = 0,
+            OgreMaxScene* scene = 0
+            ) const;
+
+        void CreateMovableObject
+            (
+            Ogre::SceneManager* sceneManager,
+            const Ogre::String& baseName,
+            Types::ObjectParameters* object,
+            const Types::MovableObjectOwner& owner,
+            OgreMaxModelInstanceCallback* callback, 
+            const Ogre::String& defaultResourceGroupName
+            ) const;
+
+        void CreateEntity
+            (
+            Ogre::SceneManager* sceneManager,
+            const Ogre::String& baseName,
+            const Ogre::String& objectName,
+            Types::EntityParameters* entityParams,
+            const Types::MovableObjectOwner& owner,
+            Types::ObjectExtraDataPtr objectExtraData,
+            OgreMaxModelInstanceCallback* callback, 
+            const Ogre::String& defaultResourceGroupName
+            ) const;
+
+        void CreateLight
+            (
+            Ogre::SceneManager* sceneManager,
+            const Ogre::String& objectName,
+            Types::LightParameters* lightParams,
+            const Types::MovableObjectOwner& owner,
+            Types::ObjectExtraDataPtr objectExtraData,
+            OgreMaxModelInstanceCallback* callback
+            ) const;
+
+        void CreateCamera
+            (
+            Ogre::SceneManager* sceneManager,
+            const Ogre::String& objectName,
+            Types::CameraParameters* cameraParams,
+            const Types::MovableObjectOwner& owner,
+            Types::ObjectExtraDataPtr objectExtraData,
+            OgreMaxModelInstanceCallback* callback
+            ) const;
+
+        void CreateParticleSystem
+            (
+            Ogre::SceneManager* sceneManager,
+            const Ogre::String& objectName,
+            Types::ParticleSystemParameters* particleSystemParams,
+            const Types::MovableObjectOwner& owner,
+            Types::ObjectExtraDataPtr objectExtraData,
+            OgreMaxModelInstanceCallback* callback
+            ) const;
+
+        void CreateBillboardSet
+            (
+            Ogre::SceneManager* sceneManager,
+            const Ogre::String& objectName,
+            Types::BillboardSetParameters* billboardSetParams,
+            const Types::MovableObjectOwner& owner,
+            Types::ObjectExtraDataPtr objectExtraData,
+            OgreMaxModelInstanceCallback* callback
+            ) const;
+
+        void CreatePlane
+            (
+            Ogre::SceneManager* sceneManager,
+            const Ogre::String& baseName,
+            const Ogre::String& objectName,
+            Types::PlaneParameters* planeParams,
+            const Types::MovableObjectOwner& owner,
+            Types::ObjectExtraDataPtr objectExtraData,
+            OgreMaxModelInstanceCallback* callback, 
+            const Ogre::String& defaultResourceGroupName
+            ) const;
+
+        void LoadNode(const TiXmlElement* objectElement, Types::NodeParameters& node);
+        Types::EntityParameters* LoadEntity(const TiXmlElement* objectElement);
+        void LoadBoneAttachments(const TiXmlElement* objectElement, Types::EntityParameters& entity);
+        void LoadBoneAttachment(const TiXmlElement* objectElement, Types::EntityParameters::BoneAttachment& boneAttachment);
+        Types::LightParameters* LoadLight(const TiXmlElement* objectElement);
+        Types::CameraParameters* LoadCamera(const TiXmlElement* objectElement);
+        Types::ParticleSystemParameters* LoadParticleSystem(const TiXmlElement* objectElement);
+        Types::BillboardSetParameters* LoadBillboardSet(const TiXmlElement* objectElement);
+        Types::PlaneParameters* LoadPlane(const TiXmlElement* objectElement);
+        void LoadBillboard(const TiXmlElement* objectElement, Types::BillboardSetParameters::Billboard& billboard);
+        void LoadLightRange(const TiXmlElement* objectElement, Types::LightParameters& light);
+        void LoadLightAttenuation(const TiXmlElement* objectElement, Types::LightParameters& light);
+        void LoadNodeAnimations(const TiXmlElement* objectElement, Types::NodeParameters& node);
+        void LoadNodeAnimation(const TiXmlElement* objectElement, Types::NodeAnimationParameters& animation);
+        void LoadNodeAnimationKeyFrame(const TiXmlElement* objectElement, Types::NodeAnimationParameters::KeyFrame& keyframe);
+
+        void HandleNewObjectExtraData(OgreMaxModelInstanceCallback* callback, Types::ObjectExtraDataPtr objectExtraData) const;
+
+    protected:
+        Types::NodeParameters rootNode;
+    };
+
+    class _OgreMaxExport OgreMaxModelInstanceCallback
+    {
+    public:
+        //MovableObject-creation callbacks, called after an object has been created
+        //These are called after the object was attached to its parent node, if there is a parent node
+        virtual void CreatedLight(const OgreMaxModel* model, Ogre::Light* light) {CreatedMovableObject(model, light);}
+        virtual void CreatedCamera(const OgreMaxModel* model, Ogre::Camera* camera) {CreatedMovableObject(model, camera);}
+        virtual void CreatedMesh(const OgreMaxModel* model, Ogre::Mesh* mesh) {}
+        virtual void CreatedEntity(const OgreMaxModel* model, Ogre::Entity* entity) {CreatedMovableObject(model, entity);}
+        virtual void CreatedParticleSystem(const OgreMaxModel* model, Ogre::ParticleSystem* particleSystem) {CreatedMovableObject(model, particleSystem);}
+        virtual void CreatedBillboardSet(const OgreMaxModel* model, Ogre::BillboardSet* billboardSet) {CreatedMovableObject(model, billboardSet);}
+        virtual void CreatedPlane(const OgreMaxModel* model, const Ogre::Plane& plane, Ogre::Entity* entity) {CreatedMovableObject(model, entity);}
+        virtual void CreatedMovableObject(const OgreMaxModel* model, Ogre::MovableObject* object) {}
+        
+        virtual void CreatedNodeAnimationTrack(const OgreMaxModel* model, Ogre::SceneNode* node, Ogre::AnimationTrack* animationTrack, bool enabled, bool looping) {}
+        virtual void CreatedNodeAnimationState(const OgreMaxModel* model, Ogre::SceneNode* node, Ogre::AnimationState* animationState) {}
+
+        /** Called after a node is created, but before its entities or any child nodes have been created */
+        virtual void StartedCreatingNode(const OgreMaxModel* model, Ogre::SceneNode* node) {}
+        
+        /** Called after the node and all its entities and child nodes have been created */
+        virtual void FinishedCreatingNode(const OgreMaxModel* model, Ogre::SceneNode* node) {}
+
+        virtual void HandleObjectExtraData(Types::ObjectExtraDataPtr objectExtraData) {}
+    };
+
+}
+
+
+#endif

Dependencies/OgreMax/inc/OgreMaxPlatform.hpp

+/*
+ * OgreMaxViewer - An Ogre 3D-based viewer for .scene and .mesh files
+ * Copyright 2008 Derek Nedelman
+ *
+ * This code is available under the OgreMax Free License:
+ *   -You may use this code for any purpose, commercial or non-commercial.
+ *   -If distributing derived works (that use this source code) in binary or source code form, 
+ *    you must give the following credit in your work's end-user documentation: 
+ *        "Portions of this work provided by OgreMax (www.ogremax.com)"
+ *
+ * Derek Nedelman assumes no responsibility for any harm caused by using this code.
+ * 
+ * OgreMaxViewer was written by Derek Nedelman and released at www.ogremax.com 
+ */
+
+#ifndef OgreMax_OgreMaxPlatform_INCLUDED
+#define OgreMax_OgreMaxPlatform_INCLUDED
+
+                  
+//Macros-----------------------------------------------------------------------
+#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
+    #if defined(OGREMAX_SHARED_LIBRARY_EXPORT)
+        //Exporting from a shared library
+        #if defined(__MINGW32__)
+            #define _OgreMaxExport
+        #else
+            #define _OgreMaxExport __declspec(dllexport)
+        #endif
+    #elif defined(OGREMAX_SHARED_LIBRARY_IMPORT)
+        //Importing from a shared library
+        #if defined(__MINGW32__)
+            #define _OgreMaxExport
+        #else
+            #define _OgreMaxExport __declspec(dllimport)
+        #endif
+    #else
+        //Using the source code directly or from a static library
+        #define _OgreMaxExport
+    #endif
+#else
+    //Either using the source code directly or from a static library...
+    //Or compiling on a platform that doesn't require import/export decorations
+    #define _OgreMaxExport
+#endif
+
+
+#endif

Dependencies/OgreMax/inc/OgreMaxRenderWindowIterator.hpp

+/*
+ * OgreMaxViewer - An Ogre 3D-based viewer for .scene and .mesh files
+ * Copyright 2008 Derek Nedelman
+ *
+ * This code is available under the OgreMax Free License:
+ *   -You may use this code for any purpose, commercial or non-commercial.
+ *   -If distributing derived works (that use this source code) in binary or source code form, 
+ *    you must give the following credit in your work's end-user documentation: 
+ *        "Portions of this work provided by OgreMax (www.ogremax.com)"
+ *
+ * Derek Nedelman assumes no responsibility for any harm caused by using this code.
+ * 
+ * OgreMaxViewer was written by Derek Nedelman and released at www.ogremax.com 
+ */
+
+#ifndef OgreMax_OgreMaxRenderWindowIterator_INCLUDED
+#define OgreMax_OgreMaxRenderWindowIterator_INCLUDED
+
+
+//Classes----------------------------------------------------------------------
+namespace OgreMax
+{   
+    /** 
+     * An interface for iterating through a collection of Ogre::RenderWindow objects 
+     * This should not be used to natively store render windows. Instead,
+     * it should be created as needed, wrapping access to a real collection that is 
+     * stored elsewhere.
+     */
+    class OgreMaxRenderWindowIterator
+    {
+    public:
+        virtual ~OgreMaxRenderWindowIterator() {}
+
+        virtual bool Start() = 0;
+        virtual Ogre::RenderWindow* GetCurrent() = 0;
+        virtual bool MoveNext() = 0;
+    };
+
+    /** Accesses one render window */
+    class OgreMaxOneRenderWindow : public OgreMaxRenderWindowIterator
+    {
+    public:
+        OgreMaxOneRenderWindow(Ogre::RenderWindow* renderWindow)
+        {
+            this->renderWindow = renderWindow;
+            this->iterationEnabled = false;
+        }
+
+        bool Start()
+        {
+            this->iterationEnabled = this->renderWindow != 0;
+            return this->iterationEnabled;
+        }
+
+        Ogre::RenderWindow* GetCurrent()
+        {
+            if (this->iterationEnabled)
+            {
+                this->iterationEnabled = false;                
+                return this->renderWindow;
+            }
+            return 0;
+        }
+
+        bool MoveNext()
+        {
+            this->iterationEnabled = false;                
+            return this->iterationEnabled;
+        }
+
+    protected:
+        Ogre::RenderWindow* renderWindow;
+        bool iterationEnabled;
+    };
+
+    /** Accesses a render window array */
+    class OgreMaxRenderWindowArray : public OgreMaxRenderWindowIterator
+    {
+    public:
+        OgreMaxRenderWindowArray(Ogre::RenderWindow** renderWindows, size_t renderWindowCount)
+        {
+            this->renderWindows = renderWindows;
+            this->renderWindowCount = renderWindowCount;
+            this->iterationEnabled = false;
+        }
+
+        bool Start()
+        {
+            this->iterationEnabled = this->renderWindowCount > 0;
+            if (this->iterationEnabled)
+                this->iterationIndex = 0;
+            return this->iterationEnabled;
+        }
+
+        Ogre::RenderWindow* GetCurrent()
+        {
+            if (this->iterationEnabled)
+                return this->renderWindows[this->iterationIndex];
+            return 0;
+        }
+
+        bool MoveNext()
+        {
+            if (this->iterationEnabled)
+            {
+                if (++this->iterationIndex == this->renderWindowCount)
+                    this->iterationEnabled = false;                            
+            }
+            return this->iterationEnabled;
+        }
+
+    protected:
+        Ogre::RenderWindow** renderWindows;
+        size_t renderWindowCount;        
+        size_t iterationIndex;
+        bool iterationEnabled;
+    };
+
+    /** 
+     * Accesses a render window collection (std::list, std::vector, std::set, and so on) 
+     * Example usage with a non-const list: 
+     *    OgreMaxRenderWindowCollection<std::list<Ogre::RenderWindow*>&, std::list<Ogre::RenderWindow*>::iterator> renderWindows(myRenderWindowList);
+     * Example usage with a const vector: 
+     *    OgreMaxRenderWindowCollection<const std::vector<Ogre::RenderWindow*>&, std::vector<Ogre::RenderWindow*>::const_iterator> renderWindows(myRenderWindowVector);
+     */
+    template <class COLLECTION, class ITERATOR>
+    class OgreMaxRenderWindowCollection : public OgreMaxRenderWindowIterator
+    {
+    public:
+        OgreMaxRenderWindowCollection(COLLECTION renderWindowCollection) : renderWindows(renderWindowCollection)
+        {
+            this->iterationEnabled = false;
+        }
+
+        bool Start()
+        {
+            this->iterationEnabled = !this->renderWindows.empty();
+            if (this->iterationEnabled)
+                this->iterator = this->renderWindows.begin();
+            return this->iterationEnabled;
+        }
+
+        Ogre::RenderWindow* GetCurrent()
+        {
+            if (this->iterationEnabled)
+                return *this->iterator;
+            return 0;
+        }
+
+        bool MoveNext()
+        {
+            if (this->iterationEnabled)
+            {
+                if (++this->iterator == this->renderWindows.end())
+                    this->iterationEnabled = false;                                   
+            }
+            return this->iterationEnabled;
+        }
+
+    protected:
+        COLLECTION renderWindows;
+        ITERATOR iterator;
+        bool iterationEnabled;
+    };
+
+}
+
+#endif

Dependencies/OgreMax/inc/OgreMaxScene.hpp

+/*
+ * OgreMaxViewer - An Ogre 3D-based viewer for .scene and .mesh files
+ * Copyright 2008 Derek Nedelman
+ *
+ * This code is available under the OgreMax Free License:
+ *   -You may use this code for any purpose, commercial or non-commercial.
+ *   -If distributing derived works (that use this source code) in binary or source code form, 
+ *    you must give the following credit in your work's end-user documentation: 
+ *        "Portions of this work provided by OgreMax (www.ogremax.com)"
+ *
+ * Derek Nedelman assumes no responsibility for any harm caused by using this code.
+ * 
+ * OgreMaxViewer was written by Derek Nedelman and released at www.ogremax.com 
+ */
+
+#ifndef OgreMax_OgreMaxScene_INCLUDED
+#define OgreMax_OgreMaxScene_INCLUDED
+
+
+//Includes---------------------------------------------------------------------
+#include <OgreRenderTargetListener.h>
+#include <OgreInstancedGeometry.h>
+#include <OgreStaticGeometry.h>
+#include "OgreMaxPlatform.hpp"
+#include "ProgressCalculator.hpp"
+#include "Version.hpp"
+#include "OgreMaxModel.hpp"
+#include "OgreMaxRenderWindowIterator.hpp"
+
+
+//Classes----------------------------------------------------------------------
+namespace OgreMax
+{   
+    class OgreMaxSceneCallback;
+
+    /** 
+     * Manages the loading of a OgreMax .scene file. 
+     * This class is very lightwight in the sense that doesn't maintain a lot of
+     * internal state. Instead, wherever possible, most of the data is put into the 
+     * Ogre scene manager. As such, when deleting an OgreMaxScene, keep in mind that
+     * the scene manager and all of resources that were loaded as a result of loading
+     * the scene are NOT destroyed. You will need to destroy those manually.
+     */
+    class _OgreMaxExport OgreMaxScene : public Ogre::RenderTargetListener
+    {
+    public:
+        OgreMaxScene();
+        virtual ~OgreMaxScene();
+
+        /**
+         * Options that may be passed to Load()
+         */
+        typedef int LoadOptions;
+        enum
+        {
+            NO_OPTIONS = 0,
+
+            /** Skips the environment settings in the file. Skipping the environment also skips shadows */
+            SKIP_ENVIRONMENT = 0x1,
+
+            /** Skips the shadow settings in the file */
+            SKIP_SHADOWS = 0x2,
+
+            /** Skips the sky settings in the file */
+            SKIP_SKY = 0x4,
+
+            /** Skips the nodes in the file */
+            SKIP_NODES = 0x8,
+
+            /** Skips the externals in the file */
+            SKIP_EXTERNALS = 0x10,
+
+            /** Skips the terrain in the file */
+            SKIP_TERRAIN = 0x20,
+
+            /** Skips the octree in the file */
+            SKIP_OCTREE = 0x40,
+
+            /** Skips scene level (non-node) lights in the file */
+            SKIP_SCENE_LIGHT = 0x80,
+
+            /** Skips scene level (non-node) cameras in the file */
+            SKIP_SCENE_CAMERA = 0x100,
+
+            /** Skips scene level query flags in the file */
+            SKIP_QUERY_FLAG_ALIASES = 0x200,
+
+            /** Skips scene level visibility flags in the file */
+            SKIP_VISIBILITY_FLAG_ALIASES = 0x400,
+
+            /** Skips scene level resource locations in the file */
+            SKIP_RESOURCE_LOCATIONS = 0x800,
+
+            /** Indicates animation states should not be created for node animation tracks */
+            NO_ANIMATION_STATES = 0x1000,
+
+            /** 
+             * Indicates scene 'externals' should not be stored. They will, however, still 
+             * be loaded and the CreatedExternal() scene callback will be called
+             */
+            NO_EXTERNALS = 0x2000,
+
+            /**
+             * By default, the OgreMaxScene::Load() checks to see if the file that was passed
+             * in exists in the file system (outside of the configured resource locations). 
+             * This flag disables that logic
+             */
+            NO_FILE_SYSTEM_CHECK = 0x4000,
+
+            /**
+             * Indicates that a light should be created if the loaded scene doesn't contain a light
+             * Any lights created as a result of setting the default lighting are not passed to
+             * the scene callback
+             */
+            SET_DEFAULT_LIGHTING = 0x8000,
+
+            /**
+             * Indicates that the 'fileNameOrContent' parameter in Load() should be treated as the
+             * scene XML. In other words, no file is loaded from Ogre's file system.
+             */
+            FILE_NAME_CONTAINS_CONTENT = 0x10000
+        };
+
+        /** 
+         * Loads a scene from the specified file. 
+         * @param fileNameOrContent [in] - The name of the file to load. This file name can contain a directory path
+         * or be a base name that exists within Ogre's resource manager. If the file contains a directory path, 
+         * the directory will be added to Ogre's resource manager as a resource location and the directory will be 
+         * set as a base resource location. If the file doesn't contain a directory path, and assuming 
+         * If the FILE_NAME_CONTAINS_CONTENT flag is specified as a load option, this parameter is treated
+         * as though it is the scene file itself. That is, the string contains the scene file XML.
+         * SetBaseResourceLocation() hasn't already been called elsewhere, no resource location configuration 
+         * will occur during the load
+         * @param renderWindow [in] - The render window in use
+         * @param loadOptions [in] - Options used to specify the loading behavior. Optional.
+         * @param sceneManager [in] - The scene manager into which the scene is loaded. Optional. If not specified, 
+         * the scene manager specified in the scene file will be used to create a new scene manager
+         * @param rootNode [in] - Root node under which all loaded scene nodes will be created. If specified,
+         * this should be a scene node in the specified scene manager
+         * @param callback [in] - Pointer to a callback object. Optional.
+         * @param defaultResourceGroupName [in] - The resource group name that is used by default when
+         * creating new resources. Optional.
+         */
+        void Load
+            (
+            const Ogre::String& fileNameOrContent, 
+            Ogre::RenderWindow* renderWindow,
+            LoadOptions loadOptions = NO_OPTIONS,
+            Ogre::SceneManager* sceneManager = 0, 
+            Ogre::SceneNode* rootNode = 0,
+            OgreMaxSceneCallback* callback = 0,
+            const Ogre::String& defaultResourceGroupName = Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME
+            );
+
+        void Load
+            (
+            const Ogre::String& fileName, 
+            OgreMaxRenderWindowIterator& renderWindows,
+            LoadOptions loadOptions = NO_OPTIONS,
+            Ogre::SceneManager* sceneManager = 0, 
+            Ogre::SceneNode* rootNode = 0,
+            OgreMaxSceneCallback* callback = 0,
+            const Ogre::String& defaultResourceGroupName = Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME
+            );
+
+        /** 
+         * Destroys the internal OgreMaxScene objects 
+         * Note that this does not affect the scene manager or any resources.
+         * Those must be destroyed manually
+         */
+        void Destroy();
+
+        /** Flags that define which name prefixes to set */
+        typedef int WhichNamePrefix;
+        enum
+        {
+            OBJECT_NAME_PREFIX = 0x1,
+            NODE_NAME_PREFIX = 0x2,
+            NODE_ANIMATION_NAME_PREFIX = 0x4,
+            ALL_NAME_PREFIXES = OBJECT_NAME_PREFIX | NODE_NAME_PREFIX | NODE_ANIMATION_NAME_PREFIX
+        };
+
+        /** 
+         * Sets one or more name prefixes. This should be called before Load() is called
+         * @param name [in] - The prefix. This may be null
+         * @param prefixes [in] - Flags indicating which prefixes to set
+         */
+        void SetNamePrefix(const Ogre::String& name, WhichNamePrefix prefixes = ALL_NAME_PREFIXES);
+
+        void Update(Ogre::Real elapsedTime);
+
+        /** Gets the base resource location */
+        const Ogre::String& GetBaseResourceLocation() const;
+
+        /** 
+         * Sets the base resource location, a directory, which all other resource locations
+         * are considered to be relative to. 
+         * @param directory [in] - The base directory. If this is an empty string, resource
+         * locations loaded from the scene file are not added to the Ogre resource group manager
+         */
+        void SetBaseResourceLocation(const Ogre::String& directory);
+
+        //Various getters
+        Ogre::SceneManager* GetSceneManager();
+        Ogre::SceneNode* GetRootNode();
+
+        /**
+         * Gets the scene node with the specified name, optionally prepending the scene node name prefix
+         * @param name [in] - The name of the scene node to get
+         * @param nameIncludesPrefix [in] - Indicates whether the name already includes the prefix. If false,
+         * the scene node name prefix is used with the node name.
+         * @return The scene node with the specified name is returned
+         */
+        Ogre::SceneNode* GetSceneNode(const Ogre::String& name, bool nameIncludesPrefix);
+
+        /** Gets the up axis type */
+        Types::UpAxis GetUpAxis() const;
+
+        /** Gets the up axis vector */
+        const Ogre::Vector3& GetUpVector() const;
+
+        /** 
+         * Gets the scene scaling - in units per meter. 
+         * This will be zero if the setting was not defined in the scene file
+         */
+        Ogre::Real GetUnitsPerMeter();
+        
+        /** 
+         * Gets the scene's unit type (meters, feet, and so on). 
+         * This is a descriptive string that may contain an additional divide factor 
+         */
+        const Ogre::String GetUnitType();
+
+        /** Gets the extra data associated with the scene */
+        const Types::ObjectExtraData& GetSceneExtraData() const;
+
+        /** Gets the extra data associated with the terrain */
+        const Types::ObjectExtraData& GetTerrainExtraData() const;
+
+        /** Gets the extra data associated with the sky box */
+        const Types::ObjectExtraData& GetSkyBoxExtraData() const;
+
+        /** Gets the extra data associated with the sky dome */
+        const Types::ObjectExtraData& GetSkyDomeExtraData() const;
+
+        /** Gets the extra data associated with the sky plane */
+        const Types::ObjectExtraData& GetSkyPlaneExtraData() const;
+
+        typedef std::list<Types::ExternalItem> ExternalItemList;
+
+        /** Gets the list of external items */
+        const ExternalItemList& GetExternalItems() const;
+
+        /** Gets the background color */
+        const Ogre::ColourValue& GetBackgroundColor() const;
+
+        /** Gets the environment near range */
+        Ogre::Real GetEnvironmentNear() const;
+
+        /** Gets the environment far range */
+        Ogre::Real GetEnvironmentFar() const;
+
+        /** Gets the loaded fog settings */
+        const Types::FogParameters& GetFogParameters() const;
+
+        /** Gets plane object used as the current shadow optimal plane */
+        Ogre::MovablePlane* GetShadowOptimalPlane();
+
+        /** Gets the plane object with the specified name */
+        Ogre::MovablePlane* GetMovablePlane(const Ogre::String& name);
+        
+        typedef std::map<const Ogre::String, Ogre::AnimationState*> AnimationStates;
+
+        /** Gets all the animation states created by the scene */
+        AnimationStates& GetAnimationStates();
+
+        /** Gets the animation state created by the scene with the specified name */
+        Ogre::AnimationState* GetAnimationState(const Ogre::String& animationName);
+        
+        typedef std::map<const Ogre::MovableObject*, Types::ObjectExtraDataPtr> ObjectExtraDataMap;
+
+        /** Gets the collection of extra data for all Ogre::MovableObjects */
+        ObjectExtraDataMap& GetAllObjectExtraData();
+
+        typedef std::map<const Ogre::Node*, Types::ObjectExtraDataPtr> NodeObjectExtraDataMap;
+
+        /** Gets the collection of extra data for all Ogre::Nodes */
+        NodeObjectExtraDataMap& GetAllNodeObjectExtraData();
+
+        typedef std::map<const Ogre::String, OgreMaxModel*> ModelMap;
+
+        /** Gets the collection of all model templates, each of which is keyed by file name */
+        const ModelMap& GetModelMap() const;
+
+        /** Gets the model template with the specified file name, loading it if it isn't already loaded */
+        OgreMaxModel* GetModel(const Ogre::String& fileName);
+
+        /** Gets the collection of scene query flag aliases */
+        const Types::FlagAliases& GetQueryFlagAliases() const;
+
+        /** Gets the collection of scene visibility flag aliases */
+        const Types::FlagAliases& GetVisibilityFlagAliases() const;
+
+        /** A single resource location */
+        class ResourceLocation
+        {    
+        public:
+            ResourceLocation()
+            {
+                this->recursive = false;
+                this->initialized = false;
+            }
+
+            ResourceLocation
+                (
+                const Ogre::String& name, 
+                const Ogre::String& type, 
+                bool recursive = false
+                )
+            {
+                this->name = name;
+                this->type = type;
+                this->recursive = recursive;
+                this->initialized = false;
+            }
+            
+            bool operator < (const ResourceLocation& other) const
+            {
+                return this->name < other.name;
+            }
+
+            Ogre::String name;    
+            Ogre::String type;
+            bool recursive;
+
+        private:
+            friend class OgreMaxScene;
+
+            bool initialized;
+        };
+
+        /** 
+         * Adds a new resource location. 
+         * The new resource location isn't visible to Ogre until CommitResourceLocations() is called
+         */
+        bool AddResourceLocation(const ResourceLocation& resourceLocation);
+
+        /** Adds new resource locations to Ogre3D's resource group manager */
+        void CommitResourceLocations();
+
+        typedef std::set<ResourceLocation> ResourceLocations;
+
+        /** Gets the resource locations that were configured through the scene */
+        const ResourceLocations& GetResourceLocations() const;
+        
+        /** Gets the extra data, if any, for the specified object */
+        Types::ObjectExtraData* GetObjectExtraData(const Ogre::MovableObject* object) const;
+
+        /** 
+         * Gets the extra data, if any, for the specified node 
+         * This only works for nodes that were exported as 'empty'
+         */
+        Types::ObjectExtraData* GetObjectExtraData(const Ogre::Node* node) const;
+
+        /** For internal use only */
+        void HandleNewObjectExtraData(Types::ObjectExtraDataPtr objectExtraData);
+
+        /** This is to be called if you manually destroy a scene node */
+        void DestroyedSceneNode(const Ogre::SceneNode* node);
+
+        /** This is to be called if you manually destroy a movable object (entity, light, camera, etc.)*/
+        void DestroyedObject(const Ogre::MovableObject* object);
+
+    protected:
+        /** 
+         * Loads a scene from the specified XML element
+         * @param objectElement [in] - The 'scene' XML element
+         */
+        void Load
+            (
+            TiXmlElement* objectElement, 
+            OgreMaxRenderWindowIterator& renderWindows,
+            LoadOptions loadOptions = NO_OPTIONS,
+            Ogre::SceneManager* sceneManager = 0, 
+            Ogre::SceneNode* rootNode = 0,
+            OgreMaxSceneCallback* callback = 0,
+            const Ogre::String& defaultResourceGroupName = Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME            
+            );
+
+        //Ogre::RenderTargetListener methods
+        void preRenderTargetUpdate(const Ogre::RenderTargetEvent& e);
+        void postRenderTargetUpdate(const Ogre::RenderTargetEvent& e);
+
+        /**
+         * Determines the name of an object stored in an XML element. The name is
+         * presumed to be for a new object, so if the name is not unique an exception is thrown
+         * @param objectElement [in] - The XML element that contains the object
+         * @param node [in] - The scene node that will contain the object once it's 
+         * parsed from the XML element.
+         * @return If the XML element contains the 'name' attribute, that attribute's value is returned.
+         * Otherwise the parent node's name is returned
+         */
+        Ogre::String GetNewObjectName(const TiXmlElement* objectElement, Ogre::SceneNode* node);
+
+        /** Updates the progress for the specified progress calculator. */
+        void UpdateLoadProgress(ProgressCalculator* calculator, Ogre::Real amount);
+
+        void LoadScene(const TiXmlElement* objectElement);
+        void FinishLoadingLookAndTrackTargets();
+        
+        bool LoadResourceLocations(const TiXmlElement* objectElement);        
+        void LoadInstancedGeometries(const TiXmlElement* objectElement);
+        void LoadInstancedGeometry(const TiXmlElement* objectElement);
+        void LoadInstancedGeometryEntity(const TiXmlElement* objectElement, Ogre::InstancedGeometry* instancedGeometry);
+        void LoadStaticGeometries(const TiXmlElement* objectElement);
+        void LoadStaticGeometry(const TiXmlElement* objectElement);
+        void LoadStaticGeometryEntity(const TiXmlElement* objectElement, Ogre::StaticGeometry* staticGeometry);
+        void LoadPortalConnectedZones(const TiXmlElement* objectElement);
+
+        void LoadNodes(const TiXmlElement* objectElement);
+        void LoadQueryFlagAliases(const TiXmlElement* objectElement);
+        void LoadVisibilityFlagAliases(const TiXmlElement* objectElement);
+        void LoadExternals(const TiXmlElement* objectElement);
+        void LoadEnvironment(const TiXmlElement* objectElement);
+        void LoadRenderTextures(const TiXmlElement* objectElement);
+        void FinishLoadingRenderTextures();
+        void GetRenderTextureObjects(Types::LoadedRenderTexture* loadedRenderTexture);
+        void LoadTerrain(const TiXmlElement* objectElement);
+        void LoadOctree(const TiXmlElement* objectElement);
+
+        void LoadNode(const TiXmlElement* objectElement, Ogre::SceneNode* parentNode);
+        
+        void LoadFog(const TiXmlElement* objectElement);
+        void LoadSkyBox(const TiXmlElement* objectElement);
+        void LoadSkyDome(const TiXmlElement* objectElement);
+        void LoadSkyPlane(const TiXmlElement* objectElement);
+        void LoadClipping(const TiXmlElement* objectElement, Ogre::Real& nearClip, Ogre::Real& farClip);
+        void LoadShadows(const TiXmlElement* objectElement);
+        void LoadExternalItem(const TiXmlElement* objectElement);
+
+        void LoadEntity(const TiXmlElement* objectElement, const Types::MovableObjectOwner& owner);
+        void LoadLight(const TiXmlElement* objectElement, const Types::MovableObjectOwner& owner);
+        void LoadCamera(const TiXmlElement* objectElement, const Types::MovableObjectOwner& owner);
+        void LoadParticleSystem(const TiXmlElement* objectElement, const Types::MovableObjectOwner& owner);
+        void LoadBillboardSet(const TiXmlElement* objectElement, const Types::MovableObjectOwner& owner);
+        void LoadPlane(const TiXmlElement* objectElement, const Types::MovableObjectOwner& owner);
+        
+        void LoadBoneAttachments(const TiXmlElement* objectElement, Ogre::Entity* entity);
+        void LoadBoneAttachment(const TiXmlElement* objectElement, Ogre::Entity* entity);
+        void LoadLookTarget(const TiXmlElement* objectElement, Ogre::SceneNode* node, Ogre::Camera* camera);
+        void LoadTrackTarget(const TiXmlElement* objectElement, Ogre::SceneNode* node, Ogre::Camera* camera);
+
+        void LoadBillboard(const TiXmlElement* objectElement, Ogre::BillboardSet* billboardSet);
+        void LoadLightRange(const TiXmlElement* objectElement, Ogre::Light* light);
+        void LoadLightAttenuation(const TiXmlElement* objectElement, Ogre::Light* light);
+        
+        void LoadNodeAnimations(const TiXmlElement* objectElement, Ogre::SceneNode* node);
+        void LoadNodeAnimation(const TiXmlElement* objectElement, Ogre::SceneNode* node);
+        void LoadNodeAnimationKeyFrame(const TiXmlElement* objectElement, Ogre::NodeAnimationTrack* animationTrack);
+
+        void LoadObjectNames(const TiXmlElement* objectElement, const Ogre::String& elementName, std::vector<Ogre::String>& names);
+        
+        void LoadRenderTextureMaterials
+            (
+            const TiXmlElement* childElement, 
+            std::vector<Types::RenderTextureParameters::Material>& materials
+            );
+
+        Ogre::ShadowCameraSetup* ParseShadowCameraSetup(const Ogre::String& type, Ogre::Plane optimalPlane);                
+
+    protected:
+        LoadOptions loadOptions;
+        OgreMaxRenderWindowIterator* renderWindows;
+        Ogre::SceneManager* sceneManager;
+        Ogre::SceneNode* rootNode;
+        OgreMaxSceneCallback* callback;
+        Ogre::String defaultResourceGroupName;
+
+        Ogre::String baseResourceLocation;
+        bool loadedFromFileSystem;
+        
+        Types::ObjectExtraData sceneExtraData;
+        Version formatVersion;
+        Version minOgreVersion;
+        Ogre::String author;
+        Types::UpAxis upAxis;
+        Ogre::Real unitsPerMeter;
+        Ogre::String unitType;
+
+        Types::ObjectExtraData terrainExtraData;
+        Types::ObjectExtraData skyBoxExtraData;
+        Types::ObjectExtraData skyDomeExtraData;
+        Types::ObjectExtraData skyPlaneExtraData;
+        
+        ExternalItemList externalItems;
+
+        Ogre::ColourValue backgroundColor;
+
+        Ogre::Real environmentNear;
+        Ogre::Real environmentFar;
+
+        Types::FogParameters fogParameters;
+
+        Ogre::MovablePlane* shadowOptimalPlane;
+
+        /** Movable planes that were created when loading Ogre plane objects */
+        typedef std::map<Ogre::String, Ogre::MovablePlane*> MovablePlanesMap;
+        MovablePlanesMap movablePlanes;
+        
+        /** The objects that were explicitly loaded from the scene file */
+        std::map<Ogre::String, Ogre::MovableObject*> loadedObjects;
+
+        /** Tracks scene loading progress. */
+        class LoadSceneProgressCalculator : public ProgressCalculator
+        {
+        public:
+            LoadSceneProgressCalculator()
+            {
+                this->nodes = AddCalculator("nodes");
+                this->externals = AddCalculator("externals");    
+            }
+
+        public:
+            //Child calculators
+            ProgressCalculator* nodes;
+            ProgressCalculator* externals;
+        };
+        LoadSceneProgressCalculator loadProgress;
+
+        /** Look target information, encountered during the loading of a scene */
+        typedef std::list<Types::LookTarget> LookTargetList;
+        LookTargetList lookTargets;
+
+        /** Track target information, encountered during the loading of a scene */
+        typedef std::list<Types::TrackTarget> TrackTargetList;
+        TrackTargetList trackTargets;
+        
+        /** The created animation states */
+        AnimationStates animationStates;
+
+        /** 
+         * A lookup table for all the ObjectExtraData created for each object
+         * This will be destroyed when the OgreMaxScene is destroyed, so if you
+         * would like to keep this data, it should be 'stolen' by calling 
+         * GetAllObjectExtraData(), copying the values, then clearing the values
+         * that are contained in the OgreMaxScene
+         */
+        ObjectExtraDataMap allObjectExtraData;
+
+        /** 
+         * A lookup table for all the ObjectExtraData created for each object
+         */        
+        NodeObjectExtraDataMap allNodeObjectExtraData;
+
+        /**
+         * A lookup table for all the models that have been loaded
+         */
+        ModelMap modelMap;
+
+        /** 
+         * The index into the first unused element in loadedRenderTextures 
+         * Used during the loading process
+         */
+        size_t currentRenderTextureIndex;
+
+        /** All the render textures */
+        std::vector<Types::LoadedRenderTexture*> loadedRenderTextures;
+
+        /** 
+         * All the render textures, keyed by the corresponding render targets
+         * The pointers reference the entries in loadedRenderTextures
+         */
+        typedef std::map<Ogre::RenderTarget*, Types::LoadedRenderTexture*> RenderTargetMap;
+        RenderTargetMap renderTargets;
+
+        /** The query flag aliases */
+        Types::FlagAliases queryFlags;
+
+        /** The visibility flag aliases */
+        Types::FlagAliases visibilityFlags;
+
+        /** The active scheme, saved before a render texture update and restored after */
+        Ogre::String previousActiveScheme;
+
+        //Various name prefixes
+        Ogre::String objectNamePrefix;
+        Ogre::String nodeNamePrefix;
+        Ogre::String nodeAnimationNamePrefix;
+        
+        /** Loaded resource locations */        
+        ResourceLocations resourceLocations;
+    };
+
+    /** A interface that receives notifications during the loading of the scene */
+    class OgreMaxSceneCallback
+    {   
+    public:
+        virtual ~OgreMaxSceneCallback() {}
+        
+        /** Called before a scene is to be loaded. */
+        virtual void StartedLoad(const OgreMaxScene* scene) {}
+
+        virtual void CreatedSceneManager(const OgreMaxScene* scene, Ogre::SceneManager* sceneManager) {}
+
+        virtual void CreatedExternal(const OgreMaxScene* scene, const OgreMax::Types::ExternalItem& item) {}
+
+        virtual void LoadingResourceLocations(const OgreMaxScene* scene) {}
+        virtual void LoadedResourceLocations(const OgreMaxScene* scene, const OgreMaxScene::ResourceLocations& resourceLocations) {}
+
+        //Resource-based callbacks, called before a resource is created
+        //The main purpose of these callbacks is to get the resource group name for the 
+        //resource being loaded, though other parameters may be modified as well
+        virtual void LoadingRenderTexture(const OgreMaxScene* scene, OgreMax::Types::RenderTextureParameters& renderTextureParameters) {}
+        virtual void LoadingSceneFile(const OgreMaxScene* scene, const Ogre::String& fileName, Ogre::String& resourceGroupName) {}
+        virtual void LoadingSkyBox(const OgreMaxScene* scene, OgreMax::Types::SkyBoxParameters& skyBoxParameters) {}
+        virtual void LoadingSkyDome(const OgreMaxScene* scene, OgreMax::Types::SkyDomeParameters& skyDomeParameters) {}
+        virtual void LoadingSkyPlane(const OgreMaxScene* scene, OgreMax::Types::SkyPlaneParameters& skyPlaneParameters) {}
+        virtual void LoadingEntity(const OgreMaxScene* scene, OgreMax::Types::EntityParameters& parameters) {}
+        virtual void LoadingPlane(const OgreMaxScene* scene, OgreMax::Types::PlaneParameters& parameters) {}
+
+        /**
+         * Called right before an Ogre animation is created. The parameters may be modified. 
+         * In particular modifying the length is useful in cases where there are multiple node animation 
+         * tracks on the animation, each of which starts and ends at different times.
+         */
+        virtual void LoadingNodeAnimation(const OgreMaxScene* scene, Types::NodeAnimationParameters& parameters) {}
+                
+        //MovableObject-creation callbacks, called after an object has been created
+        //These are called after the object was attached to its parent node, if there is a parent node
+        virtual void CreatedLight(const OgreMaxScene* scene, Ogre::Light* light) {CreatedMovableObject(scene, light);}
+        virtual void CreatedCamera(const OgreMaxScene* scene, Ogre::Camera* camera) {CreatedMovableObject(scene, camera);}
+        virtual void CreatedMesh(const OgreMaxScene* scene, Ogre::Mesh* mesh) {}
+        virtual void CreatedEntity(const OgreMaxScene* scene, Ogre::Entity* entity) {CreatedMovableObject(scene, entity);}
+        virtual void CreatedParticleSystem(const OgreMaxScene* scene, Ogre::ParticleSystem* particleSystem) {CreatedMovableObject(scene, particleSystem);}
+        virtual void CreatedBillboardSet(const OgreMaxScene* scene, Ogre::BillboardSet* billboardSet) {CreatedMovableObject(scene, billboardSet);}
+        virtual void CreatedPlane(const OgreMaxScene* scene, const Ogre::Plane& plane, Ogre::Entity* entity) {CreatedMovableObject(scene, entity);}
+        virtual void CreatedMovableObject(const OgreMaxScene* scene, Ogre::MovableObject* object) {}
+        
+        virtual void CreatedNodeAnimation(const OgreMaxScene* scene, Ogre::SceneNode* Node, Ogre::Animation* animation) {}
+        virtual void CreatedNodeAnimationTrack(const OgreMaxScene* scene, Ogre::SceneNode* node, Ogre::AnimationTrack* animationTrack, bool enabled, bool looping) {}
+        virtual void CreatedNodeAnimationState(const OgreMaxScene* scene, Ogre::SceneNode* node, Ogre::AnimationState* animationState) {}
+
+        //Render texture creation callbacks
+        virtual Ogre::Camera* GetRenderTextureCamera(const OgreMaxScene* scene, const OgreMax::Types::RenderTextureParameters& renderTextureParameters) {return 0;}
+
+        virtual void CreatedRenderTexture(const OgreMaxScene* scene, const OgreMax::Types::LoadedRenderTexture* renderTexture) {}
+
+        /** Called after a node is created, but before its entities or any child nodes have been created */
+        virtual void StartedCreatingNode(const OgreMaxScene* scene, Ogre::SceneNode* node) {}
+
+        /** Called after the node and all its entities and child nodes have been created */
+        virtual void FinishedCreatingNode(const OgreMaxScene* scene, Ogre::SceneNode* node) {}
+
+        virtual void CreatedTerrain(const OgreMaxScene* scene, const Ogre::String& dataFile) {}
+
+        virtual void HandleObjectExtraData(Types::ObjectExtraDataPtr objectExtraData) {}
+
+        //Progress callback
+        virtual void UpdatedLoadProgress(const OgreMaxScene* scene, Ogre::Real progress) {}
+
+        /** 
+         * Called after a scene is loaded. 
+         * @param scene [in] - The scene that was loaded
+         * @param success [in] - Indicates whether the scene was successfully loaded. False 
+         * indicates an error occurred.
+         */
+        virtual void FinishedLoad(const OgreMaxScene* scene, bool success) {}            
+
+        /**
+         * Notifies the caller that shadow textures are about to be created
+         * @param scene [in] - The scene that was loaded
+         * @param parameters [in/out] - The shadow parameters that are in effect. Any of the texture-related 
+         * parameters can be modified. The most typical one to be modified is the texture pixel format.
+         */
+        virtual void CreatingShadowTextures(const OgreMaxScene* scene, Types::ShadowParameters& shadowParameters) {}
+    };
+
+}
+
+#endif

Dependencies/OgreMax/inc/OgreMaxTypes.hpp

+/*
+ * OgreMaxViewer - An Ogre 3D-based viewer for .scene and .mesh files
+ * Copyright 2008 Derek Nedelman
+ *
+ * This code is available under the OgreMax Free License:
+ *   -You may use this code for any purpose, commercial or non-commercial.
+ *   -If distributing derived works (that use this source code) in binary or source code form, 
+ *    you must give the following credit in your work's end-user documentation: 
+ *        "Portions of this work provided by OgreMax (www.ogremax.com)"
+ *
+ * Derek Nedelman assumes no responsibility for any harm caused by using this code.
+ * 
+ * OgreMaxViewer was written by Derek Nedelman and released at www.ogremax.com 
+ */
+
+#ifndef OgreMax_OgreMaxTypes_INCLUDED
+#define OgreMax_OgreMaxTypes_INCLUDED
+
+
+//Includes---------------------------------------------------------------------
+#include "tinyxml.h"
+#include <OgreString.h>
+#include <OgreStringConverter.h>
+#include <OgreMaterial.h>
+#include <OgreVector3.h>
+#include <OgreVector4.h>
+#include <OgrePlane.h>
+#include <OgreQuaternion.h>
+#include <OgreHardwareBuffer.h>
+#include <OgreRenderQueue.h>
+#include <OgreLight.h>
+#include <OgreCamera.h>
+#include <OgreBillboardSet.h>
+#include <OgrePixelFormat.h>
+#include <OgreAnimation.h>
+#include <OgreAnimationState.h>
+#include <OgreTexture.h>
+#include <OgreSceneNode.h>
+#include <OgreEntity.h>
+#include <OgreTagPoint.h>
+#include <OgreSkeletonInstance.h>
+
+
+//Classes----------------------------------------------------------------------
+namespace OgreMax
+{   
+    namespace Types
+    {
+        enum UpAxis
+        {
+            UP_AXIS_Y,
+            UP_AXIS_Z
+        };
+
+        enum NodeVisibility
+        {
+            NODE_VISIBILITY_DEFAULT,
+            NODE_VISIBLE,
+            NODE_HIDDEN,
+            NODE_TREE_VISIBLE,
+            NODE_TREE_HIDDEN
+        };
+
+        enum ObjectVisibility
+        {
+            OBJECT_VISIBILITY_DEFAULT,
+            OBJECT_VISIBLE,
+            OBJECT_HIDDEN
+        };
+
+        /** A custom parameter for renderables */
+        struct CustomParameter
+        {
+            size_t id;
+            Ogre::Vector4 value;
+        };
+
+        /** A simple bounding volume, centered around the owner's origin */
+        struct BoundingVolume
+        {
+            BoundingVolume()
+            {
+                this->type = NONE;
+                this->sphereRadius = 0;
+                this->boxSize = Ogre::Vector3::ZERO;
+            }
+
+            enum Type
+            {
+                NONE,
+                SPHERE,
+                BOX,
+                MESH
+            };
+
+            /** The bounding volume type */
+            Type type;
+
+            /** The bounding sphere radius. Used when 'type' is SPHERE */
+            Ogre::Real sphereRadius;
+
+            /** The bounding box size. Used when 'type' is BOX */
+            Ogre::Vector3 boxSize;
+
+            /** A single face */
+            struct Face
+            {
+                Ogre::Vector3 vertex[3];
+            };
+
+            /** Faces of the mesh bounding volume. Used when 'type' is MESH */
+            std::vector<Face> meshFaces;
+        };
+
+        /** A single note in a note track */
+        struct Note
+        {
+            Ogre::Real time;
+            Ogre::String text;
+        };
+
+        /** A collection of notes */
+        struct NoteTrack
+        {
+            Ogre::String name;
+            std::vector<Note> notes;
+        };
+
+        /** A collection of note tracks */
+        typedef std::vector<NoteTrack> NoteTracks;
+
+        typedef Ogre::SharedPtr<NoteTracks> NoteTracksPtr;
+
+        /** A single external item. */
+        struct ExternalItem
+        {      
+            ExternalItem()
+            {
+                this->position = Ogre::Vector3::ZERO;                
+                this->scale = Ogre::Vector3::UNIT_SCALE;
+            }
+
+            Ogre::String name;
+            Ogre::String type;            
+            Ogre::String file;
+            Ogre::String userDataReference;
+            Ogre::String userData;
+            Ogre::Vector3 position;
+            Ogre::Quaternion rotation;
+            Ogre::Vector3 scale;
+            BoundingVolume boundingVolume;
+            NoteTracks noteTracks;
+        };
+
+        /** 
+         * Extra data placed for a various object types.
+         * Depending on the context and type of object, some of the fields in this structure might not be used
+         */
+        struct ObjectExtraData
+        {
+            ObjectExtraData()
+            {
+                this->node = 0;
+                this->object = 0;
+                this->receiveShadows = false;
+            }
+
+            /** 
+             * Initializes the data from another data object 
+             * Note that the object/node fields aren't copied
+             */
+            ObjectExtraData(ObjectExtraData& other)
+            {
+                this->node = 0;
+                this->object = 0;
+                this->id = other.id;
+                this->userDataReference = other.userDataReference;
+                this->userData = other.userData;
+                this->receiveShadows = other.receiveShadows;            
+                this->receiveShadows = other.receiveShadows;
+                this->noteTracks = other.noteTracks;                
+            }
+
+            /** Determines if there is any user data */
+            bool HasUserData() const
+            {
+                return !this->id.empty() || !this->userDataReference.empty() || !this->userData.empty();
+            }
+
+            /** If set, the extra data belongs to an Ogre::Node */
+            Ogre::Node* node;
+
+            /** If set, the extra data belongs to an Ogre::MovableObject */
+            Ogre::MovableObject* object;
+
+            Ogre::String id;
+            Ogre::String userDataReference;
+            Ogre::String userData;
+            bool receiveShadows;                        
+            NoteTracksPtr noteTracks;
+        };
+
+        typedef Ogre::SharedPtr<ObjectExtraData> ObjectExtraDataPtr;
+
+        struct FogParameters
+        {
+            FogParameters()
+            {  
+                this->mode = Ogre::FOG_NONE;
+
+                this->expDensity = .001;
+                this->linearStart = 0;
+                this->linearEnd = 1;    
+
+                this->color = Ogre::ColourValue::White;
+            }
+
+            Ogre::FogMode mode;
+
+            Ogre::Real expDensity;
+            Ogre::Real linearStart;
+            Ogre::Real linearEnd;
+                
+            Ogre::ColourValue color;
+        };
+    
+        struct SkyBoxParameters
+        {
+            SkyBoxParameters()
+            {
+                this->enabled = true;
+                this->distance = 0;
+                this->drawFirst = true;                        
+            }
+
+            bool enabled;
+            Ogre::String material;
+            Ogre::Real distance;
+            bool drawFirst;
+            Ogre::Quaternion rotation;
+            Ogre::String resourceGroupName;
+            ObjectExtraData extraData;
+        };
+
+        struct SkyDomeParameters
+        {
+            SkyDomeParameters()
+            {
+                this->enabled = true;
+                this->curvature = 0;
+                this->tiling = 0;
+                this->distance = 0;
+                this->drawFirst = true;
+                this->xSegments = 0;
+                this->ySegments = 0;                
+            }
+
+            bool enabled;
+            Ogre::String material;
+            Ogre::Real curvature;
+            Ogre::Real tiling;
+            Ogre::Real distance;
+            bool drawFirst;
+            int xSegments;
+            int ySegments;
+            Ogre::Quaternion rotation;
+            Ogre::String resourceGroupName;
+            ObjectExtraData extraData;
+        };
+
+        struct SkyPlaneParameters
+        {
+            SkyPlaneParameters()
+            {
+                this->enabled = true;
+                this->scale = 1;                
+                this->bow = 0;
+                this->tiling = 10;                
+                this->drawFirst = true;
+                this->xSegments = 1;
+                this->ySegments = 1;                
+            }
+
+            bool enabled;
+            Ogre::String material;
+            Ogre::Plane plane;
+            Ogre::Real scale;
+            Ogre::Real bow;
+            Ogre::Real tiling;
+            bool drawFirst;
+            int xSegments;
+            int ySegments;
+            Ogre::String resourceGroupName;
+            ObjectExtraData extraData;
+        };
+
+        struct ObjectParameters
+        {
+            enum ObjectType
+            {
+                NONE,
+                ENTITY,
+                LIGHT,
+                CAMERA,
+                PARTICLE_SYSTEM,
+                BILLBOARD_SET,
+                PLANE
+            };
+
+            ObjectParameters()
+            {
+                this->objectType = NONE;                                
+                this->renderQueue = Ogre::RENDER_QUEUE_MAIN;
+                this->renderingDistance = 0;
+                this->queryFlags = 0;
+                this->visibilityFlags = 0;
+                this->visibility = OBJECT_VISIBILITY_DEFAULT;
+            }
+
+            virtual ~ObjectParameters() 
+            {
+            }
+
+            /** Name of the object */
+            Ogre::String name;
+
+            /** 
+             * The object type. 
+             * This can be used to determine which ObjectParameters subclass can be used
+             */
+            ObjectType objectType;
+
+            /** The object's extra data */
+            ObjectExtraDataPtr extraData;
+
+            /** Object query flags */
+            Ogre::uint32 queryFlags;
+
+            /** Object visibility flags */
+            Ogre::uint32 visibilityFlags;
+
+            /** Indicates whether object is visible */
+            ObjectVisibility visibility;
+
+            /** Rendering queue. Not used by all types */
+            Ogre::uint8 renderQueue;
+
+            /** Rendering distance. Not used by all types */
+            Ogre::Real renderingDistance;
+
+            typedef std::vector<CustomParameter> CustomParameters;
+
+            /** Custom values. Not used by all types */
+            CustomParameters customParameters;
+        };
+
+        struct EntityParameters : ObjectParameters
+        {
+            EntityParameters()
+            {
+                this->objectType = ENTITY;
+
+                this->castShadows = true;
+
+                this->vertexBufferUsage = Ogre::HardwareBuffer::HBU_STATIC_WRITE_ONLY;
+	            this->indexBufferUsage = Ogre::HardwareBuffer::HBU_STATIC_WRITE_ONLY;
+	            this->vertexBufferShadowed = true;
+                this->indexBufferShadowed = true;
+            }
+
+            Ogre::String meshFile;
+            Ogre::String materialFile;    
+            bool castShadows;
+
+            Ogre::HardwareBuffer::Usage vertexBufferUsage;
+	        Ogre::HardwareBuffer::Usage indexBufferUsage;
+	        bool vertexBufferShadowed;
+            bool indexBufferShadowed;
+
+            Ogre::String resourceGroupName;
+
+            struct Subentity
+            {
+                Ogre::String materialName;
+            };
+            std::vector<Subentity> subentities;
+
+            struct BoneAttachment
+            {
+                BoneAttachment()
+                {
+                    this->object = 0;
+                    this->attachPosition = Ogre::Vector3::ZERO;
+                    this->attachScale = Ogre::Vector3::UNIT_SCALE;
+                    this->attachRotation = Ogre::Quaternion::IDENTITY;
+                }
+
+                ~BoneAttachment()
+                {
+                    delete this->object;
+                }
+
+                /** Gets the name of the attachment itself */
+                const Ogre::String& GetName() const
+                {
+                    return this->object != 0 ? this->object->name : this->name;
+                }
+
+                Ogre::String name; //Used if object is null
+                Ogre::String boneName;
+                ObjectParameters* object;
+                Ogre::Vector3 attachPosition;
+                Ogre::Vector3 attachScale;
+                Ogre::Quaternion attachRotation;
+            };
+            std::vector<BoneAttachment> boneAttachments;
+        };
+
+        struct LightParameters : ObjectParameters
+        {
+            LightParameters()
+            {
+                this->objectType = LIGHT;
+
+                this->lightType = Ogre::Light::LT_POINT;
+                this->castShadows = false;
+                this->power = 1;
+                
+                this->diffuseColor = Ogre::ColourValue::White;
+                this->specularColor = Ogre::ColourValue::Black;
+                
+                this->spotlightInnerAngle = Ogre::Degree((Ogre::Real)40);
+                this->spotlightOuterAngle = Ogre::Degree((Ogre::Real)30);
+                this->spotlightFalloff = 1;
+                
+                this->attenuationRange = 100000;
+                this->attenuationConstant = 1;
+                this->attenuationLinear = 0;            
+                this->attenuationQuadric = 0;
+
+                this->position = Ogre::Vector3::ZERO;
+                this->direction = Ogre::Vector3::UNIT_Z;
+            }
+
+            Ogre::Light::LightTypes lightType;
+            bool castShadows;
+            Ogre::Real power;
+
+            Ogre::ColourValue diffuseColor;
+            Ogre::ColourValue specularColor;
+
+            Ogre::Radian spotlightInnerAngle;
+            Ogre::Radian spotlightOuterAngle;
+            Ogre::Real spotlightFalloff;
+
+            Ogre::Real attenuationRange;
+            Ogre::Real attenuationConstant;
+            Ogre::Real attenuationLinear;            
+            Ogre::Real attenuationQuadric;
+
+            Ogre::Vector3 position;
+            Ogre::Vector3 direction;
+        };
+
+        struct CameraParameters : ObjectParameters
+        {
+            CameraParameters()
+            {
+                this->objectType = CAMERA;
+
+                this->fov = Ogre::Radian(Ogre::Math::PI/2);
+                this->aspectRatio = (Ogre::Real)1.33;
+                this->projectionType = Ogre::PT_PERSPECTIVE;
+
+                this->nearClip = 100;
+                this->farClip = 100000;
+
+                this->position = Ogre::Vector3::ZERO;
+                this->direction = Ogre::Vector3::NEGATIVE_UNIT_Z;
+            }
+
+            Ogre::Radian fov;
+            Ogre::Real aspectRatio;
+            Ogre::ProjectionType projectionType;
+            
+            Ogre::Real nearClip;
+            Ogre::Real farClip;
+
+            Ogre::Vector3 position;
+            Ogre::Quaternion orientation;
+            Ogre::Vector3 direction;
+        };
+
+        struct ParticleSystemParameters : ObjectParameters
+        {
+            ParticleSystemParameters()
+            {
+                this->objectType = PARTICLE_SYSTEM;
+            }
+
+            Ogre::String file;
+        };
+
+        struct BillboardSetParameters : ObjectParameters
+        {
+            BillboardSetParameters()
+            {
+                this->objectType = BILLBOARD_SET;
+                this->commonDirection = Ogre::Vector3::UNIT_Z;
+                this->commonUpVector = Ogre::Vector3::UNIT_Y;
+                this->billboardType = Ogre::BBT_POINT;
+                this->origin = Ogre::BBO_CENTER;
+                this->rotationType = Ogre::BBR_TEXCOORD;
+                this->poolSize = 0;
+                this->autoExtendPool = true;
+                this->cullIndividual = false;
+                this->sort = false;
+                this->accurateFacing = false;
+            }
+
+            Ogre::String material;
+            Ogre::Real width;
+            Ogre::Real height;
+            Ogre::BillboardType billboardType;
+            Ogre::BillboardOrigin origin;
+            Ogre::BillboardRotationType rotationType;
+            Ogre::Vector3 commonDirection;
+            Ogre::Vector3 commonUpVector;
+            Ogre::uint32 poolSize;
+            bool autoExtendPool;
+            bool cullIndividual;
+            bool sort;
+            bool accurateFacing;
+            
+            struct Billboard
+            {
+                Billboard() : texCoordRectangle(0, 0, 0, 0)
+                {
+                    this->width = 0;
+                    this->height = 0;
+                    this->rotationAngle = Ogre::Radian(0);
+
+                    this->position = Ogre::Vector3::ZERO;
+                    this->color = Ogre::ColourValue::White;
+                }
+
+                Ogre::Real width;
+                Ogre::Real height;
+                Ogre::FloatRect texCoordRectangle;
+                Ogre::Radian rotationAngle;
+
+                Ogre::Vector3 position;
+                Ogre::ColourValue color;
+            };
+            std::vector<Billboard> billboards;
+        };
+
+        struct PlaneParameters : ObjectParameters
+        {
+            PlaneParameters()
+            {
+                this->objectType = PLANE;
+
+                this->xSegments = 0;
+                this->ySegments = 0;
+                this->numTexCoordSets = 0;
+                this->uTile = 0;
+                this->vTile = 0;
+                this->normals = true;
+                this->createMovablePlane = true;
+                this->castShadows = true;
+                this->normal = Ogre::Vector3::ZERO;
+                this->upVector = Ogre::Vector3::UNIT_Z;
+
+                this->vertexBufferUsage = Ogre::HardwareBuffer::HBU_STATIC_WRITE_ONLY;
+                this->indexBufferUsage = Ogre::HardwareBuffer::HBU_STATIC_WRITE_ONLY;
+                this->vertexBufferShadowed = true;
+                this->indexBufferShadowed = true;
+            }
+
+            Ogre::String planeName;
+            Ogre::Real distance;
+            Ogre::Real width;
+            Ogre::Real height;
+            int xSegments;
+            int ySegments;
+            int numTexCoordSets;
+            Ogre::Real uTile;
+            Ogre::Real vTile;
+            Ogre::String material;
+            bool normals;
+            bool createMovablePlane;
+            bool castShadows;
+            
+            Ogre::Vector3 normal;
+            Ogre::Vector3 upVector;
+
+            Ogre::HardwareBuffer::Usage vertexBufferUsage;
+            Ogre::HardwareBuffer::Usage indexBufferUsage;
+            bool vertexBufferShadowed;
+            bool indexBufferShadowed;
+
+            Ogre::String resourceGroupName;
+        };
+
+        struct NodeAnimationParameters
+        {
+            NodeAnimationParameters()
+            {
+                this->length = 0;
+                this->interpolationMode = Ogre::Animation::IM_SPLINE;
+                this->rotationInterpolationMode = Ogre::Animation::RIM_LINEAR;
+                this->enable = true;
+                this->looping = true;
+            }
+
+            Ogre::String name;
+            Ogre::Real length;
+            Ogre::Animation::InterpolationMode interpolationMode;
+            Ogre::Animation::RotationInterpolationMode rotationInterpolationMode;
+            bool enable;
+            bool looping;
+
+            struct KeyFrame
+            {
+                KeyFrame()
+                {
+                    this->time = 0;
+                    this->translation = Ogre::Vector3::ZERO;
+                    this->scale = Ogre::Vector3::UNIT_SCALE;
+                }
+
+                Ogre::Real time;
+                Ogre::Vector3 translation;
+                Ogre::Quaternion rotation;
+                Ogre::Vector3 scale;
+            };
+            std::vector<KeyFrame> keyframes;
+        };
+
+        struct NodeParameters
+        {
+            NodeParameters()
+            {           
+                this->visibility = NODE_VISIBILITY_DEFAULT;
+                this->position = Ogre::Vector3::ZERO;
+                this->scale = Ogre::Vector3::UNIT_SCALE;                
+            }
+
+            ~NodeParameters()
+            {
+                for (Objects::iterator objectIterator = this->objects.begin();
+                    objectIterator != this->objects.end();
+                    ++objectIterator)
+                {
+                    delete *objectIterator;
+                }
+            }
+
+            /** The nodes's extra data */
+            ObjectExtraDataPtr extraData;
+
+            Ogre::String name;
+            Ogre::String modelName;
+            
+            NodeVisibility visibility;
+            
+            Ogre::Vector3 position;
+            Ogre::Quaternion orientation;
+            Ogre::Vector3 scale;
+
+            std::vector<NodeParameters> childNodes;
+
+            std::vector<NodeAnimationParameters> animations;
+
+            typedef std::list<ObjectParameters*> Objects;
+            Objects objects;
+        };
+
+        struct RenderTextureParameters
+        {
+            RenderTextureParameters()
+            {
+                this->width = this->height = 512;
+                this->pixelFormat = Ogre::PF_A8R8G8B8;
+                this->textureType = Ogre::TEX_TYPE_2D;
+                this->clearEveryFrame = true;
+                this->autoUpdate = true;
+                this->hideRenderObject = true;
+            }
+
+            Ogre::String name;
+            int width;
+            int height;
+            Ogre::PixelFormat pixelFormat;
+            Ogre::TextureType textureType;
+            Ogre::String cameraName;
+            Ogre::String scheme;
+            Ogre::ColourValue backgroundColor;
+            bool clearEveryFrame;
+            bool autoUpdate;
+            bool hideRenderObject;
+            Ogre::String renderObjectName;            
+            Ogre::Plane renderPlane;
+            std::vector<Ogre::String> hiddenObjects;
+            std::vector<Ogre::String> exclusiveObjects;
+            Ogre::String resourceGroupName;
+
+            struct Material
+            {
+                Ogre::String name;
+                unsigned short techniqueIndex;
+                unsigned short passIndex;
+                unsigned short textureUnitIndex;            
+            };
+            std::vector<Material> materials;
+        };
+
+        struct ShadowParameters
+        {
+            ShadowParameters()
+            {
+                this->shadowTechnique = Ogre::SHADOWTYPE_NONE;
+                this->selfShadow = true;
+                this->farDistance = 0;
+                this->textureSize = 512;
+                this->textureCount = 2;
+                this->textureOffset = (Ogre::Real).6;
+                this->textureFadeStart = (Ogre::Real).7;
+                this->textureFadeEnd = (Ogre::Real).9;
+                this->pixelFormat = Ogre::PF_UNKNOWN;
+                this->shadowColor = Ogre::ColourValue::Black;        
+            }
+
+            Ogre::ShadowTechnique shadowTechnique;
+            bool selfShadow;
+            Ogre::Real farDistance;
+            int textureSize;
+            int textureCount;
+            Ogre::Real textureOffset;
+            Ogre::Real textureFadeStart;
+            Ogre::Real textureFadeEnd;
+            Ogre::String textureShadowCasterMaterial;
+            Ogre::String textureShadowReceiverMaterial;
+            Ogre::PixelFormat pixelFormat;
+            Ogre::ColourValue shadowColor;                
+            Ogre::String cameraSetup;
+            Ogre::Plane optimalPlane;
+        };
+
+        struct LookTarget
+        {
+            /** 
+             * Initializes the LookTarget for a scene node or camera. 
+             * Either sourceNode or sourceCamera must be non-null
+             */
+            LookTarget(Ogre::SceneNode* sourceNode, Ogre::Camera* sourceCamera)
+            {
+                this->sourceNode = sourceNode;
+                this->sourceCamera = sourceCamera;
+                this->relativeTo = Ogre::Node::TS_LOCAL;
+                this->isPositionSet = false;
+                this->position = Ogre::Vector3::ZERO;
+                this->localDirection = Ogre::Vector3::NEGATIVE_UNIT_Z;
+            }
+
+            Ogre::SceneNode* sourceNode;
+            Ogre::Camera* sourceCamera;
+            Ogre::String nodeName;
+            Ogre::Node::TransformSpace relativeTo;
+            bool isPositionSet;
+            Ogre::Vector3 position;
+            Ogre::Vector3 localDirection;
+        };
+
+        struct TrackTarget