Exemplo n.º 1
0
	//---------------------------------------------------------------------
	void SceneResource::processSceneNodeContent(const Util::XmlNode * snNode, SceneNodePtr & sceneNode, bool isChild) const
	{
		WHISPERWIND_ASSERT(snNode);

		/// node property
		{
			Util::String posStr(mXmlReader->getAttribute(snNode, "position"));
			XMVECTOR posVec = Util::StringToVector(posStr, 3);

			Util::String orientStr(mXmlReader->getAttribute(snNode, "orientation"));
			XMVECTOR orientVec = Util::StringToVector(orientStr, 4);

			if (!isChild)
			{
				sceneNode->setPosition(posVec);
				sceneNode->setOrientation(orientVec);
			}
			else
			{
				sceneNode->setRelativePosition(posVec);
				sceneNode->setRelativeOrientation(orientVec);
			}
		}

		const Util::XmlNode * snChildNode = mXmlReader->getFirstNode(snNode, "child_node");
		while (snChildNode)
		{
			processChildSceneNode(snChildNode, sceneNode);

			snChildNode = mXmlReader->getNextSiblingNode(snChildNode);
		}

		const Util::XmlNode * soNode = mXmlReader->getFirstNode(snNode, "object");
		while (soNode)
		{
			processSceneObject(soNode, sceneNode);

			soNode = mXmlReader->getNextSiblingNode(soNode);
		}

		const Util::XmlNode * lightNode = mXmlReader->getFirstNode(snNode, "light");
		while (lightNode)
		{
			processLight(lightNode, sceneNode);

			lightNode = mXmlReader->getNextSiblingNode(lightNode);
		}

		const Util::XmlNode * trackNode = mXmlReader->getFirstNode(snNode, "node_track");
		while (trackNode)
		{
			processNodeTrack(trackNode, sceneNode);

			trackNode = mXmlReader->getNextSiblingNode(trackNode);
		}
	}
Exemplo n.º 2
0
void DotSceneLoader::processScene(TiXmlElement* xmlRoot) {
	std::string version = getAttrib(xmlRoot, "formatVersion", "unknown");

	std::string message = "[DotSceneLoader] Parsing dotScene file with version " + version;

	if(xmlRoot->Attribute("ID"))
		message += ", id " + std::string(xmlRoot->Attribute("ID"));
	if(xmlRoot->Attribute("sceneManager"))
		message += ", scene manager " + std::string(xmlRoot->Attribute("sceneManager"));
	if(xmlRoot->Attribute("minOgreVersion"))
		message += ", min. Ogre version " + std::string(xmlRoot->Attribute("minOgreVersion"));
	if(xmlRoot->Attribute("author"))
		message += ", author " + std::string(xmlRoot->Attribute("author"));

	TiXmlElement *element;

	// Process nodes (?)
	element = xmlRoot->FirstChildElement("nodes");
	if(element)
		processNodes(element);

	// Process externals (?)
	element = xmlRoot->FirstChildElement("externals");
	if(element)
		processExternals(element);

	// Process environment (?)
	element = xmlRoot->FirstChildElement("environment");
	if(element)
		processEnvironment(element);

	// Process terrain (?)
	element = xmlRoot->FirstChildElement("terrain");
	if(element)
		processTerrain(element);

	// Process userDataReference (?)
	element = xmlRoot->FirstChildElement("userDataReference");
	if(element)
		processUserDataReference(element);

	// Process octree (?)
	element = xmlRoot->FirstChildElement("octree");
	if(element)
		processOctree(element);

	// Process light (?)
	element = xmlRoot->FirstChildElement("light");
	if(element)
		processLight(element);

	// Process camera (?)
	element = xmlRoot->FirstChildElement("camera");
	if(element)
		processCamera(element);
}
Exemplo n.º 3
0
void ModelExporter::processNodes()
{
	AABB bounds = calculateModelBounds();

	if (_centerObjects)
	{
		// Depending on the center point, we need to use the object bounds
		// or just the translation towards the user-defined origin, ignoring bounds
		_centerTransform = _useOriginAsCenter ?
			Matrix4::getTranslation(-_origin) :
			Matrix4::getTranslation(-bounds.origin);
	}

	for (const scene::INodePtr& node : _nodes)
	{
		if (Node_isModel(node))
		{
			model::ModelNodePtr modelNode = Node_getModel(node);

			// Push the geometry into the exporter
			model::IModel& model = modelNode->getIModel();

			Matrix4 exportTransform = node->localToWorld().getPremultipliedBy(_centerTransform);

			for (int s = 0; s < model.getSurfaceCount(); ++s)
			{
				const model::IModelSurface& surface = model.getSurface(s);

				if (isExportableMaterial(surface.getActiveMaterial()))
				{
					_exporter->addSurface(surface, exportTransform);
				}
			}
		}
		else if (Node_isBrush(node))
		{
			processBrush(node);
		}
		else if (Node_isPatch(node))
		{
			processPatch(node);
		}
		else if (_exportLightsAsObjects && Node_getLightNode(node))
		{
			processLight(node);
		}
	}
}
Exemplo n.º 4
0
void	doBuildingLights( void )
{
	STRUCTURE	*psStructure;
	UDWORD	i;
	LIGHT	light;

	for(i=0; i<MAX_PLAYERS; i++)
	{
		for(psStructure = apsStructLists[i]; psStructure; psStructure = psStructure->psNext)
		{
			light.range = psStructure->pStructureType->baseWidth * TILE_UNITS;
			light.position.x = psStructure->pos.x;
			light.position.z = psStructure->pos.y;
			light.position.y = map_Height(light.position.x,light.position.z);
			light.range = psStructure->pStructureType->baseWidth * TILE_UNITS;
			light.colour = LIGHT_WHITE;
			processLight(&light);
		}
	}
}
Exemplo n.º 5
0
void DotSceneLoader::processNode(rapidxml::xml_node<>* XMLNode,
		Ogre::SceneNode *pParent) {
	// Construct the node's name
	Ogre::String name = m_sPrependNode + getAttrib(XMLNode, "name");

	// Create the scene node
	Ogre::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);
	}

	std::cout << pNode->getName();

	// Process other attributes
	Ogre::String id = getAttrib(XMLNode, "id");
