discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

$vpr and --camera

JG
Jonathan Gilbert
Tue, Nov 14, 2023 9:31 PM

Within a project I'm working on, I use --camera (the Euler variant),
--autocenter, and --viewall for five different PNG views of over 500
models, from the command line. I've got a task to face textual annotation
elements towards the camera when producing these images. The current plan
is to place the annotations within the scene, and then rotate() the
annotations towards a vector when rendered; when prototyping that out using
$vpr, it works pretty well.

Naturally, the use of --camera on the command-line and the use of $vpr
within the scene are exclusive, and I can't immediately use that to know
where I should rotate elements so that they always face the viewer. I'd
very much like to continue using --camera, since --autocenter and --viewall
can both be used and that's a lot less math to worry about.

Before I put together a manually-built list of --camera arguments and their
corresponding rotation settings for use with OpenSCAD 2021.01, I'd like to
ask in hope:

  1. Is there a way to get a rotational transform towards the camera's
    position while rendering a scene not within the UI, when $vpr is not
    set? This would obviate needing to specify both --camera and a rotational
    vector on the command-line.

  2. Is there a way to get the argument to --camera (either the vpt/vpr/d or
    eye_xyz/center_xyz variant) within an OpenSCAD script? This would obviate
    needing to create an entirely separate list of $vpr settings per camera
    position. I suppose I could replicate the same argument into a value passed
    through -D (though that seems like a needless redundancy in OpenSCAD);
    regardless, I'd need to figure out the rotational matrix to direct the
    elements to wherever the camera is pointing and I do not relish that.

  3. Do you know of an easier way than rotate(vector) to always orient
    textual elements towards the camera?

--

Within a project I'm working on, I use --camera (the Euler variant), --autocenter, and --viewall for five different PNG views of over 500 models, from the command line. I've got a task to face textual annotation elements towards the camera when producing these images. The current plan is to place the annotations within the scene, and then `rotate()` the annotations towards a vector when rendered; when prototyping that out using $vpr, it works pretty well. Naturally, the use of --camera on the command-line and the use of $vpr within the scene are exclusive, and I can't immediately use that to know where I should rotate elements so that they always face the viewer. I'd very much like to continue using --camera, since --autocenter and --viewall can both be used and that's a lot less math to worry about. Before I put together a manually-built list of --camera arguments and their corresponding rotation settings for use with OpenSCAD 2021.01, I'd like to ask in hope: 1. Is there a way to get a rotational transform towards the camera's position while rendering a scene *not* within the UI, when $vpr is *not* set? This would obviate needing to specify both --camera and a rotational vector on the command-line. 2. Is there a way to get the argument to --camera (either the vpt/vpr/d or eye_xyz/center_xyz variant) within an OpenSCAD script? This would obviate needing to create an entirely separate list of $vpr settings per camera position. I suppose I could replicate the same argument into a value passed through -D (though that seems like a needless redundancy in OpenSCAD); regardless, I'd need to figure out the rotational matrix to direct the elements to wherever the camera is pointing and I do not relish that. 3. Do you know of an easier way than `rotate(vector)` to always orient textual elements towards the camera? -- - Jon Gilbert jong@jong.org / jgilbertsjc@gmail.com
HL
Hans L
Tue, Nov 14, 2023 10:36 PM

Not sure if this helps, but I put together a small demo a while ago of a
sort of camera independent display method:

translate($vpt)           // camera translation independent
 rotate($vpr)             // camera rotation independent
  translate([0,0,$vpd/2]) // bring to foreground so not intersecting with
scene in most cases
   scale($vpd/500)        // zoom independent
    color([1,0,0]) linear_extrude(10) text("oh hi!", halign="center");

You have to enable animation with high-ish fps (eg 60) for it to update
continuously if testing camera movement in GUI.

On Tue, Nov 14, 2023 at 3:32 PM Jonathan Gilbert via Discuss <
discuss@lists.openscad.org> wrote:

