def draw(self, pipeline_color, pipeline_texture, projection, view):
        # Dibujamos el mono de color con el pipeline_color
        glUseProgram(pipeline_color.shaderProgram)
        glUniformMatrix4fv(
            glGetUniformLocation(pipeline_color.shaderProgram, 'projection'),
            1, GL_TRUE, projection)
        glUniformMatrix4fv(
            glGetUniformLocation(pipeline_color.shaderProgram, 'view'), 1,
            GL_TRUE, view)
        sg.drawSceneGraphNode(sg.findNode(self.model, 'body'), pipeline_color)

        # Dibujamos la cara (texturas)
        if self.show_face:
            glUseProgram(pipeline_texture.shaderProgram)
            glUniformMatrix4fv(
                glGetUniformLocation(pipeline_texture.shaderProgram,
                                     'projection'), 1, GL_TRUE, projection)
            glUniformMatrix4fv(
                glGetUniformLocation(pipeline_texture.shaderProgram, 'view'),
                1, GL_TRUE, view)
            sg.drawSceneGraphNode(sg.findNode(self.model, 'face'),
                                  pipeline_texture)
Exemplo n.º 2
0
    def draw(self, pipeline_color, pipeline_texture, projection, view):
        # Dibujamos el mono de color con el pipeline_color
        glUseProgram(pipeline_color.shaderProgram)
        glUniformMatrix4fv(
            glGetUniformLocation(pipeline_color.shaderProgram, 'projection'),
            1, GL_TRUE, projection)
        glUniformMatrix4fv(
            glGetUniformLocation(pipeline_color.shaderProgram, 'view'), 1,
            GL_TRUE, view)
        sg.drawSceneGraphNode(sg.findNode(self.model, 'body'), pipeline_color)

        # Dibujamos la cara (texturas)
        if self.show_face:
            glUseProgram(pipeline_texture.shaderProgram)
            glUniformMatrix4fv(
                glGetUniformLocation(pipeline_texture.shaderProgram,
                                     'projection'), 1, GL_TRUE, projection)
            glUniformMatrix4fv(
                glGetUniformLocation(pipeline_texture.shaderProgram, 'view'),
                1, GL_TRUE, view)

            if self.face_state == "feliz":
                gpu_head = es.toGPUShape(bs.createTextureCube(self.happy_face),
                                         GL_REPEAT, GL_LINEAR)
                sg.findNode(self.model, 'face').childs = [gpu_head]
                sg.drawSceneGraphNode(sg.findNode(self.model, 'face'),
                                      pipeline_texture)
            elif self.face_state == "triste":
                gpu_head = es.toGPUShape(bs.createTextureCube(self.sad_face),
                                         GL_REPEAT, GL_LINEAR)
                sg.findNode(self.model, 'face').childs = [gpu_head]
                sg.drawSceneGraphNode(sg.findNode(self.model, 'face'),
                                      pipeline_texture)
            else:
                gpu_head = es.toGPUShape(
                    bs.createTextureCube(self.neutral_face), GL_REPEAT,
                    GL_LINEAR)
                sg.findNode(self.model, 'face').childs = [gpu_head]
                sg.drawSceneGraphNode(sg.findNode(self.model, 'face'),
                                      pipeline_texture)
Exemplo n.º 3
0
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)

        # Filling or not the shapes depending on the controller state
        if (controller.fillPolygon):
            glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)
        else:
            glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)

        if controller.showAxis:
            glUniformMatrix4fv(
                glGetUniformLocation(mvcPipeline.shaderProgram, "model"), 1,
                GL_TRUE, tr2.identity())
            mvcPipeline.drawShape(gpuAxis, GL_LINES)

        # Moving the red car and rotating its wheels
        redCarNode.transform = tr2.translate(3 * np.sin(glfw.get_time()), 0,
                                             0.5)
        redWheelRotationNode = sg.findNode(redCarNode, "wheelRotation")
        redWheelRotationNode.transform = tr2.rotationY(-10 * glfw.get_time())

        # Uncomment to print the red car position on every iteration
        #print(sg.findPosition(redCarNode, "car"))

        # Drawing the Car
        sg.drawSceneGraphNode(redCarNode, mvcPipeline)
        sg.drawSceneGraphNode(blueCarNode, mvcPipeline)

        # Once the render is done, buffers are swapped, showing only the complete scene.
        glfw.swap_buffers(window)

    glfw.terminate()
Exemplo n.º 4
0
 def expand_arm(self):
     self.arm_large += 0.1
     sg.findNode(self.model,
                 'arm').transform = tr.scale(0.13, self.arm_large, 0.13)
Exemplo n.º 5
0
        if controller.showAxis:
            glUniformMatrix4fv(
                glGetUniformLocation(mvcPipeline.shaderProgram, "model"), 1,
                GL_TRUE, tr2.identity())
            mvcPipeline.drawShape(gpuAxis, GL_LINES)

        pos = int(len(c1) * t1 / 4) % len(c1)

        phi1 = np.arctan2(c1[pos][1] - c1[pos - 1][1],
                          c1[pos][0] - c1[pos - 1][0])
        # Moving the red car and rotating its ruedas
        redCarNode.transform = np.matmul(
            tr2.translate(0, 0, 0.5), tr2.translate(c1[pos][0], c1[pos][1], 0))
        redCarNode.transform = np.matmul(redCarNode.transform,
                                         tr2.rotationZ(phi1))
        redruedaRotationNode = sg.findNode(redCarNode, "ruedaRotation")
        redruedaRotationNode.transform = tr2.rotationY(10 * glfw.get_time())

        # Drawing redCar using light shader
        glUseProgram(textureShaderProgram.shaderProgram)

        # Setting all uniform shader variables

        glUniformMatrix4fv(
            glGetUniformLocation(textureShaderProgram.shaderProgram,
                                 "projection"), 1, GL_TRUE, projection)
        glUniformMatrix4fv(
            glGetUniformLocation(textureShaderProgram.shaderProgram, "view"),
            1, GL_TRUE, normal_view)

        sg.drawSceneGraphNode(redCarNode, textureShaderProgram)