Merge branch 'master' of https://github.com/Madrich/assimp
Conflicts: code/ColladaParser.cpppull/502/head
commit
4bf090e92c
5
CREDITS
5
CREDITS
|
@ -151,3 +151,8 @@ Ogre Binary format support
|
||||||
|
|
||||||
- Filip Wasil, Tieto Poland Sp. z o.o.
|
- Filip Wasil, Tieto Poland Sp. z o.o.
|
||||||
Android JNI asset extraction support
|
Android JNI asset extraction support
|
||||||
|
|
||||||
|
- Richard Steffen
|
||||||
|
Contributed X File exporter
|
||||||
|
Contributed ExportProperties interface
|
||||||
|
|
||||||
|
|
|
@ -144,7 +144,7 @@ namespace {
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Worker function for exporting a scene to 3DS. Prototyped and registered in Exporter.cpp
|
// Worker function for exporting a scene to 3DS. Prototyped and registered in Exporter.cpp
|
||||||
void ExportScene3DS(const char* pFile, IOSystem* pIOSystem, const aiScene* pScene)
|
void ExportScene3DS(const char* pFile, IOSystem* pIOSystem, const aiScene* pScene, const ExportProperties* pProperties)
|
||||||
{
|
{
|
||||||
boost::shared_ptr<IOStream> outfile (pIOSystem->Open(pFile, "wb"));
|
boost::shared_ptr<IOStream> outfile (pIOSystem->Open(pFile, "wb"));
|
||||||
if(!outfile) {
|
if(!outfile) {
|
||||||
|
|
|
@ -754,7 +754,7 @@ inline size_t WriteArray(IOStream * stream, const T* in, unsigned int size)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void ExportSceneAssbin(const char* pFile, IOSystem* pIOSystem, const aiScene* pScene)
|
void ExportSceneAssbin(const char* pFile, IOSystem* pIOSystem, const aiScene* pScene, const ExportProperties* pProperties)
|
||||||
{
|
{
|
||||||
AssbinExport exporter;
|
AssbinExport exporter;
|
||||||
exporter.WriteBinaryDump( pFile, pIOSystem, pScene );
|
exporter.WriteBinaryDump( pFile, pIOSystem, pScene );
|
||||||
|
|
|
@ -621,7 +621,7 @@ void WriteDump(const aiScene* scene, IOStream* io, bool shortened)
|
||||||
|
|
||||||
} // end of namespace AssxmlExport
|
} // end of namespace AssxmlExport
|
||||||
|
|
||||||
void ExportSceneAssxml(const char* pFile, IOSystem* pIOSystem, const aiScene* pScene)
|
void ExportSceneAssxml(const char* pFile, IOSystem* pIOSystem, const aiScene* pScene, const ExportProperties* pProperties)
|
||||||
{
|
{
|
||||||
IOStream * out = pIOSystem->Open( pFile, "wt" );
|
IOStream * out = pIOSystem->Open( pFile, "wt" );
|
||||||
if (!out) return;
|
if (!out) return;
|
||||||
|
|
|
@ -59,7 +59,7 @@ namespace Assimp
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Worker function for exporting a scene to Collada. Prototyped and registered in Exporter.cpp
|
// Worker function for exporting a scene to Collada. Prototyped and registered in Exporter.cpp
|
||||||
void ExportSceneCollada(const char* pFile, IOSystem* pIOSystem, const aiScene* pScene)
|
void ExportSceneCollada(const char* pFile, IOSystem* pIOSystem, const aiScene* pScene, const ExportProperties* pProperties)
|
||||||
{
|
{
|
||||||
std::string path = "";
|
std::string path = "";
|
||||||
std::string file = pFile;
|
std::string file = pFile;
|
||||||
|
|
|
@ -72,16 +72,16 @@ void GetPostProcessingStepInstanceList(std::vector< BaseProcess* >& out);
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Exporter worker function prototypes. Should not be necessary to #ifndef them, it's just a prototype
|
// Exporter worker function prototypes. Should not be necessary to #ifndef them, it's just a prototype
|
||||||
// do not use const, because some exporter need to convert the scene temporary
|
// do not use const, because some exporter need to convert the scene temporary
|
||||||
void ExportSceneCollada(const char*,IOSystem*, const aiScene*);
|
void ExportSceneCollada(const char*,IOSystem*, const aiScene*, const ExportProperties*);
|
||||||
void ExportSceneXFile(const char*,IOSystem*, const aiScene*);
|
void ExportSceneXFile(const char*,IOSystem*, const aiScene*, const ExportProperties*);
|
||||||
void ExportSceneObj(const char*,IOSystem*, const aiScene*);
|
void ExportSceneObj(const char*,IOSystem*, const aiScene*, const ExportProperties*);
|
||||||
void ExportSceneSTL(const char*,IOSystem*, const aiScene*);
|
void ExportSceneSTL(const char*,IOSystem*, const aiScene*, const ExportProperties*);
|
||||||
void ExportSceneSTLBinary(const char*,IOSystem*, const aiScene*);
|
void ExportSceneSTLBinary(const char*,IOSystem*, const aiScene*, const ExportProperties*);
|
||||||
void ExportScenePly(const char*,IOSystem*, const aiScene*);
|
void ExportScenePly(const char*,IOSystem*, const aiScene*, const ExportProperties*);
|
||||||
void ExportScenePlyBinary(const char*, IOSystem*, const aiScene*);
|
void ExportScenePlyBinary(const char*, IOSystem*, const aiScene*, const ExportProperties*);
|
||||||
void ExportScene3DS(const char*, IOSystem*, const aiScene*);
|
void ExportScene3DS(const char*, IOSystem*, const aiScene*, const ExportProperties*);
|
||||||
void ExportSceneAssbin(const char*, IOSystem*, const aiScene*);
|
void ExportSceneAssbin(const char*, IOSystem*, const aiScene*, const ExportProperties*);
|
||||||
void ExportSceneAssxml(const char*, IOSystem*, const aiScene*);
|
void ExportSceneAssxml(const char*, IOSystem*, const aiScene*, const ExportProperties*);
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// global array of all export formats which Assimp supports in its current build
|
// global array of all export formats which Assimp supports in its current build
|
||||||
|
@ -91,7 +91,7 @@ Exporter::ExportFormatEntry gExporters[] =
|
||||||
Exporter::ExportFormatEntry( "collada", "COLLADA - Digital Asset Exchange Schema", "dae", &ExportSceneCollada),
|
Exporter::ExportFormatEntry( "collada", "COLLADA - Digital Asset Exchange Schema", "dae", &ExportSceneCollada),
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef ASSIMP_BUILD_NO_FXILE_EXPORTER
|
#ifndef ASSIMP_BUILD_NO_XFILE_EXPORTER
|
||||||
Exporter::ExportFormatEntry( "x", "X Files", "x", &ExportSceneXFile,
|
Exporter::ExportFormatEntry( "x", "X Files", "x", &ExportSceneXFile,
|
||||||
aiProcess_MakeLeftHanded | aiProcess_FlipWindingOrder | aiProcess_FlipUVs),
|
aiProcess_MakeLeftHanded | aiProcess_FlipWindingOrder | aiProcess_FlipUVs),
|
||||||
#endif
|
#endif
|
||||||
|
@ -226,7 +226,7 @@ bool Exporter :: IsDefaultIOHandler() const
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
const aiExportDataBlob* Exporter :: ExportToBlob( const aiScene* pScene, const char* pFormatId, unsigned int )
|
const aiExportDataBlob* Exporter :: ExportToBlob( const aiScene* pScene, const char* pFormatId, unsigned int, const ExportProperties* pProperties)
|
||||||
{
|
{
|
||||||
if (pimpl->blob) {
|
if (pimpl->blob) {
|
||||||
delete pimpl->blob;
|
delete pimpl->blob;
|
||||||
|
@ -282,7 +282,7 @@ bool IsVerboseFormat(const aiScene* pScene)
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
aiReturn Exporter :: Export( const aiScene* pScene, const char* pFormatId, const char* pPath, unsigned int pPreprocessing )
|
aiReturn Exporter :: Export( const aiScene* pScene, const char* pFormatId, const char* pPath, unsigned int pPreprocessing, const ExportProperties* pProperties)
|
||||||
{
|
{
|
||||||
ASSIMP_BEGIN_EXCEPTION_REGION();
|
ASSIMP_BEGIN_EXCEPTION_REGION();
|
||||||
|
|
||||||
|
@ -290,7 +290,7 @@ aiReturn Exporter :: Export( const aiScene* pScene, const char* pFormatId, const
|
||||||
// format. They will likely not be aware that there is a flag in the scene to indicate
|
// format. They will likely not be aware that there is a flag in the scene to indicate
|
||||||
// this, however. To avoid surprises and bug reports, we check for duplicates in
|
// this, however. To avoid surprises and bug reports, we check for duplicates in
|
||||||
// meshes upfront.
|
// meshes upfront.
|
||||||
const bool is_verbose_format = !(pScene->mFlags & AI_SCENE_FLAGS_NON_VERBOSE_FORMAT) || IsVerboseFormat(pScene);
|
const bool is_verbose_format = !(pScene->mFlags & AI_SCENE_FLAGS_NON_VERBOSE_FORMAT) || IsVerboseFormat(pScene);
|
||||||
|
|
||||||
pimpl->mError = "";
|
pimpl->mError = "";
|
||||||
for (size_t i = 0; i < pimpl->mExporters.size(); ++i) {
|
for (size_t i = 0; i < pimpl->mExporters.size(); ++i) {
|
||||||
|
@ -397,7 +397,7 @@ aiReturn Exporter :: Export( const aiScene* pScene, const char* pFormatId, const
|
||||||
proc.Execute(scenecopy.get());
|
proc.Execute(scenecopy.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
exp.mExportFunction(pPath,pimpl->mIOSystem.get(),scenecopy.get());
|
exp.mExportFunction(pPath,pimpl->mIOSystem.get(),scenecopy.get(), pProperties);
|
||||||
}
|
}
|
||||||
catch (DeadlyExportError& err) {
|
catch (DeadlyExportError& err) {
|
||||||
pimpl->mError = err.what();
|
pimpl->mError = err.what();
|
||||||
|
@ -492,4 +492,116 @@ void Exporter :: UnregisterExporter(const char* id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ExportProperties :: ExportProperties() {}
|
||||||
|
|
||||||
|
ExportProperties::ExportProperties(const ExportProperties &other)
|
||||||
|
: mIntProperties(other.mIntProperties),
|
||||||
|
mFloatProperties(other.mFloatProperties),
|
||||||
|
mStringProperties(other.mStringProperties),
|
||||||
|
mMatrixProperties(other.mMatrixProperties)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
// Set a configuration property
|
||||||
|
void ExportProperties :: SetPropertyInteger(const char* szName, int iValue,
|
||||||
|
bool* bWasExisting /*= NULL*/)
|
||||||
|
{
|
||||||
|
SetGenericProperty<int>(mIntProperties, szName,iValue,bWasExisting);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
// Set a configuration property
|
||||||
|
void ExportProperties :: SetPropertyFloat(const char* szName, float iValue,
|
||||||
|
bool* bWasExisting /*= NULL*/)
|
||||||
|
{
|
||||||
|
SetGenericProperty<float>(mFloatProperties, szName,iValue,bWasExisting);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
// Set a configuration property
|
||||||
|
void ExportProperties :: SetPropertyString(const char* szName, const std::string& value,
|
||||||
|
bool* bWasExisting /*= NULL*/)
|
||||||
|
{
|
||||||
|
SetGenericProperty<std::string>(mStringProperties, szName,value,bWasExisting);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
// Set a configuration property
|
||||||
|
void ExportProperties :: SetPropertyMatrix(const char* szName, const aiMatrix4x4& value,
|
||||||
|
bool* bWasExisting /*= NULL*/)
|
||||||
|
{
|
||||||
|
SetGenericProperty<aiMatrix4x4>(mMatrixProperties, szName,value,bWasExisting);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
// Get a configuration property
|
||||||
|
int ExportProperties :: GetPropertyInteger(const char* szName,
|
||||||
|
int iErrorReturn /*= 0xffffffff*/) const
|
||||||
|
{
|
||||||
|
return GetGenericProperty<int>(mIntProperties,szName,iErrorReturn);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
// Get a configuration property
|
||||||
|
float ExportProperties :: GetPropertyFloat(const char* szName,
|
||||||
|
float iErrorReturn /*= 10e10*/) const
|
||||||
|
{
|
||||||
|
return GetGenericProperty<float>(mFloatProperties,szName,iErrorReturn);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
// Get a configuration property
|
||||||
|
const std::string ExportProperties :: GetPropertyString(const char* szName,
|
||||||
|
const std::string& iErrorReturn /*= ""*/) const
|
||||||
|
{
|
||||||
|
return GetGenericProperty<std::string>(mStringProperties,szName,iErrorReturn);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
// Has a configuration property
|
||||||
|
const aiMatrix4x4 ExportProperties :: GetPropertyMatrix(const char* szName,
|
||||||
|
const aiMatrix4x4& iErrorReturn /*= aiMatrix4x4()*/) const
|
||||||
|
{
|
||||||
|
return GetGenericProperty<aiMatrix4x4>(mMatrixProperties,szName,iErrorReturn);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
// Has a configuration property
|
||||||
|
bool ExportProperties :: HasPropertyInteger(const char* szName) const
|
||||||
|
{
|
||||||
|
return HasGenericProperty<int>(mIntProperties, szName);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
// Has a configuration property
|
||||||
|
bool ExportProperties :: HasPropertyBool(const char* szName) const
|
||||||
|
{
|
||||||
|
return HasGenericProperty<int>(mIntProperties, szName);
|
||||||
|
};
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
// Has a configuration property
|
||||||
|
bool ExportProperties :: HasPropertyFloat(const char* szName) const
|
||||||
|
{
|
||||||
|
return HasGenericProperty<float>(mFloatProperties, szName);
|
||||||
|
};
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
// Has a configuration property
|
||||||
|
bool ExportProperties :: HasPropertyString(const char* szName) const
|
||||||
|
{
|
||||||
|
return HasGenericProperty<std::string>(mStringProperties, szName);
|
||||||
|
};
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
// Has a configuration property
|
||||||
|
bool ExportProperties :: HasPropertyMatrix(const char* szName) const
|
||||||
|
{
|
||||||
|
return HasGenericProperty<aiMatrix4x4>(mMatrixProperties, szName);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif // !ASSIMP_BUILD_NO_EXPORT
|
#endif // !ASSIMP_BUILD_NO_EXPORT
|
||||||
|
|
|
@ -108,5 +108,18 @@ inline void SetGenericPropertyPtr(std::map< unsigned int, T* >& list,
|
||||||
*bWasExisting = true;
|
*bWasExisting = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
template <class T>
|
||||||
|
inline const bool HasGenericProperty(const std::map< unsigned int, T >& list,
|
||||||
|
const char* szName)
|
||||||
|
{
|
||||||
|
ai_assert(NULL != szName);
|
||||||
|
const uint32_t hash = SuperFastHash(szName);
|
||||||
|
|
||||||
|
typename std::map<unsigned int, T>::const_iterator it = list.find(hash);
|
||||||
|
if (it == list.end()) return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // !! AI_GENERIC_PROPERTY_H_INCLUDED
|
#endif // !! AI_GENERIC_PROPERTY_H_INCLUDED
|
||||||
|
|
|
@ -51,7 +51,7 @@ namespace Assimp {
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Worker function for exporting a scene to Wavefront OBJ. Prototyped and registered in Exporter.cpp
|
// Worker function for exporting a scene to Wavefront OBJ. Prototyped and registered in Exporter.cpp
|
||||||
void ExportSceneObj(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene)
|
void ExportSceneObj(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene, const ExportProperties* pProperties)
|
||||||
{
|
{
|
||||||
// invoke the exporter
|
// invoke the exporter
|
||||||
ObjExporter exporter(pFile, pScene);
|
ObjExporter exporter(pFile, pScene);
|
||||||
|
|
|
@ -50,7 +50,7 @@ namespace Assimp {
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Worker function for exporting a scene to PLY. Prototyped and registered in Exporter.cpp
|
// Worker function for exporting a scene to PLY. Prototyped and registered in Exporter.cpp
|
||||||
void ExportScenePly(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene)
|
void ExportScenePly(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene, const ExportProperties* pProperties)
|
||||||
{
|
{
|
||||||
// invoke the exporter
|
// invoke the exporter
|
||||||
PlyExporter exporter(pFile, pScene);
|
PlyExporter exporter(pFile, pScene);
|
||||||
|
@ -64,7 +64,7 @@ void ExportScenePly(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene
|
||||||
outfile->Write( exporter.mOutput.str().c_str(), static_cast<size_t>(exporter.mOutput.tellp()),1);
|
outfile->Write( exporter.mOutput.str().c_str(), static_cast<size_t>(exporter.mOutput.tellp()),1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExportScenePlyBinary(const char* pFile, IOSystem* pIOSystem, const aiScene* pScene)
|
void ExportScenePlyBinary(const char* pFile, IOSystem* pIOSystem, const aiScene* pScene, const ExportProperties* pProperties)
|
||||||
{
|
{
|
||||||
// invoke the exporter
|
// invoke the exporter
|
||||||
PlyExporter exporter(pFile, pScene, true);
|
PlyExporter exporter(pFile, pScene, true);
|
||||||
|
|
|
@ -50,7 +50,7 @@ namespace Assimp {
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Worker function for exporting a scene to Stereolithograpy. Prototyped and registered in Exporter.cpp
|
// Worker function for exporting a scene to Stereolithograpy. Prototyped and registered in Exporter.cpp
|
||||||
void ExportSceneSTL(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene)
|
void ExportSceneSTL(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene, const ExportProperties* pProperties)
|
||||||
{
|
{
|
||||||
// invoke the exporter
|
// invoke the exporter
|
||||||
STLExporter exporter(pFile, pScene);
|
STLExporter exporter(pFile, pScene);
|
||||||
|
@ -63,7 +63,7 @@ void ExportSceneSTL(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene
|
||||||
|
|
||||||
outfile->Write( exporter.mOutput.str().c_str(), static_cast<size_t>(exporter.mOutput.tellp()),1);
|
outfile->Write( exporter.mOutput.str().c_str(), static_cast<size_t>(exporter.mOutput.tellp()),1);
|
||||||
}
|
}
|
||||||
void ExportSceneSTLBinary(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene)
|
void ExportSceneSTLBinary(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene, const ExportProperties* pProperties)
|
||||||
{
|
{
|
||||||
// invoke the exporter
|
// invoke the exporter
|
||||||
STLExporter exporter(pFile, pScene, true);
|
STLExporter exporter(pFile, pScene, true);
|
||||||
|
|
|
@ -59,7 +59,7 @@ namespace Assimp
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Worker function for exporting a scene to Collada. Prototyped and registered in Exporter.cpp
|
// Worker function for exporting a scene to Collada. Prototyped and registered in Exporter.cpp
|
||||||
void ExportSceneXFile(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene)
|
void ExportSceneXFile(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene, const ExportProperties* pProperties)
|
||||||
{
|
{
|
||||||
std::string path = "";
|
std::string path = "";
|
||||||
std::string file = pFile;
|
std::string file = pFile;
|
||||||
|
@ -78,13 +78,19 @@ void ExportSceneXFile(const char* pFile,IOSystem* pIOSystem, const aiScene* pSce
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// create/copy Properties
|
||||||
|
ExportProperties props(*pProperties);
|
||||||
|
|
||||||
|
// set standard properties if not set
|
||||||
|
if (!props.HasPropertyBool(AI_CONFIG_EXPORT_XFILE_64BIT)) props.SetPropertyBool(AI_CONFIG_EXPORT_XFILE_64BIT, false);
|
||||||
|
|
||||||
// invoke the exporter
|
// invoke the exporter
|
||||||
XFileExporter iDoTheExportThing( pScene, pIOSystem, path, file);
|
XFileExporter iDoTheExportThing( pScene, pIOSystem, path, file, &props);
|
||||||
|
|
||||||
// we're still here - export successfully completed. Write result to the given IOSYstem
|
// we're still here - export successfully completed. Write result to the given IOSYstem
|
||||||
boost::scoped_ptr<IOStream> outfile (pIOSystem->Open(pFile,"wt"));
|
boost::scoped_ptr<IOStream> outfile (pIOSystem->Open(pFile,"wt"));
|
||||||
if(outfile == NULL) {
|
if(outfile == NULL) {
|
||||||
throw DeadlyExportError("could not open output .dae file: " + std::string(pFile));
|
throw DeadlyExportError("could not open output .x file: " + std::string(pFile));
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXX maybe use a small wrapper around IOStream that behaves like std::stringstream in order to avoid the extra copy.
|
// XXX maybe use a small wrapper around IOStream that behaves like std::stringstream in order to avoid the extra copy.
|
||||||
|
@ -96,7 +102,7 @@ void ExportSceneXFile(const char* pFile,IOSystem* pIOSystem, const aiScene* pSce
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Constructor for a specific scene to export
|
// Constructor for a specific scene to export
|
||||||
XFileExporter::XFileExporter(const aiScene* pScene, IOSystem* pIOSystem, const std::string& path, const std::string& file) : mIOSystem(pIOSystem), mPath(path), mFile(file)
|
XFileExporter::XFileExporter(const aiScene* pScene, IOSystem* pIOSystem, const std::string& path, const std::string& file, const ExportProperties* pProperties) : mIOSystem(pIOSystem), mPath(path), mFile(file), mProperties(pProperties)
|
||||||
{
|
{
|
||||||
// make sure that all formatting happens using the standard, C locale and not the user's current locale
|
// make sure that all formatting happens using the standard, C locale and not the user's current locale
|
||||||
mOutput.imbue( std::locale("C") );
|
mOutput.imbue( std::locale("C") );
|
||||||
|
@ -126,7 +132,7 @@ void XFileExporter::WriteFile()
|
||||||
{
|
{
|
||||||
// note, that all realnumber values must be comma separated in x files
|
// note, that all realnumber values must be comma separated in x files
|
||||||
mOutput.setf(std::ios::fixed);
|
mOutput.setf(std::ios::fixed);
|
||||||
mOutput.precision(6); // precission for float
|
mOutput.precision(16); // precission for double
|
||||||
|
|
||||||
// entry of writing the file
|
// entry of writing the file
|
||||||
WriteHeader();
|
WriteHeader();
|
||||||
|
@ -148,7 +154,10 @@ void XFileExporter::WriteFile()
|
||||||
// Writes the asset header
|
// Writes the asset header
|
||||||
void XFileExporter::WriteHeader()
|
void XFileExporter::WriteHeader()
|
||||||
{
|
{
|
||||||
mOutput << startstr << "xof 0303txt 0032" << endstr;
|
if (mProperties->GetPropertyBool(AI_CONFIG_EXPORT_XFILE_64BIT) == true)
|
||||||
|
mOutput << startstr << "xof 0303txt 0064" << endstr;
|
||||||
|
else
|
||||||
|
mOutput << startstr << "xof 0303txt 0032" << endstr;
|
||||||
mOutput << endstr;
|
mOutput << endstr;
|
||||||
mOutput << startstr << "template Frame {" << endstr;
|
mOutput << startstr << "template Frame {" << endstr;
|
||||||
PushTag();
|
PushTag();
|
||||||
|
@ -298,7 +307,7 @@ void XFileExporter::WriteNode( aiNode* pNode)
|
||||||
ss << "Node_" << pNode;
|
ss << "Node_" << pNode;
|
||||||
pNode->mName.Set(ss.str());
|
pNode->mName.Set(ss.str());
|
||||||
}
|
}
|
||||||
mOutput << startstr << "Frame " << pNode->mName.C_Str() << " {" << endstr;
|
mOutput << startstr << "Frame " << toXFileString(pNode->mName) << " {" << endstr;
|
||||||
|
|
||||||
PushTag();
|
PushTag();
|
||||||
|
|
||||||
|
@ -318,9 +327,9 @@ void XFileExporter::WriteNode( aiNode* pNode)
|
||||||
mOutput << startstr << "}" << endstr << endstr;
|
mOutput << startstr << "}" << endstr << endstr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void XFileExporter::WriteMesh(const aiMesh* mesh)
|
void XFileExporter::WriteMesh(aiMesh* mesh)
|
||||||
{
|
{
|
||||||
mOutput << startstr << "Mesh " << mesh->mName.C_Str() << "_mShape" << " {" << endstr;
|
mOutput << startstr << "Mesh " << toXFileString(mesh->mName) << "_mShape" << " {" << endstr;
|
||||||
|
|
||||||
PushTag();
|
PushTag();
|
||||||
|
|
||||||
|
@ -496,6 +505,16 @@ void XFileExporter::WriteMesh(const aiMesh* mesh)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string XFileExporter::toXFileString(aiString &name)
|
||||||
|
{
|
||||||
|
std::string str = std::string(name.C_Str());
|
||||||
|
std::replace(str.begin(), str.end(), '<', '_');
|
||||||
|
std::replace(str.begin(), str.end(), '>', '_');
|
||||||
|
std::replace(str.begin(), str.end(), '{', '_');
|
||||||
|
std::replace(str.begin(), str.end(), '}', '_');
|
||||||
|
std::replace(str.begin(), str.end(), '$', '_');
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
void XFileExporter::writePath(aiString path)
|
void XFileExporter::writePath(aiString path)
|
||||||
{
|
{
|
||||||
|
|
|
@ -61,7 +61,7 @@ class XFileExporter
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// Constructor for a specific scene to export
|
/// Constructor for a specific scene to export
|
||||||
XFileExporter(const aiScene* pScene, IOSystem* pIOSystem, const std::string& path, const std::string& file);
|
XFileExporter(const aiScene* pScene, IOSystem* pIOSystem, const std::string& path, const std::string& file, const ExportProperties* pProperties);
|
||||||
|
|
||||||
/// Destructor
|
/// Destructor
|
||||||
virtual ~XFileExporter();
|
virtual ~XFileExporter();
|
||||||
|
@ -80,7 +80,7 @@ protected:
|
||||||
void WriteNode( aiNode* pNode );
|
void WriteNode( aiNode* pNode );
|
||||||
|
|
||||||
/// write a mesh entry of the scene
|
/// write a mesh entry of the scene
|
||||||
void WriteMesh(const aiMesh* mesh);
|
void WriteMesh( aiMesh* mesh);
|
||||||
|
|
||||||
/// Enters a new xml element, which increases the indentation
|
/// Enters a new xml element, which increases the indentation
|
||||||
void PushTag() { startstr.append( " "); }
|
void PushTag() { startstr.append( " "); }
|
||||||
|
@ -94,6 +94,12 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
/// normalize the name to be accepted by xfile readers
|
||||||
|
std::string toXFileString(aiString &name);
|
||||||
|
|
||||||
|
/// hold the properties pointer
|
||||||
|
const ExportProperties* mProperties;
|
||||||
|
|
||||||
/// write a path
|
/// write a path
|
||||||
void writePath(aiString path);
|
void writePath(aiString path);
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#ifndef ASSIMP_BUILD_NO_EXPORT
|
#ifndef ASSIMP_BUILD_NO_EXPORT
|
||||||
|
|
||||||
#include "cexport.h"
|
#include "cexport.h"
|
||||||
|
#include <map>
|
||||||
|
|
||||||
namespace Assimp {
|
namespace Assimp {
|
||||||
class ExporterPimpl;
|
class ExporterPimpl;
|
||||||
|
@ -72,6 +73,9 @@ namespace Assimp {
|
||||||
* #ExportToBlob is especially useful if you intend to work
|
* #ExportToBlob is especially useful if you intend to work
|
||||||
* with the data in-memory.
|
* with the data in-memory.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
class ASSIMP_API ExportProperties;
|
||||||
|
|
||||||
class ASSIMP_API Exporter
|
class ASSIMP_API Exporter
|
||||||
// TODO: causes good ol' base class has no dll interface warning
|
// TODO: causes good ol' base class has no dll interface warning
|
||||||
//#ifdef __cplusplus
|
//#ifdef __cplusplus
|
||||||
|
@ -81,7 +85,7 @@ class ASSIMP_API Exporter
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/** Function pointer type of a Export worker function */
|
/** Function pointer type of a Export worker function */
|
||||||
typedef void (*fpExportFunc)(const char*,IOSystem*, const aiScene*);
|
typedef void (*fpExportFunc)(const char*, IOSystem*, const aiScene*, const ExportProperties*);
|
||||||
|
|
||||||
/** Internal description of an Assimp export format option */
|
/** Internal description of an Assimp export format option */
|
||||||
struct ExportFormatEntry
|
struct ExportFormatEntry
|
||||||
|
@ -171,8 +175,8 @@ public:
|
||||||
* Any IO handlers set via #SetIOHandler are ignored here.
|
* Any IO handlers set via #SetIOHandler are ignored here.
|
||||||
* @note Use aiCopyScene() to get a modifiable copy of a previously
|
* @note Use aiCopyScene() to get a modifiable copy of a previously
|
||||||
* imported scene. */
|
* imported scene. */
|
||||||
const aiExportDataBlob* ExportToBlob( const aiScene* pScene, const char* pFormatId, unsigned int pPreprocessing = 0u );
|
const aiExportDataBlob* ExportToBlob( const aiScene* pScene, const char* pFormatId, unsigned int pPreprocessing = 0u, const ExportProperties* pProperties = NULL);
|
||||||
inline const aiExportDataBlob* ExportToBlob( const aiScene* pScene, const std::string& pFormatId, unsigned int pPreprocessing = 0u );
|
inline const aiExportDataBlob* ExportToBlob( const aiScene* pScene, const std::string& pFormatId, unsigned int pPreprocessing = 0u, const ExportProperties* pProperties = NULL);
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
|
@ -208,8 +212,8 @@ public:
|
||||||
* @return AI_SUCCESS if everything was fine.
|
* @return AI_SUCCESS if everything was fine.
|
||||||
* @note Use aiCopyScene() to get a modifiable copy of a previously
|
* @note Use aiCopyScene() to get a modifiable copy of a previously
|
||||||
* imported scene.*/
|
* imported scene.*/
|
||||||
aiReturn Export( const aiScene* pScene, const char* pFormatId, const char* pPath, unsigned int pPreprocessing = 0u);
|
aiReturn Export( const aiScene* pScene, const char* pFormatId, const char* pPath, unsigned int pPreprocessing = 0u, const ExportProperties* pProperties = NULL);
|
||||||
inline aiReturn Export( const aiScene* pScene, const std::string& pFormatId, const std::string& pPath, unsigned int pPreprocessing = 0u);
|
inline aiReturn Export( const aiScene* pScene, const std::string& pFormatId, const std::string& pPath, unsigned int pPreprocessing = 0u, const ExportProperties* pProperties = NULL);
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
|
@ -309,16 +313,188 @@ protected:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------------
|
class ASSIMP_API ExportProperties
|
||||||
inline const aiExportDataBlob* Exporter :: ExportToBlob( const aiScene* pScene, const std::string& pFormatId,unsigned int pPreprocessing )
|
|
||||||
{
|
{
|
||||||
return ExportToBlob(pScene,pFormatId.c_str(),pPreprocessing);
|
public:
|
||||||
|
// Data type to store the key hash
|
||||||
|
typedef unsigned int KeyType;
|
||||||
|
|
||||||
|
// typedefs for our four configuration maps.
|
||||||
|
// We don't need more, so there is no need for a generic solution
|
||||||
|
typedef std::map<KeyType, int> IntPropertyMap;
|
||||||
|
typedef std::map<KeyType, float> FloatPropertyMap;
|
||||||
|
typedef std::map<KeyType, std::string> StringPropertyMap;
|
||||||
|
typedef std::map<KeyType, aiMatrix4x4> MatrixPropertyMap;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
/** Standard constructor
|
||||||
|
* @see ExportProperties()
|
||||||
|
*/
|
||||||
|
|
||||||
|
ExportProperties();
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** Copy constructor.
|
||||||
|
*
|
||||||
|
* This copies the configuration properties of another ExportProperties.
|
||||||
|
* @see ExportProperties(const ExportProperties& other)
|
||||||
|
*/
|
||||||
|
ExportProperties(const ExportProperties& other);
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** Set an integer configuration property.
|
||||||
|
* @param szName Name of the property. All supported properties
|
||||||
|
* are defined in the aiConfig.g header (all constants share the
|
||||||
|
* prefix AI_CONFIG_XXX and are simple strings).
|
||||||
|
* @param iValue New value of the property
|
||||||
|
* @param bWasExisting Optional pointer to receive true if the
|
||||||
|
* property was set before. The new value replaces the previous value
|
||||||
|
* in this case.
|
||||||
|
* @note Property of different types (float, int, string ..) are kept
|
||||||
|
* on different stacks, so calling SetPropertyInteger() for a
|
||||||
|
* floating-point property has no effect - the loader will call
|
||||||
|
* GetPropertyFloat() to read the property, but it won't be there.
|
||||||
|
*/
|
||||||
|
void SetPropertyInteger(const char* szName, int iValue,
|
||||||
|
bool* bWasExisting = NULL);
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** Set a boolean configuration property. Boolean properties
|
||||||
|
* are stored on the integer stack internally so it's possible
|
||||||
|
* to set them via #SetPropertyBool and query them with
|
||||||
|
* #GetPropertyBool and vice versa.
|
||||||
|
* @see SetPropertyInteger()
|
||||||
|
*/
|
||||||
|
void SetPropertyBool(const char* szName, bool value, bool* bWasExisting = NULL) {
|
||||||
|
SetPropertyInteger(szName,value,bWasExisting);
|
||||||
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** Set a floating-point configuration property.
|
||||||
|
* @see SetPropertyInteger()
|
||||||
|
*/
|
||||||
|
void SetPropertyFloat(const char* szName, float fValue,
|
||||||
|
bool* bWasExisting = NULL);
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** Set a string configuration property.
|
||||||
|
* @see SetPropertyInteger()
|
||||||
|
*/
|
||||||
|
void SetPropertyString(const char* szName, const std::string& sValue,
|
||||||
|
bool* bWasExisting = NULL);
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** Set a matrix configuration property.
|
||||||
|
* @see SetPropertyInteger()
|
||||||
|
*/
|
||||||
|
void SetPropertyMatrix(const char* szName, const aiMatrix4x4& sValue,
|
||||||
|
bool* bWasExisting = NULL);
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** Get a configuration property.
|
||||||
|
* @param szName Name of the property. All supported properties
|
||||||
|
* are defined in the aiConfig.g header (all constants share the
|
||||||
|
* prefix AI_CONFIG_XXX).
|
||||||
|
* @param iErrorReturn Value that is returned if the property
|
||||||
|
* is not found.
|
||||||
|
* @return Current value of the property
|
||||||
|
* @note Property of different types (float, int, string ..) are kept
|
||||||
|
* on different lists, so calling SetPropertyInteger() for a
|
||||||
|
* floating-point property has no effect - the loader will call
|
||||||
|
* GetPropertyFloat() to read the property, but it won't be there.
|
||||||
|
*/
|
||||||
|
int GetPropertyInteger(const char* szName,
|
||||||
|
int iErrorReturn = 0xffffffff) const;
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** Get a boolean configuration property. Boolean properties
|
||||||
|
* are stored on the integer stack internally so it's possible
|
||||||
|
* to set them via #SetPropertyBool and query them with
|
||||||
|
* #GetPropertyBool and vice versa.
|
||||||
|
* @see GetPropertyInteger()
|
||||||
|
*/
|
||||||
|
bool GetPropertyBool(const char* szName, bool bErrorReturn = false) const {
|
||||||
|
return GetPropertyInteger(szName,bErrorReturn)!=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** Get a floating-point configuration property
|
||||||
|
* @see GetPropertyInteger()
|
||||||
|
*/
|
||||||
|
float GetPropertyFloat(const char* szName,
|
||||||
|
float fErrorReturn = 10e10f) const;
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** Get a string configuration property
|
||||||
|
*
|
||||||
|
* The return value remains valid until the property is modified.
|
||||||
|
* @see GetPropertyInteger()
|
||||||
|
*/
|
||||||
|
const std::string GetPropertyString(const char* szName,
|
||||||
|
const std::string& sErrorReturn = "") const;
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** Get a matrix configuration property
|
||||||
|
*
|
||||||
|
* The return value remains valid until the property is modified.
|
||||||
|
* @see GetPropertyInteger()
|
||||||
|
*/
|
||||||
|
const aiMatrix4x4 GetPropertyMatrix(const char* szName,
|
||||||
|
const aiMatrix4x4& sErrorReturn = aiMatrix4x4()) const;
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** Determine a integer configuration property has been set.
|
||||||
|
* @see HasPropertyInteger()
|
||||||
|
*/
|
||||||
|
bool HasPropertyInteger(const char* szName) const;
|
||||||
|
|
||||||
|
/** Determine a boolean configuration property has been set.
|
||||||
|
* @see HasPropertyBool()
|
||||||
|
*/
|
||||||
|
bool HasPropertyBool(const char* szName) const;
|
||||||
|
|
||||||
|
/** Determine a boolean configuration property has been set.
|
||||||
|
* @see HasPropertyFloat()
|
||||||
|
*/
|
||||||
|
bool HasPropertyFloat(const char* szName) const;
|
||||||
|
|
||||||
|
/** Determine a String configuration property has been set.
|
||||||
|
* @see HasPropertyString()
|
||||||
|
*/
|
||||||
|
bool HasPropertyString(const char* szName) const;
|
||||||
|
|
||||||
|
/** Determine a Matrix configuration property has been set.
|
||||||
|
* @see HasPropertyMatrix()
|
||||||
|
*/
|
||||||
|
bool HasPropertyMatrix(const char* szName) const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
/** List of integer properties */
|
||||||
|
IntPropertyMap mIntProperties;
|
||||||
|
|
||||||
|
/** List of floating-point properties */
|
||||||
|
FloatPropertyMap mFloatProperties;
|
||||||
|
|
||||||
|
/** List of string properties */
|
||||||
|
StringPropertyMap mStringProperties;
|
||||||
|
|
||||||
|
/** List of Matrix properties */
|
||||||
|
MatrixPropertyMap mMatrixProperties;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
|
inline const aiExportDataBlob* Exporter :: ExportToBlob( const aiScene* pScene, const std::string& pFormatId,unsigned int pPreprocessing, const ExportProperties* pProperties)
|
||||||
|
{
|
||||||
|
return ExportToBlob(pScene,pFormatId.c_str(),pPreprocessing, pProperties);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------
|
||||||
inline aiReturn Exporter :: Export( const aiScene* pScene, const std::string& pFormatId, const std::string& pPath, unsigned int pPreprocessing )
|
inline aiReturn Exporter :: Export( const aiScene* pScene, const std::string& pFormatId, const std::string& pPath, unsigned int pPreprocessing, const ExportProperties* pProperties)
|
||||||
{
|
{
|
||||||
return Export(pScene,pFormatId.c_str(),pPath.c_str(),pPreprocessing);
|
return Export(pScene,pFormatId.c_str(),pPath.c_str(),pPreprocessing, pProperties);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Assimp
|
} // namespace Assimp
|
||||||
|
|
|
@ -879,4 +879,15 @@ enum aiComponent
|
||||||
|
|
||||||
#define AI_CONFIG_IMPORT_COLLADA_IGNORE_UP_DIRECTION "IMPORT_COLLADA_IGNORE_UP_DIRECTION"
|
#define AI_CONFIG_IMPORT_COLLADA_IGNORE_UP_DIRECTION "IMPORT_COLLADA_IGNORE_UP_DIRECTION"
|
||||||
|
|
||||||
|
|
||||||
|
// ---------- All the Export defines ------------
|
||||||
|
|
||||||
|
/** @brief Specifies the xfile use double for real values of float
|
||||||
|
*
|
||||||
|
* Property type: Bool. Default value: false.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define AI_CONFIG_EXPORT_XFILE_64BIT "EXPORT_XFILE_64BIT"
|
||||||
|
|
||||||
|
|
||||||
#endif // !! AI_CONFIG_H_INC
|
#endif // !! AI_CONFIG_H_INC
|
||||||
|
|
Loading…
Reference in New Issue