DotSceneLoader.h

Go to the documentation of this file.
00001 /******************************************************************************
00002 *       SOFA, Simulation Open-Framework Architecture, version 1.0 beta 3      *
00003 *                (c) 2006-2008 MGH, INRIA, USTL, UJF, CNRS                    *
00004 *                                                                             *
00005 * This program is free software; you can redistribute it and/or modify it     *
00006 * under the terms of the GNU General Public License as published by the Free  *
00007 * Software Foundation; either version 2 of the License, or (at your option)   *
00008 * any later version.                                                          *
00009 *                                                                             *
00010 * This program is distributed in the hope that it will be useful, but WITHOUT *
00011 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or       *
00012 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for    *
00013 * more details.                                                               *
00014 *                                                                             *
00015 * You should have received a copy of the GNU General Public License along     *
00016 * with this program; if not, write to the Free Software Foundation, Inc., 51  *
00017 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.                   *
00018 *******************************************************************************
00019 *                            SOFA :: Applications                             *
00020 *                                                                             *
00021 * Authors: M. Adam, J. Allard, B. Andre, P-J. Bensoussan, S. Cotin, C. Duriez,*
00022 * H. Delingette, F. Falipou, F. Faure, S. Fonteneau, L. Heigeas, C. Mendoza,  *
00023 * M. Nesme, P. Neumann, J-P. de la Plata Alcade, F. Poyer and F. Roy          *
00024 *                                                                             *
00025 * Contact information: contact@sofa-framework.org                             *
00026 ******************************************************************************/
00027 // http://www.ogre3d.org/wiki/index.php/New_DotScene_Loader
00028 
00029 #ifndef DOT_SCENELOADER_H
00030 #define DOT_SCENELOADER_H
00031 
00032 // Includes
00033 #include <OgreString.h>
00034 #include <OgreVector3.h>
00035 #include <OgreQuaternion.h>
00036 #include <OgreColourValue.h>
00037 #include <vector>
00038 
00039 // Forward declarations
00040 class TiXmlElement;
00041 
00042 namespace Ogre
00043 {
00044     // Forward declarations
00045     class SceneManager;
00046     class SceneNode;
00047 
00048     class nodeProperty
00049     {
00050     public:
00051         String nodeName;
00052         String propertyNm;
00053         String valueName;
00054         String typeName;
00055 
00056         nodeProperty(const String &node, const String &propertyName, const String &value, const String &type)
00057             : nodeName(node), propertyNm(propertyName), valueName(value), typeName(type) {}
00058     };
00059     
00060     class EnvironmentProperty
00061     {
00062     public:
00063         ColourValue ambientColour;
00064         ColourValue backgroundColour;
00065         Real farClipDistance;
00066         Real nearClipDistance;
00067     };
00068 
00069     class DotSceneLoader
00070     {
00071     public:
00072         DotSceneLoader();
00073         virtual ~DotSceneLoader() {}
00074 
00075         void parseDotScene(const String &SceneName, const String &groupName, SceneManager *yourSceneMgr, SceneNode *pAttachNode = NULL, const String &sPrependNode = "");
00076         SceneManager *getSceneManager() { return mSceneMgr; }
00077         String getProperty(const String &ndNm, const String &prop);
00078 
00079         std::vector<nodeProperty> nodeProperties;
00080         std::vector<String> staticObjects;
00081         std::vector<String> dynamicObjects;
00082         EnvironmentProperty environment;
00083 
00084     protected:
00085         void processScene(TiXmlElement *XMLRoot);
00086 
00087         void processNodes(TiXmlElement *XMLNode);
00088         void processExternals(TiXmlElement *XMLNode);
00089         void processEnvironment(TiXmlElement *XMLNode);
00090         void processTerrain(TiXmlElement *XMLNode);
00091         void processUserDataReference(TiXmlElement *XMLNode, SceneNode *pParent = 0);
00092         void processUserDataReference(TiXmlElement *XMLNode, Entity *pEntity);
00093         void processOctree(TiXmlElement *XMLNode);
00094         void processLight(TiXmlElement *XMLNode, SceneNode *pParent = 0);
00095         void processCamera(TiXmlElement *XMLNode, SceneNode *pParent = 0);
00096 
00097         void processNode(TiXmlElement *XMLNode, SceneNode *pParent = 0);
00098         void processLookTarget(TiXmlElement *XMLNode, SceneNode *pParent);
00099         void processTrackTarget(TiXmlElement *XMLNode, SceneNode *pParent);
00100         void processLookTarget(TiXmlElement *XMLNode, Camera *pParent);
00101         void processTrackTarget(TiXmlElement *XMLNode, Camera *pParent);
00102         void processEntity(TiXmlElement *XMLNode, SceneNode *pParent);
00103         void processParticleSystem(TiXmlElement *XMLNode, SceneNode *pParent);
00104         void processBillboardSet(TiXmlElement *XMLNode, SceneNode *pParent);
00105         void processPlane(TiXmlElement *XMLNode, SceneNode *pParent);
00106 
00107         void processFog(TiXmlElement *XMLNode);
00108         void processSkyBox(TiXmlElement *XMLNode);
00109         void processSkyDome(TiXmlElement *XMLNode);
00110         void processSkyPlane(TiXmlElement *XMLNode);
00111         void processClipping(TiXmlElement *XMLNode, Camera* pCamera = 0);
00112 
00113         void processLightRange(TiXmlElement *XMLNode, Light *pLight);
00114         void processLightAttenuation(TiXmlElement *XMLNode, Light *pLight);
00115 
00116         String getAttrib(TiXmlElement *XMLNode, const String &parameter, const String &defaultValue = "");
00117         Real getAttribReal(TiXmlElement *XMLNode, const String &parameter, Real defaultValue = 0);
00118         int getAttribInt(TiXmlElement *XMLNode, const String &parameter, int defaultValue = 0);
00119         bool getAttribBool(TiXmlElement *XMLNode, const String &parameter, bool defaultValue = false);
00120 
00121         Vector3 parseVector3(TiXmlElement *XMLNode);
00122         Quaternion parseQuaternion(TiXmlElement *XMLNode);
00123         ColourValue parseColour(TiXmlElement *XMLNode);
00124         
00125 
00126         SceneManager *mSceneMgr;
00127         SceneNode *mAttachNode;
00128         String m_sGroupName;
00129         String m_sPrependNode;
00130     };
00131 }
00132 
00133 #endif // DOT_SCENELOADER_H

Generated on Sun Nov 23 02:28:37 2008 for Sofa by  doxygen 1.5.7.1