2012-02-19 04:30:59 +01:00
|
|
|
/* Copyright (C) 2012 Wildfire Games.
|
2009-04-18 19:00:33 +02:00
|
|
|
* This file is part of 0 A.D.
|
|
|
|
*
|
|
|
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* 0 A.D. is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2007-05-07 18:33:24 +02:00
|
|
|
#ifndef INCLUDED_COLLADAMANAGER
|
|
|
|
#define INCLUDED_COLLADAMANAGER
|
2007-03-01 19:52:53 +01:00
|
|
|
|
2012-02-19 04:30:59 +01:00
|
|
|
#include "lib/file/vfs/vfs.h"
|
2007-03-01 19:52:53 +01:00
|
|
|
|
2008-01-07 21:03:19 +01:00
|
|
|
class CStr8;
|
2007-03-01 19:52:53 +01:00
|
|
|
class CColladaManagerImpl;
|
2012-02-19 04:30:59 +01:00
|
|
|
class MD5;
|
2007-03-01 19:52:53 +01:00
|
|
|
|
|
|
|
class CColladaManager
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum FileType { PMD, PSA };
|
|
|
|
|
2012-02-19 04:30:59 +01:00
|
|
|
CColladaManager(const PIVFS& vfs);
|
2007-03-01 19:52:53 +01:00
|
|
|
~CColladaManager();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the VFS path to a PMD/PSA file for the given source file.
|
|
|
|
* Performs a (cached) conversion from COLLADA if necessary.
|
|
|
|
*
|
2009-11-03 22:46:35 +01:00
|
|
|
* @param pathnameNoExtension path and name, minus extension, of file to load.
|
2010-07-29 17:55:41 +02:00
|
|
|
* One of either "sourceName.pmd" or "sourceName.dae" should exist.
|
|
|
|
* @param type FileType, .pmd or .psa
|
2007-03-01 19:52:53 +01:00
|
|
|
*
|
|
|
|
* @return full VFS path (including extension) of file to load; or empty
|
2012-02-19 04:30:59 +01:00
|
|
|
* string if there was a problem and it could not be loaded. Doesn't knowingly
|
|
|
|
* return an invalid path.
|
2007-03-01 19:52:53 +01:00
|
|
|
*/
|
2012-02-19 04:30:59 +01:00
|
|
|
VfsPath GetLoadablePath(const VfsPath& pathnameNoExtension, FileType type);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Converts DAE to archive cached .pmd/psa and outputs the resulting path
|
|
|
|
* (used by archive builder)
|
|
|
|
*
|
2012-03-01 04:55:05 +01:00
|
|
|
* @param[in] sourcePath path of the .dae to load
|
|
|
|
* @param[in] type FileType, .pmd or .psa
|
|
|
|
* @param[out] archiveCachePath output path of the cached file
|
2012-02-19 04:30:59 +01:00
|
|
|
*
|
|
|
|
* @return true if COLLADA converter completed successfully; or false if it failed
|
|
|
|
*/
|
|
|
|
bool GenerateCachedFile(const VfsPath& sourcePath, FileType type, VfsPath& archiveCachePath);
|
2007-03-01 19:52:53 +01:00
|
|
|
|
|
|
|
private:
|
2012-02-19 04:30:59 +01:00
|
|
|
/**
|
|
|
|
* Creates MD5 hash key from skeletons.xml info and COLLADA converter version,
|
|
|
|
* used to invalidate cached .pmd/psas
|
|
|
|
*
|
2012-03-01 04:55:05 +01:00
|
|
|
* @param[out] hash resulting MD5 hash
|
|
|
|
* @param[out] version version passed to CCacheLoader, used if code change should force
|
2012-02-19 04:30:59 +01:00
|
|
|
* cache invalidation
|
|
|
|
*/
|
|
|
|
void PrepareCacheKey(MD5& hash, u32& version);
|
|
|
|
|
2007-03-01 19:52:53 +01:00
|
|
|
CColladaManagerImpl* m;
|
2012-02-19 04:30:59 +01:00
|
|
|
PIVFS m_VFS;
|
2007-03-01 19:52:53 +01:00
|
|
|
};
|
|
|
|
|
2007-05-07 18:33:24 +02:00
|
|
|
#endif // INCLUDED_COLLADAMANAGER
|