LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

3D picture Draw shaded boxes - FAST!

Hi,

 

I would like to draw shaded boxes, like 'Scene.Drawable.Geometry.New Box'. But I want to draw some 100.000 boxes or more. If I use this function, I have to join the boxes using the Object.Add Object' invoke node. Repeating this for 100.000 times takes a long time, costs a lot of memory, and results in a slow display.

 

As an alternative, I created a box primitive, built from 6 quads. I can create an array holding the vertices of 100.000 cubes, and display them like a mesh. The creation is fast, and also is the display. But: the shading of the boxes differs from the shading that results from the first method. See example code.

 

I tried a whole lot of different lighting and shading settings, but I cannot get it right. Is it possible to draw a box using a mesh that looks exactly the same as the box using the new.box method?

 

In the example code, I would like to have the red box to have the same sort of shading as the green box.

Any help is appreciated.

 

 

0 Kudos
Message 1 of 5
(2,520 Views)

You need to gove different data for the Normal Array as this is what causes the different shades.  The "Normal Array" is the data used for calculating shading, not the geometric shape defined by the vertices.

0 Kudos
Message 2 of 5
(2,504 Views)

Ok, sounds very interesting. I did not use that input.

I am trying different settings now, but it does not seem to affect the display. Could you be a little bit more specific of what sort of values I should use?

 

Thanks a lot!

 

0 Kudos
Message 3 of 5
(2,496 Views)

Well you will have an X, a Y and a Z normal depending on the face of the cube and also positive or negative depending on the side of the cube.

 

Try {1,0,0}, {0,1,0}, {0,0,1}, {-1,0,0}, {0,-1,0}, {0,0,-1} although I don't know in which order (Depends ont he order of declaration of the "sides".

 

I think you may have to declare the normal mode to "Per Primitive" for this to work.

 

PS here are the normals I got working with your example

 

Mesh normals.png

Message 4 of 5
(2,487 Views)

Ok, that seems to work!

 

Thank you very much for your help.

0 Kudos
Message 5 of 5
(2,461 Views)