Raftel Engine
 
Loading...
Searching...
No Matches
Raftel::MeshFactory Class Reference

A factory class for creating and loading meshes. More...

#include <mesh.hpp>

Static Public Member Functions

static std::shared_ptr< MeshcreatePlane (float width, float height)
 Creates a plane mesh with the given width and height.
 
static std::shared_ptr< MeshcreateCube (float size)
 Creates a cube mesh with the given size.
 
static std::shared_ptr< MeshcreateSphere (float radius, int segments)
 Creates a sphere mesh with the given radius and number of segments.
 
static std::shared_ptr< MeshcreateTerrain (const char *heightMapFile, float size, float heightMultiplier, bool isCentered)
 Creates a terrain mesh from a heightmap image.
 
static std::shared_ptr< Raftel::MeshcreateCone (float radius, float height, int segments)
 Creates a 3D cone mesh.
 

Detailed Description

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.

Definition at line 305 of file mesh.hpp.

Member Function Documentation

◆ createCone()

static std::shared_ptr< Raftel::Mesh > Raftel::MeshFactory::createCone ( float radius,
float height,
int segments )
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).

Parameters
radiusThe radius of the base of the cone.
heightThe height of the cone.
segmentsThe number of segments used to approximate the circular base and lateral surface.
Returns
A shared pointer to the created mesh object representing the cone.

◆ createCube()

static std::shared_ptr< Mesh > Raftel::MeshFactory::createCube ( float size)
static

Creates a cube mesh with the given size.

Parameters
sizeThe size of the cube.
Returns
A shared pointer to the created cube mesh.

◆ createPlane()

static std::shared_ptr< Mesh > Raftel::MeshFactory::createPlane ( float width,
float height )
static

Creates a plane mesh with the given width and height.

Parameters
widthThe width of the plane.
heightThe height of the plane.
Returns
A shared pointer to the created plane mesh.

◆ createSphere()

static std::shared_ptr< Mesh > Raftel::MeshFactory::createSphere ( float radius,
int segments )
static

Creates a sphere mesh with the given radius and number of segments.

Parameters
radiusThe radius of the sphere.
segmentsThe number of segments used to approximate the sphere's surface.
Returns
A shared pointer to the created sphere mesh.

◆ createTerrain()

static std::shared_ptr< Mesh > Raftel::MeshFactory::createTerrain ( const char * heightMapFile,
float size,
float heightMultiplier,
bool isCentered )
static

Creates a terrain mesh from a heightmap image.

Parameters
heightMapFileThe file path to the heightmap image.
sizeThe size of the terrain.
heightMultiplierThe multiplier for height values.
isCenteredWhether the terrain should be centered at (0,0,0).
Returns
A shared pointer to the created terrain mesh.
Exceptions
std::runtime_errorIf the heightmap file cannot be loaded.

The documentation for this class was generated from the following file: