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)
예제 #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)
예제 #3
0
        elif controller.view == 3:
            view = tr2.lookAt(np.array([10, 5, 1]), np.array([0, 0, 0]),
                              np.array([0, 0, 1]))
        elif controller.view == 4:
            view = tr2.lookAt(np.array([10, 5, 0]), np.array([0, 0, 0]),
                              np.array([0, 0, 1]))
        if controller.showAxis:
            glUseProgram(mvcPipeline.shaderProgram)
            glUniformMatrix4fv(
                glGetUniformLocation(mvcPipeline.shaderProgram, "projection"),
                1, GL_TRUE, projection)
            glUniformMatrix4fv(
                glGetUniformLocation(mvcPipeline.shaderProgram, "view"), 1,
                GL_TRUE, view)
            glUniformMatrix4fv(
                glGetUniformLocation(mvcPipeline.shaderProgram, "model"), 1,
                GL_TRUE, tr2.identity())
            mvcPipeline.drawShape(gpuAxis, GL_LINES)

        glUseProgram(textureShaderProgram.shaderProgram)
        glUniformMatrix4fv(
            glGetUniformLocation(textureShaderProgram.shaderProgram,
                                 "projection"), 1, GL_TRUE, projection)
        glUniformMatrix4fv(
            glGetUniformLocation(textureShaderProgram.shaderProgram, "view"),
            1, GL_TRUE, view)
        #sg.drawSceneGraphNode(mar, textureShaderProgram)
        sg.drawSceneGraphNode(barco, textureShaderProgram)
        #sg.drawSceneGraphNode(isla, mvcPipeline)
        glfw.swap_buffers(window)
    glfw.terminate()
예제 #4
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()
예제 #5
0
        # Moving the spaceship
        shipNode1.transform = tr2.translate(x + 0.8, y + 0.8, 0)
        shipNode1.transform = np.matmul(
            shipNode1.transform, tr2.rotationZ(glfw.get_time() + np.pi / 2))

        shipNode2.transform = tr2.translate(-x + 2, y - 1, 1.5)
        shipNode2.transform = np.matmul(
            shipNode2.transform, tr2.rotationZ(-glfw.get_time() + np.pi / 2))

        # Drawing the scene
        glUseProgram(textureShaderProgram.shaderProgram)
        glUniformMatrix4fv(
            glGetUniformLocation(textureShaderProgram.shaderProgram,
                                 "projection"), 1, GL_TRUE, projection)
        glUniformMatrix4fv(
            glGetUniformLocation(textureShaderProgram.shaderProgram, "view"),
            1, GL_TRUE, normal_view)

        # Box, Earth and deathstar
        sg.drawSceneGraphNode(bgBoxNode, textureShaderProgram)
        sg.drawSceneGraphNode(earthNode, textureShaderProgram)
        sg.drawSceneGraphNode(starNode, textureShaderProgram)

        # Drawing the ship
        sg.drawSceneGraphNode(shipNode1, textureShaderProgram)
        sg.drawSceneGraphNode(shipNode2, textureShaderProgram)

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

    glfw.terminate()
예제 #6
0
 def draw(self, pipeline):
     glUseProgram(pipeline.shaderProgram)
     self.model.transform = tr2.translate(0.7 * self.pos_x,
                                          0.47 * self.pos_y, 0)
     sg.drawSceneGraphNode(self.model, pipeline, "transform")
예제 #7
0
        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)

        # Drawing ground and ricardo using texture shader
        glUseProgram(textureShaderProgram.shaderProgram)
        glUniformMatrix4fv(
            glGetUniformLocation(textureShaderProgram.shaderProgram,
                                 "projection"), 1, GL_TRUE, projection)
        glUniformMatrix4fv(
            glGetUniformLocation(textureShaderProgram.shaderProgram, "view"),
            1, GL_TRUE, normal_view)
        # Drawing ground
        sg.drawSceneGraphNode(groundNode, textureShaderProgram)
        sg.drawSceneGraphNode(baseNode, textureShaderProgram)
        sg.drawSceneGraphNode(ambienteNode, textureShaderProgram)
        sg.drawSceneGraphNode(ambiente1Node, textureShaderProgram)
        sg.drawSceneGraphNode(ambiente2Node, textureShaderProgram)