Within a project I'm working on, I use --camera (the Euler variant),
--autocenter, and --viewall for five different PNG views of over 500
models, from the command line. I've got a task to face textual annotation
elements towards the camera when producing these images. The current plan
is to place the annotations within the scene, and then rotate() the
annotations towards a vector when rendered; when prototyping that out using
$vpr, it works pretty well.

Naturally, the use of --camera on the command-line and the use of $vpr
within the scene are exclusive, and I can't immediately use that to know
where I should rotate elements so that they always face the viewer. I'd
very much like to continue using --camera, since --autocenter and --viewall
can both be used and that's a lot less math to worry about.

Before I put together a manually-built list of --camera arguments and
their corresponding rotation settings for use with OpenSCAD 2021.01, I'd
like to ask in hope:

  1. Is there a way to get a rotational transform towards the camera's
    position while rendering a scene not within the UI, when $vpr is not
    set? This would obviate needing to specify both --camera and a rotational
    vector on the command-line.

  2. Is there a way to get the argument to --camera (either the vpt/vpr/d or
    eye_xyz/center_xyz variant) within an OpenSCAD script? This would obviate
    needing to create an entirely separate list of $vpr settings per camera
    position. I suppose I could replicate the same argument into a value passed
    through -D (though that seems like a needless redundancy in OpenSCAD);
    regardless, I'd need to figure out the rotational matrix to direct the
    elements to wherever the camera is pointing and I do not relish that.

  3. Do you know of an easier way than rotate(vector) to always orient
    textual elements towards the camera?

--


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

Not sure if this helps, but I put together a small demo a while ago of a sort of camera independent display method: ``` translate($vpt) // camera translation independent rotate($vpr) // camera rotation independent translate([0,0,$vpd/2]) // bring to foreground so not intersecting with scene in most cases scale($vpd/500) // zoom independent color([1,0,0]) linear_extrude(10) text("oh hi!", halign="center"); ``` You have to enable animation with high-ish fps (eg 60) for it to update continuously if testing camera movement in GUI. On Tue, Nov 14, 2023 at 3:32 PM Jonathan Gilbert via Discuss < discuss@lists.openscad.org> wrote: > Within a project I'm working on, I use --camera (the Euler variant), > --autocenter, and --viewall for five different PNG views of over 500 > models, from the command line. I've got a task to face textual annotation > elements towards the camera when producing these images. The current plan > is to place the annotations within the scene, and then `rotate()` the > annotations towards a vector when rendered; when prototyping that out using > $vpr, it works pretty well. > > Naturally, the use of --camera on the command-line and the use of $vpr > within the scene are exclusive, and I can't immediately use that to know > where I should rotate elements so that they always face the viewer. I'd > very much like to continue using --camera, since --autocenter and --viewall > can both be used and that's a lot less math to worry about. > > Before I put together a manually-built list of --camera arguments and > their corresponding rotation settings for use with OpenSCAD 2021.01, I'd > like to ask in hope: > > 1. Is there a way to get a rotational transform towards the camera's > position while rendering a scene *not* within the UI, when $vpr is *not* > set? This would obviate needing to specify both --camera and a rotational > vector on the command-line. > > 2. Is there a way to get the argument to --camera (either the vpt/vpr/d or > eye_xyz/center_xyz variant) within an OpenSCAD script? This would obviate > needing to create an entirely separate list of $vpr settings per camera > position. I suppose I could replicate the same argument into a value passed > through -D (though that seems like a needless redundancy in OpenSCAD); > regardless, I'd need to figure out the rotational matrix to direct the > elements to wherever the camera is pointing and I do not relish that. > > 3. Do you know of an easier way than `rotate(vector)` to always orient > textual elements towards the camera? > > -- > - Jon Gilbert > jong@jong.org / jgilbertsjc@gmail.com > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
JG
Jonathan Gilbert
Tue, Nov 14, 2023 10:47 PM

