Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 
 
 

117 linhas
3.5 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. #ifndef OBJFILEMTLIMPORTER_H_INC
  33. #define OBJFILEMTLIMPORTER_H_INC
  34. #include <vector>
  35. #include <string>
  36. struct aiColor3D;
  37. namespace Assimp
  38. {
  39. namespace ObjFile
  40. {
  41. struct Model;
  42. struct Material;
  43. }
  44. /**
  45. * @class ObjFileMtlImporter
  46. * @brief Loads the material description from a mtl file.
  47. */
  48. class ObjFileMtlImporter
  49. {
  50. public:
  51. static const size_t BUFFERSIZE = 2048;
  52. typedef std::vector<char> DataArray;
  53. typedef std::vector<char>::iterator DataArrayIt;
  54. typedef std::vector<char>::const_iterator ConstDataArrayIt;
  55. public:
  56. //! \brief Default constructor
  57. ObjFileMtlImporter( std::vector<char> &buffer, const std::string &strAbsPath,
  58. ObjFile::Model *pModel );
  59. //! \brief DEstructor
  60. ~ObjFileMtlImporter();
  61. private:
  62. /// Copy constructor, empty.
  63. ObjFileMtlImporter(const ObjFileMtlImporter &rOther);
  64. /// \brief Assignment operator, returns only a reference of this instance.
  65. ObjFileMtlImporter &operator = (const ObjFileMtlImporter &rOther);
  66. /// Load the whole material description
  67. void load();
  68. /// Get color data.
  69. void getColorRGBA( aiColor3D *pColor);
  70. /// Get illumination model from loaded data
  71. void getIlluminationModel( int &illum_model );
  72. /// Gets a float value from data.
  73. void getFloatValue( float &value );
  74. /// Creates a new material from loaded data.
  75. void createMaterial();
  76. /// Get texture name from loaded data.
  77. void getTexture();
  78. void getTextureOption(bool &clamp);
  79. private:
  80. //! Absolute pathname
  81. std::string m_strAbsPath;
  82. //! Data iterator showing to the current position in data buffer
  83. DataArrayIt m_DataIt;
  84. //! Data iterator to end of buffer
  85. DataArrayIt m_DataItEnd;
  86. //! USed model instance
  87. ObjFile::Model *m_pModel;
  88. //! Current line in file
  89. unsigned int m_uiLine;
  90. //! Helper buffer
  91. char m_buffer[BUFFERSIZE];
  92. };
  93. // ------------------------------------------------------------------------------------------------
  94. } // Namespace Assimp
  95. #endif