Scene

group Scene

Functions

void AddModelToTheSceneTree(Scene *scene, Ref<Model> model, AnimatorComponent *animatorComponent = nullptr)

Add a model to the scene tree.

Parameters:
  • scene – The scene.

  • model – The model to add.

struct AnimatorComponent
#include <AnimatorComponent.h>

Component representing an animator.

Public Functions

AnimatorComponent(const AnimatorComponent &other)

Copy constructor for AnimatorComponent.

Parameters:

other – The other AnimatorComponent to copy from.

AnimatorComponent(Ref<Skeleton> skeleton, Ref<AnimationController> animationController)

Constructs an AnimatorComponent with the given skeleton, animation controller, and animation system.

Parameters:
  • skeleton – The skeleton reference.

  • animationController – The animation controller reference.

inline Ref<Skeleton> GetSkeleton() const

Gets the skeleton reference.

Returns:

The skeleton reference.

inline void SetSkeleton(Ref<Skeleton> skeleton)

Sets the skeleton reference.

Parameters:

skeleton – The skeleton reference to set.

inline Ref<AnimationController> GetAnimationController() const

Gets the animation controller reference.

Returns:

The animation controller reference.

inline void SetAnimationController(Ref<AnimationController> animationController)

Sets the animation controller reference.

Parameters:

animationController – The animation controller reference to set.

inline ozz::animation::SamplingJob::Context &GetContext()

Gets the sampling job context.

Returns:

The sampling job context.

inline ozz::animation::BlendingJob::Layer *GetBlendLayers()

Gets the blend layers.

Returns:

The blend layers.

inline ozz::animation::BlendingJob &GetBlendJob()

Gets the blending job.

Returns:

The blending job.

void SetCurrentAnimation(unsigned int index)

Sets the current animation for both upper and lower body layers.

Parameters:

index – The index of the animation to set.

void SetUpperAnimation(unsigned int index)

Sets the current animation for the upper body layer.

Parameters:

index – The index of the animation to set.

void SetLowerAnimation(unsigned int index)

Sets the current animation for the lower body layer.

Parameters:

index – The index of the animation to set.

template<class Archive>
void save(Archive &archive, const std::uint32_t &version) const

Serializes the AnimatorComponent.

Template Parameters:

Archive – The type of the archive.

Parameters:

archive – The archive to serialize to.

template<class Archive>
void load(Archive &archive, const std::uint32_t &version)

Deserializes the AnimatorComponent.

Template Parameters:

Archive – The type of the archive.

Parameters:

archive – The archive to deserialize from.

Public Members

bool Loop = true

Indicates if the animation should loop.

float BlendDuration = 0.25f

The duration of the blend.

float AnimationSpeed = 1.0f

The speed of the animation.

std::vector<glm::mat4> JointMatrices

The joint matrices.

UUID modelUUID

The UUID of the model.

UUID animatorUUID

The UUID of the animator.

int UpperBodyRootJoint = 0

Index of the root joint for upper body animations.

std::vector<ozz::math::SoaTransform> PartialBlendOutput

Output transforms for partial blending.

float UpperBodyWeight = 1.0f

Weight for blending upper body animations.

float LowerBodyWeight = 1.0f

Weight for blending lower body animations.

float PartialBlendThreshold = 0.01f

Threshold for partial blending.

Ref<AnimationLayer> UpperAnimation

Animation layer for upper body animations.

Ref<AnimationLayer> LowerAnimation

Animation layer for lower body animations.

bool NeedsUpdate = true

Flag to indicate if the animator needs an update.

struct CameraComponent
#include <CameraComponent.h>

Component representing a camera.

Public Functions

template<class Archive>
void serialize(Archive &archive, std::uint32_t const version)

Serializes the CameraComponent.

Template Parameters:

Archive – The type of the archive.

Parameters:

archive – The archive to serialize to.

Public Members

SceneCamera Camera

The scene camera.

struct LightComponent
#include <LightComponent.h>

Component representing a light.

Public Types

enum Type

Enum representing the type of light.

Values:

