|
lmgl 1.0.0
A lightweight OpenGL graphics engine library written in C++
|
Level of Detail (LOD) management class. More...
#include <lod.hpp>
Public Member Functions | |
| LOD ()=default | |
| Default constructor. | |
| ~LOD ()=default | |
| Default destructor. | |
| void | add_level (std::shared_ptr< Mesh > mesh, float max_distance) |
| Adds a new LOD level. | |
| std::shared_ptr< Mesh > | get_mesh (float distance_sq) const |
| Retrieves the appropriate mesh based on the squared distance. | |
| std::shared_ptr< Mesh > | get_mesh (const glm::vec3 &camera_pos, const glm::vec3 &object_pos) const |
| Retrieves the appropriate mesh based on camera and object positions. | |
| size_t | get_level_count () const |
| Retrieves the number of LOD levels. | |
| const LODLevel & | get_level (size_t index) const |
| Retrieves a specific LOD level by index. | |
| bool | has_levels () const |
| Checks if there are any LOD levels defined. | |
| void | clear () |
| Clears all LOD levels. | |
Level of Detail (LOD) management class.
This class manages multiple levels of detail for 3D objects, allowing for efficient rendering based on the distance from the camera. It provides methods to add LOD levels and retrieve the appropriate mesh based on distance.
| void lmgl::scene::LOD::add_level | ( | std::shared_ptr< Mesh > | mesh, |
| float | max_distance ) |
|
inline |
|
inline |
| std::shared_ptr< Mesh > lmgl::scene::LOD::get_mesh | ( | const glm::vec3 & | camera_pos, |
| const glm::vec3 & | object_pos ) const |
Retrieves the appropriate mesh based on camera and object positions.
This method calculates the squared distance between the camera and the object, then calls the other get_mesh method to retrieve the appropriate mesh.
| camera_pos | Position of the camera in 3D space. |
| object_pos | Position of the object in 3D space. |
| std::shared_ptr< Mesh > lmgl::scene::LOD::get_mesh | ( | float | distance_sq | ) | const |
Retrieves the appropriate mesh based on the squared distance.
The method iterates through the LOD levels and returns the mesh corresponding to the first level where the squared distance is less than or equal to the maximum distance squared for that level. If no such level is found, it returns the mesh of the highest LOD level.
| distance_sq | Squared distance from the camera to the object. |
|
inline |