BlenderModifier.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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. /** @file BlenderModifier.h
  34. * @brief Declare dedicated helper classes to simulate some blender modifiers (i.e. mirror)
  35. */
  36. #ifndef INCLUDED_AI_BLEND_MODIFIER_H
  37. #define INCLUDED_AI_BLEND_MODIFIER_H
  38. #include "BlenderIntermediate.h"
  39. namespace Assimp {
  40. namespace Blender {
  41. // -------------------------------------------------------------------------------------------
  42. /**
  43. * Dummy base class for all blender modifiers. Modifiers are reused between imports, so
  44. * they should be stateless and not try to cache model data.
  45. */
  46. // -------------------------------------------------------------------------------------------
  47. class BlenderModifier {
  48. public:
  49. /**
  50. * The class destructor, virtual.
  51. */
  52. virtual ~BlenderModifier() = default;
  53. // --------------------
  54. /**
  55. * Check if *this* modifier is active, given a ModifierData& block.
  56. */
  57. virtual bool IsActive( const ModifierData& /*modin*/) {
  58. return false;
  59. }
  60. // --------------------
  61. /**
  62. * Apply the modifier to a given output node. The original data used
  63. * to construct the node is given as well. Not called unless IsActive()
  64. * was called and gave positive response.
  65. */
  66. virtual void DoIt(aiNode& /*out*/,
  67. ConversionData& /*conv_data*/,
  68. const ElemBase& orig_modifier,
  69. const Scene& /*in*/,
  70. const Object& /*orig_object*/
  71. ) {
  72. ASSIMP_LOG_INFO("This modifier is not supported, skipping: ",orig_modifier.dna_type );
  73. return;
  74. }
  75. };
  76. // -------------------------------------------------------------------------------------------
  77. /**
  78. * Manage all known modifiers and instance and apply them if necessary
  79. */
  80. // -------------------------------------------------------------------------------------------
  81. class BlenderModifierShowcase {
  82. public:
  83. // --------------------
  84. /** Apply all requested modifiers provided we support them. */
  85. void ApplyModifiers(aiNode& out,
  86. ConversionData& conv_data,
  87. const Scene& in,
  88. const Object& orig_object
  89. );
  90. private:
  91. TempArray< std::vector,BlenderModifier > cached_modifiers;
  92. };
  93. // MODIFIERS /////////////////////////////////////////////////////////////////////////////////
  94. // -------------------------------------------------------------------------------------------
  95. /**
  96. * Mirror modifier. Status: implemented.
  97. */
  98. // -------------------------------------------------------------------------------------------
  99. class BlenderModifier_Mirror : public BlenderModifier {
  100. public:
  101. // --------------------
  102. virtual bool IsActive( const ModifierData& modin);
  103. // --------------------
  104. virtual void DoIt(aiNode& out,
  105. ConversionData& conv_data,
  106. const ElemBase& orig_modifier,
  107. const Scene& in,
  108. const Object& orig_object
  109. ) ;
  110. };
  111. // -------------------------------------------------------------------------------------------
  112. /** Subdivision modifier. Status: dummy. */
  113. // -------------------------------------------------------------------------------------------
  114. class BlenderModifier_Subdivision : public BlenderModifier {
  115. public:
  116. // --------------------
  117. virtual bool IsActive( const ModifierData& modin);
  118. // --------------------
  119. virtual void DoIt(aiNode& out,
  120. ConversionData& conv_data,
  121. const ElemBase& orig_modifier,
  122. const Scene& in,
  123. const Object& orig_object
  124. ) ;
  125. };
  126. }
  127. }
  128. #endif // !INCLUDED_AI_BLEND_MODIFIER_H