enumerator DirectionalLight

Directional light.

enumerator PointLight

Point light.

enumerator SpotLight

Spot light.

Public Functions

template<class Archive>
void serialize(Archive &archive, std::uint32_t const version)

Serializes the LightComponent.

Template Parameters:

Archive – The type of the archive.

Parameters:

archive – The archive to serialize to.

Public Members

glm::vec3 Color = {1.0f, 1.0f, 1.0f}

The color of the light.

glm::vec3 Direction = {0.0f, -1.0f, 0.0f}

The direction of the light.

glm::vec3 Position = {0.0f, 0.0f, 0.0f}

The position of the light.

float Range = 5.0f

The range of the light.

float Attenuation = 1.0f

The attenuation of the light.

float Intensity = 1.0f

The intensity of the light.

float Angle = 45.0f

The angle of the light.

float ConeAttenuation = 48.0f

The cone attenuation of the light.

int type = static_cast<int>(Type::DirectionalLight)

The type of the light.

struct MaterialComponent
#include <MaterialComponent.h>

Component representing a material.

Public Members

Ref<Material> material

The material reference.

struct MeshComponent
#include <MeshComponent.h>

Component representing a mesh.

Public Functions

inline const Ref<Mesh> &GetMesh() const

Gets the mesh reference.

Returns:

The mesh reference.

Public Members

Ref<Mesh> mesh

The mesh reference.

bool drawAABB = false

Flag to draw the axis-aligned bounding box (AABB).

AnimatorComponent *animator = nullptr

The animator component.

UUID animatorUUID = 0

The UUID of the animator.

struct TagComponent
#include <TagComponent.h>

Component representing a tag.

Public Functions

template<class Archive>
void serialize(Archive &archive, std::uint32_t const version)

Serializes the TagComponent.

Template Parameters:

Archive – The type of the archive.

Parameters:

archive – The archive to serialize to.

Public Members

std::string Tag

The tag string.

struct TransformComponent
#include <TransformComponent.h>

Component representing a transform.

Public Functions

inline glm::vec3 &GetLocalPosition()

Gets the local position vector.

Returns:

The local position vector.

inline glm::mat4 GetLocalTransform() const

Gets the local transformation matrix.

Returns:

The local transformation matrix.

inline void SetLocalTransform(const glm::mat4 &transform)

Sets the local transformation matrix.

Parameters:

transform – The transformation matrix to set.

inline const glm::mat4 &GetWorldTransform() const

Gets the world transformation matrix.

Returns:

The world transformation matrix.

inline void SetWorldTransform(const glm::mat4 &transform)

Sets the world transformation matrix.

Parameters:

transform – The transformation matrix to set.

template<class Archive>
void serialize(Archive &archive, std::uint32_t const version)

Serializes the TransformComponent.

Template Parameters:

Archive – The type of the archive.

Parameters:

archive – The archive to serialize to.

class Entity
#include <Entity.h>

Class representing an entity in the scene.

Public Functions

Entity() = default

Default constructor for Entity.

Entity(entt::entity handle, Scene *scene)

Constructor for Entity with handle and scene.

Parameters:
  • handle – The entity handle.

  • scene – The scene the entity belongs to.

Entity(const Entity &other) = default

Copy constructor for Entity.

Parameters:

other – The other entity to copy from.

template<typename T, typename ...Args>
inline T &AddComponent(Args&&... args)

Add a component to the entity.

Template Parameters:
  • T – The component type.

  • Args – The component constructor arguments.

Parameters:

args – The component constructor arguments.

Returns:

Reference to the added component.

template<typename T>
inline T &GetComponent()

Get a component from the entity.

Template Parameters:

T – The component type.

Returns:

Reference to the component.

template<typename T>
inline bool HasComponent()

Check if the entity has a component.

Template Parameters:

T – The component type.

Returns:

True if the entity has the component, false otherwise.

template<typename T>
inline void RemoveComponent()

Remove a component from the entity.

Template Parameters:

T – The component type.

inline operator bool() const

Check if the entity is valid.

Returns:

