Skip to content

Camera

Looking through a camera of your own, and where things are on screen. Everything here needs host 0.14.0.

Shake

bool Camera::Shake(double scale = 1)

Shakes the player's camera the way the game does, scale times as hard. Requires host 0.20.0.

Example
Camera::Shake(0.5);

Project

bool Camera::Project(double, double, double, float &out, float &out)

Where a point in the world shows on screen, in the units windows are placed in (Window.SetRect). False when it's behind the camera.

Example
float sx, sy;
if (Camera::Project(x, y, z, sx, sy))
    label.SetRect(sx - 80, sy - 26, 160, 26);

Take

bool Camera::Take()

Makes the game look through your camera, starting where the game's camera is. False if another plugin has it.

Example
Camera::Take();

Set

bool Camera::Set(double x, double y, double z, double pitch, double yaw, double fov = 90)

Places your camera: where it is, which way it looks (degrees; pitch up and down, yaw around) and how wide (field of view, degrees).

Example
Camera::Set(x, y, z, -30, 45, 80);

Release

void Camera::Release()

Goes back to the game's own view.

Example
Camera::Release();

IsTaken

bool Camera::IsTaken()

Whether you have the camera.

Example
if (Camera::IsTaken())
    Camera::Set(x, y, z, pitch, yaw);

Sweep

bool Camera::Sweep(double sx, double sy, double sz, double ex, double ey, double ez, double radius, double &out fraction)

Sweeps a sphere of radius from one point to another on the camera's collision channel, with every ball ignored, and gives how far along it got before it hit something (fraction, 0 to 1; 1 is clear). For a plugin camera that pulls in instead of going through walls. False if it couldn't be traced. Requires host 0.25.0.

Example
double clear;
if (Camera::Sweep(bx, by, bz, cx, cy, cz, 20, clear) && clear < 1)
{
    cx = bx + (cx - bx) * clear;      // pulled in to the wall
    cy = by + (cy - by) * clear;
    cz = bz + (cz - bz) * clear;
}