(2020-01-02, 20:39)Walt White Wrote: But I'm having a problem combining three movements into a single movement.
Having all three movements in the same animation presents a major problem (or shortcoming) of the animation scripting engine.
This because it calculates the state of ANY frame based on the current frame time.
This is usually done by a single control angle from which all others derive their state, but with this setup you have 3 different paths. To solve it you need to 'cache' the starting situation of every point in the animation where you switch from one to the other mechanical mode.
I had the same problem in the 8860 model concerning its gear box stuff.
As a result I wrote some helper 'classes' to make it a lot easier to handle.
To use those tools you need to switch the whole animation to the 'story telling' way of doing things though.
Below is a basic setup incorporating the continuous part of your animation.
Combined with the comments in the 8860 animation you might be able to add the rest yourself.
But if needed I could write something more complete this weekend.
Code:
genTools=require('genTools')
aniTools=require('aniTools')
function mainActor()
local mainSf=ldc.subfile()
local result=aniTools.actor()
--Joints and aniElms
result.inputGearsAngle=result:addAniElm(aniTools.aniElm(0))
result:addJoint(aniTools.angleJoint(mainSf:getRef('InputGears.ldr'), result.inputGearsAngle, ldc.vector(0, 1, 0)))
result.knobPairAngle=result:addAniElm(aniTools.aniElm(0))
result:addJoint(aniTools.angleJoint(mainSf:getRef('KnobPair.ldr'), result.knobPairAngle, ldc.vector(0,0, 1)))
result.endGearsAngle=result:addAniElm(aniTools.aniElm(0))
result:addJoint(aniTools.angleJoint(mainSf:getRef('EndGears.ldr'), result.endGearsAngle, ldc.vector(0,1,0)))
result.pivotDriverAngle=result:addAniElm(aniTools.aniElm(0))
result:addJoint(aniTools.angleJoint(mainSf:getRef('PivotDriver.ldr'), result.pivotDriverAngle, ldc.vector(0,1,0)))
return result
end
function onStart()
story=aniTools.story()
local actor=story:addActor(mainActor())
local seq=story:addSequence(aniTools.sequence())
--actions
seq:addAction(aniTools.speedAction(actor.inputGearsAngle, 0, nil, 45))
seq:addAction(aniTools.ratioDepAction(actor.knobPairAngle, 0, nil, actor.inputGearsAngle, -1))
seq:addAction(aniTools.ratioDepAction(actor.endGearsAngle, 0, nil, actor.knobPairAngle, -1))
seq:addAction(aniTools.ratioDepAction(actor.pivotDriverAngle, 0, nil, actor.endGearsAngle, -1))
--This helps the story table optimize some things it would otherwise do in the first onFrame apply call.
-- Keep it at the bottom of the onStart function.
story:prep()
end
function onFrame()
story:apply(ldc.animation():getFrameTime())
end
function register()
local ani=ldc.animation('My animation')
ani:setEvent('start', 'onStart')
ani:setEvent('frame', 'onFrame')
end
register()