예제 #1
0
def process(hoxlist, getgeom, drawpiece,withstyle=True):
    glPushMatrix()
    try:
        for h in hoxlist:
            if not h: continue  # all nothings are NOOPs
            if type(h) is tuple:
                op = h[0]
                if op == DRAW or (op == STYLE and withstyle):
                    drawpiece(h[1])
                elif op == MOVE:
                    try:    #debug
                        op,name,axis,mult = h
                    except ValueError:  #debug
                        print h #debug
                        raise   #debug
                    t = getgeom(name)
                    if not t: continue  # skip the rest if zero movement
                    v = [0.0,0.0,0.0]
                    v[axis] = t * mult
                    glTranslatef(*v)
                elif op == ROT:
                    try:    #debug
                        op,name,axis,mult = h
                    except ValueError:  #debug
                        print h #debug
                        raise   #debug
                    a = getgeom(name)
                    if not a: continue  # skip the rest if zero rotation
                    v = [0.0,0.0,0.0]
                    v[axis] = 1.0
                    glRotatef(a * mult,*v)
            else:   # recurse into sub-list
                process(h,getgeom,drawpiece,withstyle)
    finally:
        glPopMatrix()   # GOT to do this no matter what!
예제 #2
0
def process(hoxlist, getgeom, drawpiece, withstyle=True):
    glPushMatrix()
    try:
        for h in hoxlist:
            if not h: continue  # all nothings are NOOPs
            if type(h) is tuple:
                op = h[0]
                if op == DRAW or (op == STYLE and withstyle):
                    drawpiece(h[1])
                elif op == MOVE:
                    try:  #debug
                        op, name, axis, mult = h
                    except ValueError:  #debug
                        print h  #debug
                        raise  #debug
                    t = getgeom(name)
                    if not t: continue  # skip the rest if zero movement
                    v = [0.0, 0.0, 0.0]
                    v[axis] = t * mult
                    glTranslatef(*v)
                elif op == ROT:
                    try:  #debug
                        op, name, axis, mult = h
                    except ValueError:  #debug
                        print h  #debug
                        raise  #debug
                    a = getgeom(name)
                    if not a: continue  # skip the rest if zero rotation
                    v = [0.0, 0.0, 0.0]
                    v[axis] = 1.0
                    glRotatef(a * mult, *v)
            else:  # recurse into sub-list
                process(h, getgeom, drawpiece, withstyle)
    finally:
        glPopMatrix()  # GOT to do this no matter what!
예제 #3
0
 def setup_geom(self):
     """Default setup_geom is translation to pos, rotation by angle"""
     pos = self.pos
     angle = self.angle
     glPushMatrix()
     glTranslatef(*pos)
     if angle:
         glRotatef(angle,0,0,1.0)
예제 #4
0
 def setup_geom(self):
     """Default setup_geom is translation to pos, rotation by angle"""
     pos = self.pos
     angle = self.angle
     glPushMatrix()
     glTranslatef(*pos)
     if angle:
         glRotatef(angle, 0, 0, 1.0)