Right, so, that's essentially what I'm shooting for, thanks, except for the
parts where I'm rendering this from the command-line with --camera and
$vpr, $vpt, et al aren't set within the scene.

Your snippet below, as shown within OpenSCAD, yields as expected:
[image: image.png]

That same snippet, when rendered from the CLI with a --camera argument,
yields something quite different:

openscad --export-format png --camera=0,-200,10,0,0,0 --viewall
--autocenter --projection p -o test.png test.scad

[image: image.png]

I'm trying to get a rotational vector that will face the camera view (like
$vpr) when using the command-line with a --camera argument, in the absence
of a $vpr defined; ideally, derived from whatever --camera is set at.

On Tue, Nov 14, 2023 at 2:37 PM Hans L via Discuss <
discuss@lists.openscad.org> wrote:

Not sure if this helps, but I put together a small demo a while ago of a
sort of camera independent display method:

translate($vpt)           // camera translation independent
 rotate($vpr)             // camera rotation independent
  translate([0,0,$vpd/2]) // bring to foreground so not intersecting with
scene in most cases
   scale($vpd/500)        // zoom independent
    color([1,0,0]) linear_extrude(10) text("oh hi!", halign="center");

You have to enable animation with high-ish fps (eg 60) for it to update
continuously if testing camera movement in GUI.

On Tue, Nov 14, 2023 at 3:32 PM Jonathan Gilbert via Discuss <
discuss@lists.openscad.org> wrote:

Within a project I'm working on, I use --camera (the Euler variant),
--autocenter, and --viewall for five different PNG views of over 500
models, from the command line. I've got a task to face textual annotation
elements towards the camera when producing these images. The current plan
is to place the annotations within the scene, and then rotate() the
annotations towards a vector when rendered; when prototyping that out using
$vpr, it works pretty well.

Naturally, the use of --camera on the command-line and the use of $vpr
within the scene are exclusive, and I can't immediately use that to know
where I should rotate elements so that they always face the viewer. I'd
very much like to continue using --camera, since --autocenter and --viewall
can both be used and that's a lot less math to worry about.

Before I put together a manually-built list of --camera arguments and
their corresponding rotation settings for use with OpenSCAD 2021.01, I'd
like to ask in hope:

  1. Is there a way to get a rotational transform towards the camera's
    position while rendering a scene not within the UI, when $vpr is not
    set? This would obviate needing to specify both --camera and a rotational
    vector on the command-line.

  2. Is there a way to get the argument to --camera (either the vpt/vpr/d
    or eye_xyz/center_xyz variant) within an OpenSCAD script? This would
    obviate needing to create an entirely separate list of $vpr settings per
    camera position. I suppose I could replicate the same argument into a value
    passed through -D (though that seems like a needless redundancy in
    OpenSCAD); regardless, I'd need to figure out the rotational matrix to
    direct the elements to wherever the camera is pointing and I do not relish
    that.

  3. Do you know of an easier way than rotate(vector) to always orient
    textual elements towards the camera?

--


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

