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