Feature request: retrieve vertex coordinates from the viewport

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

Feature request: retrieve vertex coordinates from the viewport

DarioPellegrini
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/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
tp3
Reply | Threaded
Open this post in threaded view
|

Re: Feature request: retrieve vertex coordinates from the viewport

tp3
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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
-- Torsten
Reply | Threaded
Open this post in threaded view
|

Re: Feature request: retrieve vertex coordinates from the viewport

nophead
> 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 <[hidden email]> 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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Feature request: retrieve vertex coordinates from the viewport

nophead
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 <[hidden email]> 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 <[hidden email]> 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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Feature request: retrieve vertex coordinates from the viewport

JordanBrown
In reply to this post by nophead
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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Feature request: retrieve vertex coordinates from the viewport

nophead
  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 <[hidden email]> 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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Feature request: retrieve vertex coordinates from the viewport

skypuppy
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Feature request: retrieve vertex coordinates from the viewport

jotweh
In reply to this post by nophead
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 <[hidden email]> 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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Feature request: retrieve vertex coordinates from the viewport

JordanBrown
In reply to this post by nophead
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.)


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Feature request: retrieve vertex coordinates from the viewport

nophead
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.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 <[hidden email]> 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.)


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Feature request: retrieve vertex coordinates from the viewport

cacb
In reply to this post by nophead
On 27.11.2020 22:14, nop head 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?

No, not when previewing. That's why preview is faster than full boolean.

Carsten Arnholm

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Feature request: retrieve vertex coordinates from the viewport

JordanBrown
In reply to this post by nophead
On 11/27/2020 2:00 PM, nop head wrote:
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.png

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


I suspected that we were using different meanings for "vertex".  I meant "any corner of the resulting object where three (or more?) edges meet", and in particular the convex ones.  In this diagram, I was specifically looking at the three corners closest to the camera, at [5,0,5], [0,5,5], and [5,5,0].

Or this:
intersection() {
    cube([10,5,5], center=true);
    #cube([5,10,10], center=true);
}


where the result is an obvious-looking cube, but where the vertices of that cube do not match the vertices of either of the input cubes.


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org