Exemple #1
0
    def render(self):
        #初始化投影矩阵
        self.init_view()

        #启动光照
        glEnable(GL_LIGHTING)
        #清空颜色缓存与深度缓存
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)

        #设置模型视图矩阵,这节课先用单位矩阵就行了。
        glMatrixMode(GL_MODELVIEW)
        glPushMatrix()
        glLoadIdentity()
        glMultMatrixf(self.interaction.trackball.matrix)

        # 存储ModelView矩阵与其逆矩阵之后做坐标系转换用
        currentModelView = numpy.array(glGetFloatv(GL_MODELVIEW_MATRIX))
        self.modelView = numpy.transpose(currentModelView)
        self.inverseModelView = inv(numpy.transpose(currentModelView))
        #渲染场景
        self.scene.render()

        #每次渲染后复位光照状态
        glDisable(GL_LIGHTING)
        glCallList(G_OBJ_PLANE)
        glPopMatrix()
        #把数据刷新到显存上
        glFlush()
Exemple #2
0
    def render(self):
        #init shadow matrix
        self.init_view()

        #open light
        glEnable(GL_LIGHTING)

        #clear color and depth caches
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)

        #set model view matrix(danwei matrix is ok)
        #set trackball's rotate matrix as Modelview
        glMatrixMode(GL_MODELVIEW)
        glPushMatrix()

        #replace now-matrix with hengdeng matrix
        glLoadIdentity()
        glMultMatrixf(self.interaction.trackball.matrix)

        #save Modelview matrix, later change system with anti-matrix
        currentModelView = numpy.array(glGetFloatv(GL_MODELVIEW_MATRIX))
        self.modelView = numpy.transpose(currentModelView)
        self.inverseModelView = inv(numpy.transpose(currentModelView))

        #rend the scene
        self.scene.render()

        #after each shadow , huifu light state
        glDisable(GL_LIGHTING)
        glPopMatrix()

        glFlush()
Exemple #3
0
    def render(self):
        """ The render pass for the scene """
        self.init_view()

        # Enable lighting and color
        glEnable(GL_LIGHTING)

        glClearColor(0.4, 0.4, 0.4, 0.0)
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)

        # Load the modelview matrix from the current state of the trackball
        glMatrixMode(GL_MODELVIEW)
        glPushMatrix()
        glLoadIdentity()
        loc = self.interaction.translation
        glTranslated(-loc[0], -loc[1], -loc[2])
        glMultMatrixf(self.interaction.trackball.matrix)

        # store the inverse of the current modelview.
        currentModelView = numpy.array(glGetFloatv(GL_MODELVIEW_MATRIX))
        self.modelView = numpy.transpose(currentModelView)
        self.inverseModelView = inv(numpy.transpose(currentModelView))

        # render the scene. This will call the render function for each object in the scene
        self.scene.render()

        # draw the grid
        glDisable(GL_LIGHTING)
        glCallList(G_OBJ_PLANE)
        glPopMatrix()

        # flush the buffers so that the scene can be drawn
        glFlush()
Exemple #4
0
    def render(self):
        '''

        '''
        Object3D.render(self)
        if self.matrix is not None:
            glMultMatrixf(self.matrix)
Exemple #5
0
    def render(self):
        """ The render pass for the scene """
        self.init_view()

        # Enable lighting and color
        glEnable(GL_LIGHTING)

        glClearColor(0.4, 0.4, 0.4, 0.0)
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)

        # Load the modelview matrix from the current state of the trackball
        glMatrixMode(GL_MODELVIEW)
        glPushMatrix()
        glLoadIdentity()
        loc = self.interaction.translation
        glTranslated(-loc[0], -loc[1], -loc[2])
        glMultMatrixf(self.interaction.trackball.matrix)

        # store the inverse of the current modelview.
        currentModelView = numpy.array(glGetFloatv(GL_MODELVIEW_MATRIX))
        self.modelView = numpy.transpose(currentModelView)
        self.inverseModelView = inv(numpy.transpose(currentModelView))

        # render the scene. This will call the render function for each object in the scene
        self.scene.render()

        # draw the grid
        glDisable(GL_LIGHTING)
        glCallList(G_OBJ_PLANE)
        glPopMatrix()

        # flush the buffers so that the scene can be drawn
        glFlush()
	def _paintGLBox(self):
		self._position = (2.0, 2.0, 2.0)  # Set fixed translation for now
		glTranslatef(*self._position)	 # Translate Box

		matrix = quaternion_matrix(self._orientation)  # convert quaternion to translation matrix
		glMultMatrixf(matrix)			 # Rotate Box

		drawGrandAxis()
    def _paintGLBox(self):
        self._position = (2.0, 2.0, 2.0)  # Set fixed translation for now
        glTranslatef(*self._position)  # Translate Box

        matrix = quaternion_matrix(
            self._orientation)  # convert quaternion to translation matrix
        glMultMatrixf(matrix)  # Rotate Box

        drawGrandAxis()
Exemple #8
0
 def draw(self):
     #find camera's transform matrix
     m = MathUtil.buildTransformMatrix(self.ent.headLocation,
                                       self.ent.yaw + math.pi,
                                       self.ent.pitch, self.ent.roll)
     glPushMatrix()
     glMultMatrixf(m.toList())
     Graphics.drawPyramid(30, 10, 100.0)
     Graphics.drawWirePyramid(30, 10, 100.0)
     glPopMatrix()
 def loadMatrixSlow(self):
     """ set the texture matrix to: bias * crop * projection * modelView * inverseSceneModelView. """
     glLoadMatrixf( ShadowProjectiveTextureMatrix.biasMatrix )
     glMultMatrixf( self.camera.modelViewProjectionCropMatrix )
     glMultMatrixf( self.sceneCamera.inverseModelViewMatrix )
     
     # compute a normal matrix for the same thing (to transform the normals)
     # Basically, N = ((L)^-1)^-t
     self.normalMatrix = transpose( inv(
             glGetFloatv( GL_TEXTURE_MATRIX ) ) )
Exemple #10
0
	def draw(self):
		#find camera's transform matrix
		m = MathUtil.buildTransformMatrix(self.ent.headLocation,
										  self.ent.yaw + math.pi,
										  self.ent.pitch,
										  self.ent.roll)
		glPushMatrix()
		glMultMatrixf( m.toList() )
		Graphics.drawPyramid(30, 10, 100.0)
		Graphics.drawWirePyramid(30, 10, 100.0)
		glPopMatrix()
Exemple #11
0
    def paintGL(self):
        if self.parent.ipcon == None:
            return

        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)

        # Move Right And Into The Screen
        glLoadIdentity()
        glTranslatef(0.0, 0.0, -5.0)
        glMultMatrixf(self.m)

        glCallList(self.display_list)
