You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+19-70
Original file line number
Diff line number
Diff line change
@@ -30,6 +30,9 @@ Note that when using `go.animate()`, `go.get()` and `go.set()` you need to make
30
30
*`go.set("mycamera#camerascript", "zoom")`
31
31
*`go.get("mycamera#camerascript", "zoom")`
32
32
33
+
#### order (number)
34
+
The order in which multiple cameras should be drawn, lower is drawn first.
35
+
33
36
#### projection (hash)
34
37
The camera can be configured to support different kinds of orthographic projections. The default projection (aptly named `DEFAULT`) uses the same orthographic projection matrix as in the default render script (ie aspect ratio isn't maintained and content is stretched). Other projections are available out-of-the box:
35
38
@@ -43,9 +46,6 @@ Additional custom projections can be added, see `camera.add_projector()` below.
43
46
#### enabled (boolean)
44
47
This controls if the camera is enabled by default or not. Send `enable` and `disable` messages to the script or use `go.set(id, "enable", true|false)` to toggle this value.
45
48
46
-
#### offset_gui (boolean)
47
-
This controls if the gui should be offset during a screen shake or a camera recoil. This will send the camera offset to the render script using the `send_camera_offset` message.
48
-
49
49
#### follow (boolean)
50
50
This controls if the camera should follow a target or not. See `camera.follow()` for details.
51
51
@@ -73,6 +73,9 @@ The camera bounds. See `camera.bounds()` for details.
In order for the Orthographic camera to function properly you need to integrate it in your render script. You can do this in a number of different ways:
@@ -81,81 +84,27 @@ In order for the Orthographic camera to function properly you need to integrate
81
84
The Orthographic API comes with a ready to use render script in `orthographic/render/orthograpic.render_script`. Open `game.project` and make sure to reference `orthographic/render/orthograpic.render` in the `Render` field in the `Bootstrap` section.
82
85
83
86
### 2. Integrating in an existing render script
84
-
While the camera is enabled it will send `set_view_projection` messages once per frame to the render script. The message is the same as that of the camera component, meaning that it contains `id`, `view` and `projection` values. Make sure that these values are handled and used properly in the render script.
85
-
86
-
#### 2.1. Simplified integration
87
-
The Orthographic API provides a helper module to easily update the camera and set screen and world view and projection. Integrate it in your own render script like this:
88
-
89
-
local render_helper = require "orthographic.render.helper"
NOTE: In order for this to work you need to make sure that the `Shared State` setting in the `Script` section of `game.project` is checked (defaults to checked)
113
-
114
-
#### 2.2. Manual integration
115
-
If you prefer to manually setup the integration you need to make sure to handle the `set_view_projection` message:
116
-
117
-
function update(self)
118
-
...
119
-
render.set_view(self.view)
120
-
render.set_projection(self.projection)
121
-
-- draw using the view and projection
122
-
...
123
-
end
124
-
125
-
function on_message(self, message_id, message, sender)
126
-
if message_id == hash("set_view_projection") then
127
-
self.camera_id = message.id
128
-
self.view = message.view
129
-
self.projection = message.projection
130
-
end
131
-
end
132
-
133
-
An alternative approach is to ignore the `set_view_projection` message and directly read the view and projection from the camera in the render script:
87
+
Get a list of active cameras and apply the camera viewport, view and projection before drawing:
for _,camera_id in ipairs(camera.get_cameras()) do
95
+
local viewport = camera.get_viewport(camera_id)
96
+
local view = camera.get_view(camera_id)
97
+
local projection = camera.get_projection(camera_id)
145
98
146
-
It is recommended to send the window width and height from the render script to the camera module. This is required if any of the projectors provided in `camera.lua` is used. It also allows custom projectors to get the current window size by calling `camera.get_window_size()`. Set the window size like this:
NOTE: In order for this to work you need to make sure that the `Shared State` setting in the `Script` section of `game.project` is checked (defaults to checked)
107
+
```
159
108
160
109
### Example render script
161
110
The `orthographic/render` folder contains a render script that does the above mentioned integration of the Orthographic Camera API. Use it as it is or copy it into your project and make whatever modifications that you need.
0 commit comments