63 Eigen::Affine3f transform = Eigen::Affine3f::Identity();
66 ElementId parent = invalid_element;
69 SafeVector<ElementId> children;
75 SafeVector<SceneMeshInstance> meshes;
78 SafeVector<ElementId> cameras;
81 SafeVector<ElementId> lights;
190 ElementId image = invalid_element;
192 enum TextureFilter :
int {
196 NearestMipmapNearest = 9984,
197 LinearMipmapNearest = 9985,
198 NearestMipmapLinear = 9986,
199 LinearMipmapLinear = 9987
203 TextureFilter mag_filter = TextureFilter::Undefined;
208 TextureFilter min_filter = TextureFilter::Undefined;
210 enum class WrapMode {
217 WrapMode wrap_u = WrapMode::Wrap;
218 WrapMode wrap_v = WrapMode::Wrap;
220 Eigen::Vector2f scale = Eigen::Vector2f::Ones();
221 Eigen::Vector2f offset = Eigen::Vector2f::Zero();
222 float rotation = 0.0f;
231 enum class Type { Undefined, Directional, Point, Spot, Ambient, Area };
232 Type type = Type::Undefined;
237 Eigen::Vector3f position = Eigen::Vector3f::Zero();
238 Eigen::Vector3f direction = Eigen::Vector3f(0, 1, 0);
239 Eigen::Vector3f up = Eigen::Vector3f(0, 0, 1);
246 float intensity = 1.f;
247 float attenuation_constant = 1.f;
248 float attenuation_linear = 0.f;
249 float attenuation_quadratic = 0.f;
250 float attenuation_cubic = 0.f;
258 Eigen::Vector3f color_diffuse = Eigen::Vector3f::Zero();
259 Eigen::Vector3f color_specular = Eigen::Vector3f::Zero();
260 Eigen::Vector3f color_ambient = Eigen::Vector3f::Zero();
264 float angle_inner_cone;
265 float angle_outer_cone;
268 Eigen::Vector2f size = Eigen::Vector2f::Zero();
279 Eigen::Vector3f position = Eigen::Vector3f::Zero();
280 Eigen::Vector3f up = Eigen::Vector3f(0, 1, 0);
281 Eigen::Vector3f look_at = Eigen::Vector3f(0, 0, -1);
284 float near_plane = 0.1f;
288 std::optional<float> far_plane = 1000.f;
290 enum class Type { Perspective, Orthographic };
291 Type type = Type::Perspective;
296 float orthographic_width = 0.f;
304 float aspect_ratio = 1.f;
312 float horizontal_fov = (float)lagrange::internal::pi_2;
316 float get_vertical_fov()
const
318 return 2.f * std::atan(std::tan(horizontal_fov * 0.5f) / aspect_ratio);
320 void set_horizontal_fov_from_vertical_fov(
float vfov)
322 horizontal_fov = 2.f * std::atan(std::tan(vfov * 0.5f) * aspect_ratio);
324 void set_aspect_ratio_from_fov(
float vfov,
float hfov)
326 aspect_ratio = std::tan(hfov * 0.5f) / std::tan(vfov * 0.5f);
361 SafeVector<Node> nodes;
364 SafeVector<ElementId> root_nodes;
367 SafeVector<MeshType> meshes;
370 SafeVector<ImageExperimental> images;
373 SafeVector<Texture> textures;
376 SafeVector<MaterialExperimental> materials;
379 SafeVector<Light> lights;
382 SafeVector<Camera> cameras;
385 SafeVector<Skeleton> skeletons;
388 SafeVector<Animation> animations;
402 template <
typename T>
412 void add_child(ElementId parent_id, ElementId child_id);
419 using ElementType = std::decay_t<T>;
420 if constexpr (std::is_same_v<ElementType, Node>) {
421 nodes.emplace_back(std::forward<T>(value));
422 return nodes.size() - 1;
423 }
else if constexpr (std::is_same_v<ElementType, MeshType>) {
424 meshes.emplace_back(std::forward<T>(value));
425 return meshes.size() - 1;
426 }
else if constexpr (std::is_same_v<ElementType, ImageExperimental>) {
427 images.emplace_back(std::forward<T>(value));
428 return images.size() - 1;
429 }
else if constexpr (std::is_same_v<ElementType, Texture>) {
430 textures.emplace_back(std::forward<T>(value));
431 return textures.size() - 1;
432 }
else if constexpr (std::is_same_v<ElementType, MaterialExperimental>) {
433 materials.emplace_back(std::forward<T>(value));
434 return materials.size() - 1;
435 }
else if constexpr (std::is_same_v<ElementType, Light>) {
436 lights.emplace_back(std::forward<T>(value));
437 return lights.size() - 1;
438 }
else if constexpr (std::is_same_v<ElementType, Camera>) {
439 cameras.emplace_back(std::forward<T>(value));
440 return cameras.size() - 1;
441 }
else if constexpr (std::is_same_v<ElementType, Skeleton>) {
442 skeletons.emplace_back(std::forward<T>(value));
443 return skeletons.size() - 1;
444 }
else if constexpr (std::is_same_v<ElementType, Animation>) {
445 animations.emplace_back(std::forward<T>(value));
446 return animations.size() - 1;
448 static_assert(StaticAssertableBool<T>::False,
"Unsupported type");
ElementId index
Texture index. Index in scene.textures vector.
Definition Scene.h:137