[LDCad] Animation puzzle - Printable Version +- LDraw.org Discussion Forums (https://forums.ldraw.org) +-- Forum: LDraw Programs (https://forums.ldraw.org/forum-7.html) +--- Forum: LDraw Editors and Viewers (https://forums.ldraw.org/forum-11.html) +--- Thread: [LDCad] Animation puzzle (/thread-24492.html) |
Animation puzzle - Walt White - 2021-03-15 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: Move: Wrong axis: LDR file: Code: 0 FILE main.ldr LUA code: Code: function register() RE: Animation puzzle - Roland Melkert - 2021-03-15 (2021-03-15, 0:15)Walt White Wrote: 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.This is how it supposed to work The setRotation function constructs a new rotation matrix (stored in the ori variable). You then assign this matrix to the type 1 reference line of 'Axle1.ldr' by doing this you will overwrite any existing rotation. If you want to keep the initial orientation you will need to buffer it in the start event and then multiply it with the one before assigning it to the reference. But it is much more practical to make sure the reference is orientated correctly while using the 1 0 0 0 1 0 0 0 1 rotation matrix. You can do that by rotating the parts in the submodel them selves. You can see this is also the case in my second animation demo video at 2:45 Hope this clears things up. |