t
Loading...
Searching...
No Matches
t::Object3D Class Reference

The 3D object class. More...

#include <Object3D.hpp>

Inheritance diagram for t::Object3D:
t::Camera t::Light t::Mesh t::Scene t::OrthographicCamera t::PerspectiveCamera t::AmbientLight t::PointLight

Public Member Functions

virtual bool isMesh () const
 Returns whether this 3D object is a mesh.
 
virtual bool isLight () const
 Returns whether this 3D object is a light.
 
Object3Dadd (Object3D &child)
 Adds another 3D object as a child of this 3D object.
 
Object3Dtranslate (double x, double y, double z)
 Translates this 3D object by the specified amounts along the x, y, and z axes in local space.
 
Object3Drotate (double x, double y, double z, EulerRotationOrder order)
 Rotates this 3D object by the specified angles around the x, y, and z axes in local space.
 
Object3Dscale (double x, double y, double z)
 Scales this 3D object by the specified amounts along the x, y, and z axes in local space.
 
Object3DupdateLocalMatrix ()
 Updates the local transformation matrix of this 3D object.
 
Object3DupdateModelMatrix ()
 Updates the model matrix of this 3D object.
 

Public Attributes

std::optional< std::reference_wrapper< Object3D > > parent
 The parent of this 3D object.
 
Vector3 up = DEFAULT_UP
 The vector pointing to the up direction in object space.
 
Vector3 localPosition
 The position of this 3D object relative to its parent.
 
EulerRotation localRotation
 The rotation of this 3D object relative to its parent.
 
Vector3 localScale
 The scale of this 3D object relative to its parent.
 
Matrix4x4 localMatrix
 The matrix of the local transformation of this 3D object.
 
Matrix4x4 modelMatrix
 The model matrix of this 3D object, transformating local space to world space.
 
std::vector< std::reference_wrapper< Object3D > > children
 The children of this 3D object.
 

Detailed Description

The 3D object class.

A 3D object has a position, rotation, and scale in 3D space. It can also have a parent and children. The most common types of 3D objects are meshes and groups of meshes. Scenes, cameras, and lights are special types of 3D objects.

Member Function Documentation

◆ add()

Object3D & t::Object3D::add ( Object3D & child)
inline

Adds another 3D object as a child of this 3D object.

Returns
This 3D object.

◆ isLight()

virtual bool t::Object3D::isLight ( ) const
inlinevirtual

Returns whether this 3D object is a light.

Used internally before casting an Object3D to a Light.

Returns
false

Reimplemented in t::Light.

◆ isMesh()

virtual bool t::Object3D::isMesh ( ) const
inlinevirtual

Returns whether this 3D object is a mesh.

Used internally before casting an Object3D to a Mesh.

Returns
false

Reimplemented in t::Mesh.

◆ rotate()

Object3D & t::Object3D::rotate ( double x,
double y,
double z,
EulerRotationOrder order )
inline

Rotates this 3D object by the specified angles around the x, y, and z axes in local space.

Parameters
xThe angle, in radians, to rotate around the x axis.
yThe angle, in radians, to rotate around the y axis.
zThe angle, in radians, to rotate around the z axis.
orderThe order of the rotations.
Returns
This 3D object.

◆ scale()

Object3D & t::Object3D::scale ( double x,
double y,
double z )
inline

Scales this 3D object by the specified amounts along the x, y, and z axes in local space.

Parameters
xThe amount to scale along the x axis.
yThe amount to scale along the y axis.
zThe amount to scale along the z axis.
Returns
This 3D object.

◆ translate()

Object3D & t::Object3D::translate ( double x,
double y,
double z )
inline

Translates this 3D object by the specified amounts along the x, y, and z axes in local space.

Parameters
xThe amount to translate along the x axis.
yThe amount to translate along the y axis.
zThe amount to translate along the z axis.
Returns
This 3D object.

◆ updateLocalMatrix()

Object3D & t::Object3D::updateLocalMatrix ( )
inline

Updates the local transformation matrix of this 3D object.

The local transformation matrix is calculated from the local position, rotation, and scale of this 3D object.

Returns
This 3D object.

◆ updateModelMatrix()

Object3D & t::Object3D::updateModelMatrix ( )
inline

Updates the model matrix of this 3D object.

The model matrix is calculated as \(M_pL\) where \(M_p\) is the model matrix of the parent of this 3D object and \(L\) is the local matrix of this 3D object. If this 3D object has no parent, the model matrix is the same as the local matrix.

Returns
This 3D object.

Member Data Documentation

◆ localMatrix

Matrix4x4 t::Object3D::localMatrix
Initial value:
=
static Matrix4x4 identity()
Returns a identity matrix.
Definition Matrix4x4.hpp:45

The matrix of the local transformation of this 3D object.

This is calculated automatically by default during the render process from localPosition, localRotation, and localScale.

◆ localPosition

Vector3 t::Object3D::localPosition
Initial value:
= Vector3(
0, 0, 0)

The position of this 3D object relative to its parent.

◆ localRotation

EulerRotation t::Object3D::localRotation
Initial value:
= EulerRotation(
0, 0, 0, EulerRotationOrder::Xyz)

The rotation of this 3D object relative to its parent.

◆ localScale

Vector3 t::Object3D::localScale
Initial value:
= Vector3(
1, 1, 1)

The scale of this 3D object relative to its parent.

◆ modelMatrix

Matrix4x4 t::Object3D::modelMatrix
Initial value:

The model matrix of this 3D object, transformating local space to world space.

This is calculated automatically by default during the render process.


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