30using Alembic::AbcGeom::IObject;
31using Alembic::AbcGeom::IXform;
32using Alembic::AbcGeom::IXformSchema;
39 m_settings(&settings),
40 m_is_reading_a_file_sequence(settings.is_sequence),
41 m_min_time(std::numeric_limits<chrono_t>::max()),
42 m_max_time(std::numeric_limits<chrono_t>::
min()),
44 parent_reader(nullptr)
46 m_name =
object.getFullName();
47 std::vector<std::string> parts;
50 if (parts.size() >= 2) {
65 IXform ixform =
xform();
70 const IXformSchema &schema(ixform.getSchema());
71 if (!schema.valid()) {
72 std::cerr <<
"Alembic object " << ixform.getFullName() <<
" has an invalid schema."
79 IObject ixform_parent = ixform.getParent();
80 if (!ixform_parent.getParent()) {
106 const Imath::M44d &m1,
109 float mat0[4][4], mat1[4][4],
ret[4][4];
122Imath::M44d
get_matrix(
const IXformSchema &schema,
const chrono_t time)
124 Alembic::AbcGeom::ISampleSelector selector(time);
126 const std::optional<SampleInterpolationSettings> interpolation_settings =
128 selector, schema.getTimeSampling(), schema.getNumSamples());
130 if (!interpolation_settings.has_value()) {
132 Alembic::AbcGeom::XformSample s0;
133 schema.get(s0, selector);
134 return s0.getMatrix();
137 Alembic::AbcGeom::XformSample s0, s1;
138 schema.get(s0, Alembic::AbcGeom::ISampleSelector(interpolation_settings->index));
139 schema.get(s1, Alembic::AbcGeom::ISampleSelector(interpolation_settings->ceil_index));
140 return blend_matrices(s0.getMatrix(), s1.getMatrix(), interpolation_settings->weight);
144 const Alembic::Abc::ISampleSelector & ,
153 const Alembic::Abc::ISampleSelector & )
162 bool is_constant =
false;
163 float transform_from_alembic[4][4];
191 if (IXform::matches(
m_iobject.getMetaData())) {
193 return IXform(
m_iobject, Alembic::AbcGeom::kWrapExisting);
195 catch (Alembic::Util::Exception &ex) {
196 printf(
"Alembic: error reading object transform for '%s': %s\n",
205 IObject abc_parent =
m_iobject.getParent();
208 if (abc_parent.getParent() && IXform::matches(abc_parent.getMetaData())) {
210 return IXform(abc_parent, Alembic::AbcGeom::kWrapExisting);
212 catch (Alembic::Util::Exception &ex) {
213 printf(
"Alembic: error reading object transform for '%s': %s\n",
214 abc_parent.getFullName().c_str(),
230 IXform ixform =
xform();
233 r_is_constant =
true;
237 const IXformSchema &schema(ixform.getSchema());
238 if (!schema.valid()) {
239 std::cerr <<
"Alembic object " << ixform.getFullName() <<
" has an invalid schema."
244 const Imath::M44d matrix =
get_matrix(schema, time);
252 float camera_rotation[4][4];
259 float scale_mat[4][4];
264 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(struct 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 unit_m4(float m[4][4])
void scale_m4_fl(float R[4][4], float scale)
void axis_angle_to_mat4_single(float R[4][4], char axis, float angle)
#define STRNCPY(dst, src)
@ CONSTRAINT_TYPE_TRANSFORM_CACHE
@ eModifierType_MeshSequenceCache
Object is a sort of wrapper for general info.
std::string m_object_name
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)
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
ObjectRuntimeHandle * runtime
bool always_add_cache_reader