A factory class for creating and loading meshes. More...
#include <mesh.hpp>
Static Public Member Functions | |
static std::shared_ptr< Mesh > | createPlane (float width, float height) |
Creates a plane mesh with the given width and height. | |
static std::shared_ptr< Mesh > | createCube (float size) |
Creates a cube mesh with the given size. | |
static std::shared_ptr< Mesh > | createSphere (float radius, int segments) |
Creates a sphere mesh with the given radius and number of segments. | |
static std::shared_ptr< Mesh > | createTerrain (const char *heightMapFile, float size, float heightMultiplier, bool isCentered) |
Creates a terrain mesh from a heightmap image. | |
static std::shared_ptr< Raftel::Mesh > | createCone (float radius, float height, int segments) |
Creates a 3D cone mesh. | |
A factory class for creating and loading meshes.
The MeshFactory
class is responsible for loading mesh files from disk, either in a multi-threaded or single-threaded manner. It is designed to make mesh loading efficient and easy to use.
The factory provides methods to load meshes in the background or synchronously, and it can manage the loading of multiple meshes at once.
|
static |
Creates a 3D cone mesh.
This function generates a cone mesh with a specified radius, height, and number of segments. The cone consists of a circular base and a conical surface that connects the base to the apex. The base vertices are placed in a circle, and the cone is constructed by connecting the base vertices to the apex, forming the lateral surface. Additionally, the base is connected with triangles to form a flat surface. Normals are calculated for both the base (pointing downward) and the lateral surface (pointing outward).
radius | The radius of the base of the cone. |
height | The height of the cone. |
segments | The number of segments used to approximate the circular base and lateral surface. |
|
static |
Creates a cube mesh with the given size.
size | The size of the cube. |
|
static |
Creates a plane mesh with the given width and height.
width | The width of the plane. |
height | The height of the plane. |
|
static |
Creates a sphere mesh with the given radius and number of segments.
radius | The radius of the sphere. |
segments | The number of segments used to approximate the sphere's surface. |
|
static |
Creates a terrain mesh from a heightmap image.
heightMapFile | The file path to the heightmap image. |
size | The size of the terrain. |
heightMultiplier | The multiplier for height values. |
isCentered | Whether the terrain should be centered at (0,0,0). |
std::runtime_error | If the heightmap file cannot be loaded. |