Exemple #12
0
def gl_apply_inverse(transformation):
    # OpenGL uses an algebra with row vectors instead of column vectors.
    if not isinstance(transformation, Rotation):
        glTranslate(*(-transformation.t))
    else:
        a = numpy.zeros((4,4), float)
        if isinstance(transformation, Translation):
            a[3,:3] = numpy.dot(-transformation.t, transformation.r)
        if isinstance(transformation, Rotation):
            a[:3,:3] = transformation.r
        a[3,3] = 1
        glMultMatrixf(a)
Exemple #13
0
    def on_draw(self):
        with gx_matrix:
            glMultMatrixf(self.transform_gl)

            self.draw()
            self.controls.dispatch_event('on_draw')

            # use stencil for container
            with gx_stencil:
                drawRectangle((0, 0), size=self.size)
                stencilUse()
                self.container.dispatch_event('on_draw')
Exemple #14
0
def gl_apply_inverse(transformation):
    # OpenGL uses an algebra with row vectors instead of column vectors.
    if not isinstance(transformation, Rotation):
        glTranslate(*(-transformation.t))
    else:
        a = numpy.zeros((4, 4), float)
        if isinstance(transformation, Translation):
            a[3, :3] = numpy.dot(-transformation.t, transformation.r)
        if isinstance(transformation, Rotation):
            a[:3, :3] = transformation.r
        a[3, 3] = 1
        glMultMatrixf(a)
Exemple #15
0
    def on_draw(self):
        with gx_matrix:
            glMultMatrixf(self.transform_gl)

            self.draw()
            self.controls.dispatch_event('on_draw')

            # use stencil for container
            with gx_stencil:
                drawRectangle((0, 0), size=self.size)
                stencilUse()
                self.container.dispatch_event('on_draw')
Exemple #16
0
    def paintGL(self):
        if self.parent.ipcon == None:
            return

        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)

        # Move Right And Into The Screen
        glLoadIdentity()
        glTranslatef(0.0, 0.0, -5.0)
        glMultMatrixf(self.m)

        glCallList(self.display_list)
Exemple #17
0
 def render(self):
     ''' 渲染节点 '''
     glPushMatrix()
     # 实现平移
     glMultMatrixf(numpy.transpose(self.translation_matrix))
     # 实现缩放
     glMultMatrixf(self.scaling_matrix)
     cur_color = color.COLORS[self.color_index]
     # 设置颜色
     glColor3f(cur_color[0], cur_color[1], cur_color[2])
     # 渲染对象模型
     self.render_self()
Exemple #18
0
    def render(self):
        glPushMatrix()
        glMultMatrixf(numpy.transpose(self.translation))
        glMultMatrixf(self.scalemat)
        cur_color = color.COLORS[self.color_index]
        glColor3f(cur_color[0], cur_color[1], cur_color[2])
        if self.selected:  # emit light if the node is selected
            glMaterialfv(GL_FRONT, GL_EMISSION, [0.3, 0.3, 0.3])
        glCallList(self.call_list)
        if self.selected:
            glMaterialfv(GL_FRONT, GL_EMISSION, [0.0, 0.0, 0.0])

        glPopMatrix()
Exemple #19
0
    def render(self):
        glPushMatrix()

        # pingyi shixian
        glMultMatrixf(numpy.transpose(self.translation_matrix))
        # suofang shixian
        glMultMatrixf(self.scaling_matrix)
        cur_color = color.COLORS[self.color_index]
        #set color
        glColor3f(cur_color[0], cur_color[1], cur_color[2])
        # the kind of rend duixiang
        self.render_self()
        glPopMatrix()
Exemple #20
0
    def render(self):
        glPushMatrix()
        glMultMatrixf(numpy.transpose(self.translation))
        glMultMatrixf(self.scalemat)
        cur_color = color.COLORS[self.color_index]
        glColor3f(cur_color[0], cur_color[1], cur_color[2])
        if self.selected:  # emit light if the node is selected
            glMaterialfv(GL_FRONT, GL_EMISSION, [0.3, 0.3, 0.3])
        glCallList(self.call_list)
        if self.selected:
            glMaterialfv(GL_FRONT, GL_EMISSION, [0.0, 0.0, 0.0])

        glPopMatrix()
Exemple #21
0
    def render(self):
        glPushMatrix()
        glMultMatrixf(numpy.transpose(self.translation_matrix))
        glMultMatrixf(self.scaling_matrix)
        cur_color = color.COLORS[self.color_index]
        glColor3f(cur_color[0], cur_color[1], cur_color[2])
        if self.selected:  # 选中的对象会发光
            glMaterialfv(GL_FRONT, GL_EMISSION, [0.3, 0.3, 0.3])

        self.render_self()
        if self.selected:
            glMaterialfv(GL_FRONT, GL_EMISSION, [0.0, 0.0, 0.0])

        glPopMatrix()
    def _paintGLBox(self):
        # FIXME: add user configurable setting to allow use of translation as well
        self._position = (2.0, 2.0, 2.0)  # Set fixed translation for now

        glTranslatef(*self._position)  # Translate Box

        matrix = quaternion_matrix(
            self._orientation)  # convert quaternion to translation matrix
        # tf uses row-major while gl expects column-major
        matrix = matrix.transpose()
        glMultMatrixf(matrix)  # Rotate Box

        glBegin(GL_QUADS)  # Start Drawing The Box

        glColor3f(0.0, 1.0, 0.0)
        glVertex3f(1.0, 1.0, -1.0)  # Top Right Of The Quad (Top)
        glVertex3f(-1.0, 1.0, -1.0)  # Top Left Of The Quad (Top)
        glVertex3f(-1.0, 1.0, 1.0)  # Bottom Left Of The Quad (Top)
        glVertex3f(1.0, 1.0, 1.0)  # Bottom Right Of The Quad (Top)

        glColor3f(0.5, 1.0, 0.5)
        glVertex3f(1.0, -1.0, 1.0)  # Top Right Of The Quad (Bottom)
        glVertex3f(-1.0, -1.0, 1.0)  # Top Left Of The Quad (Bottom)
        glVertex3f(-1.0, -1.0, -1.0)  # Bottom Left Of The Quad (Bottom)
        glVertex3f(1.0, -1.0, -1.0)  # Bottom Right Of The Quad (Bottom)

        glColor3f(0.0, 0.0, 1.0)
        glVertex3f(1.0, 1.0, 1.0)  # Top Right Of The Quad (Front)
        glVertex3f(-1.0, 1.0, 1.0)  # Top Left Of The Quad (Front)
        glVertex3f(-1.0, -1.0, 1.0)  # Bottom Left Of The Quad (Front)
        glVertex3f(1.0, -1.0, 1.0)  # Bottom Right Of The Quad (Front)

        glColor3f(0.5, 0.5, 1.0)
        glVertex3f(1.0, -1.0, -1.0)  # Bottom Left Of The Quad (Back)
        glVertex3f(-1.0, -1.0, -1.0)  # Bottom Right Of The Quad (Back)
        glVertex3f(-1.0, 1.0, -1.0)  # Top Right Of The Quad (Back)
        glVertex3f(1.0, 1.0, -1.0)  # Top Left Of The Quad (Back)

        glColor3f(1.0, 0.5, 0.5)
        glVertex3f(-1.0, 1.0, 1.0)  # Top Right Of The Quad (Left)
        glVertex3f(-1.0, 1.0, -1.0)  # Top Left Of The Quad (Left)
        glVertex3f(-1.0, -1.0, -1.0)  # Bottom Left Of The Quad (Left)
        glVertex3f(-1.0, -1.0, 1.0)  # Bottom Right Of The Quad (Left)

        glColor3f(1.0, 0.0, 0.0)
        glVertex3f(1.0, 1.0, -1.0)  # Top Right Of The Quad (Right)
        glVertex3f(1.0, 1.0, 1.0)  # Top Left Of The Quad (Right)
        glVertex3f(1.0, -1.0, 1.0)  # Bottom Left Of The Quad (Right)
        glVertex3f(1.0, -1.0, -1.0)  # Bottom Right Of The Quad (Right)
        glEnd()  # Done Drawing The Quad
