Exemple #1
0
    def _draw_zero_plane_xy(self, color, texture_id=None, scale=1.0):
        glPushMatrix()
        # glColor3f(*rgb_to_f(*color))
        apply_texture = texture_id is not None
        if apply_texture:
            glColor3f(1, 1, 1)
            glBindTexture(GL_TEXTURE_2D, self._textures[texture_id])
            glTexCoord2f(1.0 * scale, 0.0 * scale)
        else:
            glColor3f(*rgb_to_f(*color))
        glBegin(GL_POLYGON)
        size = self._size / 2

        glVertex3f(size, size, 0)
        if apply_texture:
            glTexCoord2f(1.0 * scale, 1.0 * scale)
        glVertex3f(size, -size, 0)
        if apply_texture:
            glTexCoord2f(0.0 * scale, 1.0 * scale)
        glVertex3f(-size, -size, 0)
        if apply_texture:
            glTexCoord2f(0.0 * scale, 0.0 * scale)
        glVertex3f(-size, size, 0)
        # if texture is not None:
        #     glBindTexture(GL_TEXTURE_2D, )
        glEnd()
        glPopMatrix()
Exemple #2
0
 def _draw_yz_edge(self, color):
     glBegin(GL_POLYGON)
     glColor3f(*rgb_to_f(*color))
     size = self._size / 2
     glVertex3f(size, size, 0.)
     glVertex3f(size, -size, 0.)
     glVertex3f(-size, -size, 0.)
     glVertex3f(-size, size, 0.)
     glEnd()
Exemple #3
0
 def _draw_zero_plane_xy(self, color):
     glPushMatrix()
     glColor3f(*rgb_to_f(*color))
     glBegin(GL_POLYGON)
     size = self._size / 2
     glVertex3f(size, size, 0)
     glVertex3f(size, -size, 0)
     glVertex3f(-size, -size, 0)
     glVertex3f(-size, size, 0)
     glEnd()
     glPopMatrix()
    def draw(self):
        glColor3f(*rgb_to_f(*color.Blue))

        glBegin(GL_POLYGON)

        size = self._size * self.scale / 2
        glVertex2d(self._x + size, self._y + size)
        glVertex2d(self._x + size, self._y - size)
        glVertex2d(self._x - size, self._y - size)
        glVertex2d(self._x - size, self._y + size)

        glEnd()
Exemple #5
0
    def draw(self):
        self._draw_square()

        glPushMatrix()
        glColor3f(*rgb_to_f(*color.Orange))
        glTranslatef(*self._circle_pos, 0)
        glBegin(GL_POLYGON)
        for grad in np.linspace(0, 360, 1000):
            rad = radians(grad)
            x = self._circle_radius * cos(rad)
            y = self._circle_radius * sin(rad)
            glVertex2d(x, y)

        glEnd()
        glPopMatrix()
Exemple #6
0
 def _draw_square(self):
     glPushMatrix()
     glColor3f(*rgb_to_f(*color.Blue))
     glTranslatef(self._square_x, self._square_y, 0)
     glRotatef(self._angle, 0, 0, 1.)
     glBegin(GL_POLYGON)
     size = self._square_size / 2
     square_vertices = [
         (size, size),
         (size, -size),
         (-size, -size),
         (-size, size),
     ]
     for square_vertex in square_vertices:
         glVertex2d(*square_vertex)
     glEnd()
     glPopMatrix()