Externalize Assimp
This commit is contained in:
		
							
								
								
									
										1675
									
								
								thirdparty/assimp/code/Collada/ColladaExporter.cpp
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1675
									
								
								thirdparty/assimp/code/Collada/ColladaExporter.cpp
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										222
									
								
								thirdparty/assimp/code/Collada/ColladaExporter.h
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										222
									
								
								thirdparty/assimp/code/Collada/ColladaExporter.h
									
									
									
									
										vendored
									
									
								
							@@ -1,222 +0,0 @@
 | 
			
		||||
/*
 | 
			
		||||
Open Asset Import Library (assimp)
 | 
			
		||||
----------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
Copyright (c) 2006-2019, 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 ColladaExporter.h
 | 
			
		||||
 * Declares the exporter class to write a scene to a Collada file
 | 
			
		||||
 */
 | 
			
		||||
#ifndef AI_COLLADAEXPORTER_H_INC
 | 
			
		||||
#define AI_COLLADAEXPORTER_H_INC
 | 
			
		||||
 | 
			
		||||
#include <assimp/ai_assert.h>
 | 
			
		||||
#include <assimp/material.h>
 | 
			
		||||
#include <assimp/mesh.h>
 | 
			
		||||
#include <assimp/light.h>
 | 
			
		||||
#include <assimp/Exporter.hpp>
 | 
			
		||||
#include <sstream>
 | 
			
		||||
#include <vector>
 | 
			
		||||
#include <map>
 | 
			
		||||
 | 
			
		||||
#include <assimp/StringUtils.h>
 | 
			
		||||
 | 
			
		||||
struct aiScene;
 | 
			
		||||
struct aiNode;
 | 
			
		||||
 | 
			
		||||
namespace Assimp
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
/// Helper class to export a given scene to a Collada file. Just for my personal
 | 
			
		||||
/// comfort when implementing it.
 | 
			
		||||
