[Closed] Check face for texture values
has anyone seen a script (or know an easier way) to check whether a face is all transparent (it will have a bitmaptexture for the alpha and on the given face all pixel values would be 0) and then delete it? I’ve been trying to use volume select set to texture but its pretty hit and miss…
I’m gonna go ahead and say that there’s no easy way
The volume select is likely to be hit-or-miss for the same reason that a basic script would be hit-or-miss.
If you were to do this by script, you would have to…
- Get the faces for a given mesh
- Find the corresponding TFace
- Get the corresponding TVerts
- For each of those, find the corresponding pixel in the bitmap for the given UV values (in the TVert data)
- Read that pixel.
Problem is – just because each 3 pixels may be 100% transparent, that doesn’t mean that the entire face is transparent. There could very well be a fully opaque pixel right in the middle, and you wouldn’t know. That’s probably what’s bugging out volume select as well.
To extend the above to a working item, you would have to read -all- pixels within the triangle defined by the UV -> XY coordinates, and check if -all- of them are transparent.
It’s doable, but not as easy as just steps 1-5 above The ‘math’ topic in this forum has a bunch of line and triangle functions that would certainly help if your trig is rusty.
I’m sure there’s a simpler method – just can’t think of one at the moment that wouldn’t just cause other problems
Cheers Richard,
I figured that might be the case – Barycentric coordinates, here I come! whee, wish I had listened more in Maths back in the day – my teachers told me I would need it too…