Merge pull request #615 from delicious-monster/master
I made changes to the Collada importer so it will import SketchUp DAEs.pull/612/merge
commit
a9a62368f8
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,352 @@
|
||||||
|
/*
|
||||||
|
Open Asset Import Library (assimp)
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2015, 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.
|
||||||
|
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @file ColladaParser.h
|
||||||
|
* @brief Defines the parser helper class for the collada loader
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef AI_COLLADAPARSER_H_INC
|
||||||
|
#define AI_COLLADAPARSER_H_INC
|
||||||
|
|
||||||
|
#include "irrXMLWrapper.h"
|
||||||
|
#include "ColladaHelper.h"
|
||||||
|
#include "../include/assimp/ai_assert.h"
|
||||||
|
#include <boost/format.hpp>
|
||||||
|
|
||||||
|
namespace Assimp
|
||||||
|
{
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------
|
||||||
|
/** Parser helper class for the Collada loader.
|
||||||
|
*
|
||||||
|
* Does all the XML reading and builds internal data structures from it,
|
||||||
|
* but leaves the resolving of all the references to the loader.
|
||||||
|
*/
|
||||||
|
class ColladaParser
|
||||||
|
{
|
||||||
|
friend class ColladaLoader;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
/** Constructor from XML file */
|
||||||
|
ColladaParser( IOSystem* pIOHandler, const std::string& pFile);
|
||||||
|
|
||||||
|
/** Destructor */
|
||||||
|
~ColladaParser();
|
||||||
|
|
||||||
|
/** Reads the contents of the file */
|
||||||
|
void ReadContents();
|
||||||
|
|
||||||
|
/** Reads the structure of the file */
|
||||||
|
void ReadStructure();
|
||||||
|
|
||||||
|
/** Reads asset informations such as coordinate system informations and legal blah */
|
||||||
|
void ReadAssetInfo();
|
||||||
|
|
||||||
|
/** Reads the animation library */
|
||||||
|
void ReadAnimationLibrary();
|
||||||
|
|
||||||
|
/** Reads an animation into the given parent structure */
|
||||||
|
void ReadAnimation( Collada::Animation* pParent);
|
||||||
|
|
||||||
|
/** Reads an animation sampler into the given anim channel */
|
||||||
|
void ReadAnimationSampler( Collada::AnimationChannel& pChannel);
|
||||||
|
|
||||||
|
/** Reads the skeleton controller library */
|
||||||
|
void ReadControllerLibrary();
|
||||||
|
|
||||||
|
/** Reads a controller into the given mesh structure */
|
||||||
|
void ReadController( Collada::Controller& pController);
|
||||||
|
|
||||||
|
/** Reads the joint definitions for the given controller */
|
||||||
|
void ReadControllerJoints( Collada::Controller& pController);
|
||||||
|
|
||||||
|
/** Reads the joint weights for the given controller */
|
||||||
|
void ReadControllerWeights( Collada::Controller& pController);
|
||||||
|
|
||||||
|
/** Reads the image library contents */
|
||||||
|
void ReadImageLibrary();
|
||||||
|
|
||||||
|
/** Reads an image entry into the given image */
|
||||||
|
void ReadImage( Collada::Image& pImage);
|
||||||
|
|
||||||
|
/** Reads the material library */
|
||||||
|
void ReadMaterialLibrary();
|
||||||
|
|
||||||
|
/** Reads a material entry into the given material */
|
||||||
|
void ReadMaterial( Collada::Material& pMaterial);
|
||||||
|
|
||||||
|
/** Reads the camera library */
|
||||||
|
void ReadCameraLibrary();
|
||||||
|
|
||||||
|
/** Reads a camera entry into the given camera */
|
||||||
|
void ReadCamera( Collada::Camera& pCamera);
|
||||||
|
|
||||||
|
/** Reads the light library */
|
||||||
|
void ReadLightLibrary();
|
||||||
|
|
||||||
|
/** Reads a light entry into the given light */
|
||||||
|
void ReadLight( Collada::Light& pLight);
|
||||||
|
|
||||||
|
/** Reads the effect library */
|
||||||
|
void ReadEffectLibrary();
|
||||||
|
|
||||||
|
/** Reads an effect entry into the given effect*/
|
||||||
|
void ReadEffect( Collada::Effect& pEffect);
|
||||||
|
|
||||||
|
/** Reads an COMMON effect profile */
|
||||||
|
void ReadEffectProfileCommon( Collada::Effect& pEffect);
|
||||||
|
|
||||||
|
/** Read sampler properties */
|
||||||
|
void ReadSamplerProperties( Collada::Sampler& pSampler);
|
||||||
|
|
||||||
|
/** Reads an effect entry containing a color or a texture defining that color */
|
||||||
|
void ReadEffectColor( aiColor4D& pColor, Collada::Sampler& pSampler);
|
||||||
|
|
||||||
|
/** Reads an effect entry containing a float */
|
||||||
|
void ReadEffectFloat( float& pFloat);
|
||||||
|
|
||||||
|
/** Reads an effect parameter specification of any kind */
|
||||||
|
void ReadEffectParam( Collada::EffectParam& pParam);
|
||||||
|
|
||||||
|
/** Reads the geometry library contents */
|
||||||
|
void ReadGeometryLibrary();
|
||||||
|
|
||||||
|
/** Reads a geometry from the geometry library. */
|
||||||
|
void ReadGeometry( Collada::Mesh* pMesh);
|
||||||
|
|
||||||
|
/** Reads a mesh from the geometry library */
|
||||||
|
void ReadMesh( Collada::Mesh* pMesh);
|
||||||
|
|
||||||
|
/** Reads a source element - a combination of raw data and an accessor defining
|
||||||
|
* things that should not be redefinable. Yes, that's another rant.
|
||||||
|
*/
|
||||||
|
void ReadSource();
|
||||||
|
|
||||||
|
/** Reads a data array holding a number of elements, and stores it in the global library.
|
||||||
|
* Currently supported are array of floats and arrays of strings.
|
||||||
|
*/
|
||||||
|
void ReadDataArray();
|
||||||
|
|
||||||
|
/** Reads an accessor and stores it in the global library under the given ID -
|
||||||
|
* accessors use the ID of the parent <source> element
|
||||||
|
*/
|
||||||
|
void ReadAccessor( const std::string& pID);
|
||||||
|
|
||||||
|
/** Reads input declarations of per-vertex mesh data into the given mesh */
|
||||||
|
void ReadVertexData( Collada::Mesh* pMesh);
|
||||||
|
|
||||||
|
/** Reads input declarations of per-index mesh data into the given mesh */
|
||||||
|
void ReadIndexData( Collada::Mesh* pMesh);
|
||||||
|
|
||||||
|
/** Reads a single input channel element and stores it in the given array, if valid */
|
||||||
|
void ReadInputChannel( std::vector<Collada::InputChannel>& poChannels);
|
||||||
|
|
||||||
|
/** Reads a <p> primitive index list and assembles the mesh data into the given mesh */
|
||||||
|
size_t ReadPrimitives( Collada::Mesh* pMesh, std::vector<Collada::InputChannel>& pPerIndexChannels,
|
||||||
|
size_t pNumPrimitives, const std::vector<size_t>& pVCount, Collada::PrimitiveType pPrimType);
|
||||||
|
|
||||||
|
/** Copies the data for a single primitive into the mesh, based on the InputChannels */
|
||||||
|
void CopyVertex(size_t currentVertex, size_t numOffsets, size_t numPoints, size_t perVertexOffset,
|
||||||
|
Collada::Mesh* pMesh, std::vector<Collada::InputChannel>& pPerIndexChannels,
|
||||||
|
size_t currentPrimitive, const std::vector<size_t>& indices);
|
||||||
|
|
||||||
|
/** Reads one triangle of a tristrip into the mesh */
|
||||||
|
void ReadPrimTriStrips(size_t numOffsets, size_t perVertexOffset, Collada::Mesh* pMesh,
|
||||||
|
std::vector<Collada::InputChannel>& pPerIndexChannels, size_t currentPrimitive, const std::vector<size_t>& indices);
|
||||||
|
|
||||||
|
/** Extracts a single object from an input channel and stores it in the appropriate mesh data array */
|
||||||
|
void ExtractDataObjectFromChannel( const Collada::InputChannel& pInput, size_t pLocalIndex, Collada::Mesh* pMesh);
|
||||||
|
|
||||||
|
/** Reads the library of node hierarchies and scene parts */
|
||||||
|
void ReadSceneLibrary();
|
||||||
|
|
||||||
|
/** Reads a scene node's contents including children and stores it in the given node */
|
||||||
|
void ReadSceneNode( Collada::Node* pNode);
|
||||||
|
|
||||||
|
/** Reads a node transformation entry of the given type and adds it to the given node's transformation list. */
|
||||||
|
void ReadNodeTransformation( Collada::Node* pNode, Collada::TransformType pType);
|
||||||
|
|
||||||
|
/** Reads a mesh reference in a node and adds it to the node's mesh list */
|
||||||
|
void ReadNodeGeometry( Collada::Node* pNode);
|
||||||
|
|
||||||
|
/** Reads the collada scene */
|
||||||
|
void ReadScene();
|
||||||
|
|
||||||
|
// Processes bind_vertex_input and bind elements
|
||||||
|
void ReadMaterialVertexInputBinding( Collada::SemanticMappingTable& tbl);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
/** Aborts the file reading with an exception */
|
||||||
|
AI_WONT_RETURN void ThrowException( const std::string& pError) const AI_WONT_RETURN_SUFFIX;
|
||||||
|
|
||||||
|
/** Skips all data until the end node of the current element */
|
||||||
|
void SkipElement();
|
||||||
|
|
||||||
|
/** Skips all data until the end node of the given element */
|
||||||
|
void SkipElement( const char* pElement);
|
||||||
|
|
||||||
|
/** Compares the current xml element name to the given string and returns true if equal */
|
||||||
|
bool IsElement( const char* pName) const;
|
||||||
|
|
||||||
|
/** Tests for the opening tag of the given element, throws an exception if not found */
|
||||||
|
void TestOpening( const char* pName);
|
||||||
|
|
||||||
|
/** Tests for the closing tag of the given element, throws an exception if not found */
|
||||||
|
void TestClosing( const char* pName);
|
||||||
|
|
||||||
|
/** Checks the present element for the presence of the attribute, returns its index
|
||||||
|
or throws an exception if not found */
|
||||||
|
int GetAttribute( const char* pAttr) const;
|
||||||
|
|
||||||
|
/** Returns the index of the named attribute or -1 if not found. Does not throw,
|
||||||
|
therefore useful for optional attributes */
|
||||||
|
int TestAttribute( const char* pAttr) const;
|
||||||
|
|
||||||
|
/** Reads the text contents of an element, throws an exception if not given.
|
||||||
|
Skips leading whitespace. */
|
||||||
|
const char* GetTextContent();
|
||||||
|
|
||||||
|
/** Reads the text contents of an element, returns NULL if not given.
|
||||||
|
Skips leading whitespace. */
|
||||||
|
const char* TestTextContent();
|
||||||
|
|
||||||
|
/** Reads a single bool from current text content */
|
||||||
|
bool ReadBoolFromTextContent();
|
||||||
|
|
||||||
|
/** Reads a single float from current text content */
|
||||||
|
float ReadFloatFromTextContent();
|
||||||
|
|
||||||
|
/** Calculates the resulting transformation from all the given transform steps */
|
||||||
|
aiMatrix4x4 CalculateResultTransform( const std::vector<Collada::Transform>& pTransforms) const;
|
||||||
|
|
||||||
|
/** Determines the input data type for the given semantic string */
|
||||||
|
Collada::InputType GetTypeForSemantic( const std::string& pSemantic);
|
||||||
|
|
||||||
|
/** Finds the item in the given library by its reference, throws if not found */
|
||||||
|
template <typename Type> const Type& ResolveLibraryReference(
|
||||||
|
const std::map<std::string, Type>& pLibrary, const std::string& pURL) const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
/** Filename, for a verbose error message */
|
||||||
|
std::string mFileName;
|
||||||
|
|
||||||
|
/** XML reader, member for everyday use */
|
||||||
|
irr::io::IrrXMLReader* mReader;
|
||||||
|
|
||||||
|
/** All data arrays found in the file by ID. Might be referred to by actually
|
||||||
|
everyone. Collada, you are a steaming pile of indirection. */
|
||||||
|
typedef std::map<std::string, Collada::Data> DataLibrary;
|
||||||
|
DataLibrary mDataLibrary;
|
||||||
|
|
||||||
|
/** Same for accessors which define how the data in a data array is accessed. */
|
||||||
|
typedef std::map<std::string, Collada::Accessor> AccessorLibrary;
|
||||||
|
AccessorLibrary mAccessorLibrary;
|
||||||
|
|
||||||
|
/** Mesh library: mesh by ID */
|
||||||
|
typedef std::map<std::string, Collada::Mesh*> MeshLibrary;
|
||||||
|
MeshLibrary mMeshLibrary;
|
||||||
|
|
||||||
|
/** node library: root node of the hierarchy part by ID */
|
||||||
|
typedef std::map<std::string, Collada::Node*> NodeLibrary;
|
||||||
|
NodeLibrary mNodeLibrary;
|
||||||
|
|
||||||
|
/** Image library: stores texture properties by ID */
|
||||||
|
typedef std::map<std::string, Collada::Image> ImageLibrary;
|
||||||
|
ImageLibrary mImageLibrary;
|
||||||
|
|
||||||
|
/** Effect library: surface attributes by ID */
|
||||||
|
typedef std::map<std::string, Collada::Effect> EffectLibrary;
|
||||||
|
EffectLibrary mEffectLibrary;
|
||||||
|
|
||||||
|
/** Material library: surface material by ID */
|
||||||
|
typedef std::map<std::string, Collada::Material> MaterialLibrary;
|
||||||
|
MaterialLibrary mMaterialLibrary;
|
||||||
|
|
||||||
|
/** Light library: surface light by ID */
|
||||||
|
typedef std::map<std::string, Collada::Light> LightLibrary;
|
||||||
|
LightLibrary mLightLibrary;
|
||||||
|
|
||||||
|
/** Camera library: surface material by ID */
|
||||||
|
typedef std::map<std::string, Collada::Camera> CameraLibrary;
|
||||||
|
CameraLibrary mCameraLibrary;
|
||||||
|
|
||||||
|
/** Controller library: joint controllers by ID */
|
||||||
|
typedef std::map<std::string, Collada::Controller> ControllerLibrary;
|
||||||
|
ControllerLibrary mControllerLibrary;
|
||||||
|
|
||||||
|
/** Pointer to the root node. Don't delete, it just points to one of
|
||||||
|
the nodes in the node library. */
|
||||||
|
Collada::Node* mRootNode;
|
||||||
|
|
||||||
|
/** Root animation container */
|
||||||
|
Collada::Animation mAnims;
|
||||||
|
|
||||||
|
/** Size unit: how large compared to a meter */
|
||||||
|
float mUnitSize;
|
||||||
|
|
||||||
|
/** Which is the up vector */
|
||||||
|
enum { UP_X, UP_Y, UP_Z } mUpDirection;
|
||||||
|
|
||||||
|
/** Collada file format version */
|
||||||
|
Collada::FormatVersion mFormat;
|
||||||
|
};
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
// Check for element match
|
||||||
|
inline bool ColladaParser::IsElement( const char* pName) const
|
||||||
|
{
|
||||||
|
ai_assert( mReader->getNodeType() == irr::io::EXN_ELEMENT);
|
||||||
|
return ::strcmp( mReader->getNodeName(), pName) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
// Finds the item in the given library by its reference, throws if not found
|
||||||
|
template <typename Type>
|
||||||
|
const Type& ColladaParser::ResolveLibraryReference( const std::map<std::string, Type>& pLibrary, const std::string& pURL) const
|
||||||
|
{
|
||||||
|
typename std::map<std::string, Type>::const_iterator it = pLibrary.find( pURL);
|
||||||
|
if( it == pLibrary.end())
|
||||||
|
ThrowException( boost::str( boost::format( "Unable to resolve library reference \"%s\".") % pURL));
|
||||||
|
return it->second;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // end of namespace Assimp
|
||||||
|
|
||||||
|
#endif // AI_COLLADAPARSER_H_INC
|
File diff suppressed because it is too large
Load Diff
|
@ -47,6 +47,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#ifndef ASSIMP_BUILD_NO_COLLADA_IMPORTER
|
#ifndef ASSIMP_BUILD_NO_COLLADA_IMPORTER
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
#include <stdarg.h>
|
||||||
#include "ColladaParser.h"
|
#include "ColladaParser.h"
|
||||||
#include "fast_atof.h"
|
#include "fast_atof.h"
|
||||||
#include "ParsingUtils.h"
|
#include "ParsingUtils.h"
|
||||||
|
@ -1998,7 +1999,8 @@ void ColladaParser::ReadIndexData( Mesh* pMesh)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ASSIMP_BUILD_DEBUG
|
#ifdef ASSIMP_BUILD_DEBUG
|
||||||
if (primType != Prim_TriFans && primType != Prim_TriStrips) {
|
if (primType != Prim_TriFans && primType != Prim_TriStrips &&
|
||||||
|
primType != Prim_Lines) { // this is ONLY to workaround a bug in SketchUp 15.3.331 where it writes the wrong 'count' when it writes out the 'lines'.
|
||||||
ai_assert(actualPrimitives == numPrimitives);
|
ai_assert(actualPrimitives == numPrimitives);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -2107,13 +2109,19 @@ size_t ColladaParser::ReadPrimitives( Mesh* pMesh, std::vector<InputChannel>& pP
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// complain if the index count doesn't fit
|
// complain if the index count doesn't fit
|
||||||
if( expectedPointCount > 0 && indices.size() != expectedPointCount * numOffsets)
|
if( expectedPointCount > 0 && indices.size() != expectedPointCount * numOffsets) {
|
||||||
ThrowException( "Expected different index count in <p> element.");
|
if (pPrimType == Prim_Lines) {
|
||||||
else if( expectedPointCount == 0 && (indices.size() % numOffsets) != 0)
|
// HACK: We just fix this number since SketchUp 15.3.331 writes the wrong 'count' for 'lines'
|
||||||
ThrowException( "Expected different index count in <p> element.");
|
ReportWarning( "Expected different index count in <p> element, %d instead of %d.", indices.size(), expectedPointCount * numOffsets);
|
||||||
|
pNumPrimitives = (indices.size() / numOffsets) / 2;
|
||||||
|
} else
|
||||||
|
ThrowException( "Expected different index count in <p> element.");
|
||||||
|
|
||||||
// find the data for all sources
|
} else if( expectedPointCount == 0 && (indices.size() % numOffsets) != 0)
|
||||||
|
ThrowException( "Expected different index count in <p> element.");
|
||||||
|
|
||||||
|
// find the data for all sources
|
||||||
for( std::vector<InputChannel>::iterator it = pMesh->mPerVertexData.begin(); it != pMesh->mPerVertexData.end(); ++it)
|
for( std::vector<InputChannel>::iterator it = pMesh->mPerVertexData.begin(); it != pMesh->mPerVertexData.end(); ++it)
|
||||||
{
|
{
|
||||||
InputChannel& input = *it;
|
InputChannel& input = *it;
|
||||||
|
@ -2712,6 +2720,21 @@ AI_WONT_RETURN void ColladaParser::ThrowException( const std::string& pError) co
|
||||||
{
|
{
|
||||||
throw DeadlyImportError( boost::str( boost::format( "Collada: %s - %s") % mFileName % pError));
|
throw DeadlyImportError( boost::str( boost::format( "Collada: %s - %s") % mFileName % pError));
|
||||||
}
|
}
|
||||||
|
void ColladaParser::ReportWarning(const char* msg,...)
|
||||||
|
{
|
||||||
|
ai_assert(NULL != msg);
|
||||||
|
|
||||||
|
va_list args;
|
||||||
|
va_start(args,msg);
|
||||||
|
|
||||||
|
char szBuffer[3000];
|
||||||
|
const int iLen = vsprintf(szBuffer,msg,args);
|
||||||
|
ai_assert(iLen > 0);
|
||||||
|
|
||||||
|
va_end(args);
|
||||||
|
DefaultLogger::get()->warn("Validation warning: " + std::string(szBuffer,iLen));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Skips all data until the end node of the current element
|
// Skips all data until the end node of the current element
|
||||||
|
|
|
@ -1,42 +1,42 @@
|
||||||
/*
|
/*
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2015, assimp team
|
Copyright (c) 2006-2015, assimp team
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
with or without modification, are permitted provided that the
|
with or without modification, are permitted provided that the
|
||||||
following conditions are met:
|
following conditions are met:
|
||||||
|
|
||||||
* Redistributions of source code must retain the above
|
* Redistributions of source code must retain the above
|
||||||
copyright notice, this list of conditions and the
|
copyright notice, this list of conditions and the
|
||||||
following disclaimer.
|
following disclaimer.
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above
|
* Redistributions in binary form must reproduce the above
|
||||||
copyright notice, this list of conditions and the
|
copyright notice, this list of conditions and the
|
||||||
following disclaimer in the documentation and/or other
|
following disclaimer in the documentation and/or other
|
||||||
materials provided with the distribution.
|
materials provided with the distribution.
|
||||||
|
|
||||||
* Neither the name of the assimp team, nor the names of its
|
* Neither the name of the assimp team, nor the names of its
|
||||||
contributors may be used to endorse or promote products
|
contributors may be used to endorse or promote products
|
||||||
derived from this software without specific prior
|
derived from this software without specific prior
|
||||||
written permission of the assimp team.
|
written permission of the assimp team.
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** @file ColladaParser.h
|
/** @file ColladaParser.h
|
||||||
* @brief Defines the parser helper class for the collada loader
|
* @brief Defines the parser helper class for the collada loader
|
||||||
|
@ -53,299 +53,300 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
namespace Assimp
|
namespace Assimp
|
||||||
{
|
{
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------
|
||||||
/** Parser helper class for the Collada loader.
|
/** Parser helper class for the Collada loader.
|
||||||
*
|
*
|
||||||
* Does all the XML reading and builds internal data structures from it,
|
* Does all the XML reading and builds internal data structures from it,
|
||||||
* but leaves the resolving of all the references to the loader.
|
* but leaves the resolving of all the references to the loader.
|
||||||
*/
|
|
||||||
class ColladaParser
|
|
||||||
{
|
|
||||||
friend class ColladaLoader;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
/** Constructor from XML file */
|
|
||||||
ColladaParser( IOSystem* pIOHandler, const std::string& pFile);
|
|
||||||
|
|
||||||
/** Destructor */
|
|
||||||
~ColladaParser();
|
|
||||||
|
|
||||||
/** Reads the contents of the file */
|
|
||||||
void ReadContents();
|
|
||||||
|
|
||||||
/** Reads the structure of the file */
|
|
||||||
void ReadStructure();
|
|
||||||
|
|
||||||
/** Reads asset informations such as coordinate system informations and legal blah */
|
|
||||||
void ReadAssetInfo();
|
|
||||||
|
|
||||||
/** Reads the animation library */
|
|
||||||
void ReadAnimationLibrary();
|
|
||||||
|
|
||||||
/** Reads an animation into the given parent structure */
|
|
||||||
void ReadAnimation( Collada::Animation* pParent);
|
|
||||||
|
|
||||||
/** Reads an animation sampler into the given anim channel */
|
|
||||||
void ReadAnimationSampler( Collada::AnimationChannel& pChannel);
|
|
||||||
|
|
||||||
/** Reads the skeleton controller library */
|
|
||||||
void ReadControllerLibrary();
|
|
||||||
|
|
||||||
/** Reads a controller into the given mesh structure */
|
|
||||||
void ReadController( Collada::Controller& pController);
|
|
||||||
|
|
||||||
/** Reads the joint definitions for the given controller */
|
|
||||||
void ReadControllerJoints( Collada::Controller& pController);
|
|
||||||
|
|
||||||
/** Reads the joint weights for the given controller */
|
|
||||||
void ReadControllerWeights( Collada::Controller& pController);
|
|
||||||
|
|
||||||
/** Reads the image library contents */
|
|
||||||
void ReadImageLibrary();
|
|
||||||
|
|
||||||
/** Reads an image entry into the given image */
|
|
||||||
void ReadImage( Collada::Image& pImage);
|
|
||||||
|
|
||||||
/** Reads the material library */
|
|
||||||
void ReadMaterialLibrary();
|
|
||||||
|
|
||||||
/** Reads a material entry into the given material */
|
|
||||||
void ReadMaterial( Collada::Material& pMaterial);
|
|
||||||
|
|
||||||
/** Reads the camera library */
|
|
||||||
void ReadCameraLibrary();
|
|
||||||
|
|
||||||
/** Reads a camera entry into the given camera */
|
|
||||||
void ReadCamera( Collada::Camera& pCamera);
|
|
||||||
|
|
||||||
/** Reads the light library */
|
|
||||||
void ReadLightLibrary();
|
|
||||||
|
|
||||||
/** Reads a light entry into the given light */
|
|
||||||
void ReadLight( Collada::Light& pLight);
|
|
||||||
|
|
||||||
/** Reads the effect library */
|
|
||||||
void ReadEffectLibrary();
|
|
||||||
|
|
||||||
/** Reads an effect entry into the given effect*/
|
|
||||||
void ReadEffect( Collada::Effect& pEffect);
|
|
||||||
|
|
||||||
/** Reads an COMMON effect profile */
|
|
||||||
void ReadEffectProfileCommon( Collada::Effect& pEffect);
|
|
||||||
|
|
||||||
/** Read sampler properties */
|
|
||||||
void ReadSamplerProperties( Collada::Sampler& pSampler);
|
|
||||||
|
|
||||||
/** Reads an effect entry containing a color or a texture defining that color */
|
|
||||||
void ReadEffectColor( aiColor4D& pColor, Collada::Sampler& pSampler);
|
|
||||||
|
|
||||||
/** Reads an effect entry containing a float */
|
|
||||||
void ReadEffectFloat( float& pFloat);
|
|
||||||
|
|
||||||
/** Reads an effect parameter specification of any kind */
|
|
||||||
void ReadEffectParam( Collada::EffectParam& pParam);
|
|
||||||
|
|
||||||
/** Reads the geometry library contents */
|
|
||||||
void ReadGeometryLibrary();
|
|
||||||
|
|
||||||
/** Reads a geometry from the geometry library. */
|
|
||||||
void ReadGeometry( Collada::Mesh* pMesh);
|
|
||||||
|
|
||||||
/** Reads a mesh from the geometry library */
|
|
||||||
void ReadMesh( Collada::Mesh* pMesh);
|
|
||||||
|
|
||||||
/** Reads a source element - a combination of raw data and an accessor defining
|
|
||||||
* things that should not be redefinable. Yes, that's another rant.
|
|
||||||
*/
|
*/
|
||||||
void ReadSource();
|
class ColladaParser
|
||||||
|
{
|
||||||
|
friend class ColladaLoader;
|
||||||
|
|
||||||
/** Reads a data array holding a number of elements, and stores it in the global library.
|
protected:
|
||||||
* Currently supported are array of floats and arrays of strings.
|
/** Constructor from XML file */
|
||||||
*/
|
ColladaParser( IOSystem* pIOHandler, const std::string& pFile);
|
||||||
void ReadDataArray();
|
|
||||||
|
|
||||||
/** Reads an accessor and stores it in the global library under the given ID -
|
/** Destructor */
|
||||||
* accessors use the ID of the parent <source> element
|
~ColladaParser();
|
||||||
*/
|
|
||||||
void ReadAccessor( const std::string& pID);
|
|
||||||
|
|
||||||
/** Reads input declarations of per-vertex mesh data into the given mesh */
|
/** Reads the contents of the file */
|
||||||
void ReadVertexData( Collada::Mesh* pMesh);
|
void ReadContents();
|
||||||
|
|
||||||
/** Reads input declarations of per-index mesh data into the given mesh */
|
/** Reads the structure of the file */
|
||||||
void ReadIndexData( Collada::Mesh* pMesh);
|
void ReadStructure();
|
||||||
|
|
||||||
/** Reads a single input channel element and stores it in the given array, if valid */
|
/** Reads asset informations such as coordinate system informations and legal blah */
|
||||||
void ReadInputChannel( std::vector<Collada::InputChannel>& poChannels);
|
void ReadAssetInfo();
|
||||||
|
|
||||||
/** Reads a <p> primitive index list and assembles the mesh data into the given mesh */
|
/** Reads the animation library */
|
||||||
size_t ReadPrimitives( Collada::Mesh* pMesh, std::vector<Collada::InputChannel>& pPerIndexChannels,
|
void ReadAnimationLibrary();
|
||||||
size_t pNumPrimitives, const std::vector<size_t>& pVCount, Collada::PrimitiveType pPrimType);
|
|
||||||
|
|
||||||
/** Copies the data for a single primitive into the mesh, based on the InputChannels */
|
/** Reads an animation into the given parent structure */
|
||||||
void CopyVertex(size_t currentVertex, size_t numOffsets, size_t numPoints, size_t perVertexOffset,
|
void ReadAnimation( Collada::Animation* pParent);
|
||||||
Collada::Mesh* pMesh, std::vector<Collada::InputChannel>& pPerIndexChannels,
|
|
||||||
size_t currentPrimitive, const std::vector<size_t>& indices);
|
|
||||||
|
|
||||||
/** Reads one triangle of a tristrip into the mesh */
|
/** Reads an animation sampler into the given anim channel */
|
||||||
void ReadPrimTriStrips(size_t numOffsets, size_t perVertexOffset, Collada::Mesh* pMesh,
|
void ReadAnimationSampler( Collada::AnimationChannel& pChannel);
|
||||||
std::vector<Collada::InputChannel>& pPerIndexChannels, size_t currentPrimitive, const std::vector<size_t>& indices);
|
|
||||||
|
|
||||||
/** Extracts a single object from an input channel and stores it in the appropriate mesh data array */
|
/** Reads the skeleton controller library */
|
||||||
void ExtractDataObjectFromChannel( const Collada::InputChannel& pInput, size_t pLocalIndex, Collada::Mesh* pMesh);
|
void ReadControllerLibrary();
|
||||||
|
|
||||||
/** Reads the library of node hierarchies and scene parts */
|
/** Reads a controller into the given mesh structure */
|
||||||
void ReadSceneLibrary();
|
void ReadController( Collada::Controller& pController);
|
||||||
|
|
||||||
/** Reads a scene node's contents including children and stores it in the given node */
|
/** Reads the joint definitions for the given controller */
|
||||||
void ReadSceneNode( Collada::Node* pNode);
|
void ReadControllerJoints( Collada::Controller& pController);
|
||||||
|
|
||||||
/** Reads a node transformation entry of the given type and adds it to the given node's transformation list. */
|
/** Reads the joint weights for the given controller */
|
||||||
void ReadNodeTransformation( Collada::Node* pNode, Collada::TransformType pType);
|
void ReadControllerWeights( Collada::Controller& pController);
|
||||||
|
|
||||||
/** Reads a mesh reference in a node and adds it to the node's mesh list */
|
/** Reads the image library contents */
|
||||||
void ReadNodeGeometry( Collada::Node* pNode);
|
void ReadImageLibrary();
|
||||||
|
|
||||||
/** Reads the collada scene */
|
/** Reads an image entry into the given image */
|
||||||
void ReadScene();
|
void ReadImage( Collada::Image& pImage);
|
||||||
|
|
||||||
// Processes bind_vertex_input and bind elements
|
/** Reads the material library */
|
||||||
void ReadMaterialVertexInputBinding( Collada::SemanticMappingTable& tbl);
|
void ReadMaterialLibrary();
|
||||||
|
|
||||||
protected:
|
/** Reads a material entry into the given material */
|
||||||
/** Aborts the file reading with an exception */
|
void ReadMaterial( Collada::Material& pMaterial);
|
||||||
AI_WONT_RETURN void ThrowException( const std::string& pError) const AI_WONT_RETURN_SUFFIX;
|
|
||||||
|
|
||||||
/** Skips all data until the end node of the current element */
|
/** Reads the camera library */
|
||||||
void SkipElement();
|
void ReadCameraLibrary();
|
||||||
|
|
||||||
/** Skips all data until the end node of the given element */
|
/** Reads a camera entry into the given camera */
|
||||||
void SkipElement( const char* pElement);
|
void ReadCamera( Collada::Camera& pCamera);
|
||||||
|
|
||||||
/** Compares the current xml element name to the given string and returns true if equal */
|
/** Reads the light library */
|
||||||
bool IsElement( const char* pName) const;
|
void ReadLightLibrary();
|
||||||
|
|
||||||
/** Tests for the opening tag of the given element, throws an exception if not found */
|
/** Reads a light entry into the given light */
|
||||||
void TestOpening( const char* pName);
|
void ReadLight( Collada::Light& pLight);
|
||||||
|
|
||||||
/** Tests for the closing tag of the given element, throws an exception if not found */
|
/** Reads the effect library */
|
||||||
void TestClosing( const char* pName);
|
void ReadEffectLibrary();
|
||||||
|
|
||||||
/** Checks the present element for the presence of the attribute, returns its index
|
/** Reads an effect entry into the given effect*/
|
||||||
or throws an exception if not found */
|
void ReadEffect( Collada::Effect& pEffect);
|
||||||
int GetAttribute( const char* pAttr) const;
|
|
||||||
|
|
||||||
/** Returns the index of the named attribute or -1 if not found. Does not throw,
|
/** Reads an COMMON effect profile */
|
||||||
therefore useful for optional attributes */
|
void ReadEffectProfileCommon( Collada::Effect& pEffect);
|
||||||
int TestAttribute( const char* pAttr) const;
|
|
||||||
|
|
||||||
/** Reads the text contents of an element, throws an exception if not given.
|
/** Read sampler properties */
|
||||||
Skips leading whitespace. */
|
void ReadSamplerProperties( Collada::Sampler& pSampler);
|
||||||
const char* GetTextContent();
|
|
||||||
|
|
||||||
/** Reads the text contents of an element, returns NULL if not given.
|
/** Reads an effect entry containing a color or a texture defining that color */
|
||||||
Skips leading whitespace. */
|
void ReadEffectColor( aiColor4D& pColor, Collada::Sampler& pSampler);
|
||||||
const char* TestTextContent();
|
|
||||||
|
|
||||||
/** Reads a single bool from current text content */
|
/** Reads an effect entry containing a float */
|
||||||
bool ReadBoolFromTextContent();
|
void ReadEffectFloat( float& pFloat);
|
||||||
|
|
||||||
/** Reads a single float from current text content */
|
/** Reads an effect parameter specification of any kind */
|
||||||
float ReadFloatFromTextContent();
|
void ReadEffectParam( Collada::EffectParam& pParam);
|
||||||
|
|
||||||
/** Calculates the resulting transformation from all the given transform steps */
|
/** Reads the geometry library contents */
|
||||||
aiMatrix4x4 CalculateResultTransform( const std::vector<Collada::Transform>& pTransforms) const;
|
void ReadGeometryLibrary();
|
||||||
|
|
||||||
/** Determines the input data type for the given semantic string */
|
/** Reads a geometry from the geometry library. */
|
||||||
Collada::InputType GetTypeForSemantic( const std::string& pSemantic);
|
void ReadGeometry( Collada::Mesh* pMesh);
|
||||||
|
|
||||||
/** Finds the item in the given library by its reference, throws if not found */
|
/** Reads a mesh from the geometry library */
|
||||||
template <typename Type> const Type& ResolveLibraryReference(
|
void ReadMesh( Collada::Mesh* pMesh);
|
||||||
const std::map<std::string, Type>& pLibrary, const std::string& pURL) const;
|
|
||||||
|
|
||||||
protected:
|
/** Reads a source element - a combination of raw data and an accessor defining
|
||||||
/** Filename, for a verbose error message */
|
* things that should not be redefinable. Yes, that's another rant.
|
||||||
std::string mFileName;
|
*/
|
||||||
|
void ReadSource();
|
||||||
|
|
||||||
/** XML reader, member for everyday use */
|
/** Reads a data array holding a number of elements, and stores it in the global library.
|
||||||
irr::io::IrrXMLReader* mReader;
|
* Currently supported are array of floats and arrays of strings.
|
||||||
|
*/
|
||||||
|
void ReadDataArray();
|
||||||
|
|
||||||
/** All data arrays found in the file by ID. Might be referred to by actually
|
/** Reads an accessor and stores it in the global library under the given ID -
|
||||||
everyone. Collada, you are a steaming pile of indirection. */
|
* accessors use the ID of the parent <source> element
|
||||||
typedef std::map<std::string, Collada::Data> DataLibrary;
|
*/
|
||||||
DataLibrary mDataLibrary;
|
void ReadAccessor( const std::string& pID);
|
||||||
|
|
||||||
/** Same for accessors which define how the data in a data array is accessed. */
|
/** Reads input declarations of per-vertex mesh data into the given mesh */
|
||||||
typedef std::map<std::string, Collada::Accessor> AccessorLibrary;
|
void ReadVertexData( Collada::Mesh* pMesh);
|
||||||
AccessorLibrary mAccessorLibrary;
|
|
||||||
|
|
||||||
/** Mesh library: mesh by ID */
|
/** Reads input declarations of per-index mesh data into the given mesh */
|
||||||
typedef std::map<std::string, Collada::Mesh*> MeshLibrary;
|
void ReadIndexData( Collada::Mesh* pMesh);
|
||||||
MeshLibrary mMeshLibrary;
|
|
||||||
|
|
||||||
/** node library: root node of the hierarchy part by ID */
|
/** Reads a single input channel element and stores it in the given array, if valid */
|
||||||
typedef std::map<std::string, Collada::Node*> NodeLibrary;
|
void ReadInputChannel( std::vector<Collada::InputChannel>& poChannels);
|
||||||
NodeLibrary mNodeLibrary;
|
|
||||||
|
|
||||||
/** Image library: stores texture properties by ID */
|
/** Reads a <p> primitive index list and assembles the mesh data into the given mesh */
|
||||||
typedef std::map<std::string, Collada::Image> ImageLibrary;
|
size_t ReadPrimitives( Collada::Mesh* pMesh, std::vector<Collada::InputChannel>& pPerIndexChannels,
|
||||||
ImageLibrary mImageLibrary;
|
size_t pNumPrimitives, const std::vector<size_t>& pVCount, Collada::PrimitiveType pPrimType);
|
||||||
|
|
||||||
/** Effect library: surface attributes by ID */
|
/** Copies the data for a single primitive into the mesh, based on the InputChannels */
|
||||||
typedef std::map<std::string, Collada::Effect> EffectLibrary;
|
void CopyVertex(size_t currentVertex, size_t numOffsets, size_t numPoints, size_t perVertexOffset,
|
||||||
EffectLibrary mEffectLibrary;
|
Collada::Mesh* pMesh, std::vector<Collada::InputChannel>& pPerIndexChannels,
|
||||||
|
size_t currentPrimitive, const std::vector<size_t>& indices);
|
||||||
|
|
||||||
/** Material library: surface material by ID */
|
/** Reads one triangle of a tristrip into the mesh */
|
||||||
typedef std::map<std::string, Collada::Material> MaterialLibrary;
|
void ReadPrimTriStrips(size_t numOffsets, size_t perVertexOffset, Collada::Mesh* pMesh,
|
||||||
MaterialLibrary mMaterialLibrary;
|
std::vector<Collada::InputChannel>& pPerIndexChannels, size_t currentPrimitive, const std::vector<size_t>& indices);
|
||||||
|
|
||||||
/** Light library: surface light by ID */
|
/** Extracts a single object from an input channel and stores it in the appropriate mesh data array */
|
||||||
typedef std::map<std::string, Collada::Light> LightLibrary;
|
void ExtractDataObjectFromChannel( const Collada::InputChannel& pInput, size_t pLocalIndex, Collada::Mesh* pMesh);
|
||||||
LightLibrary mLightLibrary;
|
|
||||||
|
|
||||||
/** Camera library: surface material by ID */
|
/** Reads the library of node hierarchies and scene parts */
|
||||||
typedef std::map<std::string, Collada::Camera> CameraLibrary;
|
void ReadSceneLibrary();
|
||||||
CameraLibrary mCameraLibrary;
|
|
||||||
|
|
||||||
/** Controller library: joint controllers by ID */
|
/** Reads a scene node's contents including children and stores it in the given node */
|
||||||
typedef std::map<std::string, Collada::Controller> ControllerLibrary;
|
void ReadSceneNode( Collada::Node* pNode);
|
||||||
ControllerLibrary mControllerLibrary;
|
|
||||||
|
|
||||||
/** Pointer to the root node. Don't delete, it just points to one of
|
/** Reads a node transformation entry of the given type and adds it to the given node's transformation list. */
|
||||||
the nodes in the node library. */
|
void ReadNodeTransformation( Collada::Node* pNode, Collada::TransformType pType);
|
||||||
Collada::Node* mRootNode;
|
|
||||||
|
|
||||||
/** Root animation container */
|
/** Reads a mesh reference in a node and adds it to the node's mesh list */
|
||||||
Collada::Animation mAnims;
|
void ReadNodeGeometry( Collada::Node* pNode);
|
||||||
|
|
||||||
/** Size unit: how large compared to a meter */
|
/** Reads the collada scene */
|
||||||
float mUnitSize;
|
void ReadScene();
|
||||||
|
|
||||||
/** Which is the up vector */
|
// Processes bind_vertex_input and bind elements
|
||||||
enum { UP_X, UP_Y, UP_Z } mUpDirection;
|
void ReadMaterialVertexInputBinding( Collada::SemanticMappingTable& tbl);
|
||||||
|
|
||||||
/** Collada file format version */
|
protected:
|
||||||
Collada::FormatVersion mFormat;
|
/** Aborts the file reading with an exception */
|
||||||
};
|
AI_WONT_RETURN void ThrowException( const std::string& pError) const AI_WONT_RETURN_SUFFIX;
|
||||||
|
void ReportWarning(const char* msg,...);
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
/** Skips all data until the end node of the current element */
|
||||||
// Check for element match
|
void SkipElement();
|
||||||
inline bool ColladaParser::IsElement( const char* pName) const
|
|
||||||
{
|
|
||||||
ai_assert( mReader->getNodeType() == irr::io::EXN_ELEMENT);
|
|
||||||
return ::strcmp( mReader->getNodeName(), pName) == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
/** Skips all data until the end node of the given element */
|
||||||
// Finds the item in the given library by its reference, throws if not found
|
void SkipElement( const char* pElement);
|
||||||
template <typename Type>
|
|
||||||
const Type& ColladaParser::ResolveLibraryReference( const std::map<std::string, Type>& pLibrary, const std::string& pURL) const
|
/** Compares the current xml element name to the given string and returns true if equal */
|
||||||
{
|
bool IsElement( const char* pName) const;
|
||||||
typename std::map<std::string, Type>::const_iterator it = pLibrary.find( pURL);
|
|
||||||
if( it == pLibrary.end())
|
/** Tests for the opening tag of the given element, throws an exception if not found */
|
||||||
ThrowException( boost::str( boost::format( "Unable to resolve library reference \"%s\".") % pURL));
|
void TestOpening( const char* pName);
|
||||||
return it->second;
|
|
||||||
}
|
/** Tests for the closing tag of the given element, throws an exception if not found */
|
||||||
|
void TestClosing( const char* pName);
|
||||||
|
|
||||||
|
/** Checks the present element for the presence of the attribute, returns its index
|
||||||
|
or throws an exception if not found */
|
||||||
|
int GetAttribute( const char* pAttr) const;
|
||||||
|
|
||||||
|
/** Returns the index of the named attribute or -1 if not found. Does not throw,
|
||||||
|
therefore useful for optional attributes */
|
||||||
|
int TestAttribute( const char* pAttr) const;
|
||||||
|
|
||||||
|
/** Reads the text contents of an element, throws an exception if not given.
|
||||||
|
Skips leading whitespace. */
|
||||||
|
const char* GetTextContent();
|
||||||
|
|
||||||
|
/** Reads the text contents of an element, returns NULL if not given.
|
||||||
|
Skips leading whitespace. */
|
||||||
|
const char* TestTextContent();
|
||||||
|
|
||||||
|
/** Reads a single bool from current text content */
|
||||||
|
bool ReadBoolFromTextContent();
|
||||||
|
|
||||||
|
/** Reads a single float from current text content */
|
||||||
|
float ReadFloatFromTextContent();
|
||||||
|
|
||||||
|
/** Calculates the resulting transformation from all the given transform steps */
|
||||||
|
aiMatrix4x4 CalculateResultTransform( const std::vector<Collada::Transform>& pTransforms) const;
|
||||||
|
|
||||||
|
/** Determines the input data type for the given semantic string */
|
||||||
|
Collada::InputType GetTypeForSemantic( const std::string& pSemantic);
|
||||||
|
|
||||||
|
/** Finds the item in the given library by its reference, throws if not found */
|
||||||
|
template <typename Type> const Type& ResolveLibraryReference(
|
||||||
|
const std::map<std::string, Type>& pLibrary, const std::string& pURL) const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
/** Filename, for a verbose error message */
|
||||||
|
std::string mFileName;
|
||||||
|
|
||||||
|
/** XML reader, member for everyday use */
|
||||||
|
irr::io::IrrXMLReader* mReader;
|
||||||
|
|
||||||
|
/** All data arrays found in the file by ID. Might be referred to by actually
|
||||||
|
everyone. Collada, you are a steaming pile of indirection. */
|
||||||
|
typedef std::map<std::string, Collada::Data> DataLibrary;
|
||||||
|
DataLibrary mDataLibrary;
|
||||||
|
|
||||||
|
/** Same for accessors which define how the data in a data array is accessed. */
|
||||||
|
typedef std::map<std::string, Collada::Accessor> AccessorLibrary;
|
||||||
|
AccessorLibrary mAccessorLibrary;
|
||||||
|
|
||||||
|
/** Mesh library: mesh by ID */
|
||||||
|
typedef std::map<std::string, Collada::Mesh*> MeshLibrary;
|
||||||
|
MeshLibrary mMeshLibrary;
|
||||||
|
|
||||||
|
/** node library: root node of the hierarchy part by ID */
|
||||||
|
typedef std::map<std::string, Collada::Node*> NodeLibrary;
|
||||||
|
NodeLibrary mNodeLibrary;
|
||||||
|
|
||||||
|
/** Image library: stores texture properties by ID */
|
||||||
|
typedef std::map<std::string, Collada::Image> ImageLibrary;
|
||||||
|
ImageLibrary mImageLibrary;
|
||||||
|
|
||||||
|
/** Effect library: surface attributes by ID */
|
||||||
|
typedef std::map<std::string, Collada::Effect> EffectLibrary;
|
||||||
|
EffectLibrary mEffectLibrary;
|
||||||
|
|
||||||
|
/** Material library: surface material by ID */
|
||||||
|
typedef std::map<std::string, Collada::Material> MaterialLibrary;
|
||||||
|
MaterialLibrary mMaterialLibrary;
|
||||||
|
|
||||||
|
/** Light library: surface light by ID */
|
||||||
|
typedef std::map<std::string, Collada::Light> LightLibrary;
|
||||||
|
LightLibrary mLightLibrary;
|
||||||
|
|
||||||
|
/** Camera library: surface material by ID */
|
||||||
|
typedef std::map<std::string, Collada::Camera> CameraLibrary;
|
||||||
|
CameraLibrary mCameraLibrary;
|
||||||
|
|
||||||
|
/** Controller library: joint controllers by ID */
|
||||||
|
typedef std::map<std::string, Collada::Controller> ControllerLibrary;
|
||||||
|
ControllerLibrary mControllerLibrary;
|
||||||
|
|
||||||
|
/** Pointer to the root node. Don't delete, it just points to one of
|
||||||
|
the nodes in the node library. */
|
||||||
|
Collada::Node* mRootNode;
|
||||||
|
|
||||||
|
/** Root animation container */
|
||||||
|
Collada::Animation mAnims;
|
||||||
|
|
||||||
|
/** Size unit: how large compared to a meter */
|
||||||
|
float mUnitSize;
|
||||||
|
|
||||||
|
/** Which is the up vector */
|
||||||
|
enum { UP_X, UP_Y, UP_Z } mUpDirection;
|
||||||
|
|
||||||
|
/** Collada file format version */
|
||||||
|
Collada::FormatVersion mFormat;
|
||||||
|
};
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
// Check for element match
|
||||||
|
inline bool ColladaParser::IsElement( const char* pName) const
|
||||||
|
{
|
||||||
|
ai_assert( mReader->getNodeType() == irr::io::EXN_ELEMENT);
|
||||||
|
return ::strcmp( mReader->getNodeName(), pName) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
// Finds the item in the given library by its reference, throws if not found
|
||||||
|
template <typename Type>
|
||||||
|
const Type& ColladaParser::ResolveLibraryReference( const std::map<std::string, Type>& pLibrary, const std::string& pURL) const
|
||||||
|
{
|
||||||
|
typename std::map<std::string, Type>::const_iterator it = pLibrary.find( pURL);
|
||||||
|
if( it == pLibrary.end())
|
||||||
|
ThrowException( boost::str( boost::format( "Unable to resolve library reference \"%s\".") % pURL));
|
||||||
|
return it->second;
|
||||||
|
}
|
||||||
|
|
||||||
} // end of namespace Assimp
|
} // end of namespace Assimp
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,7 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Workspace
|
||||||
|
version = "1.0">
|
||||||
|
<FileRef
|
||||||
|
location = "self:Assimp.xcodeproj">
|
||||||
|
</FileRef>
|
||||||
|
</Workspace>
|
|
@ -0,0 +1,80 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Scheme
|
||||||
|
LastUpgradeVersion = "0700"
|
||||||
|
version = "1.3">
|
||||||
|
<BuildAction
|
||||||
|
parallelizeBuildables = "YES"
|
||||||
|
buildImplicitDependencies = "YES">
|
||||||
|
<BuildActionEntries>
|
||||||
|
<BuildActionEntry
|
||||||
|
buildForTesting = "YES"
|
||||||
|
buildForRunning = "YES"
|
||||||
|
buildForProfiling = "YES"
|
||||||
|
buildForArchiving = "YES"
|
||||||
|
buildForAnalyzing = "YES">
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "7F79227F1AB43AC3005A8E5D"
|
||||||
|
BuildableName = "libassimp.a"
|
||||||
|
BlueprintName = "assimp"
|
||||||
|
ReferencedContainer = "container:workspaces/xcode6/Assimp.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</BuildActionEntry>
|
||||||
|
</BuildActionEntries>
|
||||||
|
</BuildAction>
|
||||||
|
<TestAction
|
||||||
|
buildConfiguration = "Debug"
|
||||||
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||||
|
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||||
|
<Testables>
|
||||||
|
</Testables>
|
||||||
|
<AdditionalOptions>
|
||||||
|
</AdditionalOptions>
|
||||||
|
</TestAction>
|
||||||
|
<LaunchAction
|
||||||
|
buildConfiguration = "Debug"
|
||||||
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||||
|
launchStyle = "0"
|
||||||
|
useCustomWorkingDirectory = "NO"
|
||||||
|
ignoresPersistentStateOnLaunch = "NO"
|
||||||
|
debugDocumentVersioning = "YES"
|
||||||
|
debugServiceExtension = "internal"
|
||||||
|
allowLocationSimulation = "YES">
|
||||||
|
<MacroExpansion>
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "7F79227F1AB43AC3005A8E5D"
|
||||||
|
BuildableName = "libassimp.a"
|
||||||
|
BlueprintName = "assimp"
|
||||||
|
ReferencedContainer = "container:workspaces/xcode6/Assimp.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</MacroExpansion>
|
||||||
|
<AdditionalOptions>
|
||||||
|
</AdditionalOptions>
|
||||||
|
</LaunchAction>
|
||||||
|
<ProfileAction
|
||||||
|
buildConfiguration = "Release"
|
||||||
|
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||||
|
savedToolIdentifier = ""
|
||||||
|
useCustomWorkingDirectory = "NO"
|
||||||
|
debugDocumentVersioning = "YES">
|
||||||
|
<MacroExpansion>
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "7F79227F1AB43AC3005A8E5D"
|
||||||
|
BuildableName = "libassimp.a"
|
||||||
|
BlueprintName = "assimp"
|
||||||
|
ReferencedContainer = "container:workspaces/xcode6/Assimp.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</MacroExpansion>
|
||||||
|
</ProfileAction>
|
||||||
|
<AnalyzeAction
|
||||||
|
buildConfiguration = "Debug">
|
||||||
|
</AnalyzeAction>
|
||||||
|
<ArchiveAction
|
||||||
|
buildConfiguration = "Release"
|
||||||
|
revealArchiveInOrganizer = "YES">
|
||||||
|
</ArchiveAction>
|
||||||
|
</Scheme>
|
Loading…
Reference in New Issue