ColladaLoader.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /** Defines the collada loader class */
  2. /*
  3. Open Asset Import Library (ASSIMP)
  4. ----------------------------------------------------------------------
  5. Copyright (c) 2006-2008, ASSIMP Development Team
  6. All rights reserved.
  7. Redistribution and use of this software in source and binary forms,
  8. with or without modification, are permitted provided that the
  9. following conditions are met:
  10. * Redistributions of source code must retain the above
  11. copyright notice, this list of conditions and the
  12. following disclaimer.
  13. * Redistributions in binary form must reproduce the above
  14. copyright notice, this list of conditions and the
  15. following disclaimer in the documentation and/or other
  16. materials provided with the distribution.
  17. * Neither the name of the ASSIMP team, nor the names of its
  18. contributors may be used to endorse or promote products
  19. derived from this software without specific prior
  20. written permission of the ASSIMP Development Team.
  21. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  24. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  25. OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  26. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  27. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  28. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  29. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  30. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  31. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. ----------------------------------------------------------------------
  33. */
  34. #ifndef AI_COLLADALOADER_H_INC
  35. #define AI_COLLADALOADER_H_INC
  36. #include "BaseImporter.h"
  37. #include "ColladaParser.h"
  38. namespace Assimp
  39. {
  40. /** Loader class to read Collada scenes. Collada is over-engineered to death, with every new iteration bringing
  41. * more useless stuff, so I limited the data to what I think is useful for games.
  42. */
  43. class ColladaLoader : public BaseImporter
  44. {
  45. friend class Importer;
  46. protected:
  47. /** Constructor to be privately used by Importer */
  48. ColladaLoader();
  49. /** Destructor, private as well */
  50. ~ColladaLoader();
  51. public:
  52. /** Returns whether the class can handle the format of the given file.
  53. * See BaseImporter::CanRead() for details. */
  54. bool CanRead( const std::string& pFile, IOSystem* pIOHandler) const;
  55. protected:
  56. /** Called by Importer::GetExtensionList() for each loaded importer.
  57. * See BaseImporter::GetExtensionList() for details
  58. */
  59. void GetExtensionList( std::string& append)
  60. {
  61. append.append("*.dae");
  62. }
  63. /** Imports the given file into the given scene structure.
  64. * See BaseImporter::InternReadFile() for details
  65. */
  66. void InternReadFile( const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler);
  67. /** Recursively constructs a scene node for the given parser node and returns it. */
  68. aiNode* BuildHierarchy( const ColladaParser& pParser, const Collada::Node* pNode);
  69. /** Builds meshes for the given node and references them */
  70. void BuildMeshesForNode( const ColladaParser& pParser, const Collada::Node* pNode, aiNode* pTarget);
  71. /** Stores all meshes in the given scene */
  72. void StoreSceneMeshes( aiScene* pScene);
  73. protected:
  74. /** Filename, for a verbose error message */
  75. std::string mFileName;
  76. /** Which mesh-material compound was stored under which mesh ID */
  77. std::map<std::string, size_t> mMeshIndexbyID;
  78. /** Accumulated meshes for the target scene */
  79. std::vector<aiMesh*> mMeshes;
  80. };
  81. } // end of namespace Assimp
  82. #endif // AI_COLLADALOADER_H_INC