Exemple #23
0
    def draw(self, time, line_width=None):
        if self.hidden:
            return
        time = time * 1e-9
        if time <= self.time:
            return

        pos_start = self.pos + (self.speed * (-self.time) * self.dir)
        path = self.speed * (time - self.time) * self.dir
        if self.length:
            max_path = self.length * self.dir
            if np.linalg.norm(max_path) <= np.linalg.norm(path):
                path = max_path
        pos_end = self.pos + path

        glPushMatrix()
        if line_width:
            glLineWidth(line_width)
        else:
            glLineWidth(self.line_width)
        glColor3f(*self.color)
        glBegin(GL_LINES)
        glVertex3f(*pos_start)
        glVertex3f(*pos_end)
        glEnd()
        glPopMatrix()

        if self.cherenkov_cone_enabled and self.colourist.cherenkov_cone_enabled:

            height = np.linalg.norm(pos_end - pos_start)
            position = pos_end - self.dir * height

            glEnable(GL_LIGHTING)
            glEnable(GL_DEPTH_TEST)
            glShadeModel(GL_FLAT)
            glColor4f(0.0, 0.0, 0.8, 0.3)

            glPushMatrix()
            glTranslated(*position)
            glPushMatrix()

            v = np.array(self.dir)
            glMultMatrixf(transform(v))

            glutSolidCone(0.6691 * height, height, 128, 64)
            glPopMatrix()
            glPopMatrix()

            glDisable(GL_LIGHTING)
Exemple #24
0
    def setup(self):
        """
        render projection and modelview matrix
        :return: None
        """
        self.viewport.setup()

        # setup projection
        glMatrixMode(GL_PROJECTION)
        glLoadIdentity()
        glMultMatrixf(self.projection_matrix.T)

        glMatrixMode(GL_MODELVIEW)
        glLoadIdentity()
        glMultMatrixf(self.inv_modelview_matrix.T)
Exemple #25
0
    def render(self):
        """ renders the item to the screen """
        glPushMatrix()
        glMultMatrixf(numpy.transpose(self.translation_matrix))
        glMultMatrixf(self.scaling_matrix)
        cur_color = color.COLORS[self.color_index]
        glColor3f(cur_color[0], cur_color[1], cur_color[2])
        if self.selected:  # emit light if the node is selected
            glMaterialfv(GL_FRONT, GL_EMISSION, [0.3, 0.3, 0.3])

        self.render_self()

        if self.selected:
            glMaterialfv(GL_FRONT, GL_EMISSION, [0.0, 0.0, 0.0])
        glPopMatrix()
Exemple #26
0
    def render(self):
        """ renders the item to the screen """
        glPushMatrix()
        glMultMatrixf(numpy.transpose(self.translation_matrix))
        glMultMatrixf(self.scaling_matrix)
        cur_color = color.COLORS[self.color_index]
        glColor3f(cur_color[0], cur_color[1], cur_color[2])
        if self.selected:  # emit light if the node is selected
            glMaterialfv(GL_FRONT, GL_EMISSION, [0.3, 0.3, 0.3])

        self.render_self()
        if self.selected:
            glMaterialfv(GL_FRONT, GL_EMISSION, [0.0, 0.0, 0.0])

        glPopMatrix()
Exemple #27
0
    def transform( self, mode=None, translate=1, scale=1, rotate=1 ):
        """For each Transforming node, do OpenGL transform

        Does _not_ push-pop matrices, so do that before
        if you want to save your current matrix.  This method
        is useful primarily for storing paths to, for instance,
        bindable nodes, where you want to be able to rapidly
        transform down to the node, without needing a full
        traversal of the scenegraph.
        """
        matrix = self.transformMatrix( 
            translate=translate, scale=scale, rotate=rotate
        )
        glMultMatrixf( 
            matrix
        )
Exemple #28
0
 def draw(self):
     """Render the link with OpenGL"""
     glPushMatrix()
     glTranslatef(self.pos[0], self.pos[1], self.pos[2])  # move to location
     glMultMatrixf(self.q_rot.transformation_matrix.T
                   )  # then rotate to desired orientation
     glScale(self.size[0], self.size[1],
             self.size[2])  # scale to the desired size
     glColor3f(self.color[0], self.color[1],
               self.color[2])  # set the drawing color
     self.draw_cube()
     glPopMatrix()
     glBegin(GL_LINES)
     glVertex3fv(self.pos + self.get_r())
     glVertex3fv(self.pos + self.get_r() + self.display_force)
     glEnd()
