2 * ***** BEGIN GPL LICENSE BLOCK *****
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * Contributor(s): Esteban Tovagliari, Cedric Paille, Kevin Dietrich
20 * ***** END GPL LICENSE BLOCK *****
23 #ifndef __ABC_OBJECT_H__
24 #define __ABC_OBJECT_H__
26 #include <Alembic/Abc/All.h>
27 #include <Alembic/AbcGeom/All.h>
29 #include "abc_exporter.h"
35 class AbcTransformWriter;
40 /* ************************************************************************** */
42 class AbcObjectWriter {
45 ExportSettings &m_settings;
48 uint32_t m_time_sampling;
50 Imath::Box3d m_bounds;
51 std::vector<AbcObjectWriter *> m_children;
53 std::vector< std::pair<std::string, IDProperty *> > m_props;
59 AbcObjectWriter(Scene *scene,
61 uint32_t time_sampling,
62 ExportSettings &settings,
63 AbcObjectWriter *parent = NULL);
65 virtual ~AbcObjectWriter();
67 void addChild(AbcObjectWriter *child);
69 virtual Imath::Box3d bounds();
74 virtual void do_write() = 0;
77 /* ************************************************************************** */
81 struct ImportSettings {
83 float conversion_mat[4][4];
91 /* Length and frame offset of file sequences. */
95 /* From MeshSeqCacheModifierData.read_flag */
100 CacheFile *cache_file;
103 : do_convert_mat(false)
108 , set_frame_range(false)
112 , validate_meshes(false)
117 template <typename Schema>
118 static bool has_animations(Schema &schema, ImportSettings *settings)
120 return settings->is_sequence || !schema.isConstant();
123 /* ************************************************************************** */
127 using Alembic::AbcCoreAbstract::chrono_t;
129 class AbcObjectReader {
132 std::string m_object_name;
133 std::string m_data_name;
135 Alembic::Abc::IObject m_iobject;
137 ImportSettings *m_settings;
142 /* Use reference counting since the same reader may be used by multiple
143 * modifiers and/or constraints. */
147 explicit AbcObjectReader(const Alembic::Abc::IObject &object, ImportSettings &settings);
149 virtual ~AbcObjectReader();
151 const Alembic::Abc::IObject &iobject() const;
154 * Returns the transform of this object. This can be the Alembic object
155 * itself (in case of an Empty) or it can be the parent Alembic object.
157 virtual Alembic::AbcGeom::IXform xform();
159 Object *object() const;
160 void object(Object *ob);
162 const std::string & name() const { return m_name; }
163 const std::string & object_name() const { return m_object_name; }
164 const std::string & data_name() const { return m_data_name; }
166 virtual bool valid() const = 0;
168 virtual void readObjectData(Main *bmain, float time) = 0;
170 virtual DerivedMesh *read_derivedmesh(DerivedMesh *dm, const float time, int read_flag, const char **err_str)
178 /** Reads the object matrix and sets up an object transform if animated. */
179 void setupObjectTransform(const float time);
181 void addCacheModifier();
183 chrono_t minTime() const;
184 chrono_t maxTime() const;
186 int refcount() const;
190 void read_matrix(float r_mat[4][4], const float time,
191 const float scale, bool &is_constant);
194 Imath::M44d get_matrix(const Alembic::AbcGeom::IXformSchema &schema, const float time);
196 #endif /* __ABC_OBJECT_H__ */