Right, so, that's essentially what I'm shooting for, thanks, except for the parts where I'm rendering this from the command-line with --camera and $vpr, $vpt, et al aren't set within the scene. Your snippet below, as shown within OpenSCAD, yields as expected: [image: image.png] That same snippet, when rendered from the CLI with a --camera argument, yields something quite different: ``` openscad --export-format png --camera=0,-200,10,0,0,0 --viewall --autocenter --projection p -o test.png test.scad ``` [image: image.png] I'm trying to get a rotational vector that will face the camera view (like $vpr) when using the command-line with a --camera argument, in the absence of a $vpr defined; ideally, derived from whatever --camera is set at. On Tue, Nov 14, 2023 at 2:37 PM Hans L via Discuss < discuss@lists.openscad.org> wrote: > Not sure if this helps, but I put together a small demo a while ago of a > sort of camera independent display method: > > ``` > translate($vpt) // camera translation independent > rotate($vpr) // camera rotation independent > translate([0,0,$vpd/2]) // bring to foreground so not intersecting with > scene in most cases > scale($vpd/500) // zoom independent > color([1,0,0]) linear_extrude(10) text("oh hi!", halign="center"); > ``` > You have to enable animation with high-ish fps (eg 60) for it to update > continuously if testing camera movement in GUI. > > > On Tue, Nov 14, 2023 at 3:32 PM Jonathan Gilbert via Discuss < > discuss@lists.openscad.org> wrote: > >> Within a project I'm working on, I use --camera (the Euler variant), >> --autocenter, and --viewall for five different PNG views of over 500 >> models, from the command line. I've got a task to face textual annotation >> elements towards the camera when producing these images. The current plan >> is to place the annotations within the scene, and then `rotate()` the >> annotations towards a vector when rendered; when prototyping that out using >> $vpr, it works pretty well. >> >> Naturally, the use of --camera on the command-line and the use of $vpr >> within the scene are exclusive, and I can't immediately use that to know >> where I should rotate elements so that they always face the viewer. I'd >> very much like to continue using --camera, since --autocenter and --viewall >> can both be used and that's a lot less math to worry about. >> >> Before I put together a manually-built list of --camera arguments and >> their corresponding rotation settings for use with OpenSCAD 2021.01, I'd >> like to ask in hope: >> >> 1. Is there a way to get a rotational transform towards the camera's >> position while rendering a scene *not* within the UI, when $vpr is *not* >> set? This would obviate needing to specify both --camera and a rotational >> vector on the command-line. >> >> 2. Is there a way to get the argument to --camera (either the vpt/vpr/d >> or eye_xyz/center_xyz variant) within an OpenSCAD script? This would >> obviate needing to create an entirely separate list of $vpr settings per >> camera position. I suppose I could replicate the same argument into a value >> passed through -D (though that seems like a needless redundancy in >> OpenSCAD); regardless, I'd need to figure out the rotational matrix to >> direct the elements to wherever the camera is pointing and I do not relish >> that. >> >> 3. Do you know of an easier way than `rotate(vector)` to always orient >> textual elements towards the camera? >> >> -- >> - Jon Gilbert >> jong@jong.org / jgilbertsjc@gmail.com >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org >> > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org > -- - Jon Gilbert jong@jong.org / jgilbertsjc@gmail.com
M
mikeonenine@web.de
Wed, Nov 15, 2023 12:34 AM

Jonathan Gilbert wrote:

Right, so, that's essentially what I'm shooting for, thanks, except for the
parts where I'm rendering this from the command-line with --camera and
$vpr, $vpt, et al aren't set within the scene.

Your snippet below, as shown within OpenSCAD, yields as expected:
[image: image.png]

That same snippet, when rendered from the CLI with a --camera argument,
yields something quite different:

openscad --export-format png --camera=0,-200,10,0,0,0 --viewall
--autocenter --projection p -o test.png test.scad

[image: image.png]

I'm trying to get a rotational vector that will face the camera view (like
$vpr) when using the command-line with a --camera argument, in the absence
of a $vpr defined; ideally, derived from whatever --camera is set at.

On Tue, Nov 14, 2023 at 2:37 PM Hans L via Discuss <
discuss@lists.openscad.org> wrote:

Not sure if this helps, but I put together a small demo a while ago of a
sort of camera independent display method:

translate($vpt)           // camera translation independent
 rotate($vpr)             // camera rotation independent
  translate([0,0,$vpd/2]) // bring to foreground so not intersecting with
scene in most cases
   scale($vpd/500)        // zoom independent
    color([1,0,0]) linear_extrude(10) text("oh hi!", halign="center");

You have to enable animation with high-ish fps (eg 60) for it to update
continuously if testing camera movement in GUI.

