# Animating gif with 3D rotation

5 messages
Open this post in threaded view
|

## Animating gif with 3D rotation

 One reason that I chose Openscad is its animation. As such, Kitwallace's excellent approach of animation gif and avi is a treasure to me. It allows users to create a presentation of an object rotating from 0 to 180 and from 180 back to 0 about the z axis. But sometimes an object is best understood by viewing it in all directions. So I took it a little further to create this simple function:     module animateRot3d( t=\$t, loc=[0,0,0] ){             tt = 540*t;         rot = t< 1/3 ? [ tt,0,0 ]               : t<2/3 ? [ 180, tt-180,0 ]               : [180,180,tt];                 translate(loc)         rotate(rot)             translate( -1*loc) children();     } when operated on shapes under the animation mode, it executes rotations of 0~180 in 3 directions:     animateRot3d(t=\$t)     MyObj();   You can check the "[ ] Dump Pictures" option under the animation mode to save the output (*.png), and use KitWallace's approach to make gif or avi. The following is my first try: \$ Runsun Pan, PhD \$ libs: scadx, doctest, faces(git), offline doc(git), runscad.py(2,git), editor of choice: CudaText ( OpenSCAD lexer); \$ Tips; \$ Snippets
Open this post in threaded view
|

## Re: Animating gif with 3D rotation

 Two more examples: Oloid structure KitWallace talked about earlier: Scadx is the name of the lib that I've been working on : Here is the code to generate the *.png files: \$fn=100; module run(t=\$t){     echo("t = ", t);         // Add timer     color("black")     linear_extrude(0.1)         translate( [0,20,0])         text(str("t=", floor(t*100)/100), size=2, valign="center",halign="center");     animateRot3d(t)     translate( [0,0,-1] )     linear_extrude(2, scale=0.95)     text("Scadx", valign="center",halign="center"); }   run(); \$ Runsun Pan, PhD \$ libs: scadx, doctest, faces(git), offline doc(git), runscad.py(2,git), editor of choice: CudaText ( OpenSCAD lexer); \$ Tips; \$ Snippets
Open this post in threaded view
|