Difference between revisions of "Editor Camera"
m (→Callable functions and data available inside camera scripts) |
m (→Overview) |
||
(3 intermediate revisions by the same user not shown) | |||
Line 2: | Line 2: | ||
[[Category: Modding]] | [[Category: Modding]] | ||
[[Category:Overgrowth]] | [[Category:Overgrowth]] | ||
− | |||
− | + | The editor camera controller lets you access editor-specific state, so you can set the active camera properties to match. It also lets you respond to special editor-only events like selections, translations, etc, and appropriately freeze camera controls. | |
− | + | '''Note''': This documentation mostly applies to '''the editor camera script'''. You can access cameras from other scripts (level scripts, hotspots, character scripts), and may not need to change the editor camera script in order to get the functionality you're looking for! | |
'''TODO''': Multiple cameras - are those even a thing? How does it work for split-screen? | '''TODO''': Multiple cameras - are those even a thing? How does it work for split-screen? | ||
Line 12: | Line 11: | ||
= Documentation = | = Documentation = | ||
− | == Callable functions and data available inside camera | + | == Callable functions and data available inside the editor camera script == |
The editor camera script gets an instances of the camera itself (a variable defined as <code>Camera@ camera</code>), so it can affect the active camera. | The editor camera script gets an instances of the camera itself (a variable defined as <code>Camera@ camera</code>), so it can affect the active camera. | ||
Line 30: | Line 29: | ||
* [[Editor_Camera_Script_External_Code|These functions are unique to the editor camera script]] | * [[Editor_Camera_Script_External_Code|These functions are unique to the editor camera script]] | ||
* [[Common_Script_External_Code|These functions are shared with other script types]] - '''Beware, some of this code is only available to other script types! Read the docs carefully!''' | * [[Common_Script_External_Code|These functions are shared with other script types]] - '''Beware, some of this code is only available to other script types! Read the docs carefully!''' | ||
− | * [[Level_Script_External_Code|These functions are unique to level scripts and cannot be called from the editor camera script]] - Useful so you can | + | * [[Level_Script_External_Code|These functions are unique to level scripts and cannot be called from the editor camera script]] - Useful so you can see the '''code that does not work in this script'''. |
== Camera instances in other scripts == | == Camera instances in other scripts == | ||
Line 38: | Line 37: | ||
The camera object (that actually affects the screen) is exposed to other scripts as instances of the <code>Camera</code> class (as <code>Camera@ camera</code>). | The camera object (that actually affects the screen) is exposed to other scripts as instances of the <code>Camera</code> class (as <code>Camera@ camera</code>). | ||
− | = How to create a custom camera script = | + | = How to create a custom editor camera script = |
The editor camera script always has this path: <code>Data/Scripts/cam.as</code> | The editor camera script always has this path: <code>Data/Scripts/cam.as</code> | ||
Line 44: | Line 43: | ||
If you are overriding this in a mod, it will have this path: <code>Data/Mods/<your_mod_name>/Scripts/cam.as</code> | If you are overriding this in a mod, it will have this path: <code>Data/Mods/<your_mod_name>/Scripts/cam.as</code> | ||
− | = | + | = Editor camera script hook functions = |
− | '''All functions inside | + | '''All functions inside the editor camera script are required''' |
* [[#Init function|<code>void Init() { }</code>]] | * [[#Init function|<code>void Init() { }</code>]] | ||
Line 56: | Line 55: | ||
<pre style="white-space: pre-wrap;">void Init() { }</pre> | <pre style="white-space: pre-wrap;">void Init() { }</pre> | ||
− | [[# | + | [[#Editor camera script hook functions|'''Required''']] |
<code>Init</code> is called when the camera is first loaded, upon level load. | <code>Init</code> is called when the camera is first loaded, upon level load. | ||
Line 68: | Line 67: | ||
<pre style="white-space: pre-wrap;">void Update() { }</pre> | <pre style="white-space: pre-wrap;">void Update() { }</pre> | ||
− | [[# | + | [[#Editor camera script hook functions|'''Required''']] |
<code>Update</code> is called regularly by the engine so you can perform work. | <code>Update</code> is called regularly by the engine so you can perform work. | ||
Line 74: | Line 73: | ||
It may be useful to do initialization once in this function, if you need to delay camera updates until other objects have loaded. | It may be useful to do initialization once in this function, if you need to delay camera updates until other objects have loaded. | ||
− | Be careful to keep this function short, sweet, and fast. <code>Update</code> gets called 120 times a second as of the time of this writing. '''TODO''': Is this accurate for camera | + | Be careful to keep this function short, sweet, and fast. <code>Update</code> gets called 120 times a second as of the time of this writing. '''TODO''': Is this accurate for the editor camera script? |
== FrameSelection function == | == FrameSelection function == | ||
Line 80: | Line 79: | ||
<pre style="white-space: pre-wrap;">void FrameSelection(bool increased_distance) { }</pre> | <pre style="white-space: pre-wrap;">void FrameSelection(bool increased_distance) { }</pre> | ||
− | [[# | + | [[#Editor camera script hook functions|'''Required''']] |
<code>FrameSelection</code> is called when the "frame selection" action called in editor. This is invoked in one of two ways: | <code>FrameSelection</code> is called when the "frame selection" action called in editor. This is invoked in one of two ways: |
Latest revision as of 04:40, 19 November 2017
Contents
Overview
The editor camera controller lets you access editor-specific state, so you can set the active camera properties to match. It also lets you respond to special editor-only events like selections, translations, etc, and appropriately freeze camera controls.
Note: This documentation mostly applies to the editor camera script. You can access cameras from other scripts (level scripts, hotspots, character scripts), and may not need to change the editor camera script in order to get the functionality you're looking for!
TODO: Multiple cameras - are those even a thing? How does it work for split-screen?
Documentation
Callable functions and data available inside the editor camera script
The editor camera script gets an instances of the camera itself (a variable defined as Camera@ camera
), so it can affect the active camera.
It also gets an instance of the editor camera controller object (a variable defined as CameraObject@ co
), so it can access special camera controller object properties that are applied by the editor.
A list of functions, data, etc, is created automatically whenever you run the game, in a file on your hard drive. This lists some of the external code you get "for free" and can call from inside the editor camera script. (Some of this code in this list is not usable from an editor camera script - see the links below for more info).
- Windows:
My Documents\Wolfire\Overgrowth\aslevel_docs.h
- Mac:
~/Library/Application Support/Overgrowth/aslevel_docs.h
- Linux:
~/.local/share/Overgrowth/aslevel_docs.h
This documentation will change with each version of the game, so keep checking back on this aslevel_docs.h
file to see the most up to date information.
There are also wiki pages which have more detailed documentation many of these functions. These pages have a danger of going out of date, but give more detailed documentation on some of the code:
- These functions are unique to the editor camera script
- These functions are shared with other script types - Beware, some of this code is only available to other script types! Read the docs carefully!
- These functions are unique to level scripts and cannot be called from the editor camera script - Useful so you can see the code that does not work in this script.
Camera instances in other scripts
The editor camera controller is not exposed to other scripts at all. It is only accessible to the engine, and in the editor camera script.
The camera object (that actually affects the screen) is exposed to other scripts as instances of the Camera
class (as Camera@ camera
).
How to create a custom editor camera script
The editor camera script always has this path: Data/Scripts/cam.as
If you are overriding this in a mod, it will have this path: Data/Mods/<your_mod_name>/Scripts/cam.as
Editor camera script hook functions
All functions inside the editor camera script are required
Init function
void Init() { }
Init
is called when the camera is first loaded, upon level load.
Be careful, this may be called before some objects or script params are present in the level.
It is most useful for setting initial values for file-scope angelscript state.
Update function
void Update() { }
Update
is called regularly by the engine so you can perform work.
It may be useful to do initialization once in this function, if you need to delay camera updates until other objects have loaded.
Be careful to keep this function short, sweet, and fast. Update
gets called 120 times a second as of the time of this writing. TODO: Is this accurate for the editor camera script?
FrameSelection function
void FrameSelection(bool increased_distance) { }
FrameSelection
is called when the "frame selection" action called in editor. This is invoked in one of two ways:
- Via hotkeys (F or SHIFT + F)
- Via the
Go To Selected
action in the menu. Top Bar -> Selected -> Go To Selected
The increased_distance
parameter will be set to true
if the desired action is to frame all selected items within the camera
(the F hotkey, or the Go To Selected menu item set this to true
).
The increased_distance
parameter will be set to false
if the desired action is to teleport to the selected items
(the SHIFT + F hotkey sets this to false
).