Blender  V2.93
abc_writer_mesh.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  */
16 #pragma once
17 
22 #include "abc_writer_abstract.h"
23 #include "intern/abc_customdata.h"
24 
25 #include <Alembic/AbcGeom/OPolyMesh.h>
26 #include <Alembic/AbcGeom/OSubD.h>
27 
28 struct ModifierData;
29 
30 namespace blender::io::alembic {
31 
32 /* Writer for Alembic geometry. Does not assume the object is a mesh object. */
34  private:
35  /* Either poly-mesh or subdivision-surface is used, depending on is_subd_.
36  * References to the schema must be kept, or Alembic will not properly write. */
37  Alembic::AbcGeom::OPolyMesh abc_poly_mesh_;
38  Alembic::AbcGeom::OPolyMeshSchema abc_poly_mesh_schema_;
39 
40  Alembic::AbcGeom::OSubD abc_subdiv_;
41  Alembic::AbcGeom::OSubDSchema abc_subdiv_schema_;
42 
43  /* Determines whether a poly mesh or a subdivision surface is exported.
44  * The value is set by an export option but only true if there is a subdivision modifier on the
45  * exported object. */
46  bool is_subd_;
47  ModifierData *subsurf_modifier_;
48  ModifierData *liquid_sim_modifier_;
49 
50  CDStreamConfig m_custom_data_config;
51 
52  public:
53  explicit ABCGenericMeshWriter(const ABCWriterConstructorArgs &args);
54 
55  virtual void create_alembic_objects(const HierarchyContext *context) override;
56  virtual Alembic::Abc::OObject get_alembic_object() const override;
57  Alembic::Abc::OCompoundProperty abc_prop_for_custom_props() override;
58 
59  protected:
60  virtual bool is_supported(const HierarchyContext *context) const override;
61  virtual 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  ModifierData *get_liquid_sim_modifier(Scene *scene_eval, Object *ob_eval);
74 
75  void write_arb_geo_params(Mesh *me);
76  void get_velocities(Mesh *mesh, std::vector<Imath::V3f> &vels);
77  void get_geo_groups(Object *object,
78  Mesh *mesh,
79  std::map<std::string, std::vector<int32_t>> &geo_groups);
80 };
81 
82 /* Writer for Alembic geometry of Blender Mesh objects. */
84  public:
86 
87  protected:
88  virtual Mesh *get_export_mesh(Object *object_eval, bool &r_needsfree) override;
89 };
90 
91 } // 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)
struct SELECTID_Context context
Definition: select_engine.c:47