Skip to main content

Basic object types


The Object3D object​


The most basic object in Brakeza3D is Object3D. Any element in the scene is an Object3D.

Common properties​

PropertyTypeDescription
NamestringName of object
PositionVertex3DPosition in the world
RotationM3Object rotation
ScalefloatModel scale factor
EnabledboolDetermines if the object is active or not
RemovedboolDetermines if the object is marked to remove
SelectableboolWhether the object can be selected via mouse click
HighlightedboolWhether the object renders a colored outline (set via setHighlight)

Interacting with an Object3D​


We can interact with an Object3D using several methods:

Object3D API​


Getters​

MethodReturnDescription
getName()stringGets the object's name
getPosition()Vertex3DGets the object's position
getRotation()M3Gets the rotation
getScale()floatGets the scale factor
getTypeObject()ObjectTypeReturns the object type
getM3ModelMatrix()M3Gets the object's model matrix
getAlpha()floatGets the object's opacity
AxisForward()Vertex3DReturns the forward axis
AxisUp()Vertex3DReturns the up axis
AxisRight()Vertex3DReturns the right axis

Setters​

MethodReturnDescription
setName(name: string)voidSets a new object name
setPosition(position: Vertex3D)voidSets a new position
setRotation(rotation: M3)voidSets a new rotation
setScale(scale: float)voidSets a new scale factor
setAlpha(alpha: float)voidSets a new opacity factor
setEnabled(enable: bool)voidActivates or deactivates the object
setRemoved(removed: bool)voidRemoves the object in the next frame
setSelectable(selectable: bool)voidEnables or disables mouse selection for this object
setHighlight(r, g, b, a: float)voidDraws a colored outline around the object (Mesh3D only)
clearHighlight()voidRemoves the colored outline from the object

Actions​

MethodParametersDescription
LookAt()target: Object3DRotates the object to face another object
isSelectable()—Returns whether the object can be selected via mouse
isHighlighted()—Returns whether the object has an active highlight outline

It is also possible to add new Object3D instances to the scene using code via ObjectFactory.

Scripting on Object3D​


As we will see later, objects in Brakeza3D can be manipulated through scripts. Scripts allow you to encapsulate reusable logic and apply it across multiple objects.

Multiple scripts can be attached to a single object, and objects can also be controlled from generic or scene-level scripts.

Derived objects from Object3D​


Brakeza3D includes several ready-to-use 3D objects, all derived from Object3D. Since they inherit from Object3D, these objects can also use all the methods and properties previously described for Object3D, providing consistency and flexibility when manipulating them in the scene.

ObjectDescription
Mesh3D3D model with triangles and textures
Mesh3DAnimationSimilar to Mesh3D, but for animated models
Image2DDraws an image on screen
Image3D3D plane with an image texture
Image2DAnimationSet of Image2D objects forming an animation
ParticleEmitterParticle emitter
LightPointPoint light
LightSpotSpotlight
SwarmFlocking simulation (boids + predators)

Some of these objects will be detailed later in the documentation.

Object factory​


Additionally, Brakeza3D provides an ObjectFactory that allows developers to create almost any object in the 3D world programmatically, making scene construction highly flexible and dynamic.

Auxiliary Basic Types​


There are several data types that facilitate 3D tasks and are available in your Lua scripts.

Vertex3D​

Represents a point in three-dimensional space or a vector originating from (0, 0, 0).
It is used for geometric and vector algebra operations in 3D environments.

Vertex3D provides support for 3D coordinates and common vector operations such as addition, subtraction, vector products, normalization, scaling, and distance calculation.

Properties​

PropertyTypeDescription
xfloatX coordinate
yfloatY coordinate
zfloatZ coordinate

Methods​

MethodReturn TypeDescription
operator +(Vertex3D)Vertex3DVector addition
operator -(Vertex3D)Vertex3DVector subtraction
operator *(Vertex3D)floatCross product (as defined by the project specification)
operator %(Vertex3D)Vertex3DDot product (as defined by the project specification)
getNormalize()Vertex3DReturns the normalized vector
getModule()floatVector length (magnitude)
getInverse()Vertex3DReturns the inverted vector
getScaled(float factor)Vertex3DReturns the vector scaled by a factor
distance(Vertex3D)floatDistance to another vertex

M3 (Matrix 3x3)​

Represents a 3x3 floating-point matrix used to define rotations in 3D space.
It is commonly used for orientation, axis transformations, and rotating vectors.

M3 encapsulates a 3x3 rotation matrix and provides basic matrix operations, axis extraction, and utilities for creating identity, transposed, and Euler-based rotation matrices.

Properties​

PropertyTypeDescription
valuesfloat[9]Stores the 3x3 matrix values

Methods​

