Skip to content
0.2.0-dev Download ZIP
348 lines ·16.1 KB Raw
1<?xml version="1.0" encoding="UTF-8" ?>
2<class name="Projection" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
3 <brief_description>
4 A 4×4 matrix for 3D projective transformations.
5 </brief_description>
6 <description>
7 A 4×4 matrix used for 3D projective transformations. It can represent transformations such as translation, rotation, scaling, shearing, and perspective division. It consists of four [Vector4] columns.
8 For purely linear transformations (translation, rotation, and scale), it is recommended to use [Transform3D], as it is more performant and requires less memory.
9 Used internally as [Camera3D]'s projection matrix.
10 [b]Note:[/b] In a boolean context, a projection will evaluate to [code]false[/code] if it's equal to [constant IDENTITY]. Otherwise, a projection will always evaluate to [code]true[/code].
11 </description>
12 <tutorials>
13 </tutorials>
14 <constructors>
15 <constructor name="Projection">
16 <return type="Projection" />
17 <description>
18 Constructs a default-initialized [Projection] identical to [constant IDENTITY].
19 [b]Note:[/b] In C#, this constructs a [Projection] identical to [constant ZERO].
20 </description>
21 </constructor>
22 <constructor name="Projection">
23 <return type="Projection" />
24 <param index="0" name="from" type="Projection" />
25 <description>
26 Constructs a [Projection] as a copy of the given [Projection].
27 </description>
28 </constructor>
29 <constructor name="Projection">
30 <return type="Projection" />
31 <param index="0" name="from" type="Transform3D" />
32 <description>
33 Constructs a Projection as a copy of the given [Transform3D].
34 </description>
35 </constructor>
36 <constructor name="Projection">
37 <return type="Projection" />
38 <param index="0" name="x_axis" type="Vector4" />
39 <param index="1" name="y_axis" type="Vector4" />
40 <param index="2" name="z_axis" type="Vector4" />
41 <param index="3" name="w_axis" type="Vector4" />
42 <description>
43 Constructs a Projection from four [Vector4] values (matrix columns).
44 </description>
45 </constructor>
46 </constructors>
47 <methods>
48 <method name="create_depth_correction" qualifiers="static">
49 <return type="Projection" />
50 <param index="0" name="flip_y" type="bool" />
51 <description>
52 Creates a new [Projection] that projects positions from a depth range of [code]-1[/code] to [code]1[/code] to one that ranges from [code]0[/code] to [code]1[/code], and flips the projected positions vertically, according to [param flip_y].
53 </description>
54 </method>
55 <method name="create_fit_aabb" qualifiers="static">
56 <return type="Projection" />
57 <param index="0" name="aabb" type="AABB" />
58 <description>
59 Creates a new [Projection] that scales a given projection to fit around a given [AABB] in projection space.
60 </description>
61 </method>
62 <method name="create_for_hmd" qualifiers="static">
63 <return type="Projection" />
64 <param index="0" name="eye" type="int" />
65 <param index="1" name="aspect" type="float" />
66 <param index="2" name="intraocular_dist" type="float" />
67 <param index="3" name="display_width" type="float" />
68 <param index="4" name="display_to_lens" type="float" />
69 <param index="5" name="oversample" type="float" />
70 <param index="6" name="z_near" type="float" />
71 <param index="7" name="z_far" type="float" />
72 <description>
73 Creates a new [Projection] for projecting positions onto a head-mounted display with the given X:Y aspect ratio, distance between eyes, display width, distance to lens, oversampling factor, and depth clipping planes.
74 [param eye] creates the projection for the left eye when set to 1, or the right eye when set to 2.
75 </description>
76 </method>
77 <method name="create_frustum" qualifiers="static">
78 <return type="Projection" />
79 <param index="0" name="left" type="float" />
80 <param index="1" name="right" type="float" />
81 <param index="2" name="bottom" type="float" />
82 <param index="3" name="top" type="float" />
83 <param index="4" name="z_near" type="float" />
84 <param index="5" name="z_far" type="float" />
85 <description>
86 Creates a new [Projection] that projects positions in a frustum with the given clipping planes.
87 </description>
88 </method>
89 <method name="create_frustum_aspect" qualifiers="static">
90 <return type="Projection" />
91 <param index="0" name="size" type="float" />
92 <param index="1" name="aspect" type="float" />
93 <param index="2" name="offset" type="Vector2" />
94 <param index="3" name="z_near" type="float" />
95 <param index="4" name="z_far" type="float" />
96 <param index="5" name="flip_fov" type="bool" default="false" />
97 <description>
98 Creates a new [Projection] that projects positions in a frustum with the given size, X:Y aspect ratio, offset, and clipping planes.
99 [param flip_fov] determines whether the projection's field of view is flipped over its diagonal.
100 </description>
101 </method>
102 <method name="create_light_atlas_rect" qualifiers="static">
103 <return type="Projection" />
104 <param index="0" name="rect" type="Rect2" />
105 <description>
106 Creates a new [Projection] that projects positions into the given [Rect2].
107 </description>
108 </method>
109 <method name="create_orthogonal" qualifiers="static">
110 <return type="Projection" />
111 <param index="0" name="left" type="float" />
112 <param index="1" name="right" type="float" />
113 <param index="2" name="bottom" type="float" />
114 <param index="3" name="top" type="float" />
115 <param index="4" name="z_near" type="float" />
116 <param index="5" name="z_far" type="float" />
117 <description>
118 Creates a new [Projection] that projects positions using an orthogonal projection with the given clipping planes.
119 </description>
120 </method>
121 <method name="create_orthogonal_aspect" qualifiers="static">
122 <return type="Projection" />
123 <param index="0" name="size" type="float" />
124 <param index="1" name="aspect" type="float" />
125 <param index="2" name="z_near" type="float" />
126 <param index="3" name="z_far" type="float" />
127 <param index="4" name="flip_fov" type="bool" default="false" />
128 <description>
129 Creates a new [Projection] that projects positions using an orthogonal projection with the given size, X:Y aspect ratio, and clipping planes.
130 [param flip_fov] determines whether the projection's field of view is flipped over its diagonal.
131 </description>
132 </method>
133 <method name="create_perspective" qualifiers="static">
134 <return type="Projection" />
135 <param index="0" name="fovy" type="float" />
136 <param index="1" name="aspect" type="float" />
137 <param index="2" name="z_near" type="float" />
138 <param index="3" name="z_far" type="float" />
139 <param index="4" name="flip_fov" type="bool" default="false" />
140 <description>
141 Creates a new [Projection] that projects positions using a perspective projection with the given Y-axis field of view (in degrees), X:Y aspect ratio, and clipping planes.
142 [param flip_fov] determines whether the projection's field of view is flipped over its diagonal.
143 </description>
144 </method>
145 <method name="create_perspective_hmd" qualifiers="static">
146 <return type="Projection" />
147 <param index="0" name="fovy" type="float" />
148 <param index="1" name="aspect" type="float" />
149 <param index="2" name="z_near" type="float" />
150 <param index="3" name="z_far" type="float" />
151 <param index="4" name="flip_fov" type="bool" />
152 <param index="5" name="eye" type="int" />
153 <param index="6" name="intraocular_dist" type="float" />
154 <param index="7" name="convergence_dist" type="float" />
155 <description>
156 Creates a new [Projection] that projects positions using a perspective projection with the given Y-axis field of view (in degrees), X:Y aspect ratio, and clipping distances. The projection is adjusted for a head-mounted display with the given distance between eyes and distance to a point that can be focused on.
157 [param eye] creates the projection for the left eye when set to 1, or the right eye when set to 2.
158 [param flip_fov] determines whether the projection's field of view is flipped over its diagonal.
159 </description>
160 </method>
161 <method name="determinant" qualifiers="const">
162 <return type="float" />
163 <description>
164 Returns a scalar value that is the signed factor by which areas are scaled by this matrix. If the sign is negative, the matrix flips the orientation of the area.
165 The determinant can be used to calculate the invertibility of a matrix or solve linear systems of equations involving the matrix, among other applications.
166 </description>
167 </method>
168 <method name="flipped_y" qualifiers="const">
169 <return type="Projection" />
170 <description>
171 Returns a copy of this [Projection] with the signs of the values of the Y column flipped.
172 </description>
173 </method>
174 <method name="get_aspect" qualifiers="const">
175 <return type="float" />
176 <description>
177 Returns the X:Y aspect ratio of this [Projection]'s viewport.
178 </description>
179 </method>
180 <method name="get_far_plane_half_extents" qualifiers="const">
181 <return type="Vector2" />
182 <description>
183 Returns the dimensions of the far clipping plane of the projection, divided by two.
184 </description>
185 </method>
186 <method name="get_fov" qualifiers="const">
187 <return type="float" />
188 <description>
189 Returns the horizontal field of view of the projection (in degrees).
190 </description>
191 </method>
192 <method name="get_fovy" qualifiers="static">
193 <return type="float" />
194 <param index="0" name="fovx" type="float" />
195 <param index="1" name="aspect" type="float" />
196 <description>
197 Returns the vertical field of view of the projection (in degrees) associated with the given horizontal field of view (in degrees) and aspect ratio.
198 [b]Note:[/b] Unlike most methods of [Projection], [param aspect] is expected to be 1 divided by the X:Y aspect ratio.
199 </description>
200 </method>
201 <method name="get_lod_multiplier" qualifiers="const">
202 <return type="float" />
203 <description>
204 Returns the factor by which the visible level of detail is scaled by this [Projection].
205 </description>
206 </method>
207 <method name="get_pixels_per_meter" qualifiers="const">
208 <return type="int" />
209 <param index="0" name="for_pixel_width" type="int" />
210 <description>
211 Returns [param for_pixel_width] divided by the viewport's width measured in meters on the near plane, after this [Projection] is applied.
212 </description>
213 </method>
214 <method name="get_projection_plane" qualifiers="const">
215 <return type="Plane" />
216 <param index="0" name="plane" type="int" />
217 <description>
218 Returns the clipping plane of this [Projection] whose index is given by [param plane].
219 [param plane] should be equal to one of [constant PLANE_NEAR], [constant PLANE_FAR], [constant PLANE_LEFT], [constant PLANE_TOP], [constant PLANE_RIGHT], or [constant PLANE_BOTTOM].
220 </description>
221 </method>
222 <method name="get_viewport_half_extents" qualifiers="const">
223 <return type="Vector2" />
224 <description>
225 Returns the dimensions of the viewport plane that this [Projection] projects positions onto, divided by two.
226 </description>
227 </method>
228 <method name="get_z_far" qualifiers="const">
229 <return type="float" />
230 <description>
231 Returns the distance for this [Projection] beyond which positions are clipped.
232 </description>
233 </method>
234 <method name="get_z_near" qualifiers="const">
235 <return type="float" />
236 <description>
237 Returns the distance for this [Projection] before which positions are clipped.
238 </description>
239 </method>
240 <method name="inverse" qualifiers="const">
241 <return type="Projection" />
242 <description>
243 Returns a [Projection] that performs the inverse of this [Projection]'s projective transformation.
244 </description>
245 </method>
246 <method name="is_orthogonal" qualifiers="const">
247 <return type="bool" />
248 <description>
249 Returns [code]true[/code] if this [Projection] performs an orthogonal projection.
250 </description>
251 </method>
252 <method name="jitter_offseted" qualifiers="const">
253 <return type="Projection" />
254 <param index="0" name="offset" type="Vector2" />
255 <description>
256 Returns a [Projection] with the X and Y values from the given [Vector2] added to the first and second values of the final column respectively.
257 </description>
258 </method>
259 <method name="perspective_znear_adjusted" qualifiers="const">
260 <return type="Projection" />
261 <param index="0" name="new_znear" type="float" />
262 <description>
263 Returns a [Projection] with the near clipping distance adjusted to be [param new_znear].
264 [b]Note:[/b] The original [Projection] must be a perspective projection.
265 </description>
266 </method>
267 </methods>
268 <members>
269 <member name="w" type="Vector4" setter="" getter="" default="Vector4(0, 0, 0, 1)">
270 The projection matrix's W vector (column 3). Equivalent to array index [code]3[/code].
271 </member>
272 <member name="x" type="Vector4" setter="" getter="" default="Vector4(1, 0, 0, 0)">
273 The projection matrix's X vector (column 0). Equivalent to array index [code]0[/code].
274 </member>
275 <member name="y" type="Vector4" setter="" getter="" default="Vector4(0, 1, 0, 0)">
276 The projection matrix's Y vector (column 1). Equivalent to array index [code]1[/code].
277 </member>
278 <member name="z" type="Vector4" setter="" getter="" default="Vector4(0, 0, 1, 0)">
279 The projection matrix's Z vector (column 2). Equivalent to array index [code]2[/code].
280 </member>
281 </members>
282 <constants>
283 <constant name="PLANE_NEAR" value="0" enum="Planes">
284 The index value of the projection's near clipping plane.
285 </constant>
286 <constant name="PLANE_FAR" value="1" enum="Planes">
287 The index value of the projection's far clipping plane.
288 </constant>
289 <constant name="PLANE_LEFT" value="2" enum="Planes">
290 The index value of the projection's left clipping plane.
291 </constant>
292 <constant name="PLANE_TOP" value="3" enum="Planes">
293 The index value of the projection's top clipping plane.
294 </constant>
295 <constant name="PLANE_RIGHT" value="4" enum="Planes">
296 The index value of the projection's right clipping plane.
297 </constant>
298 <constant name="PLANE_BOTTOM" value="5" enum="Planes">
299 The index value of the projection bottom clipping plane.
300 </constant>
301 <constant name="IDENTITY" value="Projection(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)">
302 A [Projection] with no transformation defined. When applied to other data structures, no transformation is performed.
303 </constant>
304 <constant name="ZERO" value="Projection(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)">
305 A [Projection] with all values initialized to 0. When applied to other data structures, they will be zeroed.
306 </constant>
307 </constants>
308 <operators>
309 <operator name="operator !=">
310 <return type="bool" />
311 <param index="0" name="right" type="Projection" />
312 <description>
313 Returns [code]true[/code] if the projections are not equal.
314 [b]Note:[/b] Due to floating-point precision errors, this may return [code]true[/code], even if the projections are virtually equal. An [code]is_equal_approx[/code] method may be added in a future version of Godot.
315 </description>
316 </operator>
317 <operator name="operator *">
318 <return type="Projection" />
319 <param index="0" name="right" type="Projection" />
320 <description>
321 Returns a [Projection] that applies the combined transformations of this [Projection] and [param right].
322 </description>
323 </operator>
324 <operator name="operator *">
325 <return type="Vector4" />
326 <param index="0" name="right" type="Vector4" />
327 <description>
328 Projects (multiplies) the given [Vector4] by this [Projection] matrix.
329 </description>
330 </operator>
331 <operator name="operator ==">
332 <return type="bool" />
333 <param index="0" name="right" type="Projection" />
334 <description>
335 Returns [code]true[/code] if the projections are equal.
336 [b]Note:[/b] Due to floating-point precision errors, this may return [code]false[/code], even if the projections are virtually equal. An [code]is_equal_approx[/code] method may be added in a future version of Godot.
337 </description>
338 </operator>
339 <operator name="operator []">
340 <return type="Vector4" />
341 <param index="0" name="index" type="int" />
342 <description>
343 Returns the column of the [Projection] with the given index.
344 Indices are in the following order: x, y, z, w.
345 </description>
346 </operator>
347 </operators>
348</class>