discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Feature request: retrieve vertex coordinates from the viewport

D
DarioPellegrini
Fri, Nov 27, 2020 9:02 PM

Hi,

I am working on a pretty convoluted project and it has become prohibitive to
mathematically keep track of the relevant locations.

I was wondering how hard would it be adding the possibility to click on a
vertex
in the preview and get a popup with its coordinates. This would be
pretty cool also for checking a design.

If this is feasible, I can spend some time on this, given a little guidance.

Thank you

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

Hi, I am working on a pretty convoluted project and it has become prohibitive to mathematically keep track of the relevant locations. I was wondering how hard would it be adding the possibility to *click on a vertex* in the preview and get a *popup with its coordinates*. This would be pretty cool also for checking a design. If this is feasible, I can spend some time on this, given a little guidance. Thank you -- Sent from: http://forum.openscad.org/
TP
Torsten Paul
Fri, Nov 27, 2020 9:09 PM

On 27.11.20 22:02, DarioPellegrini wrote:

I was wondering how hard would it be adding the possibility
to click on a vertex in the preview and get a popup with
its coordinates
. This would be pretty cool also for checking
a design.

In preview mode, it's not possible in general. Simply because
the coordinates are not fully calculated.
Maybe it's possible to calculate a ray intersection against
the CSG tree, but I don't know if and how that would work.

For the calculated model, it's possible obviously as the full
mesh is known. This would even allow showing measurements of
edges and similar things too so that would be a very useful
feature.

ciao,
Torsten.

On 27.11.20 22:02, DarioPellegrini wrote: > I was wondering how hard would it be adding the possibility > to *click on a vertex* in the preview and get a *popup with > its coordinates*. This would be pretty cool also for checking > a design. In preview mode, it's not possible in general. Simply because the coordinates are not fully calculated. Maybe it's possible to calculate a ray intersection against the CSG tree, but I don't know if and how that would work. For the calculated model, it's possible obviously as the full mesh is known. This would even allow showing measurements of edges and similar things too so that would be a very useful feature. ciao, Torsten.
NH
nop head
Fri, Nov 27, 2020 9:14 PM

Simply because the coordinates are not fully calculated.

Is that really the case? Don't all vertices of the triangles drawn
correspond to vertices of primitives. How would the triangle be drawn if
OpenSCAD didn't know where it was?

On Fri, 27 Nov 2020 at 21:10, Torsten Paul Torsten.Paul@gmx.de wrote:

On 27.11.20 22:02, DarioPellegrini wrote:

I was wondering how hard would it be adding the possibility
to click on a vertex in the preview and get a popup with
its coordinates
. This would be pretty cool also for checking
a design.

In preview mode, it's not possible in general. Simply because
the coordinates are not fully calculated.
Maybe it's possible to calculate a ray intersection against
the CSG tree, but I don't know if and how that would work.

For the calculated model, it's possible obviously as the full
mesh is known. This would even allow showing measurements of
edges and similar things too so that would be a very useful
feature.

ciao,
Torsten.


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

> Simply because the coordinates are not fully calculated. Is that really the case? Don't all vertices of the triangles drawn correspond to vertices of primitives. How would the triangle be drawn if OpenSCAD didn't know where it was? On Fri, 27 Nov 2020 at 21:10, Torsten Paul <Torsten.Paul@gmx.de> wrote: > On 27.11.20 22:02, DarioPellegrini wrote: > > I was wondering how hard would it be adding the possibility > > to *click on a vertex* in the preview and get a *popup with > > its coordinates*. This would be pretty cool also for checking > > a design. > > In preview mode, it's not possible in general. Simply because > the coordinates are not fully calculated. > Maybe it's possible to calculate a ray intersection against > the CSG tree, but I don't know if and how that would work. > > For the calculated model, it's possible obviously as the full > mesh is known. This would even allow showing measurements of > edges and similar things too so that would be a very useful > feature. > > ciao, > Torsten. > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
NH
nop head
Fri, Nov 27, 2020 9:16 PM

