Assimp  v4.1. (December 2018)
Assimp::ColladaLoader Class Reference

Loader class to read Collada scenes. More...

Inherits Assimp::BaseImporter.

Public Member Functions

bool CanRead (const std::string &pFile, IOSystem *pIOHandler, bool checkSig) const
 Returns whether the class can handle the format of the given file. More...
 
 ColladaLoader ()
 
 ~ColladaLoader ()
 
- Public Member Functions inherited from Assimp::BaseImporter
 BaseImporter ()
 Constructor to be privately used by Importer. More...
 
const std::string & GetErrorText () const
 Returns the error description of the last error that occurred. More...
 
void GetExtensionList (std::set< std::string > &extensions)
 Called by #Importer::GetExtensionList for each loaded importer. More...
 
aiSceneReadFile (const Importer *pImp, const std::string &pFile, IOSystem *pIOHandler)
 Imports the given file and returns the imported data. More...
 
virtual ~BaseImporter ()
 Destructor, private as well. More...
 

Protected Member Functions

void AddTexture (aiMaterial &mat, const ColladaParser &pParser, const Collada::Effect &effect, const Collada::Sampler &sampler, aiTextureType type, unsigned int idx=0)
 Add a texture and all of its sampling properties to a material. More...
 
void ApplyVertexToEffectSemanticMapping (Collada::Sampler &sampler, const Collada::SemanticMappingTable &table)
 Resolve UV channel mappings. More...
 
void BuildCamerasForNode (const ColladaParser &pParser, const Collada::Node *pNode, aiNode *pTarget)
 Builds cameras for the given node and references them. More...
 
aiNodeBuildHierarchy (const ColladaParser &pParser, const Collada::Node *pNode)
 Recursively constructs a scene node for the given parser node and returns it. More...
 
void BuildLightsForNode (const ColladaParser &pParser, const Collada::Node *pNode, aiNode *pTarget)
 Builds lights for the given node and references them. More...
 
void BuildMaterials (ColladaParser &pParser, aiScene *pScene)
 Constructs materials from the collada material definitions. More...
 
void BuildMeshesForNode (const ColladaParser &pParser, const Collada::Node *pNode, aiNode *pTarget)
 Builds meshes for the given node and references them. More...
 
void CollectNodes (const aiNode *pNode, std::vector< const aiNode * > &poNodes) const
 Recursively collects all nodes into the given array. More...
 
void ConvertPath (aiString &ss)
 Converts a path read from a collada file to the usual representation. More...
 
void CreateAnimation (aiScene *pScene, const ColladaParser &pParser, const Collada::Animation *pSrcAnim, const std::string &pName)
 Constructs the animation for the given source anim. More...
 
aiMeshCreateMesh (const ColladaParser &pParser, const Collada::Mesh *pSrcMesh, const Collada::SubMesh &pSubMesh, const Collada::Controller *pSrcController, size_t pStartVertex, size_t pStartFace)
 Creates a mesh for the given ColladaMesh face subset and returns the newly created mesh. More...
 
void FillMaterials (const ColladaParser &pParser, aiScene *pScene)
 Fill materials from the collada material definitions. More...
 
aiString FindFilenameForEffectTexture (const ColladaParser &pParser, const Collada::Effect &pEffect, const std::string &pName)
 Resolves the texture name for the given effect texture entry. More...
 
aiMeshfindMesh (std::string meshid)
 
std::string FindNameForNode (const Collada::Node *pNode)
 Finds a proper name for a node derived from the collada-node's properties. More...
 
const Collada::NodeFindNode (const Collada::Node *pNode, const std::string &pName) const
 Finds a node in the collada scene by the given name. More...
 
const Collada::NodeFindNodeBySID (const Collada::Node *pNode, const std::string &pSID) const
 Finds a node in the collada scene by the given SID. More...
 
const aiImporterDescGetInfo () const
 Return importer meta information. More...
 
void InternReadFile (const std::string &pFile, aiScene *pScene, IOSystem *pIOHandler)
 Imports the given file into the given scene structure. More...
 
ai_real ReadFloat (const Collada::Accessor &pAccessor, const Collada::Data &pData, size_t pIndex, size_t pOffset) const
 Reads a float value from an accessor and its data array. More...
 
const std::string & ReadString (const Collada::Accessor &pAccessor, const Collada::Data &pData, size_t pIndex) const
 Reads a string value from an accessor and its data array. More...
 
