Ogre 加载.Scene文件

OgreMax的Scene直接导入到ogre中 该框架程序用于将嵌入到3ds中的ogreMax插件所产生的scene文件,导入到ogre中。方法:将压缩文件models文件释放到$(ogre_home)\media\models下即可。 立即下载

Introduction

Because DotSceneInterface in ogreaddons hasn't been updated for a long time now, and because the DotScene Loader with User Data and DotScene Loader with User Data Class didn't have all the features we needed (hierarchical nodes, sky settings, ...), I decided to quickly write my own loader. I used some code from DotSceneInterface, and some code from the other two loaders, but there isn't much left of it. I wrote this to be as easily extensible as possible. I'm not really sure if everything is implemented correctly, and not all features are implemented yet, so it would be cool if some people tried it out and commented about it... Go here for the forum-thread.

Just link these two files together with tinyxml to get it to work.

Update (2007-08-19): I updated the code with our current dotscene loading class. Still not complete though, but a lot of features implemented since last time (camera code, ...). You can also download the header and source file from my webspace.

For Mogre is a port available here.

A modified version of the class that populates a terrain scene manager can be found here.

Header

#ifndef DOT_SCENELOADER_H #define DOT_SCENELOADER_H // Includes #include <Ogre/OgreString.h> #include <Ogre/OgreVector3.h> #include <Ogre/OgreQuaternion.h> #include <vector> // Forward declarations class TiXmlElement; namespace Ogre { // Forward declarations class SceneManager; class SceneNode; class nodeProperty { public: String nodeName; String propertyNm; String valueName; String typeName; nodeProperty(const String &node, const String &propertyName, const String &value, const String &type) : nodeName(node), propertyNm(propertyName), valueName(value), typeName(type) {} }; class DotSceneLoader { public: DotSceneLoader() : mSceneMgr(0) {} virtual ~DotSceneLoader() {} void parseDotScene(const String &SceneName, const String &groupName, SceneManager *yourSceneMgr, SceneNode *pAttachNode = NULL, const String &sPrependNode = ""); String getProperty(const String &ndNm, const String &prop); std::vector<nodeProperty> nodeProperties; std::vector<String> staticObjects; std::vector<String> dynamicObjects; protected: void processScene(TiXmlElement *XMLRoot); void processNodes(TiXmlElement *XMLNode); void processExternals(TiXmlElement *XMLNode); void processEnvironment(TiXmlElement *XMLNode); void processTerrain(TiXmlElement *XMLNode); void processUserDataReference(TiXmlElement *XMLNode, SceneNode *pParent = 0); void processUserDataReference(TiXmlElement *XMLNode, Entity *pEntity); void processOctree(TiXmlElement *XMLNode); void processLight(TiXmlElement *XMLNode, SceneNode *pParent = 0); void processCamera(TiXmlElement *XMLNode, SceneNode *pParent = 0); void processNode(TiXmlElement *XMLNode, SceneNode *pParent = 0); void processLookTarget(TiXmlElement *XMLNode, SceneNode *pParent); void processTrackTarget(TiXmlElement *XMLNode, SceneNode *pParent); void processEntity(TiXmlElement *XMLNode, SceneNode *pParent); void processParticleSystem(TiXmlElement *XMLNode, SceneNode *pParent); void processBillboardSet(TiXmlElement *XMLNode, SceneNode *pParent); void processPlane(TiXmlElement *XMLNode, SceneNode *pParent); void processFog(TiXmlElement *XMLNode); void processSkyBox(TiXmlElement *XMLNode); void processSkyDome(TiXmlElement *XMLNode); void processSkyPlane(TiXmlElement *XMLNode); void processClipping(TiXmlElement *XMLNode); void processLightRange(TiXmlElement *XMLNode, Light *pLight); void processLightAttenuation(TiXmlElement *XMLNode, Light *pLight); String getAttrib(TiXmlElement *XMLNode, const String &parameter, const String &defaultValue = ""); Real getAttribReal(TiXmlElement *XMLNode, const String &parameter, Real defaultValue = 0); bool getAttribBool(TiXmlElement *XMLNode, const String &parameter, bool defaultValue = false); Vector3 parseVector3(TiXmlElement *XMLNode); Quaternion parseQuaternion(TiXmlElement *XMLNode); ColourValue parseColour(TiXmlElement *XMLNode); SceneManager *mSceneMgr; SceneNode *mAttachNode; String m_sGroupName; String m_sPrependNode; }; } #endif // DOT_SCENELOADER_H

Source