Or rather I should have said the vertices in the tessellated faces of the
primitives.

On Fri, 27 Nov 2020 at 21:14, nop head nop.head@gmail.com wrote:

Simply because the coordinates are not fully calculated.

Is that really the case? Don't all vertices of the triangles drawn
correspond to vertices of primitives. How would the triangle be drawn if
OpenSCAD didn't know where it was?

On Fri, 27 Nov 2020 at 21:10, Torsten Paul Torsten.Paul@gmx.de wrote:

On 27.11.20 22:02, DarioPellegrini wrote:

I was wondering how hard would it be adding the possibility
to click on a vertex in the preview and get a popup with
its coordinates
. This would be pretty cool also for checking
a design.

In preview mode, it's not possible in general. Simply because
the coordinates are not fully calculated.
Maybe it's possible to calculate a ray intersection against
the CSG tree, but I don't know if and how that would work.

For the calculated model, it's possible obviously as the full
mesh is known. This would even allow showing measurements of
edges and similar things too so that would be a very useful
feature.

ciao,
Torsten.


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

Or rather I should have said the vertices in the tessellated faces of the primitives. On Fri, 27 Nov 2020 at 21:14, nop head <nop.head@gmail.com> wrote: > > Simply because the coordinates are not fully calculated. > > Is that really the case? Don't all vertices of the triangles drawn > correspond to vertices of primitives. How would the triangle be drawn if > OpenSCAD didn't know where it was? > > On Fri, 27 Nov 2020 at 21:10, Torsten Paul <Torsten.Paul@gmx.de> wrote: > >> On 27.11.20 22:02, DarioPellegrini wrote: >> > I was wondering how hard would it be adding the possibility >> > to *click on a vertex* in the preview and get a *popup with >> > its coordinates*. This would be pretty cool also for checking >> > a design. >> >> In preview mode, it's not possible in general. Simply because >> the coordinates are not fully calculated. >> Maybe it's possible to calculate a ray intersection against >> the CSG tree, but I don't know if and how that would work. >> >> For the calculated model, it's possible obviously as the full >> mesh is known. This would even allow showing measurements of >> edges and similar things too so that would be a very useful >> feature. >> >> ciao, >> Torsten. >> >> _______________________________________________ >> OpenSCAD mailing list >> Discuss@lists.openscad.org >> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >> >
JB
Jordan Brown
Fri, Nov 27, 2020 9:21 PM

On 11/27/2020 1:14 PM, nop head wrote:

Don't all vertices of the triangles drawn correspond to vertices of
primitives.

Not if you've got boolean operations in the picture.

On 11/27/2020 1:14 PM, nop head wrote: > Don't all vertices of the triangles drawn correspond to vertices of > primitives. Not if you've got boolean operations in the picture.
NH
nop head
Fri, Nov 27, 2020 9:28 PM

Even with booleans all the original primitives get drawn to add or
subtract. Isn't any vertex a vertex of a triangle from a tessellation of a
primitive?

[image: image.png]

There are edges that are not vertices of course and they are not calculated
but if you have an actual vertex it should correspond to a drawn triangle.

On Fri, 27 Nov 2020 at 21:21, Jordan Brown openscad@jordan.maileater.net
wrote:

On 11/27/2020 1:14 PM, nop head wrote:

Don't all vertices of the triangles drawn correspond to vertices of
primitives.

Not if you've got boolean operations in the picture.

Even with booleans all the original primitives get drawn to add or subtract. Isn't any vertex a vertex of a triangle from a tessellation of a primitive? [image: image.png] There are edges that are not vertices of course and they are not calculated but if you have an actual vertex it should correspond to a drawn triangle. On Fri, 27 Nov 2020 at 21:21, Jordan Brown <openscad@jordan.maileater.net> wrote: > On 11/27/2020 1:14 PM, nop head wrote: > > Don't all vertices of the triangles drawn correspond to vertices of > primitives. > > > Not if you've got boolean operations in the picture. > >
D
David
Fri, Nov 27, 2020 9:41 PM

Huh?  What'd he say?  :)

On 11/27/20 3:28 PM, nop head wrote:

  Even with booleans all the original primitives get drawn to add or
subtract. Isn't any vertex a vertex of a triangle from a tessellation
of a primitive?

image.png

There are edges that are not vertices of course and they are not
calculated but if you have an actual vertex it should correspond to a
drawn triangle.

On Fri, 27 Nov 2020 at 21:21, Jordan Brown
<openscad@jordan.maileater.net mailto:openscad@jordan.maileater.net>
wrote:

 On 11/27/2020 1:14 PM, nop head wrote:
 Don't all vertices of the triangles drawn correspond to vertices
 of primitives.
 Not if you've got boolean operations in the picture.

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

Huh?  What'd he say?  :) On 11/27/20 3:28 PM, nop head wrote: >   Even with booleans all the original primitives get drawn to add or > subtract. Isn't any vertex a vertex of a triangle from a tessellation > of a primitive? > > image.png > > There are edges that are not vertices of course and they are not > calculated but if you have an actual vertex it should correspond to a > drawn triangle. > > On Fri, 27 Nov 2020 at 21:21, Jordan Brown > <openscad@jordan.maileater.net <mailto:openscad@jordan.maileater.net>> > wrote: > > On 11/27/2020 1:14 PM, nop head wrote: >> Don't all vertices of the triangles drawn correspond to vertices >> of primitives. > > Not if you've got boolean operations in the picture. > > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
JW
Johannes Walcher
Fri, Nov 27, 2020 9:44 PM

The current dev-version has a way to translate model information back
into the code.

To achieve this, it performs a full rendering of the model in a
background buffer and colorizes the different parts of the object
according to their ID (r/g/b encodes up to 24 bit of ID Space).
Then it grabs the color of the pixel that has been clicked and
translates the color back to the ID.

When PR #3459 is merged it could be possible to retrieve such
information from the vertex buffers by rendering these triangles also
with their respective IDs.
It might also be possible to retrieve the actual 3D coordinate from the
image.

So the Question is, what information would be interesting to retrieve?
A list of the 3D coordinates of the clicked triangle? The coordinates of
the closest vertex (the corner)?

One could also imagine to mark a point or edge 'active' and measure
other points against them?
That would mean to introduce a "selection" mode?

Any other Ideas? - we might discuss the topic in IRC.

On 27/11/2020 22.28, nop head wrote:

  Even with booleans all the original primitives get drawn to add or
subtract. Isn't any vertex a vertex of a triangle from a tessellation
of a primitive? 

image.png

There are edges that are not vertices of course and they are not
calculated but if you have an actual vertex it should correspond to a
drawn triangle.

On Fri, 27 Nov 2020 at 21:21, Jordan Brown
<openscad@jordan.maileater.net mailto:openscad@jordan.maileater.net>
wrote:

 On 11/27/2020 1:14 PM, nop head wrote:
 Don't all vertices of the triangles drawn correspond to vertices
 of primitives.
 Not if you've got boolean operations in the picture.

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

The current dev-version has a way to translate model information back into the code. To achieve this, it performs a full rendering of the model in a background buffer and colorizes the different parts of the object according to their ID (r/g/b encodes up to 24 bit of ID Space). Then it grabs the color of the pixel that has been clicked and translates the color back to the ID. When PR #3459 is merged it could be possible to retrieve such information from the vertex buffers by rendering these triangles also with their respective IDs. It might also be possible to retrieve the actual 3D coordinate from the image. So the Question is, what information would be interesting to retrieve? A list of the 3D coordinates of the clicked triangle? The coordinates of the closest vertex (the corner)? One could also imagine to mark a point or edge 'active' and measure other points against them? That would mean to introduce a "selection" mode? Any other Ideas? - we might discuss the topic in IRC. On 27/11/2020 22.28, nop head wrote: >   Even with booleans all the original primitives get drawn to add or > subtract. Isn't any vertex a vertex of a triangle from a tessellation > of a primitive?  > > image.png > > There are edges that are not vertices of course and they are not > calculated but if you have an actual vertex it should correspond to a > drawn triangle. > > On Fri, 27 Nov 2020 at 21:21, Jordan Brown > <openscad@jordan.maileater.net <mailto:openscad@jordan.maileater.net>> > wrote: > > On 11/27/2020 1:14 PM, nop head wrote: >> Don't all vertices of the triangles drawn correspond to vertices >> of primitives. > > Not if you've got boolean operations in the picture. > > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
JB
Jordan Brown
Fri, Nov 27, 2020 9:50 PM

On 11/27/2020 1:28 PM, nop head wrote:

Even with booleans all the original primitives get drawn to add or
subtract. Isn't any vertex a vertex of a triangle from a tessellation
of a primitive?

I don't deeply understand the mesh geometry, but I don't think so.

I don't know how to show the triangles, but

difference() {
    cube(10, center=true);
    #cube(10);
}

I assume that the triangles for the cube primitives are 45-45-90
triangles cutting across the diagonal one way or the other.

The three vertices at the corners of the cut-away portion are at the
centers of the faces of the two cubes, not their vertices.

(And of course the fact that they're at the centers of the faces are
just a coincidence caused by my choice of shapes to use.)

On 11/27/2020 1:28 PM, nop head wrote: > Even with booleans all the original primitives get drawn to add or > subtract. Isn't any vertex a vertex of a triangle from a tessellation > of a primitive? I don't deeply understand the mesh geometry, but I don't think so. I don't know how to show the triangles, but difference() {     cube(10, center=true);     #cube(10); } I assume that the triangles for the cube primitives are 45-45-90 triangles cutting across the diagonal one way or the other. The three vertices at the corners of the cut-away portion are at the centers of the faces of the two cubes, not their vertices. (And of course the fact that they're at the centers of the faces are just a coincidence caused by my choice of shapes to use.)
NH
nop head
Fri, Nov 27, 2020 10:00 PM

If you show the edges, then if there is an actual vertex where edges meet
then it is a vertex of a primitive. So in that case only the point in the
middle.

[image: image.png]

The other six in the cut faces have no edges, so are not vertices in that
sense. I agree they are not calculated.

On Fri, 27 Nov 2020 at 21:50, Jordan Brown openscad@jordan.maileater.net
wrote:

On 11/27/2020 1:28 PM, nop head wrote:

Even with booleans all the original primitives get drawn to add or
subtract. Isn't any vertex a vertex of a triangle from a tessellation of a
primitive?

I don't deeply understand the mesh geometry, but I don't think so.

I don't know how to show the triangles, but

difference() {
cube(10, center=true);
#cube(10);
}

I assume that the triangles for the cube primitives are 45-45-90 triangles
cutting across the diagonal one way or the other.

The three vertices at the corners of the cut-away portion are at the
centers of the faces of the two cubes, not their vertices.

(And of course the fact that they're at the centers of the faces are just
a coincidence caused by my choice of shapes to use.)

If you show the edges, then if there is an actual vertex where edges meet then it is a vertex of a primitive. So in that case only the point in the middle. [image: image.png] The other six in the cut faces have no edges, so are not vertices in that sense. I agree they are not calculated. On Fri, 27 Nov 2020 at 21:50, Jordan Brown <openscad@jordan.maileater.net> wrote: > On 11/27/2020 1:28 PM, nop head wrote: > > Even with booleans all the original primitives get drawn to add or > subtract. Isn't any vertex a vertex of a triangle from a tessellation of a > primitive? > > > I don't deeply understand the mesh geometry, but I don't think so. > > I don't know how to show the triangles, but > > difference() { > cube(10, center=true); > #cube(10); > } > > > > I assume that the triangles for the cube primitives are 45-45-90 triangles > cutting across the diagonal one way or the other. > > The three vertices at the corners of the cut-away portion are at the > centers of the faces of the two cubes, not their vertices. > > (And of course the fact that they're at the centers of the faces are just > a coincidence caused by my choice of shapes to use.) > >