Exemple #29
0
    def on_draw(self, transform, want_camera=False):

        d = self.get_dimensions()

        glViewport(int(d['subwindow_origin_x']), int(d['subwindow_origin_y']),
                   int(d['subwindow_width']), int(d['subwindow_height']))

        glMatrixMode(GL_PROJECTION)
        glLoadIdentity()

        fov_degrees = 45.
        near = 1.0
        far = 100.
        ratio = float(d['subwindow_width']) / float(d['subwindow_height'])
        if d['subwindow_width'] < d['subwindow_height']:
            xt = np.tan(fov_degrees * np.pi / 180. / 2.0) * near
            yt = xt / ratio
            glFrustum(-xt, xt, -yt, yt, near, far)
        else:
            gluPerspective(fov_degrees, ratio, near, far)

        glMatrixMode(GL_MODELVIEW)
        glLoadIdentity()
        glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE)

        glTranslatef(0.0, 0.0, -6.0)
        #        glTranslatef(0.0,0.0,-3.5)

        glPushMatrix()
        glMultMatrixf(transform)
        glColor3f(1.0, 0.75, 0.75)

        if self.autorecenter:
            camera = self.draw_primitives_recentered(want_camera=want_camera)
        else:
            if hasattr(self, 'current_center') and hasattr(
                    self, 'current_scalefactor'):
                camera = self.draw_primitives(
                    scalefactor=self.current_scalefactor,
                    center=self.current_center)
            else:
                camera = self.draw_primitives(want_camera=want_camera)

        glPopMatrix()

        if want_camera:
            return camera
    def _paintGLBox(self):
        # FIXME: add user configurable setting to allow use of translation as well
        self._position = (2.0, 2.0, 2.0)  # Set fixed translation for now

        glTranslatef(*self._position)     # Translate Box

        matrix = quaternion_matrix(self._orientation)  # convert quaternion to translation matrix
        glMultMatrixf(matrix)             # Rotate Box

        glBegin(GL_QUADS)                 # Start Drawing The Box

        glColor3f(0.0, 1.0, 0.0)
        glVertex3f(1.0, 1.0, -1.0)        # Top Right Of The Quad (Top)
        glVertex3f(-1.0, 1.0, -1.0)       # Top Left Of The Quad (Top)
        glVertex3f(-1.0, 1.0, 1.0)        # Bottom Left Of The Quad (Top)
        glVertex3f(1.0, 1.0, 1.0)         # Bottom Right Of The Quad (Top)

        glColor3f(0.5, 1.0, 0.5)
        glVertex3f(1.0, -1.0, 1.0)        # Top Right Of The Quad (Bottom)
        glVertex3f(-1.0, -1.0, 1.0)       # Top Left Of The Quad (Bottom)
        glVertex3f(-1.0, -1.0, -1.0)      # Bottom Left Of The Quad (Bottom)
        glVertex3f(1.0, -1.0, -1.0)       # Bottom Right Of The Quad (Bottom)

        glColor3f(0.0, 0.0, 1.0)
        glVertex3f(1.0, 1.0, 1.0)         # Top Right Of The Quad (Front)
        glVertex3f(-1.0, 1.0, 1.0)        # Top Left Of The Quad (Front)
        glVertex3f(-1.0, -1.0, 1.0)       # Bottom Left Of The Quad (Front)
        glVertex3f(1.0, -1.0, 1.0)        # Bottom Right Of The Quad (Front)

        glColor3f(0.5, 0.5, 1.0)
        glVertex3f(1.0, -1.0, -1.0)       # Bottom Left Of The Quad (Back)
        glVertex3f(-1.0, -1.0, -1.0)      # Bottom Right Of The Quad (Back)
        glVertex3f(-1.0, 1.0, -1.0)       # Top Right Of The Quad (Back)
        glVertex3f(1.0, 1.0, -1.0)        # Top Left Of The Quad (Back)

        glColor3f(1.0, 0.5, 0.5)
        glVertex3f(-1.0, 1.0, 1.0)        # Top Right Of The Quad (Left)
        glVertex3f(-1.0, 1.0, -1.0)       # Top Left Of The Quad (Left)
        glVertex3f(-1.0, -1.0, -1.0)      # Bottom Left Of The Quad (Left)
        glVertex3f(-1.0, -1.0, 1.0)       # Bottom Right Of The Quad (Left)

        glColor3f(1.0, 0.0, 0.0)
        glVertex3f(1.0, 1.0, -1.0)        # Top Right Of The Quad (Right)
        glVertex3f(1.0, 1.0, 1.0)         # Top Left Of The Quad (Right)
        glVertex3f(1.0, -1.0, 1.0)        # Bottom Left Of The Quad (Right)
        glVertex3f(1.0, -1.0, -1.0)       # Bottom Right Of The Quad (Right)
        glEnd()                           # Done Drawing The Quad
Exemple #31
0
    def _paintGLBox(self):
        self._position = (2.0, 2.0, 2.0)  # Set fixed translation for now
        glTranslatef(*self._position)  # Translate Box

        matrix = quaternion_matrix(
            self._orientation)  # convert quaternion to translation matrix
        glMultMatrixf(matrix)  # Rotate Box

        glBegin(GL_QUADS)  # Start Drawing The Box

        glColor3f(0.0, 1.0, 0.0)
        glVertex3f(1.0, 1.0, -1.0)  # Top Right Of The Quad (Top)
        glVertex3f(-1.0, 1.0, -1.0)  # Top Left Of The Quad (Top)
        glVertex3f(-1.0, 1.0, 1.0)  # Bottom Left Of The Quad (Top)
        glVertex3f(1.0, 1.0, 1.0)  # Bottom Right Of The Quad (Top)

        glColor3f(0.5, 1.0, 0.5)
        glVertex3f(1.0, -1.0, 1.0)  # Top Right Of The Quad (Bottom)
        glVertex3f(-1.0, -1.0, 1.0)  # Top Left Of The Quad (Bottom)
        glVertex3f(-1.0, -1.0, -1.0)  # Bottom Left Of The Quad (Bottom)
        glVertex3f(1.0, -1.0, -1.0)  # Bottom Right Of The Quad (Bottom)

        glColor3f(0.0, 0.0, 1.0)
        glVertex3f(1.0, 1.0, 1.0)  # Top Right Of The Quad (Front)
        glVertex3f(-1.0, 1.0, 1.0)  # Top Left Of The Quad (Front)
        glVertex3f(-1.0, -1.0, 1.0)  # Bottom Left Of The Quad (Front)
        glVertex3f(1.0, -1.0, 1.0)  # Bottom Right Of The Quad (Front)

        glColor3f(0.5, 0.5, 1.0)
        glVertex3f(1.0, -1.0, -1.0)  # Bottom Left Of The Quad (Back)
        glVertex3f(-1.0, -1.0, -1.0)  # Bottom Right Of The Quad (Back)
        glVertex3f(-1.0, 1.0, -1.0)  # Top Right Of The Quad (Back)
        glVertex3f(1.0, 1.0, -1.0)  # Top Left Of The Quad (Back)

        glColor3f(1.0, 0.5, 0.5)
        glVertex3f(-1.0, 1.0, 1.0)  # Top Right Of The Quad (Left)
        glVertex3f(-1.0, 1.0, -1.0)  # Top Left Of The Quad (Left)
        glVertex3f(-1.0, -1.0, -1.0)  # Bottom Left Of The Quad (Left)
        glVertex3f(-1.0, -1.0, 1.0)  # Bottom Right Of The Quad (Left)

        glColor3f(1.0, 0.0, 0.0)
        glVertex3f(1.0, 1.0, -1.0)  # Top Right Of The Quad (Right)
        glVertex3f(1.0, 1.0, 1.0)  # Top Left Of The Quad (Right)
        glVertex3f(1.0, -1.0, 1.0)  # Bottom Left Of The Quad (Right)
        glVertex3f(1.0, -1.0, -1.0)  # Bottom Right Of The Quad (Right)
        glEnd()  # Done Drawing The Quad
Exemple #32
0
    def draw(self):
        glMatrixMode(GL_MODELVIEW)
        glPushMatrix()
        glMultMatrixf(self._pose.T)

        glDisable(GL_LIGHTING)

        if self._bounds:
            glColor(*self._color)
            glLineWidth(self._width)
            gldraw.box(self._bounds[0],
                       self._bounds[1],
                       lighting=False,
                       filled=False)

        glEnable(GL_LIGHTING)

        glPopMatrix()
Exemple #33
0
    def render(self):
        """ 渲染节点 """
        glPushMatrix()
        #实现平移
        glMultMatrixf(numpy.transpose(self.translation_matrix))
        #实现缩放
        glMultMatrixf(self.scaling_matrix)
        cur_color = color.COLORS[self.color_index]
        #设置颜色
        glColor3f(cur_color[0], cur_color[1], cur_color[2])
        #渲染对象模型
        #if self.selected:  # 选中的对象会发光
        #   glMaterialfv(GL_FRONT, GL_EMISSION, [0.3, 0.3, 0.3])
        self.render_self()
        #if self.selected:
        #   glMaterialfv(GL_FRONT, GL_EMISSION, [0.0, 0.0, 0.0])

        glPopMatrix()
Exemple #34
0
    def display(self, pose: util.Pose):
        """Displays the precomputed view at a specific pose in 3d space.

        :param pose: Where to display the cube.
        """
        glPushMatrix()

        # TODO if cube_pose.is_accurate is False, render half-translucent?
        #  (This would require using a shader, or having duplicate objects)

        cube_matrix = pose.to_matrix()
        glMultMatrixf(cube_matrix.in_row_order)

        # Cube is drawn slightly larger than the 10mm to 1 cm scale, as the model looks small otherwise
        cube_scale_amt = 10.7
        glScalef(cube_scale_amt, cube_scale_amt, cube_scale_amt)

        self.display_all()
        glPopMatrix()
    def render(self):
        """ The render pass for the scene """
        self.init_view()

        glEnable(GL_LIGHTING)
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)

        # Load the modelview matrix from the current state of the trackball
        glMatrixMode(GL_MODELVIEW)
        glPushMatrix()
        glLoadIdentity()
        tar = self.interaction.LookAttarget;
        self.Camera.target = (tar[0],tar[1],tar[2])
        if self.Camera.CameraMode == 'Trackball':
            loc = self.Camera.position;
            #Camera.position
            glTranslated(-loc[0], -loc[1], -loc[2])
            glMultMatrixf(self.interaction.trackball.matrix)
        elif self.Camera.CameraMode == 'LookAt':
            # embed()
            self.Camera.point()
        elif self.Camera.CameraMode == 'LookAtFollow':
            self.Camera.follow()
            self.Camera.point()
        else:
            glMultMatrixf(self.interaction.trackball.matrix) # by default revert to trackball if mode is set incorrectly

        # store the inverse of the current modelview.
        currentModelView = numpy.array(glGetFloatv(GL_MODELVIEW_MATRIX))
        self.modelView = numpy.transpose(currentModelView)
        self.inverseModelView = inv(numpy.transpose(currentModelView))

        # render the scene. This will call the render function for each object in the scene
        self.scene.render()

        # draw the grid
        glDisable(GL_LIGHTING)
        glCallList(G_OBJ_PLANE)
        glPopMatrix()

        # flush the buffers so that the scene can be drawn
        glFlush()
Exemple #36
0
    def drawItemTree(self, item=None, useItemNames=False):
        """

        :param item:
        :param useItemNames:
        :return:
        """
        if item is None:
            items = [x for x in self.items if x.parentItem() is None]
        else:
            items = item.childItems()
            items.append(item)

        for i in items:
            if not i.visible():
                continue
            if i is item:
                try:
                    glPushAttrib(GL_ALL_ATTRIB_BITS)
                    if useItemNames:
                        glLoadName(i._id)
                        self._itemNames[i._id] = i
                    i.paint()
                except GLError as ex:
                    _log.info("Error while drawing items: {}".format(ex))

                    if CONFIG.debug:
                        raise
                finally:
                    glPopAttrib()
            else:
                glMatrixMode(GL_MODELVIEW)
                glPushMatrix()
                try:
                    tr = i.transform()
                    a = np.array(tr.copyDataTo()).reshape((4, 4))
                    glMultMatrixf(a.transpose())
                    self.drawItemTree(i, useItemNames=useItemNames)
                finally:
                    glMatrixMode(GL_MODELVIEW)
                    glPopMatrix()
Exemple #37
0
    def draw(self):

        glMatrixMode(GL_MODELVIEW)
        glPushMatrix()
        gluLookAt(-2, 2, -6, 0, 0, 0, 0, 1, 0)
        glMultMatrixf(self._identity_mat)
        color = 0
        colors = [(1, 0, 0), (1, 1, 0), (0, 1, 1), (1, 0, 0), (1, 1, 0),
                  (0, 1, 1)]

        for edge in self._edges:
            glColor3f(colors[color][0], colors[color][1], colors[color][2])
            if color > 2:
                Edge.draw_dotted_edge(
                    Edge(self._vertices[edge[0]], self._vertices[edge[1]]))
            else:
                Edge.draw_edge(
                    Edge(self._vertices[edge[0]], self._vertices[edge[1]]))
            color += 1

        glPopMatrix()
Exemple #38
0
    def draw(self):
        '''
        Draw the point cloud.
        '''
        glMatrixMode(GL_MODELVIEW)
        glPushMatrix()
        glMultMatrixf(self._pose.T)

        glDisable(GL_LIGHTING)
        glPointSize(2)

        if self._xyz_vbo:
            # ref: http://stackoverflow.com/questions/16558819/vertex-buffer-objects-in-pyopengl-vertex-index-and-colour
            with self._xyz_vbo:
                glEnableClientState(GL_VERTEX_ARRAY)
                glVertexPointerf(self._xyz_vbo)

                if self._rgb_vbo:
                    # check for dimension match to avoid segmentation faults
                    if len(self._rgb_vbo) != len(self._xyz_vbo):
                        raise RuntimeError(
                            'point cloud XYZ and RGB length mismatch: {} vs {}'
                            .format(len(self._xyz_vbo), len(self._rgb_vbo)))

                    with self._rgb_vbo:
                        # add color
                        glEnableClientState(GL_COLOR_ARRAY)
                        glColorPointerf(self._rgb_vbo)
                        glDrawArrays(GL_POINTS, 0, len(self._xyz_vbo))
                else:
                    # draw without color
                    glDrawArrays(GL_POINTS, 0, len(self._xyz_vbo))

        glDisableClientState(GL_COLOR_ARRAY)
        glDisableClientState(GL_VERTEX_ARRAY)

        glEnable(GL_LIGHTING)

        glPopMatrix()
