2 * ***** BEGIN GPL LICENSE BLOCK *****
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * Contributor(s): Esteban Tovagliari, Cedric Paille, Kevin Dietrich
20 * ***** END GPL LICENSE BLOCK *****
23 #ifndef __ABC_MESH_H__
24 #define __ABC_MESH_H__
26 #include "abc_customdata.h"
27 #include "abc_object.h"
33 /* ************************************************************************** */
35 class AbcMeshWriter : public AbcObjectWriter {
36 Alembic::AbcGeom::OPolyMeshSchema m_mesh_schema;
37 Alembic::AbcGeom::OPolyMeshSchema::Sample m_mesh_sample;
39 Alembic::AbcGeom::OSubDSchema m_subdiv_schema;
40 Alembic::AbcGeom::OSubDSchema::Sample m_subdiv_sample;
42 Alembic::Abc::OArrayProperty m_mat_indices;
45 ModifierData *m_subsurf_mod;
47 CDStreamConfig m_custom_data_config;
53 AbcMeshWriter(Scene *scene,
55 AbcTransformWriter *parent,
56 uint32_t time_sampling,
57 ExportSettings &settings);
62 virtual void do_write();
64 bool isAnimated() const;
66 void writeMesh(DerivedMesh *dm);
67 void writeSubD(DerivedMesh *dm);
69 void getMeshInfo(DerivedMesh *dm, std::vector<float> &points,
70 std::vector<int32_t> &facePoints,
71 std::vector<int32_t> &faceCounts,
72 std::vector<int32_t> &creaseIndices,
73 std::vector<int32_t> &creaseLengths,
74 std::vector<float> &creaseSharpness);
76 DerivedMesh *getFinalMesh();
77 void freeMesh(DerivedMesh *dm);
79 void getMaterialIndices(DerivedMesh *dm, std::vector<int32_t> &indices);
81 void writeArbGeoParams(DerivedMesh *dm);
82 void getGeoGroups(DerivedMesh *dm, std::map<std::string, std::vector<int32_t> > &geoGroups);
84 /* fluid surfaces support */
85 void getVelocities(DerivedMesh *dm, std::vector<Imath::V3f> &vels);
87 template <typename Schema>
88 void writeFaceSets(DerivedMesh *dm, Schema &schema);
91 /* ************************************************************************** */
93 class AbcMeshReader : public AbcObjectReader {
94 Alembic::AbcGeom::IPolyMeshSchema m_schema;
96 CDStreamConfig m_mesh_data;
99 AbcMeshReader(const Alembic::Abc::IObject &object, ImportSettings &settings);
103 void readObjectData(Main *bmain, float time);
105 DerivedMesh *read_derivedmesh(DerivedMesh *dm, const float time, int read_flag, const char **err_str);
108 void readFaceSetsSample(Main *bmain, Mesh *mesh, size_t poly_start,
109 const Alembic::AbcGeom::ISampleSelector &sample_sel);
112 /* ************************************************************************** */
114 class AbcSubDReader : public AbcObjectReader {
115 Alembic::AbcGeom::ISubDSchema m_schema;
117 CDStreamConfig m_mesh_data;
120 AbcSubDReader(const Alembic::Abc::IObject &object, ImportSettings &settings);
124 void readObjectData(Main *bmain, float time);
125 DerivedMesh *read_derivedmesh(DerivedMesh *dm, const float time, int read_flag, const char **err_str);
128 /* ************************************************************************** */
130 void read_mverts(MVert *mverts,
131 const Alembic::AbcGeom::P3fArraySamplePtr &positions,
132 const Alembic::AbcGeom::N3fArraySamplePtr &normals);
134 CDStreamConfig get_config(DerivedMesh *dm);
136 #endif /* __ABC_MESH_H__ */