29using Alembic::AbcGeom::IObject;
30using Alembic::AbcGeom::IXform;
31using Alembic::AbcGeom::IXformSchema;
45 m_name =
object.getFullName();
46 std::vector<std::string> parts;
49 if (parts.size() >= 2) {
64 IXform ixform =
xform();
69 const IXformSchema &schema(ixform.getSchema());
70 if (!schema.valid()) {
71 std::cerr <<
"Alembic object " << ixform.getFullName() <<
" has an invalid schema."
78 IObject ixform_parent = ixform.getParent();
79 if (!ixform_parent.getParent()) {
105 const Imath::M44d &m1,
108 float mat0[4][4], mat1[4][4],
ret[4][4];
121Imath::M44d
get_matrix(
const IXformSchema &schema,
const chrono_t time)
123 Alembic::AbcGeom::ISampleSelector selector(time);
125 const std::optional<SampleInterpolationSettings> interpolation_settings =
127 selector, schema.getTimeSampling(), schema.getNumSamples());
129 if (!interpolation_settings.has_value()) {
131 Alembic::AbcGeom::XformSample s0;
132 schema.get(s0, selector);
133 return s0.getMatrix();
136 Alembic::AbcGeom::XformSample s0, s1;
137 schema.get(s0, Alembic::AbcGeom::ISampleSelector(interpolation_settings->index));
138 schema.get(s1, Alembic::AbcGeom::ISampleSelector(interpolation_settings->ceil_index));
139 return blend_matrices(s0.getMatrix(), s1.getMatrix(), interpolation_settings->weight);
143 const Alembic::Abc::ISampleSelector & ,
152 const Alembic::Abc::ISampleSelector & )
161 bool is_constant =
false;
162 float transform_from_alembic[4][4];
176 if (!is_constant ||
m_settings->always_add_cache_reader) {
190 if (IXform::matches(
m_iobject.getMetaData())) {
192 return IXform(
m_iobject, Alembic::AbcGeom::kWrapExisting);
194 catch (Alembic::Util::Exception &ex) {
195 printf(
"Alembic: error reading object transform for '%s': %s\n",
204 IObject abc_parent =
m_iobject.getParent();
207 if (abc_parent.getParent() && IXform::matches(abc_parent.getMetaData())) {
209 return IXform(abc_parent, Alembic::AbcGeom::kWrapExisting);
211 catch (Alembic::Util::Exception &ex) {
212 printf(
"Alembic: error reading object transform for '%s': %s\n",
213 abc_parent.getFullName().c_str(),
229 IXform ixform =
xform();
232 r_is_constant =
true;
236 const IXformSchema &schema(ixform.getSchema());
237 if (!schema.valid()) {
238 std::cerr <<
"Alembic object " << ixform.getFullName() <<
" has an invalid schema."
243 const Imath::M44d matrix =
get_matrix(schema, time);
251 float camera_rotation[4][4];
258 float scale_mat[4][4];
263 r_is_constant = schema.isConstant();
struct bConstraint * BKE_constraint_add_for_object(struct Object *ob, const char *name, short type)
void BKE_modifiers_persistent_uid_init(const Object &object, ModifierData &md)
ModifierData * BKE_modifier_new(int type)
General operations, lookup, etc. for blender objects.
void BKE_object_apply_mat4(Object *ob, const float mat[4][4], bool use_compat, bool use_parent)
void BKE_object_to_mat4(const Object *ob, float r_mat[4][4])
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void interp_m4_m4m4(float R[4][4], const float A[4][4], const float B[4][4], float t)
void mul_m4_m4m4(float R[4][4], const float A[4][4], const float B[4][4])
void scale_m4_fl(float R[4][4], float scale)
void unit_m4(float m[4][4])
void axis_angle_to_mat4_single(float R[4][4], char axis, float angle)
char * STRNCPY(char(&dst)[N], const char *src)
@ CONSTRAINT_TYPE_TRANSFORM_CACHE
@ eModifierType_MeshSequenceCache
Object is a sort of wrapper for general info.
BMesh const char void * data
std::string m_object_name
AbcObjectReader * parent_reader
Alembic::Abc::IObject m_iobject
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
void determine_inherits_xform()
virtual bool topology_changed(const Mesh *existing_mesh, const Alembic::Abc::ISampleSelector &sample_sel)
virtual Alembic::AbcGeom::IXform xform()
void setupObjectTransform(chrono_t time)
virtual void read_geometry(bke::GeometrySet &geometry_set, const Alembic::Abc::ISampleSelector &sample_sel, int read_flag, const char *velocity_name, float velocity_scale, const char **r_err_str)
bool m_is_reading_a_file_sequence
ImportSettings * m_settings
Imath::M44d get_matrix(const IXformSchema &schema, const chrono_t time)
void copy_m44_axis_swap(float dst_mat[4][4], float src_mat[4][4], AbcAxisSwapMode mode)
static Imath::M44d blend_matrices(const Imath::M44d &m0, const Imath::M44d &m1, const double weight)
Imath::M44d convert_matrix_datatype(const float mat[4][4])
std::optional< SampleInterpolationSettings > get_sample_interpolation_settings(const Alembic::AbcGeom::ISampleSelector &selector, const Alembic::AbcCoreAbstract::TimeSamplingPtr &time_sampling, size_t samples_number)
void split(const std::string &s, const char delim, std::vector< std::string > &tokens)
struct CacheFile * cache_file