On Tue, Nov 14, 2023 at 3:32 PM Jonathan Gilbert via Discuss <
discuss@lists.openscad.org> wrote:

Within a project I'm working on, I use --camera (the Euler variant),
--autocenter, and --viewall for five different PNG views of over 500
models, from the command line. I've got a task to face textual annotation
elements towards the camera when producing these images. The current plan
is to place the annotations within the scene, and then rotate() the
annotations towards a vector when rendered; when prototyping that out using
$vpr, it works pretty well.

Naturally, the use of --camera on the command-line and the use of $vpr
within the scene are exclusive, and I can't immediately use that to know
where I should rotate elements so that they always face the viewer. I'd
very much like to continue using --camera, since --autocenter and --viewall
can both be used and that's a lot less math to worry about.

Before I put together a manually-built list of --camera arguments and
their corresponding rotation settings for use with OpenSCAD 2021.01, I'd
like to ask in hope:

  1. Is there a way to get a rotational transform towards the camera's
    position while rendering a scene not within the UI, when $vpr is not
    set? This would obviate needing to specify both --camera and a rotational
    vector on the command-line.

  2. Is there a way to get the argument to --camera (either the vpt/vpr/d
    or eye_xyz/center_xyz variant) within an OpenSCAD script? This would
    obviate needing to create an entirely separate list of $vpr settings per
    camera position. I suppose I could replicate the same argument into a value
    passed through -D (though that seems like a needless redundancy in
    OpenSCAD); regardless, I'd need to figure out the rotational matrix to
    direct the elements to wherever the camera is pointing and I do not relish
    that.

  3. Do you know of an easier way than rotate(vector) to always orient
    textual elements towards the camera?

--


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

Not sure if this helps either.

For text facing the camera I use this, kindly developed by someone in the old forum:

module txm()
{
window = [876, 640];
translate($vpt)
rotate($vpr)
scale($vpd / window.y)
translate([x,y,z])
rotate([X,Y,Z])
linear_extrude(0.0000000000000000000000000001)
text(txt, valign = "center", halign = side, font="Times New Roman", size=s);
}
color ("black")
txm(x=-80, side="left", y=-123, z=0, X=0, Y=0, Z=0, txt=(str("Length : stroke = ", l/e/2, " : 1")), s=7); 

Caddiy

