def draw_teapot(): if fill.value: gl.glEnable(gl.GL_LIGHTING) gl.glEnable(gl.GL_DEPTH_TEST) gl.glColor3f(color[0], color[1], color[2]) gl.glPolygonOffset(1, 1) gl.glEnable(gl.GL_POLYGON_OFFSET_FILL) if shape.value == 0: glut.glutSolidCube(1) elif shape.value == 1: glut.glutSolidTorus(0.25, 0.50, 32, 32) else: glut.glutSolidTeapot(.75) gl.glDisable(gl.GL_LIGHTING) gl.glDisable(gl.GL_POLYGON_OFFSET_FILL) gl.glEnable(gl.GL_LINE_SMOOTH) gl.glEnable(gl.GL_BLEND) gl.glDepthMask(gl.GL_FALSE) gl.glColor4f(0, 0, 0, .5) if shape.value == 0: glut.glutWireCube(1) elif shape.value == 1: glut.glutWireTorus(0.25, 0.50, 32, 32) else: glut.glutWireTeapot(.75) gl.glDepthMask(gl.GL_TRUE)
def paintGL(self, p0=0, p1=None, drawOpts=DRAWOPT_DEFAULT): if not self.visible: return is_click = (p1 is not None) if p1 is None: p1 = len(self) if p1 <= p0: return # draw nothing GL.glShadeModel(GL.GL_SMOOTH) GL.glPushMatrix() GL.glMultMatrixf(self.transform) GL.glColor4f(*self.colour) GL.glDisable(GL.GL_BLEND) GL.glEnable(GL.GL_DEPTH_TEST) primType = self.primitiveType.lower() if primType == 'sphere': radius = self.attrs.get('radius', 100.) slices = self.attrs.get('slices', 10) stacks = self.attrs.get('stacks', 10) if self.attrs.get('wire',None): GLUT.glutWireSphere(radius, slices, stacks) else: GLUT.glutSolidSphere(radius, slices, stacks) elif primType == 'cube': size = self.attrs.get('size', 100.) if self.attrs.get('wire',None): GLUT.glutWireCube(size) else: GLUT.glutSolidCube(size) GL.glPopMatrix()
def draw_teapot(): if fill.value: gl.glEnable (gl.GL_LIGHTING) gl.glEnable (gl.GL_DEPTH_TEST) gl.glColor3f(color[0],color[1],color[2]) gl.glPolygonOffset (1, 1) gl.glEnable (gl.GL_POLYGON_OFFSET_FILL) if shape.value == 0: glut.glutSolidCube(1) elif shape.value == 1: glut.glutSolidTorus(0.25, 0.50, 32, 32) else: glut.glutSolidTeapot(.75) gl.glDisable (gl.GL_LIGHTING) gl.glDisable (gl.GL_POLYGON_OFFSET_FILL) gl.glEnable (gl.GL_LINE_SMOOTH) gl.glEnable (gl.GL_BLEND) gl.glDepthMask (gl.GL_FALSE) gl.glColor4f(0,0,0,.5) if shape.value == 0: glut.glutWireCube(1) elif shape.value == 1: glut.glutWireTorus(0.25, 0.50, 32, 32) else: glut.glutWireTeapot(.75) gl.glDepthMask (gl.GL_TRUE)
def render(self, holograma=False): gl.glPushMatrix() gl.glTranslatef(self.x * blockSize, self.y * blockSize, 0.0) if holograma: gl.glColor3f(self.color['r'], self.color['g'], self.color['b']) glut.glutWireCube(blockSize) else: gl.glMaterialfv( gl.GL_FRONT, gl.GL_AMBIENT, [self.color['r'], self.color['g'], self.color['b'], 1.0]) gl.glMaterialfv( gl.GL_FRONT, gl.GL_DIFFUSE, [self.color['r'], self.color['g'], self.color['b'], 1.0]) gl.glMaterialfv( gl.GL_FRONT, gl.GL_SPECULAR, [self.color['r'], self.color['g'], self.color['b'], 1.0]) gl.glMaterialfv(gl.GL_FRONT, gl.GL_SHININESS, 100.0) glut.glutSolidCube(blockSize) gl.glPopMatrix()