LDCad 1.4 Beta 2 (win+linux)


Re: LDCad 1.4 Beta 2 (win+linux)
#30
I've looked into this a bit more and it turns out it's not a group matrix bug, it's event related. Nesting is fun but all the internal matrix stuff introduced rounding problems in my early alpha's after a couple of frames so I implemented caching etc. Problem is the current version only initializes this cache when the start event is used in your script. This is why my examples all work fine Smile

Anyhow a workaround is very simple, just add a (dummy) start event handler. Here is your corrected script it should work on your existing model without problems now.

Code:
function register()
  local ani=ldc.animation('42020-B')
  ani:setLength(5)
  ani:setEvent('frame', 'onFrame')
  ani:setEvent('start', 'onStart')
end

function onStart()
  --grp ori bug prevention
end
  
function onFrame()
  local ani=ldc.animation.getCurrent()
  local mainSf=ldc.subfile()
  local ori=ldc.matrix()

  local angle=720*ani:getFrameTime()/ani:getLength()
  
  ax1=mainSf:getGroup('crank')
  ori:set(0, 0, 1, 0, 1, 0, -1, 0, 0) --group has non id main item
  ori:mulRotateAB(angle, 1, 0, 0)
  ax1:setOri(ori)
  
  local ax2=mainSf:getGroup('TopRotor')
  ori:set(0, 0, 1, -1, 0, 0, 0, -1, 0)  --group has non id main item
  ori:mulRotateAB(-angle, 0, 1, 0)
  ax2:setOri(ori)
  
  local ax3=mainSf:getGroup('TailRotor')
  ori:setRotate(angle, 1, 0, 0)
  ax3:setOri(ori)

end

register()

I also corrected for the non id placements. The next version won't need the workaround anymore.
Reply
« Next Oldest | Next Newest »



Messages In This Thread
Re: LDCad 1.4 Beta 2 (win+linux) - by Roland Melkert - 2014-10-22, 19:15

Forum Jump:


Users browsing this thread: 1 Guest(s)