BBMOD_Camera

constructor

new BBMOD_Camera()

Description

A camera with support for both orthographic and perspective projection. While using perspective projection, you can easily switch between first-person and third-person view. Comes with a mouselook implementation that also works in HTML5.

Properties

Name Description
AspectRatio The camera's aspect ratio. Defaults to 16 / 9.
AudioListener If true then the camera updates position and orientation of the 3D audio listener in the BBMOD_Camera.update_matrices method. Defaults to true.
Direction The camera's horizontal direction. Defaults to 0.
DirectionUp The camera's vertical direction. Automatically clamped between BBMOD_Camera.DirectionUpMin and BBMOD_Camera.DirectionUpMax. Defaults to 0.
DirectionUpMax Maximum angle that BBMOD_Camrea.DirectionUp can be. Use undefined to remove the limit. Default value is 89.
DirectionUpMin Minimum angle that BBMOD_Camrea.DirectionUp can be. Use undefined to remove the limit. Default value is -89.
Exposure The camera's exposure value. Defaults to 1.
FollowCurve A function which remaps value in range 0..1 to a different 0..1 value. This is used to control the follow curve. If not defined then lerp is used. Defaults to undefined.
FollowFactor Controls lerp factor between the previous camera position and the object it follows. Defaults to 1, which means the camera is immediately moved to its target position. BBMOD_Camera.FollowObject must not be undefined for this to have any effect.
FollowObject An id of an instance to follow or undefined. The object must have a z variable (position on the z axis) defined! Defaults to undefined.
Fov The camera's field of view. Defaults to 60.
MouseLook If true then mouselook is enabled. Defaults to false.
MouseSensitivity Controls the mouselook sensitivity. Defaults to 1.
Offset The camera's offset from its target. Defaults to (0, 0, 0).
Orthographic Use true to enable orthographic projection. Defaults to false (perspective projection).
Position The camera's positon. Defaults to (0, 0, 0).
Raw An underlying GameMaker camera.
Roll The angle of camera's rotation from side to side. Default value is 0.
Target A position where the camera is looking at. In FPS mode (BBMOD_Camera.Zoom equals to 0) this is the camera's direction. Defaults to (1, 0, 0).
Up OBSOLETE The camera's up vector. Defaults to (0, 0, 1).
ViewProjectionMatrix The view * projection matrix.
Width The width of the orthographic projection. Height is computed using BBMOD_Camera.AspectRatio. Defaults to the window's width.
ZFar Distance to the far clipping plane. Anything farther from the camera than this will not be visible. Defaults to 32768.
ZNear Distance to the near clipping plane. Anything closer to the camera than this will not be visible. Defaults to 0.1.
Zoom The camera's distance from its target. Use 0 for a first-person camera. Defaults to 0.

Methods

Name Description
apply Applies the camera.
get_forward Retrieves a vector pointing forward in the camera's direction.
get_proj_mat Retrieves camera's projection matrix.
get_right Retrieves a vector pointing right relative to the camera's direction.
get_up Retrieves a vector pointing up relative to the camera's direction.
get_view_mat Retrieves camera's view matrix.
set_mouselook Enable/disable mouselook. This locks the mouse cursor at its current position when enabled.
update Handles mouselook, updates camera's position, matrices etc.
update_matrices Recomputes camera's view and projection matrices.
world_to_screen Computes screen-space position of a point in world-space.

Example

// Create event
camera = new BBMOD_Camera();
camera.FollowObject = OPlayer;
camera.Zoom = 0.0; // Use 0.0 for FPS, > 0.0 for TPS

// End-Step event
camera.set_mouselook(true);
camera.update(delta_time);

// Draw event
camera.apply();
// Render scene here...
Do you find this page helpful?

Copyright © 2022, BlueBurn. Built on May 18, 2022 using GMDoc.