Project 2

Points: 90 (+5 +15 BONUS)

Purpose

Learn how to use affine transformations to position objects in 3-space and illuminate them

Resources

Set Up

Task 1: Grid

Points: 5

Draw an integer grid on the Y=0-plane for the rectangle (-5,0,-5) to (+5,0,+5).
Draw the positive X axis in red, the Y axis in green and the Z axis in blue. Only draw the positive portion of each axis, of length 5.

Task 2: Camera Rotations

Points: 5

  • Use Perspective projection
  • Place the camera so you can see the whole scene: use glm::LookAt to generate the View matrix.
  • Key C selects the camera.
  • Keys and move the camera along the blue circle parallel to the equator.
  • Keys and rotate the camera along the red circle orthogonal to the equator.
  • Choose the "up" direction so the camera always points to the origin.



    Task 3: Draw the robot arm

    Points: 25

    The robot arm consists of the following parts:

  • Create triangulated objects in the .obj format, e.g. by using Blender. Hint: generate correct normals for later use.
  • To load .obj files exported with Blender:
    tinyobjloader (usage best learned by looking at the examples on github) or
    the supplied void loadObject(char* file, glm::vec4 color, Vertex * &out_Vertices, GLushort* &out_Indices, int ObjectId) function to load your objects.
  • Call void createVAOs(Vertex Vertices[], unsigned short Indices[], int ObjectId)
    or find alternative online

    Task 4: Keyboard interaction

    Points: 5+5+5+5+15

    Write the code to move the robot arm, rotate the top, rotate the arms and the pen, and twist the pen using the keyboard, as explained below:

    Indicate the selected part by drawing it in a brighter color.

    Task 5: Light up the scene

    Points: 10

  • Add two lights to the scene.
    For each light, supply position, diffuse color, ambient color and specular color.
    Position the lights near the camera so that one light comes from the left and another one from the right.
    You are free to choose any light colors and positions as long as the scene looks good.
  • Set diffuse and ambient material of the objects to the color of the object. Set specular as a multiple (eg one tenth) of the diffuse color.

    Task 6: Teleporting

    Points: 10

  • When s is pressed have a Platonic solid exit the tip of the stylus, with tangent equal to the stylus axis and derivative in length equal to the stylus length
  • The solid follows an arc according to Newton's law under gravity until it hits the grid. (Hint: use the BB-form of degree 2)
  • Animate the projectile and, on impact, move the robot arm to the impact location.

    BONUS Picking

    Points: 5

    Implement picking for selecting the parts of the robot arm. Use your knowledge acquired in Project 1. You might also find the original tutorial on picking helpful.

    BONUS webGL

    Points: 15

    Implement the project in webGL instead of openGL

    WHAT TO SUBMIT