CS 476: Computer Graphics - Camera Viewing Exercise

Graphics content developed by Chris Tralie. Module autograding ecosystem designed by Chris Tralie and Bill Mongan.

Exercise Goals

The goals of this exercise are:
  1. Explore parts of the object-first pipeline in code
  2. Implement camera viewing matrices using homogenous coordinates
Fill in the matrix that moves the world according to where a camera is looking.

Scene

{ "name":"objectfirsttester", "materials":{ "green":{ "ka":[0.0, 0.4, 0.0], "kd":[0.0, 1.0, 0.0], "ks":[0.8, 0.0, 0.0], "shininess":10 }, "grayblueshine":{ "kd":[0.5, 0.5, 0.5], "ka":[0.1, 0.1, 0.1], "ks":[0.0, 0.0, 1.0] }, "yellow":{ "kd":[0.5, 0.5, 0.2], "ka":[0.3, 0.3, 0.0], "ks":[1.0, 1.0, 0.0], "shininess":5 } }, "lights":[ { "pos":[0, 2, 0], "color":[1, 1, 1] } ], "cameras":[ { "pos": [1.3, 4.3, 9], "rot": [0, 0, 0, 1] } ], "children":[ { "transform":[20, 0, 0, 0, 0, 20, 0, 0, 0, 0, 20, 0, 0, 0, 0, 1], "shapes":[ { "type":"mesh", "filename":"../assets/js/ggslac/meshes/square.off", "material":"green" } ] }, { "shapes":[ { "type":"sphere", "radius":0.5, "center":[-3, 0, 3] } ] }, { "transform":[2, 0, 0, -2, 0, 2, 0, 1, 0, 0, 2, 0, 0, 0, 0, 1], "shapes":[ { "type":"mesh", "filename":"../assets/js/ggslac/meshes/homer.off", "material":"yellow" } ] }, { "transform":[1, 0, 0, 3, 0, 0, 1, 2, 0, -1, 0, -1, 0, 0, 0, 1], "shapes":[ { "type":"mesh", "filename":"../assets/js/ggslac/meshes/dinopet.off", "material":"grayblueshine" } ] }, { "transform":[2, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], "shapes":[ { "type":"sphere", "radius":0.5, "center":[0, 0, -10], "material":"green" } ] } ] }

Javscript Code

scene.camera.getMVMatrix = function() { let right = this.right; let up = this.up; let eye = this.pos; let matrix = glMatrix.mat4.create(); // TODO: Fill this in return matrix; }

Enter your Ursinus netid before clicking Check/Submit. This is not your ID number or your email. For example, my netid is ctralie (non Ursinus students can simply enter their name to perform the correctness check, but they won't get an e-mail record or any form of credit)

Netid
Clicking Check/Submit below will check your work and, if it passes, will submit your work automatically. You must be connected to the VPN for submission to be successful! You will receive a copy of your code via e-mail, so you'll know that it was submitted if you receive that e-mail!