Exemplo n.º 1
0
//--------------------------------------------------------
//	import the XML and convert from collada to mesh
//--------------------------------------------------------
SyncBool TLFileSys::TFileCollada::ExportAsset(TPtr<TLAsset::TAsset>& pAsset,TRefRef ExportAssetType)
{
	if ( pAsset )
	{
		TLDebug_Break("Async export not supported yet. asset should be NULL");
		return SyncFalse;
	}

	//	import xml
	SyncBool ImportResult = TFileXml::Import();
	if ( ImportResult != SyncTrue )
		return ImportResult;


	//	get the root svg tag (all items are under this and contains scene info)
	TPtr<TXmlTag> pRootTag = m_XmlData.GetChild("collada");

	//	malformed SVG maybe
	if ( !pRootTag )
		return SyncFalse;

	//	import material information
	TLDebug_Print("Collada: Importing material libraries...");
	if ( !ImportMaterialLibraries( *pRootTag ) )
		return SyncFalse;

	//	import geometry information
	TLDebug_Print("Collada: Importing geometry libraries...");
	if ( !ImportGeometryLibraries( *pRootTag ) )
		return SyncFalse;

	//	create mesh asset
	TPtr<TLAsset::TMesh> pNewMesh = new TLAsset::TMesh( GetFileRef() );
	pNewMesh->SetLoadingState( TLAsset::LoadingState_Loaded );

	//	pull out scene information (ie. what geometry is used, what matierals theyre bound to etc)
	TLDebug_Print("Collada: Importing scene...");
	if ( !ImportScene( *pNewMesh, *pRootTag ) )
		return SyncFalse;

	//	assign resulting asset
	pAsset = pNewMesh;

	//	pre-calc bounds boxes
	pNewMesh->CalcBounds();

	return SyncTrue;
}