You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

206 line
6.1 KiB

  1. /*
  2. Open Asset Import Library (assimp)
  3. ----------------------------------------------------------------------
  4. Copyright (c) 2006-2012, assimp team
  5. All rights reserved.
  6. Redistribution and use of this software in source and binary forms,
  7. with or without modification, are permitted provided that the
  8. following conditions are met:
  9. * Redistributions of source code must retain the above
  10. copyright notice, this list of conditions and the
  11. following disclaimer.
  12. * Redistributions in binary form must reproduce the above
  13. copyright notice, this list of conditions and the
  14. following disclaimer in the documentation and/or other
  15. materials provided with the distribution.
  16. * Neither the name of the assimp team, nor the names of its
  17. contributors may be used to endorse or promote products
  18. derived from this software without specific prior
  19. written permission of the assimp team.
  20. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  21. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  22. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  23. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  24. OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  25. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  26. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  27. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  28. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  29. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  30. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  31. ----------------------------------------------------------------------
  32. */
  33. /** @file ASELoader.h
  34. * @brief Definition of the .ASE importer class.
  35. */
  36. #ifndef AI_ASELOADER_H_INCLUDED
  37. #define AI_ASELOADER_H_INCLUDED
  38. #include "BaseImporter.h"
  39. #include "../include/assimp/types.h"
  40. struct aiNode;
  41. #include "ASEParser.h"
  42. namespace Assimp {
  43. // --------------------------------------------------------------------------------
  44. /** Importer class for the 3DS ASE ASCII format.
  45. *
  46. */
  47. class ASEImporter : public BaseImporter {
  48. public:
  49. ASEImporter();
  50. ~ASEImporter();
  51. public:
  52. // -------------------------------------------------------------------
  53. /** Returns whether the class can handle the format of the given file.
  54. * See BaseImporter::CanRead() for details.
  55. */
  56. bool CanRead( const std::string& pFile, IOSystem* pIOHandler,
  57. bool checkSig) const;
  58. protected:
  59. // -------------------------------------------------------------------
  60. /** Return importer meta information.
  61. * See #BaseImporter::GetInfo for the details
  62. */
  63. const aiImporterDesc* GetInfo () const;
  64. // -------------------------------------------------------------------
  65. /** Imports the given file into the given scene structure.
  66. * See BaseImporter::InternReadFile() for details
  67. */
  68. void InternReadFile( const std::string& pFile, aiScene* pScene,
  69. IOSystem* pIOHandler);
  70. // -------------------------------------------------------------------
  71. /** Called prior to ReadFile().
  72. * The function is a request to the importer to update its configuration
  73. * basing on the Importer's configuration property list.
  74. */
  75. void SetupProperties(const Importer* pImp);
  76. private:
  77. // -------------------------------------------------------------------
  78. /** Generate normal vectors basing on smoothing groups
  79. * (in some cases the normal are already contained in the file)
  80. * \param mesh Mesh to work on
  81. * \return false if the normals have been recomputed
  82. */
  83. bool GenerateNormals(ASE::Mesh& mesh);
  84. // -------------------------------------------------------------------
  85. /** Create valid vertex/normal/UV/color/face lists.
  86. * All elements are unique, faces have only one set of indices
  87. * after this step occurs.
  88. * \param mesh Mesh to work on
  89. */
  90. void BuildUniqueRepresentation(ASE::Mesh& mesh);
  91. /** Create one-material-per-mesh meshes ;-)
  92. * \param mesh Mesh to work with
  93. * \param Receives the list of all created meshes
  94. */
  95. void ConvertMeshes(ASE::Mesh& mesh, std::vector<aiMesh*>& avOut);
  96. // -------------------------------------------------------------------
  97. /** Convert a material to a aiMaterial object
  98. * \param mat Input material
  99. */
  100. void ConvertMaterial(ASE::Material& mat);
  101. // -------------------------------------------------------------------
  102. /** Setup the final material indices for each mesh
  103. */
  104. void BuildMaterialIndices();
  105. // -------------------------------------------------------------------
  106. /** Build the node graph
  107. */
  108. void BuildNodes(std::vector<ASE::BaseNode*>& nodes);
  109. // -------------------------------------------------------------------
  110. /** Build output cameras
  111. */
  112. void BuildCameras();
  113. // -------------------------------------------------------------------
  114. /** Build output lights
  115. */
  116. void BuildLights();
  117. // -------------------------------------------------------------------
  118. /** Build output animations
  119. */
  120. void BuildAnimations(const std::vector<ASE::BaseNode*>& nodes);
  121. // -------------------------------------------------------------------
  122. /** Add sub nodes to a node
  123. * \param pcParent parent node to be filled
  124. * \param szName Name of the parent node
  125. * \param matrix Current transform
  126. */
  127. void AddNodes(const std::vector<ASE::BaseNode*>& nodes,
  128. aiNode* pcParent,const char* szName);
  129. void AddNodes(const std::vector<ASE::BaseNode*>& nodes,
  130. aiNode* pcParent,const char* szName,
  131. const aiMatrix4x4& matrix);
  132. void AddMeshes(const ASE::BaseNode* snode,aiNode* node);
  133. // -------------------------------------------------------------------
  134. /** Generate a default material and add it to the parser's list
  135. * Called if no material has been found in the file (rare for ASE,
  136. * but not impossible)
  137. */
  138. void GenerateDefaultMaterial();
  139. protected:
  140. /** Parser instance */
  141. ASE::Parser* mParser;
  142. /** Buffer to hold the loaded file */
  143. char* mBuffer;
  144. /** Scene to be filled */
  145. aiScene* pcScene;
  146. /** Config options: Recompute the normals in every case - WA
  147. for 3DS Max broken ASE normal export */
  148. bool configRecomputeNormals;
  149. bool noSkeletonMesh;
  150. };
  151. } // end of namespace Assimp
  152. #endif // AI_3DSIMPORTER_H_INC