Blender V4.3
alembic_read.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2021-2022 Blender Foundation
2 *
3 * SPDX-License-Identifier: Apache-2.0 */
4
5#pragma once
6
7#ifdef WITH_ALEMBIC
8
9# include <Alembic/AbcCoreFactory/All.h>
10# include <Alembic/AbcGeom/All.h>
11
12# include "util/vector.h"
13
15
16class AlembicProcedural;
18class Progress;
19struct CachedData;
20
21/* Maps a FaceSet whose name matches that of a Shader to the index of said shader in the Geometry's
22 * used_shaders list. */
23struct FaceSetShaderIndexPair {
24 Alembic::AbcGeom::IFaceSet face_set;
25 int shader_index;
26};
27
28/* Data of an IPolyMeshSchema that we need to read. */
29struct PolyMeshSchemaData {
30 Alembic::AbcGeom::TimeSamplingPtr time_sampling;
31 size_t num_samples;
32 Alembic::AbcGeom::MeshTopologyVariance topology_variance;
33
34 Alembic::AbcGeom::IP3fArrayProperty positions;
35 Alembic::AbcGeom::IInt32ArrayProperty face_indices;
36 Alembic::AbcGeom::IInt32ArrayProperty face_counts;
37
38 Alembic::AbcGeom::IN3fGeomParam normals;
39
40 vector<FaceSetShaderIndexPair> shader_face_sets;
41
42 // Unsupported for now.
43 Alembic::AbcGeom::IV3fArrayProperty velocities;
44};
45
46void read_geometry_data(AlembicProcedural *proc,
47 CachedData &cached_data,
48 const PolyMeshSchemaData &data,
49 Progress &progress);
50
51/* Data of an ISubDSchema that we need to read. */
52struct SubDSchemaData {
53 Alembic::AbcGeom::TimeSamplingPtr time_sampling;
54 size_t num_samples;
55 Alembic::AbcGeom::MeshTopologyVariance topology_variance;
56
57 Alembic::AbcGeom::IInt32ArrayProperty face_counts;
58 Alembic::AbcGeom::IInt32ArrayProperty face_indices;
59 Alembic::AbcGeom::IP3fArrayProperty positions;
60
61 Alembic::AbcGeom::IInt32ArrayProperty crease_indices;
62 Alembic::AbcGeom::IInt32ArrayProperty crease_lengths;
63 Alembic::AbcGeom::IFloatArrayProperty crease_sharpnesses;
64
65 vector<FaceSetShaderIndexPair> shader_face_sets;
66
67 Alembic::AbcGeom::IInt32ArrayProperty corner_indices;
68 Alembic::AbcGeom::IFloatArrayProperty corner_sharpnesses;
69
70 // Those are unsupported for now.
71 Alembic::AbcGeom::IInt32Property face_varying_interpolate_boundary;
72 Alembic::AbcGeom::IInt32Property face_varying_propagate_corners;
73 Alembic::AbcGeom::IInt32Property interpolate_boundary;
74 Alembic::AbcGeom::IInt32ArrayProperty holes;
75 Alembic::AbcGeom::IStringProperty subdivision_scheme;
76 Alembic::AbcGeom::IV3fArrayProperty velocities;
77};
78
79void read_geometry_data(AlembicProcedural *proc,
80 CachedData &cached_data,
81 const SubDSchemaData &data,
82 Progress &progress);
83
84/* Data of a ICurvesSchema that we need to read. */
85struct CurvesSchemaData {
86 Alembic::AbcGeom::TimeSamplingPtr time_sampling;
87 size_t num_samples;
88 Alembic::AbcGeom::MeshTopologyVariance topology_variance;
89
90 Alembic::AbcGeom::IP3fArrayProperty positions;
91
92 Alembic::AbcGeom::IInt32ArrayProperty num_vertices;
93
94 float default_radius;
95 float radius_scale;
96
97 // Those are unsupported for now.
98 Alembic::AbcGeom::IV3fArrayProperty velocities;
99 // if this property is invalid then the weight for every point is 1
100 Alembic::AbcGeom::IFloatArrayProperty position_weights;
101 Alembic::AbcGeom::IN3fGeomParam normals;
102 Alembic::AbcGeom::IFloatGeomParam widths;
103 Alembic::AbcGeom::IUcharArrayProperty orders;
104 Alembic::AbcGeom::IFloatArrayProperty knots;
105
106 // TODO(@kevindietrich): type, basis, wrap
107};
108
109void read_geometry_data(AlembicProcedural *proc,
110 CachedData &cached_data,
111 const CurvesSchemaData &data,
112 Progress &progress);
113
114/* Data of a IPointsSchema that we need to read. */
115struct PointsSchemaData {
116 Alembic::AbcGeom::TimeSamplingPtr time_sampling;
117 size_t num_samples;
118
119 float default_radius;
120 float radius_scale;
121
122 Alembic::AbcGeom::IP3fArrayProperty positions;
123 Alembic::AbcGeom::IInt32ArrayProperty num_points;
124 Alembic::AbcGeom::IFloatGeomParam radiuses;
125 // Those are unsupported for now.
126 Alembic::AbcGeom::IV3fArrayProperty velocities;
127};
128
129void read_geometry_data(AlembicProcedural *proc,
130 CachedData &cached_data,
131 const PointsSchemaData &data,
132 Progress &progress);
133
134void read_attributes(AlembicProcedural *proc,
135 CachedData &cache,
136 const Alembic::AbcGeom::ICompoundProperty &arb_geom_params,
137 const Alembic::AbcGeom::IV2fGeomParam &default_uvs_param,
138 const AttributeRequestSet &requested_attributes,
139 Progress &progress);
140
142
143#endif
#define CCL_NAMESPACE_END
static float normals[][3]