3MFTypes.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. /*
  2. Open Asset Import Library (assimp)
  3. ----------------------------------------------------------------------
  4. Copyright (c) 2006-2025, 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. #pragma once
  34. #include <assimp/vector3.h>
  35. #include <assimp/matrix4x4.h>
  36. #include <assimp/ParsingUtils.h>
  37. #include <vector>
  38. #include <string>
  39. struct aiMaterial;
  40. struct aiMesh;
  41. namespace Assimp {
  42. namespace D3MF {
  43. enum class ResourceType {
  44. RT_Object,
  45. RT_BaseMaterials,
  46. RT_EmbeddedTexture2D,
  47. RT_Texture2DGroup,
  48. RT_ColorGroup,
  49. RT_Unknown
  50. }; // To be extended with other resource types (eg. material extension resources like Texture2d, Texture2dGroup...)
  51. class Resource {
  52. public:
  53. int mId;
  54. Resource(int id) :
  55. mId(id) {
  56. // empty
  57. }
  58. virtual ~Resource() = default;
  59. virtual ResourceType getType() const {
  60. return ResourceType::RT_Unknown;
  61. }
  62. };
  63. class EmbeddedTexture : public Resource {
  64. public:
  65. std::string mPath;
  66. std::string mContentType;
  67. std::string mTilestyleU;
  68. std::string mTilestyleV;
  69. std::vector<char> mBuffer;
  70. EmbeddedTexture(int id) :
  71. Resource(id),
  72. mPath(),
  73. mContentType(),
  74. mTilestyleU(),
  75. mTilestyleV() {
  76. // empty
  77. }
  78. ~EmbeddedTexture() override = default;
  79. ResourceType getType() const override {
  80. return ResourceType::RT_EmbeddedTexture2D;
  81. }
  82. };
  83. class Texture2DGroup : public Resource {
  84. public:
  85. std::vector<aiVector2D> mTex2dCoords;
  86. int mTexId;
  87. Texture2DGroup(int id) :
  88. Resource(id),
  89. mTexId(-1) {
  90. // empty
  91. }
  92. ~Texture2DGroup() override = default;
  93. ResourceType getType() const override {
  94. return ResourceType::RT_Texture2DGroup;
  95. }
  96. };
  97. class ColorGroup : public Resource {
  98. public:
  99. std::vector<aiColor4D> mColors;
  100. ColorGroup(int id) :
  101. Resource(id){
  102. // empty
  103. }
  104. ~ColorGroup() override = default;
  105. ResourceType getType() const override {
  106. return ResourceType::RT_ColorGroup;
  107. }
  108. };
  109. class BaseMaterials : public Resource {
  110. public:
  111. std::vector<unsigned int> mMaterialIndex;
  112. BaseMaterials(int id) :
  113. Resource(id),
  114. mMaterialIndex() {
  115. // empty
  116. }
  117. ~BaseMaterials() override = default;
  118. ResourceType getType() const override {
  119. return ResourceType::RT_BaseMaterials;
  120. }
  121. };
  122. struct Component {
  123. int mObjectId;
  124. aiMatrix4x4 mTransformation;
  125. };
  126. class Object : public Resource {
  127. public:
  128. std::vector<aiMesh *> mMeshes;
  129. std::vector<unsigned int> mMeshIndex;
  130. std::vector<Component> mComponents;
  131. std::string mName;
  132. Object(int id) :
  133. Resource(id),
  134. mName(std::string("Object_") + ai_to_string(id)) {
  135. // empty
  136. }
  137. ~Object() override = default;
  138. ResourceType getType() const override {
  139. return ResourceType::RT_Object;
  140. }
  141. };
  142. } // namespace D3MF
  143. } // namespace Assimp