Blender  V2.93
abc_reader_object.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  */
16 #pragma once
17 
22 #include <Alembic/Abc/All.h>
23 #include <Alembic/AbcGeom/All.h>
24 
25 #include "DNA_ID.h"
26 
27 struct CacheFile;
28 struct Main;
29 struct Mesh;
30 struct Object;
31 
32 using Alembic::AbcCoreAbstract::chrono_t;
33 
34 namespace blender::io::alembic {
35 
38  float conversion_mat[4][4];
39 
40  int from_up;
42  float scale;
45 
46  /* Length and frame offset of file sequences. */
49 
50  /* From MeshSeqCacheModifierData.read_flag */
51  int read_flag;
52 
54 
56 
58  : do_convert_mat(false),
59  from_up(0),
60  from_forward(0),
61  scale(1.0f),
62  is_sequence(false),
63  set_frame_range(false),
64  sequence_len(1),
65  sequence_offset(0),
66  read_flag(0),
67  validate_meshes(false),
69  {
70  }
71 };
72 
73 template<typename Schema> static bool has_animations(Schema &schema, ImportSettings *settings)
74 {
75  return settings->is_sequence || !schema.isConstant();
76 }
77 
79  protected:
80  std::string m_name;
81  std::string m_object_name;
82  std::string m_data_name;
84  Alembic::Abc::IObject m_iobject;
85 
87 
88  chrono_t m_min_time;
89  chrono_t m_max_time;
90 
91  /* Use reference counting since the same reader may be used by multiple
92  * modifiers and/or constraints. */
94 
96 
97  public:
99 
100  public:
101  explicit AbcObjectReader(const Alembic::Abc::IObject &object, ImportSettings &settings);
102 
103  virtual ~AbcObjectReader() = default;
104 
105  const Alembic::Abc::IObject &iobject() const;
106 
107  typedef std::vector<AbcObjectReader *> ptr_vector;
108 
113  virtual Alembic::AbcGeom::IXform xform();
114 
115  Object *object() const;
116  void object(Object *ob);
117 
118  const std::string &name() const
119  {
120  return m_name;
121  }
122  const std::string &object_name() const
123  {
124  return m_object_name;
125  }
126  const std::string &data_name() const
127  {
128  return m_data_name;
129  }
130  bool inherits_xform() const
131  {
132  return m_inherits_xform;
133  }
134 
135  virtual bool valid() const = 0;
136  virtual bool accepts_object_type(const Alembic::AbcCoreAbstract::ObjectHeader &alembic_header,
137  const Object *const ob,
138  const char **err_str) const = 0;
139 
140  virtual void readObjectData(Main *bmain, const Alembic::Abc::ISampleSelector &sample_sel) = 0;
141 
142  virtual struct Mesh *read_mesh(struct Mesh *mesh,
143  const Alembic::Abc::ISampleSelector &sample_sel,
144  int read_flag,
145  const char **err_str);
146  virtual bool topology_changed(Mesh *existing_mesh,
147  const Alembic::Abc::ISampleSelector &sample_sel);
148 
150  void setupObjectTransform(const float time);
151 
152  void addCacheModifier();
153 
154  chrono_t minTime() const;
155  chrono_t maxTime() const;
156 
157  int refcount() const;
158  void incref();
159  void decref();
160 
161  void read_matrix(float r_mat[4][4], const float time, const float scale, bool &is_constant);
162 
163  protected:
165 };
166 
167 Imath::M44d get_matrix(const Alembic::AbcGeom::IXformSchema &schema, const float time);
168 
169 } // namespace blender::io::alembic
ID and Library types, which are fundamental for sdna.
virtual struct Mesh * read_mesh(struct Mesh *mesh, const Alembic::Abc::ISampleSelector &sample_sel, int read_flag, const char **err_str)
AbcObjectReader(const Alembic::Abc::IObject &object, ImportSettings &settings)
const Alembic::Abc::IObject & iobject() const
const std::string & data_name() const
virtual Alembic::AbcGeom::IXform xform()
const std::string & object_name() const
const std::string & name() const
virtual bool topology_changed(Mesh *existing_mesh, const Alembic::Abc::ISampleSelector &sample_sel)
virtual void readObjectData(Main *bmain, const Alembic::Abc::ISampleSelector &sample_sel)=0
void read_matrix(float r_mat[4][4], const float time, const float scale, bool &is_constant)
virtual bool accepts_object_type(const Alembic::AbcCoreAbstract::ObjectHeader &alembic_header, const Object *const ob, const char **err_str) const =0
std::vector< AbcObjectReader * > ptr_vector
double time
Imath::M44d get_matrix(const IXformSchema &schema, const float time)
bool has_animations(Alembic::AbcGeom::IPolyMeshSchema &schema, ImportSettings *settings)
Definition: BKE_main.h:116