XRServer

package
v0.0.0-...-fa94a0d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 18, 2025 License: MIT Imports: 27 Imported by: 0

Documentation

Overview

The AR/VR server is the heart of our Advanced and Virtual Reality solution and handles all the processing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddInterface

func AddInterface(intf XRInterface.Instance)

Registers an XRInterface object.

func AddTracker

func AddTracker(tracker XRTracker.Instance)

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

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

func GetInterfaces() []map[int]string

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

func GetTracker(tracker_name string) XRTracker.Instance

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

func OnInterfaceAdded(cb func(interface_name string), flags ...Signal.Flags)

func OnInterfaceRemoved

func OnInterfaceRemoved(cb func(interface_name string), flags ...Signal.Flags)

func OnReferenceFrameChanged

func OnReferenceFrameChanged(cb func(), flags ...Signal.Flags)

func OnTrackerAdded

func OnTrackerAdded(cb func(tracker_name string, atype int), flags ...Signal.Flags)

func OnTrackerRemoved

func OnTrackerRemoved(cb func(tracker_name string, atype int), flags ...Signal.Flags)

func OnTrackerUpdated

func OnTrackerUpdated(cb func(tracker_name string, atype int), flags ...Signal.Flags)

func PrimaryInterface

func PrimaryInterface() XRInterface.Instance

func RemoveInterface

func RemoveInterface(intf XRInterface.Instance)

Removes this 'interface'.

func RemoveTracker

func RemoveTracker(tracker XRTracker.Instance)

Removes this 'tracker'.

func SetCameraLockedToOrigin

func SetCameraLockedToOrigin(value bool)

func SetPrimaryInterface

func SetPrimaryInterface(value XRInterface.Instance)

func SetWorldOrigin

func SetWorldOrigin(value Transform3D.BasisOrigin)

func SetWorldScale

func SetWorldScale(value Float.X)

func WorldOrigin

func WorldOrigin() Transform3D.BasisOrigin

func WorldScale

func WorldScale() Float.X

Types

type Extension

type Extension[T gdclass.Interface] struct{ gdclass.Extension[T, Instance] }

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

func (*Extension[T]) AsObject

func (self *Extension[T]) AsObject() [1]gd.Object

type ID

type ID Object.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.

func (ID) Instance

func (id ID) Instance() (Instance, bool)

type Instance

type Instance [1]gdclass.XRServer

Instance of the class with convieniently typed arguments and results.

func (Instance) AsObject

func (self Instance) AsObject() [1]gd.Object

func (Instance) ID

func (self Instance) ID() ID

func (*Instance) SetObject

func (self *Instance) SetObject(obj [1]gd.Object) bool

func (Instance) Virtual

func (self Instance) Virtual(name string) reflect.Value

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
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL