Voltray Engine Docs
Loading...
Searching...
No Matches
SceneObjectFactory Class Reference

Factory class for creating common scene objects with primitive meshes. More...

#include <SceneObjectFactory.h>

Static Public Member Functions

static std::shared_ptr< SceneObjectCreateCube (const std::string &name="Cube", float size=1.0f)
 Creates a cube scene object.
 
static std::shared_ptr< SceneObjectCreateSphere (const std::string &name="Sphere", float radius=0.5f, int widthSegments=32, int heightSegments=16)
 Creates a sphere scene object.
 
static std::shared_ptr< SceneObjectCreatePlane (const std::string &name="Plane", float width=1.0f, float height=1.0f, int widthSegments=1, int heightSegments=1)
 Creates a plane scene object.
 
static std::shared_ptr< SceneObjectCreateCylinder (const std::string &name="Cylinder", float radiusTop=0.5f, float radiusBottom=0.5f, float height=1.0f, int radialSegments=32, int heightSegments=1)
 Creates a cylinder scene object.
 
static std::shared_ptr< SceneObjectCreateTriangle (const std::string &name="Triangle", float size=1.0f)
 Creates a triangle scene object.
 
static std::shared_ptr< SceneObjectLoadFromFile (const std::string &filepath, const std::string &name="")
 Load a scene object from an external mesh file (OBJ, FBX, etc.).
 
static std::vector< std::shared_ptr< SceneObject > > LoadAllFromFile (const std::string &filepath)
 Load all meshes from a file as separate scene objects.
 
static std::shared_ptr< SceneObjectCreateFromMesh (std::shared_ptr< Mesh > mesh, const std::string &name="CustomMesh")
 Create a scene object from an existing mesh.
 

Detailed Description

Factory class for creating common scene objects with primitive meshes.

SceneObjectFactory provides convenient methods to create scene objects with pre-generated primitive meshes, making it easy to add common shapes to the scene without manually creating meshes and objects.

Member Function Documentation

◆ CreateCube()

std::shared_ptr< SceneObject > SceneObjectFactory::CreateCube ( const std::string &  name = "Cube",
float  size = 1.0f 
)
static

Creates a cube scene object.

Parameters
nameName of the object.
sizeSize of the cube.
Returns
Shared pointer to the created scene object.

◆ CreateCylinder()

std::shared_ptr< SceneObject > SceneObjectFactory::CreateCylinder ( const std::string &  name = "Cylinder",
float  radiusTop = 0.5f,
float  radiusBottom = 0.5f,
float  height = 1.0f,
int  radialSegments = 32,
int  heightSegments = 1 
)
static

Creates a cylinder scene object.

Parameters
nameName of the object.
radiusTopRadius at the top.
radiusBottomRadius at the bottom.
heightHeight of the cylinder.
radialSegmentsNumber of radial segments.
heightSegmentsNumber of height segments.
Returns
Shared pointer to the created scene object.

◆ CreateFromMesh()

std::shared_ptr< SceneObject > SceneObjectFactory::CreateFromMesh ( std::shared_ptr< Mesh mesh,
const std::string &  name = "CustomMesh" 
)
static

Create a scene object from an existing mesh.

Parameters
meshShared pointer to the mesh.
nameName of the object.
Returns
Shared pointer to the created scene object.

◆ CreatePlane()

std::shared_ptr< SceneObject > SceneObjectFactory::CreatePlane ( const std::string &  name = "Plane",
float  width = 1.0f,
float  height = 1.0f,
int  widthSegments = 1,
int  heightSegments = 1 
)
static

Creates a plane scene object.

Parameters
nameName of the object.
widthWidth of the plane.
heightHeight of the plane.
widthSegmentsNumber of width segments.
heightSegmentsNumber of height segments.
Returns
Shared pointer to the created scene object.

◆ CreateSphere()

std::shared_ptr< SceneObject > SceneObjectFactory::CreateSphere ( const std::string &  name = "Sphere",
float  radius = 0.5f,
int  widthSegments = 32,
int  heightSegments = 16 
)
static

Creates a sphere scene object.

Parameters
nameName of the object.
radiusRadius of the sphere.
widthSegmentsNumber of horizontal segments.
heightSegmentsNumber of vertical segments.
Returns
Shared pointer to the created scene object.

◆ CreateTriangle()

std::shared_ptr< SceneObject > SceneObjectFactory::CreateTriangle ( const std::string &  name = "Triangle",
float  size = 1.0f 
)
static

Creates a triangle scene object.

Parameters
nameName of the object.
sizeSize of the triangle.
Returns
Shared pointer to the created scene object.

◆ LoadAllFromFile()

std::vector< std::shared_ptr< SceneObject > > SceneObjectFactory::LoadAllFromFile ( const std::string &  filepath)
static

Load all meshes from a file as separate scene objects.

Parameters
filepathPath to the mesh file.
Returns
Vector of shared pointers to all created scene objects.

◆ LoadFromFile()

std::shared_ptr< SceneObject > SceneObjectFactory::LoadFromFile ( const std::string &  filepath,
const std::string &  name = "" 
)
static

Load a scene object from an external mesh file (OBJ, FBX, etc.).

Parameters
filepathPath to the mesh file.
nameName of the object (defaults to filename if empty).
Returns
Shared pointer to the created scene object, or nullptr if failed.

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