Browse Source

Update 2 Bone IK example;

bjorn 3 years ago
parent
commit
3b6198dca2
1 changed files with 10 additions and 9 deletions
  1. 10 9
      examples/Animation/2_Bone_IK/main.lua

+ 10 - 9
examples/Animation/2_Bone_IK/main.lua

@@ -54,23 +54,24 @@ function lovr.update(dt)
   end
   end
 end
 end
 
 
-function lovr.draw()
+function lovr.draw(pass)
 
 
   -- Draw the joints and the control point
   -- Draw the joints and the control point
-  lovr.graphics.setColor(0xff80ff)
-  lovr.graphics.sphere(root, pointSize / 2)
-  lovr.graphics.sphere(target, pointSize / 2)
-  lovr.graphics.setColor(0x80ffff)
-  lovr.graphics.sphere(control, pointSize / 2)
+  pass:setColor(0xff80ff)
+  pass:sphere(root, pointSize / 2)
+  pass:sphere(target, pointSize / 2)
+  pass:setColor(0x80ffff)
+  pass:sphere(control, pointSize / 2)
 
 
   -- Draw the hand
   -- Draw the hand
-  lovr.graphics.setColor(0xffffff)
+  pass:setColor(0xffffff)
   for _, hand in ipairs({ 'left', 'right' }) do
   for _, hand in ipairs({ 'left', 'right' }) do
     if lovr.headset.isTracked(hand) then
     if lovr.headset.isTracked(hand) then
-      lovr.graphics.cube('fill', mat4(lovr.headset.getPose(hand)):scale(.01))
+      pass:cube(mat4(lovr.headset.getPose(hand)):scale(.01))
     end
     end
   end
   end
 
 
   -- Draw a line from the root to the result from the IK solver, then to the target
   -- Draw a line from the root to the result from the IK solver, then to the target
-  lovr.graphics.line(root, solve(root, target, control, boneLengths), target)
+  print(solve(root, target, control, boneLengths))
+  pass:line(root, solve(root, target, control, boneLengths), target)
 end
 end