[Closed] Getting the multiple normals of each vertex
Hi,
I’m programming an exporter with MaxScript for my homemade games. Usually, Gouraud’s shading is enough to provide a good appearance for many models in games. But for some models (like a mechanical object), it is required more than one normal per vertex to get a good shading. In this case, it’s not nice to calculate the normals in code.
I know 3ds max and gmax can generate these multiple normal, but I don’t know how to get them using MaxScript.
Please, could anybody show me how to get the multiple normals for each vertex? I would be very grateful in seeing a piece of code.
Thanks in advance
Adriano Ribeiro
http://www.adrianojmr.ubbi.com.br
Hi MagicToy, I believe something like this is what you need:
If the object is an Editable Poly:
theVert = 1
theVertFaces = polyop.getFacesUsingVert $.baseobject theVert
theNormals = for i in theVertFaces collect (polyop.getFaceNormal $.baseobject i node:$)
If the object is an Editable Mesh:
theVert = 182
theVertFaces = meshop.getFacesUsingVert $.baseobject theVert
theNormals = for i in theVertFaces collect (getFaceNormal $ i)
Also note that if you instead use getNormal $ theVert on an Editable mesh object, the normal you get from that already takes into account the smoothing that the model has.
cheers,
CML
Thank you very much, Rivendale.
Regarding getNormal:
Please, correct me if I’m wrong, but the getNormal returns the normal (just one) of the vertex, right? Do you mean that just this normal is enough to converse the shading showing in the Max’s viewport?
Sometimes, the vertex shared by two or more faces must have more than one normal to provide a satisfactory Gouraud’s shading.
Consider a single box: If we use only one normal for each vertex, the corners will appear smoothed, what is not desired.
Hey, I edited my previous post for a better way to get it on an Editable mesh.
Yes getNormal returns the combined normals of the surrounding faces, including any smoothing, for one vertex. I would guess you need all the normals in your case though. I don’t really have much experience with what you are doing though.
cheers,
CML
Hiya,
Just a little more infomration.
getnormal returns the face normal, and takes into account smoothing groups. This is usually more than enough information!
meshop.getfacecenter will give you the face center which is where the face normal is.
meshop.getFaceRNormals returns the render normals for the face’s three vertices.
Hope this helps! :>
J.