Project 2a © Jorg Peters

Points: 5 + 5 + 5

Purpose

Learn to move objects via the mouse in OpenGL.

Set up

Use this new code base.

Declare any online code by stating the link in your code.

hints.

Task 1: Create Scene

Display 8 points on the screen, each of a different color and arranged uniformly on a circle.

Task 2: Picking

Use orthogonal projection!

Task 3: Dragging

Implement the ability to move the points with the mouse.

Make all points suitably large.

Coordinate-system notes:

  • The OpenGL window origin (0, 0) is bottom-left, whereas the mouse reports with (0, 0) on top-left.
  • In order to map mouse coordinates to world coordinates:
    • Retrieve the cursor position using glfwGetCursorPos.
    • Obtain world coordinates using glm::unProject(glm::vec3(---,---, 0.0), ModelMatrix, ProjectionMatrix, vp) where --- is a placeholder for your code and vp is short for Viewport.
    • Consult web OpenGL documentation.

Reference figures

Computer graphics window with a dark blue background and eight differently colored square points arranged approximately uniformly around a circle.
Figure 1. Eight colored points arranged around a circle.
Computer graphics window with a dark blue background and eight differently colored square points spread farther apart, illustrating a changed point arrangement.
Figure 2. Eight colored points in a different arrangement.

What to Submit