LDCad Animation puzzle


Animation puzzle
#1

.ldr   animationDemo.ldr (Size: 1.35 KB / Downloads: 1)
I'm using LDCad 1.6d, working on an animation, and have a baffling problem.  I can recreate the problem using Roland's original basic animation demo on YouTube:

I create the model and copy his LUA script. See aniDemoModel.png

As soon as I launch the LUA script, the Axle1 sub-model jumps to a new position on the first frame.  It also loses the 13° rotation that allowed its 14 tooth gear to mesh correctly with the Axle2 gear.  See aniDemoMove.png

Then using Roland's setRotate(angle, 1, 0, 0) the sub-model rotates around the wrong axis.  See aniDemoWrongAxis.png

Changing setRotate() to "angle, 0, 0, 1" fixes the wrong axis problem so the sub-model rotates around the correct axis, but I can't find any way to keep the sub-model from jumping to the new position and losing its 13° adjustment.

I've done other animations (which still work) and have never seen this problem.  Now it's happening to every new model I make!


Model:
[Image: aniDemoModel.png]

Move:
[Image: aniDemoMove.png]

Wrong axis:
[Image: aniDemoWrongAxis.png]

LDR file:
Code:
0 FILE main.ldr
0 Name: animationDemo
0 Author: LDCad
0 !LDCAD SCRIPT [source=animationDemo.lua]
1 14 0 0 0 1 0 0 0 1 0 0 0 1 3702.dat
1 14 50 0 -30 0 0 1 0 1 0 -1 0 0 3700.dat
1 14 -70 0 -30 0 0 1 0 1 0 -1 0 0 3700.dat
1 14 -10 0 -30 0 0 1 0 1 0 -1 0 0 3700.dat
1 14 0 0 -60 1 0 0 0 1 0 0 0 1 3702.dat
1 14 -70 -8 -30 0 0 1 0 1 0 -1 0 0 3710.dat
1 14 -10 -8 -30 0 0 1 0 1 0 -1 0 0 3710.dat
1 14 50 -8 -30 0 0 1 0 1 0 -1 0 0 3710.dat
1 14 50 24 -30 0 0 1 0 1 0 -1 0 0 3710.dat
1 14 -10 24 -30 0 0 1 0 1 0 -1 0 0 3710.dat
1 14 -70 24 -30 0 0 1 0 1 0 -1 0 0 3710.dat
1 16 -23 10 -30 0 0 1 0 1 0 -1 0 0 Axle2.ldr
1 14 50 -16 -30 0 0 1 0 1 0 -1 0 0 3023.dat
1 14 50 -40 -30 0 0 1 0 1 0 -1 0 0 3700.dat
1 16 60 -30 -30 1 0 0 0 0.99 0.139 0 -0.139 0.99 Axle3.ldr
1 16 -40 10 -80 -0.974 -0.225 0 -0.225 0.974 0 0 0 -1 Axle1.ldr
0 FILE Axle1.ldr
0 Author: LDraw
1 71 0 0 0 1 0 0 0 1 0 0 0 1 3736.dat
1 0 0 0 -50 0 0 -1 0 1 0 1 0 0 3706.dat
1 71 0 0 -67 -1 0 0 0 1 0 0 0 -1 4143.dat
1 71 0 0 -99.997 1 0.001 0 -0.001 1 0 0 0 1 3713.dat
1 71 -30 0 12 0 0.139 -0.99 0 0.99 0.139 1 0 0 3749.dat
0 FILE Axle2.ldr
0 Author: LDraw
1 71 0 0 0 1 0 0 0 1 0 0 0 1 4143.dat
1 0 0 0 53 0 0 1 0 1 0 -1 0 0 3706.dat
1 71 0 0 93 1 0 0 0 1 0 0 0 1 3647.dat
0 FILE Axle3.ldr
0 Author: LDraw
1 71 0 0 0 1 0 0 0 1 0 0 0 1 3749.dat
1 71 10 0 0 0 0 1 0 1 0 -1 0 0 3648.dat

LUA code:
Code:
function register()
  local ani=ldc.animation('animationDemo')
  ani:setLength(20)
  ani:setEvent('frame', 'onFrame')
end

function onFrame()
  local ani=ldc.animation.getCurrent()
  local mainSf=ldc.subfile()
  local ori=ldc.matrix()

  local angle=720*ani:getFrameTime()/ani:getLength()

  local ax1=mainSf:getRef('Axle1.ldr')
  ori:setRotate(angle, 0, 0, 1)
  ax1:setOri(ori)
end

register()
Reply
« Next Oldest | Next Newest »



Messages In This Thread
Animation puzzle - by Walt White - 2021-03-15, 0:15
RE: Animation puzzle - by Roland Melkert - 2021-03-15, 19:51

Forum Jump:


Users browsing this thread: 1 Guest(s)