Ejemplo n.º 1
0
//-----------------------------------------------------------------------
void
System::clearStaticGeometries(void)
{
    std::list<Ogre::StaticGeometry*>::const_iterator it;
    for (it = mStaticGeometries.begin(); it != mStaticGeometries.end(); ++it)
    {
        Ogre::StaticGeometry* sg = *it;
        getSceneManager()->destroyStaticGeometry(sg->getName());
    }

    mStaticGeometries.clear();
}
Ejemplo n.º 2
0
bool LevelGeometryLoader::processStaticGeometries(TiXmlElement *XMLRoot)
{
	ASSERT(XMLRoot);

	TiXmlElement *pElement, *auxPElem;

	// Process nodes (?)
	pElement = XMLRoot->FirstChildElement("staticGeometries");
	if(!pElement){
		debug("Error: Invalid .scene processStaticGeometries\n" );
		return false;
	}

	mStaticGeometry.clear();

	Ogre::StaticGeometry	*sgeo = 0;
	Ogre::Vector3			origin;
	Ogre::Vector3			dimension;
	bool					visible;
	Ogre::String			name;
	bool					castShadow;

	// parse the staticGeometries
	pElement = pElement->FirstChildElement("staticGeometry");
	while(pElement)
	{
		// Parse a StaticGeometry
		visible = Ogre::DotSceneLoader::getAttribBool(pElement, "visible");
		name = Ogre::DotSceneLoader::getAttrib(pElement, "name");
		castShadow = Ogre::DotSceneLoader::getAttribBool(pElement, "castShadows");

		try {
			sgeo = Common::GlobalObjects::sceneManager->createStaticGeometry(name);
			debug("StaticGeometry %s created\n", name.c_str());
		} catch(...) {
			debug("Error: Invalid name to StaticGeometry\n" );
			return false;
		}

		mStaticGeometry.push_back(sgeo);

		sgeo->setCastShadows(castShadow);
		sgeo->setVisible(visible);

		// get the origin
		auxPElem = pElement->FirstChildElement("origin");
		if(auxPElem) {
			sgeo->setOrigin(Ogre::DotSceneLoader::parseVector3(auxPElem));
		}

		// get the dimensions
		auxPElem = pElement->FirstChildElement("dimensions");
		if(auxPElem) {
			sgeo->setRegionDimensions(Ogre::DotSceneLoader::parseVector3(auxPElem));
		}

		// iterate over the entity list
		auxPElem = pElement;
		auxPElem = auxPElem->FirstChildElement("entities");
		if(!auxPElem){
			debug("Error: StaticGeometry without Entity! %s\n", sgeo->getName().c_str());
			ASSERT(false);
			mStaticGeometry.erase(mStaticGeometry.end()-1);
			Common::GlobalObjects::sceneManager->destroyStaticGeometry(sgeo);
			pElement = pElement->NextSiblingElement("staticGeometry");
			continue;
		}
		auxPElem = auxPElem->FirstChildElement("entity");
		while(auxPElem){
			// get the entities associated
			if(!processEntityStaticGeoemtry(auxPElem, sgeo)){
				debug("Error: Invalid entity of StaticGeometry\n" );
				return false;
			}

			auxPElem = auxPElem->NextSiblingElement("entity");
		}

		// build the staticGeometry
		sgeo->build();

		pElement = pElement->NextSiblingElement("staticGeometry");
	}


	return true;

}