26 using Alembic::Abc::FloatArraySamplePtr;
27 using Alembic::Abc::Int32ArraySamplePtr;
28 using Alembic::Abc::P3fArraySamplePtr;
29 using Alembic::Abc::PropertyHeader;
30 using Alembic::Abc::UcharArraySamplePtr;
32 using Alembic::AbcGeom::CurvePeriodicity;
33 using Alembic::AbcGeom::ICompoundProperty;
34 using Alembic::AbcGeom::ICurves;
35 using Alembic::AbcGeom::ICurvesSchema;
36 using Alembic::AbcGeom::IFloatGeomParam;
37 using Alembic::AbcGeom::IInt16Property;
38 using Alembic::AbcGeom::ISampleSelector;
39 using Alembic::AbcGeom::kWrapExisting;
46 ICurves abc_curves(
object, kWrapExisting);
47 m_curves_schema = abc_curves.getSchema();
54 return m_curves_schema.valid();
58 const Alembic::AbcCoreAbstract::ObjectHeader &alembic_header,
60 const char **err_str)
const
62 if (!Alembic::AbcGeom::ICurves::matches(alembic_header)) {
64 "Object type mismatch, Alembic object path pointed to Curves when importing, but not any "
70 *err_str =
"Object type mismatch, Alembic object path points to Curves.";
85 ICompoundProperty user_props = m_curves_schema.getUserProperties();
88 if (header !=
nullptr && header->isScalar() && IInt16Property::matches(*header)) {
89 IInt16Property resolu(user_props, header->getName());
90 cu->
resolu = resolu.getValue(sample_sel);
105 const ICurvesSchema &schema,
106 const ISampleSelector &sample_sel)
108 ICurvesSchema::Sample smp;
110 smp = schema.getValue(sample_sel);
112 catch (Alembic::Util::Exception &ex) {
113 printf(
"Alembic: error reading curve sample for '%s/%s' at time %f: %s\n",
115 schema.getName().c_str(),
116 sample_sel.getRequestedTime(),
121 const Int32ArraySamplePtr num_vertices = smp.getCurvesNumVertices();
122 const P3fArraySamplePtr
positions = smp.getPositions();
123 const FloatArraySamplePtr weights = smp.getPositionWeights();
124 const FloatArraySamplePtr knots = smp.getKnots();
125 const CurvePeriodicity periodicity = smp.getWrap();
126 const UcharArraySamplePtr orders = smp.getOrders();
128 const IFloatGeomParam widths_param = schema.getWidthsParam();
129 FloatArraySamplePtr radiuses;
131 if (widths_param.valid()) {
132 IFloatGeomParam::Sample wsample = widths_param.getExpandedValue(sample_sel);
133 radiuses = wsample.getVals();
139 for (
size_t i = 0; i < num_vertices->size(); i++) {
140 const int num_verts = (*num_vertices)[i];
145 nu->
pntsu = num_verts;
149 switch (smp.getType()) {
150 case Alembic::AbcGeom::kCubic:
153 case Alembic::AbcGeom::kVariableOrder:
154 if (orders && orders->size() > i) {
155 nu->
orderu =
static_cast<short>((*orders)[i]);
159 case Alembic::AbcGeom::kLinear:
164 if (periodicity == Alembic::AbcGeom::kNonPeriodic) {
167 else if (periodicity == Alembic::AbcGeom::kPeriodic) {
176 const int start = idx;
177 const int end = idx + num_verts;
180 for (
int j = start, k = end - nu->
orderu; j < nu->orderu; j++, k++) {
181 const Imath::V3f &p1 = (*positions)[j];
182 const Imath::V3f &p2 = (*positions)[k];
192 if (overlap == 0 && num_verts > 2 && (*
positions)[start] == (*positions)[end - 1]) {
202 nu->
pntsu -= overlap;
205 const bool do_weights = (weights !=
nullptr) && (weights->size() > 1);
208 const bool do_radius = (radiuses !=
nullptr) && (radiuses->size() > 1);
209 float radius = (radiuses && radiuses->size() == 1) ? (*radiuses)[0] : 1.0f;
216 for (
int j = 0; j < nu->
pntsu; j++, bp++, idx++) {
217 const Imath::V3f &
pos = (*positions)[idx];
220 radius = (*radiuses)[idx];
224 weight = (*weights)[idx];
234 if (knots && knots->size() != 0) {
235 nu->
knotsu =
static_cast<float *
>(
239 if (periodicity == Alembic::AbcGeom::kPeriodic && (
KNOTSU(nu) == knots->size() - 2)) {
241 for (
size_t i = 1; i < knots->size() - 1; i++) {
242 nu->
knotsu[i - 1] = (*knots)[knot_offset + i];
251 knot_offset += knots->size();
262 const ISampleSelector &sample_sel,
266 const char **err_str)
268 ICurvesSchema::Sample
sample;
271 sample = m_curves_schema.getValue(sample_sel);
273 catch (Alembic::Util::Exception &ex) {
274 *err_str =
"Error reading curve sample; more detail on the console";
275 printf(
"Alembic: error reading curve sample for '%s/%s' at time %f: %s\n",
277 m_curves_schema.getName().c_str(),
278 sample_sel.getRequestedTime(),
280 return existing_mesh;
284 const Int32ArraySamplePtr num_vertices =
sample.getCurvesNumVertices();
291 bool same_topology = curve_count == num_vertices->size();
295 for (curve_idx = 0; nurbs; nurbs = nurbs->
next, curve_idx++) {
296 const int num_in_alembic = (*num_vertices)[curve_idx];
297 const int num_in_blender = nurbs->
pntsu;
299 if (num_in_alembic != num_in_blender) {
300 same_topology =
false;
306 if (!same_topology) {
312 for (curve_idx = 0; nurbs; nurbs = nurbs->
next, curve_idx++) {
313 const int totpoint = (*num_vertices)[curve_idx];
318 for (
int i = 0; i < totpoint; i++,
point++, vertex_idx++) {
319 const Imath::V3f &
pos = (*positions)[vertex_idx];
323 else if (nurbs->
bezt) {
326 for (
int i = 0; i < totpoint; i++, bezier++, vertex_idx++) {
327 const Imath::V3f &
pos = (*positions)[vertex_idx];
struct Curve * BKE_curve_add(struct Main *bmain, const char *name, int type)
void BKE_nurb_knot_calc_u(struct Nurb *nu)
void BKE_nurbList_free(struct ListBase *lb)
ListBase * BKE_curve_nurbs_get(struct Curve *cu)
struct Mesh * BKE_mesh_new_nomain_from_curve(const struct Object *ob)
General operations, lookup, etc. for blender objects.
struct Object * BKE_object_add_only_object(struct Main *bmain, int type, const char *name) ATTR_RETURNS_NONNULL
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
int BLI_listbase_count(const struct ListBase *listbase) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Object is a sort of wrapper for general info.
Read Guarded memory(de)allocation.
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block Image Sample an image file as a texture Sky Generate a procedural sky texture Noise Generate fractal Perlin noise Wave Generate procedural bands or rings with noise Voronoi Generate Worley noise based on the distance to random points Typically used to generate textures such as or biological cells Brick Generate a procedural texture producing bricks Texture Retrieve multiple types of texture coordinates nTypically used as inputs for texture nodes Vector Convert a point
bool accepts_object_type(const Alembic::AbcCoreAbstract::ObjectHeader &alembic_header, const Object *const ob, const char **err_str) const override
void readObjectData(Main *bmain, const Alembic::Abc::ISampleSelector &sample_sel) override
void read_curve_sample(Curve *cu, const Alembic::AbcGeom::ICurvesSchema &schema, const Alembic::Abc::ISampleSelector &sample_selector)
bool valid() const override
struct Mesh * read_mesh(struct Mesh *existing_mesh, const Alembic::Abc::ISampleSelector &sample_sel, int read_flag, const char *velocity_name, float velocity_scale, const char **err_str) override
AbcCurveReader(const Alembic::Abc::IObject &object, ImportSettings &settings)
std::string m_object_name
Alembic::Abc::IObject m_iobject
ImportSettings * m_settings
void *(* MEM_callocN)(size_t len, const char *str)
void get_min_max_time(const Alembic::AbcGeom::IObject &object, const Schema &schema, chrono_t &min, chrono_t &max)
BLI_INLINE void copy_zup_from_yup(float zup[3], const float yup[3])
const std::string ABC_CURVE_RESOLUTION_U_PROPNAME
bool has_animations(Alembic::AbcGeom::IPolyMeshSchema &schema, ImportSettings *settings)
MutableSpan< float3 > positions
bool always_add_cache_reader