Purpose
Learn how to use affine transformations to position objects in 3-space.
Resources
- OpenGL Transformations and Matrices — moving, scaling, and rotating objects.
- OpenGL Shading — lighting the scene.
- GLFW Input Handling — adding keyboard inputs.
- GLM — convenient OpenGL mathematics library.
- GLSL Data Types — useful for shader programming.
Set Up
- Use one of: OpenGL or WebGL.
- For OpenGL, use the supplied code base.
- For WebGL, starter code is not provided.
Task 1: Grid (5 points)
Draw an integer grid on the Y = 0 plane for the rectangle from (-5, 0, -5) to (+5, 0, +5).
Draw the positive portion of each axis, with length 5:
- X axis: red
- Y axis: green
- Z axis: blue
Task 2: Camera Rotations (5 points)
- Use perspective projection.
- Place the camera so that you can see the whole scene. Use
glm::LookAtto generate the View matrix. - Press C to select the camera.
- Use ← and → to move the camera along the blue circle parallel to the equator.
- Use ↑ and ↓ to 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 (25 points)
The robot arm consists of the following parts:
- Base: truncated tetrahedron placed on the X–Z plane.
- Arm 1: rectangular box emanating from and hinged at the center of the base.
- Joint: dodecahedron of appropriate radius at the other end of Arm 1.
- Arm 2: cylinder connected to the center of the joint.
Geometry and models
- Create triangulated objects in
.objformat, for example by using Blender. - Hint: generate correct normals for later use. Place the object origin to serve as pivot center (for example the center of the bottom circle of the cylinder)
- To load
.objfiles, use tinyobjloader or similar or adjust the supplied OBJ loader:bool loadOBJ( const char *path, std::vector<...>& out_vertices, std::vector<...>& out_uvs, std::vector<...>& out_normals, std::vector<...>& out_indices )
What to Submit
- Your modified source files — CPP, shader, HTML, OBJ, as appropriate. File paths used to load models must be relative to the source directory; do not use absolute paths specific to your computer.
- A link to a screen capture of your running program showcasing the implementation of all tasks, using Recordit or a similar screen-recording tool. List the tasks in order and demonstrate each task, or state that you did not implement it and briefly explain why.