Difference between revisions of "Editor Camera Script External Code"
m (→CameraObject class) |
m (→CameraObject class) |
||
(18 intermediate revisions by the same user not shown) | |||
Line 5: | Line 5: | ||
To see a list of external code that is available to all scripts, please see this page - [[Common Script External Code]] | To see a list of external code that is available to all scripts, please see this page - [[Common Script External Code]] | ||
− | This page is manually updated, so may be slightly out of date from time to time | + | This page is manually updated, so may be slightly out of date from time to time. |
== Global Variables == | == Global Variables == | ||
− | <pre style="white-space: pre-wrap;">CameraObject co; // Access camera parameters that aren't accessible from other scripts</pre> | + | <pre style="white-space: pre-wrap;">CameraObject co; // Access the editor camera controller itself, including parameters that aren't accessible from other scripts</pre> |
== Classes == | == Classes == | ||
=== [[#CameraObject class|CameraObject class]] === | === [[#CameraObject class|CameraObject class]] === | ||
<pre style="white-space: pre-wrap;">class CameraObject;</pre> | <pre style="white-space: pre-wrap;">class CameraObject;</pre> | ||
− | Access camera parameters that aren't accessible from other scripts, such as whether the camera is controlled by a player, frozen, or ignoring mouse input. | + | Access the editor camera controller object. |
+ | |||
+ | This lets you access parameters that aren't accessible from other scripts, such as whether the camera is controlled by a player, frozen, or ignoring mouse input. | ||
+ | |||
+ | It also gives access to a quaternion representing the orientation of the camera, instead of <code>Camera</code>'s euler angle access functions. | ||
+ | |||
+ | '''Note''': It is recommended to also set all these properties/call these functions on the '''<code>camera</code>''' object to match this camera controller in the editor camera script '''<code>Update</code>''' function: | ||
+ | |||
+ | * <code>camera.SetYRotation</code>, <code>camera.SetXRotation</code>, <code>camera.SetZRotation</code> | ||
+ | * <code>camera.SetPos</code> | ||
+ | * <code>camera.SetDistance</code> | ||
+ | * <code>camera.SetVelocity</code> | ||
+ | * <code>camera.SetFOV</code> | ||
+ | * <code>camera.SetDOF</code> | ||
+ | * <code>camera.CalcFacing</code>, <code>camera.CalcUp</code> | ||
'''Properties''' | '''Properties''' | ||
− | <pre style="white-space: pre-wrap;">vec3 velocity; | + | <pre style="white-space: pre-wrap;">vec3 velocity; |
− | bool controlled; // Whether the camera is currently being controlled by a player | + | // The current velocity of the editor camera controller. |
− | bool frozen; // | + | // Note: always call camera.SetVelocity in Update to set the actual camera velocity to match</pre> |
− | bool ignore_mouse_input; | + | <pre style="white-space: pre-wrap;">bool controlled; // Whether the editor camera controller is currently being controlled by a player</pre> |
− | bool has_position_initialized; | + | <pre style="white-space: pre-wrap;">bool frozen; // If the script should ignore all controller input. The engine doesn't currently use this at all</pre> |
+ | <pre style="white-space: pre-wrap;">bool ignore_mouse_input; | ||
+ | // If the script should ignore mouse input. Engine sets this when editor is doing selection, transformations</pre> | ||
+ | <pre style="white-space: pre-wrap;">bool has_position_initialized; | ||
+ | // Initialized to false when a level loads. Useful for teleporting the camera to the first controlled movement object</pre> | ||
'''Methods''' | '''Methods''' | ||
− | <pre style="white-space: pre-wrap;">const quaternion& GetRotation(); // Get the current direction of the camera controller | + | <pre style="white-space: pre-wrap;">const quaternion& GetRotation(); // Get the current direction of the editor camera controller</pre> |
− | void SetRotation(const quaternion &in quat); | + | <pre style="white-space: pre-wrap;">void SetRotation(const quaternion &in quat); |
− | const vec3& GetTranslation(); // Gets the current position of the camera controller | + | // Set the current direction of the editor camera controller. |
− | void SetTranslation(const vec3 &in vec); | + | // Note: always call camera.SetXRotation, etc, in Update to set the actual camera rotation to match</pre> |
+ | <pre style="white-space: pre-wrap;">const vec3& GetTranslation(); // Gets the current position of the editor camera controller</pre> | ||
+ | <pre style="white-space: pre-wrap;">void SetTranslation(const vec3 &in vec); | ||
+ | // Sets the current position of the editor camera controller. | ||
+ | // Note: always call camera.SetPos in Update to move the actual camera to the same spot</pre> | ||
'''Related Global Variables''' | '''Related Global Variables''' | ||
− | <pre style="white-space: pre-wrap;">CameraObject co; // The global instance of this class</pre> | + | <pre style="white-space: pre-wrap;">CameraObject co; // The global instance of this editor camera controller class</pre> |
<pre style="white-space: pre-wrap;">Camera camera; // The global instance of an object for controlling the actual camera itself</pre> | <pre style="white-space: pre-wrap;">Camera camera; // The global instance of an object for controlling the actual camera itself</pre> |
Latest revision as of 04:30, 19 November 2017
This is a list of the external code that is only available to be used inside the editor camera script - variables, functions, and classes that "magically" exist.
To see a list of external code that is available to all scripts, please see this page - Common Script External Code
This page is manually updated, so may be slightly out of date from time to time.
Global Variables
CameraObject co; // Access the editor camera controller itself, including parameters that aren't accessible from other scripts
Classes
CameraObject class
class CameraObject;
Access the editor camera controller object.
This lets you access parameters that aren't accessible from other scripts, such as whether the camera is controlled by a player, frozen, or ignoring mouse input.
It also gives access to a quaternion representing the orientation of the camera, instead of Camera
's euler angle access functions.
Note: It is recommended to also set all these properties/call these functions on the camera
object to match this camera controller in the editor camera script Update
function:
-
camera.SetYRotation
,camera.SetXRotation
,camera.SetZRotation
-
camera.SetPos
-
camera.SetDistance
-
camera.SetVelocity
-
camera.SetFOV
-
camera.SetDOF
-
camera.CalcFacing
,camera.CalcUp
Properties
vec3 velocity; // The current velocity of the editor camera controller. // Note: always call camera.SetVelocity in Update to set the actual camera velocity to match
bool controlled; // Whether the editor camera controller is currently being controlled by a player
bool frozen; // If the script should ignore all controller input. The engine doesn't currently use this at all
bool ignore_mouse_input; // If the script should ignore mouse input. Engine sets this when editor is doing selection, transformations
bool has_position_initialized; // Initialized to false when a level loads. Useful for teleporting the camera to the first controlled movement object
Methods
const quaternion& GetRotation(); // Get the current direction of the editor camera controller
void SetRotation(const quaternion &in quat); // Set the current direction of the editor camera controller. // Note: always call camera.SetXRotation, etc, in Update to set the actual camera rotation to match
const vec3& GetTranslation(); // Gets the current position of the editor camera controller
void SetTranslation(const vec3 &in vec); // Sets the current position of the editor camera controller. // Note: always call camera.SetPos in Update to move the actual camera to the same spot
Related Global Variables
CameraObject co; // The global instance of this editor camera controller class
Camera camera; // The global instance of an object for controlling the actual camera itself