選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 
 
 
 

213 行
5.8 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 NFFLoader.h
  34. * @brief Declaration of the NFF importer class.
  35. */
  36. #ifndef AI_NFFLOADER_H_INCLUDED
  37. #define AI_NFFLOADER_H_INCLUDED
  38. #include "BaseImporter.h"
  39. #include <vector>
  40. #include "../include/assimp/types.h"
  41. namespace Assimp {
  42. // ----------------------------------------------------------------------------------
  43. /** NFF (Neutral File Format) Importer class.
  44. *
  45. * The class implements both Eric Haynes NFF format and Sense8's NFF (NFF2) format.
  46. * Both are quite different and the loading code is somewhat dirty at
  47. * the moment. Sense8 should be moved to a separate loader.
  48. */
  49. class NFFImporter : public BaseImporter
  50. {
  51. public:
  52. NFFImporter();
  53. ~NFFImporter();
  54. public:
  55. // -------------------------------------------------------------------
  56. /** Returns whether the class can handle the format of the given file.
  57. * See BaseImporter::CanRead() for details.
  58. */
  59. bool CanRead( const std::string& pFile, IOSystem* pIOHandler,
  60. bool checkSig) const;
  61. protected:
  62. // -------------------------------------------------------------------
  63. /** Return importer meta information.
  64. * See #BaseImporter::GetInfo for the details
  65. */
  66. const aiImporterDesc* GetInfo () const;
  67. // -------------------------------------------------------------------
  68. /** Imports the given file into the given scene structure.
  69. * See BaseImporter::InternReadFile() for details
  70. */
  71. void InternReadFile( const std::string& pFile, aiScene* pScene,
  72. IOSystem* pIOHandler);
  73. private:
  74. // describes face material properties
  75. struct ShadingInfo
  76. {
  77. ShadingInfo()
  78. : color (0.6f,0.6f,0.6f)
  79. , diffuse (1.f,1.f,1.f)
  80. , specular (1.f,1.f,1.f)
  81. , ambient (0.f,0.f,0.f)
  82. , emissive (0.f,0.f,0.f)
  83. , refracti (1.f)
  84. , twoSided (false) // for NFF2
  85. , shaded (true) // for NFF2
  86. , opacity (1.f)
  87. , shininess (0.f)
  88. , mapping (aiTextureMapping_UV)
  89. {}
  90. aiColor3D color,diffuse,specular,ambient,emissive;
  91. float refracti;
  92. std::string texFile;
  93. // For NFF2
  94. bool twoSided;
  95. bool shaded;
  96. float opacity, shininess;
  97. std::string name;
  98. // texture mapping to be generated for the mesh - uv is the default
  99. // it means: use UV if there, nothing otherwise. This property is
  100. // used for locked meshes.
  101. aiTextureMapping mapping;
  102. // shininess is ignored for the moment
  103. bool operator == (const ShadingInfo& other) const
  104. {
  105. return color == other.color &&
  106. diffuse == other.diffuse &&
  107. specular == other.specular &&
  108. ambient == other.ambient &&
  109. refracti == other.refracti &&
  110. texFile == other.texFile &&
  111. twoSided == other.twoSided &&
  112. shaded == other.shaded;
  113. // Some properties from NFF2 aren't compared by this operator.
  114. // Comparing MeshInfo::matIndex should do that.
  115. }
  116. };
  117. // describes a NFF light source
  118. struct Light
  119. {
  120. Light()
  121. : intensity (1.f)
  122. , color (1.f,1.f,1.f)
  123. {}
  124. aiVector3D position;
  125. float intensity;
  126. aiColor3D color;
  127. };
  128. enum PatchType
  129. {
  130. PatchType_Simple = 0x0,
  131. PatchType_Normals = 0x1,
  132. PatchType_UVAndNormals = 0x2
  133. };
  134. // describes a NFF mesh
  135. struct MeshInfo
  136. {
  137. MeshInfo(PatchType _pType, bool bL = false)
  138. : pType (_pType)
  139. , bLocked (bL)
  140. , radius (1.f,1.f,1.f)
  141. , dir (0.f,1.f,0.f)
  142. , matIndex (0)
  143. {
  144. name[0] = '\0'; // by default meshes are unnamed
  145. }
  146. ShadingInfo shader;
  147. PatchType pType;
  148. bool bLocked;
  149. // for spheres, cones and cylinders: center point of the object
  150. aiVector3D center, radius, dir;
  151. char name[128];
  152. std::vector<aiVector3D> vertices, normals, uvs;
  153. std::vector<unsigned int> faces;
  154. // for NFF2
  155. std::vector<aiColor4D> colors;
  156. unsigned int matIndex;
  157. };
  158. // -------------------------------------------------------------------
  159. /** Loads the material table for the NFF2 file format from an
  160. * external file.
  161. *
  162. * @param output Receives the list of output meshes
  163. * @param path Path to the file (abs. or rel.)
  164. * @param pIOHandler IOSystem to be used to open the file
  165. */
  166. void LoadNFF2MaterialTable(std::vector<ShadingInfo>& output,
  167. const std::string& path, IOSystem* pIOHandler);
  168. };
  169. } // end of namespace Assimp
  170. #endif // AI_NFFIMPORTER_H_IN