All pastes #339621 Raw Edit

Untitled

public text v1 · immutable
#339621 ·published 2007-02-04 05:58 UTC
rendered paste body
class RectangularSolid:
    def __init__(self, xw, yw, zw):
        self.coords = xw, yw, zw
    
    def draw(self):
        xw, yw, zw = self.coords
        x = xw/2.
        y = yw/2.
        
        glBegin(GL_QUADS)
        glNormal3f(0,0,1)
        glVertex3f(x, y, 0)
        glVertex3f(-x, y, 0)
        glVertex3f(-x, -y, 0)
        glVertex3f(x, -y, 0)
        
        glNormal3f(1,0,0)
        glVertex3f(x, y, 0)
        glVertex3f(x, -y, 0)
        glVertex3f(x, -y, zw)
        glVertex3f(x, y, zw)
        
        glNormal3f(0,1,0)
        glVertex3f(x, y, 0)
        glVertex3f(x, y, zw)
        glVertex3f(-x, y, zw)
        glVertex3f(-x, y, 0)
        
        glNormal3f(0,-1,0)
        glVertex3f(x, -y, 0)
        glVertex3f(-x, -y, 0)
        glVertex3f(-x, -y, zw)
        glVertex3f(x, -y, zw)
        
        glNormal3f(-1,0,0)
        glVertex3f(-x, y, 0)
        glVertex3f(-x, y, zw)
        glVertex3f(-x, -y, zw)
        glVertex3f(-x, -y, 0)
        
        glNormal3f(0,0,-1)
        glVertex3f(x, y, zw)
        glVertex3f(x, -y, zw)
        glVertex3f(-x, -y, zw)
        glVertex3f(-x, y, zw)
        glEnd()