CMPS 160 -- Lab Assignment 3
Due date:
Midnight, Friday, May 6, 2016
NO LATE SUBMISSIONS ACCEPTED
Objectives:
Picking, mouse clicks, and mouse movements.
Description
-
This lab assignment is mainly about GUI.
The scene is the same as in Prog 2 -- a single object that's centered and scaled.
Using a combination of clicking and mouse click/movements, one can create
a more "direct-manipulation" interface compared to interacting with sliders.
Use Prog2 as your starting point, we will assume the same viewing and lighting conditions.
First, add an option via a toggle button to switch between orthographic and perspective projection.
The slightly tricky part is figuring out reasonable parameters for each projection.
Experiment with what parameters provide a reasonable projection
(object is still centered and not too big nor too small, and is still entirely visible).
It is fine if you hard code these parameters for this program.
-
Second, add the following functionality -- clicking on any part of an object
with the left mouse button will change its color.
This can be as simple as having a gray default color for an object and an assigned color for
the same object. Repeated left mouse clicking on the object will toggle the color between gray
and the assigned color.
Doing a left mouse click on the background will toggle between two background colors --
make sure you pick 2 different discernable colors.
-
Third, right clicking on the object together with mouse movements will cause a rotation
of the object around the y-axis of the viewing coordinate frame.
Note that this is the vertical axis of a canonical viewing coordinate system.
Moving the mouse to the right, while the right mouse is down, will create a positive rotation;
while moving the mouse to the left will create a negative rotation.
Make sure that you rotate the object in-place i.e. rotation is about the world y-axis
and not the object y-axis.
Note that we are only interested in the left-right movements of the mouse.
We don't care about the up-down movements of the mouse.
Here's an example
that might be helpful although it does more than what's
needed for this task.
-
Fourth, clicking with the middle button/wheel and rolling the wheel on the object
will change the scale of the object.
Rolling the wheel up or forwards will increase the size of the object;
while rolling the wheel down or backwards will decrease the size of the object.
Make sure that the object is scaled (in place) with respect to the origin.
Also watch out for the range of values for scaling.
Pick a range e.g. [0.1 .. 2.0] for the scale factor.
Scaling is uniform in all 3 dimensions.
-
Note that scaling and rotation can be done in any order and the results should be cumulative.
For example, allow the user rotate an object, scale it, rotate again, scale again, etc.
Best way to think about this is that one is not modifying any object coordinates.
Rather, one is modifying the composite transformation matrix to be applied to the object coordinates.
Make sure you don't have a matrix with zero scale anywhere along the way.
-
Right click and middle click on the background does not do anything.
References:
The following references may be useful.
-
Chapter 10 of Matsuda/Lea book, and section 7.14 of Angel/Shreiner book.
-
mouse events
Grading:
5 header blocks and proper documentation/comments
10 toggle button for ortho vs perspective projection
20 object picking changes object color
5 background picking changes background color
10 no actions for middle and right clicks on background
15 right click and mouse movement for rotation (only)
15 middle click and mouse movement for scaling (only)
20 any combination of right and middle clicks on the object and mouse movement
-20 submitting materials that are not needed e.g. copies of materials from lib,
copies of coor/poly files, etc. [Ok to submit a README file]
-20 not following instructions posted on class url and/or piazza
-20 does not run when html file is clicked; requires grader to fix code to make it run.
XXX more may be added here
Please include a README file if your code requires "special handling"
e.g. it works only for certain object(s), it takes 20 sec for a pick
to be detected, it works only on chrome on a mac, etc. -- no points
are taken off for these, but will help the grader know what to expect
vs thinking that you have a non-functional code.
Who graded your assignment:
David: aassi - dstansbe
Daniel:dtra24 - kevylet
Joseph: kmccotte - nnakano
John (Andy): nshariat - zpeterse
Submission:
Your lab assignment should be contained in two files: an index.html file and
Picking.js.
A README file can be included if appropriate.
Put both of these in a folder called lab3.
Do not include any of the object data files from the class repository.
Zip up lab3 before submitting.
Submission must be done using the "submit" command from unix.ic.ucsc.edu
- submit cmps160-ap.s16 lab3 lab3.zip
Last modified
Monday, 09-May-2016 19:18:37 PDT.