Documentation
¶
Overview ¶
The AR/VR server is the heart of our Advanced and Virtual Reality solution and handles all the processing.
Index ¶
- func AddInterface(intf XRInterface.Instance)
- func AddTracker(tracker XRTracker.Instance)
- func Advanced() class
- func CameraLockedToOrigin() bool
- func CenterOnHmd(rotation_mode RotationMode, keep_height bool)
- func ClearReferenceFrame()
- func FindInterface(name string) XRInterface.Instance
- func GetHmdTransform() Transform3D.BasisOrigin
- func GetInterface(idx int) XRInterface.Instance
- func GetInterfaceCount() int
- func GetInterfaces() []map[int]string
- func GetReferenceFrame() Transform3D.BasisOrigin
- func GetTracker(tracker_name string) XRTracker.Instance
- func GetTrackers(tracker_types int) map[interface{}]interface{}
- func OnInterfaceAdded(cb func(interface_name string), flags ...Signal.Flags)
- func OnInterfaceRemoved(cb func(interface_name string), flags ...Signal.Flags)
- func OnReferenceFrameChanged(cb func(), flags ...Signal.Flags)
- func OnTrackerAdded(cb func(tracker_name string, atype int), flags ...Signal.Flags)
- func OnTrackerRemoved(cb func(tracker_name string, atype int), flags ...Signal.Flags)
- func OnTrackerUpdated(cb func(tracker_name string, atype int), flags ...Signal.Flags)
- func PrimaryInterface() XRInterface.Instance
- func RemoveInterface(intf XRInterface.Instance)
- func RemoveTracker(tracker XRTracker.Instance)
- func SetCameraLockedToOrigin(value bool)
- func SetPrimaryInterface(value XRInterface.Instance)
- func SetWorldOrigin(value Transform3D.BasisOrigin)
- func SetWorldScale(value Float.X)
- func WorldOrigin() Transform3D.BasisOrigin
- func WorldScale() Float.X
- type Extension
- type ID
- type Instance
- type RotationMode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddTracker ¶
Registers a new XRTracker that tracks a physical object.
func Advanced ¶
func Advanced() class
Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.
func CameraLockedToOrigin ¶
func CameraLockedToOrigin() bool
If set to true, the scene will be rendered as if the camera is locked to the XROrigin3D.
Note: This doesn't provide a very comfortable experience for users. This setting exists for doing benchmarking or automated testing, where you want to control what is rendered via code.
func CenterOnHmd ¶
func CenterOnHmd(rotation_mode RotationMode, keep_height bool)
This is an important function to understand correctly. AR and VR platforms all handle positioning slightly differently.
For platforms that do not offer spatial tracking, our origin point (0, 0, 0) is the location of our HMD, but you have little control over the direction the player is facing in the real world.
For platforms that do offer spatial tracking, our origin point depends very much on the system. For OpenVR, our origin point is usually the center of the tracking space, on the ground. For other platforms, it's often the location of the tracking camera.
This method allows you to center your tracker on the location of the HMD. It will take the current location of the HMD and use that to adjust all your tracking data; in essence, realigning the real world to your player's current position in the game world.
For this method to produce usable results, tracking information must be available. This often takes a few frames after starting your game.
You should call this method after a few seconds have passed. For example, when the user requests a realignment of the display holding a designated button on a controller for a short period of time, or when implementing a teleport mechanism.
func ClearReferenceFrame ¶
func ClearReferenceFrame()
Clears the reference frame that was set by previous calls to CenterOnHmd.
func FindInterface ¶
func FindInterface(name string) XRInterface.Instance
Finds an interface by its '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.
func GetHmdTransform ¶
func GetHmdTransform() Transform3D.BasisOrigin
Returns the primary interface's transformation.
func GetInterface ¶
func GetInterface(idx int) XRInterface.Instance
Returns the interface registered at the given 'idx' index in the list of interfaces.
func GetInterfaceCount ¶
func GetInterfaceCount() int
Returns the number of interfaces currently registered with the AR/VR server. If your project supports multiple AR/VR platforms, you can look through the available interface, and either present the user with a selection or simply try to initialize each interface and use the first one that returns true.
func GetInterfaces ¶
Returns a list of available interfaces the ID and name of each interface.
func GetReferenceFrame ¶
func GetReferenceFrame() Transform3D.BasisOrigin
Returns the reference frame transform. Mostly used internally and exposed for GDExtension build interfaces.
func GetTracker ¶
Returns the positional tracker with the given 'tracker_name'.
func GetTrackers ¶
func GetTrackers(tracker_types int) map[interface{}]interface{}
Returns a dictionary of trackers for 'tracker_types'.
func OnInterfaceAdded ¶
Emitted when a new interface has been added.
func OnInterfaceRemoved ¶
Emitted when an interface is removed.
func OnReferenceFrameChanged ¶
Emitted when the reference frame transform changes.
func OnTrackerAdded ¶
Emitted when a new tracker has been added. If you don't use a fixed number of controllers or if you're using XRAnchor3Ds for an AR solution, it is important to react to this signal to add the appropriate XRController3D or XRAnchor3D nodes related to this new tracker.
func OnTrackerRemoved ¶
Emitted when a tracker is removed. You should remove any XRController3D or XRAnchor3D points if applicable. This is not mandatory, the nodes simply become inactive and will be made active again when a new tracker becomes available (i.e. a new controller is switched on that takes the place of the previous one).
func OnTrackerUpdated ¶
Emitted when an existing tracker has been updated. This can happen if the user switches controllers.
func PrimaryInterface ¶
func PrimaryInterface() XRInterface.Instance
The primary XRInterface currently bound to the XRServer.
func SetCameraLockedToOrigin ¶
func SetCameraLockedToOrigin(value bool)
SetCameraLockedToOrigin sets the property returned by [IsCameraLockedToOrigin].
func SetPrimaryInterface ¶
func SetPrimaryInterface(value XRInterface.Instance)
SetPrimaryInterface sets the property returned by [GetPrimaryInterface].
func SetWorldOrigin ¶
func SetWorldOrigin(value Transform3D.BasisOrigin)
SetWorldOrigin sets the property returned by [GetWorldOrigin].
func SetWorldScale ¶
SetWorldScale sets the property returned by [GetWorldScale].
func WorldOrigin ¶
func WorldOrigin() Transform3D.BasisOrigin
The current origin of our tracking space in the virtual world. This is used by the renderer to properly position the camera with new tracking data.
Note: This property is managed by the current XROrigin3D node. It is exposed for access from GDExtensions.
func WorldScale ¶
The scale of the game world compared to the real world. By default, most AR/VR platforms assume that 1 game unit corresponds to 1 real world meter.
Types ¶
type Extension ¶
Extension can be embedded in a new struct to create an extension of this class. T should be the type that is embedding this Extension
type ID ¶
ID is a typed object ID (reference) to an instance of this class, use it to store references to objects with unknown lifetimes, as an ID will not panic on use if the underlying object has been destroyed.
type RotationMode ¶
type RotationMode int //gd:XRServer.RotationMode
const ( // 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. ResetFullRotation RotationMode = 0 // Resets the orientation but keeps the tilt of the device. So if we're looking down, we keep looking down but heading will be reset. ResetButKeepTilt RotationMode = 1 // Does not reset the orientation of the HMD, only the position of the player gets centered. DontResetRotation RotationMode = 2 )