37 using Alembic::Abc::FloatArraySample;
38 using Alembic::Abc::Int32ArraySample;
39 using Alembic::Abc::OObject;
40 using Alembic::Abc::V2fArraySample;
41 using Alembic::Abc::V3fArraySample;
43 using Alembic::AbcGeom::kFacevaryingScope;
44 using Alembic::AbcGeom::OBoolProperty;
45 using Alembic::AbcGeom::OCompoundProperty;
46 using Alembic::AbcGeom::OFaceSet;
47 using Alembic::AbcGeom::OFaceSetSchema;
48 using Alembic::AbcGeom::ON3fGeomParam;
49 using Alembic::AbcGeom::OPolyMesh;
50 using Alembic::AbcGeom::OPolyMeshSchema;
51 using Alembic::AbcGeom::OSubD;
52 using Alembic::AbcGeom::OSubDSchema;
53 using Alembic::AbcGeom::OV2fGeomParam;
54 using Alembic::AbcGeom::UInt32ArraySample;
62 std::vector<int32_t> &poly_verts,
63 std::vector<int32_t> &loop_counts,
64 bool &r_has_flat_shaded_poly);
67 std::vector<int32_t> &lengths,
68 std::vector<float> &sharpnesses);
71 std::vector<float> &sharpnesses);
73 std::vector<Imath::V3f> &
normals,
74 bool has_flat_shaded_poly);
90 abc_subdiv_schema_ = abc_subdiv_.getSchema();
95 abc_poly_mesh_schema_ = abc_poly_mesh_.getSchema();
97 OCompoundProperty typeContainer = abc_poly_mesh_.getSchema().getUserProperties();
98 OBoolProperty
type(typeContainer,
"meshtype");
99 type.set(subsurf_modifier_ ==
nullptr);
108 return abc_poly_mesh_;
123 for (; md; md = md->
prev) {
145 bool needsfree =
false;
149 if (
mesh ==
nullptr) {
154 const bool tag_only =
false;
161 bmesh_from_mesh_params.calc_vert_normal =
true;
172 mesh = triangulated_mesh;
212 std::vector<Imath::V3f> points,
normals;
213 std::vector<int32_t> poly_verts, loop_counts;
214 std::vector<Imath::V3f> velocities;
215 bool has_flat_shaded_poly =
false;
221 write_face_sets(
context.object,
mesh, abc_poly_mesh_schema_);
224 OPolyMeshSchema::Sample mesh_sample = OPolyMeshSchema::Sample(
225 V3fArraySample(points), Int32ArraySample(poly_verts), Int32ArraySample(loop_counts));
227 UVSample uvs_and_indices;
232 if (!uvs_and_indices.indices.empty() && !uvs_and_indices.uvs.empty()) {
233 OV2fGeomParam::Sample uv_sample;
234 uv_sample.setVals(V2fArraySample(uvs_and_indices.uvs));
235 uv_sample.setIndices(UInt32ArraySample(uvs_and_indices.indices));
236 uv_sample.setScope(kFacevaryingScope);
238 abc_poly_mesh_schema_.setUVSourceName(name);
239 mesh_sample.setUVs(uv_sample);
249 ON3fGeomParam::Sample normals_sample;
251 normals_sample.setScope(kFacevaryingScope);
252 normals_sample.setVals(V3fArraySample(
normals));
255 mesh_sample.setNormals(normals_sample);
262 if (get_velocities(
mesh, velocities)) {
263 mesh_sample.setVelocities(V3fArraySample(velocities));
269 abc_poly_mesh_schema_.set(mesh_sample);
271 write_arb_geo_params(
mesh);
274 void ABCGenericMeshWriter::write_subd(HierarchyContext &
context,
struct Mesh *
mesh)
276 std::vector<float> edge_crease_sharpness, vert_crease_sharpness;
277 std::vector<Imath::V3f> points;
278 std::vector<int32_t> poly_verts, loop_counts;
279 std::vector<int32_t> edge_crease_indices, edge_crease_lengths, vert_crease_indices;
280 bool has_flat_poly =
false;
288 write_face_sets(
context.object,
mesh, abc_subdiv_schema_);
291 OSubDSchema::Sample subdiv_sample = OSubDSchema::Sample(
292 V3fArraySample(points), Int32ArraySample(poly_verts), Int32ArraySample(loop_counts));
299 OV2fGeomParam::Sample uv_sample;
300 uv_sample.setVals(V2fArraySample(
sample.uvs));
301 uv_sample.setIndices(UInt32ArraySample(
sample.indices));
302 uv_sample.setScope(kFacevaryingScope);
304 abc_subdiv_schema_.setUVSourceName(name);
305 subdiv_sample.setUVs(uv_sample);
316 if (!edge_crease_indices.empty()) {
317 subdiv_sample.setCreaseIndices(Int32ArraySample(edge_crease_indices));
318 subdiv_sample.setCreaseLengths(Int32ArraySample(edge_crease_lengths));
319 subdiv_sample.setCreaseSharpnesses(FloatArraySample(edge_crease_sharpness));
322 if (!vert_crease_indices.empty()) {
323 subdiv_sample.setCornerIndices(Int32ArraySample(vert_crease_indices));
324 subdiv_sample.setCornerSharpnesses(FloatArraySample(vert_crease_sharpness));
329 abc_subdiv_schema_.set(subdiv_sample);
331 write_arb_geo_params(
mesh);
334 template<
typename Schema>
335 void ABCGenericMeshWriter::write_face_sets(
Object *
object,
struct Mesh *
mesh, Schema &schema)
337 std::map<std::string, std::vector<int32_t>> geo_groups;
338 get_geo_groups(
object,
mesh, geo_groups);
340 std::map<std::string, std::vector<int32_t>>::iterator it;
341 for (it = geo_groups.begin(); it != geo_groups.end(); ++it) {
342 OFaceSet face_set = schema.createFaceSet(it->first);
343 OFaceSetSchema::Sample samp;
344 samp.setFaces(Int32ArraySample(it->second));
345 face_set.getSchema().set(samp);
349 void ABCGenericMeshWriter::write_arb_geo_params(
struct Mesh *me)
355 OCompoundProperty arb_geom_params;
357 arb_geom_params = abc_subdiv_.getSchema().getArbGeomParams();
360 arb_geom_params = abc_poly_mesh_.getSchema().getArbGeomParams();
365 bool ABCGenericMeshWriter::get_velocities(
struct Mesh *
mesh, std::vector<Imath::V3f> &vels)
372 if (velocity_layer ==
nullptr) {
377 const float(*mesh_velocities)[3] =
reinterpret_cast<float(*)[3]
>(velocity_layer->
data);
380 vels.resize(totverts);
382 for (
int i = 0; i < totverts; i++) {
389 void ABCGenericMeshWriter::get_geo_groups(
Object *
object,
391 std::map<std::string, std::vector<int32_t>> &geo_groups)
396 for (
int i = 0; i < num_poly; i++) {
397 MPoly ¤t_poly = polygons[i];
398 short mnr = current_poly.
mat_nr;
408 if (geo_groups.find(name) == geo_groups.end()) {
409 std::vector<int32_t> faceArray;
410 geo_groups[name] = faceArray;
413 geo_groups[name].push_back(i);
416 if (geo_groups.empty()) {
421 std::vector<int32_t> faceArray;
424 faceArray.push_back(i);
427 geo_groups[name] = faceArray;
446 std::vector<int32_t> &poly_verts,
447 std::vector<int32_t> &loop_counts,
448 bool &r_has_flat_shaded_poly)
454 r_has_flat_shaded_poly =
false;
458 poly_verts.reserve(num_loops);
459 loop_counts.reserve(num_poly);
462 for (
int i = 0; i < num_poly; i++) {
463 MPoly &poly = mpoly[i];
464 loop_counts.push_back(poly.
totloop);
470 for (
int j = 0; j < poly.
totloop; j++, loop--) {
471 poly_verts.push_back(loop->
v);
478 std::vector<int32_t> &lengths,
479 std::vector<float> &sharpnesses)
481 const float factor = 1.0f / 255.0f;
490 const float sharpness =
static_cast<float>(edge[i].crease) * factor;
492 if (sharpness != 0.0f) {
495 sharpnesses.push_back(sharpness);
499 lengths.resize(sharpnesses.size(), 2);
504 std::vector<float> &sharpnesses)
516 const float sharpness = creases[i];
518 if (sharpness != 0.0f) {
520 sharpnesses.push_back(sharpness);
526 std::vector<Imath::V3f> &
normals,
527 bool has_flat_shaded_poly)
540 BLI_assert_msg(lnors !=
nullptr,
"BKE_mesh_calc_normals_split() should have computed CD_NORMAL");
548 for (
int j = mp->
totloop - 1; j >= 0; j--, abc_index++) {
typedef float(TangentPoint)[2]
Generic geometry attributes built on CustomData.
struct CustomDataLayer * BKE_id_attribute_find(const struct ID *id, const char *name, int type, eAttrDomain domain)
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)
General operations, lookup, etc. for blender objects.
struct Mesh * BKE_object_get_evaluated_mesh(const struct Object *object)
#define BLI_assert_msg(a, msg)
#define CLOG_INFO(clg_ref, level,...)
@ eModifierMode_DisableTemporary
_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
ATTR_WARN_UNUSED_RESULT const BMVert * v
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)
ccl_gpu_kernel_postfix int ccl_global int * indices
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)
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)
void write_generated_coordinates(const OCompoundProperty &prop, CDStreamConfig &config)
static void get_vertices(struct Mesh *mesh, std::vector< Imath::V3f > &points)
static void get_vert_creases(struct Mesh *mesh, std::vector< int32_t > &indices, std::vector< float > &sharpnesses)
static void get_edge_creases(struct Mesh *mesh, std::vector< int32_t > &indices, std::vector< int32_t > &lengths, std::vector< float > &sharpnesses)
MutableSpan< float3 > normals
SocketIndexByIdentifierMap * map
enum eEvaluationMode evaluation_mode
bool visible_objects_only
struct ModifierData * prev
const ABCHierarchyIterator * hierarchy_iterator
Alembic::Abc::OObject abc_parent
const AlembicExportParams * export_params