Sign in to follow this  
Followers 0
JopieK

Simple animations using LDD

16 posts in this topic

EDIT by regulator: I thought this was such an intersting idea, that I made a new topic out of it. Hope that was OK.

Using it for backgrounds for stop-motion video is an application I never considered, but it makes sense. It's easier to move a model on the computer over a small and properly defined distance than it is to do the same with a physical model. No doubt about it.

Especially the CMD-K (ctrl+K on windows?!) option is very handy... It is not very difficult to make animations in that way:

hotairballoon2.gif

Here you can see the scene it is used in: BlocksWorld (not yet finished and also not totally IE proof, but gives a good idea)

Share this post


Link to post
Share on other sites

It would be nice to be able to use animations like in Povray or Blender.

As far as I know, there are no programs to create a povray file out of a LXF.

The only way now is by using LDraw as converter. But then some bricks are missing.

Stop motion is nice, but take a lot of time. Complex movements are very difficult to create.

Share this post


Link to post
Share on other sites

Well, that is true, I was also hoping to be able to go from LDD to Blender or so. I noticed that LEGO has a special render application because the "Design By ME" box is definitely rendered using raytracing etc.

If one wants too look inside that virtual environment (not working in some IE version according to my girlfriend):

eurobricks / eurobricks is a valid username / login

I already came up with this idea quite some time ago. It will be a mix of an adventure (like monkey island), some contemporary internet games and a collaborative or complex learning environment. I will let students (and in future maybe also other teachers) develop part of it. Subjects like basic math, counting money, information retrieval and language learning will be among the subjects taught in the environment. Factors like fun and motivation will be a very important part. Hope you enjoy the basics already ;)

BlocksWorld

Share this post


Link to post
Share on other sites

A simple, crude idea for controlling/generating animations would be small program that produces animation frames. This is how far I've come in my reasoning:

Input would be: Model (as LXF-file) together with a list of the elements that should be manipulated and how (rotation/postion change direction). Could also be the camera for a simple case.

Algorithm:

1. Open/Parse LXF

2. Make small change in position of defined elements

3. Save file

4. Open in LDD, take screenshot

Loop

The LXF-format is pretty straight forward XML-based format. Bascially a typical post looks like this:

     <Part refID="0" designID="3700" materials="21">
       <Bone refID="0" transformation="1.0000001192092896,0.00076067680492997169,0,-0.00076067680492997169,1.0000001192092896,0,0,0,0.99999994039535522,0.00044196844100952148,0.95969939231872559,2.4890007972717285">
       </Bone>
     </Part>

On the first row is the DesignID (basically the mold) and then materials (i.e. color)

On the next row we have the postion/rotation matrix, 9+3 positions

Position 1 through 9: x, z, y axis orientation of element

Position 10 to 12: Position of brick in space relative origo

So basically, a program would have to perform some tranformation operations to the position values, output a LXF-file, open the file in LXF, use SendKeys to take a screenshot, and so on.

I've managed to figure out that for a simple brick being rotated around one of the axis, it's basically only some Sin(X) operations needed.

I'd love to give it a go myself, but I feel it's stretching my competence a bit too much :tongue:

If anyone feels like having a go, I have some more info that could be useful (and so does LDD Tech guru Bojan).

Share this post


Link to post
Share on other sites

Well, I would be very eager to hear it. Using your tips I should also make an application that can do this but I'm not too good a Mac programmer, maybe in Java then (or in C# under windows but I don't like windows).

Share this post


Link to post
Share on other sites

Well, I would be very eager to hear it. Using your tips I should also make an application that can do this but I'm not too good a Mac programmer, maybe in Java then (or in C# under windows but I don't like windows).

Perhaps I was unclear. With "more info" I meant that if there are some questions, I may have a few tips. However, the basic info how to get started is mentioned in the first post.

Can you perhaps start yourself to analyze and get familiar with the LXF-format, create some ideas, and do a simple LXF-creator, and then get back with specific questions?

May I propose Windows, since it's the most common platform.

Share this post


Link to post
Share on other sites

Well, first of all, lxf seems to be a binary format file. I can export the XML in LDD of course, but is there any info on how the lxf is built?!

Share this post


Link to post
Share on other sites

Well, first of all, lxf seems to be a binary format file. I can export the XML in LDD of course, but is there any info on how the lxf is built?!

A LXF-file is actually a simple zip-file. Use winzip to unzip and you'll find two files, a PNG thumbnail and the XML-file (text). The specification for the file structure can be found here.

Share this post


Link to post
Share on other sites

A LXF-file is actually a simple zip-file. Use winzip to unzip and you'll find two files, a PNG thumbnail and the XML-file (text). The specification for the file structure can be found here.

Well there are more elegant ways then to unzip the file. What we first need is then an unzip algorithm and an XML parser. The only thing is that I'm not too good at graphical programming, that would be the ideal solution. An alternative might be to 'hack' into the existing interface of LDD by using keyhooks.

Share this post


Link to post
Share on other sites

A simple, crude idea for controlling/generating animations would be small program that produces animation frames. This is how far I've come in my reasoning:

Input would be: Model (as LXF-file) together with a list of the elements that should be manipulated and how (rotation/postion change direction). Could also be the camera for a simple case.

Algorithm:

1. Open/Parse LXF

2. Make small change in position of defined elements

3. Save file

4. Open in LDD, take screenshot

Loop

The LXF-format is pretty straight forward XML-based format. Bascially a typical post looks like this:

     <Part refID="0" designID="3700" materials="21">
       <Bone refID="0" transformation="1.0000001192092896,0.00076067680492997169,0,-0.00076067680492997169,1.0000001192092896,0,0,0,0.99999994039535522,0.00044196844100952148,0.95969939231872559,2.4890007972717285">
       </Bone>
     </Part>

