Due: Mar. 1, 2020, @ 11:59 PM

Provided Material:

Important Notes

  1. Read the submission instructions carefully! If you are missing some files, but we can still grade, you will lose 20% of the total points. If we cannot grade your work due to missing files, you will receive no credit.
  2. Save your project onto the U: drive, which is your EWS storage, and available across all of the computers in the lab. If you save to the C: drive, your project will only exist on that single computer.
  3. If you use your own machine, make sure you use the version of Unity installed on all of the lab machines to avoid compatibility issues.
  4. To enable autofill in Visual Studio 2019, go to Edit -> Preferences -> External Tools and change the
    External Tools Script Editor from Open File Extension to Visual Studio 2019.

Cameras / VR / Unity

The precise implementation of the user’s view into the Unity world is somewhat complicated due to the interaction with the VR headset. The OVR package provides two prefabs to simplify things. The OVRCameraRig provides only a camera into the world, with minor movement of the camera allowed due to head tracking. The OVRPlayerController acts much like Unity’s default player controller, and adds movement via joystick. The Oculus-specific functionality is provided by the OVRManager script.

You must use either an OVRCameraRig, or a MainCamera object with the OVRManager script attached. We recommend the former for simplicity.

VR Mirror

This part of the MP will teach you how to manipulate a GameObject’s rotation and position.

You must modify the provided scene, so that there is one button that does each of the following actions. The button names are placeholders, and it is up to you to choose something reasonable.

  • Pressing Button 1 must reset the camera position in global coordinates to (0, 0, 0).
  • Pressing Button 2 must invert (i.e. rotate 180 degrees) the user’s view about the \(y\)-axis, so that they are looking in the reverse direction relative to the plane of the room floor.
  • Pressing Button 3 must make the cube-shaped face in the scene either mirror or follow the user’s movements.
  • Pressing Button 4 must quit the game.

Write a script named CameraReset that moves the main camera’s position in global coordinates to (0, 0, 0) whenever you press Button 1. Pressing Button 1 multiple times must move the camera back to the origin each time, regardless of where the player moves their head between presses.

Hint: the Oculus software controls the camera’s local coordinates. Thus, global refers to the sum of the coordinates of the main camera and its parents.

Write a script named CameraFlipper that flips the MainCamera 180 degrees about the \(y\)-axis when you press Button 2, as if you were turning around to look behind you. After flipping the first time, you will be facing a transparent window with a floating cube face on the other side. Pressing Button 2 multiple times must cause a 180-degree flip for each press.

The CameraReset and CameraFlipper scripts must be independent of each other, and the behavior of one must not interfere with the other. Specifically, CameraFlipper must not change the camera’s global position.

Write a script VRMirror to modify the position and rotation of the cube face to match or mirror your own. Pressing Button 3 must alternate between matching and mirroring. We don’t care what happens before we press Button 3 for the first time.

In match mode, the cube must be looking in the same direction as the camera. If the user faces the mirror directly, they should see the back of the cube’s head, and when the user brings their face closer to the mirror, the cube should move in the same direction, which for the cube is away from the mirror.

In mirror mode, when you face the window, the cube must face the camera, and as a result, the user should see the cube’s face. If you bring your face close to the screen, the cube will necessarily move closer to the screen as well. Imagine looking into a mirror to get an intuition of this.

Please remember to tell us what your control scheme is.

Geometric Transformations

This part of the MP will reinforce the mathematical notion of geometric transforms.

Complete the following written problems. You must show your work and all intermediate results in symbolic form. Do not convert results to decimals.

Submit your answers as a PDF. We recommend using LaTeX to typeset your mathematics.

  1. (6 pts) In one sentence, explain what the following homogeneous transformation accomplishes when applied to a point \((x, y, z)\), in terms of yaw, pitch, roll, and translation.
    \(T_1 = \begin{bmatrix} {1 \over \sqrt{2}} & -{1 \over \sqrt{2}} & 0 & 1 \\ {1 \over \sqrt{2}} & {1 \over \sqrt{2}} & 0 & 9 \\ 0 & 0 & 1 & 6 \\ 0 & 0 & 0 & 1 \end{bmatrix} \begin{bmatrix} x \\ y \\ z \\ 1 \end{bmatrix}\)

  2. (6 pts) Write out the \(4 \times 4\) matrix homogeneous transformation \(T_2\), that, when applied to a point \((x, y, z)\), translates the point by \((4,9,8)\), followed by a pitch of 120 degrees.

  3. (4 pts) We would like to reverse the transformation applied by \(T_2 T_1\). Write out \(\left(T_2 T_1\right)^{-1}\).

  4. (8 pts) Write out the quaternions equivalent to the rotations in \(T_1\) and \(T_2\) as \(q_1\) and \(q_2\).

  5. (8 pts) Calculate the product of \(q_1\) and \(q_2\), i.e. \(q_1 \circ q_2\).

  6. (8 pts) Suppose we have a rotation transform \(R\), and a translation transformation \(T\), neither of which are the identity transform. In what cases are these transforms commutative, i.e., order of application doesn’t matter?

Submission Instructions

Step 1: Create a Unity package file

  1. Save your Unity scene in the Assets folder with a descriptive title.
  2. Using the editor, find the created scene in the Project menu
  3. Right click on the scene and select “Export Package…”
  4. Export the file using default settings. Make sure that “Include dependencies” is enabled.
  5. This will create a .unitypackage file. We may use this during grading if your executable does not work, so make sure you also submit the data folder.

Step 2: Create a standalone build

  1. Save the project to C:\Users\<your netid>\<project name> temporarily, rather than the EWS U: drive. Local storage is faster when building.
  2. Go to Edit → Project Settings → Player. Make sure the “Virtual Reality Supported” box under XR Settings is checked.
  3. Go to File → Build Settings.
  4. Open the scene with your work for the MP.
  5. Click “Add Open Scenes”. You must have saved the scene to the assets folder for this to work.
  6. Click “Build”.
  7. This will create an executable (.exe) for running the build, a folder containing your scene data, a “Mono” folder, and UnityPlayer.dll.

Step 3: Copy the Input Manager file

  1. Shut down your project.
  2. In your project folder, navigate to the ProjectSettings subfolder.
  3. Find the InputManager.asset file, and copy it to your submission folder. This will allow us to replicate any new gamepad buttons or joysticks you mapped.

Step 4: Zip the files and submit through Compass

  1. Create a zip file containing the following items:
    • The .unitypackage created in Step 1
    • The .exe, .dll, Mono, AND DATA FOLDER created in Step 2
    • The InputManager.asset file found in Step 3
    • A README.txt file containing any instructions or notes relevant for evaluating your assignment.
  2. Ensure that the executable in your submission folder runs correctly on the Rift before submitting. The easiest way to do this is to unpack the zip file into a new folder, and then run the executable.
  3. Name the file by separating NetIDs with underscores- _cs498vr_MP#_part#.zip. EXAMPLE: If steve1 and anna2 worked together, the file for MP 1.1 should be called steve1_anna2_cs498vr_MP1_1.zip.
  4. Only one partner should submit the resulting file.


Name Points Description
Position Reset 10 The position reset functionality works properly.
View Flipping 10 Flipping the camera works properly and preserves the user's global position.
Cube Match Mode 20 The cube correctly matches the user's movements.
Cube Mirror Mode 15 The cube correctly mirrors the user's movements.
Cube Mode Toggle 5 The cube switches between mirror and match modes correctly.
Written Problems 40 See problems for precise breakdown.
Total 100