Blender V4.3
abc_customdata.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2016 Kévin Dietrich. All rights reserved.
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4#pragma once
5
11
12#include <Alembic/Abc/ICompoundProperty.h>
13#include <Alembic/Abc/ISampleSelector.h>
14#include <Alembic/Abc/OCompoundProperty.h>
15#include <Alembic/Abc/TypedArraySample.h>
16#include <Alembic/AbcCoreAbstract/Foundation.h>
17#include <Alembic/AbcGeom/GeometryScope.h>
18#include <Alembic/AbcGeom/OGeomParam.h>
19
20#include <cstdint>
21#include <map>
22#include <string>
23#include <vector>
24
25struct CustomData;
26struct Mesh;
27
28using Alembic::Abc::ICompoundProperty;
29using Alembic::Abc::OCompoundProperty;
30using Alembic::Abc::V3fArraySamplePtr;
31namespace blender::io::alembic {
32
33struct UVSample {
34 std::vector<Imath::V2f> uvs;
35 std::vector<uint32_t> indices;
36};
37
41
44
47
49
51
53
54 /* TODO(kevin): might need a better way to handle adding and/or updating
55 * custom data such that it updates the custom data holder and its pointers properly. */
57 void *(*add_customdata_cb)(Mesh *mesh, const char *name, int data_type);
58
59 Alembic::Abc::chrono_t time;
61
63
64 /* Alembic needs Blender to keep references to C++ objects (the destructors finalize the writing
65 * to ABC). The following fields are all used to keep these references. */
66
67 /* Mapping from UV map name to its ABC property, for the 2nd and subsequent UV maps; the primary
68 * UV map is kept alive by the Alembic mesh sample itself. */
69 std::map<std::string, Alembic::AbcGeom::OV2fGeomParam> abc_uv_maps;
70
71 /* ORCO coordinates, aka Generated Coordinates. */
72 Alembic::AbcGeom::OV3fGeomParam abc_orco;
73
74 /* Mapping from vertex color layer name to its Alembic color data. */
75 std::map<std::string, Alembic::AbcGeom::OC4fGeomParam> abc_vertex_colors;
76
79 totloop(0),
81 faces_num(0),
82 totvert(0),
84 mesh(NULL),
86 time(0.0),
88 {
89 }
90};
91
92/* Get the UVs for the main UV property on a OSchema.
93 * Returns the name of the UV layer.
94 *
95 * For now the active layer is used, maybe needs a better way to choose this. */
96const char *get_uv_sample(UVSample &sample, const CDStreamConfig &config, CustomData *data);
97
98void write_generated_coordinates(const OCompoundProperty &prop, CDStreamConfig &config);
99
100void read_velocity(const V3fArraySamplePtr &velocities,
101 const CDStreamConfig &config,
102 const float velocity_scale);
103
104void read_generated_coordinates(const ICompoundProperty &prop,
105 const CDStreamConfig &config,
106 const Alembic::Abc::ISampleSelector &iss);
107
108void write_custom_data(const OCompoundProperty &prop,
109 CDStreamConfig &config,
110 CustomData *data,
111 int data_type);
112
113void read_custom_data(const std::string &iobject_full_name,
114 const ICompoundProperty &prop,
115 const CDStreamConfig &config,
116 const Alembic::Abc::ISampleSelector &iss);
117
123
132AbcUvScope get_uv_scope(const Alembic::AbcGeom::GeometryScope scope,
133 const CDStreamConfig &config,
134 const Alembic::AbcGeom::UInt32ArraySamplePtr &indices);
135
136} // namespace blender::io::alembic
#define NULL
AbcUvScope get_uv_scope(const Alembic::AbcGeom::GeometryScope scope, const CDStreamConfig &config, const Alembic::AbcGeom::UInt32ArraySamplePtr &indices)
const char * get_uv_sample(UVSample &sample, const CDStreamConfig &config, CustomData *data)
void read_velocity(const V3fArraySamplePtr &velocities, const CDStreamConfig &config, const float velocity_scale)
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)
void read_generated_coordinates(const ICompoundProperty &prop, const CDStreamConfig &config, const Alembic::Abc::ISampleSelector &iss)
void write_generated_coordinates(const OCompoundProperty &prop, CDStreamConfig &config)
std::map< std::string, Alembic::AbcGeom::OC4fGeomParam > abc_vertex_colors
void *(* add_customdata_cb)(Mesh *mesh, const char *name, int data_type)
Alembic::AbcGeom::OV3fGeomParam abc_orco
std::map< std::string, Alembic::AbcGeom::OV2fGeomParam > abc_uv_maps
std::vector< Imath::V2f > uvs
std::vector< uint32_t > indices