View Full Version : Check face for texture values
06-01-2008, 12:42 AM
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...
06-01-2008, 02:24 AM
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...
1. Get the faces for a given mesh
2. Find the corresponding TFace
3. Get the corresponding TVerts
4. For each of those, find the corresponding pixel in the bitmap for the given UV values (in the TVert data)
5. 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 :)
06-01-2008, 11:10 PM
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... :(
06-01-2008, 11:10 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.
vBulletin v3.0.5, Copyright ©2000-2013, Jelsoft Enterprises Ltd.