示例#1
0
int main(int numargs, char** args)
{
	if (numargs < 2)
        return -1;

	parseArgs(numargs, args);

    auto root = OGRE_NEW Ogre::Root("", "", "ogre.log");
    root->loadPlugin("RenderSystem_Direct3D9_d");
    root->setRenderSystem(root->getRenderSystemByName("Direct3D9 Rendering Subsystem"));
    root->getRenderSystem()->setConfigOption("Full Screen","No");
    root->initialise(true);
	converterMgr = new ConverterMgr();

	CovOptions option;
	option.source = srcName.c_str();
	option.dest   = destName.c_str();

	Ogre::ResourceGroupManager::getSingleton().addResourceLocation(srcName.ExtractDirName().c_str(),"FileSystem");
	Ogre::ResourceGroupManager::getSingleton().initialiseResourceGroup(Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);

	if (isAnimation)
	{
		converterMgr->SkeletonToMotion(option);
	}
	else
	{
		converterMgr->MeshToModel(option);
	}

	delete converterMgr;
    delete root;
    return 0;
}
示例#2
0
void ModelConverter::ExportMesh( const Mesh* pMesh, const String& filename )
{
	LogManager::getSingleton().logMessage("XMLMeshSerializer writing mesh data to " + filename + "...");
	
	mMesh = const_cast<Mesh*>(pMesh);

	LogManager::getSingleton().logMessage("Populating DOM...");

	DiMeshPtr mesh = WriteMesh(pMesh);

	LogManager::getSingleton().logMessage("DOM populated, writing model file..");

	if (mesh)
	{
		// save to file
		DiMeshSerializer ms;
		ms.ExportMesh(mesh,filename);

		// write material files
		DiMesh::SubMeshIterator it = mesh->GetSubMeshs();
		while (it.HasMoreElements())
		{
			DiSubMesh* subMesh = it.GetNext();
			unsigned int maxw = subMesh->GetMaxWeights();
			DiString matname = subMesh->GetMaterialName();

			DiString matfile = filename.c_str();
			matfile = matfile.ExtractDirName();
			matfile += matname;

			WriteSimpleMaterial(maxw,matfile);
		}
	}
}
示例#3
0
void parseArgs(int numArgs, char **args)
{
	srcName = args[1];
	srcName.ToLower();
	if(srcName.CheckFileExtension("skeleton") ||
		srcName.CheckFileExtension("skeleton"))
	{
		isAnimation = true;
	}

	if(numArgs == 2)
	{
		destName = srcName.ExtractDirName();
		DiString temp = srcName.ExtractFileName().ExtractBaseName();
		destName.append(temp);
		destName.append(!isAnimation?".model":".motion");
	}
	else if(numArgs == 3)
	{
		destName = args[2];
	}
}