Blender  V2.93
abc_customdata.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  * The Original Code is Copyright (C) 2016 Kévin Dietrich.
17  * All rights reserved.
18  */
19 #pragma once
20 
25 #include <Alembic/Abc/All.h>
26 #include <Alembic/AbcGeom/All.h>
27 
28 #include <map>
29 
30 struct CustomData;
31 struct MLoop;
32 struct MLoopUV;
33 struct MPoly;
34 struct MVert;
35 struct Mesh;
36 
37 using Alembic::Abc::ICompoundProperty;
38 using Alembic::Abc::OCompoundProperty;
39 namespace blender::io::alembic {
40 
41 struct UVSample {
42  std::vector<Imath::V2f> uvs;
43  std::vector<uint32_t> indices;
44 };
45 
48  int totloop;
49 
51  int totpoly;
52 
54  int totvert;
55 
57 
59 
60  bool pack_uvs;
61 
62  /* TODO(kevin): might need a better way to handle adding and/or updating
63  * custom data such that it updates the custom data holder and its pointers properly. */
65  void *(*add_customdata_cb)(Mesh *mesh, const char *name, int data_type);
66 
67  float weight;
68  float time;
70  Alembic::AbcGeom::index_t index;
71  Alembic::AbcGeom::index_t ceil_index;
72 
73  const char **modifier_error_message;
74 
75  /* Alembic needs Blender to keep references to C++ objects (the destructors
76  * finalize the writing to ABC). This map stores OV2fGeomParam objects for the
77  * 2nd and subsequent UV maps; the primary UV map is kept alive by the Alembic
78  * mesh sample itself. */
79  std::map<std::string, Alembic::AbcGeom::OV2fGeomParam> abc_uv_maps;
80 
82  : mloop(NULL),
83  totloop(0),
84  mpoly(NULL),
85  totpoly(0),
86  totvert(0),
87  pack_uvs(false),
88  mesh(NULL),
90  weight(0.0f),
91  time(0.0f),
92  index(0),
93  ceil_index(0),
95  {
96  }
97 };
98 
99 /* Get the UVs for the main UV property on a OSchema.
100  * Returns the name of the UV layer.
101  *
102  * For now the active layer is used, maybe needs a better way to choose this. */
103 const char *get_uv_sample(UVSample &sample, const CDStreamConfig &config, CustomData *data);
104 
105 void write_custom_data(const OCompoundProperty &prop,
106  CDStreamConfig &config,
107  CustomData *data,
108  int data_type);
109 
110 void read_custom_data(const std::string &iobject_full_name,
111  const ICompoundProperty &prop,
112  const CDStreamConfig &config,
113  const Alembic::Abc::ISampleSelector &iss);
114 
115 } // namespace blender::io::alembic
static void sample(SocketReader *reader, int x, int y, float color[4])
const char * get_uv_sample(UVSample &sample, const CDStreamConfig &config, CustomData *data)
void write_custom_data(const OCompoundProperty &prop, CDStreamConfig &config, CustomData *data, int data_type)
void read_custom_data(const std::string &iobject_full_name, const ICompoundProperty &prop, const CDStreamConfig &config, const Alembic::Abc::ISampleSelector &iss)
Alembic::AbcGeom::index_t index
Alembic::AbcGeom::index_t ceil_index
void *(* add_customdata_cb)(Mesh *mesh, const char *name, int data_type)
std::map< std::string, Alembic::AbcGeom::OV2fGeomParam > abc_uv_maps
std::vector< Imath::V2f > uvs
std::vector< uint32_t > indices