Following the example:
Code: Select all
enableIk=function(enable)
if enable then
sim.setObjectMatrix(ikTarget,-1,sim.getObjectMatrix(ikTip,-1))
for i=1,#jointHandles,1 do
sim.setJointMode(jointHandles[i],sim.jointmode_ik,1)
end
sim.setExplicitHandling(ikGroup,0)
else
sim.setExplicitHandling(ikGroup,1)
for i=1,#jointHandles,1 do
sim.setJointMode(jointHandles[i],sim.jointmode_force,0)
end
end
end
function sysCall_init()
local simBase=sim.getObject('.')
local simTip=sim.getObject('./tip')
local simTarget=sim.getObject('./target')
ikEnv=simIK.createEnvironment()
ikGroup=simIK.createGroup(ikEnv)
simIK.setGroupCalculation(ikEnv,ikGroup,simIK.method_pseudo_inverse,0,6)
simIK.addElementFromScene(ikEnv,ikGroup,simBase,simTip,simTarget,simIK.constraint_pose)
end