discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Efficient generation of many PNG images from command line?

MM
Michael Marx
Sat, Jan 23, 2021 5:06 AM

-----Original Message-----
From: Discuss [mailto:discuss-bounces@lists.openscad.org] On Behalf Of Vigardo
Sent: Sat, 23 Jan 2021 04:43

I think that tp3 already advised about this on a previous post:

Me: "2) Will the persistent cache feature persist across multiple separate
calls to OpenSCAD command-lined or just the GUI version?"
tp3: "It's supposed to work with both (but command line will need explicit
setup options, not using the config that is available in GUI)."

What are these "explicit setup options"?

The persistent cache feature is a work-in-progress. Not in nightly builds yet.

--
This email has been checked for viruses by AVG.
https://www.avg.com

> -----Original Message----- > From: Discuss [mailto:discuss-bounces@lists.openscad.org] On Behalf Of Vigardo > Sent: Sat, 23 Jan 2021 04:43 > > I think that *tp3* already advised about this on a previous post: > > Me: "2) Will the persistent cache feature persist across multiple separate > calls to OpenSCAD command-lined or just the GUI version?" > tp3: "It's supposed to work with both (but command line will need explicit > setup options, not using the config that is available in GUI)." > > What are these "explicit setup options"? > The persistent cache feature is a work-in-progress. Not in nightly builds yet. -- This email has been checked for viruses by AVG. https://www.avg.com
V
Vigardo
Sat, Jan 23, 2021 12:13 PM

MichaelAtOz' wrote

The persistent cache feature is a work-in-progress. Not in nightly builds
yet.

Ok, I´ll wait. But, the cache behavior is going to be the exactly the same
in command-line and GUI, am I right? Thanks!

Whosawhatsis wrote

Putting --camera in your command line will override $vpr, $vpt and $vpd.

This totally explains why the "Viewport rotation" method did not update the
view :-) Thanks!

JordanBrown wrote

You probably want to stick with the latter.  It's doing what you want to
do:  moving the camera.

Ok, I´ll do!

JordanBrown wrote

But of course if your animation consists of flying your camera around,
it will get really boring if you don't have the camera move when $t
changes.

Sure, but this is how a turn table is expected to behave :-)

JordanBrown wrote

I'm not sure exactly what problem you're seeing, but note that --camera is
the same as setting $vpt, $vpr, and $vpd.
Don't have $vpt/$vpr/$vpd depend on $t.  Or is there something more
complicated that I'm missing?

Yes, I´ll try to explain it better here, sorry :-)

When I generate the snapshots from GUI there is no problem, the turntable
works as expected (both ways, rotating either the object itself or the
camera).

// Viewport rotation
$vpr=[90,0,-$t*180];
echo("vpr=",$vpr,"vpt=",$vpt,"vpd=",$vpd);
render() mymodel();

The problem arises when I run the same script from the command-line:

#> OpenSCAD-2021.01-RC6-x86_64.AppImage --animate 36 ViewRender.scad

Then, to obtain the same expected behavior I have to explicitly set the view
port distance ($vpd) to some manually adjusted distance, e.g. $vpd=5. If I
do not add this value to the code, then the views appear empty since the
$vpd seems to be set to some very high distance (i.e. 500) by default:

ECHO: "vpr=", [90, 0, 0], "vpt=", [0, 0, 0], "vpd=", 500

Conversely, the same $vpd-less script works perfect from GUI. It seems that
if the GUI is not used, then the $vpd is not appropriately set. May this be
a bug? Any workaround?

Note that for my turntable application the camera must be rotating while
maintaining a constant distance to the object. The $vpd must be maintained
from first to last frame of the animation, but at the same time must be set
automatically to fit the whole object. If the view is fitted to the object
for each frame, this will cause an annoying "zoom in & out" effect. This
latter effect happens if using the "Explicit rotation" approach form
command-line but not from GUI.

--
Sent from: http://forum.openscad.org/

