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
// 4. Intersect far and left planes with top planes from both eyes, save the point with highest y as top_left.
192
+
Vector3 top_left, other;
193
+
ERR_FAIL_COND_V_MSG(
194
+
!far_plane.intersect_3(planes[0][Projection::PLANE_LEFT], planes[0][Projection::PLANE_TOP], &top_left), proj, "Can't determine left camera far/left/top vector");
195
+
ERR_FAIL_COND_V_MSG(
196
+
!far_plane.intersect_3(planes[1][Projection::PLANE_LEFT], planes[1][Projection::PLANE_TOP], &other), proj, "Can't determine right camera far/left/top vector");
197
+
if (top_left.y < other.y) {
198
+
top_left = other;
199
+
}
200
+
201
+
// 5. Intersect far and left planes with bottom planes from both eyes, save the point with lowest y as bottom_left.
202
+
Vector3 bottom_left;
203
+
ERR_FAIL_COND_V_MSG(
204
+
!far_plane.intersect_3(planes[0][Projection::PLANE_LEFT], planes[0][Projection::PLANE_BOTTOM], &bottom_left), proj, "Can't determine left camera far/left/bottom vector");
205
+
ERR_FAIL_COND_V_MSG(
206
+
!far_plane.intersect_3(planes[1][Projection::PLANE_LEFT], planes[1][Projection::PLANE_BOTTOM], &other), proj, "Can't determine right camera far/left/bottom vector");
207
+
if (other.y < bottom_left.y) {
208
+
bottom_left = other;
209
+
}
210
+
211
+
// 6. Intersect far and right planes with top planes from both eyes, save the point with highest y as top_right.
212
+
Vector3 top_right;
213
+
ERR_FAIL_COND_V_MSG(
214
+
!far_plane.intersect_3(planes[0][Projection::PLANE_RIGHT], planes[0][Projection::PLANE_TOP], &top_right), proj, "Can't determine left camera far/right/top vector");
215
+
ERR_FAIL_COND_V_MSG(
216
+
!far_plane.intersect_3(planes[1][Projection::PLANE_RIGHT], planes[1][Projection::PLANE_TOP], &other), proj, "Can't determine right camera far/right/top vector");
217
+
if (top_right.y < other.y) {
218
+
top_right = other;
219
+
}
220
+
221
+
// 7. Intersect far and right planes with bottom planes from both eyes, save the point with lowest y as bottom_right.
222
+
Vector3 bottom_right;
223
+
ERR_FAIL_COND_V_MSG(
224
+
!far_plane.intersect_3(planes[0][Projection::PLANE_RIGHT], planes[0][Projection::PLANE_BOTTOM], &bottom_right), proj, "Can't determine left camera far/right/bottom vector");
225
+
ERR_FAIL_COND_V_MSG(
226
+
!far_plane.intersect_3(planes[1][Projection::PLANE_RIGHT], planes[1][Projection::PLANE_BOTTOM], &other), proj, "Can't determine right camera far/right/bottom vector");
227
+
if (other.y < bottom_right.y) {
228
+
bottom_right = other;
229
+
}
230
+
231
+
// 8. Create top plane with these points: camera origin, top_left, top_right
232
+
Plane top(origin, top_left, top_right);
233
+
234
+
// 9. Create bottom plane with these points: camera origin, bottom_left, bottom_right
// 10. Intersect near plane with bottm/left planes, to obtain min_vec then top/right to obtain max_vec
241
+
Vector3 min_vec;
242
+
ERR_FAIL_COND_V_MSG(
243
+
!near_plane.intersect_3(bottom, planes[0][Projection::PLANE_LEFT], &min_vec), proj, "Can't determine left camera near/left/bottom vector");
244
+
ERR_FAIL_COND_V_MSG(
245
+
!near_plane.intersect_3(bottom, planes[1][Projection::PLANE_LEFT], &other), proj, "Can't determine right camera near/left/bottom vector");
246
+
if (other.x < min_vec.x) {
247
+
min_vec = other;
248
+
}
249
+
250
+
Vector3 max_vec;
251
+
ERR_FAIL_COND_V_MSG(
252
+
!near_plane.intersect_3(top, planes[0][Projection::PLANE_RIGHT], &max_vec), proj, "Can't determine left camera near/right/top vector");
253
+
ERR_FAIL_COND_V_MSG(
254
+
!near_plane.intersect_3(top, planes[1][Projection::PLANE_RIGHT], &other), proj, "Can't determine right camera near/right/top vector");
255
+
if (max_vec.x < other.x) {
256
+
max_vec = other;
257
+
}
258
+
259
+
// 11. get x and y from these to obtain left, top, right bottom for the frustum. Get the distance from near plane to camera origin to obtain near, and the distance from the far plane to the camera origin to obtain far.
260
+
float z_near = -near_plane.distance_to(origin);
261
+
float z_far = -far_plane.distance_to(origin);
262
+
263
+
// Safeguard our near and far values
264
+
z_near = MAX(z_near, origin.z + 0.01);
265
+
z_far = MAX(z_far, z_near + 1.0);
266
+
267
+
// 12. Use this to build the combined camera matrix.
Sets camera to use any set of [param projections]. You can specify one projection for each view set on the viewport. If the views are offset (e.g. ocular distance) and/or skewed, this data can be provided through [param offsets].
Copy file name to clipboardExpand all lines: doc/classes/XRCamera3D.xml
+4-1Lines changed: 4 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -6,12 +6,15 @@
6
6
<description>
7
7
A camera node which automatically positions itself based on XR tracking data.
8
8
In contrast to [XRController3D], the render thread has access to more up-to-date tracking data, and the location of the [XRCamera3D] node can lag a few milliseconds behind what is used for rendering.
9
-
[b]Note:[/b] If [member Viewport.use_xr] is [code]true[/code], most of the camera properties are overridden by the active [XRInterface]. The only properties that can be trusted are the near and far planes.
The name of the camera tracker we're bound to. Which trackers are available is not known during design time.
17
+
The default tracker refers to the HMD position of the main player. Consult the documentation of the [XRInterface] for any additional trackers. There may be additional tracked headsets for multiplayer systems or a tracker may be available for a physical camera in a mixed reality scenario.
Copy file name to clipboardExpand all lines: doc/classes/XRInterface.xml
+19-2Lines changed: 19 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -17,6 +17,23 @@
17
17
If this is an AR interface that requires displaying a camera feed as the background, this method returns the feed ID in the [CameraServer] for this interface.
Gets an array of offset transforms for each view for tracker [param tracker_name]. [param tracker_name] must refer to an [XRPositionalTracker] used as a camera. Returns an empty array if this interface is not responsible for this tracker.
Gets an array of projection matrices for each view for tracker [param tracker_name]. [param tracker_name] must refer to an [XRPositionalTracker] used as a camera. Returns an empty array if this interface is not responsible for this tracker.
35
+
</description>
36
+
</method>
20
37
<methodname="get_capabilities"qualifiers="const">
21
38
<returntype="int" />
22
39
<description>
@@ -35,7 +52,7 @@
35
52
Returns an array of vectors that represent the physical play area mapped to the virtual space around the [XROrigin3D] point. The points form a convex polygon that can be used to react to or visualize the play area. This returns an empty array if this feature is not supported or if the information is not yet available.
If supported, returns the status of our tracking. This will allow you to provide feedback to the user whether there are issues with positional tracking.
Copy file name to clipboardExpand all lines: doc/classes/XRInterfaceExtension.xml
+19-2Lines changed: 19 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -28,6 +28,23 @@
28
28
Returns the camera feed ID for the [CameraFeed] registered with the [CameraServer] that should be presented as the background on an AR capable device (if applicable).
Gets an array of offset transforms for each view for tracker [param tracker_name]. [param tracker_name] must refer to an [XRPositionalTracker] used as a camera. Returns an empty array if this interface is not responsible for this tracker.
Gets an array of projection matrices for each view for tracker [param tracker_name]. [param tracker_name] must refer to an [XRPositionalTracker] used as a camera. Returns an empty array if this interface is not responsible for this tracker.
Copy file name to clipboardExpand all lines: doc/classes/XRServer.xml
+24-2Lines changed: 24 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -50,6 +50,25 @@
50
50
Finds an interface by its [param name]. For example, if your project uses capabilities of an AR/VR platform, you can find the interface for that platform by name and initialize it.
Gets an array of offset transforms for each view for tracker [param tracker_name]. [param tracker_name] must refer to an [XRPositionalTracker] used as a camera.
58
+
Will check our primary interface first, then check each active interface. Returns empty if no interfaces manage this tracker.
Gets an array of projection matrices for each view for tracker [param tracker_name]. [param tracker_name] must refer to an [XRPositionalTracker] used as a camera.
69
+
Will check our primary interface first, then check each active interface. Returns empty if no interfaces manage this tracker.
The tracker tracks the location of the player's head. This is usually a location centered between the player's eyes. Note that for handheld AR devices this can be the current location of the device.
The tracker tracks the location of the player's head. This is usually a location centered between the player's eyes. Note that for handheld AR devices this can be the current location of the device.
Fully reset the orientation of the HMD. Regardless of what direction the user is looking to in the real world. The user will look dead ahead in the virtual world.
0 commit comments