28 using Alembic::Abc::P3fArraySamplePtr;
29 using Alembic::AbcGeom::OCurves;
30 using Alembic::AbcGeom::OCurvesSchema;
31 using Alembic::AbcGeom::ON3fGeomParam;
32 using Alembic::AbcGeom::OV2fGeomParam;
45 abc_curves_schema_ = abc_curves_.getSchema();
70 std::vector<Imath::V3f>
verts;
71 std::vector<int32_t> hvertices;
72 std::vector<Imath::V2f> uv_values;
73 std::vector<Imath::V3f> norm_values;
84 if (export_children) {
85 write_hair_child_sample(
context,
mesh,
verts, norm_values, uv_values, hvertices);
89 Alembic::Abc::P3fArraySample iPos(
verts);
90 OCurvesSchema::Sample
sample(iPos, hvertices);
91 sample.setBasis(Alembic::AbcGeom::kNoBasis);
92 sample.setType(Alembic::AbcGeom::kLinear);
93 sample.setWrap(Alembic::AbcGeom::kNonPeriodic);
95 if (!uv_values.empty()) {
96 OV2fGeomParam::Sample uv_smp;
97 uv_smp.setVals(uv_values);
101 if (!norm_values.empty()) {
102 ON3fGeomParam::Sample norm_smp;
103 norm_smp.setVals(norm_values);
104 sample.setNormals(norm_smp);
109 abc_curves_schema_.set(
sample);
114 std::vector<Imath::V3f> &
verts,
115 std::vector<Imath::V3f> &norm_values,
116 std::vector<Imath::V2f> &uv_values,
117 std::vector<int32_t> &hvertices)
128 if ((!mtface || !mface) && !uv_warning_shown_) {
130 "Warning, no UV set found for underlying geometry of %s.\n",
132 uv_warning_shown_ =
true;
145 for (
int p = 0; p < psys->
totpart; p++, pa++) {
153 if (num < mesh->totface) {
155 MFace *face = mface ==
nullptr ? nullptr : &mface[num];
156 MTFace *tface = mtface + num;
159 float r_uv[2], mapfw[4], vec[3];
162 uv_values.emplace_back(r_uv[0], r_uv[1]);
178 norm_values.push_back(tmp_nor);
182 std::fprintf(stderr,
"Particle to faces overflow (%d/%d)\n", num,
mesh->
totface);
191 MFace *face = &mface[n];
192 MTFace *tface = mtface + n;
200 for (
int o = 0; o < 4; o++) {
201 if (o > 2 && vtx[o] == 0) {
206 uv_values.emplace_back(tface->
uv[o][0], tface->
uv[o][1]);
209 norm_values.push_back(tmp_nor);
222 hvertices.push_back(
steps);
224 for (k = 0; k <
steps; k++, path++) {
230 verts.emplace_back(vert[0], vert[2], -vert[1]);
235 void ABCHairWriter::write_hair_child_sample(
const HierarchyContext &
context,
237 std::vector<Imath::V3f> &
verts,
238 std::vector<Imath::V3f> &norm_values,
239 std::vector<Imath::V2f> &uv_values,
240 std::vector<int32_t> &hvertices)
257 for (
int p = 0; p < psys->
totchild; p++, pc++) {
261 const int num = pc->
num;
265 "Child particle of hair system %s has unknown face index of geometry of %s, skipping "
273 MTFace *tface = mtface + num;
275 float r_uv[2], tmpnor[3], mapfw[4], vec[3];
278 uv_values.emplace_back(r_uv[0], r_uv[1]);
294 norm_values.emplace_back(tmpnor[0], tmpnor[2], -tmpnor[1]);
297 if (!uv_values.empty()) {
298 uv_values.push_back(uv_values[pc->
parent]);
300 if (!norm_values.empty()) {
301 norm_values.push_back(norm_values[pc->
parent]);
306 hvertices.push_back(
steps);
308 for (
int k = 0; k <
steps; k++) {
314 verts.emplace_back(vert[0], vert[2], -vert[1]);
typedef float(TangentPoint)[2]
CustomData interface, see also DNA_customdata_types.h.
const CustomData_MeshMasks CD_MASK_MESH
const float(* BKE_mesh_vertex_normals_ensure(const struct Mesh *mesh))[3]
void BKE_mesh_tessface_ensure(struct Mesh *mesh)
struct Mesh * mesh_get_eval_final(struct Depsgraph *depsgraph, const struct Scene *scene, struct Object *ob, const struct CustomData_MeshMasks *dataMask)
void psys_interpolate_uvs(const struct MTFace *tface, int quad, const float w[4], float uvco[2])
void psys_interpolate_face(struct Mesh *mesh, struct MVert *mvert, const float(*vert_normals)[3], struct MFace *mface, struct MTFace *tface, const float(*orcodata)[3], float w[4], float vec[3], float nor[3], float utan[3], float vtan[3], float orco[3])
void mul_m4_v3(const float M[4][4], float r[3])
void invert_m4_m4_safe(float Ainv[4][4], const float A[4][4])
MINLINE void copy_v3_v3(float r[3], const float a[3])
#define CLOG_WARN(clg_ref,...)
#define CLOG_INFO(clg_ref, level,...)
struct Scene * DEG_get_evaluated_scene(const struct Depsgraph *graph)
Object is a sort of wrapper for general info.
#define PART_CHILD_PARTICLES
Alembic::Abc::OCompoundProperty abc_schema_prop_for_custom_props(T abc_schema)
uint32_t timesample_index_
Imath::Box3d bounding_box_
const ABCWriterConstructorArgs args_
virtual void update_bounding_box(Object *object)
virtual Alembic::Abc::OObject get_alembic_object() const override
ABCHairWriter(const ABCWriterConstructorArgs &args)
virtual void do_write(HierarchyContext &context) override
virtual bool check_is_animated(const HierarchyContext &context) const override
Alembic::Abc::OCompoundProperty abc_prop_for_custom_props() override
virtual void create_alembic_objects(const HierarchyContext *context) override
IconTextureDrawCall normal
BLI_INLINE void copy_yup_from_zup(float yup[3], const float zup[3])
struct ParticleCacheKey ** childcache
struct ParticleCacheKey ** pathcache
Alembic::Abc::OObject abc_parent