Last active
September 14, 2023 07:22
-
-
Save maluoi/fea5500f05037e1e70b4a1b077775c62 to your computer and use it in GitHub Desktop.
StereoKit "Reset to center"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using StereoKit; | |
SK.Initialize("SKRecenter"); | |
SK.Run(() => { | |
Mesh.Sphere.Draw(Material.Default, Matrix.TS(0, 0, -0.5f, 0.1f)); | |
if (Input.Key(Key.Space).IsJustActive()) { | |
// Get the head pose, and flatten the rotation to just the Y axis. | |
Pose head = Input.Head; | |
head.orientation.x = 0; | |
head.orientation.z = 0; | |
head.orientation.Normalize(); | |
Pose root = Renderer.CameraRoot.Pose; | |
Renderer.CameraRoot = Matrix.TR( | |
head.orientation.Inverse * (root.position-head.position), | |
root.orientation * head.orientation.Inverse | |
); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment