Documentation
¶
Overview ¶
Package XRServer provides methods for working with XRServer object instances.
Index ¶
- func AddInterface(intf [1]gdclass.XRInterface)
- func AddTracker(tracker [1]gdclass.XRTracker)
- func Advanced() class
- func CenterOnHmd(rotation_mode gdclass.XRServerRotationMode, keep_height bool)
- func ClearReferenceFrame()
- func FindInterface(name string) [1]gdclass.XRInterface
- func GetHmdTransform() Transform3D.BasisOrigin
- func GetInterface(idx int) [1]gdclass.XRInterface
- func GetInterfaceCount() int
- func GetInterfaces() []map[int]string
- func GetReferenceFrame() Transform3D.BasisOrigin
- func GetTracker(tracker_name string) [1]gdclass.XRTracker
- func GetTrackers(tracker_types int) map[interface{}]interface{}
- func OnInterfaceAdded(cb func(interface_name string))
- func OnInterfaceRemoved(cb func(interface_name string))
- func OnReferenceFrameChanged(cb func())
- func OnTrackerAdded(cb func(tracker_name string, atype int))
- func OnTrackerRemoved(cb func(tracker_name string, atype int))
- func OnTrackerUpdated(cb func(tracker_name string, atype int))
- func PrimaryInterface() [1]gdclass.XRInterface
- func RemoveInterface(intf [1]gdclass.XRInterface)
- func RemoveTracker(tracker [1]gdclass.XRTracker)
- func SetPrimaryInterface(value [1]gdclass.XRInterface)
- func SetWorldOrigin(value Transform3D.BasisOrigin)
- func SetWorldScale(value Float.X)
- func WorldOrigin() Transform3D.BasisOrigin
- func WorldScale() Float.X
- type RotationMode
- type TrackerType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddInterface ¶
func AddInterface(intf [1]gdclass.XRInterface)
Registers an [XRInterface] object.
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 CenterOnHmd ¶
func CenterOnHmd(rotation_mode gdclass.XRServerRotationMode, 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 [method center_on_hmd].
func FindInterface ¶
func FindInterface(name string) [1]gdclass.XRInterface
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.
func GetHmdTransform ¶
func GetHmdTransform() Transform3D.BasisOrigin
Returns the primary interface's transformation.
func GetInterface ¶
func GetInterface(idx int) [1]gdclass.XRInterface
Returns the interface registered at the given [param 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 [code]true[/code].
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 [param tracker_name].
func GetTrackers ¶
func GetTrackers(tracker_types int) map[interface{}]interface{}
Returns a dictionary of trackers for [param tracker_types].
func OnInterfaceAdded ¶
func OnInterfaceAdded(cb func(interface_name string))
func OnInterfaceRemoved ¶
func OnInterfaceRemoved(cb func(interface_name string))
func OnReferenceFrameChanged ¶
func OnReferenceFrameChanged(cb func())
func OnTrackerAdded ¶
func OnTrackerRemoved ¶
func OnTrackerUpdated ¶
func PrimaryInterface ¶
func PrimaryInterface() [1]gdclass.XRInterface
func RemoveInterface ¶
func RemoveInterface(intf [1]gdclass.XRInterface)
Removes this [param interface].
func SetPrimaryInterface ¶
func SetPrimaryInterface(value [1]gdclass.XRInterface)
func SetWorldOrigin ¶
func SetWorldOrigin(value Transform3D.BasisOrigin)
func SetWorldScale ¶
func WorldOrigin ¶
func WorldOrigin() Transform3D.BasisOrigin
func WorldScale ¶
Types ¶
type RotationMode ¶
type RotationMode = gdclass.XRServerRotationMode //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 )
type TrackerType ¶
type TrackerType = gdclass.XRServerTrackerType //gd:XRServer.TrackerType
const ( /*The tracker tracks the location of the players head. This is usually a location centered between the players eyes. Note that for handheld AR devices this can be the current location of the device.*/ TrackerHead TrackerType = 1 /*The tracker tracks the location of a controller.*/ TrackerController TrackerType = 2 /*The tracker tracks the location of a base station.*/ TrackerBasestation TrackerType = 4 /*The tracker tracks the location and size of an AR anchor.*/ TrackerAnchor TrackerType = 8 /*The tracker tracks the location and joints of a hand.*/ TrackerHand TrackerType = 16 /*The tracker tracks the location and joints of a body.*/ TrackerBody TrackerType = 32 /*The tracker tracks the expressions of a face.*/ TrackerFace TrackerType = 64 /*Used internally to filter trackers of any known type.*/ TrackerAnyKnown TrackerType = 127 /*Used internally if we haven't set the tracker type yet.*/ TrackerUnknown TrackerType = 128 /*Used internally to select all trackers.*/ TrackerAny TrackerType = 255 )