2015-05-19 03:48:29 +00:00
|
|
|
/*
|
2015-07-27 02:16:01 +00:00
|
|
|
Open Asset Import Library (assimp)
|
|
|
|
----------------------------------------------------------------------
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2020-01-20 13:53:12 +00:00
|
|
|
Copyright (c) 2006-2020, assimp team
|
2018-01-28 18:42:05 +00:00
|
|
|
|
2017-05-09 17:57:36 +00:00
|
|
|
|
2015-07-27 02:16:01 +00:00
|
|
|
All rights reserved.
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2015-07-27 02:16:01 +00:00
|
|
|
Redistribution and use of this software in source and binary forms,
|
|
|
|
with or without modification, are permitted provided that the
|
|
|
|
following conditions are met:
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2015-07-27 02:16:01 +00:00
|
|
|
* Redistributions of source code must retain the above
|
|
|
|
copyright notice, this list of conditions and the
|
|
|
|
following disclaimer.
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2015-07-27 02:16:01 +00:00
|
|
|
* 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.
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2015-07-27 02:16:01 +00:00
|
|
|
* 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.
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2015-07-27 02:16:01 +00:00
|
|
|
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.
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2015-07-27 02:16:01 +00:00
|
|
|
----------------------------------------------------------------------
|
|
|
|
*/
|
2015-05-19 03:48:29 +00:00
|
|
|
|
|
|
|
/** @file ColladaParser.h
|
2015-05-19 03:52:10 +00:00
|
|
|
* @brief Defines the parser helper class for the collada loader
|
2015-05-19 03:48:29 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef AI_COLLADAPARSER_H_INC
|
|
|
|
#define AI_COLLADAPARSER_H_INC
|
|
|
|
|
|
|
|
#include "ColladaHelper.h"
|
2018-01-06 00:18:33 +00:00
|
|
|
#include <assimp/TinyFormatter.h>
|
2020-04-28 16:46:07 +00:00
|
|
|
#include <assimp/ai_assert.h>
|
|
|
|
#include <assimp/irrXMLWrapper.h>
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
namespace Assimp {
|
|
|
|
class ZipArchiveIOSystem;
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
// ------------------------------------------------------------------------------------------
|
|
|
|
/** Parser helper class for the Collada loader.
|
2015-07-27 02:16:01 +00:00
|
|
|
*
|
|
|
|
* Does all the XML reading and builds internal data structures from it,
|
|
|
|
* but leaves the resolving of all the references to the loader.
|
2015-05-19 03:57:13 +00:00
|
|
|
*/
|
2020-04-28 16:46:07 +00:00
|
|
|
class ColladaParser {
|
|
|
|
friend class ColladaLoader;
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** Converts a path read from a collada file to the usual representation */
|
|
|
|
static void UriDecodePath(aiString &ss);
|
2019-10-11 17:57:38 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
protected:
|
|
|
|
/** Map for generic metadata as aiString */
|
|
|
|
typedef std::map<std::string, aiString> StringMetaData;
|
2019-04-09 15:28:15 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** Constructor from XML file */
|
|
|
|
ColladaParser(IOSystem *pIOHandler, const std::string &pFile);
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** Destructor */
|
|
|
|
~ColladaParser();
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** Attempts to read the ZAE manifest and returns the DAE to open */
|
|
|
|
static std::string ReadZaeManifest(ZipArchiveIOSystem &zip_archive);
|
2019-07-12 10:29:35 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** Reads the contents of the file */
|
|
|
|
void ReadContents();
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** Reads the structure of the file */
|
|
|
|
void ReadStructure();
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** Reads asset information such as coordinate system information and legal blah */
|
|
|
|
void ReadAssetInfo();
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** Reads contributor information such as author and legal blah */
|
|
|
|
void ReadContributorInfo();
|
2019-04-09 15:28:15 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** Reads generic metadata into provided map and renames keys for Assimp */
|
|
|
|
void ReadMetaDataItem(StringMetaData &metadata);
|
2019-04-09 15:28:15 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** Reads the animation library */
|
|
|
|
void ReadAnimationLibrary();
|
2016-02-07 22:36:49 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** Reads the animation clip library */
|
|
|
|
void ReadAnimationClipLibrary();
|
2016-02-07 22:36:49 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** Unwrap controllers dependency hierarchy */
|
|
|
|
void PostProcessControllers();
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** Re-build animations from animation clip library, if present, otherwise combine single-channel animations */
|
|
|
|
void PostProcessRootAnimations();
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** Reads an animation into the given parent structure */
|
|
|
|
void ReadAnimation(Collada::Animation *pParent);
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** Reads an animation sampler into the given anim channel */
|
|
|
|
void ReadAnimationSampler(Collada::AnimationChannel &pChannel);
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** Reads the skeleton controller library */
|
|
|
|
void ReadControllerLibrary();
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** Reads a controller into the given mesh structure */
|
|
|
|
void ReadController(Collada::Controller &pController);
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** Reads the joint definitions for the given controller */
|
|
|
|
void ReadControllerJoints(Collada::Controller &pController);
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** Reads the joint weights for the given controller */
|
|
|
|
void ReadControllerWeights(Collada::Controller &pController);
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** Reads the image library contents */
|
|
|
|
void ReadImageLibrary();
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** Reads an image entry into the given image */
|
|
|
|
void ReadImage(Collada::Image &pImage);
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** Reads the material library */
|
|
|
|
void ReadMaterialLibrary();
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** Reads a material entry into the given material */
|
|
|
|
void ReadMaterial(Collada::Material &pMaterial);
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** Reads the camera library */
|
|
|
|
void ReadCameraLibrary();
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** Reads a camera entry into the given camera */
|
|
|
|
void ReadCamera(Collada::Camera &pCamera);
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** Reads the light library */
|
|
|
|
void ReadLightLibrary();
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** Reads a light entry into the given light */
|
|
|
|
void ReadLight(Collada::Light &pLight);
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** Reads the effect library */
|
|
|
|
void ReadEffectLibrary();
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** Reads an effect entry into the given effect*/
|
|
|
|
void ReadEffect(Collada::Effect &pEffect);
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** Reads an COMMON effect profile */
|
|
|
|
void ReadEffectProfileCommon(Collada::Effect &pEffect);
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** Read sampler properties */
|
|
|
|
void ReadSamplerProperties(Collada::Sampler &pSampler);
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** Reads an effect entry containing a color or a texture defining that color */
|
|
|
|
void ReadEffectColor(aiColor4D &pColor, Collada::Sampler &pSampler);
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** Reads an effect entry containing a float */
|
|
|
|
void ReadEffectFloat(ai_real &pFloat);
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** Reads an effect parameter specification of any kind */
|
|
|
|
void ReadEffectParam(Collada::EffectParam &pParam);
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** Reads the geometry library contents */
|
|
|
|
void ReadGeometryLibrary();
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** Reads a geometry from the geometry library. */
|
2020-04-29 16:17:46 +00:00
|
|
|
void ReadGeometry(Collada::Mesh &pMesh);
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** Reads a mesh from the geometry library */
|
2020-04-29 16:17:46 +00:00
|
|
|
void ReadMesh(Collada::Mesh &pMesh);
|
2020-04-28 16:46:07 +00:00
|
|
|
|
|
|
|
/** Reads a source element - a combination of raw data and an accessor defining
|
2015-07-27 02:16:01 +00:00
|
|
|
* things that should not be redefinable. Yes, that's another rant.
|
|
|
|
*/
|
2020-04-28 16:46:07 +00:00
|
|
|
void ReadSource();
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** Reads a data array holding a number of elements, and stores it in the global library.
|
2015-07-27 02:16:01 +00:00
|
|
|
* Currently supported are array of floats and arrays of strings.
|
|
|
|
*/
|
2020-04-28 16:46:07 +00:00
|
|
|
void ReadDataArray();
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** Reads an accessor and stores it in the global library under the given ID -
|
2015-07-27 02:16:01 +00:00
|
|
|
* accessors use the ID of the parent <source> element
|
|
|
|
*/
|
2020-04-28 16:46:07 +00:00
|
|
|
void ReadAccessor(const std::string &pID);
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** Reads input declarations of per-vertex mesh data into the given mesh */
|
2020-04-29 16:17:46 +00:00
|
|
|
void ReadVertexData(Collada::Mesh &pMesh);
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** Reads input declarations of per-index mesh data into the given mesh */
|
2020-04-29 16:17:46 +00:00
|
|
|
void ReadIndexData(Collada::Mesh &pMesh);
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** Reads a single input channel element and stores it in the given array, if valid */
|
|
|
|
void ReadInputChannel(std::vector<Collada::InputChannel> &poChannels);
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** Reads a <p> primitive index list and assembles the mesh data into the given mesh */
|
2020-04-29 16:17:46 +00:00
|
|
|
size_t ReadPrimitives(Collada::Mesh &pMesh, std::vector<Collada::InputChannel> &pPerIndexChannels,
|
2020-04-28 16:46:07 +00:00
|
|
|
size_t pNumPrimitives, const std::vector<size_t> &pVCount, Collada::PrimitiveType pPrimType);
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** 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,
|
2020-04-29 16:17:46 +00:00
|
|
|
Collada::Mesh &pMesh, std::vector<Collada::InputChannel> &pPerIndexChannels,
|
2020-04-28 16:46:07 +00:00
|
|
|
size_t currentPrimitive, const std::vector<size_t> &indices);
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** Reads one triangle of a tristrip into the mesh */
|
2020-04-29 16:17:46 +00:00
|
|
|
void ReadPrimTriStrips(size_t numOffsets, size_t perVertexOffset, Collada::Mesh &pMesh,
|
2020-04-28 16:46:07 +00:00
|
|
|
std::vector<Collada::InputChannel> &pPerIndexChannels, size_t currentPrimitive, const std::vector<size_t> &indices);
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** Extracts a single object from an input channel and stores it in the appropriate mesh data array */
|
2020-04-29 16:17:46 +00:00
|
|
|
void ExtractDataObjectFromChannel(const Collada::InputChannel &pInput, size_t pLocalIndex, Collada::Mesh &pMesh);
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** Reads the library of node hierarchies and scene parts */
|
|
|
|
void ReadSceneLibrary();
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** Reads a scene node's contents including children and stores it in the given node */
|
|
|
|
void ReadSceneNode(Collada::Node *pNode);
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** 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);
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** Reads a mesh reference in a node and adds it to the node's mesh list */
|
|
|
|
void ReadNodeGeometry(Collada::Node *pNode);
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** Reads the collada scene */
|
|
|
|
void ReadScene();
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
// Processes bind_vertex_input and bind elements
|
|
|
|
void ReadMaterialVertexInputBinding(Collada::SemanticMappingTable &tbl);
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** Reads embedded textures from a ZAE archive*/
|
|
|
|
void ReadEmbeddedTextures(ZipArchiveIOSystem &zip_archive);
|
2019-07-12 13:46:48 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
protected:
|
|
|
|
/** Aborts the file reading with an exception */
|
2020-08-18 15:32:34 +00:00
|
|
|
template<typename... T>
|
|
|
|
AI_WONT_RETURN void ThrowException(T&&... args) const AI_WONT_RETURN_SUFFIX;
|
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
void ReportWarning(const char *msg, ...);
|
2015-07-27 02:16:01 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** Skips all data until the end node of the current element */
|
|
|
|
void SkipElement();
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** Skips all data until the end node of the given element */
|
|
|
|
void SkipElement(const char *pElement);
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** Compares the current xml element name to the given string and returns true if equal */
|
|
|
|
bool IsElement(const char *pName) const;
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** Tests for the opening tag of the given element, throws an exception if not found */
|
|
|
|
void TestOpening(const char *pName);
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** Tests for the closing tag of the given element, throws an exception if not found */
|
|
|
|
void TestClosing(const char *pName);
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** Checks the present element for the presence of the attribute, returns its index
|
2015-07-27 02:16:01 +00:00
|
|
|
or throws an exception if not found */
|
2020-04-28 16:46:07 +00:00
|
|
|
int GetAttribute(const char *pAttr) const;
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** Returns the index of the named attribute or -1 if not found. Does not throw,
|
2015-07-27 02:16:01 +00:00
|
|
|
therefore useful for optional attributes */
|
2020-04-28 16:46:07 +00:00
|
|
|
int TestAttribute(const char *pAttr) const;
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** Reads the text contents of an element, throws an exception if not given.
|
2015-07-27 02:16:01 +00:00
|
|
|
Skips leading whitespace. */
|
2020-04-28 16:46:07 +00:00
|
|
|
const char *GetTextContent();
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2020-06-23 19:05:42 +00:00
|
|
|
/** Reads the text contents of an element, returns nullptr if not given.
|
2015-07-27 02:16:01 +00:00
|
|
|
Skips leading whitespace. */
|
2020-04-28 16:46:07 +00:00
|
|
|
const char *TestTextContent();
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** Reads a single bool from current text content */
|
|
|
|
bool ReadBoolFromTextContent();
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** Reads a single float from current text content */
|
|
|
|
ai_real ReadFloatFromTextContent();
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** Calculates the resulting transformation from all the given transform steps */
|
|
|
|
aiMatrix4x4 CalculateResultTransform(const std::vector<Collada::Transform> &pTransforms) const;
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** Determines the input data type for the given semantic string */
|
|
|
|
Collada::InputType GetTypeForSemantic(const std::string &pSemantic);
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** 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;
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
protected:
|
|
|
|
/** Filename, for a verbose error message */
|
|
|
|
std::string mFileName;
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** XML reader, member for everyday use */
|
|
|
|
irr::io::IrrXMLReader *mReader;
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** All data arrays found in the file by ID. Might be referred to by actually
|
2015-07-27 02:16:01 +00:00
|
|
|
everyone. Collada, you are a steaming pile of indirection. */
|
2020-04-28 16:46:07 +00:00
|
|
|
typedef std::map<std::string, Collada::Data> DataLibrary;
|
|
|
|
DataLibrary mDataLibrary;
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** Same for accessors which define how the data in a data array is accessed. */
|
|
|
|
typedef std::map<std::string, Collada::Accessor> AccessorLibrary;
|
|
|
|
AccessorLibrary mAccessorLibrary;
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** Mesh library: mesh by ID */
|
|
|
|
typedef std::map<std::string, Collada::Mesh *> MeshLibrary;
|
|
|
|
MeshLibrary mMeshLibrary;
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** node library: root node of the hierarchy part by ID */
|
|
|
|
typedef std::map<std::string, Collada::Node *> NodeLibrary;
|
|
|
|
NodeLibrary mNodeLibrary;
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** Image library: stores texture properties by ID */
|
|
|
|
typedef std::map<std::string, Collada::Image> ImageLibrary;
|
|
|
|
ImageLibrary mImageLibrary;
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** Effect library: surface attributes by ID */
|
|
|
|
typedef std::map<std::string, Collada::Effect> EffectLibrary;
|
|
|
|
EffectLibrary mEffectLibrary;
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** Material library: surface material by ID */
|
|
|
|
typedef std::map<std::string, Collada::Material> MaterialLibrary;
|
|
|
|
MaterialLibrary mMaterialLibrary;
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** Light library: surface light by ID */
|
|
|
|
typedef std::map<std::string, Collada::Light> LightLibrary;
|
|
|
|
LightLibrary mLightLibrary;
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** Camera library: surface material by ID */
|
|
|
|
typedef std::map<std::string, Collada::Camera> CameraLibrary;
|
|
|
|
CameraLibrary mCameraLibrary;
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** Controller library: joint controllers by ID */
|
|
|
|
typedef std::map<std::string, Collada::Controller> ControllerLibrary;
|
|
|
|
ControllerLibrary mControllerLibrary;
|
2016-02-07 22:36:49 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** Animation library: animation references by ID */
|
|
|
|
typedef std::map<std::string, Collada::Animation *> AnimationLibrary;
|
|
|
|
AnimationLibrary mAnimationLibrary;
|
2016-02-07 22:36:49 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** Animation clip library: clip animation references by ID */
|
|
|
|
typedef std::vector<std::pair<std::string, std::vector<std::string>>> AnimationClipLibrary;
|
|
|
|
AnimationClipLibrary mAnimationClipLibrary;
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2020-04-28 16:46:07 +00:00
|
|
|
/** Pointer to the root node. Don't delete, it just points to one of
|
2015-07-27 02:16:01 +00:00
|
|
|
the nodes in the node library. */
|
2020-04-28 16:46:07 +00:00
|
|
|
Collada::Node *mRootNode;
|
|
|
|
|
|
|
|
/** Root animation container */
|
|
|
|
Collada::Animation mAnims;
|
|
|
|
|
|
|
|
/** Size unit: how large compared to a meter */
|
|
|
|
ai_real mUnitSize;
|
|
|
|
|
|
|
|
/** Which is the up vector */
|
|
|
|
enum { UP_X,
|
|
|
|
UP_Y,
|
|
|
|
UP_Z } mUpDirection;
|
|
|
|
|
|
|
|
/** Asset metadata (global for scene) */
|
|
|
|
StringMetaData mAssetMetaData;
|
|
|
|
|
|
|
|
/** 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())
|
2020-08-18 15:32:34 +00:00
|
|
|
ThrowException("Unable to resolve library reference \"", pURL, "\".");
|
2020-04-28 16:46:07 +00:00
|
|
|
return it->second;
|
|
|
|
}
|
2016-04-05 21:23:53 +00:00
|
|
|
|
2015-05-19 03:48:29 +00:00
|
|
|
} // end of namespace Assimp
|
|
|
|
|
|
|
|
#endif // AI_COLLADAPARSER_H_INC
|