Thoughts on animation scripting language


Re: Thoughts on animation scripting language
#13
Thanks for the info, but I think basic LUA will do for now.

At the moment I'm trying to set up a global approach for the animation handing, as I have zero experience in LUA and you seem to have some I would appreciate your thoughts regarding the below approach.

Consider the following (pseudo) LUA script

Code:
--global scope part of the script, will be ran upon file load.


--Setup custom group 'methods' for the ldcGroup pseudo class
--  this will determine the way we want to animate the groups
--  simple rotation over the z axis in this example.


function ldcGroup.initLink(grpName)

  result=ldcGroup.link(grpName)
  result.angle=0 --introduce obj var ??
  return result
end

function ldcGroup:getAngle()
  --does not really need a function, but maybe we want to do more in here in the future
  return self.angle
end

function ldcGroup:setAngle(newAngle)

  self.angle=newAngle
  local matrix=self.getCurrentMatrix()
  matrix.loadRotation(newAngle, 0.0, 0.0, 1.0);
end


--make global lua vars for groups we want to manipulate
gearA=ldcGroup.initLink('group1')
gearB=ldcGroup.initLink('group2')


--called by LDCad on 'reset' event
function init()

  gearA:setAngle(0.0);
  gearB:setAngle(0.0);  
end


--called by LDCad on 'frame change' event
function calcFrame()

  angleA=gearA.getAngle() + 15
  gearA:setAngle(angleA)

  angleB=angleA*-2
  gearB:setAngle(angleB)
end

The thing I want to achieve here is setting up a scripting environment which is extremely dynamic. I don't want to restrict users to animate in a certain way. So by using LUA they should be able to animate simple gears, but also e.g. walking mini figs etc.

In the long term you could setup a LUA library containing code for handling gears universally etc. This would also allow for third party written code handling e.g. extremely complex kinetics to be used by others.

So my question is: Does the above approach makes sense, or I'm I thinking in a wrong direction here or are there any LUA limitations spoiling this.

if anybody wants to actively help think out this environment please let me know.

[edit] made minor corrections to the script
Reply
« Next Oldest | Next Newest »



Messages In This Thread
Re: Thoughts on animation scripting language - by Roland Melkert - 2014-02-11, 0:48

Forum Jump:


Users browsing this thread: 1 Guest(s)