neoGFX
Cross-platform C++ app/game engine
Loading...
Searching...
No Matches
i_scene_graph.hpp
Go to the documentation of this file.
1// i_scene_graph.hpp
2/*
3 neolib C++ App/Game Engine
4 Copyright (c) 2020 Leigh Johnston. All Rights Reserved.
5
6 This program is free software: you can redistribute it and / or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
18*/
19
20#pragma once
21
22#include <neogfx/neogfx.hpp>
27
28namespace neogfx
29{
30 namespace scene_graph
31 {
32 enum class accessor_component_type : uint32_t
33 {
34 BYTE = 5120,
35 UNSIGNED_BYTE = 5121,
36 SHORT = 5122,
37 UNSIGNED_SHORT = 5123,
38 UNSIGNED_INT = 5125,
39 FLOAT = 5126
40 };
41
42 enum class accessor_type : uint32_t
43 {
44 SCALAR = 0,
45 VEC2 = 1,
46 VEC3 = 2,
47 VEC4 = 3,
48 MAT2 = 4,
49 MAT3 = 5,
50 MAT4 = 6
51 };
52
53 enum class buffer_view_target : uint32_t
54 {
55 ARRAY_BUFFER = 34962,
57 };
58
59 enum class rendering_mode : uint32_t
60 {
61 POINTS = 0,
62 LINES = 1,
63 LINE_LOOP = 2,
64 LINE_STRIP = 3,
65 TRIANGLES = 4,
67 TRIANGLE_FAN = 6
68 };
69
70 enum class vertex_attribute : uint32_t
71 {
72 POSITION = 0,
73 NORMAL = 1,
74 TANGENT = 2,
75 TEXCOORD_0 = 3,
76 TEXCOORD_1 = 4,
77 COLOR_0 = 5,
78 JOINTS_0 = 6,
79 WEIGHTS_0 = 7
80 };
81
82 enum class camera_type : uint32_t
83 {
84 Perspective = 0,
85 Orthographic = 1
86 };
87
88 enum class mag_filter : uint32_t
89 {
90 NEAREST = 9728,
91 LINEAR = 9729
92 };
93
94 enum class min_filter : uint32_t
95 {
96 NEAREST = 9728,
97 LINEAR = 9729,
102 };
103
104 enum class wrapping_mode : uint32_t
105 {
106 CLAMP_TO_EDGE = 33071,
107 MIRRORED_REPEAT = 33648,
108 REPEAT = 10497
109 };
110
111 enum class alpha_mode : uint32_t
112 {
113 Opaque = 0,
114 Mask = 1,
115 Blend = 2
116 };
117
118 enum class tex_coord : uint32_t
119 {
120 TEXCOORD_0 = 0,
121 TEXCOORD_1 = 1,
122 TEXCOORD_2 = 2,
123 TEXCOORD_3 = 3,
124 TEXCOORD_4 = 4,
125 TEXCOORD_5 = 5,
126 TEXCOORD_6 = 6,
127 TEXCOORD_7 = 7,
128 TEXCOORD_8 = 8,
129 TEXCOORD_9 = 9,
130 TEXCOORD_10 = 10
131 };
132
134 {
135 public:
137 public:
138 virtual ~i_buffer() = default;
139 public:
140 virtual neolib::i_optional<neolib::i_string> const& name() const = 0;
141 public:
142 virtual std::size_t byte_length() const = 0;
143 virtual void const* data() const = 0;
144 virtual void* data() = 0;
145 public:
146 template <typename T>
147 T const* data() const
148 {
149 return static_cast<T const*>(data());
150 }
151 template <typename T>
152 T* data()
153 {
154 return static_cast<T*>(data());
155 }
156 };
157
159 {
160 public:
162 public:
163 virtual ~i_buffer_view() = default;
164 public:
165 virtual neolib::i_optional<neolib::i_string> const& name() const = 0;
166 public:
167 virtual i_buffer const& buffer() const = 0;
168 virtual i_buffer& buffer() = 0;
169 virtual std::size_t byte_offset() const = 0;
170 virtual std::size_t byte_length() const = 0;
171 virtual std::size_t byte_stride() const = 0;
172 virtual buffer_view_target target() const = 0;
173 };
174
176 {
177 public:
179 public:
180 virtual ~i_sparse_array() = default;
181 public:
182 virtual i_buffer_view const& indices_buffer_view() const = 0;
184 virtual std::size_t indices_byte_offset() const = 0;
186 virtual i_buffer_view const& values_buffer_view() const = 0;
188 virtual std::size_t values_byte_offset() const = 0;
189 };
190
192 {
193 public:
195 public:
196 virtual ~i_accessor() = default;
197 public:
198 virtual neolib::i_optional<neolib::i_string> const& name() const = 0;
199 public:
200 virtual i_buffer_view const& buffer_view() const = 0;
202 virtual std::size_t byte_offset() const = 0;
204 virtual bool normalized() const = 0;
205 virtual std::size_t count() const = 0;
206 virtual accessor_type type() const = 0;
207 virtual void const* max() const = 0;
208 virtual void const* min() const = 0;
209 virtual bool has_sparse() const = 0;
210 virtual i_sparse_array const& sparse() const = 0;
211 virtual i_sparse_array& sparse() = 0;
212 };
213
215 {
216 public:
218 public:
219 virtual ~i_attributes() = default;
220 public:
221 virtual bool has_attribute(vertex_attribute aAttribute) const = 0;
222 virtual i_accessor const& attribute(vertex_attribute aAttribute) const = 0;
223 virtual i_accessor& attribute(vertex_attribute aAttribute) = 0;
224 };
225
227 {
228 public:
230 };
231
233 {
234 public:
236 public:
237 virtual ~i_image() = default;
238 public:
239 virtual neolib::i_optional<neolib::i_string> const& name() const = 0;
240 public:
241 virtual neolib::i_optional<neolib::i_string> const& uri() const = 0;
244 };
245
247 {
248 public:
250 public:
251 virtual ~i_sampler() = default;
252 public:
253 virtual neolib::i_optional<neolib::i_string> const& name() const = 0;
254 public:
257 virtual wrapping_mode wrap_S() const = 0;
258 virtual wrapping_mode wrap_T() const = 0;
259 };
260
262 {
263 public:
265 public:
266 virtual ~i_texture() = default;
267 public:
268 virtual neolib::i_optional<neolib::i_string> const& name() const = 0;
269 public:
270 virtual i_sampler const& sampler() const = 0;
271 virtual i_sampler& sampler() = 0;
272 virtual i_image const& source() const = 0;
273 virtual i_image& source() = 0;
274 };
275
277 {
278 public:
280 public:
281 virtual ~i_texture_reference() = default;
282 public:
283 virtual i_texture const& texture() const = 0;
284 virtual i_texture& texture() = 0;
286 };
287
289 {
290 public:
292 public:
293 virtual scalar scale() const = 0;
294 };
295
297 {
298 public:
300 public:
301 virtual scalar strength_cutoff() const = 0;
302 };
303
305 {
306 public:
308 };
309
311 {
312 public:
314 public:
315 virtual ~i_pbr_metallic_roughness() = default;
316 public:
317 virtual vec4 const& base_color_factor() const = 0;
318 virtual i_texture_reference const& base_color_texture() const = 0;
320 virtual scalar metallic_factor() const = 0;
321 virtual scalar roughness_factor() const = 0;
324 };
325
327 {
328 public:
330 public:
331 virtual ~i_material() = default;
332 public:
333 virtual neolib::i_optional<neolib::i_string> const& name() const = 0;
334 public:
337 virtual i_normal_texture const& normal_texture() const = 0;
339 virtual i_occlusion_texture const& occlusion_texture() const = 0;
341 virtual i_emissive_texture const& emissive_texture() const = 0;
343 virtual vec3 const& emissive_factor() const = 0;
344 virtual scalar alpha_cutoff() const = 0;
345 virtual bool double_sided() const = 0;
346 };
347
349 {
350 public:
352 public:
353 virtual ~i_mesh_primitive() = default;
354 public:
355 virtual neolib::i_optional<neolib::i_string> const& name() const = 0;
356 public:
357 virtual rendering_mode mode() const = 0;
358 virtual i_accessor const& indices() const = 0;
359 virtual i_accessor& indices() = 0;
360 virtual i_attributes const& attributes() const = 0;
361 virtual i_attributes& attributes() = 0;
362 virtual i_morph_target const& morph_targets() const = 0;
364 virtual i_material const& material() const = 0;
365 virtual i_material& material() = 0;
366 };
367
368 class i_mesh
369 {
370 public:
372 public:
373 virtual ~i_mesh() = default;
374 public:
375 virtual neolib::i_optional<neolib::i_string> const& name() const = 0;
376 public:
377 virtual neolib::i_vector<scalar> const& weights() const = 0;
379 };
380
382 {
383 public:
385 public:
386 virtual ~i_camera() = default;
387 public:
388 virtual neolib::i_optional<neolib::i_string> const& name() const = 0;
389 public:
390 virtual camera_type type() = 0;
391 };
392
394 {
395 public:
397 public:
398 virtual scalar xmag() const = 0;
399 virtual scalar xmag() const = 0;
400 virtual scalar zfar() const = 0;
401 virtual scalar znear() const = 0;
402 };
403
405 {
406 public:
408 public:
409 virtual neolib::i_optional<scalar> const& aspectRatio() const = 0;
410 virtual scalar yfov() const = 0;
411 virtual neolib::i_optional<scalar> const& zfar() const = 0;
412 virtual scalar znear() const = 0;
413 };
414
415 class i_skin
416 {
417 public:
419 public:
420 virtual ~i_skin() = default;
421 public:
422 virtual neolib::i_optional<neolib::i_string> const& name() const = 0;
423 };
424
425 class i_node
426 {
427 public:
429 public:
431 typedef struct { vec3 translation; vec4 rotation; vec3 scale; } trs_transform;
432 enum class local_transform_flavour : uint32_t { Matrix, TRS };
434 public:
435 virtual ~i_node() = default;
436 public:
437 virtual neolib::i_optional<neolib::i_string> const& name() const = 0;
438 public:
439 virtual neolib::i_vector<i_node*> const& children() const = 0;
441 public:
442 virtual local_transform_type const& local_transform() const = 0;
444 virtual bool has_mesh() const = 0;
445 virtual i_mesh const& mesh() const = 0;
446 virtual i_mesh& mesh() = 0;
447 virtual bool has_camera() const = 0;
448 virtual i_camera const& camera() const = 0;
449 virtual i_camera& camera() = 0;
450 virtual bool has_skin() const = 0;
451 virtual i_skin const& skin() const = 0;
452 virtual i_skin& skin() = 0;
453 virtual neolib::i_vector<scalar> const& weights() const = 0;
455 };
456
458 {
459 public:
461 public:
462 virtual ~i_scene() = default;
463 public:
464 virtual i_node const& root() const = 0;
465 virtual i_node& root() = 0;
466 };
467 }
468}
virtual neolib::i_optional< neolib::i_string > const & name() const =0
virtual std::size_t byte_offset() const =0
virtual void const * max() const =0
virtual i_buffer_view const & buffer_view() const =0
virtual accessor_type type() const =0
virtual i_buffer_view & buffer_view()=0
virtual bool has_sparse() const =0
virtual bool normalized() const =0
virtual i_sparse_array & sparse()=0
virtual void const * min() const =0
virtual i_sparse_array const & sparse() const =0
virtual accessor_component_type component_type() const =0
virtual std::size_t count() const =0
virtual i_accessor & attribute(vertex_attribute aAttribute)=0
virtual i_accessor const & attribute(vertex_attribute aAttribute) const =0
virtual bool has_attribute(vertex_attribute aAttribute) const =0
virtual std::size_t byte_stride() const =0
virtual i_buffer const & buffer() const =0
virtual std::size_t byte_length() const =0
virtual i_buffer & buffer()=0
virtual std::size_t byte_offset() const =0
virtual buffer_view_target target() const =0
virtual neolib::i_optional< neolib::i_string > const & name() const =0
virtual ~i_buffer()=default
virtual std::size_t byte_length() const =0
virtual void const * data() const =0
virtual neolib::i_optional< neolib::i_string > const & name() const =0
virtual camera_type type()=0
virtual neolib::i_optional< neolib::i_string > const & name() const =0
virtual ~i_camera()=default
virtual neolib::i_optional< i_buffer_view > const & buffer_view() const =0
virtual ~i_image()=default
virtual neolib::i_optional< neolib::i_string > const & uri() const =0
virtual neolib::i_optional< neolib::i_string > const & mime_type() const =0
virtual neolib::i_optional< neolib::i_string > const & name() const =0
virtual i_emissive_texture & emissive_texture()=0
virtual i_occlusion_texture & occlusion_texture()=0
virtual i_normal_texture const & normal_texture() const =0
virtual neolib::i_optional< neolib::i_string > const & name() const =0
virtual i_emissive_texture const & emissive_texture() const =0
virtual vec3 const & emissive_factor() const =0
virtual bool double_sided() const =0
virtual i_pbr_metallic_roughness & pbr_metallic_roughness()=0
virtual i_normal_texture & normal_texture()=0
virtual i_occlusion_texture const & occlusion_texture() const =0
virtual i_pbr_metallic_roughness const & pbr_metallic_roughness() const =0
virtual scalar alpha_cutoff() const =0
virtual neolib::i_optional< neolib::i_string > const & name() const =0
virtual i_material & material()=0
virtual rendering_mode mode() const =0
virtual i_attributes & attributes()=0
virtual i_accessor & indices()=0
virtual i_accessor const & indices() const =0
virtual i_material const & material() const =0
virtual i_morph_target const & morph_targets() const =0
virtual i_morph_target & morph_targets()=0
virtual i_attributes const & attributes() const =0
virtual ~i_mesh()=default
virtual neolib::i_vector< scalar > const & weights() const =0
virtual neolib::i_optional< neolib::i_string > const & name() const =0
virtual neolib::i_vector< scalar > & weights()=0
virtual neolib::i_vector< scalar > const & weights() const =0
virtual i_camera & camera()=0
virtual neolib::i_vector< scalar > & weights()=0
virtual bool has_camera() const =0
virtual i_skin & skin()=0
virtual i_skin const & skin() const =0
virtual i_camera const & camera() const =0
virtual bool has_skin() const =0
virtual neolib::i_vector< i_node * > & children()=0
neolib::i_plugin_variant< local_transform_flavour, matrix_transform, trs_transform > local_transform_type
virtual local_transform_type & local_transform()=0
virtual neolib::i_optional< neolib::i_string > const & name() const =0
virtual neolib::i_vector< i_node * > const & children() const =0
virtual bool has_mesh() const =0
virtual local_transform_type const & local_transform() const =0
virtual i_mesh const & mesh() const =0
virtual i_mesh & mesh()=0
virtual ~i_node()=default
virtual scalar scale() const =0
virtual scalar strength_cutoff() const =0
virtual i_texture_reference & base_color_texture()=0
virtual i_texture_reference const & base_color_texture() const =0
virtual scalar roughness_factor() const =0
virtual vec4 const & base_color_factor() const =0
virtual i_texture_reference & metallic_roughness_texture()=0
virtual i_texture_reference const & metallic_roughness_texture() const =0
virtual neolib::i_optional< scalar > const & aspectRatio() const =0
virtual neolib::i_optional< scalar > const & zfar() const =0
virtual scene_graph::min_filter min_filter() const =0
virtual scene_graph::mag_filter mag_filter() const =0
virtual wrapping_mode wrap_S() const =0
virtual neolib::i_optional< neolib::i_string > const & name() const =0
virtual wrapping_mode wrap_T() const =0
virtual ~i_sampler()=default
virtual i_node & root()=0
virtual i_node const & root() const =0
virtual ~i_scene()=default
virtual ~i_skin()=default
virtual neolib::i_optional< neolib::i_string > const & name() const =0
virtual std::size_t indices_byte_offset() const =0
virtual i_buffer_view const & indices_buffer_view() const =0
virtual i_buffer_view & indices_buffer_view()=0
virtual i_buffer_view const & values_buffer_view() const =0
virtual std::size_t values_byte_offset() const =0
virtual accessor_component_type indices_component_type() const =0
virtual i_buffer_view & values_buffer_view()=0
virtual i_texture const & texture() const =0
virtual scene_graph::tex_coord tex_coord() const =0
virtual i_image const & source() const =0
virtual i_image & source()=0
virtual ~i_texture()=default
virtual i_sampler const & sampler() const =0
virtual i_sampler & sampler()=0
virtual neolib::i_optional< neolib::i_string > const & name() const =0
double scalar
Definition numerical.hpp:63