I'm trying to implement depth ordering of surfaces and points but I'm unsure how to do it. I have a Point class which basically contains x,y,z coordinates and these are used to define the center point of circles, the ends of lines and the corners of surfaces (tris and quads) so we have:
class Point(object):
def __init__(self, x, y z):
self.x = x
self.y = y
self.z = z
class Circle(object):
def __init__(self, center, radius):
#center is a point
self.point_array = [center]
self.radius = radius
class Line(object):
def __init__(self, pos1, pos2):
#pos1, pos2 are points
self.point_array = [pos1, pos2]
class Tri(object):
def __init__(self, pos1, pos2, pos3):
#pos's are Points
self.point_array = [pos1, pos2, pos3]
class Quad(object):
def __init__(self, pos1, pos2, pos3, pos4):
#you get the idea by now...
self.point_array = [point1, point2, point3, point4]
Now I'm culling the ones not visible and appending the objects to a list to the draw to the screen. What I need to do now is sort the list of objects by each objects lowest z-coordinate but I'm unsure how to go about this.
Pointobjects in your list to sort, or onlyQuad,Tri,LineandCircleobjects?