Chain/track animation in LDCad


Chain/track animation in LDCad
#1
Hi all,
I am wondering is it possible to animate chain/track in LDCad?
If yes, any help is highly appreciated.
I searched the forums and found nothing on that particular subject.
Regards.
Reply
RE: Chain/track animation in LDCad
#2
(2016-05-17, 13:04)Gret Rumpel Wrote: Hi all,
I am wondering is it possible to animate chain/track in LDCad?
If yes, any help is highly appreciated.
I searched the forums and found nothing on that particular subject.
Regards.

Yes but you will need to write a lua script for it. Its job would be to calculate the location and orientation of each chain link on a per frame basis.

The good news is you can probably do this for movement along just one link and then repeat that over and over an optical illusion would make it look like the links go all the way around.

My older LD4DStudio program has an example project animating a chain using scripts but that's not lua and a very simplified one.

In short it is a challenge but it should be a fun thing to figure out Smile
Reply
RE: Chain/track animation in LDCad
#3
(2016-05-17, 17:57)Roland Melkert Wrote:
(2016-05-17, 13:04)Gret Rumpel Wrote: Hi all,
I am wondering is it possible to animate chain/track in LDCad?
If yes, any help is highly appreciated.
I searched the forums and found nothing on that particular subject.
Regards.

Yes but you will need to write a lua script for it. Its job would be to calculate the location and orientation of each chain link on a per frame basis.

The good news is you can probably do this for movement along just one link and then repeat that over and over an optical illusion would make it look like the links go all the way around.

My older LD4DStudio program has an example project animating a chain using scripts but that's not lua and a very simplified one.

In short it is a challenge but it should be a fun thing to figure out Smile
Hi Roland,
Thank you for the fast reply. Actually I hoped for you to answer Smile
First of all congratulations for LDCad effort. It's a great piece of software.
To be more specific I'm working on a revised version of 42042 Crawler crane's track drive. The factory layout features jointly driven tracks thus it could go only straight forth and back.
I used LDCad to build a complete model of a real track drive which consists of two motors, transverse subtractor and two reductors  (one for each track).
I managed to animate all gears - from input drive shafts down to drive sprocket wheels on the tracks.
And here I stuck Huh
I'll try to post some pictures or even a clip if I manage to export it Wink
So I really hope you to be more specific on how to animate tracks.
How to get instance and manipulate a single track element?

Regards.

P.S.
To be honest I am new to LDraw and 3D modeling.
But in my opinion LDCad has a fast learning curve which helped me a lot.
Reply
RE: Chain/track animation in LDCad
#4
(2016-05-17, 20:55)Gret Rumpel Wrote: Hi Roland,
Thank you for the fast reply. Actually I hoped for you to answer Smile
First of all congratulations for LDCad effort. It's a great piece of software.
To be more specific I'm working on a revised version of 42042 Crawler crane's track drive. The factory layout features jointly driven tracks thus it could go only straight forth and back.
I used LDCad to build a complete model of a real track drive which consists of two motors, transverse subtractor and two reductors  (one for each track).
I managed to animate all gears - from input drive shafts down to drive sprocket wheels on the tracks.
And here I stuck Huh
I'll try to post some pictures or even a clip if I manage to export it Wink
So I really hope you to be more specific on how to animate tracks.
How to get instance and manipulate a single track element?

Regards.

P.S.
To be honest I am new to LDraw and 3D modeling.
But in my opinion LDCad has a fast learning curve which helped me a lot.

Thanks Gret.

If you used a template for the chain you could make it move fairly easy in the new 1.6 Alpha but a bug I discovered trying this out spoils it all it will work as expected in the next version though.

Here's the script. I used Philo's 42042.mpd as found here: http://omr.ldraw.org/set/42042-1/  It just needs an additional group for the first point of the track.

Code:
function onFrame()

 local ani=ldc.animation.getCurrent()
 local angle=ani:getFrameTime()/ani:getLength()*360 --current angle of the wheel around the first chain point.

 local linkLen=30 --length of single chain segment.
 local pntRadius=50  --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('42042 - technicChainTread38Closed-1.ldr')
 local chainPnt=chainSf:getGroup('pnt1') --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, 0, 0, 1)
 chainPnt:setOri(ori)
