# 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
|

## Re: Animating gif with 3D rotation

 The oloid is a good example of a model that's hard to visualise in the three axis rotation. What do you think about adding a simple ancillary origin(3-axes) model to the scene so the user can keep track of the direction they are looking at ? Other models like a grid or even the global axes might also be visually helpful. On 9/27/2015 5:41 PM, runsun wrote: > 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: doctest , faces ( git ), offliner ( git ); > >   tips: hash( 1 , 2 ), sweep , var , lerp > > \$ -- Linux Mint 17.1 Rebecca x64  + OpenSCAD 2015.03.15/2015.04.01.nightly > > > > > -- > View this message in context: http://forum.openscad.org/Animating-gif-with-3D-rotation-tp14011p14012.html> Sent from the OpenSCAD mailing list archive at Nabble.com. > > _______________________________________________ > OpenSCAD mailing list > [hidden email] > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org> > > ----- > No virus found in this message. > Checked by AVG - www.avg.com > Version: 2015.0.6140 / Virus Database: 4419/10707 - Release Date: 09/26/15 > > _______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org