Problems with getNormal function

Hello Everyone!

I am trying to export vertex normals of objects into a simple custom ASCII format.

Some relevant parts of the code:

> mesh = snapshotAsMesh objects[idx]
> faceCount = getNumFaces mesh
>
> for idx = 1 to faceCount do
> (
> coord_face = getFace mesh idx
> for vidx = 1 to 3 do
> (
> vector = getNormal mesh coord_face[vidx]
> format " n % % %" vector[1] vector[2] vector[3] to:file
> )
> )

When I use my script to export the vertex normals of a cube I get strange results:

> // triangle 1
> v -5.0 -5.0 -5.0 n 0.0 0.0 -2.0
> v -5.0 5.0 -5.0 n 0.0 0.0 -1.0
> v 5.0 5.0 -5.0 n 0.0 0.0 -2.0
> // triangle 2
> v 5.0 5.0 -5.0 n 0.0 0.0 -2.0
> v 5.0 -5.0 -5.0 n 0.0 0.0 -1.0
> v -5.0 -5.0 -5.0 n 0.0 0.0 -2.0
> // triangle 3
> v -5.0 -5.0 5.0 n 0.0 0.0 2.0
> v 5.0 -5.0 5.0 n 0.0 0.0 1.0
> v 5.0 5.0 5.0 n 0.0 0.0 2.0

<and so on..>

I also tried to export face normals and they were perfectly OK.

Am I doing something wrong or is the internal vertex normal cache broken somehow?

Anybody ever had similar problems with normals?

Thx in advance for any comments!

Martin

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
madman97's picture

Hi all!   I have the same

Hi all!

 

I have the same problem. I think it has something to do with smoothing groups???

When I create a simple Box in 3d max and convert it to editable mesh and i write this kind of script:

 

t=snapshotasmesh $

for i=1 to t.numverts do (print (getnormal t i))

 

I get these results (quite stupid): 

[0,0,-1.5708]
[0,0,-1.5708]
[0,0,-1.5708]
[0,0,-1.5708]
[0,0,1.5708]
[0,0,1.5708]
[0,0,1.5708]
[0,0,1.5708]

 

I'm sure, that i have to use face normal in this case (with getFaceNormal function), but I don't know how to check, when should I use first or second function, i.e. when to use vertex normals or face normals.

 

 

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.