I have a question about z-sorting, I have made couple different working versions of it according to Flash and Math, and couple other tutorials from different sites.
Everything works great until one of the polygons is much bigger than the other, at that point even that smaller blue polygon is still in reality in front of the bigger red one, in flash it is rendered behind it because it’s z-value is actually larger at situation described below. Because it might be difficult to imagine, I have rendered an example in 3dsmax (which actually renders it Correctly) in flash my blue square is not visible at this rotations (both squares have rotation pivot point in 0,0,0 but the blue one is also translated to: x=20, y=0, z=10, so when both are rotated by 45deg they appear exactly as on picture.
z-sorting function is very simple it adds up all z values of each of the four vertexes for each polygon, then it is sorted so the highest value is rendered first then lower one.
below there are z positions of both of the polys.
red square all vertex z position add to:
35.355 + 35.355 + (-35.355) + (-35.355) = 0
blue small squre z positions add to:
12.374 + 12.374 + 1.768 + 1.768 = 28.284