MichaelAtOz' wrote > The persistent cache feature is a work-in-progress. Not in nightly builds > yet. Ok, I´ll wait. But, the cache behavior is going to be the exactly the same in command-line and GUI, am I right? Thanks! Whosawhatsis wrote > Putting --camera in your command line will override $vpr, $vpt and $vpd. This totally explains why the "Viewport rotation" method did not update the view :-) Thanks! JordanBrown wrote > You probably want to stick with the latter.  It's doing what you want to > do:  moving the camera. Ok, I´ll do! JordanBrown wrote > But of course if your animation consists of flying your camera around, > it will get really boring if you don't have the camera move when $t > changes. Sure, but this is how a turn table is expected to behave :-) JordanBrown wrote > I'm not sure exactly what problem you're seeing, but note that --camera is > the same as setting $vpt, $vpr, and $vpd. > Don't have $vpt/$vpr/$vpd depend on $t.  Or is there something more > complicated that I'm missing? Yes, I´ll try to explain it better here, sorry :-) When I generate the snapshots from GUI there is no problem, the turntable works as expected (both ways, rotating either the object itself or the camera). // Viewport rotation $vpr=[90,0,-$t*180]; echo("vpr=",$vpr,"vpt=",$vpt,"vpd=",$vpd); render() mymodel(); The problem arises when I run the same script from the command-line: #> OpenSCAD-2021.01-RC6-x86_64.AppImage --animate 36 ViewRender.scad Then, to obtain the same expected behavior I have to explicitly set the view port distance ($vpd) to some manually adjusted distance, e.g. $vpd=5. If I do not add this value to the code, then the views appear empty since the $vpd seems to be set to some very high distance (i.e. 500) by default: ECHO: "vpr=", [90, 0, 0], "vpt=", [0, 0, 0], "vpd=", 500 Conversely, the same $vpd-less script works perfect from GUI. It seems that if the GUI is not used, then the $vpd is not appropriately set. May this be a bug? Any workaround? Note that for my turntable application the camera must be rotating while maintaining a constant distance to the object. The $vpd must be maintained from first to last frame of the animation, but at the same time must be set automatically to fit the whole object. If the view is fitted to the object for each frame, this will cause an annoying "zoom in & out" effect. This latter effect happens if using the "Explicit rotation" approach form command-line but not from GUI. -- Sent from: http://forum.openscad.org/
MM
Michael Marx
Sat, Jan 23, 2021 12:33 PM

-----Original Message-----
From: Discuss [mailto:discuss-bounces@lists.openscad.org] On Behalf Of Vigardo
Sent: Sat, 23 Jan 2021 23:13
To: discuss@lists.openscad.org
Subject: Re: [OpenSCAD] Efficient generation of many PNG images from command line?

MichaelAtOz' wrote

The persistent cache feature is a work-in-progress. Not in nightly builds
yet.

Ok, I´ll wait. But, the cache behavior is going to be the exactly the same
in command-line and GUI, am I right? Thanks!

The persistent cache feature is a work-in-progress.

--
This email has been checked for viruses by AVG.
https://www.avg.com

> -----Original Message----- > From: Discuss [mailto:discuss-bounces@lists.openscad.org] On Behalf Of Vigardo > Sent: Sat, 23 Jan 2021 23:13 > To: discuss@lists.openscad.org > Subject: Re: [OpenSCAD] Efficient generation of many PNG images from command line? > > MichaelAtOz' wrote > > The persistent cache feature is a work-in-progress. Not in nightly builds > > yet. > > Ok, I´ll wait. But, the cache behavior is going to be the exactly the same > in command-line and GUI, am I right? Thanks! > The persistent cache feature is a work-in-progress. -- This email has been checked for viruses by AVG. https://www.avg.com
NH
nop head
Sat, Jan 23, 2021 12:44 PM

$vpd seems to be set to some very high distance (i.e. 500) by default:

Yes that is the default for the GUI as well. You have to click on ViewAll
to set it appropriately for your object. On the command line --viewall does
the same.

On Sat, 23 Jan 2021 at 12:34, Michael Marx michael@marx.id.au wrote:

-----Original Message-----
From: Discuss [mailto:discuss-bounces@lists.openscad.org] On Behalf Of

Vigardo

Sent: Sat, 23 Jan 2021 23:13
To: discuss@lists.openscad.org
Subject: Re: [OpenSCAD] Efficient generation of many PNG images from