#include "DotSceneLoader.h" #include "tinyxml.h" #include <Ogre/Ogre.h> using namespace std; using namespace Ogre; void DotSceneLoader::parseDotScene(const String &SceneName, const String &groupName, SceneManager *yourSceneMgr, SceneNode *pAttachNode, const String &sPrependNode) { // set up shared object values m_sGroupName = groupName; mSceneMgr = yourSceneMgr; m_sPrependNode = sPrependNode; staticObjects.clear(); dynamicObjects.clear(); TiXmlDocument *XMLDoc = 0; TiXmlElement *XMLRoot; try { // Strip the path Ogre::String basename, path; Ogre::StringUtil::splitFilename(SceneName, basename, path); DataStreamPtr pStream = ResourceGroupManager::getSingleton(). openResource( basename, groupName ); //DataStreamPtr pStream = ResourceGroupManager::getSingleton(). //	openResource( SceneName, groupName ); String data = pStream->getAsString(); // Open the .scene File XMLDoc = new TiXmlDocument(); XMLDoc->Parse( data.c_str() ); pStream->close(); pStream.setNull(); if( XMLDoc->Error() ) { //We'll just log, and continue on gracefully LogManager::getSingleton().logMessage("[DotSceneLoader] The TiXmlDocument reported an error"); delete XMLDoc; return; } } catch(...) { //We'll just log, and continue on gracefully LogManager::getSingleton().logMessage("[DotSceneLoader] Error creating TiXmlDocument"); delete XMLDoc; return; } // Validate the File XMLRoot = XMLDoc->RootElement(); if( String( XMLRoot->Value()) != "scene" ) { LogManager::getSingleton().logMessage( "[DotSceneLoader] Error: Invalid .scene File. Missing <scene>" ); delete XMLDoc; return; } // figure out where to attach any nodes we create mAttachNode = pAttachNode; if(!mAttachNode) mAttachNode = mSceneMgr->getRootSceneNode(); // Process the scene processScene(XMLRoot); // Close the XML File delete XMLDoc; } void DotSceneLoader::processScene(TiXmlElement *XMLRoot) { // Process the scene parameters String version = getAttrib(XMLRoot, "formatVersion", "unknown"); String message = "[DotSceneLoader] Parsing dotScene file with version " + version; if(XMLRoot->Attribute("ID")) message += ", id " + String(XMLRoot->Attribute("ID")); if(XMLRoot->Attribute("sceneManager")) message += ", scene manager " + String(XMLRoot->Attribute("sceneManager")); if(XMLRoot->Attribute("minOgreVersion")) message += ", min. Ogre version " + String(XMLRoot->Attribute("minOgreVersion")); if(XMLRoot->Attribute("author")) message += ", author " + String(XMLRoot->Attribute("author")); LogManager::getSingleton().logMessage(message); TiXmlElement *pElement; // Process nodes (?) pElement = XMLRoot->FirstChildElement("nodes"); if(pElement) processNodes(pElement); // Process externals (?) pElement = XMLRoot->FirstChildElement("externals"); if(pElement) processExternals(pElement); // Process environment (?) pElement = XMLRoot->FirstChildElement("environment"); if(pElement) processEnvironment(pElement); // Process terrain (?) pElement = XMLRoot->FirstChildElement("terrain"); if(pElement) processTerrain(pElement); // Process userDataReference (?) pElement = XMLRoot->FirstChildElement("userDataReference"); if(pElement) processUserDataReference(pElement); // Process octree (?) pElement = XMLRoot->FirstChildElement("octree"); if(pElement) processOctree(pElement); // Process light (?) pElement = XMLRoot->FirstChildElement("light"); if(pElement) processLight(pElement); // Process camera (?) pElement = XMLRoot->FirstChildElement("camera"); if(pElement) processCamera(pElement); } void DotSceneLoader::processNodes(TiXmlElement *XMLNode) { TiXmlElement *pElement; // Process node (*) pElement = XMLNode->FirstChildElement("node"); while(pElement) { processNode(pElement); pElement = pElement->NextSiblingElement("node"); } // Process position (?) pElement = XMLNode->FirstChildElement("position"); if(pElement) { mAttachNode->setPosition(parseVector3(pElement)); mAttachNode->setInitialState(); } // Process rotation (?) pElement = XMLNode->FirstChildElement("rotation"); if(pElement) { mAttachNode->setOrientation(parseQuaternion(pElement)); mAttachNode->setInitialState(); } // Process scale (?) pElement = XMLNode->FirstChildElement("scale"); if(pElement) { mAttachNode->setScale(parseVector3(pElement)); mAttachNode->setInitialState(); } } void DotSceneLoader::processExternals(TiXmlElement *XMLNode) { //! @todo Implement this } void DotSceneLoader::processEnvironment(TiXmlElement *XMLNode) { TiXmlElement *pElement; // Process fog (?) pElement = XMLNode->FirstChildElement("fog"); if(pElement) processFog(pElement); // Process skyBox (?) pElement = XMLNode->FirstChildElement("skyBox"); if(pElement) processSkyBox(pElement); // Process skyDome (?) pElement = XMLNode->FirstChildElement("skyDome"); if(pElement) processSkyDome(pElement); // Process skyPlane (?) pElement = XMLNode->FirstChildElement("skyPlane"); if(pElement) processSkyPlane(pElement); // Process clipping (?) pElement = XMLNode->FirstChildElement("clipping"); if(pElement) processClipping(pElement); // Process colourAmbient (?) pElement = XMLNode->FirstChildElement("colourAmbient"); if(pElement) mSceneMgr->setAmbientLight(parseColour(pElement)); // Process colourBackground (?) //! @todo Set the background colour of all viewports (RenderWindow has to be provided then) pElement = XMLNode->FirstChildElement("colourBackground"); if(pElement) ;//mSceneMgr->set(parseColour(pElement)); // Process userDataReference (?) pElement = XMLNode->FirstChildElement("userDataReference"); if(pElement) processUserDataReference(pElement); } void DotSceneLoader::processTerrain(TiXmlElement *XMLNode) { //! @todo Implement this } void DotSceneLoader::processUserDataReference(TiXmlElement *XMLNode, SceneNode *pParent) { //! @todo Implement this } void DotSceneLoader::processOctree(TiXmlElement *XMLNode) { //! @todo Implement this } void DotSceneLoader::processLight(TiXmlElement *XMLNode, SceneNode *pParent) { // Process attributes String name = getAttrib(XMLNode, "name"); String id = getAttrib(XMLNode, "id"); // Create the light Light *pLight = mSceneMgr->createLight(name); if(pParent) pParent->attachObject(pLight); String sValue = getAttrib(XMLNode, "type"); if(sValue == "point") pLight->setType(Light::LT_POINT); else if(sValue == "directional") pLight->setType(Light::LT_DIRECTIONAL); else if(sValue == "spot") pLight->setType(Light::LT_SPOTLIGHT); else if(sValue == "radPoint") pLight->setType(Light::LT_POINT); pLight->setVisible(getAttribBool(XMLNode, "visible", true)); pLight->setCastShadows(getAttribBool(XMLNode, "castShadows", true)); TiXmlElement *pElement; // Process position (?) pElement = XMLNode->FirstChildElement("position"); if(pElement) pLight->setPosition(parseVector3(pElement)); // Process normal (?) pElement = XMLNode->FirstChildElement("normal"); if(pElement) pLight->setDirection(parseVector3(pElement)); // Process colourDiffuse (?) pElement = XMLNode->FirstChildElement("colourDiffuse"); if(pElement) pLight->setDiffuseColour(parseColour(pElement)); // Process colourSpecular (?) pElement = XMLNode->FirstChildElement("colourSpecular"); if(pElement) pLight->setSpecularColour(parseColour(pElement)); // Process lightRange (?) pElement = XMLNode->FirstChildElement("lightRange"); if(pElement) processLightRange(pElement, pLight); // Process lightAttenuation (?) pElement = XMLNode->FirstChildElement("lightAttenuation"); if(pElement) processLightAttenuation(pElement, pLight); // Process userDataReference (?) pElement = XMLNode->FirstChildElement("userDataReference"); if(pElement) ;//processUserDataReference(pElement, pLight); } void DotSceneLoader::processCamera(TiXmlElement *XMLNode, SceneNode *pParent) { // Process attributes String name = getAttrib(XMLNode, "name"); String id = getAttrib(XMLNode, "id"); Real fov = getAttribReal(XMLNode, "fov", 45); Real aspectRatio = getAttribReal(XMLNode, "aspectRatio", 1.3333); String projectionType = getAttrib(XMLNode, "projectionType", "perspective"); // Create the camera Camera *pCamera = mSceneMgr->createCamera(name); if(pParent) pParent->attachObject(pCamera); // Set the field-of-view //! @todo Is this always in degrees? pCamera->setFOVy(Ogre::Degree(fov)); // Set the aspect ratio pCamera->setAspectRatio(aspectRatio); // Set the projection type if(projectionType == "perspective") pCamera->setProjectionType(PT_PERSPECTIVE); else if(projectionType == "orthographic") pCamera->setProjectionType(PT_ORTHOGRAPHIC); TiXmlElement *pElement; // Process clipping (?) pElement = XMLNode->FirstChildElement("clipping"); if(pElement) { Real nearDist = getAttribReal(pElement, "near"); pCamera->setNearClipDistance(nearDist); Real farDist = getAttribReal(pElement, "far"); pCamera->setFarClipDistance(farDist); } // Process position (?) pElement = XMLNode->FirstChildElement("position"); if(pElement) pCamera->setPosition(parseVector3(pElement)); // Process rotation (?) pElement = XMLNode->FirstChildElement("rotation"); if(pElement) pCamera->setOrientation(parseQuaternion(pElement)); // Process normal (?) pElement = XMLNode->FirstChildElement("normal"); if(pElement) ;//!< @todo What to do with this element? // Process lookTarget (?) pElement = XMLNode->FirstChildElement("lookTarget"); if(pElement) ;//!< @todo Implement the camera look target // Process trackTarget (?) pElement = XMLNode->FirstChildElement("trackTarget"); if(pElement) ;//!< @todo Implement the camera track target // Process userDataReference (?) pElement = XMLNode->FirstChildElement("userDataReference"); if(pElement) ;//!< @todo Implement the camera user data reference } void DotSceneLoader::processNode(TiXmlElement *XMLNode, SceneNode *pParent) { // Construct the node's name String name = m_sPrependNode + getAttrib(XMLNode, "name"); // Create the scene node SceneNode *pNode; if(name.empty()) { // Let Ogre choose the name if(pParent) pNode = pParent->createChildSceneNode(); else pNode = mAttachNode->createChildSceneNode(); } else { // Provide the name if(pParent) pNode = pParent->createChildSceneNode(name); else pNode = mAttachNode->createChildSceneNode(name); } // Process other attributes String id = getAttrib(XMLNode, "id"); bool isTarget = getAttribBool(XMLNode, "isTarget"); TiXmlElement *pElement; // Process position (?) pElement = XMLNode->FirstChildElement("position"); if(pElement) { pNode->setPosition(parseVector3(pElement)); pNode->setInitialState(); } // Process rotation (?) pElement = XMLNode->FirstChildElement("rotation"); if(pElement) { pNode->setOrientation(parseQuaternion(pElement)); pNode->setInitialState(); } // Process scale (?) pElement = XMLNode->FirstChildElement("scale"); if(pElement) { pNode->setScale(parseVector3(pElement)); pNode->setInitialState(); } // Process lookTarget (?) pElement = XMLNode->FirstChildElement("lookTarget"); if(pElement) processLookTarget(pElement, pNode); // Process trackTarget (?) pElement = XMLNode->FirstChildElement("trackTarget"); if(pElement) processTrackTarget(pElement, pNode); // Process node (*) pElement = XMLNode->FirstChildElement("node"); while(pElement) { processNode(pElement, pNode); pElement = pElement->NextSiblingElement("node"); } // Process entity (*) pElement = XMLNode->FirstChildElement("entity"); while(pElement) { processEntity(pElement, pNode); pElement = pElement->NextSiblingElement("entity"); } // Process light (*) pElement = XMLNode->FirstChildElement("light"); while(pElement) { processLight(pElement, pNode); pElement = pElement->NextSiblingElement("light"); } // Process camera (*) pElement = XMLNode->FirstChildElement("camera"); while(pElement) { processCamera(pElement, pNode); pElement = pElement->NextSiblingElement("camera"); } // Process particleSystem (*) pElement = XMLNode->FirstChildElement("particleSystem"); while(pElement) { processParticleSystem(pElement, pNode); pElement = pElement->NextSiblingElement("particleSystem"); } // Process billboardSet (*) pElement = XMLNode->FirstChildElement("billboardSet"); while(pElement) { processBillboardSet(pElement, pNode); pElement = pElement->NextSiblingElement("billboardSet"); } // Process plane (*) pElement = XMLNode->FirstChildElement("plane"); while(pElement) { processPlane(pElement, pNode); pElement = pElement->NextSiblingElement("plane"); } // Process userDataReference (?) pElement = XMLNode->FirstChildElement("userDataReference"); if(pElement) processUserDataReference(pElement, pNode); } void DotSceneLoader::processLookTarget(TiXmlElement *XMLNode, SceneNode *pParent) { //! @todo Is this correct? Cause I don't have a clue actually // Process attributes String nodeName = getAttrib(XMLNode, "nodeName"); Node::TransformSpace relativeTo = Node::TS_PARENT; String sValue = getAttrib(XMLNode, "relativeTo"); if(sValue == "local") relativeTo = Node::TS_LOCAL; else if(sValue == "parent") relativeTo = Node::TS_PARENT; else if(sValue == "world") relativeTo = Node::TS_WORLD; TiXmlElement *pElement; // Process position (?) Vector3 position; pElement = XMLNode->FirstChildElement("position"); if(pElement) position = parseVector3(pElement); // Process localDirection (?) Vector3 localDirection = Vector3::NEGATIVE_UNIT_Z; pElement = XMLNode->FirstChildElement("localDirection"); if(pElement) localDirection = parseVector3(pElement); // Setup the look target try { if(!nodeName.empty()) { SceneNode *pLookNode = mSceneMgr->getSceneNode(nodeName); position = pLookNode->_getDerivedPosition(); } pParent->lookAt(position, relativeTo, localDirection); } catch(Ogre::Exception &/*e*/) { LogManager::getSingleton().logMessage("[DotSceneLoader] Error processing a look target!"); } } void DotSceneLoader::processTrackTarget(TiXmlElement *XMLNode, SceneNode *pParent) { // Process attributes String nodeName = getAttrib(XMLNode, "nodeName"); TiXmlElement *pElement; // Process localDirection (?) Vector3 localDirection = Vector3::NEGATIVE_UNIT_Z; pElement = XMLNode->FirstChildElement("localDirection"); if(pElement) localDirection = parseVector3(pElement); // Process offset (?) Vector3 offset = Vector3::ZERO; pElement = XMLNode->FirstChildElement("offset"); if(pElement) offset = parseVector3(pElement); // Setup the track target try { SceneNode *pTrackNode = mSceneMgr->getSceneNode(nodeName); pParent->setAutoTracking(true, pTrackNode, localDirection, offset); } catch(Ogre::Exception &/*e*/) { LogManager::getSingleton().logMessage("[DotSceneLoader] Error processing a track target!"); } } void DotSceneLoader::processEntity(TiXmlElement *XMLNode, SceneNode *pParent) { // Process attributes String name = getAttrib(XMLNode, "name"); String id = getAttrib(XMLNode, "id"); String meshFile = getAttrib(XMLNode, "meshFile"); String materialFile = getAttrib(XMLNode, "materialFile"); bool isStatic = getAttribBool(XMLNode, "static", false);; bool castShadows = getAttribBool(XMLNode, "castShadows", true); // TEMP: Maintain a list of static and dynamic objects if(isStatic) staticObjects.push_back(name); else dynamicObjects.push_back(name); TiXmlElement *pElement; // Process vertexBuffer (?) pElement = XMLNode->FirstChildElement("vertexBuffer"); if(pElement) ;//processVertexBuffer(pElement); // Process indexBuffer (?) pElement = XMLNode->FirstChildElement("indexBuffer"); if(pElement) ;//processIndexBuffer(pElement); // Create the entity Entity *pEntity = 0; try { MeshManager::getSingleton().load(meshFile, m_sGroupName); pEntity = mSceneMgr->createEntity(name, meshFile); pEntity->setCastShadows(castShadows); pParent->attachObject(pEntity); if(!materialFile.empty()) pEntity->setMaterialName(materialFile); } catch(Ogre::Exception &/*e*/) { LogManager::getSingleton().logMessage("[DotSceneLoader] Error loading an entity!"); } // Process userDataReference (?) pElement = XMLNode->FirstChildElement("userDataReference"); if(pElement) processUserDataReference(pElement, pEntity); } void DotSceneLoader::processParticleSystem(TiXmlElement *XMLNode, SceneNode *pParent) { // Process attributes String name = getAttrib(XMLNode, "name"); String id = getAttrib(XMLNode, "id"); String file = getAttrib(XMLNode, "file"); // Create the particle system try { ParticleSystem *pParticles = mSceneMgr->createParticleSystem(name, file); pParent->attachObject(pParticles); } catch(Ogre::Exception &/*e*/) { LogManager::getSingleton().logMessage("[DotSceneLoader] Error creating a particle system!"); } } void DotSceneLoader::processBillboardSet(TiXmlElement *XMLNode, SceneNode *pParent) { //! @todo Implement this } void DotSceneLoader::processPlane(TiXmlElement *XMLNode, SceneNode *pParent) { //! @todo Implement this } void DotSceneLoader::processFog(TiXmlElement *XMLNode) { // Process attributes Real expDensity = getAttribReal(XMLNode, "expDensity", 0.001); Real linearStart = getAttribReal(XMLNode, "linearStart", 0.0); Real linearEnd = getAttribReal(XMLNode, "linearEnd", 1.0); FogMode mode = FOG_NONE; String sMode = getAttrib(XMLNode, "mode"); if(sMode == "none") mode = FOG_NONE; else if(sMode == "exp") mode = FOG_EXP; else if(sMode == "exp2") mode = FOG_EXP2; else if(sMode == "linear") mode = FOG_LINEAR; TiXmlElement *pElement; // Process colourDiffuse (?) ColourValue colourDiffuse = ColourValue::White; pElement = XMLNode->FirstChildElement("colourDiffuse"); if(pElement) colourDiffuse = parseColour(pElement); // Setup the fog mSceneMgr->setFog(mode, colourDiffuse, expDensity, linearStart, linearEnd); } void DotSceneLoader::processSkyBox(TiXmlElement *XMLNode) { // Process attributes String material = getAttrib(XMLNode, "material"); Real distance = getAttribReal(XMLNode, "distance", 5000); bool drawFirst = getAttribBool(XMLNode, "drawFirst", true); TiXmlElement *pElement; // Process rotation (?) Quaternion rotation = Quaternion::IDENTITY; pElement = XMLNode->FirstChildElement("rotation"); if(pElement) rotation = parseQuaternion(pElement); // Setup the sky box mSceneMgr->setSkyBox(true, material, distance, drawFirst, rotation, m_sGroupName); } void DotSceneLoader::processSkyDome(TiXmlElement *XMLNode) { // Process attributes String material = XMLNode->Attribute("material"); Real curvature = getAttribReal(XMLNode, "curvature", 10); Real tiling = getAttribReal(XMLNode, "tiling", 8); Real distance = getAttribReal(XMLNode, "distance", 4000); bool drawFirst = getAttribBool(XMLNode, "drawFirst", true); TiXmlElement *pElement; // Process rotation (?) Quaternion rotation = Quaternion::IDENTITY; pElement = XMLNode->FirstChildElement("rotation"); if(pElement) rotation = parseQuaternion(pElement); // Setup the sky dome mSceneMgr->setSkyDome(true, material, curvature, tiling, distance, drawFirst, rotation, 16, 16, -1, m_sGroupName); } void DotSceneLoader::processSkyPlane(TiXmlElement *XMLNode) { // Process attributes String material = getAttrib(XMLNode, "material"); Real planeX = getAttribReal(XMLNode, "planeX", 0); Real planeY = getAttribReal(XMLNode, "planeY", -1); Real planeZ = getAttribReal(XMLNode, "planeX", 0); Real planeD = getAttribReal(XMLNode, "planeD", 5000); Real scale = getAttribReal(XMLNode, "scale", 1000); Real bow = getAttribReal(XMLNode, "bow", 0); Real tiling = getAttribReal(XMLNode, "tiling", 10); bool drawFirst = getAttribBool(XMLNode, "drawFirst", true); // Setup the sky plane Plane plane; plane.normal = Vector3(planeX, planeY, planeZ); plane.d = planeD; mSceneMgr->setSkyPlane(true, plane, material, scale, tiling, drawFirst, bow, 1, 1, m_sGroupName); } void DotSceneLoader::processClipping(TiXmlElement *XMLNode) { //! @todo Implement this // Process attributes Real fNear = getAttribReal(XMLNode, "near", 0); Real fFar = getAttribReal(XMLNode, "far", 1); } void DotSceneLoader::processLightRange(TiXmlElement *XMLNode, Light *pLight) { // Process attributes Real inner = getAttribReal(XMLNode, "inner"); Real outer = getAttribReal(XMLNode, "outer"); Real falloff = getAttribReal(XMLNode, "falloff", 1.0); // Setup the light range pLight->setSpotlightRange(Angle(inner), Angle(outer), falloff); } void DotSceneLoader::processLightAttenuation(TiXmlElement *XMLNode, Light *pLight) { // Process attributes Real range = getAttribReal(XMLNode, "range"); Real constant = getAttribReal(XMLNode, "constant"); Real linear = getAttribReal(XMLNode, "linear"); Real quadratic = getAttribReal(XMLNode, "quadratic"); // Setup the light attenuation pLight->setAttenuation(range, constant, linear, quadratic); } String DotSceneLoader::getAttrib(TiXmlElement *XMLNode, const String &attrib, const String &defaultValue) { if(XMLNode->Attribute(attrib)) return XMLNode->Attribute(attrib); else return defaultValue; } Real DotSceneLoader::getAttribReal(TiXmlElement *XMLNode, const String &attrib, Real defaultValue) { if(XMLNode->Attribute(attrib)) return StringConverter::parseReal(XMLNode->Attribute(attrib)); else return defaultValue; } bool DotSceneLoader::getAttribBool(TiXmlElement *XMLNode, const String &attrib, bool defaultValue) { if(!XMLNode->Attribute(attrib)) return defaultValue; if(String(XMLNode->Attribute(attrib)) == "true") return true; return false; } Vector3 DotSceneLoader::parseVector3(TiXmlElement *XMLNode) { return Vector3( StringConverter::parseReal(XMLNode->Attribute("x")), StringConverter::parseReal(XMLNode->Attribute("y")), StringConverter::parseReal(XMLNode->Attribute("z")) ); } Quaternion DotSceneLoader::parseQuaternion(TiXmlElement *XMLNode) { //! @todo Fix this crap! Quaternion orientation; if(XMLNode->Attribute("qx")) { orientation.x = StringConverter::parseReal(XMLNode->Attribute("qx")); orientation.y = StringConverter::parseReal(XMLNode->Attribute("qy")); orientation.z = StringConverter::parseReal(XMLNode->Attribute("qz")); orientation.w = StringConverter::parseReal(XMLNode->Attribute("qw")); } else if(XMLNode->Attribute("axisX")) { Vector3 axis; axis.x = StringConverter::parseReal(XMLNode->Attribute("axisX")); axis.y = StringConverter::parseReal(XMLNode->Attribute("axisY")); axis.z = StringConverter::parseReal(XMLNode->Attribute("axisZ")); Real angle = StringConverter::parseReal(XMLNode->Attribute("angle"));; orientation.FromAngleAxis(Ogre::Angle(angle), axis); } else if(XMLNode->Attribute("angleX")) { Vector3 axis; axis.x = StringConverter::parseReal(XMLNode->Attribute("angleX")); axis.y = StringConverter::parseReal(XMLNode->Attribute("angleY")); axis.z = StringConverter::parseReal(XMLNode->Attribute("angleZ")); //orientation.FromAxes(&axis); //orientation.F } return orientation; } ColourValue DotSceneLoader::parseColour(TiXmlElement *XMLNode) { return ColourValue( StringConverter::parseReal(XMLNode->Attribute("r")), StringConverter::parseReal(XMLNode->Attribute("g")), StringConverter::parseReal(XMLNode->Attribute("b")), XMLNode->Attribute("a") != NULL ? StringConverter::parseReal(XMLNode->Attribute("a")) : 1 ); } String DotSceneLoader::getProperty(const String &ndNm, const String &prop) { for ( unsigned int i = 0 ; i < nodeProperties.size(); i++ ) { if ( nodeProperties[i].nodeName == ndNm && nodeProperties[i].propertyNm == prop ) { return nodeProperties[i].valueName; } } return ""; } void DotSceneLoader::processUserDataReference(TiXmlElement *XMLNode, Entity *pEntity) { String str = XMLNode->Attribute("id"); pEntity->setUserAny(Any(str)); }
ogre1.8导入ogremax的scene(VS2010工程文件) 1.在3Dmax中使用ogremax导出scene 2.ogremaxViewer检测scene可用性 3.把scene放入$OGRE_HOME$/media下 4.修改代码中载入资源的名称,编译运行 立即下载

