MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / OpenVRDrawTarget

Class OpenVRDrawTarget

src/main/java/field/graphics/vr/OpenVRDrawTarget.kt:20–458  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18import org.lwjgl.openvr.VR.k_unTrackedDeviceIndex_Hmd
19import org.lwjgl.openvr.VR.ETrackedDeviceProperty_Prop_ModelNumber_String
20import org.lwjgl.openvr.VRSystem.*
21//import org.lwjgl.ovr.OVR
22import java.nio.ByteBuffer
23import java.nio.ByteOrder
24import java.nio.LongBuffer
25
26class OpenVRDrawTarget {
27
28 internal var warmUp = 0
29
30 @JvmField
31 var fbo: FBO? = null
32
33 var debug = true
34
35 val buttons = Buttons { b ->
36 val axes = listOf("button0_left", "button1_left", "button2_left", "button32_left", "button33_left", "axis0_left_x", "axis0_left_y", "axis1_left_x")
37 axes.forEach { b.addAxis(it) }
38 axes.forEach { b.addAxis(it.replace("left", "right")) }
39 }
40
41 var lockHead = false
42
43 val leftTouched = mutableSetOf<String>();
44 val rightTouched = mutableSetOf<String>();
45
46
47 var lastTD = 0L;
48
49 fun getPreviewTexture() = fbo
50
51
52 var previouslyVisible = false
53 var headOn = IdempotencyMap<Runnable>(Runnable::class.java)
54 var headOff = IdempotencyMap<Runnable>(Runnable::class.java)
55
56 fun init(w: Scene) {
57 w.attach(0, "__initopenvr__") { _: Int ->
58 actualInit(w)
59 false
60 }
61
62 w.attach(100, "__go_openvr__") { _: Int ->
63
64 if (fbo != null && true) stackPush().use {
65
66 GraphicsContext.checkError {
67 "before OpenVR FBO"
68 }
69
70 val poses = TrackedDevicePose.callocStack(VR.k_unMaxTrackedDeviceCount)
71 val gposes = TrackedDevicePose.callocStack(VR.k_unMaxTrackedDeviceCount) // no idea what this is?
72 VRCompositor.VRCompositor_WaitGetPoses(poses, gposes)
73
74// val a = ByteBuffer.allocateDirect(8).order(ByteOrder.nativeOrder()).asLongBuffer()
75// a.clear()
76// VRInput.VRInput_GetActionHandle("/user/hand/left/output/haptic", a)
77// VRInput.VRInput_TriggerHapticVibrationAction(a.get(0), 0f, 1f, 100f, 100f, 0)

Callers 1

SimpleOculusTargetClass · 0.85

Calls 6

IdempotencyMapClass · 0.85
Mat4Class · 0.85
addAxisMethod · 0.80
replaceMethod · 0.80
ButtonsClass · 0.70
forEachMethod · 0.45

Tested by

no test coverage detected