void ResolveNodeInstances (const ColladaParser &pParser, const Collada::Node *pNode, std::vector< const Collada::Node * > &resolved)
 Resolve node instances. More...
 
void SetupProperties (const Importer *pImp)
 Called prior to ReadFile(). More...
 
void StoreAnimations (aiScene *pScene, const ColladaParser &pParser)
 Stores all animations. More...
 
void StoreAnimations (aiScene *pScene, const ColladaParser &pParser, const Collada::Animation *pSrcAnim, const std::string &pPrefix)
 Stores all animations for the given source anim and its nested child animations. More...
 
void StoreSceneCameras (aiScene *pScene)
 Stores all cameras in the given scene. More...
 
void StoreSceneLights (aiScene *pScene)
 Stores all lights in the given scene. More...
 
void StoreSceneMaterials (aiScene *pScene)
 Stores all materials in the given scene. More...
 
void StoreSceneMeshes (aiScene *pScene)
 Stores all meshes in the given scene. More...
 
void StoreSceneTextures (aiScene *pScene)
 Stores all textures in the given scene. More...
 

Protected Attributes

bool ignoreUpDirection
 
std::vector< aiAnimation * > mAnims
 Accumulated animations for the target scene. More...
 
std::vector< aiCamera * > mCameras
 Temporary camera list. More...
 
std::string mFileName
 Filename, for a verbose error message. More...
 
std::vector< aiLight * > mLights
 Temporary light list. More...
 
std::map< std::string, size_t > mMaterialIndexByName
 Which material was stored under which index in the scene. More...
 
std::vector< aiMesh * > mMeshes
 Accumulated meshes for the target scene. More...
 
std::map< ColladaMeshIndex, size_t > mMeshIndexByID
 Which mesh-material compound was stored under which mesh ID. More...
 
unsigned int mNodeNameCounter
 Used by FindNameForNode() to generate unique node names. More...
 
std::vector< aiMesh * > mTargetMeshes
 Accumulated morph target meshes. More...
 
std::vector< aiTexture * > mTextures
 Temporary texture list. More...
 
std::vector< std::pair< Collada::Effect *, aiMaterial * > > newMats
 Temporary material list. More...
 
bool noSkeletonMesh
 
- Protected Attributes inherited from Assimp::BaseImporter
std::string m_ErrorText
 Error description in case there was one. More...
 
ProgressHandlerm_progress
 Currently set progress handler. More...
 

Additional Inherited Members

- Public Types inherited from Assimp::BaseImporter
enum  TextFileMode { ALLOW_EMPTY, FORBID_EMPTY }
 Enum to define, if empty files are ok or not. More...
 
- Static Public Member Functions inherited from Assimp::BaseImporter
static bool CheckMagicToken (IOSystem *pIOHandler, const std::string &pFile, const void *magic, unsigned int num, unsigned int offset=0, unsigned int size=4)
 Check whether a file starts with one or more magic tokens. More...
 
static void ConvertToUTF8 (std::vector< char > &data)
 An utility for all text file loaders. More...
 
static void ConvertUTF8toISO8859_1 (std::string &data)
 An utility for all text file loaders. More...
 
template<typename T >
static AI_FORCE_INLINE void CopyVector (std::vector< T > &vec, T *&out, unsigned int &outLength)
 Utility function to move a std::vector into a aiScene array. More...
 
static std::string GetExtension (const std::string &pFile)
 Extract file extension from a string. More...
 
static bool SearchFileHeaderForToken (IOSystem *pIOSystem, const std::string &file, const char **tokens, unsigned int numTokens, unsigned int searchBytes=200, bool tokensSol=false)
 A utility for CanRead(). More...
 
static bool SimpleExtensionCheck (const std::string &pFile, const char *ext0, const char *ext1=NULL, const char *ext2=NULL)
 Check whether a file has a specific file extension. More...
 
static void TextFileToBuffer (IOStream *stream, std::vector< char > &data, TextFileMode mode=FORBID_EMPTY)
 Utility for text file loaders which copies the contents of the file into a memory buffer and converts it to our UTF8 representation. More...
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ ColladaLoader()

ColladaLoader::ColladaLoader ( )

◆ ~ColladaLoader()

ColladaLoader::~ColladaLoader ( )

Member Function Documentation

◆ AddTexture()

void ColladaLoader::AddTexture ( aiMaterial mat,
const ColladaParser pParser,
const Collada::Effect effect,
const Collada::Sampler sampler,
aiTextureType  type,
unsigned int  idx = 0 
)
protected

Add a texture and all of its sampling properties to a material.

◆ ApplyVertexToEffectSemanticMapping()

void ColladaLoader::ApplyVertexToEffectSemanticMapping ( Collada::Sampler sampler,
const Collada::SemanticMappingTable table 
)
protected

Resolve UV channel mappings.

◆ BuildCamerasForNode()

void ColladaLoader::BuildCamerasForNode ( const ColladaParser pParser,
const Collada::Node pNode,
aiNode pTarget 
)
protected

Builds cameras for the given node and references them.

◆ BuildHierarchy()

aiNode * ColladaLoader::BuildHierarchy ( const ColladaParser pParser,
const Collada::Node pNode 
)
protected

Recursively constructs a scene node for the given parser node and returns it.

◆ BuildLightsForNode()

void ColladaLoader::BuildLightsForNode ( const ColladaParser pParser,
const Collada::Node pNode,
aiNode pTarget 
)
protected

Builds lights for the given node and references them.

◆ BuildMaterials()

void ColladaLoader::BuildMaterials ( ColladaParser pParser,
aiScene pScene 
)
protected

Constructs materials from the collada material definitions.

◆ BuildMeshesForNode()

void ColladaLoader::BuildMeshesForNode ( const ColladaParser pParser,
const Collada::Node pNode,
aiNode pTarget 
)
protected

Builds meshes for the given node and references them.

◆ CanRead()

bool ColladaLoader::CanRead ( const std::string &  pFile,
IOSystem pIOHandler,
bool  checkSig 
) const
virtual

Returns whether the class can handle the format of the given file.

See BaseImporter::CanRead() for details.

Implements Assimp::BaseImporter.

◆ CollectNodes()

void ColladaLoader::CollectNodes ( const aiNode pNode,
std::vector< const aiNode * > &  poNodes 
) const
protected

Recursively collects all nodes into the given array.

◆ ConvertPath()

void ColladaLoader::ConvertPath ( aiString ss)
protected

Converts a path read from a collada file to the usual representation.

◆ CreateAnimation()

void ColladaLoader::CreateAnimation ( aiScene pScene,
const ColladaParser pParser,
const Collada::Animation pSrcAnim,
const std::string &  pName 
)
protected

Constructs the animation for the given source anim.

◆ CreateMesh()

aiMesh * ColladaLoader::CreateMesh ( const ColladaParser pParser,
const Collada::Mesh pSrcMesh,
const Collada::SubMesh pSubMesh,
const Collada::Controller pSrcController,
size_t  pStartVertex,
size_t  pStartFace 
)
protected

Creates a mesh for the given ColladaMesh face subset and returns the newly created mesh.

◆ FillMaterials()

void ColladaLoader::FillMaterials ( const ColladaParser pParser,
aiScene pScene 
)
protected

Fill materials from the collada material definitions.

◆ FindFilenameForEffectTexture()

aiString ColladaLoader::FindFilenameForEffectTexture ( const ColladaParser pParser,
const Collada::Effect pEffect,
const std::string &  pName 
)
protected

Resolves the texture name for the given effect texture entry.

◆ findMesh()

aiMesh * ColladaLoader::findMesh ( std::string  meshid)
protected

◆ FindNameForNode()

std::string ColladaLoader::FindNameForNode ( const Collada::Node pNode)
protected

Finds a proper name for a node derived from the collada-node's properties.

◆ FindNode()

const Collada::Node * ColladaLoader::FindNode ( const Collada::Node pNode,
const std::string &  pName 
) const
protected

Finds a node in the collada scene by the given name.

◆ FindNodeBySID()

const Collada::Node * ColladaLoader::FindNodeBySID ( const Collada::Node pNode,
const std::string &  pSID 
) const
protected

Finds a node in the collada scene by the given SID.

◆ GetInfo()

const aiImporterDesc * ColladaLoader::GetInfo ( ) const
protectedvirtual

Return importer meta information.

See #BaseImporter::GetInfo for the details

Implements Assimp::BaseImporter.

◆ InternReadFile()

void ColladaLoader::InternReadFile ( const std::string &  pFile,
aiScene pScene,
IOSystem pIOHandler 
)
protectedvirtual

Imports the given file into the given scene structure.

See BaseImporter::InternReadFile() for details

Implements Assimp::BaseImporter.

◆ ReadFloat()

ai_real ColladaLoader::ReadFloat ( const Collada::Accessor pAccessor,
const Collada::Data pData,
size_t  pIndex,
size_t  pOffset 
) const
protected

