コード例 #1
0
ファイル: MmOptimiseTool.cpp プロジェクト: xubingyue/Ogitor
	//------------------------------------------------------------------------
	void OptimiseTool::doInvoke(const OptionList& toolOptions,
		const Ogre::StringVector& inFileNames, const Ogre::StringVector& outFileNamesArg)
	{
		// Name count has to match, else we have no way to figure out how to apply output
		// names to input files.
		if (!(outFileNamesArg.empty() || inFileNames.size() == outFileNamesArg.size()))
		{
			fail("number of output files must match number of input files.");
		}

		mPosTolerance = mNormTolerance = mUVTolerance = 1e-06f;
		mKeepIdentityTracks = OptionsUtil::isOptionSet(toolOptions, "keep-identity-tracks");
		for (OptionList::const_iterator it = toolOptions.begin(); it != toolOptions.end(); ++it)
		{
			if (it->first == "tolerance")
			{
				mPosTolerance = mNormTolerance = mUVTolerance = static_cast<float>(any_cast<Real>(it->second));
			}
			else if (it->first == "pos_tolerance")
			{
				mPosTolerance = static_cast<float>(any_cast<Real>(it->second));
			}
			else if (it->first == "norm_tolerance")
			{
				mNormTolerance = static_cast<float>(any_cast<Real>(it->second));
			}
			else if (it->first == "uv_tolerance")
			{
				mUVTolerance = static_cast<float>(any_cast<Real>(it->second));
			}
		}


		StringVector outFileNames = outFileNamesArg.empty() ? inFileNames : outFileNamesArg;

		// Process the meshes
		for (size_t i = 0, end = inFileNames.size(); i < end; ++i)
		{
			if (StringUtil::endsWith(inFileNames[i], ".mesh", true))
			{
				processMeshFile(inFileNames[i], outFileNames[i]);
			}
			else if (StringUtil::endsWith(inFileNames[i], ".skeleton", true))
			{
				processSkeletonFile(inFileNames[i], outFileNames[i]);
			}
			else
			{
				warn("unrecognised name ending for file " + inFileNames[i]);
				warn("file skipped.");
			}
		}
	}
コード例 #2
0
bool Parser::processMesh()
{	
	std::string strMaterial, strTemp;
	Material	*pMaterial;
	Shape		*pShape;
	Transform	tTrans;
	
	// Lista de punteros a MeshTriangle a añadir a la escena, que será
	// construida durante la lectura de la lista de vértices o del
	// fichero .obj que se nos proporcione. Una vez construida, los
	// añadiremos a la escena.
	std::vector<MeshTriangle *> MTList;	
	
	if(!ignorarChars())
			return false;
			
	if(!readToken(strTemp))
		return false;
			
	if(strTemp == "vertex_list") {
		if(!processMeshVertex(pShape, &MTList))
			return false;
	}
	else if(strTemp == "file") {
		pShape = new Mesh();
		
		if(!processMeshFile(pShape, &MTList))
		return false;
	}
	else // Etiqueta desconocida, descripción errónea de la malla
		return false;
				
	if(!readBloqueTxt("material", strMaterial))
		return false;
	
	if(!ignorarChars())
		return false;
		
	if(!readToken(strTemp))
		return false;
	
	if(strTemp == "transform") {
		if(!processTransform(&tTrans))
			return false;
		
		if(!ignorarChars())
			return false;
		
		if(!readToken(strTemp))
			return false;
	}
	
	if(strTemp != "/object")
		return false;
	
	if((pMaterial = m_pGlobals->pScene->getMaterial(strMaterial)) != NULL) {
		pShape->setMaterial(pMaterial);
		pShape->setTrans(&tTrans);
		m_pGlobals->pScene->addObject(pShape, strMaterial, pMaterial->isLight());		
		
		// Añadimos ahora a la escena todos los triángulos que componen la malla
		for(int i = 0; i < (int) MTList.size(); i++)
			m_pGlobals->pScene->addObject((Shape *) MTList[i], strMaterial, pMaterial->isLight());		
	}
	else // Material asociado al objeto desconocido.
		return false; 
	
	return true;
}