end

function register()
  local ani=ldc.animation('Chain')
  ani:setLength(10)
  ani:setEvent('frame', 'onFrame')
end

register()


The 1.5 way of doing it would involve setting up a manual chain (not generated). The easiest way of doing that would be to edit the mpd after using the template. Remove everything after "0 FILE"  up to "0 //Segments" to reduce the chain to a normal submodel.

After reloading the model you can access the individual links through a ldc.subfile object using the getRef('57518.dat', index) where index starts at 1 confirm the lua standard.

Once you got the links in an lua table you could do the individual math for each of them which won't be easy as you basically rewriting the generator.
Reply
RE: Chain/track animation in LDCad
#5
(2016-05-17, 22:11)Roland Melkert Wrote:
(2016-05-17, 20:55)Gret Rumpel Wrote: Hi Roland,
Thank you for the fast reply. Actually I hoped for you to answer Smile
First of all congratulations for LDCad effort. It's a great piece of software.
To be more specific I'm working on a revised version of 42042 Crawler crane's track drive. The factory layout features jointly driven tracks thus it could go only straight forth and back.
I used LDCad to build a complete model of a real track drive which consists of two motors, transverse subtractor and two reductors  (one for each track).
I managed to animate all gears - from input drive shafts down to drive sprocket wheels on the tracks.
And here I stuck Huh
I'll try to post some pictures or even a clip if I manage to export it Wink
So I really hope you to be more specific on how to animate tracks.
How to get instance and manipulate a single track element?

Regards.

P.S.
To be honest I am new to LDraw and 3D modeling.
But in my opinion LDCad has a fast learning curve which helped me a lot.

Thanks Gret.

If you used a template for the chain you could make it move fairly easy in the new 1.6 Alpha but a bug I discovered trying this out spoils it all it will work as expected in the next version though.

Here's the script. I used Philo's 42042.mpd as found here: http://omr.ldraw.org/set/42042-1/  It just needs an additional group for the first point of the track.

Code:
function onFrame()

 local ani=ldc.animation.getCurrent()
 local angle=ani:getFrameTime()/ani:getLength()*360 --current angle of the wheel around the first chain point.

 local linkLen=30 --length of single chain segment.
 local pntRadius=50  --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('42042 - technicChainTread38Closed-1.ldr')
 local chainPnt=chainSf:getGroup('pnt1') --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, 0, 0, 1)
 chainPnt:setOri(ori)
end

function register()
  local ani=ldc.animation('Chain')
  ani:setLength(10)
  ani:setEvent('frame', 'onFrame')
end

register()


The 1.5 way of doing it would involve setting up a manual chain (not generated). The easiest way of doing that would be to edit the mpd after using the template. Remove everything after "0 FILE"  up to "0 //Segments" to reduce the chain to a normal submodel.

After reloading the model you can access the individual links through a ldc.subfile object using the getRef('57518.dat', index) where index starts at 1 confirm the lua standard.

Once you got the links in an lua table you could do the individual math for each of them which won't be easy as you basically rewriting the generator.

Hi,
I used template to generate the tracks and v1.5 way of doing things seams to be very inefficient.
It's pretty clear how to achieve the goal in v1.6 so I will wait for its stable release.
It sounds very easy and native as well that when you move first point of the template the whole of it will be regenerated.
When do you think a stable v1.6 will be available?
Thank you for the assistance.
Regards.
Reply
RE: Chain/track animation in LDCad
#6
(2016-05-18, 20:34)Gret Rumpel Wrote: Hi,
I used template to generate the tracks and v1.5 way of doing things seams to be very inefficient.
It's pretty clear how to achieve the goal in v1.6 so I will wait for its stable release.
It sounds very easy and native as well that when you move first point of the template the whole of it will be regenerated.
When do you think a stable v1.6 will be available?
Thank you for the assistance.
Regards.

It might be inefficient but in some cases, even in 1.6, it might be the only way to get a 'perfect' animation as you have total control over the links.

The first 1.6 beta will take some time as I currently don't have much time for the project. So you might want to try the next alpha first.
Reply
« Next Oldest | Next Newest »



Forum Jump:


Users browsing this thread: 1 Guest(s)