相关推荐

MuMu模拟器过检测实战:从硬件伪装到API欺骗的完整避坑指南

本文详细介绍了MuMu模拟器过检测的实战技术,从硬件伪装到API欺骗的全方位解决方案。通过修改CPU/GPU信息、内存分布、系统属性和行为模拟等关键技术,帮助用户有效绕过现代应用的模拟器检测机制,提升模拟器的隐蔽性和稳定性。

xxx12的博客 1445

OGRE日志文件

如果在自己的项目中使用了OGRE,当么当程序出现错误时,如果有提示说是OGRE中的Exception,我们可以直接找到项目运行产生的ogre.log文件,其它指示了发生异常的具体信息。 如:Ogre::ItemIdentityException。 如果使用的引擎有自己的日志文件,出现错误就方便多了。

heaven20062006的专栏 751

避坑指南:Zephyr RTOS与nRF Connect SDK环境搭建常见错误及解决方案

本文详细解析了Zephyr RTOS与nRF Connect SDK环境搭建过程中的常见错误及解决方案,涵盖网络问题、代理设置、SEGGER Embedded Studio配置、分支切换等关键环节。针对开发者实际遇到的痛点问题,提供了一系列实用技巧和深度排错方法,帮助高效完成NCS开发环境部署。

weixin_28685287的博客 173