command line?

MichaelAtOz' wrote

The persistent cache feature is a work-in-progress. Not in nightly

builds

yet.

Ok, I´ll wait. But, the cache behavior is going to be the exactly the

same

in command-line and GUI, am I right? Thanks!

The persistent cache feature is a work-in-progress.

--
This email has been checked for viruses by AVG.
https://www.avg.com


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

> $vpd seems to be set to some very high distance (i.e. 500) by default: Yes that is the default for the GUI as well. You have to click on ViewAll to set it appropriately for your object. On the command line --viewall does the same. On Sat, 23 Jan 2021 at 12:34, Michael Marx <michael@marx.id.au> wrote: > > > > -----Original Message----- > > From: Discuss [mailto:discuss-bounces@lists.openscad.org] On Behalf Of > Vigardo > > Sent: Sat, 23 Jan 2021 23:13 > > To: discuss@lists.openscad.org > > Subject: Re: [OpenSCAD] Efficient generation of many PNG images from > command line? > > > > MichaelAtOz' wrote > > > The persistent cache feature is a work-in-progress. Not in nightly > builds > > > yet. > > > > Ok, I´ll wait. But, the cache behavior is going to be the exactly the > same > > in command-line and GUI, am I right? Thanks! > > > > > The persistent cache feature is a work-in-progress. > > > -- > This email has been checked for viruses by AVG. > https://www.avg.com > > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
V
Vigardo
Sat, Jan 23, 2021 3:13 PM

nophead wrote

Yes that is the default for the GUI as well. You have to click on ViewAll
to set it appropriately for your object. On the command line --viewall
does
the same.

That is what I though. I tried --viewall option in some of my past tests but
since it did not work I removed it from the command line options (to avoid
adding noise to the discussion :-)... but I was wrong...this may be the key
point.

The --viewall option does not work from command line, at least not for
OpenSCAD-2021.01-RC5-x86_64 and OpenSCAD-2021.01-RC6-x86_64 versions:

#> OpenSCAD-2021.01-RC6-x86_64.AppImage --viewall --animate 36
ViewRender.scad

As you can check, the $vpd remains 500, with or without --viewall option.

SCRIPT CODE:
$vpr=[90,0,-$t*180];
echo("vpr=",$vpr,"vpt=",$vpt,"vpd=",$vpd);
render() mymodel();

OUTPUT:
ECHO: "vpr=", [90, 0, 0], "vpt=", [0, 0, 0], "vpd=", 500

Would this be a bug related to --viewall behavior in command-line tool or am
I doing something wrong?

--
Sent from: http://forum.openscad.org/

nophead wrote > Yes that is the default for the GUI as well. You have to click on ViewAll > to set it appropriately for your object. On the command line --viewall > does > the same. That is what I though. I tried --viewall option in some of my past tests but since it did not work I removed it from the command line options (to avoid adding noise to the discussion :-)... but I was wrong...this may be the key point. The --viewall option does not work from command line, at least not for OpenSCAD-2021.01-RC5-x86_64 and OpenSCAD-2021.01-RC6-x86_64 versions: #> OpenSCAD-2021.01-RC6-x86_64.AppImage --viewall --animate 36 ViewRender.scad As you can check, the $vpd remains 500, with or without --viewall option. SCRIPT CODE: $vpr=[90,0,-$t*180]; echo("vpr=",$vpr,"vpt=",$vpt,"vpd=",$vpd); render() mymodel(); OUTPUT: ECHO: "vpr=", [90, 0, 0], "vpt=", [0, 0, 0], "vpd=", 500 Would this be a bug related to --viewall behavior in command-line tool or am I doing something wrong? -- Sent from: http://forum.openscad.org/
TP
Torsten Paul
Sat, Jan 23, 2021 3:22 PM

As you can check, the $vpd remains 500, with or
without --viewall option.

And generates this warning with --viewall which explains
what's happening:

WARNING: Viewall and autocenter disabled in favor of $vp*

ciao,
Torsten.

> As you can check, the $vpd remains 500, with or > without --viewall option. And generates this warning with --viewall which explains what's happening: WARNING: Viewall and autocenter disabled in favor of $vp* ciao, Torsten.
JB
Jordan Brown
Sat, Jan 23, 2021 3:39 PM

