From 999a4b381f32f27ba6b8a99cba1caffef4f1f948 Mon Sep 17 00:00:00 2001 From: Jan Tiemann Date: Mon, 12 Jul 2021 13:04:13 +0200 Subject: [PATCH] OpenVRHMD.kt: Fix getPosition --- src/main/kotlin/graphics/scenery/controls/OpenVRHMD.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/graphics/scenery/controls/OpenVRHMD.kt b/src/main/kotlin/graphics/scenery/controls/OpenVRHMD.kt index d15ff4297..433b0eb6c 100644 --- a/src/main/kotlin/graphics/scenery/controls/OpenVRHMD.kt +++ b/src/main/kotlin/graphics/scenery/controls/OpenVRHMD.kt @@ -426,7 +426,9 @@ open class OpenVRHMD(val seated: Boolean = false, val useCompositor: Boolean = t */ override fun getPosition(): Vector3f { val m = getPose() - return Vector3f(-1.0f * m.get(0, 3), -1.0f * m.get(1, 3), -1.0f * m.get(2, 3)) + val d = Vector3f(-1.0f * m.get(3, 0), -1.0f * m.get(3, 1), -1.0f * m.get(3, 2)) + // the position is already rotated by the orientation therefore we need to inverse that the get the absolute position + return d.rotate(getOrientation().conjugate()) } /**