Example #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;
}
Example #2
0
	MediaInfo LocalFileResolver::ResolveInfo (const QString& file)
	{
		const auto& modified = QFileInfo (file).lastModified ();
		{
			QReadLocker locker (&CacheLock_);
			if (Cache_.contains (file))
			{
				const auto& pair = Cache_ [file];
				if (pair.first == modified)
					return pair.second;
			}
		}

		QMutexLocker tlLocker (&TaglibMutex_);

		auto r = GetFileRef (file);
		auto tag = r.tag ();
		if (!tag)
			throw ResolveError (file, "failed to get file tags");

		auto audio = r.audioProperties ();

		auto ftl = [] (const TagLib::String& str) { return QString::fromUtf8 (str.toCString (true)); };
		auto genres = ftl (tag->genre ()).split ('/', QString::SkipEmptyParts);
		std::for_each (genres.begin (), genres.end (),
				[] (QString& genre) { genre = genre.trimmed (); });

		MediaInfo info
		{
			file,
			ftl (tag->artist ()),
			ftl (tag->album ()),
			ftl (tag->title ()),
			genres,
			audio ? audio->length () : 0,
			static_cast<qint32> (tag->year ()),
			static_cast<qint32> (tag->track ())
		};
		{
			QWriteLocker locker (&CacheLock_);
			if (Cache_.size () > 200)
				Cache_.clear ();
			Cache_ [file] = qMakePair (modified, info);
		}
		return info;
	}
Example #3
0
//--------------------------------------------------------
//	import the XML
//--------------------------------------------------------
SyncBool TLFileSys::TFileParticle::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 )
	{
		if ( ImportResult == SyncFalse )
		{
			TLDebug_Break("Failed to parse xml file");
		}
		return ImportResult;
	}

	//	get the root tag
	TPtr<TXmlTag> pRootTag = m_XmlData.GetChild("Particle");

	//	malformed XML
	if ( !pRootTag )
	{
		TLDebug_Print("Scheme file missing root <Particle> tag");
		return SyncFalse;
	}

	//	make up new storage asset type
	TPtr<TLAsset::TParticle> pNewAsset = new TLAsset::TParticle( GetFileRef() );
	ImportResult = ImportRoot( pRootTag, *pNewAsset );

	//	failed to import
	if ( ImportResult != SyncTrue )
	{
		return SyncFalse;
	}

	//	assign resulting asset
	pAsset = pNewAsset;

	return SyncTrue;
}
//--------------------------------------------------------
//	import the XML and convert from SVG to mesh
//--------------------------------------------------------
SyncBool TLFileSys::TFileTextDatabase::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 tag
	TPtr<TXmlTag> pTtdTag = m_XmlData.GetChild("textdatabase");

	//	malformed AssetScript
	if ( !pTtdTag )
	{
		TLDebug_Print("TTD file missing root <textdatabase> tag");
		return SyncFalse;
	}

	//	do specific importing
	TPtr<TLAsset::TAsset> pNewAsset = new TLAsset::TText( GetFileRef() );

	ImportResult = ImportText( pNewAsset, pTtdTag );

	//	failed to import
	if ( ImportResult != SyncTrue )
	{
		return SyncFalse;
	}

	//	assign resulting asset
	pAsset = pNewAsset;

	return SyncTrue;
}