Crimson Engine 1.0.0
A high-performance C++20 game engine prototype showcasing a custom ECS, Vulkan renderer, and ImGui editor.
Loading...
Searching...
No Matches
EntityFactory Namespace Reference

Factory functions to create, configure, and initialize typical entities and their Vulkan rendering resources. More...

Functions

Entity spawnPrimitive (Registry &registry, VulkanRenderer &renderer, PrimitiveKind kind, const std::string &name, const glm::vec3 &position)
 Spawns an entity with a basic geometric primitive mesh.
Entity spawnCamera (Registry &registry, VulkanRenderer &renderer, const std::string &name, const glm::vec3 &position, const glm::vec3 &rotation, float fov)
 Spawns a camera entity.
Entity spawnGrid (Registry &registry, VulkanRenderer &renderer, const std::string &name, const glm::vec3 &position, const glm::vec3 &rotation, const glm::vec4 &color, float spacing, float size)
 Spawns a grid entity used for rendering editor grids.
Entity spawnAnimatedModel (Registry &registry, VulkanRenderer &renderer, const std::string &name, const std::string &gltfPath, const glm::vec3 &position)
 Spawns an animated or static glTF mesh model.
void uploadMesh (Registry &registry, VulkanRenderer &renderer, Entity entity)
 Allocates and uploads GPU buffers for a mesh component on the specified entity.

Detailed Description

Factory functions to create, configure, and initialize typical entities and their Vulkan rendering resources.

Factory methods for creating common game entities (cameras, grids, shapes) and uploading their mesh data.

Function Documentation

◆ spawnAnimatedModel()

Entity EntityFactory::spawnAnimatedModel ( Registry & registry,
VulkanRenderer & renderer,
const std::string & name,
const std::string & gltfPath,
const glm::vec3 & position )

Spawns an animated or static glTF mesh model.

◆ spawnCamera()

Entity EntityFactory::spawnCamera ( Registry & registry,
VulkanRenderer & renderer,
const std::string & name,
const glm::vec3 & position,
const glm::vec3 & rotation,
float fov )

Spawns a camera entity.

Spawns a camera entity with projection setup.

Parameters
registryReference to the ECS Registry.
rendererReference to the Vulkan Renderer.
nameName of the camera entity.
positionInitial position of the camera.
rotationInitial rotation of the camera.
fovField of view in degrees.
Returns
The spawned Entity object.
Parameters
registryTarget ECS Registry.
rendererVulkan renderer context.
nameCamera name.
positionLocation vector.
rotationYaw, pitch, roll orientation.
fovField of view.
Returns
Spawned camera entity handle.

◆ spawnGrid()

Entity EntityFactory::spawnGrid ( Registry & registry,
VulkanRenderer & renderer,
const std::string & name,
const glm::vec3 & position,
const glm::vec3 & rotation,
const glm::vec4 & color,
float spacing,
float size )

Spawns a grid entity used for rendering editor grids.

Spawns a grid overlay drawing reference.

Parameters
registryReference to the ECS Registry.
rendererReference to the Vulkan Renderer.
nameName of the grid entity.
positionInitial position of the grid.
rotationInitial rotation of the grid.
colorBase color of grid lines.
spacingLine spacing.
sizeOverall grid size.
Returns
The spawned Entity object.
Parameters
registryTarget ECS Registry.
rendererVulkan renderer context.
nameGrid name.
positionLocation vector.
rotationOrientation rotation.
colorGrid line color.
spacingLine separation distance.
sizeOverall grid area size.
Returns
Spawned grid entity handle.

◆ spawnPrimitive()

Entity EntityFactory::spawnPrimitive ( Registry & registry,
VulkanRenderer & renderer,
PrimitiveKind kind,
const std::string & name,
const glm::vec3 & position )

Spawns an entity with a basic geometric primitive mesh.

Spawns a primitive shape entity (e.g. Triangle, Cube, Quad).

Parameters
registryReference to the ECS Registry.
rendererReference to the Vulkan Renderer.
kindThe kind of primitive shape (Triangle, Cube, Quad).
nameName of the spawned entity.
positionInitial position of the entity.
Returns
The spawned Entity object.
Parameters
registryTarget ECS Registry.
rendererVulkan renderer context.
kindPrimitive kind (Triangle, Cube, Quad).
nameEntity name.
positionTranslation vector.
Returns
Spawned entity handle.

◆ uploadMesh()

void EntityFactory::uploadMesh ( Registry & registry,
VulkanRenderer & renderer,
Entity entity )

Allocates and uploads GPU buffers for a mesh component on the specified entity.

Uploads mesh component data to Vulkan GPU buffers.

Parameters
registryReference to the ECS Registry.
rendererReference to the Vulkan Renderer.
entityEntity containing the Mesh component to upload.
registryECS registry containing target entity.
rendererVulkan renderer instance.
entityTarget entity.