I am making a dynamic 3D API that allows me to create 3D objects using an unlimited number of planes (not taking processor speed into account)… Anyway, It was working fine and it does wire-frame perfectly, but when I tried texturizing it, I had problems sorting the depths of the textures…
I tried many methods, first I looked at the the average “z” value of each plane… This method worked well for simple shapes like cubes… But when I added an extra plane (rectangular) floating above by cube, when I rotated the whole lot, the extra plane’s sorting was inaccurate… This is due to the fact that it is much bigger than the cube and that while parts of it was in front of the cube (z index), the rest was far behind it and thus the average z was lower than some sides of that cube…
Then, I tried to fix this by finding the “angle” of the center-point of each plane from the origin… But that basically did the same thing as the z-sorting method… Then I tried doing it by using the normal of each plane, but that failed also because two planes could face the same direction and yet, one could be in front of the other…
So as a last resort I tried using a combination of all the variables and angles described above… But nothing worked.
Does anyone have any idea how I could go about achieving my goal? Even a link to a good math/programming tutorial would be nice… I haven’t found any good ones yet.
Thanks.