//  bool isTarget = getAttribBool(XMLNode, "isTarget");

	rapidxml::xml_node<>* pElement;

	// Process position (?)
	pElement = XMLNode->first_node("position");
	if (pElement) {
		pNode->setPosition(parseVector3(pElement));
		pNode->setInitialState();
	}

	// Process rotation (?)
	pElement = XMLNode->first_node("rotation");
	if (pElement) {
		pNode->setOrientation(parseQuaternion(pElement));
		pNode->setInitialState();
	}

	// Process scale (?)
	pElement = XMLNode->first_node("scale");
	if (pElement) {
		pNode->setScale(parseVector3(pElement));
		pNode->setInitialState();
	}

	// Process lookTarget (?)
	pElement = XMLNode->first_node("lookTarget");
	if (pElement)
		processLookTarget(pElement, pNode);

	// Process trackTarget (?)
	pElement = XMLNode->first_node("trackTarget");
	if (pElement)
		processTrackTarget(pElement, pNode);

	// Process node (*)
	pElement = XMLNode->first_node("node");
	while (pElement) {
		processNode(pElement, pNode);
		pElement = pElement->next_sibling("node");
	}

	// Process entity (*)
	pElement = XMLNode->first_node("entity");
	while (pElement) {
		processEntity(pElement, pNode);
		pElement = pElement->next_sibling("entity");
	}

	// Process light (*)
	pElement = XMLNode->first_node("light");
	while (pElement) {
	    processLight(pElement, pNode);
	    pElement = pElement->next_sibling("light");
	}

	// Process camera (*)
	pElement = XMLNode->first_node("camera");
	while (pElement) {
		processCamera(pElement, pNode);
		pElement = pElement->next_sibling("camera");
	}

	// Process particleSystem (*)
	pElement = XMLNode->first_node("particleSystem");
	while (pElement) {
		processParticleSystem(pElement, pNode);
		pElement = pElement->next_sibling("particleSystem");
	}

	// Process plane (*)
	pElement = XMLNode->first_node("plane");
	while (pElement) {
		processPlane(pElement, pNode);
		pElement = pElement->next_sibling("plane");
	}

	// Process userDataReference (?)
	pElement = XMLNode->first_node("userDataReference");

	// Process entity (*)
	pElement = XMLNode->first_node("pagedgeometry");
	while (pElement) {
		processPagedGeometry(pElement);
		pElement = pElement->next_sibling("pagedgeometry");
	}
}
Exemplo n.º 6
0
void DotSceneLoader::processNode(TiXmlElement *xmlNode, Node *pParent) {
	// Construct the node's name
	std::string name = getAttrib(xmlNode, "name");

	// Create the scene node
	Node *node;
	if(name.empty()) {
		// Let Ogre choose the name
		if(pParent) {
			node = scene->createNode();
			pParent->addChild(node);
		} else {
			node = scene->createNode();
			rootNode->addChild(node);
		}
	} else {
		// Provide the name
		if(pParent) {
			node = scene->createNode(/*name*/);
			pParent->addChild(node);
		} else {
			node = scene->createNode(/*name*/);
			rootNode->addChild(node);
		}
	}

	// Process other attributes
	std::string id = getAttrib(xmlNode, "id");
	bool isTarget = getAttribBool(xmlNode, "isTarget");

	TiXmlElement *element;

	// Process position (?)
	element = xmlNode->FirstChildElement("position");
	if(element) {
		node->setPosition(parseVector3(element));
	}

	// Process rotation (?)
	element = xmlNode->FirstChildElement("rotation");
	if(element) {
		node->setOrientation(parseQuaternion(element));
	}

	// Process scale (?)
	element = xmlNode->FirstChildElement("scale");
	if(element) {
		node->setScale(parseVector3(element));
	}

	// Process lookTarget (?)
	element = xmlNode->FirstChildElement("lookTarget");
	if(element)
		processLookTarget(element, node);

	// Process trackTarget (?)
	element = xmlNode->FirstChildElement("trackTarget");
	if(element)
		processTrackTarget(element, node);

	// Process node (*)
	element = xmlNode->FirstChildElement("node");
	while(element) {
		processNode(element, node);
		element = element->NextSiblingElement("node");
	}

	// Process entity (*)
	element = xmlNode->FirstChildElement("entity");
	while(element) {
		processEntity(element, node);
		element = element->NextSiblingElement("entity");
	}

	// Process light (*)
	element = xmlNode->FirstChildElement("light");
	while(element) {
		processLight(element, node);
		element = element->NextSiblingElement("light");
	}

	// Process camera (*)
	element = xmlNode->FirstChildElement("camera");
	while(element) {
		processCamera(element, node);
		element = element->NextSiblingElement("camera");
	}

	// Process particleSystem (*)
	element = xmlNode->FirstChildElement("particleSystem");
	while(element) {
		processParticleSystem(element, node);
		element = element->NextSiblingElement("particleSystem");
	}

	// Process billboardSet (*)
	element = xmlNode->FirstChildElement("billboardSet");
	while(element) {
		processBillboardSet(element, node);
		element = element->NextSiblingElement("billboardSet");
	}

	// Process plane (*)
	element = xmlNode->FirstChildElement("plane");
	while(element) {
		processPlane(element, node);
		element = element->NextSiblingElement("plane");
	}

	// Process userDataReference (?)
	element = xmlNode->FirstChildElement("userDataReference");
	if(element)
		processUserDataReference(element, node);
}