コード例 #1
0
 def render(self, view, renderingSystem):
     modelToWorldTransform = lu.make_mat4_from_zAxis(
         self.position, self.heading, [0.0, 0.0, 1.0])
     rotationTransform = lu.make_rotation_y(self.rotation)
     renderingSystem.drawObjModel(self.model,
                                  modelToWorldTransform * rotationTransform,
                                  view)
コード例 #2
0
 def __make_inner_squares_right(squares):
     rot_tfm = lu.make_rotation_y(math.pi / 2)
     translation = lambda i: lu.make_translation(-2 + i, 0, 0)
     CubeRenderer.__add_inner_squares(squares, rot_tfm, translation,
                                      RIGHT_TRANS)
     translation = lambda i: lu.make_translation(-2 + 2 * SPACING + i, 0, 0)
     CubeRenderer.__add_inner_squares(squares, rot_tfm, translation,
                                      RIGHT_TRANS)
コード例 #3
0
def renderFrame(uiWidth, width, height):
    global g_triangleVerts
    global g_cameraDistance
    global g_cameraYawDeg
    global g_cameraPitchDeg
    global g_yFovDeg

    global g_lightYaw
    global g_lightDistance
    global g_lightPitch

    # This configures the fixed-function transformation from Normalized Device Coordinates (NDC)
    # to the screen (pixels - called 'window coordinates' in OpenGL documentation).
    #   See: https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glViewport.xhtml
    glViewport(0, 0, width, height)
    # Set the colour we want the frame buffer cleared to,
    glClearColor(0.2, 0.5, 0.1, 1.0)
    # Tell OpenGL to clear the render target to the clear values for both depth and colour buffers (depth uses the default)
    glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT)

    viewToClipTransform = lu.make_perspective(g_yFovDeg, width / height, 0.1,
                                              50.0)

    eyePos = lu.Mat3(lu.make_rotation_y(
        math.radians(g_cameraYawDeg))) * lu.Mat3(
            lu.make_rotation_x(
                math.radians(g_cameraPitchDeg))) * [0, 0, g_cameraDistance]
    worldToViewTransform = magic.make_lookAt(eyePos, [0, 0, 0], [0, 1, 0])

    worldToClipTransform = viewToClipTransform * worldToViewTransform

    lightRotation = lu.Mat3(lu.make_rotation_y(
        math.radians(g_lightYaw))) * lu.Mat3(
            lu.make_rotation_x(math.radians(g_lightPitch)))
    lightPosition = [0.02, 0, 0] + lu.vec3(0, 23, 0.2)

    draw_court(worldToClipTransform, lightPosition)
    lu.drawSphere([0.23, -0.45, 0.1, 0], 0.007, [0, 1, 0, 0.5],
                  viewToClipTransform, worldToViewTransform)
    lu.drawSphere(lightPosition, 0.01, [1, 1, 0, 1], viewToClipTransform,
                  worldToViewTransform)
コード例 #4
0
 def __add_left_squares(self, squares):
     translation = lambda row, col: lu.make_translation(
         SPACING, 2 - row + SPACING, -SPACING - 2 + col)
     rot_tfm = lu.make_rotation_y(math.pi / 2)
     CubeRenderer.__add_squares(self.cube.right.squares, squares, rot_tfm,
                                translation)
コード例 #5
0
 def __add_right_squares(self, squares):
     translation = RIGHT_TRANS
     rot_tfm = lu.make_rotation_y(math.pi / 2)
     CubeRenderer.__add_squares(self.cube.right.squares, squares, rot_tfm,
                                translation)