True if the entity is valid, false otherwise.

inline operator entt::entity() const

Convert the entity to its handle.

Returns:

The entity handle.

inline operator uint32_t() const

Convert the entity to its handle as a uint32_t.

Returns:

The entity handle as a uint32_t.

inline bool operator==(const Entity &other) const

Equality operator.

Parameters:

other – The other entity to compare with.

Returns:

True if the entities are equal, false otherwise.

inline bool operator!=(const Entity &other) const

Inequality operator.

Parameters:

other – The other entity to compare with.

Returns:

True if the entities are not equal, false otherwise.

inline void SetParent(Entity entity)

Set the parent of the entity.

Parameters:

entity – The parent entity.

class PrimitiveMesh
#include <PrimitiveMesh.h>

Class representing different types of primitive meshes.

Public Static Functions

static Ref<Mesh> CreateQuad()

Creates a quad mesh.

Returns:

A reference to the created quad mesh.

static Ref<Mesh> CreateCube(const glm::vec3 &size = {1.0f, 1.0f, 1.0f}, int subdivideW = 0, int subdidiveH = 0, int subdivideD = 0)

Creates a cube mesh.

Creates a cube mesh.

Parameters:
  • size – The size of the cube.

  • subdivideW – Number of subdivisions along the width.

  • subdivideH – Number of subdivisions along the height.

  • subdivideD – Number of subdivisions along the depth.

  • size – The size of the cube.

  • subdivideW – Subdivision parameter for width (currently not functional).

  • subdivideH – Subdivision parameter for height (currently not functional).

  • subdivideD – Subdivision parameter for depth (currently not functional).

Returns:

A reference to the created cube mesh.

Returns:

Ref<Mesh> A reference to the created cube mesh.

static Ref<Mesh> CreateSphere(float radius = 0.5f, float height = 1.0f, int radialSegments = 64, int rings = 32, bool isHemiSphere = false)

Creates a sphere mesh.

Parameters:
  • radius – The radius of the sphere.

  • height – The height of the sphere.

  • radialSegments – Number of radial segments.

  • rings – Number of rings.

  • isHemiSphere – Whether the sphere is a hemisphere.

Returns:

A reference to the created sphere mesh.

static Ref<Mesh> CreatePlane(const glm::vec2 &size = {1.0f, 1.0f}, const glm::vec3 &normal = {0.0f, 1.0f, 0.0f})

Creates a plane mesh.

Parameters:
  • size – The size of the plane.

  • normal – The normal vector of the plane.

Returns:

A reference to the created plane mesh.

static Ref<Mesh> CreateCylinder(float topRadius = 0.5f, float bottomRadius = 0.5f, float height = 1.0f, int radialSegments = 64, int rings = 1, bool capTop = true, bool capBottom = true)

Creates a cylinder mesh.

Parameters:
  • topRadius – The radius of the top of the cylinder.

  • bottomRadius – The radius of the bottom of the cylinder.

  • height – The height of the cylinder.

  • radialSegments – Number of radial segments.

  • rings – Number of rings.

  • capTop – Whether to cap the top of the cylinder.

  • capBottom – Whether to cap the bottom of the cylinder.

Returns:

A reference to the created cylinder mesh.

static Ref<Mesh> CreateCone(float radius = 0.5f, float height = 1.0f, int radialSegments = 64, int rings = 1, bool cap = true)

Creates a cone mesh.

Parameters:
  • radius – The radius of the base of the cone.

  • height – The height of the cone.

  • radialSegments – Number of radial segments.

  • rings – Number of rings.

  • cap – Whether to cap the base of the cone.

Returns:

A reference to the created cone mesh.

static Ref<Mesh> CreateTorus(float innerRadius = 0.5f, float outerRadius = 1.0f, int rings = 64, int ringSegments = 32)

Creates a torus mesh.

Parameters:
  • innerRadius – The inner radius of the torus.

  • outerRadius – The outer radius of the torus.

  • rings – Number of rings.

  • ringSegments – Number of ring segments.

Returns:

A reference to the created torus mesh.

