Blender  V3.3
abc_reader_object.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 #pragma once
3 
8 #include <Alembic/Abc/All.h>
9 #include <Alembic/AbcGeom/All.h>
10 
11 #include "DNA_ID.h"
12 
13 struct CacheFile;
14 struct Main;
15 struct Mesh;
16 struct Object;
17 
18 using Alembic::AbcCoreAbstract::chrono_t;
19 
20 namespace blender::io::alembic {
21 
24  float conversion_mat[4][4];
25 
26  int from_up;
28  float scale;
31 
32  /* Length and frame offset of file sequences. */
35 
36  /* From MeshSeqCacheModifierData.read_flag */
37  int read_flag;
38 
39  /* From CacheFile and MeshSeqCacheModifierData */
40  std::string velocity_name;
42 
45 
47 
49  : do_convert_mat(false),
50  from_up(0),
51  from_forward(0),
52  scale(1.0f),
53  is_sequence(false),
54  set_frame_range(false),
55  sequence_len(1),
56  sequence_offset(0),
57  read_flag(0),
58  velocity_name(""),
59  velocity_scale(1.0f),
60  validate_meshes(false),
63  {
64  }
65 };
66 
67 template<typename Schema> static bool has_animations(Schema &schema, ImportSettings *settings)
68 {
69  return settings->is_sequence || !schema.isConstant();
70 }
71 
73  protected:
74  std::string m_name;
75  std::string m_object_name;
76  std::string m_data_name;
78  Alembic::Abc::IObject m_iobject;
79 
81 
82  chrono_t m_min_time;
83  chrono_t m_max_time;
84 
85  /* Use reference counting since the same reader may be used by multiple
86  * modifiers and/or constraints. */
88 
90 
91  public:
93 
94  public:
95  explicit AbcObjectReader(const Alembic::Abc::IObject &object, ImportSettings &settings);
96 
97  virtual ~AbcObjectReader() = default;
98 
99  const Alembic::Abc::IObject &iobject() const;
100 
101  typedef std::vector<AbcObjectReader *> ptr_vector;
102 
107  virtual Alembic::AbcGeom::IXform xform();
108 
109  Object *object() const;
110  void object(Object *ob);
111 
112  const std::string &name() const
113  {
114  return m_name;
115  }
116  const std::string &object_name() const
117  {
118  return m_object_name;
119  }
120  const std::string &data_name() const
121  {
122  return m_data_name;
123  }
124  bool inherits_xform() const
125  {
126  return m_inherits_xform;
127  }
128 
129  virtual bool valid() const = 0;
130  virtual bool accepts_object_type(const Alembic::AbcCoreAbstract::ObjectHeader &alembic_header,
131  const Object *const ob,
132  const char **err_str) const = 0;
133 
134  virtual void readObjectData(Main *bmain, const Alembic::Abc::ISampleSelector &sample_sel) = 0;
135 
136  virtual struct Mesh *read_mesh(struct Mesh *mesh,
137  const Alembic::Abc::ISampleSelector &sample_sel,
138  int read_flag,
139  const char *velocity_name,
140  float velocity_scale,
141  const char **err_str);
142  virtual bool topology_changed(const Mesh *existing_mesh,
143  const Alembic::Abc::ISampleSelector &sample_sel);
144 
146  void setupObjectTransform(chrono_t time);
147 
148  void addCacheModifier();
149 
150  chrono_t minTime() const;
151  chrono_t maxTime() const;
152 
153  int refcount() const;
154  void incref();
155  void decref();
156 
157  void read_matrix(float r_mat[4][4], chrono_t time, float scale, bool &is_constant);
158 
159  protected:
162 };
163 
164 Imath::M44d get_matrix(const Alembic::AbcGeom::IXformSchema &schema, chrono_t time);
165 
166 } // namespace blender::io::alembic
ID and Library types, which are fundamental for sdna.
AbcObjectReader(const Alembic::Abc::IObject &object, ImportSettings &settings)
void read_matrix(float r_mat[4][4], chrono_t time, float scale, bool &is_constant)
const Alembic::Abc::IObject & iobject() const
virtual bool topology_changed(const Mesh *existing_mesh, const Alembic::Abc::ISampleSelector &sample_sel)
const std::string & data_name() const
virtual Alembic::AbcGeom::IXform xform()
const std::string & object_name() const
const std::string & name() const
virtual void readObjectData(Main *bmain, const Alembic::Abc::ISampleSelector &sample_sel)=0
virtual struct Mesh * read_mesh(struct Mesh *mesh, const Alembic::Abc::ISampleSelector &sample_sel, int read_flag, const char *velocity_name, float velocity_scale, const char **err_str)
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 chrono_t time)
bool has_animations(Alembic::AbcGeom::IPolyMeshSchema &schema, ImportSettings *settings)
Definition: BKE_main.h:121