Reads a float value from an accessor and its data array.

Parameters
pAccessorThe accessor to use for reading
pDataThe data array to read from
pIndexThe index of the element to retrieve
pOffsetOffset into the element, for multipart elements such as vectors or matrices
Returns
the specified value

◆ ReadString()

const std::string & ColladaLoader::ReadString ( const Collada::Accessor pAccessor,
const Collada::Data pData,
size_t  pIndex 
) const
protected

Reads a string value from an accessor and its data array.

Parameters
pAccessorThe accessor to use for reading
pDataThe data array to read from
pIndexThe index of the element to retrieve
Returns
the specified value

◆ ResolveNodeInstances()

void ColladaLoader::ResolveNodeInstances ( const ColladaParser pParser,
const Collada::Node pNode,
std::vector< const Collada::Node * > &  resolved 
)
protected

Resolve node instances.

◆ SetupProperties()

void ColladaLoader::SetupProperties ( const Importer pImp)
protectedvirtual

Called prior to ReadFile().

The function is a request to the importer to update its configuration basing on the Importer's configuration property list.

Parameters
pImpImporter instance

Reimplemented from Assimp::BaseImporter.

◆ StoreAnimations() [1/2]

void ColladaLoader::StoreAnimations ( aiScene pScene,
const ColladaParser pParser 
)
protected

Stores all animations.

Parameters
pScenetarget scene to store the anims

◆ StoreAnimations() [2/2]

void ColladaLoader::StoreAnimations ( aiScene pScene,
const ColladaParser pParser,
const Collada::Animation pSrcAnim,
const std::string &  pPrefix 
)
protected

Stores all animations for the given source anim and its nested child animations.

Parameters
pScenetarget scene to store the anims
pSrcAnimthe source animation to process
pPrefixPrefix to the name in case of nested animations

◆ StoreSceneCameras()

void ColladaLoader::StoreSceneCameras ( aiScene pScene)
protected

Stores all cameras in the given scene.

◆ StoreSceneLights()

void ColladaLoader::StoreSceneLights ( aiScene pScene)
protected

Stores all lights in the given scene.

◆ StoreSceneMaterials()

void ColladaLoader::StoreSceneMaterials ( aiScene pScene)
protected

Stores all materials in the given scene.

◆ StoreSceneMeshes()

void ColladaLoader::StoreSceneMeshes ( aiScene pScene)
protected

Stores all meshes in the given scene.

◆ StoreSceneTextures()

void ColladaLoader::StoreSceneTextures ( aiScene pScene)
protected

Stores all textures in the given scene.

Member Data Documentation

◆ ignoreUpDirection

bool Assimp::ColladaLoader::ignoreUpDirection
protected

◆ mAnims

std::vector<aiAnimation*> Assimp::ColladaLoader::mAnims
protected

Accumulated animations for the target scene.

◆ mCameras

std::vector<aiCamera*> Assimp::ColladaLoader::mCameras
protected

Temporary camera list.

◆ mFileName

std::string Assimp::ColladaLoader::mFileName
protected

Filename, for a verbose error message.

◆ mLights

std::vector<aiLight*> Assimp::ColladaLoader::mLights
protected

Temporary light list.

◆ mMaterialIndexByName

std::map<std::string, size_t> Assimp::ColladaLoader::mMaterialIndexByName
protected

Which material was stored under which index in the scene.

◆ mMeshes

std::vector<aiMesh*> Assimp::ColladaLoader::mMeshes
protected

Accumulated meshes for the target scene.

◆ mMeshIndexByID

std::map<ColladaMeshIndex, size_t> Assimp::ColladaLoader::mMeshIndexByID
protected

Which mesh-material compound was stored under which mesh ID.

◆ mNodeNameCounter

unsigned int Assimp::ColladaLoader::mNodeNameCounter
protected

Used by FindNameForNode() to generate unique node names.

◆ mTargetMeshes

std::vector<aiMesh*> Assimp::ColladaLoader::mTargetMeshes
protected

Accumulated morph target meshes.

◆ mTextures

std::vector<aiTexture*> Assimp::ColladaLoader::mTextures
protected

Temporary texture list.

◆ newMats

std::vector<std::pair<Collada::Effect*, aiMaterial*> > Assimp::ColladaLoader::newMats
protected

Temporary material list.

◆ noSkeletonMesh

bool Assimp::ColladaLoader::noSkeletonMesh
protected

The documentation for this class was generated from the following files: