Lagrange
Loading...
Searching...
No Matches
CistaScene.h
1/*
2 * Copyright 2026 Adobe. All rights reserved.
3 * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License. You may obtain a copy
5 * of the License at http://www.apache.org/licenses/LICENSE-2.0
6 *
7 * Unless required by applicable law or agreed to in writing, software distributed under
8 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9 * OF ANY KIND, either express or implied. See the License for the specific language
10 * governing permissions and limitations under the License.
11 */
12#pragma once
13
14#include "CistaMesh.h"
15#include "CistaValue.h"
16
17#include <cista/containers/optional.h>
18#include <cista/containers/string.h>
19#include <cista/containers/vector.h>
20
21#include <array>
22#include <cstdint>
23
24namespace lagrange::serialization::internal {
25
26namespace data = cista::offset;
27
28constexpr uint64_t k_invalid_element = ~uint64_t(0);
29
31{
32 uint64_t index = k_invalid_element;
33 int32_t texcoord = 0;
34};
35
37{
38 uint64_t mesh = k_invalid_element;
39 data::vector<uint64_t> materials;
40};
41
43{
44 data::string name;
45 std::array<float, 16> transform{}; // Affine3f = 4x4 float matrix
46 uint64_t parent = k_invalid_element;
47 data::vector<uint64_t> children;
48 data::vector<CistaSceneMeshInstance> meshes;
49 data::vector<uint64_t> cameras;
50 data::vector<uint64_t> lights;
51 CistaExtensions extensions;
52};
53
55{
56 uint64_t width = 0;
57 uint64_t height = 0;
58 uint64_t num_channels = 0;
59 uint8_t element_type = 0; // std::underlying_type_t<AttributeValueType>
60 data::vector<uint8_t> data_bytes;
61};
62
64{
65 data::string name;
66 CistaImageBuffer image;
67 data::string uri;
68 CistaExtensions extensions;
69};
70
72{
73 data::string name;
74 uint64_t image = k_invalid_element;
75 int32_t mag_filter = 0;
76 int32_t min_filter = 0;
77 uint8_t wrap_u = 0;
78 uint8_t wrap_v = 0;
79 std::array<float, 2> scale{};
80 std::array<float, 2> offset{};
81 float rotation = 0.f;
82 CistaExtensions extensions;
83};
84
86{
87 data::string name;
88 std::array<float, 4> base_color_value{};
89 std::array<float, 3> emissive_value{};
90 float metallic_value = 0.f;
91 float roughness_value = 0.f;
92 float alpha_cutoff = 0.f;
93 float normal_scale = 0.f;
94 float occlusion_strength = 0.f;
95 uint8_t alpha_mode = 0;
96 bool double_sided = false;
97 CistaTextureInfo base_color_texture;
98 CistaTextureInfo emissive_texture;
99 CistaTextureInfo metallic_roughness_texture;
100 CistaTextureInfo normal_texture;
101 CistaTextureInfo occlusion_texture;
102 CistaExtensions extensions;
103};
104
106{
107 data::string name;
108 uint8_t type = 0;
109 std::array<float, 3> position{};
110 std::array<float, 3> direction{};
111 std::array<float, 3> up{};
112 float intensity = 0.f;
113 float attenuation_constant = 0.f;
114 float attenuation_linear = 0.f;
115 float attenuation_quadratic = 0.f;
116 float attenuation_cubic = 0.f;
117 float range = 0.f;
118 std::array<float, 3> color_diffuse{};
119 std::array<float, 3> color_specular{};
120 std::array<float, 3> color_ambient{};
121 cista::optional<float> angle_inner_cone;
122 cista::optional<float> angle_outer_cone;
123 std::array<float, 2> size{};
124 CistaExtensions extensions;
125};
126
128{
129 data::string name;
130 uint8_t type = 0;
131 std::array<float, 3> position{};
132 std::array<float, 3> up{};
133 std::array<float, 3> look_at{};
134 float near_plane = 0.f;
135 cista::optional<float> far_plane;
136 float orthographic_width = 0.f;
137 float aspect_ratio = 0.f;
138 float horizontal_fov = 0.f;
139 CistaExtensions extensions;
140};
141
143{
144 data::vector<uint64_t> meshes;
145 CistaExtensions extensions;
146};
147
149{
150 data::string name;
151 CistaExtensions extensions;
152};
153
155{
156 uint32_t version = 1;
157 uint8_t scalar_type_size = 0;
158 uint8_t index_type_size = 0;
159
160 data::string name;
161
162 data::vector<CistaNode> nodes;
163 data::vector<uint64_t> root_nodes;
164 data::vector<CistaMesh> meshes;
165 data::vector<CistaImage> images;
166 data::vector<CistaTexture> textures;
167 data::vector<CistaMaterial> materials;
168 data::vector<CistaLight> lights;
169 data::vector<CistaCamera> cameras;
170 data::vector<CistaSkeleton> skeletons;
171 data::vector<CistaAnimation> animations;
172 CistaExtensions extensions;
173};
174
175} // namespace lagrange::serialization::internal
Cista-compatible representation of scene::Extensions.
Definition CistaValue.h:55