Blender V5.3
abc_writer_mesh.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4#pragma once
5
9
10#include "abc_writer_abstract.h"
13
14#include "BLI_vector.hh"
15
16#include <Alembic/AbcGeom/OPolyMesh.h>
17#include <Alembic/AbcGeom/OSubD.h>
18
19namespace blender {
20
21struct ModifierData;
22
23namespace io::alembic {
24
25/* Writer for Alembic geometry. Does not assume the object is a mesh object. */
27 private:
28 /* Either poly-mesh or subdivision-surface is used, depending on is_subd_.
29 * References to the schema must be kept, or Alembic will not properly write. */
30 Alembic::AbcGeom::OPolyMesh abc_poly_mesh_;
31 Alembic::AbcGeom::OPolyMeshSchema abc_poly_mesh_schema_;
32
33 Alembic::AbcGeom::OSubD abc_subdiv_;
34 Alembic::AbcGeom::OSubDSchema abc_subdiv_schema_;
35
36 Alembic::AbcGeom::OCompoundProperty abc_custom_data_container_;
37 Alembic::AbcGeom::OInt32Property abc_subdiv_render_levels_;
38 Alembic::AbcGeom::OInt32Property abc_subdiv_viewport_levels_;
39
40 /* Determines whether a poly mesh or a subdivision surface is exported.
41 * The value is set by an export option but only true if there is a subdivision modifier on the
42 * exported object. */
43 bool is_subd_;
44 ModifierData *subsurf_modifier_;
45
46 CDStreamConfig m_custom_data_config;
47 std::unique_ptr<AttributeParamMaps> attribute_maps_ = nullptr;
48
49 /* Names of all face sets created so far, across frames. */
50 Vector<std::string> face_set_names_;
51
52 public:
54
55 void create_alembic_objects(const HierarchyContext *context) override;
56 Alembic::Abc::OObject get_alembic_object() const override;
57 Alembic::Abc::OCompoundProperty abc_prop_for_custom_props() override;
58
59 protected:
60 bool is_supported(const HierarchyContext *context) const override;
61 void do_write(HierarchyContext &context) override;
62
63 virtual Mesh *get_export_mesh(Object *object_eval, bool &r_needsfree) = 0;
64 virtual void free_export_mesh(Mesh *mesh);
65
66 virtual bool export_as_subdivision_surface(Object *ob_eval) const;
67
68 private:
69 void write_mesh(HierarchyContext &context, Mesh *mesh);
70 void write_subd(HierarchyContext &context, Mesh *mesh);
71 template<typename Schema> void write_face_sets(Object *object, Mesh *mesh, Schema &schema);
72
73 void write_arb_geo_params(Mesh *mesh, const Object &object, const size_t num_geom_samples);
74 void get_geo_groups(Object *object,
75 Mesh *mesh,
76 std::map<std::string, std::vector<int32_t>> &geo_groups);
77
78 AttributeParamMaps &get_attribute_param_maps();
79};
80
81/* Writer for Alembic geometry of Blender Mesh objects. */
83 public:
85
86 protected:
87 Mesh *get_export_mesh(Object *object_eval, bool &r_needsfree) override;
88};
89
90} // namespace io::alembic
91} // namespace blender
ABCAbstractWriter(const ABCWriterConstructorArgs &args)
void do_write(HierarchyContext &context) override
ABCGenericMeshWriter(const ABCWriterConstructorArgs &args)
Alembic::Abc::OObject get_alembic_object() const override
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
void create_alembic_objects(const HierarchyContext *context) override
virtual bool export_as_subdivision_surface(Object *ob_eval) const
Mesh * get_export_mesh(Object *object_eval, bool &r_needsfree) override
ABCMeshWriter(const ABCWriterConstructorArgs &args)
BMesh Iterators.