Thoughts on animation scripting language

Re: Thoughts on animation scripting language
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?

function register()

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

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

print('apiVersion: ',ldc.getApiVersion());

--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'Group 1');'Group 2');'Group 3');

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

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);

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

    if doAltTest then

      --rel rotation test (excuse to play more with matrix and vector userdata)
      pos=ldc.vector(90, 40, 70);
      ori:setRotate(angle3, 0, 0, 1);


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



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.
« Next Oldest | Next Newest »

Messages In This Thread
Re: Thoughts on animation scripting language - by Roland Melkert - 2014-03-08, 18:27

Forum Jump:

Users browsing this thread: 1 Guest(s)