Tuesday, March 8, 2016

Animating an OpenSCAD Figure

First, let's draw a cube:


Now, let's animate a 360 degree turntable view of the cube:


$t is filled in when the animation is in process.  You can see it in action like this:

    rotate([0,0,$t*360]) {

To enable the animation:

  • View/Animate to fill in the animation parameters
  • fill in FPS and Steps.  Good values are 24 and 240
  • don't fill in Time.  It is derived from the other parameters.  This is the value of $t in the code.
  • To grab the frames, click the Dump Pictures box.  This will create files frameXXXXX.png in the same directory as your SCAD file.  Note that this implies you've saved your file.

Once you've got the files, you can string them together into an animation.  There's a ton of ways of doing that; I use QuickTime Player 7 on my Mac:

  • File / New Player
  • File / Open Image Sequence - navigate to your folder, and select the first generated file (frame00000.png).  QuickTime will figure out the list of frames from there.
  • Frame Rate: 24
  • You should have a quicktime movie of your animation.  Save it out and you're good to go!

blogodex = {"toc" : "OpenSCAD", "idx" : ["animation", "turntable"]};

No comments: