Cubemap *MaterialManager::cubemapFromXMLNode(TiXmlNode *node) { TiXmlElement *nodeElement = node->ToElement(); if (!nodeElement) return NULL; // Skip comment nodes Cubemap *newCubemap = NULL; String name = nodeElement->Attribute("name"); String xPos = nodeElement->Attribute("xPos"); String xNeg = nodeElement->Attribute("xNeg"); String yPos = nodeElement->Attribute("yPos"); String yNeg = nodeElement->Attribute("yNeg"); String zPos = nodeElement->Attribute("zPos"); String zNeg = nodeElement->Attribute("zNeg"); newCubemap = CoreServices::getInstance()->getRenderer()->createCubemap( CoreServices::getInstance()->getMaterialManager()->createTextureFromFile(xPos), CoreServices::getInstance()->getMaterialManager()->createTextureFromFile(xNeg), CoreServices::getInstance()->getMaterialManager()->createTextureFromFile(yPos), CoreServices::getInstance()->getMaterialManager()->createTextureFromFile(yNeg), CoreServices::getInstance()->getMaterialManager()->createTextureFromFile(zPos), CoreServices::getInstance()->getMaterialManager()->createTextureFromFile(zNeg) ); newCubemap->setResourceName(name); return newCubemap; }
Cubemap *MaterialManager::cubemapFromXMLNode(TiXmlNode *node) { TiXmlElement *nodeElement = node->ToElement(); if (!nodeElement) return NULL; // Skip comment nodes Cubemap *newCubemap = NULL; String name = nodeElement->Attribute("name"); String mapString = nodeElement->GetText(); vector<String> maps = mapString.split(","); if(maps.size() != 6) { Logger::log("Error: A cubemap must contain 6 images \n"); return NULL; } newCubemap = CoreServices::getInstance()->getRenderer()->createCubemap( (Texture*)CoreServices::getInstance()->getResourceManager()->getResource(Resource::RESOURCE_TEXTURE, maps[0]), (Texture*)CoreServices::getInstance()->getResourceManager()->getResource(Resource::RESOURCE_TEXTURE, maps[1]), (Texture*)CoreServices::getInstance()->getResourceManager()->getResource(Resource::RESOURCE_TEXTURE, maps[2]), (Texture*)CoreServices::getInstance()->getResourceManager()->getResource(Resource::RESOURCE_TEXTURE, maps[3]), (Texture*)CoreServices::getInstance()->getResourceManager()->getResource(Resource::RESOURCE_TEXTURE, maps[4]), (Texture*)CoreServices::getInstance()->getResourceManager()->getResource(Resource::RESOURCE_TEXTURE, maps[5]) ); newCubemap->setResourceName(name); return newCubemap; }