Skip to content

camera

FreeBodyEngine.core.camera #

CAMERA_PROJECTION #

Bases: Enum

The two projection modes a Camera can use to build its projection matrix.

ORTHOGRAPHIC = auto() class-attribute instance-attribute #

PERSPECTIVE = auto() class-attribute instance-attribute #

Camera(projection, background_color, zoom) #

Mixin holding the projection/background/matrix state shared by Camera2D and Camera3D - always used alongside a Node2D/Node3D base (see those classes), never on its own.

Stores the camera's settings and sets view_matrix/proj_matrix to identity until the first matrix update runs.

background_color = background_color instance-attribute #

proj_matrix = np.identity(4, np.float32) instance-attribute #

projection = projection instance-attribute #

view_matrix = np.identity(4, np.float32) instance-attribute #

zoom = zoom instance-attribute #

Camera2D(position=Vector(), zoom=250, rotation=0, projection=CAMERA_PROJECTION.ORTHOGRAPHIC, background_color=Color('#060e08')) #

Bases: Node2D, Camera

A generic camera object. The camera doesn't draw anything, its only purpose is to provide matricies to the renderer.

:param position: The world position of the camera. :type position: vector

:param zoom: The zoom of the camera. The larger the zoom value, the larger the image. :type zoom: float

:param rotation: The rotation of the camera around the Z axis. :type rotation: float

:param background_color: The color that the background of the screen will be set to. :type background_color: Color

Initializes both the Node2D and Camera halves of this object, since Camera2D doesn't use a single cooperative super().__init__() chain.

on_initialize() #

Builds the initial projection and view matrices once the camera is attached to the scene tree (and so has a world_transform).

update() #

Updates the node tree as usual, then rebuilds both matrices every frame so the camera tracks window resizes and its own movement/rotation/zoom without needing an explicit invalidation.

Camera3D(position=Vector3(), rotation=Vector3(), zoom=1.0, projection=CAMERA_PROJECTION.PERSPECTIVE, background_color=Color('#324848')) #

Bases: Node3D, Camera

A 3D counterpart to Camera2D.

Initializes both the Node3D and Camera halves of this object, since Camera3D doesn't use a single cooperative super().__init__() chain.

on_initialize() #

Builds the initial projection and view matrices once the camera is attached to the scene tree (and so has a world_transform).

update() #

Updates the node tree as usual, then rebuilds both matrices every frame so the camera tracks window resizes and its own movement/rotation/zoom without needing an explicit invalidation.