[Closed] Detecting overlaping polys(backfaces)?
Ok im trying to detect proper backface culling, if there is a polygon in the way blocking another it want to find that hidden poly.
How is the best wa to do this?
Ive already used the face normal and ray casting in max to remove backfaces “max style” now i need to get those polys hiding behind other objects…
Cheers
Backface culling means to cull the backfacing polygons, that is, those polygons whose normal faces away from the camera. You can simply test that checking the dot product of the polygon normal with the camera’s viewing vector (cam.target – cam.pos). The result of the dot product of the (normalized) vectors is the cos of the angle they form. So if the dot product is negative the polygon is front-facing, if it’s positive the polygon is back-facing, and thus culled (not drawed).
example:
view = [0,1,0] --viewing vector
n1 = normalize [1,1,0] -- backfacing polygon normal
n2 = normalize [1,-1,0] -- frontfacing polygon normal
a1 = dot n1 view -- result 0.707107
a2 = dot n2 view -- result -0.707107
radToDeg a1 --this gives the angle of n1 and view in degrees.
To just test the culling you don’t need to normalize the vectors, as you are just testing the sign of the product and that doesn’t change with the length of the vectors. You shouldn’t use it as it involves an sqrt which is slooow…
After all this stuff, i think it’s not what you were looking for, I think that’s something called Occlusion Culling in which, at the moment, i can give you no help. (sorry)
Vaya coñazo que he soltado…