On the first row is the DesignID (basically the mold) and then materials (i.e. color)

On the next row we have the postion/rotation matrix, 9+3 positions

Position 1 through 9: x, z, y axis orientation of element

Position 10 to 12: Position of brick in space relative origo

So basically, a program would have to perform some tranformation operations to the position values, output a LXF-file, open the file in LXF, use SendKeys to take a screenshot, and so on.

I've managed to figure out that for a simple brick being rotated around one of the axis, it's basically only some Sin(X) operations needed.

I'd love to give it a go myself, but I feel it's stretching my competence a bit too much :tongue:

If anyone feels like having a go, I have some more info that could be useful (and so does LDD Tech guru Bojan).

This is possible, using en excel to calculate all the parameters and manual bring them to the file, step by step.

In povray you can define your formula and let the program do the calculations.

I have made a movie a few years ago, with a college, and several computer where rendering for days.

With 15 frames per second, you can make 1 second worth of animation in 1 hour or so in LDD. A 10 minute movie would take 600 hours ?!.

And there is no option for background, lightning and scenes with several movements together.

Share this post


Link to post
Share on other sites

This is possible, using en excel to calculate all the parameters and manual bring them to the file, step by step.

In povray you can define your formula and let the program do the calculations.

I have made a movie a few years ago, with a college, and several computer where rendering for days.

With 15 frames per second, you can make 1 second worth of animation in 1 hour or so in LDD. A 10 minute movie would take 600 hours ?!.

And there is no option for background, lightning and scenes with several movements together.

It should be automatic, otherwise its not going to be practical. And I was thinking of small animations scenes for fun - not entire movies :tongue:

The idea is that you build a model in LDD, then define which parts should rotate/move (could for example be a propeller), or wheels rotating, or something simple. Then just start the "animation" program, select LXF-file, click Go and you would get about 1 frames (i.e. PNGs) per 5 seconds. These could be made into an AVI or GIF. So it's only for smaller stuff/animations, maybe like 15 seconds long (which would take about 15 minutes).

Well there are more elegant ways then to unzip the file. What we first need is then an unzip algorithm and an XML parser. The only thing is that I'm not too good at graphical programming, that would be the ideal solution. An alternative might be to 'hack' into the existing interface of LDD by using keyhooks.

Why would you need graphical programming? This is only a matter of performing some translation matrix operations, output some XML-code (i.e. LXF)-file etc, open the file in LDD, take a screenshot (SendKeys) etc. It's a crude method, I know, but it's all for fun and for shorter animation.

Share this post


Link to post
Share on other sites

You don't need graphical programming, using windows messages would also be nice already, but still, it doesn't give you a lot of feedback of course. I'm not sue wether that is possible, but maybe it could even become a photoshop plugin. Problem with windows is that the applications are not normally scriptable. In Mac OS most applications are so no real programming (just Applescript) is required although I don't think this is usable with LDD for Mac (but didn't look into it so it is a wild guess). In fact looking at havok.com it might be that LDD is just an application built around the havok.com tools:

http://www.havok.com/index.php?page=general-information

Share this post


Link to post
Share on other sites

You don't need graphical programming, using windows messages would also be nice already, but still, it doesn't give you a lot of feedback of course. I'm not sue wether that is possible, but maybe it could even become a photoshop plugin. Problem with windows is that the applications are not normally scriptable. In Mac OS most applications are so no real programming (just Applescript) is required although I don't think this is usable with LDD for Mac (but didn't look into it so it is a wild guess). In fact looking at havok.com it might be that LDD is just an application built around the havok.com tools:

http://www.havok.com/index.php?page=general-information

Well, give it a try with whatever approach you want and get back here in the forum when you have come a bit further.

In the meantime, if anyone else feels like giving it a go, it'd be nice.

Share this post


Link to post
Share on other sites

What I see in the XML file is:


<Cameras>
   <Camera refID="1" fieldOfView="80" distance="207.7166595458984375" transformation="0.745532572269439697265625,0,-0.66646921634674072265625,-0.2326819896697998046875,0.93707573413848876953125,-0.2602851092815399169921875,0.624532043933868408203125,0.349126398563385009765625,0.698620378971099853515625,134.8406219482421875,62.021808624267578125,131.483428955078125"/>
 </Cameras>
 <Bricks cameraRef="1">
 ...

So apparently more cams can be used (the file format supports it at least), and you can assign a camera to groups of bricks. An other interesting find is this:

<Group transformation="1,0,0,0,1,0,0,0,1,0,0,0" pivot="0,0,0" ...

So we could also in theory make a tool that lets you really animate objects...

Share this post


Link to post
Share on other sites

What I see in the XML file is...

Exactly - You see what I mean now - The idea was very straight forward. Generate LXF-file, take screenshot (send keys strokes, Ctrl-K), tweak the transformations a bit, generate new LXF-file, take screenshot, and so on. I agree, it's not elegant, but it will work for simpler stuff. And I think it's the only way to go since LDD will not allow us access to the data geometries or an API, so the only way to do it is throught the application.

Share this post


Link to post
Share on other sites

So apparently more cams can be used (the file format supports it at least), and you can assign a camera to groups of bricks. An other interesting find is this:

<Group transformation="1,0,0,0,1,0,0,0,1,0,0,0" pivot="0,0,0" ...

So we could also in theory make a tool that lets you really animate objects...

Group transformation is really necessary to make something move.

Suppose you want a car take a turn, and you have to move all bricks one by one, along a curved path.

If this works, then we are one step closer to animation. Let's find out.

Tried it and failed.

Changed the numbers after pivot = No result

Changed the numbers after transformation = No result or error : file could not be loaded.

When you rotate or move a group in LDD the numbers doens't change.

Anyone ??

Edited by private_lego

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.