Hi Cirilo, A "big picture" comment about the normals and normals in VRML:
VRML does not support explicitly (or implicitly? O_o) "normals per-vertex-per-face". Take your file as reference, you stored vertex list, indexes list and "normals per-vertex" (== size of vertex list). So in this case (and it is what VRML supports ) you are storing normals per vertex (with the same size)== size of the vertex list, it means that vertexes will share normals. However, in your model example, that may not be what you want for that model. Since you have top and bottom planes and contours triangles, they are in a completely in opposite directions. If you share this way the vertices it will look stranger because they will get normals that the geometry and your mind is not expecting. For example: http://download.autodesk.com/us/fbx/3ds_max_help/fbx_3dsmax_online/files/WS1a9193826455f5ff-6d855556117c4584e5420a2.htm In the first image, they use same normals per vertex as you, and you see that the cube shading will look strange because the calculated normal of the vertex are pointing in the direction (of the first image) The "per vertex normals" are better used when you have smooth transitions in the model, example: http://4.bp.blogspot.com/-cmhdqSY0yrQ/UJGdjgUeH-I/AAAAAAAABMk/DgLVaeg4LrQ/s1600/vertexLighting.jpg http://www.math.ubc.ca/~cass/courses/m308-03b/projects-03b/drader/images/bezier_patch_example_2.jpg http://static.highend3d.com/tutorialimages/229/nm_high.jpg For your star model the facenormals (or not storing any normals at all) is the best solution. This was in fact an issue while working in VRML / 3d-viewer because some models files come with bad normals or normals per-vertex but they look better flatted (because the nature geometry of the model) So I had implemented and two methods to internal calculate the normals, the regular normal per face and a "smooth" "normal per-vertex-per-face" (that was a slow but good quality algorithm) If you really want to store "normal per-vertex-per-face" in VRML, you have to store all triangles individually. i.e: V1,V2,V3, V4,V5,V6, V7,V8,V9 ... // vertices list for individual triangles 1,2,3, 4,5,6, 7,8,9 ...// indexes of triangles with NO REUSE N1,N2,N3, N4,N5,N6, N7,N8,N9 // normal list for individual vertices of individual triangles In summary: Face normal: good for objects with sharp geometry (cubes.. rectangular shapes.. etc) Per-vertex normals: good for objects that are already smooth by nature (eg the cylinder contours sides, sphere.. it also work good in objects that are very tesselated ==lots of triangles to make approximations or smooth transitions ) Per-vertex-per-face normals: if the object have sharp and smooth parts. My suggestion would be: For VRML, only store face normals (or dont store it and loader/render will calculate it.. no problem) or store per-vertex normals (as you are doing) if it if OK for model. Store "Per-vertex-per-face normals" if you don't mind with the file size, if not, loader plugins can calculate it (from original file vertice / face information) in run time (slow) if you want.. and you may store it the new model in cache. Anyway, this may not be related with the cause of your normal issue. Cheers, Mario 'KammutierSpule' Luzeiro ________________________________________ From: Kicad-developers [[email protected]] on behalf of Cirilo Bernardo [[email protected]] Sent: 16 December 2015 04:21 To: KiCad Developers Subject: [Kicad-developers] help with 3D normals Hi folks, I've added 3D per-vertex normal calculations to the 3D model plugins but I'm calculating bad figures as seen in the *.wrl file below and a corresponding render from view3dscene: https://drive.google.com/file/d/0By_XTJN-s8aXX3pCeFhWbTZNYWs/view?usp=sharing https://drive.google.com/file/d/0By_XTJN-s8aXSmNEMlhOblRlLUE/view?usp=sharing Does anyone have some idea what I could be doing wrong to get such artefacts in the image? I would like to fix my per-vertex normals calculation as it's meant to be a tool to help 3D plugin developers create normals lists in cases where the model does not provide the information. - Cirilo _______________________________________________ Mailing list: https://launchpad.net/~kicad-developers Post to : [email protected] Unsubscribe : https://launchpad.net/~kicad-developers More help : https://help.launchpad.net/ListHelp