On 1/23/2021 4:13 AM, Vigardo wrote:

JordanBrown wrote

But of course if your animation consists of flying your camera around,
it will get really boring if you don't have the camera move when $t
changes.

Sure, but this is how a turn table is expected to behave :-)

So, as you noted, you can either rotate the model, or move the camera.

If you want to simulate a turntable, you'd rotate the model while
keeping the camera in the same place.  Note that the axes stay fixed.

rotate($t*360) cube(10, center=true);

From the CLI, you could have --camera set whatever viewpoint you

wanted.  You probably don't want --viewall, because for a non-trivial
model it'll probably zoom in and out to make the various views of the
model fit into the viewport.  (Or, alternatively, you could have the
model set $vpr/$vpt/$vpd and lock the viewpoint in place.)

If you want to simulate flying the camera around the model, you'd move
the camera while leaving the model in the same place.  Note that the
axes move, because the camera is moving relative to them.

$vpr=[80,0,360*$t];
$vpd=140;
$vpt=[0,0,0];
cube(10, center=true);

Here you would not want to use --camera or --viewall from the CLI,
because the model file is completely controlling the camera.

What values would you want for $vpt/$vpr/$vpd or, alternatively, for
--camera?  Probably simplest is to first not set up the camera, use
the interactive controls to put the camera where you want it, and then
read the values off the "Viewport" line at the bottom of the window. 
You can also use the "Copy viewport ..." options from the Edit menu.

On 1/23/2021 4:13 AM, Vigardo wrote: > JordanBrown wrote >> But of course if your animation consists of flying your camera around, >> it will get really boring if you don't have the camera move when $t >> changes. > Sure, but this is how a turn table is expected to behave :-) So, as you noted, you can either rotate the model, or move the camera. If you want to simulate a turntable, you'd rotate the model while keeping the camera in the same place.  Note that the axes stay fixed. rotate($t*360) cube(10, center=true); >From the CLI, you could have --camera set whatever viewpoint you wanted.  You probably don't want --viewall, because for a non-trivial model it'll probably zoom in and out to make the various views of the model fit into the viewport.  (Or, alternatively, you could have the model set $vpr/$vpt/$vpd and lock the viewpoint in place.) If you want to simulate flying the camera around the model, you'd move the camera while leaving the model in the same place.  Note that the axes move, because the camera is moving relative to them. $vpr=[80,0,360*$t]; $vpd=140; $vpt=[0,0,0]; cube(10, center=true); Here you would not want to use --camera or --viewall from the CLI, because the model file is completely controlling the camera. What values would you want for $vpt/$vpr/$vpd or, alternatively, for --camera?  Probably simplest is to first *not* set up the camera, use the interactive controls to put the camera where you want it, and then read the values off the "Viewport" line at the bottom of the window.  You can also use the "Copy viewport ..." options from the Edit menu.
V
Vigardo
Sat, Jan 23, 2021 4:32 PM

tp3 wrote

And generates this warning with --viewall which explains what's happening:
WARNING: Viewall and autocenter disabled in favor of $vp*

You´re absolutely right. I miss that warning, I´m sorry!

JordanBrown wrote

From the CLI, you could have --camera set whatever viewpoint you
wanted.  You probably don't want --viewall, because for a non-trivial
model it'll probably zoom in and out to make the various views of the
model fit into the viewport.  (Or, alternatively, you could have the
model set $vpr/$vpt/$vpd and lock the viewpoint in place.)

This is exactly what I´m trying to. However, if I keep the camera fix and
rotate the model, the zoom in and out issue happens. Both using or not
--viewall option. Conversely, if I keep the model fix but rotate the camera
around it, then I have to manually set the $vpd variable... which is not
possible (see next)

JordanBrown wrote

What values would you want for $vpt/$vpr/$vpd or, alternatively, for
--camera?  Probably simplest is to first not set up the camera, use
the interactive controls to put the camera where you want it, and then
read the values off the "Viewport" line at the bottom of the window. 
You can also use the "Copy viewport ..." options from the Edit menu.

