50 using Alembic::Abc::FloatArraySample;
51 using Alembic::Abc::Int32ArraySample;
52 using Alembic::Abc::OObject;
53 using Alembic::Abc::V2fArraySample;
54 using Alembic::Abc::V3fArraySample;
56 using Alembic::AbcGeom::kFacevaryingScope;
57 using Alembic::AbcGeom::OBoolProperty;
58 using Alembic::AbcGeom::OCompoundProperty;
59 using Alembic::AbcGeom::OFaceSet;
60 using Alembic::AbcGeom::OFaceSetSchema;
61 using Alembic::AbcGeom::ON3fGeomParam;
62 using Alembic::AbcGeom::OPolyMesh;
63 using Alembic::AbcGeom::OPolyMeshSchema;
64 using Alembic::AbcGeom::OSubD;
65 using Alembic::AbcGeom::OSubDSchema;
66 using Alembic::AbcGeom::OV2fGeomParam;
67 using Alembic::AbcGeom::UInt32ArraySample;
75 std::vector<int32_t> &poly_verts,
76 std::vector<int32_t> &loop_counts,
77 bool &r_has_flat_shaded_poly);
80 std::vector<int32_t> &lengths,
81 std::vector<float> &sharpnesses);
83 std::vector<Imath::V3f> &
normals,
84 bool has_flat_shaded_poly);
100 abc_subdiv_schema_ = abc_subdiv_.getSchema();
105 abc_poly_mesh_schema_ = abc_poly_mesh_.getSchema();
107 OCompoundProperty typeContainer = abc_poly_mesh_.getSchema().getUserProperties();
108 OBoolProperty
type(typeContainer,
"meshtype");
109 type.set(subsurf_modifier_ ==
nullptr);
113 liquid_sim_modifier_ = get_liquid_sim_modifier(scene_eval,
context->object);
121 return abc_poly_mesh_;
136 for (; md; md = md->
prev) {
173 bool needsfree =
false;
177 if (
mesh ==
nullptr) {
182 const bool tag_only =
false;
198 mesh = triangulated_mesh;
236 std::vector<Imath::V3f> points,
normals;
237 std::vector<int32_t> poly_verts, loop_counts;
238 std::vector<Imath::V3f> velocities;
239 bool has_flat_shaded_poly =
false;
245 write_face_sets(
context.object,
mesh, abc_poly_mesh_schema_);
248 OPolyMeshSchema::Sample mesh_sample = OPolyMeshSchema::Sample(
249 V3fArraySample(points), Int32ArraySample(poly_verts), Int32ArraySample(loop_counts));
251 UVSample uvs_and_indices;
256 if (!uvs_and_indices.indices.empty() && !uvs_and_indices.uvs.empty()) {
257 OV2fGeomParam::Sample uv_sample;
258 uv_sample.setVals(V2fArraySample(uvs_and_indices.uvs));
259 uv_sample.setIndices(UInt32ArraySample(uvs_and_indices.indices));
260 uv_sample.setScope(kFacevaryingScope);
262 abc_poly_mesh_schema_.setUVSourceName(name);
263 mesh_sample.setUVs(uv_sample);
273 ON3fGeomParam::Sample normals_sample;
275 normals_sample.setScope(kFacevaryingScope);
276 normals_sample.setVals(V3fArraySample(
normals));
279 mesh_sample.setNormals(normals_sample);
282 if (liquid_sim_modifier_ !=
nullptr) {
283 get_velocities(
mesh, velocities);
284 mesh_sample.setVelocities(V3fArraySample(velocities));
290 abc_poly_mesh_schema_.set(mesh_sample);
292 write_arb_geo_params(
mesh);
295 void ABCGenericMeshWriter::write_subd(HierarchyContext &
context,
struct Mesh *
mesh)
297 std::vector<float> crease_sharpness;
298 std::vector<Imath::V3f> points;
299 std::vector<int32_t> poly_verts, loop_counts;
300 std::vector<int32_t> crease_indices, crease_lengths;
301 bool has_flat_poly =
false;
308 write_face_sets(
context.object,
mesh, abc_subdiv_schema_);
311 OSubDSchema::Sample subdiv_sample = OSubDSchema::Sample(
312 V3fArraySample(points), Int32ArraySample(poly_verts), Int32ArraySample(loop_counts));
319 OV2fGeomParam::Sample uv_sample;
320 uv_sample.setVals(V2fArraySample(
sample.uvs));
321 uv_sample.setIndices(UInt32ArraySample(
sample.indices));
322 uv_sample.setScope(kFacevaryingScope);
324 abc_subdiv_schema_.setUVSourceName(name);
325 subdiv_sample.setUVs(uv_sample);
332 if (!crease_indices.empty()) {
333 subdiv_sample.setCreaseIndices(Int32ArraySample(crease_indices));
334 subdiv_sample.setCreaseLengths(Int32ArraySample(crease_lengths));
335 subdiv_sample.setCreaseSharpnesses(FloatArraySample(crease_sharpness));
340 abc_subdiv_schema_.set(subdiv_sample);
342 write_arb_geo_params(
mesh);
345 template<
typename Schema>
346 void ABCGenericMeshWriter::write_face_sets(
Object *
object,
struct Mesh *
mesh, Schema &schema)
348 std::map<std::string, std::vector<int32_t>> geo_groups;
349 get_geo_groups(
object,
mesh, geo_groups);
351 std::map<std::string, std::vector<int32_t>>::iterator it;
352 for (it = geo_groups.begin(); it != geo_groups.end(); ++it) {
353 OFaceSet face_set = schema.createFaceSet(it->first);
354 OFaceSetSchema::Sample samp;
355 samp.setFaces(Int32ArraySample(it->second));
356 face_set.getSchema().set(samp);
360 void ABCGenericMeshWriter::write_arb_geo_params(
struct Mesh *me)
362 if (liquid_sim_modifier_ !=
nullptr) {
371 OCompoundProperty arb_geom_params;
373 arb_geom_params = abc_subdiv_.getSchema().getArbGeomParams();
376 arb_geom_params = abc_poly_mesh_.getSchema().getArbGeomParams();
381 void ABCGenericMeshWriter::get_velocities(
struct Mesh *
mesh, std::vector<Imath::V3f> &vels)
386 vels.resize(totverts);
392 float *mesh_vels =
reinterpret_cast<float *
>(fss->
meshVelocities);
394 for (
int i = 0; i < totverts; i++) {
400 std::fill(vels.begin(), vels.end(), Imath::V3f(0.0f));
404 void ABCGenericMeshWriter::get_geo_groups(
Object *
object,
406 std::map<std::string, std::vector<int32_t>> &geo_groups)
411 for (
int i = 0; i < num_poly; i++) {
412 MPoly ¤t_poly = polygons[i];
413 short mnr = current_poly.
mat_nr;
423 if (geo_groups.find(name) == geo_groups.end()) {
424 std::vector<int32_t> faceArray;
425 geo_groups[name] = faceArray;
428 geo_groups[name].push_back(i);
431 if (geo_groups.empty()) {
436 std::vector<int32_t> faceArray;
439 faceArray.push_back(i);
442 geo_groups[name] = faceArray;
461 std::vector<int32_t> &poly_verts,
462 std::vector<int32_t> &loop_counts,
463 bool &r_has_flat_shaded_poly)
469 r_has_flat_shaded_poly =
false;
473 poly_verts.reserve(num_loops);
474 loop_counts.reserve(num_poly);
477 for (
int i = 0; i < num_poly; i++) {
478 MPoly &poly = mpoly[i];
479 loop_counts.push_back(poly.
totloop);
485 for (
int j = 0; j < poly.
totloop; j++, loop--) {
486 poly_verts.push_back(loop->
v);
493 std::vector<int32_t> &lengths,
494 std::vector<float> &sharpnesses)
496 const float factor = 1.0f / 255.0f;
505 const float sharpness =
static_cast<float>(edge[i].
crease) * factor;
507 if (sharpness != 0.0f) {
510 sharpnesses.push_back(sharpness);
514 lengths.resize(sharpnesses.size(), 2);
518 std::vector<Imath::V3f> &
normals,
519 bool has_flat_shaded_poly)
532 BLI_assert(lnors !=
nullptr || !
"BKE_mesh_calc_normals_split() should have computed CD_NORMAL");
540 for (
int j = mp->
totloop - 1; j >= 0; j--, abc_index++) {
typedef float(TangentPoint)[2]
CustomData interface, see also DNA_customdata_types.h.
bool CustomData_has_layer(const struct CustomData *data, int type)
void * CustomData_get_layer(const struct CustomData *data, int type)
void BKE_id_free(struct Main *bmain, void *idv)
General operations, lookup, etc. for materials.
struct Material * BKE_object_material_get(struct Object *ob, short act)
struct BMesh * BKE_mesh_to_bmesh_ex(const struct Mesh *me, const struct BMeshCreateParams *create_params, const struct BMeshFromMeshParams *convert_params)
struct Mesh * BKE_mesh_from_bmesh_for_eval_nomain(struct BMesh *bm, const struct CustomData_MeshMasks *cd_mask_extra, const struct Mesh *me_settings)
void BKE_mesh_calc_normals_split(struct Mesh *mesh)
bool BKE_modifier_is_enabled(const struct Scene *scene, struct ModifierData *md, int required_mode)
struct ModifierData * BKE_modifiers_findby_type(const struct Object *ob, ModifierType type)
General operations, lookup, etc. for blender objects.
struct Mesh * BKE_object_get_evaluated_mesh(struct Object *object)
#define CLOG_INFO(clg_ref, level,...)
struct Scene * DEG_get_evaluated_scene(const struct Depsgraph *graph)
@ eModifierMode_DisableTemporary
#define OB_FLUIDSIM_DOMAIN
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble v1
ATTR_WARN_UNUSED_RESULT BMesh * bm
void BM_mesh_free(BMesh *bm)
BMesh Free Mesh.
ATTR_WARN_UNUSED_RESULT const BMVert * v2
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
void BM_mesh_triangulate(BMesh *bm, const int quad_method, const int ngon_method, const int min_vertices, const bool tag_only, BMOperator *op, BMOpSlot *slot_facemap_out, BMOpSlot *slot_facemap_double_out)
virtual std::string get_id_name(const ID *id) const
Alembic::Abc::OCompoundProperty abc_schema_prop_for_custom_props(T abc_schema)
uint32_t timesample_index_
bool frame_has_been_written_
Imath::Box3d bounding_box_
const ABCWriterConstructorArgs args_
virtual void update_bounding_box(Object *object)
virtual void do_write(HierarchyContext &context) override
ABCGenericMeshWriter(const ABCWriterConstructorArgs &args)
virtual Alembic::Abc::OObject get_alembic_object() const override
virtual void free_export_mesh(Mesh *mesh)
virtual bool is_supported(const HierarchyContext *context) const override
virtual Mesh * get_export_mesh(Object *object_eval, bool &r_needsfree)=0
Alembic::Abc::OCompoundProperty abc_prop_for_custom_props() override
virtual void create_alembic_objects(const HierarchyContext *context) override
virtual bool export_as_subdivision_surface(Object *ob_eval) const
virtual Mesh * get_export_mesh(Object *object_eval, bool &r_needsfree) override
ABCMeshWriter(const ABCWriterConstructorArgs &args)
static float normals[][3]
static void sample(SocketReader *reader, int x, int y, float color[4])
BLI_INLINE void copy_yup_from_zup(float yup[3], const float zup[3])
static void get_topology(struct Mesh *mesh, std::vector< int32_t > &poly_verts, std::vector< int32_t > &loop_counts, bool &r_has_flat_shaded_poly)
const char * get_uv_sample(UVSample &sample, const CDStreamConfig &config, CustomData *data)
static void get_creases(struct Mesh *mesh, std::vector< int32_t > &indices, std::vector< int32_t > &lengths, std::vector< float > &sharpnesses)
void write_custom_data(const OCompoundProperty &prop, CDStreamConfig &config, CustomData *data, int data_type)
static void get_loop_normals(struct Mesh *mesh, std::vector< Imath::V3f > &normals, bool has_flat_shaded_poly)
static void get_vertices(struct Mesh *mesh, std::vector< Imath::V3f > &points)
struct SELECTID_Context context
enum eEvaluationMode evaluation_mode
bool visible_objects_only
struct FluidsimSettings * fss
struct FluidVertexVelocity * meshVelocities
struct CustomData pdata ldata
struct ModifierData * prev
const ABCHierarchyIterator * hierarchy_iterator
Alembic::Abc::OObject abc_parent
const AlembicExportParams * export_params