Example #1
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)))
Example #2
0
        def on_draw():
            # clears the screen with the background color
            gl.glClear(gl.GL_COLOR_BUFFER_BIT)

            # sets wire-frame mode
            gl.glPolygonMode(gl.GL_FRONT_AND_BACK, gl.GL_LINE)

            # draws the current model
            self.current_model.draw()
Example #3
0
 def draw(self):
     gl.glPolygonMode(gl.GL_FRONT_AND_BACK, gl.GL_FILL)
     mesh = DaeMesh(self.dae)
     mesh.draw()
     gl.glPolygonMode(gl.GL_FRONT_AND_BACK, gl.GL_LINE)
     self.draw_simplified(self.dae.geometries[0].primitives[0].vertex,
                          num_divisions=2)
     self.z_max = mesh.max_xyz[2]
     self.z_min = mesh.min_xyz[2]
Example #4
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)))
Example #5
0
    def _model_render(self, model):

        # sets fill mode
        gl.glPolygonMode(gl.GL_FRONT_AND_BACK, gl.GL_FILL)

        # draws the current model
        self._model_draw(model)

        # sets wire-frame mode
        gl.glPolygonMode(gl.GL_FRONT_AND_BACK, gl.GL_LINE)

        # draws the current model
        temp_color = model.color
        model.color = white
        self._model_draw(model)
        model.color = temp_color
Example #6
0
    def render_model(self, model, fill=True, frame=True):

        if fill:
            # sets fill mode
            gl.glPolygonMode(gl.GL_FRONT_AND_BACK, gl.GL_FILL)

            # draws the current model
            self.draw_model(model)

        if frame:
            # sets wire-frame mode
            gl.glPolygonMode(gl.GL_FRONT_AND_BACK, gl.GL_LINE)

            # draws the current model wire-frame
            temp_color = model.color
            model.color = white
            self.draw_model(model)
            model.color = temp_color
    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()
Example #8
0
 def on_resize(width, height):
     gl.glMatrixMode(gl.GL_PROJECTION)
     glu.gluPerspective(90, float(width)/height, 10, 1_000)
     gl.glPolygonMode(gl.GL_FRONT_AND_BACK, gl.GL_LINE)
     gl.glMatrixMode(gl.GL_MODELVIEW)
     return pyglet.event.EVENT_HANDLED