Jonathan Gilbert wrote: > Right, so, that's essentially what I'm shooting for, thanks, except for the > parts where I'm rendering this from the command-line with --camera and > $vpr, $vpt, et al aren't set within the scene. > > Your snippet below, as shown within OpenSCAD, yields as expected: > \[image: image.png\] > > That same snippet, when rendered from the CLI with a --camera argument, > yields something quite different: > > ``` > openscad --export-format png --camera=0,-200,10,0,0,0 --viewall > --autocenter --projection p -o test.png test.scad > ``` > > \[image: image.png\] > > I'm trying to get a rotational vector that will face the camera view (like > $vpr) when using the command-line with a --camera argument, in the absence > of a $vpr defined; ideally, derived from whatever --camera is set at. > > On Tue, Nov 14, 2023 at 2:37 PM Hans L via Discuss < > discuss@lists.openscad.org> wrote: > > > Not sure if this helps, but I put together a small demo a while ago of a > > sort of camera independent display method: > > > > ``` > > translate($vpt) // camera translation independent > > rotate($vpr) // camera rotation independent > > translate([0,0,$vpd/2]) // bring to foreground so not intersecting with > > scene in most cases > > scale($vpd/500) // zoom independent > > color([1,0,0]) linear_extrude(10) text("oh hi!", halign="center"); > > ``` > > > > You have to enable animation with high-ish fps (eg 60) for it to update > > continuously if testing camera movement in GUI. > > > > On Tue, Nov 14, 2023 at 3:32 PM Jonathan Gilbert via Discuss < > > discuss@lists.openscad.org> wrote: > > > > > Within a project I'm working on, I use --camera (the Euler variant), > > > \--autocenter, and --viewall for five different PNG views of over 500 > > > models, from the command line. I've got a task to face textual annotation > > > elements towards the camera when producing these images. The current plan > > > is to place the annotations within the scene, and then `rotate()` the > > > annotations towards a vector when rendered; when prototyping that out using > > > $vpr, it works pretty well. > > > > > > Naturally, the use of --camera on the command-line and the use of $vpr > > > within the scene are exclusive, and I can't immediately use that to know > > > where I should rotate elements so that they always face the viewer. I'd > > > very much like to continue using --camera, since --autocenter and --viewall > > > can both be used and that's a lot less math to worry about. > > > > > > Before I put together a manually-built list of --camera arguments and > > > their corresponding rotation settings for use with OpenSCAD 2021.01, I'd > > > like to ask in hope: > > > > > > 1. Is there a way to get a rotational transform towards the camera's > > > position while rendering a scene *not* within the UI, when $vpr is *not* > > > set? This would obviate needing to specify both --camera and a rotational > > > vector on the command-line. > > > > > > 2. Is there a way to get the argument to --camera (either the vpt/vpr/d > > > or eye_xyz/center_xyz variant) within an OpenSCAD script? This would > > > obviate needing to create an entirely separate list of $vpr settings per > > > camera position. I suppose I could replicate the same argument into a value > > > passed through -D (though that seems like a needless redundancy in > > > OpenSCAD); regardless, I'd need to figure out the rotational matrix to > > > direct the elements to wherever the camera is pointing and I do not relish > > > that. > > > > > > 3. Do you know of an easier way than `rotate(vector)` to always orient > > > textual elements towards the camera? > > > > > > \-- > > > > > > * Jon Gilbert > > > jong@jong.org / jgilbertsjc@gmail.com > > > > > > --- > > > > > > OpenSCAD mailing list > > > To unsubscribe send an email to discuss-leave@lists.openscad.org > > > > --- > > > > OpenSCAD mailing list > > To unsubscribe send an email to discuss-leave@lists.openscad.org > > \-- > > * Jon Gilbert > jong@jong.org / jgilbertsjc@gmail.com Not sure if this helps either. For text facing the camera I use this, kindly developed by someone in the old forum: ``` module txm() ``` ``` { ``` ``` window = [876, 640]; ``` ``` translate($vpt) ``` ``` rotate($vpr) ``` ``` scale($vpd / window.y) ``` ``` translate([x,y,z]) ``` ``` rotate([X,Y,Z]) ``` ``` linear_extrude(0.0000000000000000000000000001) ``` ``` text(txt, valign = "center", halign = side, font="Times New Roman", size=s); ``` ``` } ``` ``` color ("black") ``` ``` txm(x=-80, side="left", y=-123, z=0, X=0, Y=0, Z=0, txt=(str("Length : stroke = ", l/e/2, " : 1")), s=7); ``` Caddiy
JB
Jordan Brown
Wed, Nov 15, 2023 12:55 AM

It sure seems like a bug that $vpr et al aren't set when you export a
PNG from the CLI.

It sure seems like a bug that $vpr et al aren't set when you export a PNG from the CLI.
JB
Jordan Brown
Sat, Nov 18, 2023 2:48 PM

On 11/14/2023 4:55 PM, Jordan Brown via Discuss wrote:

It sure seems like a bug that $vpr et al aren't set when you export a
PNG from the CLI.

Issue #4466 https://github.com/openscad/openscad/issues/4466 "let
$vp.. variables reflect the viewport when rendering from the command line".

On 11/14/2023 4:55 PM, Jordan Brown via Discuss wrote: > It sure seems like a bug that $vpr et al aren't set when you export a > PNG from the CLI. Issue #4466 <https://github.com/openscad/openscad/issues/4466> "let $vp.. variables reflect the viewport when rendering from the command line".