Ogre中调用OgreMaxViewer来load场景文件.scene

这几天一直都在被这个问题困扰,各种方法都试了,都快哭了,现在终于OK了。先Mark一下, 免得日后又忘了。 1.基本框架 基本框架就不自己亲自搭建了,打算直接用Ogre官网提供的TutorialFramework,先将此平台 搭建好,详情可参考另一篇博文http://blog.csdn.net/liygcheng/article/details/9923989 2...

weixin_30267785的博客 250

5G移动性管理实战:手把手教你配置NR小区重选参数(附避坑指南)

本文深入解析5G网络移动性管理中的小区重选参数配置实战。通过拆解小区选择与重选的核心机制,结合真实案例,手把手指导如何配置NR小区重选参数,并分享常见避坑指南,帮助工程师优化网络性能,提升用户移动体验。

weixin_29229261的博客 202

SAP CO模块实战:成本中心会计分割结构配置全流程(OKES事务码详解)

本文详细解析了SAP CO模块中成本中心会计分割结构的配置全流程,重点讲解了OKES事务码的实战操作。内容涵盖分割结构的概念理解、配置前的次级成本要素与作业类型主数据准备,并通过步骤拆解演示了如何定义分割结构、规则与版本,以及如何将配置关联到成本中心并执行分割。最后提供了常见问题排查与优化建议,旨在帮助顾问及财务人员掌握成本精确分摊的关键配置,确保期末成本核算的准确性。

embedding5hiker的博客 818

Fedora下的Ogre编译与安装

一直对3D擎感兴趣,但是因为专业问题和项目太忙,没有足够的时间,现在终于闲下来一点于是准备了解学习一下Orge这个3D引擎。     在官网上发现没有prebuild的Linux版本(可能是Linux的Distro太多了吧- -!),只有android,ios,Mac和VitualC++的,于是只好下载souce自己编译。下载完成解压后,折腾了一上午终于成功看到了萌萌的小兽人,还是很开心的,所以

tinyFatAries的专栏 705

第五节_PySide6基本窗口控件_主窗口和标签

本文介绍了PySide6中主窗口和标签控件的使用。主要内容包括: 窗口控件分类: QWidget是基础窗口部件,可作为独立窗口或子部件 QMainWindow提供标准应用程序框架,包含菜单栏、工具栏等 QDialog用于对话框,支持模态交互 主窗口创建: 演示了如何创建QMainWindow子类 实现了窗口居中、设置图标、状态栏等功能 提供了窗口几何信息的获取方法 QLabel标签控件: 继承自QFrame类 用于显示文本或图像 文章通过代码示例详细说明了主窗口的创建和使用方法,包括位置控制、图标设置等常见

su桥木的博客 1027

OGRE1.8.1预编译包vs2010x86异常问题

