Blender V5.0
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
9
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
39 int *corner_verts = nullptr;
40 int totloop = 0;
41
42 int *face_offsets = nullptr;
43 int faces_num = 0;
44
45 float3 *positions = nullptr;
46 int totvert = 0;
47
48 float2 *uv_map = nullptr;
49
50 CustomData *loopdata = nullptr;
51
52 bool pack_uvs = false;
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. */
56 Mesh *mesh = nullptr;
57 void *(*add_customdata_cb)(Mesh *mesh, const char *name, int data_type) = nullptr;
58
59 Alembic::Abc::chrono_t time = 0.0;
61
62 const char **modifier_error_message = nullptr;
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
77 CDStreamConfig() = default;
78};
79
80/* Get the UVs for the main UV property on a OSchema.
81 * Returns the name of the UV layer.
82 *
83 * For now the active layer is used, maybe needs a better way to choose this. */
84const char *get_uv_sample(UVSample &sample, const CDStreamConfig &config, CustomData *data);
85
86void write_generated_coordinates(const OCompoundProperty &prop, CDStreamConfig &config);
87
88void read_velocity(const V3fArraySamplePtr &velocities,
89 const CDStreamConfig &config,
90 const float velocity_scale);
91
92void read_generated_coordinates(const ICompoundProperty &prop,
93 const CDStreamConfig &config,
94 const Alembic::Abc::ISampleSelector &iss);
95
96void write_custom_data(const OCompoundProperty &prop,
97 CDStreamConfig &config,
99 int data_type);
100
101void read_custom_data(const std::string &iobject_full_name,
102 const ICompoundProperty &prop,
103 const CDStreamConfig &config,
104 const Alembic::Abc::ISampleSelector &iss);
105
111
120AbcUvScope get_uv_scope(const Alembic::AbcGeom::GeometryScope scope,
121 const CDStreamConfig &config,
122 const Alembic::AbcGeom::UInt32ArraySamplePtr &indices);
123
124} // namespace blender::io::alembic
BMesh const char void * data
static ushort indices[]
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)
VecBase< float, 2 > float2
VecBase< float, 3 > float3
const char * name
std::map< std::string, Alembic::AbcGeom::OC4fGeomParam > abc_vertex_colors
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