Unfortunately, your approach is not possible for my application. Let me tell
you more. I´m developing some web server that is intended to run OpenSCAD
(server side), so automation and CLI are mandatory. Sorry, perhaps I should
have told this before.

I already figured out a quite dirty workaround to create the turntable... I
used an awk script that parsed the an OpenSCAD generated STL file to dump
its boundary box and from it I can roughly estimate $vpd... But I don´t like
this solution since it slows down even more my workflow. The way OpenSCAD
defines the appropriate camera zoom using the "View All" seems much better.

How would I tell OpenSCAD (from CLI) to use and keep fixed the camera "View
All" parameters?

Perhaps adding a "--viewall_zero" option to initialize all view parameters
at $t=0 (i.e. for the first frame), and then let the user choose which $vp*
parameters to update via code?

Any better alternative?

--
Sent from: http://forum.openscad.org/

tp3 wrote > And generates this warning with --viewall which explains what's happening: > WARNING: Viewall and autocenter disabled in favor of $vp* You´re absolutely right. I miss that warning, I´m sorry! JordanBrown wrote > From the CLI, you could have --camera set whatever viewpoint you > wanted.  You probably don't want --viewall, because for a non-trivial > model it'll probably zoom in and out to make the various views of the > model fit into the viewport.  (Or, alternatively, you could have the > model set $vpr/$vpt/$vpd and lock the viewpoint in place.) This is exactly what I´m trying to. However, if I keep the camera fix and rotate the model, the zoom in and out issue happens. Both using or not --viewall option. Conversely, if I keep the model fix but rotate the camera around it, then I have to manually set the $vpd variable... which is not possible (see next) JordanBrown wrote > What values would you want for $vpt/$vpr/$vpd or, alternatively, for > --camera?  Probably simplest is to first *not* set up the camera, use > the interactive controls to put the camera where you want it, and then > read the values off the "Viewport" line at the bottom of the window.  > You can also use the "Copy viewport ..." options from the Edit menu. Unfortunately, your approach is not possible for my application. Let me tell you more. I´m developing some web server that is intended to run OpenSCAD (server side), so automation and CLI are mandatory. Sorry, perhaps I should have told this before. I already figured out a quite dirty workaround to create the turntable... I used an awk script that parsed the an OpenSCAD generated STL file to dump its boundary box and from it I can roughly estimate $vpd... But I don´t like this solution since it slows down even more my workflow. The way OpenSCAD defines the appropriate camera zoom using the "View All" seems much better. How would I tell OpenSCAD (from CLI) to use and keep fixed the camera "View All" parameters? Perhaps adding a "--viewall_zero" option to initialize all view parameters at $t=0 (i.e. for the first frame), and then let the user choose which $vp* parameters to update via code? Any better alternative? -- Sent from: http://forum.openscad.org/
JB
Jordan Brown
Sat, Jan 23, 2021 4:55 PM

Sorry, we've exceeded my understanding.  Somebody who understands the
camera settings, and in particular how they relate to "view all", will
need to chime in.

Sorry, we've exceeded my understanding.  Somebody who understands the camera settings, and in particular how they relate to "view all", will need to chime in.
NH
nop head
Sat, Jan 23, 2021 6:33 PM

I always use --autocenter with --viewall on the command line to get the
camera looking at the object and scaling it to fit. I haven't tried the
command line animation yet. If it recomputes the camera setting per frame I
could that would be a problem. In the GUI you do it first and then start
the animation. It needs to match that.

On Sat, 23 Jan 2021 at 17:32, Jordan Brown openscad@jordan.maileater.net
wrote:

Sorry, we've exceeded my understanding.  Somebody who understands the
camera settings, and in particular how they relate to "view all", will need
to chime in.


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

I always use --autocenter with --viewall on the command line to get the camera looking at the object and scaling it to fit. I haven't tried the command line animation yet. If it recomputes the camera setting per frame I could that would be a problem. In the GUI you do it first and then start the animation. It needs to match that. On Sat, 23 Jan 2021 at 17:32, Jordan Brown <openscad@jordan.maileater.net> wrote: > Sorry, we've exceeded my understanding. Somebody who understands the > camera settings, and in particular how they relate to "view all", will need > to chime in. > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >