Beispiel #1
0
void MeshExporter::ExtractSkeleton(IGameNode * node)
{
	if(!node->IsGroupOwner())
		_dumpJoint(node);

	for(int i=0;i<node->GetChildCount();i++)
	{
		IGameNode * child = node->GetNodeChild(i);
		// we deal with targets in the light/camera section
		if(child->IsTarget())
			continue;

		ExtractSkeleton(child);
	}

	node->ReleaseIGameObject();
}
Beispiel #2
0
int TrianExporter::DoExport( const TCHAR * name, ExpInterface *ei, Interface *i, BOOL suppressPrompts, DWORD options )
{
	//Open the file to export to.
	m_of.open( name );

	//Create an Error procedure.
	MyErrorProc pErrorProc;
	SetErrorCallBack( &pErrorProc );

	//Get the game interface
	m_pIGame = GetIGameInterface();

	//Start the progress bar.
	i->ProgressStart( _T( "Exporting to .trian file..." ), TRUE, fn, NULL );

	//Set up the conversion manager.
	IGameConversionManager * cm = GetConversionManager();
	
	//Set up the whacky coordinate system that 3DS Max uses.
	UserCoord whacky = 
	{
		1, //Right-Handed.
		1, //X Axis goes right.
		4, //Y Axis goes in.
		3, //Z Axis goes down.
		0, //U Tex Axis is left.
		1  //V Tex Axis is down.
	};
	cm->SetUserCoordSystem( whacky );

	//Set the coordinate system.
	cm->SetCoordSystem( IGameConversionManager::IGAME_MAX );
	
	//Initialize the game scene.
	m_pIGame->InitialiseIGame( options & SCENE_EXPORT_SELECTED );

	//Go through all the nodes of the scene and export only the Game Meshes.
	for( int l = 0; l < m_pIGame->GetTopLevelNodeCount(); l++ )
	{
		//Get the current Game node.
		IGameNode * node = m_pIGame->GetTopLevelNode( l );

		//Check for selected state.
		if( node->IsTarget() )
			continue;

		ExportNodeInfo( node );
	}

	//End the progress bar.
	i->ProgressEnd();

	//Release the scene.
	m_pIGame->ReleaseIGame();
	m_pIGame = 0;

	//Close the output stream.
	m_of.close();

	return TRUE;
}
Beispiel #3
0
void MeshExporter::ExtractMesh(IGameNode * node)
{
	IGameObject* obj = node->GetIGameObject();

	// export option
	bool expColor = ExportConfig::Instance()->IsExportColor();
	bool expNormal = ExportConfig::Instance()->IsExportNormal();
	bool expTexcoord = ExportConfig::Instance()->IsExportTexcoord();
	bool expLightmapUV = ExportConfig::Instance()->IsExportLightmapUV();

	obj->InitializeData();

	const char * nodeName = node->GetName();

	IGameNode * parent = node->GetNodeParent();
	IGameMesh::ObjectTypes type = obj->GetIGameType();

	if (type == IGameMesh::IGAME_MESH)
	{
		IGameMesh* mesh = (IGameMesh*) obj;
		Tab<int> texMaps = mesh->GetActiveMapChannelNum();

		mMeshData.VertexElems |= MeshSerializer::VE_POSITION;

		// position
		for (int i = 0; i < mesh->GetNumberOfVerts(); ++i)
			mMeshData.P.PushBack(Utility::ToFloat3(mesh->GetVertex(i)));

		// vertex color
		for (int i = 0; expColor && i < mesh->GetNumberOfColorVerts(); ++i)
		{
			Point3 c = mesh->GetColorVertex(i);
			float a = mesh->GetAlphaVertex(i);

			mMeshData.C.PushBack(Float4(c.x, c.y, c.z, a));
			mMeshData.VertexElems |= MeshSerializer::VE_COLOR;
		}

		// normal
		for (int i = 0; expNormal && i < mesh->GetNumberOfNormals(); ++i)
		{
			mMeshData.N.PushBack(Utility::ToFloat3(mesh->GetNormal(i)));
			mMeshData.VertexElems |= MeshSerializer::VE_NORMAL;
		}

		// uv
		for (int i = 0;  expTexcoord && texMaps.Count() > 1 && i < mesh->GetNumberOfMapVerts(texMaps[1]); ++i)
		{
			Point3 tv = mesh->GetMapVertex(texMaps[1], i);

			mMeshData.UV.PushBack(Float2(tv.x, 1 - tv.y));
			mMeshData.VertexElems |= MeshSerializer::VE_TEXCOORD;
		}

		// light map uv
		for (int i = 0;  expLightmapUV && texMaps.Count() > 2 && i < mesh->GetNumberOfMapVerts(texMaps[2]); ++i)
		{
			Point3 tv = mesh->GetMapVertex(texMaps[2], i);

			mMeshData.LUV.PushBack(Float2(tv.x, 1 - tv.y));
			mMeshData.VertexElems |= MeshSerializer::VE_LIGHTMAPUV;
		}

		IGameSkin * skin = obj->GetIGameSkin();
		if (skin != NULL)
			_dumpSkinInfo(skin);
		else if (parent != NULL && parent->GetIGameObject()->GetIGameType() == IGameMesh::IGAME_BONE)
			_genSkinInfo(parent);

		_dumpMeshBuffer(mesh);

		mMeshData.Clear();
	}

	for(int i=0;i<node->GetChildCount();i++)
	{
		IGameNode * child = node->GetNodeChild(i);
		// we deal with targets in the light/camera section
		if(child->IsTarget())
			continue;

		ExtractMesh(child);
	}

	node->ReleaseIGameObject();
}