ScriptSpot

Forum topic · General Scripting

auto detect inverted model!

By zahid hasan · 2012-04-17

Description

hi,

i have a problem with mesh normal. like when i attach together a model, sometimes the normal is inverted.i have to add a normal modifier to flip the whole model.
is there a trick to find out if the model is inverted or may be a way to avoid it when attaching them.i was thinking of finding out if most of the face normal are outward or not. please share your idea.thanks

Comments (3)

Reset Negative Object Scale Values

barigazy · 2012-04-23

This is more compact version
fn ResetNegativeScale backToOne:true =
(
if selection.count != 0 do
(
for obj in selection do
(
if backToOne != true then
(
local ss = obj.scale
if (ss.x < 0 or ss.y < 0 or ss.z < 0) do (obj.scale = point3 (abs ss.x) (abs ss.y) (abs ss.z))
)
else (if obj.scale != [1,1,1] do obj.scale = [1,1,1])
)
)
)

barigazy · 2012-04-23

Flipped (inverted) faces will also happen when use mirror tool and then assign XForm modifier on it(ResetXForm).
The cause is negative scale value.
I use this before i perform attach or reset xform operation
if $.scale != [1,1,1] do $.scale = [1,1,1]
--or if you don't want to change scale number do this
ss = $.scale
if (ss.x < 0 or ss.y < 0 or ss.z < 0) do
($.scale = point3 (abs ss.x) (abs ss.y) (abs ss.z))

thanks Barigazy . i will

zahid hasan · 2012-04-23

i just checked it and it solved the problem. thanks a lot barigazy.