void DotSceneLoader::processClipping(TiXmlElement *xmlNode) { //! @todo Implement this // Process attributes float fNear = getAttribReal(xmlNode, "near", 0); float fFar = getAttribReal(xmlNode, "far", 1); }
void DotSceneLoader::processFog(TiXmlElement *xmlNode) { #if 0 // Process attributes float expDensity = getAttribReal(xmlNode, "expDensity", 0.001); float linearStart = getAttribReal(xmlNode, "linearStart", 0.0); float linearEnd = getAttribReal(xmlNode, "linearEnd", 1.0); FogMode mode = FOG_NONE; std::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 (?) math::Vector3 colourDiffuse = math::Vector3::White; pElement = xmlNode->FirstChildElement("colourDiffuse"); if(pElement) colourDiffuse = parseColour(pElement); // Setup the fog sceneManager->setFog(mode, colourDiffuse, expDensity, linearStart, linearEnd); #endif }
void DotSceneLoader::processPlane(rapidxml::xml_node<>* XMLNode, Ogre::SceneNode *pParent) { Ogre::String name = getAttrib(XMLNode, "name"); Ogre::Real distance = getAttribReal(XMLNode, "distance"); Ogre::Real width = getAttribReal(XMLNode, "width"); Ogre::Real height = getAttribReal(XMLNode, "height"); int xSegments = Ogre::StringConverter::parseInt(getAttrib(XMLNode, "xSegments")); int ySegments = Ogre::StringConverter::parseInt(getAttrib(XMLNode, "ySegments")); int numTexCoordSets = Ogre::StringConverter::parseInt(getAttrib(XMLNode, "numTexCoordSets")); Ogre::Real uTile = getAttribReal(XMLNode, "uTile"); Ogre::Real vTile = getAttribReal(XMLNode, "vTile"); Ogre::String material = getAttrib(XMLNode, "material"); bool hasNormals = getAttribBool(XMLNode, "hasNormals"); Ogre::Vector3 normal = parseVector3(XMLNode->first_node("normal")); Ogre::Vector3 up = parseVector3(XMLNode->first_node("upVector")); Ogre::Plane plane(normal, distance); Ogre::MeshPtr res = Ogre::MeshManager::getSingletonPtr()->createPlane( name + "mesh", "General", plane, width, height, xSegments, ySegments, hasNormals, numTexCoordSets, uTile, vTile, up); Ogre::Entity* ent = mSceneMgr->createEntity(name, name + "mesh"); ent->setMaterialName(material); pParent->attachObject(ent); }
void DotSceneLoader::processFog(rapidxml::xml_node<>* XMLNode) { // Process attributes Ogre::Real expDensity = getAttribReal(XMLNode, "density", 0.001); Ogre::Real linearStart = getAttribReal(XMLNode, "start", 0.0); Ogre::Real linearEnd = getAttribReal(XMLNode, "end", 1.0); Ogre::FogMode mode = Ogre::FOG_NONE; Ogre::String sMode = getAttrib(XMLNode, "mode"); if (sMode == "none") mode = Ogre::FOG_NONE; else if (sMode == "exp") mode = Ogre::FOG_EXP; else if (sMode == "exp2") mode = Ogre::FOG_EXP2; else if (sMode == "linear") mode = Ogre::FOG_LINEAR; else mode = (Ogre::FogMode)Ogre::StringConverter::parseInt(sMode); rapidxml::xml_node<>* pElement; // Process colourDiffuse (?) Ogre::ColourValue colourDiffuse = Ogre::ColourValue::White; pElement = XMLNode->first_node("colour"); if (pElement) colourDiffuse = parseColour(pElement); // Setup the fog mSceneMgr->setFog(mode, colourDiffuse, expDensity, linearStart, linearEnd); }
void DotSceneLoader::processClipping(rapidxml::xml_node<>* XMLNode) { //! @todo Implement this // Process attributes Ogre::Real fNear = getAttribReal(XMLNode, "near", 0); Ogre::Real fFar = getAttribReal(XMLNode, "far", 1); }
void DotSceneLoader::processLightRange(TiXmlElement *xmlNode, Light *pLight) { // Process attributes float inner = getAttribReal(xmlNode, "inner"); float outer = getAttribReal(xmlNode, "outer"); float 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 float range = getAttribReal(xmlNode, "range"); float constant = getAttribReal(xmlNode, "constant"); float linear = getAttribReal(xmlNode, "linear"); float quadratic = getAttribReal(xmlNode, "quadratic"); // Setup the light attenuation pLight->setAttenuations(math::Vector3(range, 1, 1)); }
void DotSceneLoader::processLightRange(rapidxml::xml_node<>* XMLNode, Ogre::Light *pLight) { // Process attributes Ogre::Real inner = getAttribReal(XMLNode, "inner"); Ogre::Real outer = getAttribReal(XMLNode, "outer"); Ogre::Real fall_globaloff = getAttribReal(XMLNode, "fall_globaloff", 1.0); // Setup the light range pLight->setSpotlightRange(Ogre::Angle(inner), Ogre::Angle(outer), fall_globaloff); }
void DotSceneLoader::processLightAttenuation(rapidxml::xml_node<>* XMLNode, Ogre::Light *pLight) { // Process attributes Ogre::Real range = getAttribReal(XMLNode, "range"); Ogre::Real constant = getAttribReal(XMLNode, "constant"); Ogre::Real linear = getAttribReal(XMLNode, "linear"); Ogre::Real quadratic = getAttribReal(XMLNode, "quadratic"); // Setup the light attenuation pLight->setAttenuation(range, constant, linear, quadratic); }
void DotSceneLoader::processCamera(rapidxml::xml_node<>* XMLNode, Ogre::SceneNode *pParent) { // Process attributes Ogre::String name = getAttrib(XMLNode, "name"); Ogre::String id = getAttrib(XMLNode, "id"); // Ogre::Real fov = getAttribReal(XMLNode, "fov", 45); // Ogre::Real aspectRatio = getAttribReal(XMLNode, "aspectRatio", 1.3333); Ogre::String projectionType = getAttrib(XMLNode, "projectionType", "perspective"); // Create the camera Ogre::Camera *pCamera = mSceneMgr->createCamera(name); // Set the projection type if (projectionType == "perspective") pCamera->setProjectionType(Ogre::PT_PERSPECTIVE); else if (projectionType == "orthographic") pCamera->setProjectionType(Ogre::PT_ORTHOGRAPHIC); rapidxml::xml_node<>* pElement; // Process clipping (?) pElement = XMLNode->first_node("clipping"); if (pElement) { Ogre::Real nearDist = getAttribReal(pElement, "near"); if (nearDist > 0) pCamera->setNearClipDistance(nearDist); Ogre::Real farDist = getAttribReal(pElement, "far"); pCamera->setFarClipDistance(farDist); } // Process position (?) pElement = XMLNode->first_node("position"); if (pElement) pCamera->setPosition(parseVector3(pElement)); // Process rotation (?) pElement = XMLNode->first_node("rotation"); if (pElement) pCamera->setOrientation(parseQuaternion(pElement)); // construct a scenenode is no parent if (!pParent) { Ogre::SceneNode* pNode = mAttachNode->createChildSceneNode(name); pNode->setPosition(pCamera->getPosition()); pNode->setOrientation(pCamera->getOrientation()); pNode->scale(1, 1, 1); } }
void DotSceneLoader::processTerrain(rapidxml::xml_node<>* XMLNode) { Ogre::Real worldSize = getAttribReal(XMLNode, "worldSize"); int mapSize = Ogre::StringConverter::parseInt(XMLNode->first_attribute("mapSize")->value()); int rows = Ogre::StringConverter::parseInt(XMLNode->first_attribute("rows")->value()); int columns = Ogre::StringConverter::parseInt(XMLNode->first_attribute("columns")->value()); bool colourmapEnabled = getAttribBool(XMLNode, "colourmapEnabled"); int colourMapTextureSize = Ogre::StringConverter::parseInt(XMLNode->first_attribute("colourMapTextureSize")->value()); Ogre::Vector3 lightdir(0, -0.3, 0.75); lightdir.normalise(); Ogre::Light* l = mSceneMgr->createLight("tstLight"); l->setType(Ogre::Light::LT_DIRECTIONAL); l->setDirection(lightdir); l->setDiffuseColour(Ogre::ColourValue(1.0, 1.0, 1.0)); l->setSpecularColour(Ogre::ColourValue(0.4, 0.4, 0.4)); mSceneMgr->setAmbientLight(Ogre::ColourValue(0.6, 0.6, 0.6)); mTerrainGlobalOptions->setMaxPixelError(1); mTerrainGlobalOptions->setCompositeMapDistance(2000); mTerrainGlobalOptions->setLightMapDirection(lightdir); mTerrainGlobalOptions->setCompositeMapAmbient(mSceneMgr->getAmbientLight()); mTerrainGlobalOptions->setCompositeMapDiffuse(l->getDiffuseColour()); mTerrainGroup = OGRE_NEW Ogre::TerrainGroup(mSceneMgr, Ogre::Terrain::ALIGN_X_Z, mapSize, worldSize); mTerrainGroup->setOrigin(Ogre::Vector3::ZERO); rapidxml::xml_node<>* pElement; rapidxml::xml_node<>* pPageElement; // Process terrain pages (*) pElement = XMLNode->first_node("terrainPages"); while(pElement) { pPageElement = pElement->first_node("terrainPage"); while(pPageElement) { processTerrainPage(pPageElement); pPageElement = pPageElement->next_sibling("terrainPage"); } pElement = pElement->next_sibling("terrainPages"); } mTerrainGroup->loadAllTerrains(true); // process blendmaps pElement = XMLNode->first_node("terrainPages"); while(pElement) { pPageElement = pElement->first_node("terrainPage"); while(pPageElement) { processBlendmaps(pPageElement); pPageElement = pPageElement->next_sibling("terrainPage"); } pElement = pElement->next_sibling("terrainPages"); } mTerrainGroup->freeTemporaryResources(); //mTerrain->setPosition(mTerrainPosition); }
void DotSceneLoader::processSkyDome(rapidxml::xml_node<>* XMLNode) { // Process attributes Ogre::String material = XMLNode->first_attribute("material")->value(); Ogre::Real curvature = getAttribReal(XMLNode, "curvature", 10); Ogre::Real tiling = getAttribReal(XMLNode, "tiling", 8); Ogre::Real distance = getAttribReal(XMLNode, "distance", 4000); bool drawFirst = getAttribBool(XMLNode, "drawFirst", true); rapidxml::xml_node<>* pElement; // Process rotation (?) Ogre::Quaternion rotation = Ogre::Quaternion::IDENTITY; pElement = XMLNode->first_node("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::processSkyDome(TiXmlElement *xmlNode) { #if 0 // Process attributes std::string material = xmlNode->Attribute("material"); float curvature = getAttribReal(xmlNode, "curvature", 10); float tiling = getAttribReal(xmlNode, "tiling", 8); float distance = getAttribReal(xmlNode, "distance", 4000); bool drawFirst = getAttribBool(xmlNode, "drawFirst", true); TiXmlElement *pElement; // Process rotation (?) math::Quaternion rotation = math::Quaternion::IDENTITY; pElement = xmlNode->FirstChildElement("rotation"); if(pElement) rotation = parseQuaternion(pElement); // Setup the sky dome sceneManager->setSkyDome(true, material, curvature, tiling, distance, drawFirst, rotation, 16, 16, -1, m_sGroupName); #endif }
void DotSceneLoader::processSkyBox(TiXmlElement *xmlNode) { #if 0 // Process attributes std::string material = getAttrib(xmlNode, "material"); float distance = getAttribReal(xmlNode, "distance", 5000); bool drawFirst = getAttribBool(xmlNode, "drawFirst", true); TiXmlElement *pElement; // Process rotation (?) math::Quaternion rotation = math::Quaternion::IDENTITY; pElement = xmlNode->FirstChildElement("rotation"); if(pElement) rotation = parseQuaternion(pElement); // Setup the sky box sceneManager->setSkyBox(true, material, distance, drawFirst, rotation, m_sGroupName); #endif }
void DotSceneLoader::processSkyPlane(rapidxml::xml_node<>* XMLNode) { // Process attributes Ogre::String material = getAttrib(XMLNode, "material"); Ogre::Real planeX = getAttribReal(XMLNode, "planeX", 0); Ogre::Real planeY = getAttribReal(XMLNode, "planeY", -1); Ogre::Real planeZ = getAttribReal(XMLNode, "planeX", 0); Ogre::Real planeD = getAttribReal(XMLNode, "planeD", 5000); Ogre::Real scale = getAttribReal(XMLNode, "scale", 1000); Ogre::Real bow = getAttribReal(XMLNode, "bow", 0); Ogre::Real tiling = getAttribReal(XMLNode, "tiling", 10); bool drawFirst = getAttribBool(XMLNode, "drawFirst", true); // Setup the sky plane Ogre::Plane plane; plane.normal = Ogre::Vector3(planeX, planeY, planeZ); plane.d = planeD; mSceneMgr->setSkyPlane(true, plane, material, scale, tiling, drawFirst, bow, 1, 1, m_sGroupName); }
void DotSceneLoader::processSkyBox(rapidxml::xml_node<>* XMLNode) { // Process attributes Ogre::String material = getAttrib(XMLNode, "material", "BaseWhite"); Ogre::Real distance = getAttribReal(XMLNode, "distance", 5000); bool drawFirst = getAttribBool(XMLNode, "drawFirst", true); bool active = getAttribBool(XMLNode, "active", false); if (!active) return; rapidxml::xml_node<>* pElement; // Process rotation (?) Ogre::Quaternion rotation = Ogre::Quaternion::IDENTITY; pElement = XMLNode->first_node("rotation"); if (pElement) rotation = parseQuaternion(pElement); // Setup the sky box mSceneMgr->setSkyBox(true, material, distance, drawFirst, rotation, m_sGroupName); }
void DotSceneLoader::processSkyPlane(TiXmlElement *xmlNode) { #if 0 // Process attributes std::string material = getAttrib(xmlNode, "material"); float planeX = getAttribReal(xmlNode, "planeX", 0); float planeY = getAttribReal(xmlNode, "planeY", -1); float planeZ = getAttribReal(xmlNode, "planeX", 0); float planeD = getAttribReal(xmlNode, "planeD", 5000); float scale = getAttribReal(xmlNode, "scale", 1000); float bow = getAttribReal(xmlNode, "bow", 0); float tiling = getAttribReal(xmlNode, "tiling", 10); bool drawFirst = getAttribBool(xmlNode, "drawFirst", true); // Setup the sky plane Plane plane; plane.normal = math::Vector3(planeX, planeY, planeZ); plane.d = planeD; sceneManager->setSkyPlane(true, plane, material, scale, tiling, drawFirst, bow, 1, 1, m_sGroupName); #endif }
void DotSceneLoader::processCamera(rapidxml::xml_node<>* XMLNode, Ogre::SceneNode *pParent) { // Process attributes Ogre::String name = getAttrib(XMLNode, "name"); Ogre::String id = getAttrib(XMLNode, "id"); Ogre::Real fov = getAttribReal(XMLNode, "fov", 45); Ogre::Real aspectRatio = getAttribReal(XMLNode, "aspectRatio", 1.3333); Ogre::String projectionType = getAttrib(XMLNode, "projectionType", "perspective"); // Create the camera Ogre::Camera *pCamera = mSceneMgr->createCamera(name); //TODO: make a flag or attribute indicating whether or not the camera should be attached to any parent node. //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(Ogre::PT_PERSPECTIVE); else if (projectionType == "orthographic") pCamera->setProjectionType(Ogre::PT_ORTHOGRAPHIC); rapidxml::xml_node<>* pElement; // Process clipping (?) pElement = XMLNode->first_node("clipping"); if (pElement) { Ogre::Real nearDist = getAttribReal(pElement, "near"); pCamera->setNearClipDistance(nearDist); Ogre::Real farDist = getAttribReal(pElement, "far"); pCamera->setFarClipDistance(farDist); } // Process position (?) pElement = XMLNode->first_node("position"); if (pElement) pCamera->setPosition(parseVector3(pElement)); // Process rotation (?) pElement = XMLNode->first_node("rotation"); if (pElement) pCamera->setOrientation(parseQuaternion(pElement)); // Process normal (?) pElement = XMLNode->first_node("normal"); if (pElement) ;//!< @todo What to do with this element? // Process lookTarget (?) pElement = XMLNode->first_node("lookTarget"); if (pElement) ;//!< @todo Implement the camera look target // Process trackTarget (?) pElement = XMLNode->first_node("trackTarget"); if (pElement) ;//!< @todo Implement the camera track target // Process userDataReference (?) pElement = XMLNode->first_node("userDataReference"); if (pElement) ;//!< @todo Implement the camera user data reference // construct a scenenode is no parent if (!pParent) { Ogre::SceneNode* pNode = mAttachNode->createChildSceneNode(name); pNode->setPosition(pCamera->getPosition()); pNode->setOrientation(pCamera->getOrientation()); pNode->scale(1, 1, 1); } }
void DotSceneLoader::processTerrainPage(rapidxml::xml_node<>* XMLNode) { Ogre::String name = getAttrib(XMLNode, "name"); int pageX = Ogre::StringConverter::parseInt(XMLNode->first_attribute("pageX")->value()); int pageY = Ogre::StringConverter::parseInt(XMLNode->first_attribute("pageY")->value()); Ogre::Real worldSize = getAttribReal(XMLNode, "worldSize"); int mapSize = Ogre::StringConverter::parseInt(XMLNode->first_attribute("mapSize")->value()); bool colourmapEnabled = getAttribBool(XMLNode, "colourmapEnabled"); int colourmapTexturesize = Ogre::StringConverter::parseInt(XMLNode->first_attribute("colourmapTexturesize")->value()); int layerCount = Ogre::StringConverter::parseInt(XMLNode->first_attribute("layerCount")->value()); Ogre::String filename = mTerrainGroup->generateFilename(pageX, pageY); if (Ogre::ResourceGroupManager::getSingleton().resourceExists(mTerrainGroup->getResourceGroup(), filename)) { mTerrainGroup->defineTerrain(pageX, pageY); } else { rapidxml::xml_node<>* pElement; pElement = XMLNode->first_node("position"); if(pElement) mTerrainPosition = parseVector3(pElement); Ogre::DataStreamPtr stream = Ogre::ResourceGroupManager::getSingleton().openResource(name + Ogre::String(".ohm"), "General" ); size_t size = stream.get()->size(); if(size != mapSize * mapSize * 4) { OGRE_EXCEPT( Ogre::Exception::ERR_INTERNAL_ERROR, "Size of stream does not match terrainsize!", "TerrainPage" ); } float* buffer = OGRE_ALLOC_T(float, size, Ogre::MEMCATEGORY_GEOMETRY); stream->read(buffer, size); Ogre::Terrain::ImportData& imp = mTerrainGroup->getDefaultImportSettings(); imp.terrainSize = mapSize; imp.worldSize = worldSize; imp.inputFloat = buffer; imp.inputImage = 0; imp.deleteInputData = true; imp.minBatchSize = 33; imp.maxBatchSize = 65; imp.layerList.resize(layerCount); int count = 0; // Process layers (*) rapidxml::xml_node<>* pTerrainLayer; rapidxml::xml_node<>* pTerrainTextures; rapidxml::xml_node<>* pTerrainTexture; pElement = XMLNode->first_node("layers"); while(pElement) { pTerrainLayer = pElement->first_node("layer"); while(pTerrainLayer) { int worldSize = Ogre::StringConverter::parseInt(pTerrainLayer->first_attribute("worldSize")->value()); pTerrainTextures = pTerrainLayer->first_node("textures"); pTerrainTexture = pTerrainTextures->first_node("texture"); while(pTerrainTexture) { imp.layerList[count].textureNames.push_back(getAttrib(pTerrainTexture,"name","")); imp.layerList[count].worldSize = (Ogre::Real)worldSize; pTerrainTexture = pTerrainTexture->next_sibling("texture"); } count++; // do stuff pTerrainLayer = pTerrainLayer->next_sibling("layer"); } pElement = pElement->next_sibling("layers"); } mTerrainGroup->defineTerrain(pageX, pageY, &imp); } }
void DotSceneLoader::processCamera(TiXmlElement *xmlNode, Node *pParent) { #if 0 // Process attributes std::string name = getAttrib(xmlNode, "name"); std::string id = getAttrib(xmlNode, "id"); float fov = getAttribReal(xmlNode, "fov", 45); float aspectRatio = getAttribReal(xmlNode, "aspectRatio", 1.3333); std::string projectionType = getAttrib(xmlNode, "projectionType", "perspective"); // Create the camera Camera *pCamera = sceneManager->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) { float nearDist = getAttribReal(pElement, "nearPlaneDist"); pCamera->setNearClipDistance(nearDist); float farDist = getAttribReal(pElement, "farPlaneDist"); 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 #endif }