1 | /* |
2 | Open Asset Import Library (assimp) |
3 | ---------------------------------------------------------------------- |
4 | |
5 | Copyright (c) 2006-2017, assimp team |
6 | |
7 | All rights reserved. |
8 | |
9 | Redistribution and use of this software in source and binary forms, |
10 | with or without modification, are permitted provided that the |
11 | following conditions are met: |
12 | |
13 | * Redistributions of source code must retain the above |
14 | copyright notice, this list of conditions and the |
15 | following disclaimer. |
16 | |
17 | * Redistributions in binary form must reproduce the above |
18 | copyright notice, this list of conditions and the |
19 | following disclaimer in the documentation and/or other |
20 | materials provided with the distribution. |
21 | |
22 | * Neither the name of the assimp team, nor the names of its |
23 | contributors may be used to endorse or promote products |
24 | derived from this software without specific prior |
25 | written permission of the assimp team. |
26 | |
27 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
28 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
29 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
30 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
31 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
32 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
33 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
34 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
35 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
36 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
37 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
38 | |
39 | ---------------------------------------------------------------------- |
40 | */ |
41 | |
42 | /** @file BlenderModifier.h |
43 | * @brief Declare dedicated helper classes to simulate some blender modifiers (i.e. mirror) |
44 | */ |
45 | #ifndef INCLUDED_AI_BLEND_MODIFIER_H |
46 | #define INCLUDED_AI_BLEND_MODIFIER_H |
47 | |
48 | #include "BlenderIntermediate.h" |
49 | #include "TinyFormatter.h" |
50 | |
51 | namespace Assimp { |
52 | namespace Blender { |
53 | |
54 | // ------------------------------------------------------------------------------------------- |
55 | /** Dummy base class for all blender modifiers. Modifiers are reused between imports, so |
56 | * they should be stateless and not try to cache model data. */ |
57 | // ------------------------------------------------------------------------------------------- |
58 | class BlenderModifier |
59 | { |
60 | public: |
61 | virtual ~BlenderModifier() { |
62 | // empty |
63 | } |
64 | |
65 | public: |
66 | |
67 | // -------------------- |
68 | /** Check if *this* modifier is active, given a ModifierData& block.*/ |
69 | virtual bool IsActive( const ModifierData& /*modin*/) { |
70 | return false; |
71 | } |
72 | |
73 | // -------------------- |
74 | /** Apply the modifier to a given output node. The original data used |
75 | * to construct the node is given as well. Not called unless IsActive() |
76 | * was called and gave positive response. */ |
77 | virtual void DoIt(aiNode& /*out*/, |
78 | ConversionData& /*conv_data*/, |
79 | const ElemBase& orig_modifier, |
80 | const Scene& /*in*/, |
81 | const Object& /*orig_object*/ |
82 | ) { |
83 | DefaultLogger::get()->warn((Formatter::format("This modifier is not supported, skipping: " ),orig_modifier.dna_type)); |
84 | return; |
85 | } |
86 | }; |
87 | |
88 | |
89 | // ------------------------------------------------------------------------------------------- |
90 | /** Manage all known modifiers and instance and apply them if necessary */ |
91 | // ------------------------------------------------------------------------------------------- |
92 | class BlenderModifierShowcase |
93 | { |
94 | public: |
95 | |
96 | // -------------------- |
97 | /** Apply all requested modifiers provided we support them. */ |
98 | void ApplyModifiers(aiNode& out, |
99 | ConversionData& conv_data, |
100 | const Scene& in, |
101 | const Object& orig_object |
102 | ); |
103 | |
104 | private: |
105 | |
106 | TempArray< std::vector,BlenderModifier > cached_modifiers; |
107 | }; |
108 | |
109 | |
110 | |
111 | |
112 | |
113 | // MODIFIERS |
114 | |
115 | |
116 | |
117 | // ------------------------------------------------------------------------------------------- |
118 | /** Mirror modifier. Status: implemented. */ |
119 | // ------------------------------------------------------------------------------------------- |
120 | class BlenderModifier_Mirror : public BlenderModifier |
121 | { |
122 | public: |
123 | |
124 | // -------------------- |
125 | virtual bool IsActive( const ModifierData& modin); |
126 | |
127 | // -------------------- |
128 | virtual void DoIt(aiNode& out, |
129 | ConversionData& conv_data, |
130 | const ElemBase& orig_modifier, |
131 | const Scene& in, |
132 | const Object& orig_object |
133 | ) ; |
134 | }; |
135 | |
136 | // ------------------------------------------------------------------------------------------- |
137 | /** Subdivision modifier. Status: dummy. */ |
138 | // ------------------------------------------------------------------------------------------- |
139 | class BlenderModifier_Subdivision : public BlenderModifier |
140 | { |
141 | public: |
142 | |
143 | // -------------------- |
144 | virtual bool IsActive( const ModifierData& modin); |
145 | |
146 | // -------------------- |
147 | virtual void DoIt(aiNode& out, |
148 | ConversionData& conv_data, |
149 | const ElemBase& orig_modifier, |
150 | const Scene& in, |
151 | const Object& orig_object |
152 | ) ; |
153 | }; |
154 | |
155 | |
156 | }} |
157 | #endif // !INCLUDED_AI_BLEND_MODIFIER_H |
158 | |