Exemple #39
0
    def display(self, pose: util.Pose, head_angle: util.Angle,
                lift_position: util.Distance):
        """Displays the precomputed view at a specific pose in 3d space.

        :param pose: Where to display the robot.
        """
        if not self._display_lists:
            return

        robot_matrix = pose.to_matrix()
        head_angle_degrees = head_angle.degrees

        # Get the angle of Vector's lift for rendering - we subtract the angle
        # of the lift in the default pose in the object, and apply the inverse
        # rotation
        sin_angle = (lift_position.distance_mm -
                     LIFT_PIVOT_HEIGHT_MM) / LIFT_ARM_LENGTH_MM
        angle_radians = math.asin(sin_angle)

        lift_angle = -(angle_radians - LIFT_ANGLE_IN_DEFAULT_POSE)
        lift_angle_degrees = math.degrees(lift_angle)

        glPushMatrix()
        glEnable(GL_LIGHTING)
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
        glEnable(GL_BLEND)

        glMultMatrixf(robot_matrix.in_row_order)

        robot_scale_amt = 10.0  # cm to mm
        glScalef(robot_scale_amt, robot_scale_amt, robot_scale_amt)
        glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)

        self._display_vector_body()
        self._display_vector_lift(lift_angle_degrees)
        self._display_vector_head(head_angle_degrees)

        glDisable(GL_LIGHTING)
        glPopMatrix()
    def display_screen(self):
        glDisable(GL_LIGHTING)

        glColor3f(1, 1, 1)

        # Projection
        glMatrixMode(GL_PROJECTION)
        glLoadIdentity()
        gluPerspective (self.fov,float(self.width)/float(self.height),self.clippingplanes[0],self.clippingplanes[1])

        # Initialize ModelView matrix
        glMatrixMode(GL_MODELVIEW)
        glLoadIdentity()

        # View transformation
        mat = se3.homogeneous(self.camera.matrix())
        cols = zip(*mat)
        pack = sum((list(c) for c in cols),[])
        glMultMatrixf(pack)

        labels = dict([ (k, T[1]) for (k, T) in vantage_point_xforms.items() ])
        for (k, v) in labels.items():
            try:
                labels[k] = gluProject(*v)
            except:
                labels[k] = None

        glMatrixMode(GL_PROJECTION)
        glLoadIdentity()
        glOrtho(0,self.width,self.height,0,-1,1);
        glMatrixMode(GL_MODELVIEW)
        glLoadIdentity()

        for (s, p) in labels.items():
            if p:
                glRasterPos3f(p[0], self.height - p[1], p[2])
                gldraw.glutBitmapString(GLUT_BITMAP_HELVETICA_12, s)
Exemple #41
0
def stencilPop():
    '''Pop out the last stack from stencil stack'''
    global __stencil_stack
    glPopAttrib()
    __stencil_stack -= 1

    # remove current stencil stack
    __stencil_stack_dl.pop()
    __stencil_stack_view.pop()

    # replay stencil stack from the start
    # only if it's enabled
    if not glIsEnabled(GL_STENCIL_TEST):
        return

    # clear stencil
    glClearStencil(0)
    glClear(GL_STENCIL_BUFFER_BIT)

    # increment the draw buffer
    glStencilFunc(GL_NEVER, 0x0, 0x0)
    glStencilOp(GL_INCR, GL_INCR, GL_INCR)
    glColorMask(0, 0, 0, 0)

    # replay all gl operation
    for idx in xrange(__stencil_stack):
        dl = __stencil_stack_dl[idx]
        view = __stencil_stack_view[idx]
        with gx_matrix_identity:
            glMultMatrixf(view)
            dl.draw()

    # draw inner content only when stencil match the buffer
    glColorMask(1, 1, 1, 1)
    glStencilFunc(GL_EQUAL, __stencil_stack, __stencil_stack)
    glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP)
    def draw(self, resolution_meter, position, orientation,yaw):

        try:
            self._lock.acquire()
            vehicle_position = (
                position[0] * resolution_meter, position[1] * resolution_meter,
                position[2] * resolution_meter)
            glTranslatef(vehicle_position[0],vehicle_position[1],vehicle_position[2])  # Translate Box

            matrix = quaternion_matrix(orientation)  # convert quaternion to translation matrix
            glMultMatrixf(matrix)  # Rotate Box

            glBegin(GL_TRIANGLES)
            glColor3f(0.0078, 0.2588, 0.39607)
            for tri in self.get_triangles():
                glNormal3f(tri.normal.x, tri.normal.z, tri.normal.y)
                glVertex3f((tri.points[0].x - self.vehicle_size_y) * resolution_meter,
                           (tri.points[0].z - self.vehicle_size_x) * resolution_meter,
                           (tri.points[0].y - self.vehicle_size_z) * resolution_meter)
                glVertex3f((tri.points[1].x - self.vehicle_size_y) * resolution_meter,
                           (tri.points[1].z - self.vehicle_size_x) * resolution_meter,
                           (tri.points[1].y - self.vehicle_size_z) * resolution_meter)
                glVertex3f((tri.points[2].x - self.vehicle_size_y) * resolution_meter,
                           (tri.points[2].z - self.vehicle_size_x) * resolution_meter,
                           (tri.points[2].y - self.vehicle_size_z) * resolution_meter)
            glEnd()

            if self._lock_on_sub:
                modelview_matrix = self.gl_view.get_view_matrix()
                modelview_matrix[3] = [vehicle_position[0] * -1 , vehicle_position[1] * -1, modelview_matrix[3][2], modelview_matrix[3][3]]
                self.gl_view.load_view_matrix(modelview_matrix)

            if self._lock_rotate:
                self.gl_view.rotate_absolute((0,0,1),yaw)
        finally:
                self._lock.release()
Exemple #43
0
    def render(self, local_rot):
        glMatrixMode(GL_MODELVIEW)
        glPushMatrix()
        gluLookAt(-2, 2, -6, 0, 0, 0, 0, 1, 0)
        glMultMatrixf(self._trans_mat)
        glMultMatrixf(self._rotation_mat)

        glPushMatrix()
        self.move_x()
        self.move_y()
        self.move_z()
        glPopMatrix()

        glPushMatrix()
        glLoadIdentity()
        if local_rot:
            self.rotate_local()
        else:
            self.rotate_global()
        self._rotation_mat = glGetFloatv(GL_MODELVIEW_MATRIX)
        glPopMatrix()

        self.draw()
        glPopMatrix()
Exemple #44
0
def stencilPop():
    '''Pop out the last stack from stencil stack'''
    global __stencil_stack
    glPopAttrib()
    __stencil_stack -= 1

    # remove current stencil stack
    __stencil_stack_dl.pop()
    __stencil_stack_view.pop()

    # replay stencil stack from the start
    # only if it's enabled
    if not glIsEnabled(GL_STENCIL_TEST):
        return

    # clear stencil
    glClearStencil(0)
    glClear(GL_STENCIL_BUFFER_BIT)

    # increment the draw buffer
    glStencilFunc(GL_NEVER, 0x0, 0x0)
    glStencilOp(GL_INCR, GL_INCR, GL_INCR)
    glColorMask(0, 0, 0, 0)

    # replay all gl operation
    for idx in xrange(__stencil_stack):
        dl = __stencil_stack_dl[idx]
        view = __stencil_stack_view[idx]
        with gx_matrix_identity:
            glMultMatrixf(view)
            dl.draw()

    # draw inner content only when stencil match the buffer
    glColorMask(1, 1, 1, 1)
    glStencilFunc(GL_EQUAL, __stencil_stack, __stencil_stack)
    glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP)
Exemple #45
0
    def render(self):
        glPushMatrix()
        # gltools.render_axis(10)
        # Draw chess board
        gltools.glMove([0.0, -0.01, 0.0])
        # gltools.render_chessboard(10, 20.0)
        gltools.render_floor(20, 40.0)

        # Draw skeleton
        gltools.glMove([0, 0, 0])
        glPushMatrix()
        M_s = [1.0, 0.0, 0.0, 0.0,
               1.0, 0.0, -1.0, 0.0,
               0.0, 0.0, 1.0, 0.0,
               0.0, -0.001, 0.0, 1.0]
        glMultMatrixf(M_s)
        glColor(0.0, 0.0, 0.0, 1.0)
        gl.glEnable(gl.GL_LIGHTING)
        self.skel.render_with_color(0.0, 0.0, 0.0)
        gl.glEnable(gl.GL_LIGHTING)
        glPopMatrix()

        gltools.glMove([0, 0, 0])
        self.skel.render()

        gltools.glMove([0, 0, 0])
        glColor(1, 0, 0)
        # gltools.render_arrow(self.skel.C,
        #                      self.skel.C + 0.2 * self.tip.projected_Cdot())

        # # Draw TIP
        # tip_index = self.history.get_frame()['tip_index']
        # tips = self.tip_controller.tips
        # for i in range(tip_index, len(tips)):
        #     tips[i].render()

        # for c in self.prob.contacts:
        #     c.render()

        # Draw contacts
        gltools.glMove([0, 0, 0])
        # glColor(0.7, 0.0, 0.3)
        # for c in self.history.get_frame()['contacts']:
        #     gltools.render_arrow(c[0:3], c[0:3] - 0.001 * c[3:6])

        if self.history.get_frame()['t'] < 10.0:
            gltools.glMove([0, 0, 0])
            q = self.cfg.saved_target_point
            d = self.cfg.force()
            d[0] = 0.0
            len_d = np.linalg.norm(d)
            d /= len_d
            l = len_d * 0.025 + 0.020

            # d[0] = 0.0
            # len_d = np.linalg.norm(d)
            # d /= len_d
            # len_d /= 60.0
            # l = len_d * 0.025

            p = q - l * d
            # p[0] = q[0]
            # gltools.render_arrow2([0, 0.4, 0], [0, 0.4, 0.4])
            rb = 0.01 * (len_d * 0.025 + 1.0)
            hw = 0.015 * (len_d * 0.05 + 1.0)
            hl = 0.015 * (len_d * 0.05 + 1.0)
            rb *= 0.5
            hw *= 0.5
            # rb *= 2.0
            # hw *= 2.0
            gltools.render_arrow2(p, q, rb, hw, hl)

        glPopMatrix()