MethodReturn TypeDescription
operator +(M3)M3Matrix addition
operator -(M3)M3Matrix subtraction
operator *(M3)M3Matrix multiplication
operator *(Vertex3D)Vertex3DMultiplies the matrix by a vector
X()Vertex3DReturns the X axis vector
Y()Vertex3DReturns the Y axis vector
Z()Vertex3DReturns the Z axis vector
getMatrixIdentity()M3Returns the identity matrix
getTranspose()M3Returns the transposed matrix
getMatrixRotationForEulerAngles(p, y, r)M3Creates a rotation matrix from Euler angles (pitch, yaw, roll)

AABB (Axis-Aligned Bounding Box)​

Represents an Axis-Aligned Bounding Box (AABB) in 3D space.
An AABB is a bounding volume whose faces are aligned with the coordinate axes, commonly used for collision detection and spatial queries.

AABB3D defines a box using two vertices: the minimum and maximum corners.
Because it is aligned with the coordinate axes, intersection and containment tests are fast and efficient.

Properties​

PropertyTypeDescription
minVertex3DMinimum corner of the bounding box
maxVertex3DMaximum corner of the bounding box

Methods​

MethodReturn TypeDescription
isColliding(AABB3D)boolChecks overlap with another AABB
size()Vertex3DReturns the size of the bounding box
getCenter()Vertex3DReturns the center point of the bounding box
isPointInside(Vertex3D)boolChecks whether a point is inside the bounding box

Point2D​

Represents a point or vector in two-dimensional space using integer coordinates.
It is commonly used for grid-based logic, screen positioning, and 2D calculations.

Point2D provides basic arithmetic and utility operations for working with 2D vectors, including addition, subtraction, normalization, and scaling.

Properties​

PropertyTypeDescription
xintX coordinate
yintY coordinate

Methods​

MethodReturn TypeDescription
operator +(Point2D)Point2DPoint/vector addition
operator -(Point2D)Point2DPoint/vector subtraction
operator /(Point2D)Point2DComponent-wise division
getNormalize()Point2DReturns the normalized vector
getScaled(float factor)Point2DReturns the vector scaled by a factor

Color​

Represents an RGBA color with floating-point components.
It is commonly used for rendering, shading, and color manipulation in 2D and 3D engines.

Color encapsulates red, green, blue, and alpha components, providing arithmetic operations, comparisons, and utility functions.
Several predefined colors are available for convenience.

Constructors​

ConstructorDescription
Color()Default constructor, initializes to black (0, 0, 0, 0)
Color(float r, float g, float b, float a = 0)Initializes color with specified RGBA values

Properties​

PropertyTypeDescription
rfloatRed component (0.0 – 1.0)
gfloatGreen component (0.0 – 1.0)
bfloatBlue component (0.0 – 1.0)
afloatAlpha (opacity) component (0.0 – 1.0)

Methods​

MethodReturn TypeDescription
operator +(Color)ColorAdds two colors component-wise
operator -(Color)ColorSubtracts two colors component-wise
operator *(Color)ColorMultiplies two colors component-wise
operator *(float)ColorMultiplies color by a scalar
operator /(float)ColorDivides color by a scalar
operator ==(Color)boolChecks equality of two colors
setRed(float)voidSets the red component
setGreen(float)voidSets the green component
setBlue(float)voidSets the blue component

Predefined Colors​

NameRGBA
white()(1, 1, 1, 0)
red()(1, 0, 0, 0)
green()(0, 1, 0, 0)
blue()(0, 0, 1, 0)
black()(0, 0, 0, 0)
yellow()(1, 1, 0, 0)
fuchsia()(1, 0, 1, 0)
cyan()(0, 1, 1, 0)
orange()(1, 0.5, 0.2, 0)
olive()(0.5, 0.5, 0, 0)
gray()(0.5, 0.5, 0.5, 0)
pink()(1, 0.41, 0.71, 0)
lime()(0.75, 1, 0, 0)
turquoise()(0.25, 0.88, 0.82, 0)
violet()(0.93, 0.51, 0.93, 0)
gold()(1, 0.84, 0, 0)
indigo()(0.29, 0, 0.51, 0)
magenta()(1, 0, 0.56, 0)
aquamarine()(0.5, 1, 0.83, 0)
crimson()(0.86, 0.08, 0.24, 0)
FOGDefault()(0.5, 0.5, 0.5, 0)

Image​

Represents a 2D image object in Brakeza3D that can be positioned, resized, and rendered on the screen.
Image2D inherits from Object3D, allowing it to integrate seamlessly with the engine’s scene system while providing 2D-specific functionality.

Constructors​

ConstructorDescription
Image2D()Default constructor
Image2D(string pathFile, int width, int height)Constructor that loads an image from file with the specified size

Properties​

PropertyTypeDescription
xintX position on the screen
yintY position on the screen
widthintWidth of the image on screen
heightintHeight of the image on screen
filepathstringPath to the image file

Methods​

MethodReturn TypeDescription
setSize(int x, int y)voidSets the width and height of the image
setScreenPosition(int x, int y)voidSets the X and Y screen position
setFilePath(const std::string &filepath)voidSets the file path for the image
getTypeObject()ObjectTypeReturns the type of object (Image2D)