Reply
This is an open group. Sign in and click the "Join Group" button to become a group member and start posting.
Highlighted
Solved! Go to solution

Select objects in 3D picture control - select primitive in mesh

Once I have selected an object in the 3D picture control using "pick point", how can I identify the selected the primitive of the object.

All I have is the position on the 3D picture, and the object (returned from 3Dpicture Control / pick model as selected by 3Dpicture control/ pick point)

 

Lets say I have a cube on a 3D picture, when I click on the cube, I can identify the object (the cube), but I would like to identify the triangle / quad primitive, and change/highlight its color.

0 Kudos
Message 1 of 7
(2,634 Views)
6 REPLIES

Re: Select objects in 3D picture control - select primitive in mesh

I am not aware of any special function in LabVIEW that would do that for you (but I would be happy to hear from anyone who would know one) but it can be done.

Pick primitive - multiple meshes_FP.png

I can see two methods:

  1. tracking yourself within the mesh to find which surface the clicked point belongs
  2. converts a mesh into multiple meshes.

Method 1 is probably what would be done by non-LabVIEW programmers. You need to take the point, removes all rotations and translations of the mesh in the 3D Pict space, and then loop through the surfaces of your mesh to find to what surface the point belongs. It is the hard way. Fortunately, the LabVIEW helps us a little bit. Below is the code to extract point, and then transform it back in the referential of your mesh (I did not try to loop through the surfaces).

Pick primitive_BD.png

 

Method 2 is probably your best bet. This is how I produced the image at the top of this post. You simply need to convert each surface into its own mesh, add all those meshes into a single object, and then handle that object. When you click on a surface, you just need to change the color using the reference provided to you. Below is an example of the code to build a multiple-mesh cube (I put the vertices, normals, and indices as constants for simplicity.

Pick primitive - multiple meshes_BD.png

Hope it helps.

Marc Dubois
HaroTek LLC
www.harotek.com
0 Kudos
Message 2 of 7
(2,613 Views)

Re: Select objects in 3D picture control - select primitive in mesh

Hi Mark

 

Thanks for the assistance.

Will try option 1 for the complex geometries.

For the pre-set geometries (cones, sphere, box etc), is there a way to obtain the mesh vertices (they appear to be internal to LabView) ?

 

Would you mind sharing your example in LabView 15 for me please.

0 Kudos
Message 3 of 7
(2,605 Views)

Re: Select objects in 3D picture control - select primitive in mesh

Thank you Mark, I have implemented your suggestion (attached) for picking a primitive..... linear operation.... quite fast.

But I had to have the mesh before I can use it.... how do I get the mesh class out of a named Object?

I have a complex scene, so obtaining the mesh programmatically would be much neater.

 

See below .... the incorrectly wired "get more specific class"SceneMesh.png

Example also traverses the model to get the correct point on the model (thanks to Mark for his example on which this is based).

Example doesn't use the in-range on the cluster, but splits it up into X,Y,Z, as LabView 15 appears to have a bug with the in-Range instruction.

Anyone know how to get a mesh from a built in primitive (box, cone etc)?

0 Kudos
Message 4 of 7
(2,592 Views)
Solution
Accepted by topic author Philippe_RSA
06-21-2017 11:30 PM

Re: Select objects in 3D picture control - select primitive in mesh

Hi Philippe,

 

I don't think it is possible to extract the mesh arrays from an object after it has been added. I would love to be able to do it so if you find a way, please let me know.

 

I think that you will have to manage your meshes yourself. First, you can generate the simple shapes yourself. I did that in C++ a while ago and I have just created a dll (SimpleMesh.dll) that can be called from LabVIEW (code is from "Introduction to 3D Game Programming with DirectX 12"
from Frank D. Luna). This way, you have access to the full data from the mesh. Also, for your detection algorithm, I am not sure what you are trying to do. If you try to see if a point is within a triangle, there are techniques to do that. I have just copied the Barycentric algorithm code from the  blackpawn.com/texts/pointinpoly/ into a Formula node and it seems to work (you have to test for co-planarity first).

I modified your VI with those 2 modifications and below is an image I obtained.

Pick and color primitive (mod)_FP.png

I have attached the 3 VIs and the dll with this post, along with the two previous VIs in LabVIEW 2015 format. The dll requires Visual Studio 2015 redistributable x86.

Good luck and let us know how it goes.

Marc Dubois
HaroTek LLC
www.harotek.com
Message 5 of 7
(2,566 Views)

Re: Select objects in 3D picture control - select primitive in mesh

Hi Mark

 

Thanks for the mesh generators. I will try and put some textures on them, to see if it handles differently to the LabView standard geometries.

 

I suspect my version of the primitive selection is 10* faster (only has to do comparisons, and no dot products or multiplications)....

 

Please let me know if you get a solution for mesh reference from object.

0 Kudos
Message 6 of 7
(2,461 Views)

Re: Select objects in 3D picture control - select primitive in mesh

H

ere is a new version of the SimpleMesh DLL. This version (1.1) is not going to crash with zero or negative values. 

The SimpleMesh DLL can be used to generate 3D objects of simple shapes and to have access to the vertices, indices, normals, and texture coefficients of the meshes (only triangles). The different shape types are:

  • Box
  • Cylinder
  • Sphere
  • Geosphere.

For all shapes, the absolute value of the parameter is used, except for the cylinder. If you put negative values for parameters 2 or 3 (bottom and top radii) of the cylinder, the corresponding cap is not drawn.

Quality is a factor between 0 and 1 (it is actually not capped at 1). You can use the quality factor with values close to 0 with the Cylinder, Sphere, and Geosphere, to generate more complex shapes (try it!).

The difference between the sphere and geosphere is that the geosphere is made of triangles that have all the same size.

The DLL is demonstrated by two VIs,  Generate Simple Mesh.vi and Generate Simple Mesh - Vertices.vi. The first VI calls the DLL and generates the requested shape as a 3D object and Mesh object. The second DLL also calls the DLL to generate a requested shape but provides the vertices, indices, normals and texture coefficients.

The two VIs are demonstrated in a test VI: test create mesh.vi. Below is an image of the front panel of the test vi. Use the random colors option to be able to see all the different triangles.

test create mesh_FP.png

The VIs are LabVIEW 2015 and the SimpleMesh DLL requires the Visual Studio 2015 redistributable x86.

Marc Dubois
HaroTek LLC
www.harotek.com
0 Kudos
Message 7 of 7
(2,372 Views)
Reply
This is an open group. Sign in and click the "Join Group" button to become a group member and start posting.