04-09-2014 09:12 AM
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.
04-09-2014 09:44 AM
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.
04-09-2014 10:31 AM
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!
04-09-2014 11:25 AM - edited 04-09-2014 11:49 AM
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
04-10-2014 03:30 AM
Ok, that seems to work!
Thank you very much for your help.