Class TCamera

Unit

Declaration

type TCamera = class(TEntity3D)

Description

Camera description.

It defines the fustrum by setting the viewport (SetViewport), and the FarPlane and the NearPlane properties, so the height is 2 units and width is proportial to the viewport height/width relation.

See also
TWorld3D.Camera
Reference to the active camera.
TWorld3D.Render
Renders the world.

Hierarchy

Overview

Methods

Public CONSTRUCTOR Create; override;
Public DESTRUCTOR Destroy; OVERRIDE;
Public PROCEDURE SetViewport (CONST x, y, w, h: INTEGER);
Public PROCEDURE ApplyViewport; VIRTUAL;
Public procedure SetPerspectiveProjection;
Public procedure SetOrthographicProjection;
Public PROCEDURE Update; VIRTUAL;
Public PROCEDURE ApplyMatrix; VIRTUAL;
Public PROCEDURE ApplyRotationMatrix; INLINE;
Public PROCEDURE ApplyInverseRotationMatrix; INLINE;

Properties

Public property NearPlane: GLfloat READ fNear WRITE fNear;
Public property FarPlane: GLfloat READ fFar WRITE fFar;
Public property Light: TLight READ fLight;

Description

Methods

Public CONSTRUCTOR Create; override;

Creates and initialises the camera.

Public DESTRUCTOR Destroy; OVERRIDE;

Destroys the camera.

It also destroys the Light.

Public PROCEDURE SetViewport (CONST x, y, w, h: INTEGER);

Define the viewport used by this camera.

The viewport definition may affect the frustrum angle.

Parameters
x
Horizontal position of the viewport on the screen in pixels.
y
Vertical position of the viewport on the screen in pixels.
w
Width position of the viewport in pixels.
h
Height of the viewport in pixels.
See also
ApplyViewport
Apply the viewport configuration.
Public PROCEDURE ApplyViewport; VIRTUAL;

Apply the viewport configuration.

See also
SetViewport
Define the viewport used by this camera.
FarPlane
The far plane distance.
NearPlane
The near plane distance.
Public procedure SetPerspectiveProjection;

Change the camera projection matrix for perspective projection.

Note this affects the viewport only.

This method also call glLoadIdentity so it cleans the transformation matrix stack.

See also
TCamera.SetOrthographicProjection
Change the camera projection matrix for orthographic (paralel) projection.
Public procedure SetOrthographicProjection;

Change the camera projection matrix for orthographic (paralel) projection.

Note this affects the viewport only.

For OpenGL, screen coordinates are -1 to 1 in both height and width. For Allegro, it is pixel coordinates.

This method also call glLoadIdentity so it cleans the transformation matrix stack.

See also
TCamera.SetPerspectiveProjection
Change the camera projection matrix for perspective projection.
TDisplay.SetOrthographicProjection
Set orthogonal projection for full display.
Public PROCEDURE Update; VIRTUAL;

Updates the camera, if needed.

Public PROCEDURE ApplyMatrix; VIRTUAL;

Build an apply the camera matrix.

ApplyMatrix builds the camera matrix using current Position and Rotation then adds it to the matrix stack.

Note it doesn't loads the Identity matrix so previous applied matrices will affect the scene transformations.

See also
TCamera.ApplyRotationMatrix
Apply only the rotation matrix without translation.
ApplyInverseRotationMatrix
Apply the inverse rotation matrix.
Public PROCEDURE ApplyRotationMatrix; INLINE;

Apply only the rotation matrix without translation.

This can be used to implement skyboxes and other special effects.

See also
MultiplyVectorMatrix
Multiply the given vector with the given matrix.
ApplyInverseRotationMatrix
Apply the inverse rotation matrix.
Public PROCEDURE ApplyInverseRotationMatrix; INLINE;

Apply the inverse rotation matrix.

This can be used to implement billboards, 3D sprites and other special effects.

See also
MultiplyVectorMatrix
Multiply the given vector with the given matrix.
ApplyRotationMatrix
Apply only the rotation matrix without translation.

Properties

Public property NearPlane: GLfloat READ fNear WRITE fNear;

The near plane distance. It modifies FOV.

By default it's 1.5. You must call ApplyViewport after setting it.

See also
FarPlane
The far plane distance.
Public property FarPlane: GLfloat READ fFar WRITE fFar;

The far plane distance. It doesn't modifies FOV.

By default it's 1000. You must call ApplyViewport after setting it.

See also
NearPlane
The near plane distance.
Public property Light: TLight READ fLight;

A light attached to the camera, so its position and angle are relative to the camera.

You don't have to create this light because the camera creates one automatically.

The camera owns this light so if you assing a new one, the previous will be destroyed. If you need to change this light it's better to change the properties of the light than assign one.

If you don't want to use a camera light just assign Nil.


Generated by PasDoc 0.15.0. Generated on 2025-07-31 11:41:01.