PDA

View Full Version : Automatically fix face normals


galeru
07-28-2009, 08:54 PM
Hey Guys,

I have looked around the internet everywhere but have not been able to find a solution at all.

So the problem:-

I have a model that has come from sketch up and all of the normals are messed up. Basically if i turn of 2 sided lighting or 2 sided faces then you see the face normal problems. I want to bake in all the lighting to the model once i have done and as you all know this will make the faces come out black.

What i am looking for is a script that will analyse or select normals facing inwards and set them all to be outwards. Alternatively if there was a script that set all of the normals to aim at an object then this could work by making them all face in and then reversing them.

I dont know if this is possible but at the moment i have to do it all manually and its taking too long.

so if anyone has any ideas how to fix face normals that would be a life saver.

Kind Regards

cbamber85
07-29-2009, 08:30 PM
If your model is simple and convex, then the locator aim setup might work ok. Just iterate through all the faces, form a vector between each vertex of the current face and the locator, normalise, and override the current normal with your new one (because MFnMesh uses a per-vertex-per-polygon MVectorArray).

If your model isn't convex (which is probably the case), then you'll have to find the 'wrong' normals by comparison against an initial 'seed' vertex which you know to be right i.e. if a neighbouring vertex normal is greater than 120degs for example then flip it.

CGTalk Moderation
07-29-2009, 08:30 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.