Notifications
Clear all

[Closed] Vertex normal – not face Normal

I was wondering if anyone knew the best way to get the normal of a vertex in a mesh?
(don’t mean calculate either i.e. taking the face normal and averaging it out etc.)

I realize that you can use the Edit Normal Modifier to query these values from the polygon corners however I wanted to collect the data relative to the correct positional vertex and texture vertex values.

Can I trust the corner indices in the Edit Normal Modifier are the in the same order as the corner indices I query though getTVFace?

Is there one modifier or class I can query to get all these values and guarantee they are correct indices?

8 Replies
2 Replies
(@eric720)
Joined: 10 months ago

Posts: 0

mesh = $box01.mesh
num_faces = mesh.numface
for fi =1 to numFaces do
(
face = getFace mesh fi

for i=1 to 3 do
(
vi = (int face[i])
current_vertex_noraml = normalize (getNormal mesh vi)
)
)

(@eric720)
Joined: 10 months ago

Posts: 0

   mesh = $box01.mesh
   numFaces = mesh.numFaces
   for fi =1 to numFaces do
   (
	face = getFace mesh fi
	for i=1 to 3 do
	(
	 vi = (int face[i])
	 current_vertex_normal = normalize (getNormal mesh vi)
	)
   )

 
 
mesh = $box01.mesh
num_faces = mesh.numface
for fi =1 to numFaces do
(
face = getFace mesh fi
 
for i=1 to 3 do
(
vi = (int face[i])
current_vertex_noraml = normalize (getNormal mesh vi)
)
)
 

Is normalize (getNormal mesh vi) going to give accurate results on a boundary edge between smoothing groups, where one welded vertex has two normals?

1 Reply
(@eric720)
Joined: 10 months ago

Posts: 0

I quotedthe description of maxscript reference:

getNormal <mesh> <vert_index_integer>
[left][left]Returns the normal at the indexed vertex’s position as a point3. The normal is based on the faces that use the vertex and the smoothing groups assigned to those faces.[/left][/left]
[left][left] [/left][/left]
[left][left]I guess it can do the job.[/left][/left]

That’s correct but the data is invalid. The main problem being it will return only ‘n’ number of normals where n = the number of verts in the mesh. However a mesh can have up to n*3 normals (i.e. if every edge was hard). So this method wont give me accurate results as it will average the vert’s normals on hard edges.

1 Reply
(@eric720)
Joined: 10 months ago

Posts: 0

Well, have you ever tried the script in Max? coz the code will get you every vertex normal for each face even the normal on hard edge. So just draw a box and try.

  
   bmesh = $box01.mesh
   numFaces = bmesh.numFaces
   for fi =1 to numFaces do
   (
 face = getFace bmesh fi
 for i=1 to 3 do
 (
  vi = (int face[i])
  current_vertex_normal = normalize (getNormal bmesh vi)
  print current_vertex_normal
 )
   )

The problem lays in edges that are set to hard (edges of smoothing groups).

          Lets say you have two triangles  (A and B) connected along one edge (vertex #2 to #3).
          
          When querying vertex #2 with getNormal you are returned [b]ONE[/b] normal [x,y,z].
          
          However, and this is the core of the problem, you should get returned [b]TWO[/b] normals.
          
          The reason you should get two normals and not one is because since this edge is in effect 'broken' (not smoothed).  This can only be represented numerically with two seperate normals.
          
          This is why when querying the normals through the 'Edit Normals' modifier you must supply the triangle index as well as the corner index to get the normal values. Because, as in the example below, the result for Triangle A corner vertex #2 is very different to Triangle B corner vertex #2.
          
          
          What you are getting in return from getNormal is in fact the average of both normals.  If someone knows how to extract that data from the average I'd love to hear it.

             #4
                /\
                /  \
               /  A \
             #2------#3
               \  B /
                \  /
                \/
             #1
 
 Sorry for the crappy ASCII art!