07-27-2019 07:30 AM
I am trying to draw a 3D object and display it in a 3D picture control. I am using the triangle drawing mode and the vertex array as a source for the mesh. The elements for the vertex array are provided from a text file (attached). My problem is that I am not able to draw the whole object all together using all the triangles but I am able to draw the triangles one by one (it kinda lacks memory). Is there any hope that I could draw the whole object and display it using the VI that I use (attached)?. (Note: the designed VI runs only for 9 iterations to illustrate my problem in those 9 rows of data, you can totally ignore it and assume that there is continuous data fed to the index array).
I appreciate your help.
Solved! Go to Solution.
07-28-2019 08:53 AM - edited 07-28-2019 09:00 AM
The Vertex Array input of the Create Mesh function takes an array of cluster where each cluster has the elements X, Y, Z. Each of the cluster represents a point that can be used more than once for the same 3D object. The order in which the points are used to create triangles is provided by the Indices input, 3 indices at a time. For example, in your example, the point (0,0,0) does not need to appear 3 times in the file if the provided Indices used the proper index (0 for example) for each of the triangle, as I have shown in the array constant I created. I think that if you do not provide an input to Indices, the function assumes the indices are the indices of the clusters in the array.
You need to specify what kind of color binding you want to use for the color of the triangles. By default, it is Overall, meaning that the first color of the array is used for all triangles. I selected Per Primitive and since there are 3 triangles, I needed to provided only 3 colors. Notice that colors are RGBA, Red-Green-Blue-Alpha. Alpha is used for transparency.
Concerning the reading of the file, you used a spreadsheet style. Each row should be read as a point and converted into a cluster. Using a format like .stl makes more sense. LabVIEW has a native function to read an .stl file. You can also use the Haro3D library for free to load and save .stl files.
12-10-2021 05:24 AM
Can't you use the point just once?
12-10-2021 06:20 AM
Yes you can use a point only one time but unless you draw a single triangle, it is not very efficient. If you draw an object that is made of multiple connected triangles, each point needs to be part of multiple triangles, like the central point in the figure above. This central point can be part of 3 or 6 triangles. It makes more sense to use it only once, and then repeat the same index multiple times. It is more efficient memory wise because an index uses only 1 integer while a point uses 3 floating points. I suspect that it is also more computationally efficient as well.
You can use a point only one time but you will have to repeat it multiple times in the vertices array and use their corresponding values in the index array only one time but it is less efficient.