Motor animation


Motor animation
#1
Hi everyone,
I am wondering how is it possible to animate motor in LDCad?
I found great LDCAD animation on youtube :



I found Scripting API on Melkert website 

Here the model:
[Image: Motor_animation_view.png]

I am able to rotate the camshaft with this script:

Code:
--[[Sripted by Co for NEMOOZ]]
function register()

--****************************************************************************************
-- "Dissolve" script makes parts disappear progressively from the model ("Build" inverse)
--****************************************************************************************
    local ani=ldc.animation('Motor')

   --Set the length of the animation in seconds
   ani:setLength(10)
    
   ani:setEvent('start', 'motorStart')
   ani:setEvent('frame', 'motorFrame')
end

function motorStart()
     mainSf=ldc.subfile()
end

function motorFrame()

   local ani=ldc.animation.getCurrent()
   local ori=ldc.matrix()
 
   local angle=1800*ani:getFrameTime()/ani:getLength()
   
   local ax1=mainSf:getRef('axe_motor.ldr')
   ori:setRotate(angle, 1, 0, 0)
   ax1:setOri(ori)
end

register()


I searched the forums and found nothing on that particular subject.

Regards


Attached Files
.zip   Motor_animation.zip (Size: 921.15 KB / Downloads: 1)
Reply
RE: Motor animation
#2
(2018-07-29, 19:04)NEMOOZ Wrote: Hi everyone,
I am wondering how is it possible to animate motor in LDCad?

Yes but you might need to split the axle from the rest of the motor so you can rotate the axle part of the motor.

Although usually this is not needed as the motor axle is not visible due to the gears attached to it.

Once you got a group or reference for the moving section you can use it like in your example script by calling :ConfusedetOri

As for the documentation on creating animations this is currently mostly found trough the comments in the sample animations.

The api on the site only explains the meaning of the objects and functions available inside LDCad's lua environment.
Reply
RE: Motor animation
#3
Hi Roland,
first, i have to thank you for your amazing work about this soft ! 

I'm able to rotate axis motor but I can't animate Engine piston on cylinder:
  • make an axial movement of Engine Piston Round (2851.dat) into cylinder (2850.dat)
  • make an circular movement and not a rotation of valves (radius: 10,5 / center: 0,0,0)
I tried to use chain script to inspired me but without success, as you can see :
Code:
   local ani=ldc.animation.getCurrent()
   local angle=ani:getFrameTime()/ani:getLength()*360 --current angle of the wheel around the first chain point.

   local linkLen=10 --length of single chain segment.
   local pntRadius=10,5  --current radius of the first path point.
   local linkAngle=math.deg(math.tan(linkLen/pntRadius)) --angle difference on the wheel for a single link.
   local pntAngle=angle % linkAngle --frame's angle, this will create the illusion of a continues move around the whole chain.

   local chainSf=ldc.subfile('piston.ldr')
   local chainPnt=chainSf:getGroup('Group 1') --use a group as the current api can't set matrices for non references (is pending).

   --apply the angle this will trigger a path regeneration.
   local ori=ldc.matrix()
   ori:setRotate(pntAngle, 1, 0, 0)
   chainPnt:setOri(ori)



In fact if you can share me your 8860 script animation, i'll probably be able to make it !
Reply
RE: Motor animation
#4
(2018-08-07, 18:33)NEMOOZ Wrote: In fact if you can share me your 8860 script animation, i'll probably be able to make it !

The 8860 animation is included in the 1.6 releases.

An example of calculating the piston can also be found in the  technic.lua global script
Reply
« Next Oldest | Next Newest »



Forum Jump:


Users browsing this thread: 1 Guest(s)
Forum Jump:


Users browsing this thread: 1 Guest(s)