Welcome! Log In Create A New Profile

Advanced
Re: Thoughts on animation scripting language
avatarMarch 08, 2014 10:27AM
I've been playing around with lua for a couple of weeks now, and managed to set up a decent basic interface with the LDCad internals.

The below lua script is my current test script, everything in it actually works (compile/runtime wise) and I was wondering if it is somewhat 'understandable'. Or do people think it's to lowlevel?

--Initialization----
function register()

  local myAni=ldc.animation('Test animation 1');
  myAni:setFPS(25);
  myAni:setLength(2); --seconds
  myAni:setEvent('frameChange', 'frameChange');
  myAni:setEvent('play', 'play');

  myAni=ldc.animation('Test animation 2');
  myAni:setFPS(25);
  myAni:setLength(10); --seconds
  myAni:setEvent('frameChange', 'frameChange');
  myAni:setEvent('play', 'play');
end

--ldc.setPrint2Log(true);
--ldc.setPrint2Console(true);
print('apiVersion: ',ldc.getApiVersion());
register();



--Animation functions-----
function play()

  doAltTest=false; --in order to test the matrix class wrapper
  totRotCnt=2; --nr of rotations within the animation length

  --try to bind upto 3 groups
  grp1=ldc.group('Group 1');
  grp2=ldc.group('Group 2');
  grp3=ldc.group('Group 3');

  local ani=ldc.animation.getCurrent();
  print('fps: ', ani:getFPS(), ', frameCnt: ',ani:getFrameCnt());
end

function frameChange()

  local ani=ldc.animation.getCurrent();
  local angle1=ani:getFrameNr()/ani:getFrameCnt()*totRotCnt*360;

  if (grp2:isLinked() and grp3:isLinked()) then

    --full gear rotation test
    local angle2=-0.5*angle1+(360/16/2);
    local angle3=-0.2*angle2+(360/40/2);

    print('frame: ',ani:getFrameNr(),', angle1: ',angle1, ', angle2: ', angle2, ', angle3: ', angle3);

    local ori=ldc.matrix();
    ori:mulRotateAB(angle1, 0, 0, 1);
    grp1:setOri(ori);

    ori:setRotate(angle2, 0, 0, 1);
    grp2:setOri(ori);

    if doAltTest then

      --rel rotation test (excuse to play more with matrix and vector userdata)
      pos=ldc.vector(90, 40, 70);
      mat=ldc.matrix();
      mat:mulTranslateAB(pos);
      mat:mulAB(ori);
      pos:scale(-1);
      mat:mulTranslateAB(pos);
      grp3:setPosOri(mat);
    else
      ori:setRotate(angle3, 0, 0, 1);
      grp3:setOri(ori);
    end

  else

    --single rotating group test
    local ori=ldc.matrix();
    ori:mulRotateAB(angle1, 1, 0, 0);
    grp1:setOri(ori);

  end

end

I'm also thinking to add a matrixstack object, so you could use that similar to the OpenGL intermediate mode.

Anyhow if anyone has additional suggestions for api functions/functionality I'm open to suggestions.
SubjectAuthorViewsPosted
Thoughts on animation scripting language Roland Melkert467February 04, 2014 02:26PM
Re: Thoughts on animation scripting language Orion Pobursky156February 04, 2014 03:40PM
Re: Thoughts on animation scripting language Philippe Hurbain152February 05, 2014 12:35AM
Re: Thoughts on animation scripting language Roland Melkert155February 05, 2014 10:13AM
Re: Thoughts on animation scripting language Philippe Hurbain122February 05, 2014 11:12AM
Re: Thoughts on animation scripting language Roland Melkert131February 05, 2014 12:07PM
Re: Thoughts on animation scripting language Orion Pobursky153February 05, 2014 03:25PM
Re: Thoughts on animation scripting language Roland Melkert138February 05, 2014 05:34PM
Re: Thoughts on animation scripting language Orion Pobursky126February 05, 2014 06:10PM
Re: Thoughts on animation scripting language Ben Supnik158February 05, 2014 06:15PM
Re: Thoughts on animation scripting language Roland Melkert131February 06, 2014 10:38AM
Re: Thoughts on animation scripting language Ben Supnik164February 06, 2014 05:21PM
Re: Thoughts on animation scripting language Roland Melkert169February 10, 2014 04:48PM
Re: Thoughts on animation scripting language Stephen118February 11, 2014 08:33AM
Re: Thoughts on animation scripting language Roland Melkert131February 11, 2014 12:58PM
Re: Thoughts on animation scripting language Stephen128February 11, 2014 04:54PM
Re: Thoughts on animation scripting language Roland Melkert128February 12, 2014 09:27AM
Re: Thoughts on animation scripting language Tore Eriksson142February 17, 2014 01:02PM
Re: Thoughts on animation scripting language Roland Melkert134February 17, 2014 03:36PM
Re: Thoughts on animation scripting language Tore Eriksson144February 19, 2014 11:21AM
Re: Thoughts on animation scripting language Ignacio Fernandez Galvan128February 19, 2014 11:55AM
Re: Thoughts on animation scripting language Roland Melkert139February 19, 2014 01:42PM
Re: Thoughts on animation scripting language Sergio Reano139February 20, 2014 06:57AM
Re: Thoughts on animation scripting language Roland Melkert117February 20, 2014 01:05PM
Re: Thoughts on animation scripting language Roland Melkert146March 08, 2014 10:27AM
Re: Thoughts on animation scripting language Ignacio Fernandez Galvan133March 09, 2014 12:03AM
Re: Thoughts on animation scripting language Roland Melkert192March 09, 2014 01:33PM
Re: Thoughts on animation scripting language Michael Horvath95May 31, 2014 08:06PM
Re: Thoughts on animation scripting language Roland Melkert121June 01, 2014 12:48PM
Some progress (was re: Thoughts on ani...) Roland Melkert85July 06, 2014 07:24PM
Re: Some progress (was re: Thoughts on ani...) Michael Horvath80July 08, 2014 08:27AM
Re: Some progress (was re: Thoughts on ani...) Roland Melkert73July 08, 2014 12:45PM
Relative movement framework (was re: Thoughts on ani...) Roland Melkert70July 19, 2014 11:54AM
Preview of LDCad 1.4 animation scripting api (was re: Thoughts on ani...) Roland Melkert81September 17, 2014 03:55PM
Re: Preview of LDCad 1.4 animation scripting api (was re: Thoughts on ani...) Michael Heidemann73September 20, 2014 06:06AM
Re: Preview of LDCad 1.4 animation scripting api (was re: Thoughts on ani...) Roland Melkert83September 20, 2014 11:31AM
Re: Preview of LDCad 1.4 animation scripting api (was re: Thoughts on ani...) Michael Heidemann86September 20, 2014 02:27PM



Sorry, only registered users may post in this forum.

Click here to login