Răsfoiți Sursa

Add Interaction/Pointing example;

bjorn 5 ani în urmă
părinte
comite
a1ee83e20b
2 a modificat fișierele cu 17 adăugiri și 0 ștergeri
  1. 16 0
      examples/Interaction/Pointing/main.lua
  2. 1 0
      examples/init.lua

+ 16 - 0
examples/Interaction/Pointing/main.lua

@@ -0,0 +1,16 @@
+function lovr.draw()
+  for i, hand in ipairs(lovr.headset.getHands()) do
+    local position = vec3(lovr.headset.getPosition(hand))
+    local direction = quat(lovr.headset.getOrientation(hand)):direction()
+
+    lovr.graphics.setColor(1, 1, 1)
+    lovr.graphics.sphere(position, .01)
+
+    if lovr.headset.isDown(hand, 'trigger') then
+      lovr.graphics.setColor(0, 1, 0)
+    else
+      lovr.graphics.setColor(1, 0, 0)
+    end
+    lovr.graphics.line(position, position + direction * 50)
+  end
+end

+ 1 - 0
examples/init.lua

@@ -4,6 +4,7 @@ return {
   'Intro/3D_Model',
   'Intro/360_Photo',
   'Intro/Tracked_Hands',
+  'Interaction/Pointing',
   'Custom_Mesh',
   'Animation',
   'Physics',