辉辉 (Fighting Bull Studio) 1.  出现异常OGREEXCEPTION (7:InternalErrorException): Unable to compile Cg programOgre/ParticleGS/DisplayVScg 该问题出现是由于加载的资源中有CG程序,但是Plugin_cgmanager不适用而引起的,解决的办法是:如果不需要的话,手动加载指

Fighting Bull 1610

PCL 欧式聚类分割【2026最新版】

PCL中欧式聚类提取算法原理详解、代码实现以及一个大自然场景地物分割提取并保存分割结果到本地文件夹的应用案例。

点云侠的博客 40万+

生存曲线绘制及图例标签添加(使用R语言)

数据应该包含两列:一个是表示个体生存时间的时间变量(通常称为"时间(time)“)和一个是表示个体是否发生事件(如死亡)的事件变量(通常称为"事件(event)”)。通过修改上述代码中的数据和参数,您可以根据自己的需求绘制生存曲线,并添加相应的图例信息和标签。生存曲线是在生存分析中常用的工具,用于描述一组个体随时间的存活概率。函数的第一个参数指定图例的位置,这里我们选择了右上角(“topright”)。包来进行生存曲线的绘制,并通过添加图例信息和标签来增强可视化效果。的数据框,包含这两列数据。

CyberXZ的博客 562

OGRE示例Demo_BSP代码分析

最近在自学OGRE,自我感觉分析具体代码的时候就像在拨香蕉皮,一层嵌套另一层。Resource life cycle感觉挺重要的,针对这个Demo分析下吧。Class BspApplication中,有三个保护性成员变量 protected: String mQuakePk3;                                    String mQuakeLevel; Examp

痞子龙3D编程 1855

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

Ogre 加载.Scene文件

Introduction Because DotSceneInterface in ogreaddons hasnt been updated for a long time now, and because the DotScene Loader with User Data and DotScene Loader with User Data Class didnt have all

痞子龙3D编程 5198

IMSL CNL 7.0.0 (x86-64)Crack

IMSL CNL 7.0.0 (x86-64)Crack intel的算法库破解文件,这是C++版本的破解文件

InTheHand.Net.Personal+BlueTooth4,蓝牙开发

项目中有蓝牙开发的必备dll,现在网上相关的文档博客不少,有的说的多有的说少,但是却很少有这两个dll,分享一下。

Ogre读取Ogitor的scene场景简介

这几天在用Ogre读取Ogitor的场景,遇到了不少问题,在网上也找不到详细的说明,虽然读取Ogitor的场景对很多人来说太简单了,但对一些新手来说就有点难了,我刚开始就觉得是无从下手,因此简单的描述下读取过程和一些常见问题,希望对一些新手有所帮助,高手就可以跳过了O(∩_∩)O~我简单的分为2大步:1.     学会简单的使用Ogitor,新建自己的场景,然后导出为scene场景文件Ogitor的简单操作我就不再详述了,直接引用网上的:一、基本控制1.场景中的坐标:x轴z轴表示左右,Y表示上下2.QWEA

