Skip to content

static class Camera (client-side)

Available since version: 0.1.3

This class represents in game Camera.

Properties

Mat4& vobMatrix

Available since version: 0.2.0

Represents the reference to the camera vob matrix in world space.


Mat4& viewMatrix

Available since version: 0.2.0

Represents the reference to the camera view matrix.


Mat4& projectionMatrix

Available since version: 0.2.0

Represents the reference to the camera projection matrix.


Mat4& worldMatrix

Available since version: 0.2.0

Represents the reference to the camera world matrix.


Mat4& worldViewMatrix

Available since version: 0.2.0

Represents the reference to the camera world-view matrix.


bool modeChangeEnabled

Represents the camera mode change feature.
When mode change is enabled, game switches between different camera modes, e.g: when you draw weapon, camera mode will switch to "CAMMODMELEE".


bool movementEnabled

Represents the camera movement feature.
When movement is disabled, the camera gets detached from the player.


Methods

setMode

This method will set the camera mode.

void setMode(string mode, array[userpointer] targetList)

Parameters:

  • string mode: the camera mode.
  • array[userpointer] targetList: =[] the list containing vobs used by the specific camera mode, e.g: CamModDialog requires list containing two npc pointers.

getMode

This method will get the camera mode.

string getMode()

Returns string:

the camera mode.


getPosition

This method will get the camera position.

{x, y, z} getPosition()

Returns {x, y, z}:

the camera position.


setPosition

This method will set the camera position.

void setPosition(float x, float y, float z)

Parameters:

  • float x: the position on x axis.
  • float y: the position on y axis.
  • float z: the position on z axis.

getRotation

Note

There's no guarantee that returned rotation will be the same as the set one.

This method will get the camera rotation.

{x, y, z} getRotation()

Returns {x, y, z}:

the camera rotation.


setRotation

This method will set the camera rotation.

void setRotation(float x, float y, float z)

Parameters:

  • float x: the rotation on x axis in deegres.
  • float y: the rotation on y axis in deegres.
  • float z: the rotation on z axis in deegres.

project

Available since version: 0.1.10

This method will convert point from 3d world space to screen coordinates (pixels).

Vec2|null project(float x, float y, float z)

Parameters:

  • float x: the position on x axis.
  • float y: the position on y axis.
  • float z: the position on z axis.

Returns Vec2|null:

screen coordinates represented as pixels. If projected point is behind camera, null is returned instead.


backProject

Available since version: 0.2.1

This method will convert point from 2d screen coordinates (pixels) to 3d world space.

Vec3 backProject(int screenX, int screenY, float distance)

Parameters:

  • int screenX: the x position on screen in pixels.
  • int screenY: the y position on screen in pixels.
  • float distance: the relative distance from the camera.

Returns Vec3:

world space coordinates.


setTargetVob

This method will set the target vob for the camera.

void setTargetVob(Vob vob)

Parameters:

  • Vob vob: the vob object reference.

setTargetPlayer

This method will set the target player for the camera.

void setTargetPlayer(int playerId)

Parameters:

  • int playerId: the id of the player.