Beispiel #1
0
    def draw_model(self, model):

        # gl.glLoadIdentity()
        gl.glPushMatrix()

        # sets the color
        gl.glColor4f(*model.color)

        # sets the position
        gl.glTranslatef(model.x - self.cx, model.y - self.cy, model.z - self.cz)

        # sets the rotation
        gl.glRotatef(model.rx, 1, 0, 0)
        gl.glRotatef(model.ry, 0, 1, 0)
        gl.glRotatef(model.rz, 0, 0, 1)

        # sets the scale
        gl.glScalef(model.scale, model.scale, model.scale)

        # draws the quads
        pyglet.graphics.draw_indexed(len(model.vertices) // 3, gl.GL_QUADS, model.quad_indices,
                                     ('v3f', model.vertices))

        # draws the triangles
        pyglet.graphics.draw_indexed(len(model.vertices) // 3, gl.GL_TRIANGLES, model.triangle_indices,
                                     ('v3f', model.vertices))

        gl.glPopMatrix()
Beispiel #2
0
 def draw_ground_line(self, model):
     gl.glPolygonMode(gl.GL_FRONT_AND_BACK, gl.GL_FILL)
     gl.glColor4f(*ground_line)
     pyglet.graphics.draw(
         2, pyglet.gl.GL_LINES,
         ('v3f', (model.x - self.cx, model.y - self.cy, model.z - self.cz,
                  model.x - self.cx, -self.cy, model.z - self.cz)))
Beispiel #3
0
    def draw(self):
        gl.glLoadIdentity()
        gl.glTranslatef(self.x, self.y, self.z)
        gl.glRotatef(self.rx, 1, 0, 0)
        gl.glRotatef(self.ry, 0, 1, 0)
        gl.glRotatef(self.rz, 0, 0, 1)

        # sets the color
        gl.glColor4f(*self.color)

        for facet in self.facets:
            facet.draw()
Beispiel #4
0
def circle(x, y, radius, color):
    iterations = 20
    s = sin(2*pi / iterations)
    c = cos(2*pi / iterations)

    dx, dy = radius, 0

    glColor4f(*color)
    glBegin(GL_TRIANGLE_FAN)
    glVertex2f(x, y)
    for i in range(iterations+1):
        glVertex2f(x+dx, y+dy)
        dx, dy = (dx*c - dy*s), (dy*c + dx*s)
    glEnd()
    def draw(self):

        gl.glPushMatrix()
        # sets the position
        gl.glTranslatef(self.x, self.y, self.z)

        # sets the rotation
        gl.glRotatef(self.rx, 1, 0, 0)
        gl.glRotatef(self.ry, 0, 1, 0)
        gl.glRotatef(self.rz, 0, 0, 1)

        # sets the color
        gl.glColor4f(*self.color)

        # draw primitives with batch or vertex_list
        #        batch=pyglet.graphics.Batch();
        #        vertex_list=batch.add(len(self.vertices) // 3,gl.GL_QUADS,None,('v3f', self.vertices));
        #        batch.draw();

        #        # draw by texture rendering
        if len(self.text_indices) > 0:
            gl.glPolygonMode(gl.GL_FRONT_AND_BACK, gl.GL_FILL)
            print("text mode!")
            self.vertex_list.draw(gl.GL_TRIANGLES)

        # draw by wire-frame mode
        else:
            # sets wire-frame mode
            gl.glPolygonMode(gl.GL_FRONT_AND_BACK, gl.GL_LINE)
            # draws the quads
            pyglet.graphics.draw_indexed(
                len(self.vertices) // 3, gl.GL_QUADS, self.quad_indices,
                ('v3f', self.vertices))
            # draws the triangles
            pyglet.graphics.draw_indexed(
                len(self.vertices) // 3, gl.GL_TRIANGLES,
                self.triangle_indices, ('v3f', self.vertices))
        gl.glPopMatrix()
Beispiel #6
0
    def draw(self):
        gl.glLoadIdentity()

        # sets the position
        gl.glTranslatef(self.x, self.y, self.z)

        # sets the rotation
        gl.glRotatef(self.rx, 1, 0, 0)
        gl.glRotatef(self.ry, 0, 1, 0)
        gl.glRotatef(self.rz, 0, 0, 1)

        # sets the color
        gl.glColor4f(*self.color)

        # draws the quads
        pyglet.graphics.draw_indexed(
            len(self.vertices) / 3, gl.GL_QUADS, self.quad_indices,
            ('v3f', self.vertices))

        # draws the triangles
        pyglet.graphics.draw_indexed(
            len(self.vertices) / 3, gl.GL_TRIANGLES, self.triangle_indices,
            ('v3f', self.vertices))
Beispiel #7
0
 def draw_axes():
     """
     Draw the XYZ axes
     """
     d = 1000
     gl.glPolygonMode(gl.GL_FRONT_AND_BACK, gl.GL_FILL)
     gl.glColor4f(*red)
     pyglet.graphics.draw(2, pyglet.gl.GL_LINES, ('v3f', (0, 0, 0,  d, 0, 0)))
     gl.glColor4f(*green)
     pyglet.graphics.draw(2, pyglet.gl.GL_LINES, ('v3f', (0, 0, 0,  0, d, 0)))
     gl.glColor4f(*blue)
     pyglet.graphics.draw(2, pyglet.gl.GL_LINES, ('v3f', (0, 0, 0,  0, 0, d)))
Beispiel #8
0
 def draw(self):
     #pass
     gl.glColor4f(*point_color)
     gl.glPointSize(5)
     pyglet.graphics.draw(
         len(self.points) // 3, gl.GL_POINTS, ('v3f', self.points))
     if len(self.points) // 3 > 1:
         pyglet.graphics.draw(
             len(self.points) // 3, gl.GL_LINE_STRIP, ('v3f', self.points))
         if self.end:
             gl.glColor4f(*cutting_vector_by_mean_color)
             pyglet.graphics.draw(
                 len(self.cutting_vector_points_by_mean) // 3, gl.GL_LINES,
                 ('v3f', self.cutting_vector_points_by_mean))
         else:
             gl.glColor4f(*cutting_vector_color)
             pyglet.graphics.draw(
                 len(self.cutting_vector_points) // 3, gl.GL_LINES,
                 ('v3f', self.cutting_vector_points))
Beispiel #9
0
    def draw(self):
        self.sprite.draw()

        if configuration.DEBUG:
            glColor4f(1, 0, 0, 1)
            draw(4, GL_POINTS, ("v2i", self.rect.points))