Pages

Wednesday, December 22, 2010

Select objects with missing UV's

Prior to rendering or exporting to a game engine we need to see which objects will cause problems because of missing UV's. Louis Marcoux offer video tutorial on how to write script for that purpose.

Marcoux script (for explanation watch his tutorial):
clearSelection()
for a in objects do
(
TotalUVNumVerts = 0
for b in 1 to (meshop.getNumMaps a.mesh) do
(
UVFound = try(meshop.getNumMapVerts a.mesh b)
catch(results = 0)
TotalUVNumVerts += UVFound
)
if (TotalUVNumVerts == 0) then selectmore a
)

Recently David Stokes share different approach which I like because it is more simple. He use node.mesh.numtverts test to collect objects with missing UV's.

Stokes script:

unmappedObjs = for obj in geometry where
obj.mesh.numtverts == 0 collect obj

I was afford to add an error check filtering improvements to his solution. So, because we call node.mesh (i.e. using TriMesh) we need to filter and exclude objects like particles, targetObject, ... we can filter the objects using getPolygonCount() function:
select (
for obj in geometry where
(getPolygonCount obj)[2] > 0 collect (
if obj.mesh.numtverts == 0 then obj
else dontCollect
)
)

...or filtered with canConvertTo() function:
select (
for obj in geometry where
canConvertTo obj TriMeshGeometry collect (
if obj.mesh.numtverts == 0 then obj
else dontCollect
)
)

No comments:

Post a Comment

Thanks for your comment