Collada Export: escape user-defined strings in XML output.
parent
fddae20cb7
commit
33ffb0003e
|
@ -144,6 +144,7 @@ SET( Common_SRCS
|
||||||
LogAux.h
|
LogAux.h
|
||||||
Bitmap.cpp
|
Bitmap.cpp
|
||||||
Bitmap.h
|
Bitmap.h
|
||||||
|
XMLTools.h
|
||||||
)
|
)
|
||||||
SOURCE_GROUP(Common FILES ${Common_SRCS})
|
SOURCE_GROUP(Common FILES ${Common_SRCS})
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "Bitmap.h"
|
#include "Bitmap.h"
|
||||||
#include "fast_atof.h"
|
#include "fast_atof.h"
|
||||||
#include "SceneCombiner.h"
|
#include "SceneCombiner.h"
|
||||||
|
#include "XMLTools.h"
|
||||||
|
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
@ -93,6 +94,7 @@ void ExportSceneCollada(const char* pFile, IOSystem* pIOSystem, const aiScene* p
|
||||||
} // end of namespace Assimp
|
} // end of namespace Assimp
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Constructor for a specific scene to export
|
// Constructor for a specific scene to export
|
||||||
ColladaExporter::ColladaExporter( const aiScene* pScene, IOSystem* pIOSystem, const std::string& path, const std::string& file) : mIOSystem(pIOSystem), mPath(path), mFile(file)
|
ColladaExporter::ColladaExporter( const aiScene* pScene, IOSystem* pIOSystem, const std::string& path, const std::string& file) : mIOSystem(pIOSystem), mPath(path), mFile(file)
|
||||||
|
@ -140,7 +142,7 @@ void ColladaExporter::WriteFile()
|
||||||
// useless Collada fu at the end, just in case we haven't had enough indirections, yet.
|
// useless Collada fu at the end, just in case we haven't had enough indirections, yet.
|
||||||
mOutput << startstr << "<scene>" << endstr;
|
mOutput << startstr << "<scene>" << endstr;
|
||||||
PushTag();
|
PushTag();
|
||||||
mOutput << startstr << "<instance_visual_scene url=\"#" + std::string(mScene->mRootNode->mName.C_Str()) + "\" />" << endstr;
|
mOutput << startstr << "<instance_visual_scene url=\"#" + XMLEscape(mScene->mRootNode->mName.C_Str()) + "\" />" << endstr;
|
||||||
PopTag();
|
PopTag();
|
||||||
mOutput << startstr << "</scene>" << endstr;
|
mOutput << startstr << "</scene>" << endstr;
|
||||||
PopTag();
|
PopTag();
|
||||||
|
@ -236,12 +238,12 @@ void ColladaExporter::WriteHeader()
|
||||||
if (!meta || !meta->Get("Author", value))
|
if (!meta || !meta->Get("Author", value))
|
||||||
mOutput << startstr << "<author>" << "Assimp" << "</author>" << endstr;
|
mOutput << startstr << "<author>" << "Assimp" << "</author>" << endstr;
|
||||||
else
|
else
|
||||||
mOutput << startstr << "<author>" << value.C_Str() << "</author>" << endstr;
|
mOutput << startstr << "<author>" << XMLEscape(value.C_Str()) << "</author>" << endstr;
|
||||||
|
|
||||||
if (!meta || !meta->Get("AuthoringTool", value))
|
if (!meta || !meta->Get("AuthoringTool", value))
|
||||||
mOutput << startstr << "<authoring_tool>" << "Assimp Exporter" << "</authoring_tool>" << endstr;
|
mOutput << startstr << "<authoring_tool>" << "Assimp Exporter" << "</authoring_tool>" << endstr;
|
||||||
else
|
else
|
||||||
mOutput << startstr << "<authoring_tool>" << value.C_Str() << "</authoring_tool>" << endstr;
|
mOutput << startstr << "<authoring_tool>" << XMLEscape(value.C_Str()) << "</authoring_tool>" << endstr;
|
||||||
|
|
||||||
//mOutput << startstr << "<author>" << mScene->author.C_Str() << "</author>" << endstr;
|
//mOutput << startstr << "<author>" << mScene->author.C_Str() << "</author>" << endstr;
|
||||||
//mOutput << startstr << "<authoring_tool>" << mScene->authoringTool.C_Str() << "</authoring_tool>" << endstr;
|
//mOutput << startstr << "<authoring_tool>" << mScene->authoringTool.C_Str() << "</authoring_tool>" << endstr;
|
||||||
|
@ -342,16 +344,20 @@ void ColladaExporter::WriteImageEntry( const Surface& pSurface, const std::strin
|
||||||
{
|
{
|
||||||
if( !pSurface.texture.empty() )
|
if( !pSurface.texture.empty() )
|
||||||
{
|
{
|
||||||
mOutput << startstr << "<image id=\"" << pNameAdd << "\">" << endstr;
|
mOutput << startstr << "<image id=\"" << XMLEscape(pNameAdd) << "\">" << endstr;
|
||||||
PushTag();
|
PushTag();
|
||||||
mOutput << startstr << "<init_from>";
|
mOutput << startstr << "<init_from>";
|
||||||
|
|
||||||
|
// URL encode image file name first, then XML encode on top
|
||||||
|
std::stringstream imageUrlEncoded;
|
||||||
for( std::string::const_iterator it = pSurface.texture.begin(); it != pSurface.texture.end(); ++it )
|
for( std::string::const_iterator it = pSurface.texture.begin(); it != pSurface.texture.end(); ++it )
|
||||||
{
|
{
|
||||||
if( isalnum( *it) || *it == '_' || *it == '.' || *it == '/' || *it == '\\' )
|
if( isalnum( *it) || *it == '_' || *it == '.' || *it == '/' || *it == '\\' )
|
||||||
mOutput << *it;
|
imageUrlEncoded << *it;
|
||||||
else
|
else
|
||||||
mOutput << '%' << std::hex << size_t( (unsigned char) *it) << std::dec;
|
imageUrlEncoded << '%' << std::hex << size_t( (unsigned char) *it) << std::dec;
|
||||||
}
|
}
|
||||||
|
mOutput << XMLEscape(imageUrlEncoded.str());
|
||||||
mOutput << "</init_from>" << endstr;
|
mOutput << "</init_from>" << endstr;
|
||||||
PopTag();
|
PopTag();
|
||||||
mOutput << startstr << "</image>" << endstr;
|
mOutput << startstr << "</image>" << endstr;
|
||||||
|
@ -371,7 +377,7 @@ void ColladaExporter::WriteTextureColorEntry( const Surface& pSurface, const std
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mOutput << startstr << "<texture texture=\"" << pImageName << "\" texcoord=\"CHANNEL" << pSurface.channel << "\" />" << endstr;
|
mOutput << startstr << "<texture texture=\"" << XMLEscape(pImageName) << "\" texcoord=\"CHANNEL" << pSurface.channel << "\" />" << endstr;
|
||||||
}
|
}
|
||||||
PopTag();
|
PopTag();
|
||||||
mOutput << startstr << "</" << pTypeName << ">" << endstr;
|
mOutput << startstr << "</" << pTypeName << ">" << endstr;
|
||||||
|
@ -385,21 +391,21 @@ void ColladaExporter::WriteTextureParamEntry( const Surface& pSurface, const std
|
||||||
// if surface is a texture, write out the sampler and the surface parameters necessary to reference the texture
|
// if surface is a texture, write out the sampler and the surface parameters necessary to reference the texture
|
||||||
if( !pSurface.texture.empty() )
|
if( !pSurface.texture.empty() )
|
||||||
{
|
{
|
||||||
mOutput << startstr << "<newparam sid=\"" << pMatName << "-" << pTypeName << "-surface\">" << endstr;
|
mOutput << startstr << "<newparam sid=\"" << XMLEscape(pMatName) << "-" << pTypeName << "-surface\">" << endstr;
|
||||||
PushTag();
|
PushTag();
|
||||||
mOutput << startstr << "<surface type=\"2D\">" << endstr;
|
mOutput << startstr << "<surface type=\"2D\">" << endstr;
|
||||||
PushTag();
|
PushTag();
|
||||||
mOutput << startstr << "<init_from>" << pMatName << "-" << pTypeName << "-image</init_from>" << endstr;
|
mOutput << startstr << "<init_from>" << XMLEscape(pMatName) << "-" << pTypeName << "-image</init_from>" << endstr;
|
||||||
PopTag();
|
PopTag();
|
||||||
mOutput << startstr << "</surface>" << endstr;
|
mOutput << startstr << "</surface>" << endstr;
|
||||||
PopTag();
|
PopTag();
|
||||||
mOutput << startstr << "</newparam>" << endstr;
|
mOutput << startstr << "</newparam>" << endstr;
|
||||||
|
|
||||||
mOutput << startstr << "<newparam sid=\"" << pMatName << "-" << pTypeName << "-sampler\">" << endstr;
|
mOutput << startstr << "<newparam sid=\"" << XMLEscape(pMatName) << "-" << pTypeName << "-sampler\">" << endstr;
|
||||||
PushTag();
|
PushTag();
|
||||||
mOutput << startstr << "<sampler2D>" << endstr;
|
mOutput << startstr << "<sampler2D>" << endstr;
|
||||||
PushTag();
|
PushTag();
|
||||||
mOutput << startstr << "<source>" << pMatName << "-" << pTypeName << "-surface</source>" << endstr;
|
mOutput << startstr << "<source>" << XMLEscape(pMatName) << "-" << pTypeName << "-surface</source>" << endstr;
|
||||||
PopTag();
|
PopTag();
|
||||||
mOutput << startstr << "</sampler2D>" << endstr;
|
mOutput << startstr << "</sampler2D>" << endstr;
|
||||||
PopTag();
|
PopTag();
|
||||||
|
@ -439,7 +445,7 @@ void ColladaExporter::WriteMaterials()
|
||||||
name = "mat";
|
name = "mat";
|
||||||
materials[a].name = std::string( "m") + boost::lexical_cast<std::string> (a) + name.C_Str();
|
materials[a].name = std::string( "m") + boost::lexical_cast<std::string> (a) + name.C_Str();
|
||||||
for( std::string::iterator it = materials[a].name.begin(); it != materials[a].name.end(); ++it ) {
|
for( std::string::iterator it = materials[a].name.begin(); it != materials[a].name.end(); ++it ) {
|
||||||
// isalnum on MSVC asserts for code points in [0,255]. Thus prevent unwanted promotion
|
// isalnum on MSVC asserts for code points outside [0,255]. Thus prevent unwanted promotion
|
||||||
// of char to signed int and take the unsigned char value.
|
// of char to signed int and take the unsigned char value.
|
||||||
if( !isalnum( static_cast<uint8_t>(*it) ) ) {
|
if( !isalnum( static_cast<uint8_t>(*it) ) ) {
|
||||||
*it = '_';
|
*it = '_';
|
||||||
|
@ -510,7 +516,7 @@ void ColladaExporter::WriteMaterials()
|
||||||
{
|
{
|
||||||
const Material& mat = *it;
|
const Material& mat = *it;
|
||||||
// this is so ridiculous it must be right
|
// this is so ridiculous it must be right
|
||||||
mOutput << startstr << "<effect id=\"" << mat.name << "-fx\" name=\"" << mat.name << "\">" << endstr;
|
mOutput << startstr << "<effect id=\"" << XMLEscape(mat.name) << "-fx\" name=\"" << XMLEscape(mat.name) << "\">" << endstr;
|
||||||
PushTag();
|
PushTag();
|
||||||
mOutput << startstr << "<profile_COMMON>" << endstr;
|
mOutput << startstr << "<profile_COMMON>" << endstr;
|
||||||
PushTag();
|
PushTag();
|
||||||
|
@ -561,9 +567,9 @@ void ColladaExporter::WriteMaterials()
|
||||||
for( std::vector<Material>::const_iterator it = materials.begin(); it != materials.end(); ++it )
|
for( std::vector<Material>::const_iterator it = materials.begin(); it != materials.end(); ++it )
|
||||||
{
|
{
|
||||||
const Material& mat = *it;
|
const Material& mat = *it;
|
||||||
mOutput << startstr << "<material id=\"" << mat.name << "\" name=\"" << mat.name << "\">" << endstr;
|
mOutput << startstr << "<material id=\"" << XMLEscape(mat.name) << "\" name=\"" << mat.name << "\">" << endstr;
|
||||||
PushTag();
|
PushTag();
|
||||||
mOutput << startstr << "<instance_effect url=\"#" << mat.name << "-fx\"/>" << endstr;
|
mOutput << startstr << "<instance_effect url=\"#" << XMLEscape(mat.name) << "-fx\"/>" << endstr;
|
||||||
PopTag();
|
PopTag();
|
||||||
mOutput << startstr << "</material>" << endstr;
|
mOutput << startstr << "</material>" << endstr;
|
||||||
}
|
}
|
||||||
|
@ -591,13 +597,14 @@ void ColladaExporter::WriteGeometryLibrary()
|
||||||
void ColladaExporter::WriteGeometry( size_t pIndex)
|
void ColladaExporter::WriteGeometry( size_t pIndex)
|
||||||
{
|
{
|
||||||
const aiMesh* mesh = mScene->mMeshes[pIndex];
|
const aiMesh* mesh = mScene->mMeshes[pIndex];
|
||||||
std::string idstr = GetMeshId( pIndex);
|
const std::string idstr = GetMeshId( pIndex);
|
||||||
|
const std::string idstrEscaped = XMLEscape(idstr);
|
||||||
|
|
||||||
if( mesh->mNumFaces == 0 || mesh->mNumVertices == 0 )
|
if( mesh->mNumFaces == 0 || mesh->mNumVertices == 0 )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// opening tag
|
// opening tag
|
||||||
mOutput << startstr << "<geometry id=\"" << idstr << "\" name=\"" << idstr << "_name\" >" << endstr;
|
mOutput << startstr << "<geometry id=\"" << idstrEscaped << "\" name=\"" << idstrEscaped << "_name\" >" << endstr;
|
||||||
PushTag();
|
PushTag();
|
||||||
|
|
||||||
mOutput << startstr << "<mesh>" << endstr;
|
mOutput << startstr << "<mesh>" << endstr;
|
||||||
|
@ -627,20 +634,20 @@ void ColladaExporter::WriteGeometry( size_t pIndex)
|
||||||
}
|
}
|
||||||
|
|
||||||
// assemble vertex structure
|
// assemble vertex structure
|
||||||
mOutput << startstr << "<vertices id=\"" << idstr << "-vertices" << "\">" << endstr;
|
mOutput << startstr << "<vertices id=\"" << idstrEscaped << "-vertices" << "\">" << endstr;
|
||||||
PushTag();
|
PushTag();
|
||||||
mOutput << startstr << "<input semantic=\"POSITION\" source=\"#" << idstr << "-positions\" />" << endstr;
|
mOutput << startstr << "<input semantic=\"POSITION\" source=\"#" << idstrEscaped << "-positions\" />" << endstr;
|
||||||
if( mesh->HasNormals() )
|
if( mesh->HasNormals() )
|
||||||
mOutput << startstr << "<input semantic=\"NORMAL\" source=\"#" << idstr << "-normals\" />" << endstr;
|
mOutput << startstr << "<input semantic=\"NORMAL\" source=\"#" << idstrEscaped << "-normals\" />" << endstr;
|
||||||
for( size_t a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++a )
|
for( size_t a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++a )
|
||||||
{
|
{
|
||||||
if( mesh->HasTextureCoords( a) )
|
if( mesh->HasTextureCoords( a) )
|
||||||
mOutput << startstr << "<input semantic=\"TEXCOORD\" source=\"#" << idstr << "-tex" << a << "\" " /*<< "set=\"" << a << "\"" */ << " />" << endstr;
|
mOutput << startstr << "<input semantic=\"TEXCOORD\" source=\"#" << idstrEscaped << "-tex" << a << "\" " /*<< "set=\"" << a << "\"" */ << " />" << endstr;
|
||||||
}
|
}
|
||||||
for( size_t a = 0; a < AI_MAX_NUMBER_OF_COLOR_SETS; ++a )
|
for( size_t a = 0; a < AI_MAX_NUMBER_OF_COLOR_SETS; ++a )
|
||||||
{
|
{
|
||||||
if( mesh->HasVertexColors( a) )
|
if( mesh->HasVertexColors( a) )
|
||||||
mOutput << startstr << "<input semantic=\"COLOR\" source=\"#" << idstr << "-color" << a << "\" " /*<< set=\"" << a << "\"" */ << " />" << endstr;
|
mOutput << startstr << "<input semantic=\"COLOR\" source=\"#" << idstrEscaped << "-color" << a << "\" " /*<< set=\"" << a << "\"" */ << " />" << endstr;
|
||||||
}
|
}
|
||||||
|
|
||||||
PopTag();
|
PopTag();
|
||||||
|
@ -660,7 +667,7 @@ void ColladaExporter::WriteGeometry( size_t pIndex)
|
||||||
{
|
{
|
||||||
mOutput << startstr << "<lines count=\"" << countLines << "\" material=\"defaultMaterial\">" << endstr;
|
mOutput << startstr << "<lines count=\"" << countLines << "\" material=\"defaultMaterial\">" << endstr;
|
||||||
PushTag();
|
PushTag();
|
||||||
mOutput << startstr << "<input offset=\"0\" semantic=\"VERTEX\" source=\"#" << idstr << "-vertices\" />" << endstr;
|
mOutput << startstr << "<input offset=\"0\" semantic=\"VERTEX\" source=\"#" << idstrEscaped << "-vertices\" />" << endstr;
|
||||||
mOutput << startstr << "<p>";
|
mOutput << startstr << "<p>";
|
||||||
for( size_t a = 0; a < mesh->mNumFaces; ++a )
|
for( size_t a = 0; a < mesh->mNumFaces; ++a )
|
||||||
{
|
{
|
||||||
|
@ -681,7 +688,7 @@ void ColladaExporter::WriteGeometry( size_t pIndex)
|
||||||
{
|
{
|
||||||
mOutput << startstr << "<polylist count=\"" << countPoly << "\" material=\"defaultMaterial\">" << endstr;
|
mOutput << startstr << "<polylist count=\"" << countPoly << "\" material=\"defaultMaterial\">" << endstr;
|
||||||
PushTag();
|
PushTag();
|
||||||
mOutput << startstr << "<input offset=\"0\" semantic=\"VERTEX\" source=\"#" << idstr << "-vertices\" />" << endstr;
|
mOutput << startstr << "<input offset=\"0\" semantic=\"VERTEX\" source=\"#" << idstrEscaped << "-vertices\" />" << endstr;
|
||||||
|
|
||||||
mOutput << startstr << "<vcount>";
|
mOutput << startstr << "<vcount>";
|
||||||
for( size_t a = 0; a < mesh->mNumFaces; ++a )
|
for( size_t a = 0; a < mesh->mNumFaces; ++a )
|
||||||
|
@ -728,11 +735,11 @@ void ColladaExporter::WriteFloatArray( const std::string& pIdString, FloatDataTy
|
||||||
|
|
||||||
std::string arrayId = pIdString + "-array";
|
std::string arrayId = pIdString + "-array";
|
||||||
|
|
||||||
mOutput << startstr << "<source id=\"" << pIdString << "\" name=\"" << pIdString << "\">" << endstr;
|
mOutput << startstr << "<source id=\"" << XMLEscape(pIdString) << "\" name=\"" << XMLEscape(pIdString) << "\">" << endstr;
|
||||||
PushTag();
|
PushTag();
|
||||||
|
|
||||||
// source array
|
// source array
|
||||||
mOutput << startstr << "<float_array id=\"" << arrayId << "\" count=\"" << pElementCount * floatsPerElement << "\"> ";
|
mOutput << startstr << "<float_array id=\"" << XMLEscape(arrayId) << "\" count=\"" << pElementCount * floatsPerElement << "\"> ";
|
||||||
PushTag();
|
PushTag();
|
||||||
|
|
||||||
if( pType == FloatType_TexCoord2 )
|
if( pType == FloatType_TexCoord2 )
|
||||||
|
@ -804,11 +811,11 @@ void ColladaExporter::WriteFloatArray( const std::string& pIdString, FloatDataTy
|
||||||
// Writes the scene library
|
// Writes the scene library
|
||||||
void ColladaExporter::WriteSceneLibrary()
|
void ColladaExporter::WriteSceneLibrary()
|
||||||
{
|
{
|
||||||
std::string scene_name = mScene->mRootNode->mName.C_Str();
|
const std::string scene_name_escaped = XMLEscape(mScene->mRootNode->mName.C_Str());
|
||||||
|
|
||||||
mOutput << startstr << "<library_visual_scenes>" << endstr;
|
mOutput << startstr << "<library_visual_scenes>" << endstr;
|
||||||
PushTag();
|
PushTag();
|
||||||
mOutput << startstr << "<visual_scene id=\"" + scene_name + "\" name=\"" + scene_name + "\">" << endstr;
|
mOutput << startstr << "<visual_scene id=\"" + scene_name_escaped + "\" name=\"" + scene_name_escaped + "\">" << endstr;
|
||||||
PushTag();
|
PushTag();
|
||||||
|
|
||||||
// start recursive write at the root node
|
// start recursive write at the root node
|
||||||
|
@ -833,7 +840,8 @@ void ColladaExporter::WriteNode(aiNode* pNode)
|
||||||
pNode->mName.Set(ss.str());
|
pNode->mName.Set(ss.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
mOutput << startstr << "<node id=\"" << pNode->mName.data << "\" name=\"" << pNode->mName.data << "\">" << endstr;
|
const std::string node_name_escaped = XMLEscape(pNode->mName.data);
|
||||||
|
mOutput << startstr << "<node id=\"" << node_name_escaped << "\" name=\"" << node_name_escaped << "\">" << endstr;
|
||||||
PushTag();
|
PushTag();
|
||||||
|
|
||||||
// write transformation - we can directly put the matrix there
|
// write transformation - we can directly put the matrix there
|
||||||
|
@ -854,13 +862,13 @@ void ColladaExporter::WriteNode(aiNode* pNode)
|
||||||
if( mesh->mNumFaces == 0 || mesh->mNumVertices == 0 )
|
if( mesh->mNumFaces == 0 || mesh->mNumVertices == 0 )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
mOutput << startstr << "<instance_geometry url=\"#" << GetMeshId( pNode->mMeshes[a]) << "\">" << endstr;
|
mOutput << startstr << "<instance_geometry url=\"#" << XMLEscape(GetMeshId( pNode->mMeshes[a])) << "\">" << endstr;
|
||||||
PushTag();
|
PushTag();
|
||||||
mOutput << startstr << "<bind_material>" << endstr;
|
mOutput << startstr << "<bind_material>" << endstr;
|
||||||
PushTag();
|
PushTag();
|
||||||
mOutput << startstr << "<technique_common>" << endstr;
|
mOutput << startstr << "<technique_common>" << endstr;
|
||||||
PushTag();
|
PushTag();
|
||||||
mOutput << startstr << "<instance_material symbol=\"defaultMaterial\" target=\"#" << materials[mesh->mMaterialIndex].name << "\" />" << endstr;
|
mOutput << startstr << "<instance_material symbol=\"defaultMaterial\" target=\"#" << XMLEscape(materials[mesh->mMaterialIndex].name) << "\" />" << endstr;
|
||||||
PopTag();
|
PopTag();
|
||||||
mOutput << startstr << "</technique_common>" << endstr;
|
mOutput << startstr << "</technique_common>" << endstr;
|
||||||
PopTag();
|
PopTag();
|
||||||
|
|
|
@ -0,0 +1,81 @@
|
||||||
|
/*
|
||||||
|
Open Asset Import Library (assimp)
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2012, assimp team
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the
|
||||||
|
following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the assimp team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the assimp team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef INCLUDED_ASSIMP_XML_TOOLS_H
|
||||||
|
#define INCLUDED_ASSIMP_XML_TOOLS_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace Assimp {
|
||||||
|
// XML escape the 5 XML special characters (",',<,> and &) in |data|
|
||||||
|
// Based on http://stackoverflow.com/questions/5665231
|
||||||
|
std::string XMLEscape(const std::string& data) {
|
||||||
|
std::string buffer;
|
||||||
|
|
||||||
|
const size_t size = data.size();
|
||||||
|
buffer.reserve(size + size / 8);
|
||||||
|
for(size_t i = 0; i < size; ++i) {
|
||||||
|
const char c = data[i];
|
||||||
|
switch(c) {
|
||||||
|
case '&' :
|
||||||
|
buffer.append("&");
|
||||||
|
break;
|
||||||
|
case '\"':
|
||||||
|
buffer.append(""");
|
||||||
|
break;
|
||||||
|
case '\'':
|
||||||
|
buffer.append("'");
|
||||||
|
break;
|
||||||
|
case '<' :
|
||||||
|
buffer.append("<");
|
||||||
|
break;
|
||||||
|
case '>' :
|
||||||
|
buffer.append(">");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
buffer.append(&c, 1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // INCLUDED_ASSIMP_XML_TOOLS_H
|
|
@ -0,0 +1,210 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<COLLADA xmlns="http://www.collada.org/2005/11/COLLADASchema" version="1.4.1">
|
||||||
|
<asset>
|
||||||
|
<contributor>
|
||||||
|
<author>alorino</author>
|
||||||
|
<authoring_tool>Maya 7.0 | ColladaMaya v2.01 Jun 9 2006 at 16:08:19 | FCollada v1.11</authoring_tool>
|
||||||
|
<comments>Collada Maya Export Options: bakeTransforms=0;exportPolygonMeshes=1;bakeLighting=0;isSampling=0;
|
||||||
|
curveConstrainSampling=0;exportCameraAsLookat=0;
|
||||||
|
exportLights=1;exportCameras=1;exportJointsAndSkin=1;
|
||||||
|
exportAnimations=1;exportTriangles=0;exportInvisibleNodes=0;
|
||||||
|
exportNormals=1;exportTexCoords=1;exportVertexColors=1;exportTangents=0;
|
||||||
|
exportTexTangents=0;exportConstraints=0;exportPhysics=0;exportXRefs=1;
|
||||||
|
dereferenceXRefs=0;cameraXFov=0;cameraYFov=1</comments>
|
||||||
|
<copyright>
|
||||||
|
Copyright 2006 Sony Computer Entertainment Inc.
|
||||||
|
Licensed under the SCEA Shared Source License, Version 1.0 (the
|
||||||
|
"License"); you may not use this file except in compliance with the
|
||||||
|
License. You may obtain a copy of the License at:
|
||||||
|
http://research.scea.com/scea_shared_source_license.html
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
</copyright>
|
||||||
|
</contributor>
|
||||||
|
<created>2006-06-21T21:23:22Z</created>
|
||||||
|
<modified>2006-06-21T21:23:22Z</modified>
|
||||||
|
<unit meter="0.01" name="centimeter"/>
|
||||||
|
<up_axis>Y_UP</up_axis>
|
||||||
|
</asset>
|
||||||
|
<library_cameras>
|
||||||
|
<camera id="PerspCamera" name="PerspCamera">
|
||||||
|
<optics>
|
||||||
|
<technique_common>
|
||||||
|
<perspective>
|
||||||
|
<yfov>37.8493</yfov>
|
||||||
|
<aspect_ratio>1</aspect_ratio>
|
||||||
|
<znear>10</znear>
|
||||||
|
<zfar>1000</zfar>
|
||||||
|
</perspective>
|
||||||
|
</technique_common>
|
||||||
|
</optics>
|
||||||
|
</camera>
|
||||||
|
<camera id="testCameraShape" name="testCameraShape">
|
||||||
|
<optics>
|
||||||
|
<technique_common>
|
||||||
|
<perspective>
|
||||||
|
<yfov>37.8501</yfov>
|
||||||
|
<aspect_ratio>1</aspect_ratio>
|
||||||
|
<znear>0.01</znear>
|
||||||
|
<zfar>1000</zfar>
|
||||||
|
</perspective>
|
||||||
|
</technique_common>
|
||||||
|
</optics>
|
||||||
|
</camera>
|
||||||
|
</library_cameras>
|
||||||
|
<library_lights>
|
||||||
|
<light id="light-lib" name="light">
|
||||||
|
<technique_common>
|
||||||
|
<point>
|
||||||
|
<color>1 1 1</color>
|
||||||
|
<constant_attenuation>1</constant_attenuation>
|
||||||
|
<linear_attenuation>0</linear_attenuation>
|
||||||
|
<quadratic_attenuation>0</quadratic_attenuation>
|
||||||
|
</point>
|
||||||
|
</technique_common>
|
||||||
|
<technique profile="MAX3D">
|
||||||
|
<intensity>1.000000</intensity>
|
||||||
|
</technique>
|
||||||
|
</light>
|
||||||
|
<light id="pointLightShape1-lib" name="pointLightShape1">
|
||||||
|
<technique_common>
|
||||||
|
<point>
|
||||||
|
<color>1 1 1</color>
|
||||||
|
<constant_attenuation>1</constant_attenuation>
|
||||||
|
<linear_attenuation>0</linear_attenuation>
|
||||||
|
<quadratic_attenuation>0</quadratic_attenuation>
|
||||||
|
</point>
|
||||||
|
</technique_common>
|
||||||
|
</light>
|
||||||
|
</library_lights>
|
||||||
|
<library_materials>
|
||||||
|
<material id="Blue" name="Blue">
|
||||||
|
<instance_effect url="#Blue-fx"/>
|
||||||
|
</material>
|
||||||
|
</library_materials>
|
||||||
|
<library_effects>
|
||||||
|
<effect id="Blue-fx">
|
||||||
|
<profile_COMMON>
|
||||||
|
<technique sid="common">
|
||||||
|
<phong>
|
||||||
|
<emission>
|
||||||
|
<color>0 0 0 1</color>
|
||||||
|
</emission>
|
||||||
|
<ambient>
|
||||||
|
<color>0 0 0 1</color>
|
||||||
|
</ambient>
|
||||||
|
<diffuse>
|
||||||
|
<color>0.137255 0.403922 0.870588 1</color>
|
||||||
|
</diffuse>
|
||||||
|
<specular>
|
||||||
|
<color>0.5 0.5 0.5 1</color>
|
||||||
|
</specular>
|
||||||
|
<shininess>
|
||||||
|
<float>16</float>
|
||||||
|
</shininess>
|
||||||
|
<reflective>
|
||||||
|
<color>0 0 0 1</color>
|
||||||
|
</reflective>
|
||||||
|
<reflectivity>
|
||||||
|
<float>0.5</float>
|
||||||
|
</reflectivity>
|
||||||
|
<transparent>
|
||||||
|
<color>0 0 0 1</color>
|
||||||
|
</transparent>
|
||||||
|
<transparency>
|
||||||
|
<float>1</float>
|
||||||
|
</transparency>
|
||||||
|
<index_of_refraction>
|
||||||
|
<float>0</float>
|
||||||
|
</index_of_refraction>
|
||||||
|
</phong>
|
||||||
|
</technique>
|
||||||
|
</profile_COMMON>
|
||||||
|
</effect>
|
||||||
|
</library_effects>
|
||||||
|
<library_geometries>
|
||||||
|
<geometry id=""&<box-lib>&"" name=""&<box>&"">
|
||||||
|
<mesh>
|
||||||
|
<source id=""&<box-lib-positions>&"" name="position">
|
||||||
|
<float_array id="box-lib-positions-array" count="24">-50 50 50 50 50 50 -50 -50 50 50 -50 50 -50 50 -50 50 50 -50 -50 -50 -50 50 -50 -50</float_array>
|
||||||
|
<technique_common>
|
||||||
|
<accessor count="8" offset="0" source="#box-lib-positions-array" stride="3">
|
||||||
|
<param name="X" type="float"></param>
|
||||||
|
<param name="Y" type="float"></param>
|
||||||
|
<param name="Z" type="float"></param>
|
||||||
|
</accessor>
|
||||||
|
</technique_common>
|
||||||
|
</source>
|
||||||
|
<source id=""&<box-lib-normals>&"" name="normal">
|
||||||
|
<float_array id="box-lib-normals-array" count="72">0 0 1 0 0 1 0 0 1 0 0 1 0 1 0 0 1 0 0 1 0 0 1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 0 0 -1 0 0 -1 0 0 -1 0 0 -1</float_array>
|
||||||
|
<technique_common>
|
||||||
|
<accessor count="24" offset="0" source="#box-lib-normals-array" stride="3">
|
||||||
|
<param name="X" type="float"></param>
|
||||||
|
<param name="Y" type="float"></param>
|
||||||
|
<param name="Z" type="float"></param>
|
||||||
|
</accessor>
|
||||||
|
</technique_common>
|
||||||
|
</source>
|
||||||
|
<vertices id=""&<box-lib-vertices>&"">
|
||||||
|
<input semantic="POSITION" source="#"&<box-lib-positions>&""/>
|
||||||
|
</vertices>
|
||||||
|
<polylist count="6" material="BlueSG">
|
||||||
|
<input offset="0" semantic="VERTEX" source="#"&<box-lib-vertices>&""/>
|
||||||
|
<input offset="1" semantic="NORMAL" source="#"&<box-lib-normals>&""/>
|
||||||
|
<vcount>4 4 4 4 4 4</vcount>
|
||||||
|
<p>0 0 2 1 3 2 1 3 0 4 1 5 5 6 4 7 6 8 7 9 3 10 2 11 0 12 4 13 6 14 2 15 3 16 7 17 5 18 1 19 5 20 7 21 6 22 4 23</p>
|
||||||
|
</polylist>
|
||||||
|
</mesh>
|
||||||
|
</geometry>
|
||||||
|
</library_geometries>
|
||||||
|
<library_visual_scenes>
|
||||||
|
<visual_scene id=""&<VisualSceneNode>&"" name="untitled">
|
||||||
|
<node id="Camera" name="Camera">
|
||||||
|
<translate sid="translate">-427.749 333.855 655.017</translate>
|
||||||
|
<rotate sid="rotateY">0 1 0 -33</rotate>
|
||||||
|
<rotate sid="rotateX">1 0 0 -22.1954</rotate>
|
||||||
|
<rotate sid="rotateZ">0 0 1 0</rotate>
|
||||||
|
<instance_camera url="#PerspCamera"/>
|
||||||
|
</node>
|
||||||
|
<node id="Light" name="Light">
|
||||||
|
<translate sid="translate">-500 1000 400</translate>
|
||||||
|
<rotate sid="rotateZ">0 0 1 0</rotate>
|
||||||
|
<rotate sid="rotateY">0 1 0 0</rotate>
|
||||||
|
<rotate sid="rotateX">1 0 0 0</rotate>
|
||||||
|
<instance_light url="#light-lib"/>
|
||||||
|
</node>
|
||||||
|
<node id="Box" name=""&<Box>&"">
|
||||||
|
<rotate sid="rotateZ">0 0 1 0</rotate>
|
||||||
|
<rotate sid="rotateY">0 1 0 0</rotate>
|
||||||
|
<rotate sid="rotateX">1 0 0 0</rotate>
|
||||||
|
<instance_geometry url="#"&<box-lib>&"">
|
||||||
|
<bind_material>
|
||||||
|
<technique_common>
|
||||||
|
<instance_material symbol="BlueSG" target="#Blue"/>
|
||||||
|
</technique_common>
|
||||||
|
</bind_material>
|
||||||
|
</instance_geometry>
|
||||||
|
</node>
|
||||||
|
<node id="testCamera" name="testCamera">
|
||||||
|
<translate sid="translate">-427.749 333.855 655.017</translate>
|
||||||
|
<rotate sid="rotateY">0 1 0 -33</rotate>
|
||||||
|
<rotate sid="rotateX">1 0 0 -22.1954</rotate>
|
||||||
|
<rotate sid="rotateZ">0 0 1 0</rotate>
|
||||||
|
<instance_camera url="#testCameraShape"/>
|
||||||
|
</node>
|
||||||
|
<node id="pointLight1" name="pointLight1">
|
||||||
|
<translate sid="translate">3 4 10</translate>
|
||||||
|
<rotate sid="rotateZ">0 0 1 0</rotate>
|
||||||
|
<rotate sid="rotateY">0 1 0 0</rotate>
|
||||||
|
<rotate sid="rotateX">1 0 0 0</rotate>
|
||||||
|
<instance_light url="#pointLightShape1-lib"/>
|
||||||
|
</node>
|
||||||
|
</visual_scene>
|
||||||
|
</library_visual_scenes>
|
||||||
|
<scene>
|
||||||
|
<instance_visual_scene url="#"&<VisualSceneNode>&""/>
|
||||||
|
</scene>
|
||||||
|
</COLLADA>
|
Loading…
Reference in New Issue