The only way I know to find nearby triangles is to simply LOOK IN THE VERTICES ARRAY
OTHER THAN LOOKING IN THE VERTICES ARRAY, does anyone know of any lower-level magic in Unity that gives you adjacent or nearby triangles in a running scene? The 1-ring? THUS FOR EXAMPLE…
Perhaps something at the shader level? Perhaps something at the OpenGL level? Does the 3D pipeline “know” this information in some way ? Perhaps something at the physics level?
Does anyone know the answer to this puzzle? Thanks!
#Solution …
I was able to talk with a few people who work at the hardware level of the 3D pipeline. Confirmed that in fact (perhaps surprisingly) the 3D pipeline has absolutely no idea about where any triangles are. End of story. In a word, rendering happens in a vacuum of one triangle. So the answer is very simply NO.
#Shared verts in models…
This question has raised the issue of the representation of verts in 3D models.
There appears to be a common misconception that it is “normal for” models to have shared verts where possible, or that verts “should be shared” or “are always” shared where possible.
This is quite wrong, the sharedness of verts in 3D models is random, and is just an artefact of how the model happened to be made. You definitely cannot rely on verts being shared where possible, in 3D.
I grabbed the basic Unity3D “sphere primitive” and looked at it. (Since a sphere is “smooth everywhere” it’s a good example of a model where you could share vertices!)
It happens to have 339 verts not shared, that, could be shared. I then modified the model to have EVERY vert not-shared where possible, and then modified it again to have EVERY vert shared where possible.
Note that in all three cases, of course the model works exactly the same inside Unity3D or any other 3D graphics process. In 3D, whether or not verts that-could-be-shared, are shared or not, is totally irrelevant.
I produced a complete Unity project which you can download that includes all three models and lets you spin them, etc. Also, if you ever happen to need a sphere model that has NO shared, or ALL shared, verts-that-can-be-shred, the three models are included in the project.
in fact here is the link to the whole Unity project:
http://www.mediafire.com/?29fyhq2sjtrdj3q
Now, this image shows the same model. But this time it has been changed so that there are zero shared verts.
Finally this image shows the same model, but with every vert shared where possible.
Once again here is the link to the whole Unity project:
http://www.mediafire.com/?29fyhq2sjtrdj3q
which also includes the three different meshes (“as seen in unity” “written with all-shared” “written with no-shared”).
The app looks like this…you can spin 'em around and so on (my kids love playing with it! heh)