Browse Source

getViewAngles; getViewPose;

bjorn 4 years ago
parent
commit
3619e4addc
2 changed files with 102 additions and 0 deletions
  1. 44 0
      api/lovr/headset/getViewAngles.lua
  2. 58 0
      api/lovr/headset/getViewPose.lua

+ 44 - 0
api/lovr/headset/getViewAngles.lua

@@ -0,0 +1,44 @@
+return {
+  tag = 'headset',
+  summary = 'Get the field of view angles of a view.',
+  description = [[
+    Returns the view angles of one of the headset views.
+
+    These can be used with `Mat4:fov` to create a projection matrix.
+
+    If tracking data is unavailable for the view or the index is invalid, `nil` is returned.
+  ]],
+  arguments = {
+    {
+      name = 'view',
+      type = 'number',
+      description = 'The view index.'
+    }
+  },
+  returns = {
+    {
+      name = 'left',
+      type = 'number',
+      description = 'The left view angle, in radians.'
+    },
+    {
+      name = 'right',
+      type = 'number',
+      description = 'The right view angle, in radians.'
+    },
+    {
+      name = 'top',
+      type = 'number',
+      description = 'The top view angle, in radians.'
+    },
+    {
+      name = 'bottom',
+      type = 'number',
+      description = 'The bottom view angle, in radians.'
+    }
+  },
+  related = {
+    'lovr.headset.getViewCount',
+    'lovr.headset.getViewPose'
+  }
+}

+ 58 - 0
api/lovr/headset/getViewPose.lua

@@ -0,0 +1,58 @@
+return {
+  tag = 'headset',
+  summary = 'Get the pose of one of the views.',
+  description = [[
+    Returns the pose of one of the headset views.  This info can be used to create view matrices or
+    do other eye-dependent calculations.
+
+    If tracking data is unavailable for the view or the index is invalid, `nil` is returned.
+  ]],
+  arguments = {
+    {
+      name = 'view',
+      type = 'number',
+      description = 'The view index.'
+    }
+  },
+  returns = {
+    {
+      name = 'x',
+      type = 'number',
+      description = 'The x coordinate of the view position, in meters.'
+    },
+    {
+      name = 'y',
+      type = 'number',
+      description = 'The y coordinate of the view position, in meters.'
+    },
+    {
+      name = 'z',
+      type = 'number',
+      description = 'The z coordinate of the view position, in meters.'
+    },
+    {
+      name = 'angle',
+      type = 'number',
+      description = 'The amount of rotation around the rotation axis, in radians.'
+    },
+    {
+      name = 'ax',
+      type = 'number',
+      description = 'The x component of the axis of rotation.'
+    },
+    {
+      name = 'ay',
+      type = 'number',
+      description = 'The y component of the axis of rotation.'
+    },
+    {
+      name = 'az',
+      type = 'number',
+      description = 'The z component of the axis of rotation.'
+    }
+  },
+  related = {
+    'lovr.headset.getViewCount',
+    'lovr.headset.getViewAngles'
+  }
+}