def axes(length=1.0): ''' Draw x,y,z axes. length -- length of the arrows along axes ''' glPushMatrix() scale(length) # y-axis arrow_2d() # z-axis glPushMatrix() rotate(90.0, 0.0, 0.0) arrow_2d() glPopMatrix() # x-axis glPushMatrix() rotate(0.0, 0.0, -90.0) arrow_2d() glPopMatrix() glPopMatrix()
def cube(*args, **kwargs): glPushMatrix() scale(*args) style = kwargs.get('style', 'wireframe') texture = kwargs.get('texture', None) if texture: style = 'solid' if style == 'wireframe': glPolygonMode(GL_FRONT_AND_BACK, GL_LINE) glDisable(GL_CULL_FACE) _Cube.draw() glPolygonMode(GL_FRONT_AND_BACK, GL_FILL) glEnable(GL_CULL_FACE) elif style == 'solid': if type(texture) == dict: texture['top'].bind() _Cube.draw_top() texture['bottom'].bind() _Cube.draw_bottom() texture['sides'].bind() _Cube.draw_sides() else: if texture: texture.bind() _Cube.draw() if texture: texture.unbind() else: raise Exception('vroom.cube: invalid style value') glPopMatrix()