def render(self): glColor(0, 1, 1) glPushMatrix() glTranslate(*self.p) if self.skel.m < 10.0: glutSolidSphere(0.02, 4, 2) else: glutSolidSphere(0.06, 4, 2) glPopMatrix()
def handle_draw( self ): """draw a teapot """ #print "handle draw 0" glMaterialfv( GL_FRONT, GL_SPECULAR, self.specular ) glMaterialfv( GL_FRONT, GL_SHININESS, self.shininess ) glMaterialfv( GL_FRONT, GL_DIFFUSE, self.diffuse ) if self.teapot: glutSolidTeapot( 10.0 ) else: glutSolidSphere( 10.0, 12, 12 )
def __init__(self, pos, vel, ttl, color): super(BulletEnt, self).__init__(None, 1) self.pos = numpy.array(pos, dtype=float) self.velocity = vel self.speed = numpy.linalg.norm(vel) self.ttl = ttl try: self.dl = bullet_dl[color] except KeyError: self.dl = util.get_displaylist() glNewList(self.dl, GL_COMPILE) glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, color) glutSolidSphere(5, 5, 5) glEndList() bullet_dl[color] = self.dl
def display_scene(curr_moons): glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) glPushMatrix() glMaterialfv(GL_FRONT, GL_DIFFUSE, [1.0, 1.0, 1.0, 1.0]) glTranslatef(0, 0, 0) glutSolidSphere(.2, 60, 20) glPopMatrix() for index, m in enumerate(curr_moons): glPushMatrix() glMaterialfv(GL_FRONT, GL_DIFFUSE, colors[index]) glTranslatef(m.x / 10, m.y / 10, m.z / 10) glutSolidSphere(.1, 60, 20) glPopMatrix() apply_gravity(curr_moons) apply_velocity(curr_moons) glutSwapBuffers()
def draw(self): glPushMatrix() glTranslated(self.pos.x, self.pos.y, self.pos.z) glEnable(GL_LIGHTING) color_r = 0.5 color_g = 0.0 color_b = 0.0 glColor3f(color_r, color_g, color_b) glEnable(GL_COLOR_MATERIAL) glColorMaterial(GL_FRONT, GL_DIFFUSE) #glDisable(GL_TEXTURE_2D) glutSolidSphere(self.radius, 64, 64) glDisable(GL_COLOR_MATERIAL) glDisable(GL_LIGHTING) glPopMatrix()
def draw(self, time, spectrum): if self.hidden: return if time < self.time: self._show_replaced_hits() return self._hide_replaced_hits() # color = (1.0, 1.0-self.time/2000.0, self.time/2000.0) color = spectrum(self.time, self) glPushMatrix() glTranslated(self.x, self.y, self.z) glColor3f(*color) # glEnable(GL_COLOR_MATERIAL) # glColorMaterial(GL_FRONT, GL_DIFFUSE) glutSolidSphere(int(1 + np.sqrt(self.tot) * 1.5), 16, 16) # glDisable(GL_COLOR_MATERIAL) glPopMatrix()
def __init__(self, pos, vel, ttl, color): super(BulletEnt, self).__init__( None, 1 ) self.pos = numpy.array(pos, dtype=float) self.velocity = vel self.speed = numpy.linalg.norm(vel) # Total time self.ttl = ttl try: self.dl = bullet_dl[color] except KeyError: self.dl = util.get_displaylist() glNewList(self.dl, GL_COMPILE) glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, color) glutSolidSphere(5, 5, 5) glEndList() bullet_dl[color] = self.dl
def render(self): glLineWidth(3.0) glColor(0.7, 0.0, 0.0, 1.0) gltools.glMove([0.0, 0.0, 0.0]) glBegin(GL_LINE_STRIP) for p in [self.p1, self.C, self.p2]: glVertex(p) glEnd() glColor(0.545, 0.000, 0.000, 1.0) gltools.glMove(self.p1) glutSolidSphere(0.03, 4, 2) glColor(1.000, 0.843, 0.000, 1.0) gltools.glMove(self.C) glutSolidSphere(0.03, 4, 2) glColor(0.294, 0.000, 0.510, 1.0) gltools.glMove(self.p2) glutSolidSphere(0.03, 4, 2) glLineWidth(1.0)
def render(self): glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, (1,0,0,0)) glutSolidSphere(5, 5, 5)
def _sphere_(self, radius=1): ''' ''' glutSolidSphere(radius, xseg, yseg)
def run(self): self.show_all() gtk.main() def dump(self, *args): self.bsarea.dump(self.width,self.height) def quit(self, *args): gtk.mainquit() def addSphere((x,y,z),rad,(red,green,blue),nslices,nstacks): glPushMatrix(); glTranslatef(x,y,z,) color = [red,green,blue,1.] glMaterialfv(GL_FRONT,GL_DIFFUSE,color) glutSolidSphere(rad,nslices,nstacks) glPopMatrix() return def addLine((x1,y1,z1),(x2,y2,z2),(red,green,blue)): glDisable(GL_LIGHTING) glColor3f(red,green,blue) glBegin(GL_LINES) glVertex3f(x1,y1,z1) glVertex3f(x2,y2,z2) glEnd() glEnable(GL_LIGHTING) return def addCylinder((x1,y1,z1),(x2,y2,z2),rad,nsides,(red,green,blue)): l = vlength((x1-x2,y1-y2,z1-z2))
def solid_sphere(cls, radius: float, slices: int, stacks: int): glutSolidSphere(radius, slices, stacks)
def render(self): glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, (1, 0, 0, 0)) glutSolidSphere(5, 5, 5)