One reason that I chose Openscad is its animation. As such, Kitwallace's
excellent approach
http://kitwallace.tumblr.com/post/85663417144/openscad-animation-view 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:
http://forum.openscad.org/file/n14011/whip.gif
$ 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-tp14011.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
Two more examples:
Oloid structure KitWallace talked about earlier
http://forum.openscad.org/Irregular-mesh-generated-td13765.html :
http://forum.openscad.org/file/n14012/oloid.gif
Scadx is the name of the lib that I've been working on :
http://forum.openscad.org/file/n14012/scadx_animate_test_crop.gif
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.
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
http://forum.openscad.org/Irregular-mesh-generated-td13765.html :
http://forum.openscad.org/file/n14012/oloid.gif
Scadx is the name of the lib that I've been working on :
http://forum.openscad.org/file/n14012/scadx_animate_test_crop.gif
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
Discuss@lists.openscad.org
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
@Neon22: I agree with you.
$ 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-tp14011p14023.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
The oloid with axes:
http://forum.openscad.org/file/n14029/oloid_w_axes_delay_30.gif
The code to run animation of my Oloid() object is as followed :
module run( t=$t ){
// Add timer
//
// The i,n,t in timertext are given through the command line
// parameter of runcad.py (see below):
// D="i=%(i)s;n=%(n)s;run(t=%(t)s);"
timertext= str( i+1,"/",n,", t=", floor(t*100)/100);
color("black")
translate( [0,0,5])
rotate([60,0,150]) // To make sure timertext follow the viewport, make
this
// rotation the same as the rotation portion of the
camera
// setting applied in the python script :
// camera=0,0,0,60,0,150,30
linear_extrude(0.1)
text( timertext
, size=0.4, halign="center");
/* Command line in shell using runscad.py:
$ python ../../runscad.py ./150912_Oloid.scad oloid.png n=60
D="i=%(i)s;n=%(n)s;run(t=%(t)s);" camera=0,0,0,60,0,150,30 imgsize=400,400
$ convert -delay 10 -loop 0 ./oloid000??.png
oloid_w_axes_delay_10.gif
$ convert -delay 20 -loop 0 ./oloid000??.png
oloid_w_axes_delay_20.gif
$ convert -delay 30 -loop 0 ./oloid000??.png
oloid_w_axes_delay_30.gif
*/
translate( [0,0,-0.75] ) // Make object a little lower to accommodate
for timertext
animateRot3d(t){
ColorAxes(["r",0.03,"len", 5]); // show axes
Oloid();
}
}
In which I used a python script, runscad.py
https://gist.github.com/runsun/995250a8002386ab9abc , which is designed
to run a scad file multiple times, with the ability of, among other things,
generating animation png files. automatically. See the example usage given
above in the code, or visit the gist page.
$ 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-tp14011p14029.html
Sent from the OpenSCAD mailing list archive at Nabble.com.