3D Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

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

Solved!
Go to solution

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 10
(11,230 Views)

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
Download All
0 Kudos
Message 2 of 10
(11,209 Views)

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 10
(11,201 Views)

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 10
(11,188 Views)
Solution
Accepted by topic author Philippe_RSA

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
Download All
Message 5 of 10
(11,162 Views)

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 10
(11,057 Views)

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
0 Kudos
Message 7 of 10
(10,968 Views)

Hi, i already use your first example to get a point from my 3d picture from a STL file.

Now i need to get the vertex or the normal from that point.

I already use the property "NormalArray" to get the array from all the STL file but i can´t determine exactly wich normal correspond to the pick point.

 

0 Kudos
Message 8 of 10
(7,517 Views)

Based on the example "Pick and color primitive (mod).vi", you can simply extract the normal array from the model (just pull down the SceneMesh property node and select "NormalArray". Bring the array to the For Loop and output the correct array using a select function connected to the ouput of the function "Point in triangle.vi", as shown in the diagram below. Notice that there is one normal for each point defining a triangle but those 3 normals should be have the same values.

Pick and color primitive (mod)_BD.png

Marc Dubois
0 Kudos
Message 9 of 10
(7,509 Views)

Hi,

https://forums.ni.com/t5/3D-Vision/3D-VISION-Advanced-Toolkit-For-LabVIEW/td-p/4135464

http://sine.ni.com/nips/cds/view/p/lang/zhs/nid/217368

"3D Vision Advanced Toolkit For LabVIEW" There is a special toolkit for tools for content in 3D pictures.

张斌_0-1616116464905.png张斌_1-1616116485757.png张斌_2-1616116565656.png张斌_3-1616116588113.png张斌_4-1616116615020.png

Email: Technology@cos-3d.com

 

张斌_6-1615777778266.jpeg

Message 10 of 10
(5,076 Views)