static Ref<Mesh> CreateCapsule(float radius = 0.5f, float height = 2.0f, int radialSegments = 64, int rings = 8)

Creates a capsule mesh.

Parameters:
  • radius – The radius of the capsule.

  • height – The height of the capsule.

  • radialSegments – Number of radial segments.

  • rings – Number of rings.

Returns:

A reference to the created capsule mesh.

struct SceneDebugFlags
class Scene
#include <Scene.h>

Class representing a scene.

Public Functions

Scene()

Constructor for Scene.

~Scene() = default

Default destructor.

Entity CreateEntity(const std::string &name = std::string())

Create an entity in the scene.

Parameters:

name – The name of the entity.

Returns:

The created entity.

void DestroyEntity(Entity entity)

Destroy an entity in the scene.

Parameters:

entity – The entity to destroy.

void OnInitEditor()

Initialize the scene.

void OnUpdateEditor(EditorCamera &camera, float dt)

Update the scene in editor mode.

Parameters:
  • camera – The editor camera.

  • dt – The delta time.

void OnUpdateRuntime(float dt)

Update the scene in runtime mode.

Parameters:

dt – The delta time.

void OnEvent(Event &e)

Handle an event in the scene.

Parameters:

e – The event.

void OnExitEditor()

Exit the scene.

void UpdateAudioComponentsPositions()

Update the positions of the audio components.

void AssignAnimatorsToMeshes(const std::vector<AnimatorComponent*> animators)

Assigns animators to meshes.

Parameters:

animators – The vector of animator components.

Public Static Functions

static Ref<Scene> Load(const std::filesystem::path &path)

Load a scene from a file.

Parameters:

path – The path to the file.

Returns:

The loaded scene.

static void Save(const std::filesystem::path &path, Ref<Scene> scene)

Save a scene to a file.

Parameters:
  • path – The path to the file.

  • scene – The scene to save.

class SceneCamera : public Coffee::Camera
#include <SceneCamera.h>

Camera class for the scene.

Public Functions

SceneCamera()

Constructor for SceneCamera.

~SceneCamera() = default

Default destructor.

struct HierarchyComponent
#include <SceneTree.h>

Component for managing entity hierarchy.

Public Functions

HierarchyComponent(entt::entity parent)

Constructor with parent entity.

Parameters:

parent – The parent entity.

HierarchyComponent()

Default constructor.

template<class Archive>
inline void save(Archive &archive, std::uint32_t const version) const

Serialize the component.

Template Parameters:

Archive – The archive type.

Parameters:

archive – The archive.

Public Static Functions

static void OnConstruct(Scene *scene, entt::registry &registry, entt::entity entity)

Called when the component is constructed.

Parameters:
  • registry – The entity registry.

  • entity – The entity.

static void OnDestroy(entt::registry &registry, entt::entity entity)

Called when the component is destroyed.

Parameters:
  • registry – The entity registry.

  • entity – The entity.

static void OnUpdate(entt::registry &registry, entt::entity entity)

Called when the component is updated.

Parameters:
  • registry – The entity registry.

  • entity – The entity.

static void Reparent(entt::registry &registry, entt::entity entity, entt::entity parent)

Reparent the entity to a new parent.

Parameters:
  • registry – The entity registry.

  • entity – The entity to reparent.

  • parent – The new parent entity.

static void Reorder(entt::registry &registry, entt::entity entity, entt::entity after, entt::entity before)

Move an entity within the hierarchy. Will reparent if needed.

Parameters:
  • registry – The entity registry

  • entity – The entity to be moved

  • after – The entity after which the entity will be moved to

  • before – The entity before which the entity will be moved to

class SceneTree
#include <SceneTree.h>

Class for managing the scene tree.

Public Functions

SceneTree(Scene *scene)

Constructor for SceneTree.

Parameters:

scene – The scene context.

~SceneTree() = default

Default destructor.

void Update()

Update the scene tree.

void UpdateTransform(entt::entity entity)

Update the transform of an entity.

Parameters:

entity – The entity to update.