Exemple #46
0
    def on_draw(self):
         
        glBlendFunc(GL_SRC_ALPHA, GL_DST_ALPHA)

        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
        glLoadIdentity()
        
        glTranslate(self.translatex, self.translatey, self.depth)
        
        if self.autoRun:
            glRotate(self.rotx,  0, 1, 0)
        
        else:
            # Perform arcball rotation.
            glScale(1,-1,1)
            glMultMatrixf(self.arcball.transform)
            glScale(1,-1,1)
        
        with displayListify("cubeTranslate") as shouldLeave:
            if shouldLeave: raise LeaveWith
                
            # Scale the co-ordinates so that they are correct
            glScale(2/128, 2/128, 2/128)
            
            glColor(0.25, 0.25, 0.25, 1)
            glutWireCube(255)
            
            glTranslate(-128, -128, -128)
        
        with displayListify("allPoints") as shouldLeave:
            if shouldLeave: raise LeaveWith
            
            with SaveMatrix():
                # Flip the co-ordinates and translate upwards
                glScale(1,-1,1)
                glColor(0.25, 0.25, 0.25, 0.5)
                glTranslate(0,-255,0)
                glPointSize(pointSize)
                for dat in reversed(vLists):
                    glTranslate(0., 0., 1./nChunks*255)
                    dat.draw(GL_POINTS)

        with displayListify("axisLabels") as shouldLeave:
            if shouldLeave: raise LeaveWith
        #if True:
            with SaveMatrix():
                glTranslate(128,0,0)
                self.makeLabel("End").draw()
                
                glTranslate(0,0,255)
                self.makeLabel("Beginning").draw()
                
                with SaveMatrix():
                    glTranslate(-128,128,0)
                    glRotate(90,0,0,1)
                    self.makeLabel("Byte 1").draw()
                
                glTranslate(0,255,0)
                self.makeLabel("Byte 2").draw()
        
        with displayListify("fileName") as shouldLeave:
            if shouldLeave: raise LeaveWith
            glLoadIdentity()
            
            with SaveMatrix():
                glColor(1,0,0)
                glTranslate(0,-2.2,-4)
                glScale(1/64, 1/64, 1/64)
                l = self.makeLabel(basename(currentInputFile))
                l.color = (0, 128, 230, 255)
                l.draw()
        
        glTranslate(0,0,-1)
        
        if self.autoRun:
        
            if self.rotx > 360 - 45:
                vlist = vertex_list(4, ('v2i', (-1, -1, 1, -1, 1, 1, -1, 1)))
                glColor(0,0,0,(self.rotx-(360-45))/45)
                vlist.draw(GL_QUADS)
                
            if self.rotx < 45:
                vlist = vertex_list(4, ('v2i', (-1, -1, 1, -1, 1, 1, -1, 1)))
                glColor(0,0,0,1-(self.rotx/45))
                vlist.draw(GL_QUADS)
    def paintGL(self):
        if self.parent.ipcon == None:
            return

        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
        glLoadIdentity()

        # Move Right And Into The Screen
        glTranslatef(0.0, 0.0, -5.0)

        glMultMatrixf(self.m)

        # Draw board
        glColor3f(*self.color_board)
        glColor3f(0.0, 0.0, 0.0)
        self.draw_cuboid(1.0, 1.0, 0.1)

        # Draw USB connector
        glColor3f(0.5, 0.51, 0.58)
        glPushMatrix()
        glTranslatef(0.0, -0.8, 0.2)
        self.draw_cuboid(0.2, 0.25, 0.1)
        glPopMatrix()

        # Draw button right
        glPushMatrix()
        glColor3f(0.5, 0.51, 0.58)
        glTranslatef(0.65, -0.95, 0.125)
        self.draw_cuboid(0.1, 0.075, 0.05)
        glColor3f(0.0, 0.0, 0.0)
        glTranslatef(0.0, -0.075, 0.0)
        self.draw_cuboid(0.05, 0.025, 0.045)
        glPopMatrix()

        # Draw button left
        glPushMatrix()
        glColor3f(0.5, 0.51, 0.58)
        glTranslatef(-0.65, -0.95, 0.125)
        self.draw_cuboid(0.1, 0.075, 0.05)
        glColor3f(0.0, 0.0, 0.0)
        glTranslatef(0.0, -0.075, 0.0)
        self.draw_cuboid(0.05, 0.025, 0.045)
        glPopMatrix()

        # Draw btb left top
        glPushMatrix()
        glColor3f(1.0, 1.0, 1.0)
        glTranslatef(-0.75, 0.0, 0.25)
        self.draw_cuboid(0.13, 0.5, 0.15)
        glPopMatrix()

        # Draw btb right top
        glPushMatrix()
        glColor3f(1.0, 1.0, 1.0)
        glTranslatef(0.75, 0.0, 0.25)
        self.draw_cuboid(0.13, 0.5, 0.15)
        glPopMatrix()

        # Draw btb left bottom
        glPushMatrix()
        glColor3f(1.0, 1.0, 1.0)
        glTranslatef(-0.75, 0.0, -0.2)
        self.draw_cuboid(0.13, 0.5, 0.1)
        glPopMatrix()

        # Draw btb right bottom
        glPushMatrix()
        glColor3f(1.0, 1.0, 1.0)
        glTranslatef(0.75, 0.0, -0.2)
        self.draw_cuboid(0.13, 0.5, 0.1)
        glPopMatrix()

        # Draw bricklet port left
        glPushMatrix()
        glColor3f(1.0, 1.0, 1.0)
        glTranslatef(-0.425, 0.9, -0.125)
        self.draw_cuboid(0.325, 0.1, 0.05)
        glPopMatrix()

        # Draw bricklet port right
        glPushMatrix()
        glColor3f(1.0, 1.0, 1.0)
        glTranslatef(0.425, 0.9, -0.125)
        self.draw_cuboid(0.325, 0.1, 0.05)
        glPopMatrix()

        # Draw Axis
        glPushMatrix()
        glTranslatef(-1.2, -1.2, -0.3)
        glLineWidth(5.0)

        glBegin(GL_LINES)
        glColor3f(1, 0, 0)  # // X axis is red.
        glVertex3fv((0, 0, 0))
        glVertex3fv((2, 0, 0))
        glColor3f(0, 0.5, 0)  # // y axis is green.
        glVertex3fv((0, 0, 0))
        glVertex3fv((0, 2, 0))
        glColor3f(0, 0, 1)  # // z axis is blue.
        glVertex3fv((0, 0, 0))
        glVertex3fv((0, 0, 2))
        glEnd()

        glPopMatrix()
Exemple #48
0
 def on_draw(self):
     if not self.visible:
         return
     with gx_matrix:
         glMultMatrixf(self._transform_gl)
         super(MTScatter, self).on_draw()
Exemple #49
0
 def draw(self):
    cam_inv = gmtl.makeInvert(self.transform)
    glMultMatrixf(getMatrixData(cam_inv))
Exemple #50
0
 def on_draw(self):
     if not self.visible:
         return
     with gx_matrix:
         glMultMatrixf(self._transform_gl)
         super(MTScatter, self).on_draw()
Exemple #51
0
    def paintGL(self):
        if self.parent.ipcon == None:
            return 
    
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
        glLoadIdentity()
        
        # Move Right And Into The Screen
        glTranslatef(0.0, 0.0, -5.0) 

#        glRotatef(self.roll,  0.0, 1.0, 0.0)
#        glRotatef(self.yaw,  0.0, 0.0, 1.0)
#        glRotatef(self.pitch, 1.0, 0.0, 0.0)
        
        glMultMatrixf(self.m)
        
        # draw board
        glColor3f(*self.color_board)
        glColor3f(0.0, 0.0, 0.0)
        self.draw_cuboid(1.0, 1.0, 0.1)
     
        # draw leds
#        self.draw_led(-0.3, 0.7, x)
#        self.draw_led(-0.7, 0.3, y)
#        self.draw_led(-0.3, 0.3, z)
        
        # draw female connector
        #glColor3f(*self.color_connector)
        glColor3f(0.5, 0.51, 0.58)
        glPushMatrix()
#        glTranslatef(0.525, 0.2, -0.7)
#        self.draw_cuboid(0.45, 0.05, 0.2)
        glTranslatef(0.0, -0.9, 0.2)
        self.draw_cuboid(0.2, 0.3, 0.15)
        glPopMatrix()
        

#        glRotatef(0 , 1,0,0);
#        glRotatef(0, 0,1,0);
#        glScalef(0.25, 0.25, 0.25);
        
        
        # Draw Axis
        glPushMatrix();
        glTranslatef(-1.2, -1.2, -0.3);
        glLineWidth(5.0);
        
        glBegin(GL_LINES)
        glColor3f(1,0,0) #// X axis is red.
        glVertex3fv((0,0,0))
        glVertex3fv((2, 0,0))
        glColor3f(0,1,0) #// y axis is green.
        glVertex3fv((0,0,0))
        glVertex3fv((0,2,0))
        glColor3f(0,0,1) #// z axis is blue.
        glVertex3fv((0,0,0))
        glVertex3fv((0,0,2))
        glEnd()
        
        glPopMatrix()
        
        # draw spacer
#        glColor3f(*self.color_connector)
#        glPushMatrix()
#        glTranslatef(-0.7, 0.2, 0.65)
#        self.draw_cuboid(0.2, 0.05, 0.3)
#        glTranslatef(0.0, -0.5, 0.0)
#        self.draw_cuboid(0.2, 0.2, 0.3)
#        glPopMatrix()
        
        # draw pins
#        for pin in self.pins:
#            self.draw_pin(*pin)

        self.swapBuffers()