class ColladaExporter
 | 
			
		||||
{
 | 
			
		||||
public:
 | 
			
		||||
    /// Constructor for a specific scene to export
 | 
			
		||||
    ColladaExporter( const aiScene* pScene, IOSystem* pIOSystem, const std::string& path, const std::string& file);
 | 
			
		||||
 | 
			
		||||
    /// Destructor
 | 
			
		||||
    virtual ~ColladaExporter();
 | 
			
		||||
 | 
			
		||||
protected:
 | 
			
		||||
    /// Starts writing the contents
 | 
			
		||||
    void WriteFile();
 | 
			
		||||
 | 
			
		||||
    /// Writes the asset header
 | 
			
		||||
    void WriteHeader();
 | 
			
		||||
 | 
			
		||||
    /// Writes the embedded textures
 | 
			
		||||
    void WriteTextures();
 | 
			
		||||
 | 
			
		||||
    /// Writes the material setup
 | 
			
		||||
    void WriteMaterials();
 | 
			
		||||
 | 
			
		||||
    /// Writes the cameras library
 | 
			
		||||
    void WriteCamerasLibrary();
 | 
			
		||||
 | 
			
		||||
    // Write a camera entry
 | 
			
		||||
    void WriteCamera(size_t pIndex);
 | 
			
		||||
 | 
			
		||||
    /// Writes the cameras library
 | 
			
		||||
    void WriteLightsLibrary();
 | 
			
		||||
 | 
			
		||||
    // Write a camera entry
 | 
			
		||||
    void WriteLight(size_t pIndex);
 | 
			
		||||
    void WritePointLight(const aiLight *const light);
 | 
			
		||||
    void WriteDirectionalLight(const aiLight *const light);
 | 
			
		||||
    void WriteSpotLight(const aiLight *const light);
 | 
			
		||||
    void WriteAmbienttLight(const aiLight *const light);
 | 
			
		||||
 | 
			
		||||
    /// Writes the controller library
 | 
			
		||||
    void WriteControllerLibrary();
 | 
			
		||||
 | 
			
		||||
    /// Writes a skin controller of the given mesh
 | 
			
		||||
    void WriteController( size_t pIndex);
 | 
			
		||||
 | 
			
		||||
    /// Writes the geometry library
 | 
			
		||||
    void WriteGeometryLibrary();
 | 
			
		||||
 | 
			
		||||
    /// Writes the given mesh
 | 
			
		||||
    void WriteGeometry( size_t pIndex);
 | 
			
		||||
 | 
			
		||||
    //enum FloatDataType { FloatType_Vector, FloatType_TexCoord2, FloatType_TexCoord3, FloatType_Color, FloatType_Mat4x4, FloatType_Weight };
 | 
			
		||||
    // customized to add animation related type
 | 
			
		||||
	enum FloatDataType { FloatType_Vector, FloatType_TexCoord2, FloatType_TexCoord3, FloatType_Color, FloatType_Mat4x4, FloatType_Weight, FloatType_Time };
 | 
			
		||||
 | 
			
		||||
    /// Writes a float array of the given type
 | 
			
		||||
    void WriteFloatArray( const std::string& pIdString, FloatDataType pType, const ai_real* pData, size_t pElementCount);
 | 
			
		||||
 | 
			
		||||
    /// Writes the scene library
 | 
			
		||||
    void WriteSceneLibrary();
 | 
			
		||||
 | 
			
		||||
	// customized, Writes the animation library
 | 
			
		||||
	void WriteAnimationsLibrary();
 | 
			
		||||
	void WriteAnimationLibrary( size_t pIndex);
 | 
			
		||||
	std::string mFoundSkeletonRootNodeID = "skeleton_root";	 	// will be replaced by found node id in the WriteNode call.
 | 
			
		||||
	
 | 
			
		||||
    /// Recursively writes the given node
 | 
			
		||||
    void WriteNode( const aiScene* scene, aiNode* pNode);
 | 
			
		||||
 | 
			
		||||
    /// Enters a new xml element, which increases the indentation
 | 
			
		||||
    void PushTag() { startstr.append( "  "); }
 | 
			
		||||
    /// Leaves an element, decreasing the indentation
 | 
			
		||||
    void PopTag() { 
 | 
			
		||||
        ai_assert( startstr.length() > 1); 
 | 
			
		||||
        startstr.erase( startstr.length() - 2); 
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// Creates a mesh ID for the given mesh
 | 
			
		||||
    std::string GetMeshId( size_t pIndex) const {
 | 
			
		||||
        return std::string( "meshId" ) + to_string(pIndex);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
    /// Stringstream to write all output into
 | 
			
		||||
    std::stringstream mOutput;
 | 
			
		||||
 | 
			
		||||
    /// The IOSystem for output
 | 
			
		||||
    IOSystem* mIOSystem;
 | 
			
		||||
 | 
			
		||||
    /// Path of the directory where the scene will be exported
 | 
			
		||||
    const std::string mPath;
 | 
			
		||||
 | 
			
		||||
    /// Name of the file (without extension) where the scene will be exported
 | 
			
		||||
    const std::string mFile;
 | 
			
		||||
 | 
			
		||||
    /// The scene to be written
 | 
			
		||||
    const aiScene* mScene;
 | 
			
		||||
    bool mSceneOwned;
 | 
			
		||||
 | 
			
		||||
    /// current line start string, contains the current indentation for simple stream insertion
 | 
			
		||||
    std::string startstr;
 | 
			
		||||
    /// current line end string for simple stream insertion
 | 
			
		||||
    std::string endstr;
 | 
			
		||||
 | 
			
		||||
  // pair of color and texture - texture precedences color
 | 
			
		||||
  struct Surface
 | 
			
		||||
  {
 | 
			
		||||
    bool exist;
 | 
			
		||||
    aiColor4D color;
 | 
			
		||||
    std::string texture;
 | 
			
		||||
    size_t channel;
 | 
			
		||||
    Surface() { exist = false; channel = 0; }
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  struct Property
 | 
			
		||||
  {
 | 
			
		||||
    bool exist;
 | 
			
		||||
     ai_real value;
 | 
			
		||||
     Property()
 | 
			
		||||
         : exist(false)
 | 
			
		||||
         , value(0.0)
 | 
			
		||||
     {}
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  // summarize a material in an convenient way.
 | 
			
		||||
  struct Material
 | 
			
		||||
  {
 | 
			
		||||
    std::string name;
 | 
			
		||||
    std::string shading_model;
 | 
			
		||||
    Surface ambient, diffuse, specular, emissive, reflective, transparent, normal;
 | 
			
		||||
    Property shininess, transparency, index_refraction;
 | 
			
		||||
 | 
			
		||||
    Material() {}
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  std::vector<Material> materials;
 | 
			
		||||
 | 
			
		||||
  std::map<unsigned int, std::string> textures;
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
  /// Dammit C++ - y u no compile two-pass? No I have to add all methods below the struct definitions
 | 
			
		||||
  /// Reads a single surface entry from the given material keys
 | 
			
		||||
  void ReadMaterialSurface( Surface& poSurface, const aiMaterial* pSrcMat, aiTextureType pTexture, const char* pKey, size_t pType, size_t pIndex);
 | 
			
		||||
  /// Writes an image entry for the given surface
 | 
			
		||||
  void WriteImageEntry( const Surface& pSurface, const std::string& pNameAdd);
 | 
			
		||||
  /// Writes the two parameters necessary for referencing a texture in an effect entry
 | 
			
		||||
  void WriteTextureParamEntry( const Surface& pSurface, const std::string& pTypeName, const std::string& pMatName);
 | 
			
		||||
  /// Writes a color-or-texture entry into an effect definition
 | 
			
		||||
  void WriteTextureColorEntry( const Surface& pSurface, const std::string& pTypeName, const std::string& pImageName);
 | 
			
		||||
  /// Writes a scalar property
 | 
			
		||||
  void WriteFloatEntry( const Property& pProperty, const std::string& pTypeName);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#endif // !! AI_COLLADAEXPORTER_H_INC
 | 
			
		||||
							
								
								
									
										701
									
								
								thirdparty/assimp/code/Collada/ColladaHelper.h
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										701
									
								
								thirdparty/assimp/code/Collada/ColladaHelper.h
									
									
									
									
										vendored
									
									
								
							@@ -1,701 +0,0 @@
 | 
			
		||||
/** Helper structures for the Collada loader */
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
Open Asset Import Library (assimp)
 | 
			
		||||
----------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
Copyright (c) 2006-2019, 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 AI_COLLADAHELPER_H_INC
 | 
			
		||||
#define AI_COLLADAHELPER_H_INC
 | 
			
		||||
 | 
			
		||||
#include <map>
 | 
			
		||||
#include <vector>
 | 
			
		||||
#include <stdint.h>
 | 
			
		||||
#include <assimp/light.h>
 | 
			
		||||
#include <assimp/mesh.h>
 | 
			
		||||
#include <assimp/material.h>
 | 
			
		||||
 | 
			
		||||
struct aiMaterial;
 | 
			
		||||
 | 
			
		||||
namespace Assimp    {
 | 
			
		||||
namespace Collada       {
 | 
			
		||||
 | 
			
		||||
/** Collada file versions which evolved during the years ... */
 | 
			
		||||
enum FormatVersion
 | 
			
		||||
{
 | 
			
		||||
    FV_1_5_n,
 | 
			
		||||
    FV_1_4_n,
 | 
			
		||||
    FV_1_3_n
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/** Transformation types that can be applied to a node */
 | 
			
		||||
enum TransformType
 | 
			
		||||
{
 | 
			
		||||
    TF_LOOKAT,
 | 
			
		||||
    TF_ROTATE,
 | 
			
		||||
    TF_TRANSLATE,
 | 
			
		||||
    TF_SCALE,
 | 
			
		||||
    TF_SKEW,
 | 
			
		||||
    TF_MATRIX
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/** Different types of input data to a vertex or face */
 | 
			
		||||
enum InputType
 | 
			
		||||
{
 | 
			
		||||
    IT_Invalid,
 | 
			
		||||
    IT_Vertex,  // special type for per-index data referring to the <vertices> element carrying the per-vertex data.
 | 
			
		||||
    IT_Position,
 | 
			
		||||
    IT_Normal,
 | 
			
		||||
    IT_Texcoord,
 | 
			
		||||
    IT_Color,
 | 
			
		||||
    IT_Tangent,
 | 
			
		||||
    IT_Bitangent
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/** Supported controller types */
 | 
			
		||||
enum ControllerType
 | 
			
		||||
{
 | 
			
		||||
    Skin,
 | 
			
		||||
    Morph
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/** Supported morph methods */
 | 
			
		||||
enum MorphMethod
 | 
			
		||||
{
 | 
			
		||||
    Normalized,
 | 
			
		||||
    Relative
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/** Contains all data for one of the different transformation types */
 | 
			
		||||
struct Transform
 | 
			
		||||
{
 | 
			
		||||
    std::string mID;  ///< SID of the transform step, by which anim channels address their target node
 | 
			
		||||
    TransformType mType;
 | 
			
		||||
    ai_real f[16]; ///< Interpretation of data depends on the type of the transformation
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/** A collada camera. */
 | 
			
		||||
struct Camera
 | 
			
		||||
{
 | 
			
		||||
    Camera()
 | 
			
		||||
        :   mOrtho  (false)
 | 
			
		||||
        ,   mHorFov (10e10f)
 | 
			
		||||
        ,   mVerFov (10e10f)
 | 
			
		||||
        ,   mAspect (10e10f)
 | 
			
		||||
        ,   mZNear  (0.1f)
 | 
			
		||||
        ,   mZFar   (1000.f)
 | 
			
		||||
    {}
 | 
			
		||||
 | 
			
		||||
    // Name of camera
 | 
			
		||||
    std::string mName;
 | 
			
		||||
 | 
			
		||||
    // True if it is an orthografic camera
 | 
			
		||||
    bool mOrtho;
 | 
			
		||||
 | 
			
		||||
    //! Horizontal field of view in degrees
 | 
			
		||||
    ai_real mHorFov;
 | 
			
		||||
 | 
			
		||||
    //! Vertical field of view in degrees
 | 
			
		||||
    ai_real mVerFov;
 | 
			
		||||
 | 
			
		||||
    //! Screen aspect
 | 
			
		||||
    ai_real mAspect;
 | 
			
		||||
 | 
			
		||||
    //! Near& far z
 | 
			
		||||
    ai_real mZNear, mZFar;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#define ASSIMP_COLLADA_LIGHT_ANGLE_NOT_SET 1e9f
 | 
			
		||||
 | 
			
		||||
/** A collada light source. */
 | 
			
		||||
struct Light
 | 
			
		||||
{
 | 
			
		||||
    Light()
 | 
			
		||||
        :   mType            (aiLightSource_UNDEFINED)
 | 
			
		||||
        ,   mAttConstant     (1.f)
 | 
			
		||||
        ,   mAttLinear       (0.f)
 | 
			
		||||
        ,   mAttQuadratic    (0.f)
 | 
			
		||||
        ,   mFalloffAngle    (180.f)
 | 
			
		||||
        ,   mFalloffExponent (0.f)
 | 
			
		||||
        ,   mPenumbraAngle   (ASSIMP_COLLADA_LIGHT_ANGLE_NOT_SET)
 | 
			
		||||
        ,   mOuterAngle      (ASSIMP_COLLADA_LIGHT_ANGLE_NOT_SET)
 | 
			
		||||
        ,   mIntensity       (1.f)
 | 
			
		||||
    {}
 | 
			
		||||
 | 
			
		||||
    //! Type of the light source aiLightSourceType + ambient
 | 
			
		||||
    unsigned int mType;
 | 
			
		||||
 | 
			
		||||
    //! Color of the light
 | 
			
		||||
    aiColor3D mColor;
 | 
			
		||||
 | 
			
		||||
    //! Light attenuation
 | 
			
		||||
    ai_real mAttConstant,mAttLinear,mAttQuadratic;
 | 
			
		||||
 | 
			
		||||
    //! Spot light falloff
 | 
			
		||||
    ai_real mFalloffAngle;
 | 
			
		||||
    ai_real mFalloffExponent;
 | 
			
		||||
 | 
			
		||||
    // -----------------------------------------------------
 | 
			
		||||
    // FCOLLADA extension from here
 | 
			
		||||
 | 
			
		||||
    //! ... related stuff from maja and max extensions
 | 
			
		||||
    ai_real mPenumbraAngle;
 | 
			
		||||
    ai_real mOuterAngle;
 | 
			
		||||
 | 
			
		||||
    //! Common light intensity
 | 
			
		||||
    ai_real mIntensity;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/** Short vertex index description */
 | 
			
		||||
struct InputSemanticMapEntry
 | 
			
		||||
{
 | 
			
		||||
    InputSemanticMapEntry()
 | 
			
		||||
        :   mSet(0)
 | 
			
		||||
        ,   mType(IT_Invalid)
 | 
			
		||||
    {}
 | 
			
		||||
 | 
			
		||||
    //! Index of set, optional
 | 
			
		||||
    unsigned int mSet;
 | 
			
		||||
 | 
			
		||||
    //! Type of referenced vertex input
 | 
			
		||||
    InputType mType;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/** Table to map from effect to vertex input semantics */
 | 
			
		||||
struct SemanticMappingTable
 | 
			
		||||
{
 | 
			
		||||
    //! Name of material
 | 
			
		||||
    std::string mMatName;
 | 
			
		||||
 | 
			
		||||
    //! List of semantic map commands, grouped by effect semantic name
 | 
			
		||||
    std::map<std::string, InputSemanticMapEntry> mMap;
 | 
			
		||||
 | 
			
		||||
    //! For std::find
 | 
			
		||||
    bool operator == (const std::string& s) const {
 | 
			
		||||
        return s == mMatName;
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/** A reference to a mesh inside a node, including materials assigned to the various subgroups.
 | 
			
		||||
 * The ID refers to either a mesh or a controller which specifies the mesh
 | 
			
		||||
 */
 | 
			
		||||
struct MeshInstance
 | 
			
		||||
{
 | 
			
		||||
    ///< ID of the mesh or controller to be instanced
 | 
			
		||||
    std::string mMeshOrController;
 | 
			
		||||
 | 
			
		||||
    ///< Map of materials by the subgroup ID they're applied to
 | 
			
		||||
    std::map<std::string, SemanticMappingTable> mMaterials;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/** A reference to a camera inside a node*/
 | 
			
		||||
struct CameraInstance
 | 
			
		||||
{
 | 
			
		||||
     ///< ID of the camera
 | 
			
		||||
    std::string mCamera;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/** A reference to a light inside a node*/
 | 
			
		||||
struct LightInstance
 | 
			
		||||
{
 | 
			
		||||
     ///< ID of the camera
 | 
			
		||||
    std::string mLight;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/** A reference to a node inside a node*/
 | 
			
		||||
struct NodeInstance
 | 
			
		||||
{
 | 
			
		||||
     ///< ID of the node
 | 
			
		||||
    std::string mNode;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/** A node in a scene hierarchy */
 | 
			
		||||
struct Node
 | 
			
		||||
{
 | 
			
		||||
    std::string mName;
 | 
			
		||||
    std::string mID;
 | 
			
		||||
    std::string mSID;
 | 
			
		||||
    Node* mParent;
 | 
			
		||||
    std::vector<Node*> mChildren;
 | 
			
		||||
 | 
			
		||||
    /** Operations in order to calculate the resulting transformation to parent. */
 | 
			
		||||
    std::vector<Transform> mTransforms;
 | 
			
		||||
 | 
			
		||||
    /** Meshes at this node */
 | 
			
		||||
    std::vector<MeshInstance> mMeshes;
 | 
			
		||||
 | 
			
		||||
    /** Lights at this node */
 | 
			
		||||
    std::vector<LightInstance> mLights;
 | 
			
		||||
 | 
			
		||||
    /** Cameras at this node */
 | 
			
		||||
    std::vector<CameraInstance> mCameras;
 | 
			
		||||
 | 
			
		||||
    /** Node instances at this node */
 | 
			
		||||
    std::vector<NodeInstance> mNodeInstances;
 | 
			
		||||
 | 
			
		||||
    /** Root-nodes: Name of primary camera, if any */
 | 
			
		||||
    std::string mPrimaryCamera;
 | 
			
		||||
 | 
			
		||||
    //! Constructor. Begin with a zero parent
 | 
			
		||||
    Node()
 | 
			
		||||
    : mParent( nullptr ){
 | 
			
		||||
        // empty
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    //! Destructor: delete all children subsequently
 | 
			
		||||
    ~Node() {
 | 
			
		||||
        for( std::vector<Node*>::iterator it = mChildren.begin(); it != mChildren.end(); ++it)
 | 
			
		||||
            delete *it;
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/** Data source array: either floats or strings */
 | 
			
		||||
struct Data
 | 
			
		||||
{
 | 
			
		||||
    bool mIsStringArray;
 | 
			
		||||
    std::vector<ai_real> mValues;
 | 
			
		||||
    std::vector<std::string> mStrings;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/** Accessor to a data array */
 | 
			
		||||
struct Accessor
 | 
			
		||||
{
 | 
			
		||||
    size_t mCount;   // in number of objects
 | 
			
		||||
    size_t mSize;    // size of an object, in elements (floats or strings, mostly 1)
 | 
			
		||||
    size_t mOffset;  // in number of values
 | 
			
		||||
    size_t mStride;  // Stride in number of values
 | 
			
		||||
    std::vector<std::string> mParams; // names of the data streams in the accessors. Empty string tells to ignore.
 | 
			
		||||
    size_t mSubOffset[4]; // Suboffset inside the object for the common 4 elements. For a vector, that's XYZ, for a color RGBA and so on.
 | 
			
		||||
                          // For example, SubOffset[0] denotes which of the values inside the object is the vector X component.
 | 
			
		||||
    std::string mSource;   // URL of the source array
 | 
			
		||||
    mutable const Data* mData; // Pointer to the source array, if resolved. NULL else
 | 
			
		||||
 | 
			
		||||
    Accessor()
 | 
			
		||||
    {
 | 
			
		||||
        mCount = 0; mSize = 0; mOffset = 0; mStride = 0; mData = NULL;
 | 
			
		||||
        mSubOffset[0] = mSubOffset[1] = mSubOffset[2] = mSubOffset[3] = 0;
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/** A single face in a mesh */
 | 
			
		||||
struct Face
 | 
			
		||||
{
 | 
			
		||||
    std::vector<size_t> mIndices;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/** An input channel for mesh data, referring to a single accessor */
 | 
			
		||||
struct InputChannel
 | 
			
		||||
{
 | 
			
		||||
    InputType mType;      // Type of the data
 | 
			
		||||
    size_t mIndex;        // Optional index, if multiple sets of the same data type are given
 | 
			
		||||
    size_t mOffset;       // Index offset in the indices array of per-face indices. Don't ask, can't explain that any better.
 | 
			
		||||
    std::string mAccessor; // ID of the accessor where to read the actual values from.
 | 
			
		||||
    mutable const Accessor* mResolved; // Pointer to the accessor, if resolved. NULL else
 | 
			
		||||
 | 
			
		||||
    InputChannel() { mType = IT_Invalid; mIndex = 0; mOffset = 0; mResolved = NULL; }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/** Subset of a mesh with a certain material */
 | 
			
		||||
struct SubMesh
 | 
			
		||||
{
 | 
			
		||||
    std::string mMaterial; ///< subgroup identifier
 | 
			
		||||
    size_t mNumFaces; ///< number of faces in this submesh
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/** Contains data for a single mesh */
 | 
			
		||||
struct Mesh
 | 
			
		||||
{
 | 
			
		||||
    Mesh()
 | 
			
		||||
    {
 | 
			
		||||
        for (unsigned int i = 0; i < AI_MAX_NUMBER_OF_TEXTURECOORDS;++i)
 | 
			
		||||
            mNumUVComponents[i] = 2;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    std::string mName;
 | 
			
		||||
 | 
			
		||||
    // just to check if there's some sophisticated addressing involved...
 | 
			
		||||
    // which we don't support, and therefore should warn about.
 | 
			
		||||
    std::string mVertexID;
 | 
			
		||||
 | 
			
		||||
    // Vertex data addressed by vertex indices
 | 
			
		||||
    std::vector<InputChannel> mPerVertexData;
 | 
			
		||||
 | 
			
		||||
    // actual mesh data, assembled on encounter of a <p> element. Verbose format, not indexed
 | 
			
		||||
    std::vector<aiVector3D> mPositions;
 | 
			
		||||
    std::vector<aiVector3D> mNormals;
 | 
			
		||||
    std::vector<aiVector3D> mTangents;
 | 
			
		||||
    std::vector<aiVector3D> mBitangents;
 | 
			
		||||
    std::vector<aiVector3D> mTexCoords[AI_MAX_NUMBER_OF_TEXTURECOORDS];
 | 
			
		||||
    std::vector<aiColor4D>  mColors[AI_MAX_NUMBER_OF_COLOR_SETS];
 | 
			
		||||
 | 
			
		||||
    unsigned int mNumUVComponents[AI_MAX_NUMBER_OF_TEXTURECOORDS];
 | 
			
		||||
 | 
			
		||||
    // Faces. Stored are only the number of vertices for each face.
 | 
			
		||||
    // 1 == point, 2 == line, 3 == triangle, 4+ == poly
 | 
			
		||||
    std::vector<size_t> mFaceSize;
 | 
			
		||||
 | 
			
		||||
    // Position indices for all faces in the sequence given in mFaceSize -
 | 
			
		||||
    // necessary for bone weight assignment
 | 
			
		||||
    std::vector<size_t> mFacePosIndices;
 | 
			
		||||
 | 
			
		||||
    // Submeshes in this mesh, each with a given material
 | 
			
		||||
    std::vector<SubMesh> mSubMeshes;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/** Which type of primitives the ReadPrimitives() function is going to read */
 | 
			
		||||
enum PrimitiveType
 | 
			
		||||
{
 | 
			
		||||
    Prim_Invalid,
 | 
			
		||||
    Prim_Lines,
 | 
			
		||||
    Prim_LineStrip,
 | 
			
		||||
    Prim_Triangles,
 | 
			
		||||
    Prim_TriStrips,
 | 
			
		||||
    Prim_TriFans,
 | 
			
		||||
    Prim_Polylist,
 | 
			
		||||
    Prim_Polygon
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/** A skeleton controller to deform a mesh with the use of joints */
 | 
			
		||||
struct Controller
 | 
			
		||||
{
 | 
			
		||||
    // controller type
 | 
			
		||||
    ControllerType mType;
 | 
			
		||||
 | 
			
		||||
    // Morphing method if type is Morph
 | 
			
		||||
    MorphMethod mMethod;
 | 
			
		||||
 | 
			
		||||
    // the URL of the mesh deformed by the controller.
 | 
			
		||||
    std::string mMeshId;
 | 
			
		||||
 | 
			
		||||
    // accessor URL of the joint names
 | 
			
		||||
    std::string mJointNameSource;
 | 
			
		||||
 | 
			
		||||
    ///< The bind shape matrix, as array of floats. I'm not sure what this matrix actually describes, but it can't be ignored in all cases
 | 
			
		||||
    ai_real mBindShapeMatrix[16];
 | 
			
		||||
 | 
			
		||||
    // accessor URL of the joint inverse bind matrices
 | 
			
		||||
    std::string mJointOffsetMatrixSource;
 | 
			
		||||
 | 
			
		||||
    // input channel: joint names.
 | 
			
		||||
    InputChannel mWeightInputJoints;
 | 
			
		||||
    // input channel: joint weights
 | 
			
		||||
    InputChannel mWeightInputWeights;
 | 
			
		||||
 | 
			
		||||
    // Number of weights per vertex.
 | 
			
		||||
    std::vector<size_t> mWeightCounts;
 | 
			
		||||
 | 
			
		||||
    // JointIndex-WeightIndex pairs for all vertices
 | 
			
		||||
    std::vector< std::pair<size_t, size_t> > mWeights;
 | 
			
		||||
 | 
			
		||||
    std::string mMorphTarget;
 | 
			
		||||
    std::string mMorphWeight;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/** A collada material. Pretty much the only member is a reference to an effect. */
 | 
			
		||||
struct Material
 | 
			
		||||
{
 | 
			
		||||
    std::string mName;
 | 
			
		||||
    std::string mEffect;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/** Type of the effect param */
 | 
			
		||||
enum ParamType
 | 
			
		||||
{
 | 
			
		||||
    Param_Sampler,
 | 
			
		||||
    Param_Surface
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/** A param for an effect. Might be of several types, but they all just refer to each other, so I summarize them */
 | 
			
		||||
struct EffectParam
 | 
			
		||||
{
 | 
			
		||||
    ParamType mType;
 | 
			
		||||
    std::string mReference; // to which other thing the param is referring to.
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/** Shading type supported by the standard effect spec of Collada */
 | 
			
		||||
enum ShadeType
 | 
			
		||||
{
 | 
			
		||||
    Shade_Invalid,
 | 
			
		||||
    Shade_Constant,
 | 
			
		||||
    Shade_Lambert,
 | 
			
		||||
    Shade_Phong,
 | 
			
		||||
    Shade_Blinn
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/** Represents a texture sampler in collada */
 | 
			
		||||
struct Sampler
 | 
			
		||||
{
 | 
			
		||||
    Sampler()
 | 
			
		||||
        :   mWrapU      (true)
 | 
			
		||||
        ,   mWrapV      (true)
 | 
			
		||||
        ,   mMirrorU    ()
 | 
			
		||||
        ,   mMirrorV    ()
 | 
			
		||||
        ,   mOp         (aiTextureOp_Multiply)
 | 
			
		||||
        ,   mUVId       (UINT_MAX)
 | 
			
		||||
        ,   mWeighting  (1.f)
 | 
			
		||||
        ,   mMixWithPrevious (1.f)
 | 
			
		||||
    {}
 | 
			
		||||
 | 
			
		||||
    /** Name of image reference
 | 
			
		||||
     */
 | 
			
		||||
    std::string mName;
 | 
			
		||||
 | 
			
		||||
    /** Wrap U?
 | 
			
		||||
     */
 | 
			
		||||
    bool mWrapU;
 | 
			
		||||
 | 
			
		||||
    /** Wrap V?
 | 
			
		||||
     */
 | 
			
		||||
    bool mWrapV;
 | 
			
		||||
 | 
			
		||||
    /** Mirror U?
 | 
			
		||||
     */
 | 
			
		||||
    bool mMirrorU;
 | 
			
		||||
 | 
			
		||||
    /** Mirror V?
 | 
			
		||||
     */
 | 
			
		||||
    bool mMirrorV;
 | 
			
		||||
 | 
			
		||||
    /** Blend mode
 | 
			
		||||
     */
 | 
			
		||||
    aiTextureOp mOp;
 | 
			
		||||
 | 
			
		||||
    /** UV transformation
 | 
			
		||||
     */
 | 
			
		||||
    aiUVTransform mTransform;
 | 
			
		||||
 | 
			
		||||
    /** Name of source UV channel
 | 
			
		||||
     */
 | 
			
		||||
    std::string mUVChannel;
 | 
			
		||||
 | 
			
		||||
    /** Resolved UV channel index or UINT_MAX if not known
 | 
			
		||||
     */
 | 
			
		||||
    unsigned int mUVId;
 | 
			
		||||
 | 
			
		||||
    // OKINO/MAX3D extensions from here
 | 
			
		||||
    // -------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
    /** Weighting factor
 | 
			
		||||
     */
 | 
			
		||||
    ai_real mWeighting;
 | 
			
		||||
 | 
			
		||||
    /** Mixing factor from OKINO
 | 
			
		||||
     */
 | 
			
		||||
    ai_real mMixWithPrevious;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/** A collada effect. Can contain about anything according to the Collada spec,
 | 
			
		||||
    but we limit our version to a reasonable subset. */
 | 
			
		||||
struct Effect
 | 
			
		||||
{
 | 
			
		||||
    // Shading mode
 | 
			
		||||
    ShadeType mShadeType;
 | 
			
		||||
 | 
			
		||||
    // Colors
 | 
			
		||||
    aiColor4D mEmissive, mAmbient, mDiffuse, mSpecular,
 | 
			
		||||
        mTransparent, mReflective;
 | 
			
		||||
 | 
			
		||||
    // Textures
 | 
			
		||||
    Sampler mTexEmissive, mTexAmbient, mTexDiffuse, mTexSpecular,
 | 
			
		||||
        mTexTransparent, mTexBump, mTexReflective;
 | 
			
		||||
 | 
			
		||||
    // Scalar factory
 | 
			
		||||
    ai_real mShininess, mRefractIndex, mReflectivity;
 | 
			
		||||
    ai_real mTransparency;
 | 
			
		||||
    bool mHasTransparency;
 | 
			
		||||
    bool mRGBTransparency;
 | 
			
		||||
    bool mInvertTransparency;
 | 
			
		||||
 | 
			
		||||
    // local params referring to each other by their SID
 | 
			
		||||
    typedef std::map<std::string, Collada::EffectParam> ParamLibrary;
 | 
			
		||||
    ParamLibrary mParams;
 | 
			
		||||
 | 
			
		||||
    // MAX3D extensions
 | 
			
		||||
    // ---------------------------------------------------------
 | 
			
		||||
    // Double-sided?
 | 
			
		||||
    bool mDoubleSided, mWireframe, mFaceted;
 | 
			
		||||
 | 
			
		||||
    Effect()
 | 
			
		||||
        : mShadeType    (Shade_Phong)
 | 
			
		||||
        , mEmissive     ( 0, 0, 0, 1)
 | 
			
		||||
        , mAmbient      ( 0.1f, 0.1f, 0.1f, 1)
 | 
			
		||||
        , mDiffuse      ( 0.6f, 0.6f, 0.6f, 1)
 | 
			
		||||
        , mSpecular     ( 0.4f, 0.4f, 0.4f, 1)
 | 
			
		||||
        , mTransparent  ( 0, 0, 0, 1)
 | 
			
		||||
        , mShininess    (10.0f)
 | 
			
		||||
        , mRefractIndex (1.f)
 | 
			
		||||
        , mReflectivity (0.f)
 | 
			
		||||
        , mTransparency (1.f)
 | 
			
		||||
        , mHasTransparency (false)
 | 
			
		||||
        , mRGBTransparency(false)
 | 
			
		||||
        , mInvertTransparency(false)
 | 
			
		||||
        , mDoubleSided  (false)
 | 
			
		||||
        , mWireframe    (false)
 | 
			
		||||
        , mFaceted      (false)
 | 
			
		||||
    {
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/** An image, meaning texture */
 | 
			
		||||
struct Image
 | 
			
		||||
{
 | 
			
		||||
    std::string mFileName;
 | 
			
		||||
 | 
			
		||||
    /** Embedded image data */
 | 
			
		||||
    std::vector<uint8_t> mImageData;
 | 
			
		||||
 | 
			
		||||
    /** File format hint ofembedded image data */
 | 
			
		||||
    std::string mEmbeddedFormat;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/** An animation channel. */
 | 
			
		||||
struct AnimationChannel
 | 
			
		||||
{
 | 
			
		||||
    /** URL of the data to animate. Could be about anything, but we support only the
 | 
			
		||||
     * "NodeID/TransformID.SubElement" notation
 | 
			
		||||
     */
 | 
			
		||||
    std::string mTarget;
 | 
			
		||||
 | 
			
		||||
    /** Source URL of the time values. Collada calls them "input". Meh. */
 | 
			
		||||
    std::string mSourceTimes;
 | 
			
		||||
    /** Source URL of the value values. Collada calls them "output". */
 | 
			
		||||
    std::string mSourceValues;
 | 
			
		||||
    /** Source URL of the IN_TANGENT semantic values. */
 | 
			
		||||
    std::string mInTanValues;
 | 
			
		||||
    /** Source URL of the OUT_TANGENT semantic values. */
 | 
			
		||||
    std::string mOutTanValues;
 | 
			
		||||
    /** Source URL of the INTERPOLATION semantic values. */
 | 
			
		||||
    std::string mInterpolationValues;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/** An animation. Container for 0-x animation channels or 0-x animations */
 | 
			
		||||
struct Animation
 | 
			
		||||
{
 | 
			
		||||
    /** Anim name */
 | 
			
		||||
    std::string mName;
 | 
			
		||||
 | 
			
		||||
    /** the animation channels, if any */
 | 
			
		||||
    std::vector<AnimationChannel> mChannels;
 | 
			
		||||
 | 
			
		||||
    /** the sub-animations, if any */
 | 
			
		||||
    std::vector<Animation*> mSubAnims;
 | 
			
		||||
 | 
			
		||||
    /** Destructor */
 | 
			
		||||
    ~Animation()
 | 
			
		||||
    {
 | 
			
		||||
        for( std::vector<Animation*>::iterator it = mSubAnims.begin(); it != mSubAnims.end(); ++it)
 | 
			
		||||
            delete *it;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
	/** Collect all channels in the animation hierarchy into a single channel list. */
 | 
			
		||||
	void CollectChannelsRecursively(std::vector<AnimationChannel> &channels)
 | 
			
		||||
	{
 | 
			
		||||
		channels.insert(channels.end(), mChannels.begin(), mChannels.end());
 | 
			
		||||
 | 
			
		||||
		for (std::vector<Animation*>::iterator it = mSubAnims.begin(); it != mSubAnims.end(); ++it)
 | 
			
		||||
		{
 | 
			
		||||
			Animation *pAnim = (*it);
 | 
			
		||||
 | 
			
		||||
			pAnim->CollectChannelsRecursively(channels);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/** Combine all single-channel animations' channel into the same (parent) animation channel list. */
 | 
			
		||||
	void CombineSingleChannelAnimations()
 | 
			
		||||
	{
 | 
			
		||||
		CombineSingleChannelAnimationsRecursively(this);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	void CombineSingleChannelAnimationsRecursively(Animation *pParent)
 | 
			
		||||
	{
 | 
			
		||||
		for (std::vector<Animation*>::iterator it = pParent->mSubAnims.begin(); it != pParent->mSubAnims.end();)
 | 
			
		||||
		{
 | 
			
		||||
			Animation *anim = *it;
 | 
			
		||||
 | 
			
		||||
			CombineSingleChannelAnimationsRecursively(anim);
 | 
			
		||||
 | 
			
		||||
			if (anim->mChannels.size() == 1)
 | 
			
		||||
			{
 | 
			
		||||
				pParent->mChannels.push_back(anim->mChannels[0]);
 | 
			
		||||
 | 
			
		||||
				it = pParent->mSubAnims.erase(it);
 | 
			
		||||
 | 
			
		||||
				delete anim;
 | 
			
		||||
			}
 | 
			
		||||
			else
 | 
			
		||||
			{
 | 
			
		||||
				++it;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/** Description of a collada animation channel which has been determined to affect the current node */
 | 
			
		||||
struct ChannelEntry
 | 
			
		||||
{
 | 
			
		||||
    const Collada::AnimationChannel* mChannel; ///> the source channel
 | 
			
		||||
    std::string mTargetId;
 | 
			
		||||
    std::string mTransformId;   // the ID of the transformation step of the node which is influenced
 | 
			
		||||
    size_t mTransformIndex; // Index into the node's transform chain to apply the channel to
 | 
			
		||||
    size_t mSubElement; // starting index inside the transform data
 | 
			
		||||
 | 
			
		||||
    // resolved data references
 | 
			
		||||
    const Collada::Accessor* mTimeAccessor; ///> Collada accessor to the time values
 | 
			
		||||
    const Collada::Data* mTimeData; ///> Source data array for the time values
 | 
			
		||||
    const Collada::Accessor* mValueAccessor; ///> Collada accessor to the key value values
 | 
			
		||||
    const Collada::Data* mValueData; ///> Source datat array for the key value values
 | 
			
		||||
 | 
			
		||||
    ChannelEntry()
 | 
			
		||||
      : mChannel()
 | 
			
		||||
      , mTransformIndex()
 | 
			
		||||
      , mSubElement()
 | 
			
		||||
      , mTimeAccessor()
 | 
			
		||||
      , mTimeData()
 | 
			
		||||
      , mValueAccessor()
 | 
			
		||||
      , mValueData()
 | 
			
		||||
   {}
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
} // end of namespace Collada
 | 
			
		||||
} // end of namespace Assimp
 | 
			
		||||
 | 
			
		||||
#endif // AI_COLLADAHELPER_H_INC
 | 
			
		||||
							
								
								
									
										1961
									
								
								thirdparty/assimp/code/Collada/ColladaLoader.cpp
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1961
									
								
								thirdparty/assimp/code/Collada/ColladaLoader.cpp
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										259
									
								
								thirdparty/assimp/code/Collada/ColladaLoader.h
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										259
									
								
								thirdparty/assimp/code/Collada/ColladaLoader.h
									
									
									
									
										vendored
									
									
								
							@@ -1,259 +0,0 @@
 | 
			
		||||
/** Defines the collada loader class */
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
Open Asset Import Library (assimp)
 | 
			
		||||
----------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
Copyright (c) 2006-2019, 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 AI_COLLADALOADER_H_INC
 | 
			
		||||
#define AI_COLLADALOADER_H_INC
 | 
			
		||||
 | 
			
		||||
#include <assimp/BaseImporter.h>
 | 
			
		||||
#include "ColladaParser.h"
 | 
			
		||||
 | 
			
		||||
struct aiNode;
 | 
			
		||||
struct aiCamera;
 | 
			
		||||
struct aiLight;
 | 
			
		||||
struct aiTexture;
 | 
			
		||||
struct aiAnimation;
 | 
			
		||||
 | 
			
		||||
namespace Assimp
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
struct ColladaMeshIndex
 | 
			
		||||
{
 | 
			
		||||
    std::string mMeshID;
 | 
			
		||||
    size_t mSubMesh;
 | 
			
		||||
    std::string mMaterial;
 | 
			
		||||
    ColladaMeshIndex( const std::string& pMeshID, size_t pSubMesh, const std::string& pMaterial)
 | 
			
		||||
        : mMeshID( pMeshID), mSubMesh( pSubMesh), mMaterial( pMaterial)
 | 
			
		||||
    {   }
 | 
			
		||||
 | 
			
		||||
    bool operator < (const ColladaMeshIndex& p) const
 | 
			
		||||
    {
 | 
			
		||||
        if( mMeshID == p.mMeshID)
 | 
			
		||||
        {
 | 
			
		||||
            if( mSubMesh == p.mSubMesh)
 | 
			
		||||
                return mMaterial < p.mMaterial;
 | 
			
		||||
            else
 | 
			
		||||
                return mSubMesh < p.mSubMesh;
 | 
			
		||||
        } else
 | 
			
		||||
        {
 | 
			
		||||
            return mMeshID < p.mMeshID;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/** Loader class to read Collada scenes. Collada is over-engineered to death, with every new iteration bringing
 | 
			
		||||
 * more useless stuff, so I limited the data to what I think is useful for games.
 | 
			
		||||
*/
 | 
			
		||||
class ColladaLoader : public BaseImporter
 | 
			
		||||
{
 | 
			
		||||
public:
 | 
			
		||||
    ColladaLoader();
 | 
			
		||||
    ~ColladaLoader();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
    /** Returns whether the class can handle the format of the given file.
 | 
			
		||||
     * See BaseImporter::CanRead() for details. */
 | 
			
		||||
    bool CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const override;
 | 
			
		||||
 | 
			
		||||
protected:
 | 
			
		||||
    /** Return importer meta information.
 | 
			
		||||
     * See #BaseImporter::GetInfo for the details
 | 
			
		||||
     */
 | 
			
		||||
    const aiImporterDesc* GetInfo () const override;
 | 
			
		||||
 | 
			
		||||
    void SetupProperties(const Importer* pImp) override;
 | 
			
		||||
 | 
			
		||||
    /** Imports the given file into the given scene structure.
 | 
			
		||||
     * See BaseImporter::InternReadFile() for details
 | 
			
		||||
     */
 | 
			
		||||
    void InternReadFile( const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler) override;
 | 
			
		||||
 | 
			
		||||
    /** Recursively constructs a scene node for the given parser node and returns it. */
 | 
			
		||||
    aiNode* BuildHierarchy( const ColladaParser& pParser, const Collada::Node* pNode);
 | 
			
		||||
 | 
			
		||||
    /** Resolve node instances */
 | 
			
		||||
    void ResolveNodeInstances( const ColladaParser& pParser, const Collada::Node* pNode,
 | 
			
		||||
        std::vector<const Collada::Node*>& resolved);
 | 
			
		||||
 | 
			
		||||
    /** Builds meshes for the given node and references them */
 | 
			
		||||
    void BuildMeshesForNode( const ColladaParser& pParser, const Collada::Node* pNode,
 | 
			
		||||
        aiNode* pTarget);
 | 
			
		||||
		
 | 
			
		||||
    aiMesh *findMesh(const std::string& meshid);
 | 
			
		||||
 | 
			
		||||
    /** Creates a mesh for the given ColladaMesh face subset and returns the newly created mesh */
 | 
			
		||||
    aiMesh* CreateMesh( const ColladaParser& pParser, const Collada::Mesh* pSrcMesh, const Collada::SubMesh& pSubMesh,
 | 
			
		||||
        const Collada::Controller* pSrcController, size_t pStartVertex, size_t pStartFace);
 | 
			
		||||
 | 
			
		||||
    /** Builds cameras for the given node and references them */
 | 
			
		||||
    void BuildCamerasForNode( const ColladaParser& pParser, const Collada::Node* pNode,
 | 
			
		||||
        aiNode* pTarget);
 | 
			
		||||
 | 
			
		||||
    /** Builds lights for the given node and references them */
 | 
			
		||||
    void BuildLightsForNode( const ColladaParser& pParser, const Collada::Node* pNode,
 | 
			
		||||
        aiNode* pTarget);
 | 
			
		||||
 | 
			
		||||
    /** Stores all meshes in the given scene */
 | 
			
		||||
    void StoreSceneMeshes( aiScene* pScene);
 | 
			
		||||
 | 
			
		||||
    /** Stores all materials in the given scene */
 | 
			
		||||
    void StoreSceneMaterials( aiScene* pScene);
 | 
			
		||||
 | 
			
		||||
    /** Stores all lights in the given scene */
 | 
			
		||||
    void StoreSceneLights( aiScene* pScene);
 | 
			
		||||
 | 
			
		||||
    /** Stores all cameras in the given scene */
 | 
			
		||||
    void StoreSceneCameras( aiScene* pScene);
 | 
			
		||||
 | 
			
		||||
    /** Stores all textures in the given scene */
 | 
			
		||||
    void StoreSceneTextures( aiScene* pScene);
 | 
			
		||||
 | 
			
		||||
    /** Stores all animations
 | 
			
		||||
     * @param pScene target scene to store the anims
 | 
			
		||||
     */
 | 
			
		||||
    void StoreAnimations( aiScene* pScene, const ColladaParser& pParser);
 | 
			
		||||
 | 
			
		||||
    /** Stores all animations for the given source anim and its nested child animations
 | 
			
		||||
     * @param pScene target scene to store the anims
 | 
			
		||||
     * @param pSrcAnim the source animation to process
 | 
			
		||||
     * @param pPrefix Prefix to the name in case of nested animations
 | 
			
		||||
     */
 | 
			
		||||
    void StoreAnimations( aiScene* pScene, const ColladaParser& pParser, const Collada::Animation* pSrcAnim, const std::string& pPrefix);
 | 
			
		||||
 | 
			
		||||
    /** Constructs the animation for the given source anim */
 | 
			
		||||
    void CreateAnimation( aiScene* pScene, const ColladaParser& pParser, const Collada::Animation* pSrcAnim, const std::string& pName);
 | 
			
		||||
 | 
			
		||||
    /** Constructs materials from the collada material definitions */
 | 
			
		||||
    void BuildMaterials( ColladaParser& pParser, aiScene* pScene);
 | 
			
		||||
 | 
			
		||||
    /** Fill materials from the collada material definitions */
 | 
			
		||||
    void FillMaterials( const ColladaParser& pParser, aiScene* pScene);
 | 
			
		||||
 | 
			
		||||
    /** Resolve UV channel mappings*/
 | 
			
		||||
    void ApplyVertexToEffectSemanticMapping(Collada::Sampler& sampler,
 | 
			
		||||
        const Collada::SemanticMappingTable& table);
 | 
			
		||||
 | 
			
		||||
    /** Add a texture and all of its sampling properties to a material*/
 | 
			
		||||
    void AddTexture ( aiMaterial& mat, const ColladaParser& pParser,
 | 
			
		||||
        const Collada::Effect& effect,
 | 
			
		||||
        const Collada::Sampler& sampler,
 | 
			
		||||
        aiTextureType type, unsigned int idx = 0);
 | 
			
		||||
 | 
			
		||||
    /** Resolves the texture name for the given effect texture entry */
 | 
			
		||||
    aiString FindFilenameForEffectTexture( const ColladaParser& pParser,
 | 
			
		||||
        const Collada::Effect& pEffect, const std::string& pName);
 | 
			
		||||
 | 
			
		||||
    /** Converts a path read from a collada file to the usual representation */
 | 
			
		||||
    void ConvertPath( aiString& ss);
 | 
			
		||||
 | 
			
		||||
    /** Reads a float value from an accessor and its data array.
 | 
			
		||||
     * @param pAccessor The accessor to use for reading
 | 
			
		||||
     * @param pData The data array to read from
 | 
			
		||||
     * @param pIndex The index of the element to retrieve
 | 
			
		||||
     * @param pOffset Offset into the element, for multipart elements such as vectors or matrices
 | 
			
		||||
     * @return the specified value
 | 
			
		||||
     */
 | 
			
		||||
    ai_real ReadFloat( const Collada::Accessor& pAccessor, const Collada::Data& pData, size_t pIndex, size_t pOffset) const;
 | 
			
		||||
 | 
			
		||||
    /** Reads a string value from an accessor and its data array.
 | 
			
		||||
     * @param pAccessor The accessor to use for reading
 | 
			
		||||
     * @param pData The data array to read from
 | 
			
		||||
     * @param pIndex The index of the element to retrieve
 | 
			
		||||
     * @return the specified value
 | 
			
		||||
     */
 | 
			
		||||
    const std::string& ReadString( const Collada::Accessor& pAccessor, const Collada::Data& pData, size_t pIndex) const;
 | 
			
		||||
 | 
			
		||||
    /** Recursively collects all nodes into the given array */
 | 
			
		||||
    void CollectNodes( const aiNode* pNode, std::vector<const aiNode*>& poNodes) const;
 | 
			
		||||
 | 
			
		||||
    /** Finds a node in the collada scene by the given name */
 | 
			
		||||
    const Collada::Node* FindNode( const Collada::Node* pNode, const std::string& pName) const;
 | 
			
		||||
    /** Finds a node in the collada scene by the given SID */
 | 
			
		||||
    const Collada::Node* FindNodeBySID( const Collada::Node* pNode, const std::string& pSID) const;
 | 
			
		||||
 | 
			
		||||
    /** Finds a proper name for a node derived from the collada-node's properties */
 | 
			
		||||
    std::string FindNameForNode( const Collada::Node* pNode);
 | 
			
		||||
 | 
			
		||||
protected:
 | 
			
		||||
    /** Filename, for a verbose error message */
 | 
			
		||||
    std::string mFileName;
 | 
			
		||||
 | 
			
		||||
    /** Which mesh-material compound was stored under which mesh ID */
 | 
			
		||||
    std::map<ColladaMeshIndex, size_t> mMeshIndexByID;
 | 
			
		||||
 | 
			
		||||
    /** Which material was stored under which index in the scene */
 | 
			
		||||
    std::map<std::string, size_t> mMaterialIndexByName;
 | 
			
		||||
 | 
			
		||||
    /** Accumulated meshes for the target scene */
 | 
			
		||||
    std::vector<aiMesh*> mMeshes;
 | 
			
		||||
	
 | 
			
		||||
    /** Accumulated morph target meshes */
 | 
			
		||||
    std::vector<aiMesh*> mTargetMeshes;
 | 
			
		||||
 | 
			
		||||
    /** Temporary material list */
 | 
			
		||||
    std::vector<std::pair<Collada::Effect*, aiMaterial*> > newMats;
 | 
			
		||||
 | 
			
		||||
    /** Temporary camera list */
 | 
			
		||||
    std::vector<aiCamera*> mCameras;
 | 
			
		||||
 | 
			
		||||
    /** Temporary light list */
 | 
			
		||||
    std::vector<aiLight*> mLights;
 | 
			
		||||
 | 
			
		||||
    /** Temporary texture list */
 | 
			
		||||
    std::vector<aiTexture*> mTextures;
 | 
			
		||||
 | 
			
		||||
    /** Accumulated animations for the target scene */
 | 
			
		||||
    std::vector<aiAnimation*> mAnims;
 | 
			
		||||
 | 
			
		||||
    bool noSkeletonMesh;
 | 
			
		||||
    bool ignoreUpDirection;
 | 
			
		||||
    bool useColladaName;
 | 
			
		||||
 | 
			
		||||
    /** Used by FindNameForNode() to generate unique node names */
 | 
			
		||||
    unsigned int mNodeNameCounter;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
} // end of namespace Assimp
 | 
			
		||||
 | 
			
		||||
#endif // AI_COLLADALOADER_H_INC
 | 
			
		||||
							
								
								
									
										3409
									
								
								thirdparty/assimp/code/Collada/ColladaParser.cpp
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										3409
									
								
								thirdparty/assimp/code/Collada/ColladaParser.cpp
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										393
									
								
								thirdparty/assimp/code/Collada/ColladaParser.h
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										393
									
								
								thirdparty/assimp/code/Collada/ColladaParser.h
									
									
									
									
										vendored
									
									
								
							@@ -1,393 +0,0 @@
 | 
			
		||||
/*
 | 
			
		||||
 Open Asset Import Library (assimp)
 | 
			
		||||
 ----------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
 Copyright (c) 2006-2019, 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 <assimp/irrXMLWrapper.h>
 | 
			
		||||
#include "ColladaHelper.h"
 | 
			
		||||
#include <assimp/ai_assert.h>
 | 
			
		||||
#include <assimp/TinyFormatter.h>
 | 
			
		||||
 | 
			
		||||
namespace Assimp
 | 
			
		||||
{
 | 
			
		||||
    class ZipArchiveIOSystem;
 | 
			
		||||
 | 
			
		||||
    // ------------------------------------------------------------------------------------------
 | 
			
		||||
    /** 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:
 | 
			
		||||
        /** Map for generic metadata as aiString */
 | 
			
		||||
        typedef std::map<std::string, aiString> StringMetaData;
 | 
			
		||||
 | 
			
		||||
        /** Constructor from XML file */
 | 
			
		||||
        ColladaParser( IOSystem* pIOHandler, const std::string& pFile);
 | 
			
		||||
 | 
			
		||||
        /** Destructor */
 | 
			
		||||
        ~ColladaParser();
 | 
			
		||||
 | 
			
		||||
        /** Attempts to read the ZAE manifest and returns the DAE to open */
 | 
			
		||||
        static std::string ReadZaeManifest(ZipArchiveIOSystem &zip_archive);
 | 
			
		||||
 | 
			
		||||
        /** Reads the contents of the file */
 | 
			
		||||
        void ReadContents();
 | 
			
		||||
 | 
			
		||||
        /** Reads the structure of the file */
 | 
			
		||||
        void ReadStructure();
 | 
			
		||||
 | 
			
		||||
        /** Reads asset information such as coordinate system information and legal blah */
 | 
			
		||||
        void ReadAssetInfo();
 | 
			
		||||
 | 
			
		||||
        /** Reads contributor information such as author and legal blah */
 | 
			
		||||
        void ReadContributorInfo();
 | 
			
		||||
 | 
			
		||||
        /** Reads generic metadata into provided map */
 | 
			
		||||
        void ReadMetaDataItem(StringMetaData &metadata);
 | 
			
		||||
 | 
			
		||||
        /** Convert underscore_seperated to CamelCase "authoring_tool" becomes "AuthoringTool" */
 | 
			
		||||
        static void ToCamelCase(std::string &text);
 | 
			
		||||
 | 
			
		||||
        /** Reads the animation library */
 | 
			
		||||
        void ReadAnimationLibrary();
 | 
			
		||||
 | 
			
		||||
		/** Reads the animation clip library */
 | 
			
		||||
		void ReadAnimationClipLibrary();
 | 
			
		||||
 | 
			
		||||
        /** Unwrap controllers dependency hierarchy */
 | 
			
		||||
        void PostProcessControllers();
 | 
			
		||||
    
 | 
			
		||||
		/** Re-build animations from animation clip library, if present, otherwise combine single-channel animations */
 | 
			
		||||
		void PostProcessRootAnimations();
 | 
			
		||||
 | 
			
		||||
        /** 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( ai_real& 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);
 | 
			
		||||
 | 
			
		||||
        /** Reads embedded textures from a ZAE archive*/
 | 
			
		||||
        void ReadEmbeddedTextures(ZipArchiveIOSystem &zip_archive);
 | 
			
		||||
 | 
			
		||||
    protected:
 | 
			
		||||
        /** 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 */
 | 
			
		||||
        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 */
 | 
			
		||||
        ai_real 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;
 | 
			
		||||
 | 
			
		||||
		/** Animation library: animation references by ID */
 | 
			
		||||
		typedef std::map<std::string, Collada::Animation*> AnimationLibrary;
 | 
			
		||||
		AnimationLibrary mAnimationLibrary;
 | 
			
		||||
 | 
			
		||||
		/** Animation clip library: clip animation references by ID */
 | 
			
		||||
		typedef std::vector<std::pair<std::string, std::vector<std::string> > > AnimationClipLibrary;
 | 
			
		||||
		AnimationClipLibrary mAnimationClipLibrary;
 | 
			
		||||
 | 
			
		||||
        /** 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 */
 | 
			
		||||
        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())
 | 
			
		||||
            ThrowException( Formatter::format() << "Unable to resolve library reference \"" << pURL << "\"." );
 | 
			
		||||
        return it->second;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
} // end of namespace Assimp
 | 
			
		||||
 | 
			
		||||
#endif // AI_COLLADAPARSER_H_INC
 | 
			
		||||
		Reference in New Issue
	
	Block a user