MobileVRInterface

package
v0.0.0-...-357ca8a Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2025 License: MIT Imports: 25 Imported by: 0

Documentation

Overview

This is a generic mobile VR implementation where you need to provide details about the phone and HMD used. It does not rely on any existing framework. This is the most basic interface we have. For the best effect, you need a mobile phone with a gyroscope and accelerometer.

Note that even though there is no positional tracking, the camera will assume the headset is at a height of 1.85 meters. You can change this by setting EyeHeight.

You can initialize this interface as follows:

package main

import (
	"graphics.gd/classdb/Node"
	"graphics.gd/classdb/Viewport"
	"graphics.gd/classdb/XRInterface"
	"graphics.gd/classdb/XRServer"
)

func ExampleMobileVR(node Node.Instance) {
	var XR = XRServer.FindInterface("Native mobile")
	if XR != XRInterface.Nil && XR.Initialize() {
		Viewport.Get(node).SetUseXr(true)
	}
}

Note: For Android, ProjectSettings "input_devices/sensors/enable_accelerometer", ProjectSettings "input_devices/sensors/enable_gravity", ProjectSettings "input_devices/sensors/enable_gyroscope" and ProjectSettings "input_devices/sensors/enable_magnetometer" must be enabled.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Advanced

type Advanced = class

Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.

type Any

type Any interface {
	gd.IsClass
	AsMobileVRInterface() Instance
}

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]) AsMobileVRInterface

func (self *Extension[T]) AsMobileVRInterface() Instance

func (*Extension[T]) AsObject

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

func (*Extension[T]) AsRefCounted

func (self *Extension[T]) AsRefCounted() [1]gd.RefCounted

func (*Extension[T]) AsXRInterface

func (self *Extension[T]) AsXRInterface() XRInterface.Instance

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.MobileVRInterface

Instance of the class with convieniently typed arguments and results.

var Nil Instance

Nil is a nil/null instance of the class. Equivalent to the zero value.

func New

func New() Instance

func (Instance) AsMobileVRInterface

func (self Instance) AsMobileVRInterface() Instance

func (Instance) AsObject

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

func (Instance) AsRefCounted

func (self Instance) AsRefCounted() [1]gd.RefCounted

func (Instance) AsXRInterface

func (self Instance) AsXRInterface() XRInterface.Instance

func (Instance) DisplayToLens

func (self Instance) DisplayToLens() Float.X

The distance between the display and the lenses inside of the device in centimeters.

func (Instance) DisplayWidth

func (self Instance) DisplayWidth() Float.X

The width of the display in centimeters.

func (Instance) EyeHeight

func (self Instance) EyeHeight() Float.X

The height at which the camera is placed in relation to the ground (i.e. XROrigin3D node).

func (Instance) ID

func (self Instance) ID() ID

func (Instance) Iod

func (self Instance) Iod() Float.X

The interocular distance, also known as the interpupillary distance. The distance between the pupils of the left and right eye.

func (Instance) K1

func (self Instance) K1() Float.X

The k1 lens factor is one of the two constants that define the strength of the lens used and directly influences the lens distortion effect.

func (Instance) K2

func (self Instance) K2() Float.X

The k2 lens factor, see k1.

func (Instance) OffsetRect

func (self Instance) OffsetRect() Rect2.PositionSize

Set the offset rect relative to the area being rendered. A length of 1 represents the whole rendering area on that axis.

func (Instance) Oversample

func (self Instance) Oversample() Float.X

The oversample setting. Because of the lens distortion we have to render our buffers at a higher resolution then the screen can natively handle. A value between 1.5 and 2.0 often provides good results but at the cost of performance.

func (Instance) SetDisplayToLens

func (self Instance) SetDisplayToLens(value Float.X)

SetDisplayToLens sets the property returned by [GetDisplayToLens].

func (Instance) SetDisplayWidth

func (self Instance) SetDisplayWidth(value Float.X)

SetDisplayWidth sets the property returned by [GetDisplayWidth].

func (Instance) SetEyeHeight

func (self Instance) SetEyeHeight(value Float.X)

SetEyeHeight sets the property returned by [GetEyeHeight].

func (Instance) SetIod

func (self Instance) SetIod(value Float.X)

SetIod sets the property returned by [GetIod].

func (Instance) SetK1

func (self Instance) SetK1(value Float.X)

SetK1 sets the property returned by [GetK1].

func (Instance) SetK2

func (self Instance) SetK2(value Float.X)

SetK2 sets the property returned by [GetK2].

func (*Instance) SetObject

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

func (Instance) SetOffsetRect

func (self Instance) SetOffsetRect(value Rect2.PositionSize)

SetOffsetRect sets the property returned by [GetOffsetRect].

func (Instance) SetOversample

func (self Instance) SetOversample(value Float.X)

SetOversample sets the property returned by [GetOversample].

func (Instance) SetVrsMinRadius

func (self Instance) SetVrsMinRadius(value Float.X)

SetVrsMinRadius sets the property returned by [GetVrsMinRadius].

func (Instance) SetVrsStrength

func (self Instance) SetVrsStrength(value Float.X)

SetVrsStrength sets the property returned by [GetVrsStrength].

func (Instance) Virtual

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

func (Instance) VrsMinRadius

func (self Instance) VrsMinRadius() Float.X

The minimum radius around the focal point where full quality is guaranteed if VRS is used as a percentage of screen size.

Note: Mobile and Forward+ renderers only. Requires Viewport.VrsMode to be set to [Viewport.VrsXr].

func (Instance) VrsStrength

func (self Instance) VrsStrength() Float.X

The strength used to calculate the VRS density map. The greater this value, the more noticeable VRS is. This improves performance at the cost of quality.

Note: Mobile and Forward+ renderers only. Requires Viewport.VrsMode to be set to [Viewport.VrsXr].

Jump to

Keyboard shortcuts

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