熊小屁的专栏 2128

全球国家地区城市数据

MySQL全球国家地区城市数据报。。。。。。。。。。。。

Ogre中设置.scene文件中所有实体、子实体以及各个LOD层级的材质

在Ogre中,当我们装载进来.scene文件(Ogremax导出的文件格式)后,可能有时候需要设置这些文件中包含的所有实体的材质,这时,我们可以通过下面这段代码来获取其中的所有实体,并为其设置材质: Ogre::int32 numChildNode = mMaxScene->GetRootNode()->numChildren(); for (int i = 0; i < numChil

zomeelee的专栏 754

在ogre中加载 ogremax场景文件方法

看到很多人对ogremax在ogre中怎么加载不大熟悉,其实作者有一篇文章有介绍的,我把我自己在我的ogreview中用ogremax的方法写下来,供各位参考。 (1)首先下载最新的ogremax.  (2)找到图片中列出来的文件,放到自己的程序目录中 (3)同时把解析XML的tinyxml相关文件负责知道程序目录 (4)把以上文件加到项目中,编译,应该是编译通过的

fenxinzi557的博客 477

学习OGRE - 读取天龙八部scene文件

scene文件描述中包含有地形, 场景物件, 灯光, 模型等信息. 之前的地形信息就是从scene文件获得的, 这次接着把场景物件, 灯光, 模型都显示出来. 天龙的场景物件除了大部分的静态物件, 还有一些要播动画的物件. 这次只是简单的把所有物件导进来, 还没有做动画处理, 过几天再把它实现 ;) (这次把灯光加进来后, 效果很不一样) 转载于:https...

weixin_30416871的博客 417

OGRE分析之文件系统(一)

OGRE既可以读取普通的文件,又可以读取Zip压缩文件。其文件系统可以分目录管理和文件管理两大部分。从应用层次上,OGRE还提供了配置文件管理、日志文件管理和资源文件管理等。假如再加上mesh文件、字体文件、纹理文件等,OGRE的文件系统可谓十分庞大。配置文件比较常用,因此先从配置文件说起。详细分析

actionmoon的专栏 542

Ogre中载入OgreMax场景文件的方法

看到很多人对ogremax在ogre中怎么加载不大熟悉,其实作者有一篇文章有介绍的,我把我自己在我的ogreview中用ogremax的方法写下来,供各位参考。 (1)首先下载最新的ogremax. (2)找到图片中列出来的文件,放到自己的程序目录中 (3)同时把解析XML的tinyxml相关文件负责知道程序目录 (4)把以上文件加到项目中,编译,应该是编译通过的。 (5)然后就是在程序

狼牙 2230

OGRE加载天龙八部场景

天龙八部的场景还是不错的,刚看到的时候很想把它自己加载一下。前端时候一直在研究天龙的场景加载,在上网查了很多资料看了很多高手的BLOG后,在同事的帮助下终于搞定了,呵呵。天龙场景主要是scene、Terrain、GridInfo、Heightmap、lightmap等文件。首先加载scene文件,里面可以读取到Terrain文件名,以及场景上的所有对象,包括灯光、雾、模型等等。然后

5017

在Ogre中载入OgreMax场景文件的方法

在ogre中加在 ogremax场景文件方法发布: 2009-2-10 21:54 |  作者: webmaster |  来源: 本站原创 |  查看: 27次看到很多人对ogremax在ogre中怎么加载不大熟悉,其实作者有一篇文章有介绍的,我把我自己在我的ogreview中用ogremax的方法写下来,供各位参考。(1)首先下载最新的ogremax. (2)找到图片中列出

痞子龙3D编程 3629

武侠世界,基于Ogre的地形分析

早期的天龙八部跟武侠世界基本相似。 先简单地说一下载入场景的大致过程:       读取.Scene文件      根据读取.Terrain文件      读取地砖大小() 地形大小(, ),缩放值()。      读取所有要用的地形贴图(中各项)。      读取.g

游戏开发 1712

OGRE场景管理

1、SceneGraph(场景图) 的概念 SceneGraph一般以树型结构组织,反映了场景中对象的逻辑关系,这里一定要把用于空间分割的二叉树、八叉树算法区别开来,场景图只是逻辑关系而已。以下是组织高效的场景图的一些准则: 1)不要用场景图来进行可见性检测。 2)不要用场景图来进行碰撞查询。 3)不要以空间关系建立场景图,应该以逻辑关系建立。 2 、O...

weixin_30432179的博客 204

3Dmax 导入 Ogre 有关文章

http://hi.baidu.com/hy469680890/blog/item/6832541af35161148618bf54.htmlOgreMax导出的.scene到底要如何才能被NxOgre顺利加载,并且能解析.scene里面的mesh模型呢?.scene直接用Ogre加载并解析就可以.NxOgre如果要加载动态的模型直接使用mesh加载,并在程序里面设定碰撞模型,如果是静

jxusthusiwen的专栏 1265
上一篇: ogre配置文件
下一篇: Ogre Mesh的加载
性感花脸
博客等级 码龄20年 26粉丝 37原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址