Blender V4.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
10#include "abc_writer_abstract.h"
12
13#include <Alembic/AbcGeom/OPolyMesh.h>
14#include <Alembic/AbcGeom/OSubD.h>
15
16struct ModifierData;
17
18namespace blender::io::alembic {
19
20/* Writer for Alembic geometry. Does not assume the object is a mesh object. */
22 private:
23 /* Either poly-mesh or subdivision-surface is used, depending on is_subd_.
24 * References to the schema must be kept, or Alembic will not properly write. */
25 Alembic::AbcGeom::OPolyMesh abc_poly_mesh_;
26 Alembic::AbcGeom::OPolyMeshSchema abc_poly_mesh_schema_;
27
28 Alembic::AbcGeom::OSubD abc_subdiv_;
29 Alembic::AbcGeom::OSubDSchema abc_subdiv_schema_;
30
31 /* Determines whether a poly mesh or a subdivision surface is exported.
32 * The value is set by an export option but only true if there is a subdivision modifier on the
33 * exported object. */
34 bool is_subd_;
35 ModifierData *subsurf_modifier_;
36
37 CDStreamConfig m_custom_data_config;
38
39 public:
41
42 virtual void create_alembic_objects(const HierarchyContext *context) override;
43 virtual Alembic::Abc::OObject get_alembic_object() const override;
44 Alembic::Abc::OCompoundProperty abc_prop_for_custom_props() override;
45
46 protected:
47 virtual bool is_supported(const HierarchyContext *context) const override;
48 virtual void do_write(HierarchyContext &context) override;
49
50 virtual Mesh *get_export_mesh(Object *object_eval, bool &r_needsfree) = 0;
51 virtual void free_export_mesh(Mesh *mesh);
52
53 virtual bool export_as_subdivision_surface(Object *ob_eval) const;
54
55 private:
56 void write_mesh(HierarchyContext &context, Mesh *mesh);
57 void write_subd(HierarchyContext &context, Mesh *mesh);
58 template<typename Schema> void write_face_sets(Object *object, Mesh *mesh, Schema &schema);
59
60 void write_arb_geo_params(Mesh *mesh);
61 bool get_velocities(Mesh *mesh, std::vector<Imath::V3f> &vels);
62 void get_geo_groups(Object *object,
63 Mesh *mesh,
64 std::map<std::string, std::vector<int32_t>> &geo_groups);
65};
66
67/* Writer for Alembic geometry of Blender Mesh objects. */
69 public:
71
72 protected:
73 virtual Mesh *get_export_mesh(Object *object_eval, bool &r_needsfree) override;
74};
75
76} // namespace blender::io::alembic
virtual void do_write(HierarchyContext &context) override
ABCGenericMeshWriter(const ABCWriterConstructorArgs &args)
virtual Alembic::Abc::OObject get_alembic_object() const override
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)