Task gpu004: GUI for examining of 3D objects using the "Trackball" system (C++)

The task is to implement convenient exploration of the 3D object using the popular "Trackball" system.

Trackball app screenshot

Overview

GUI for object rotation in front of the viewer. Imagine virtual invisible ball (trackball) connected rigidly to the examined object. Ball (as well as the object) have fixed center point but are able to rotate freely around it. Look at the demo video.

Principle

Imagine the starting point of the mouse drag and the current point in 3D space on the ball surface. All you must do is to determine one simple ball rotation from the starting point to the current mouse position. Details and formulas can be found:

Implementation

As starting point you should use the template01 project from the ogl repository. It is able to draw simple object using OpenGL (default object - color cube). You can add some more sophisticated object later, but fist you must implement the interactive rotation. Important functions:
  • handleMousePress - mouse button press
  • handleMouseRelease - mouse button release
  • handleMouseMove - mouse pointer move
  • handleMouseWheel - mouse wheel
  • handleKeyPress - keyboard press
  • handleKeyRelease - keyboard release
  • drawGLScene - scene drawing function

You may adopt implementation from the C# solution 038trackball.

More tasks

More complicated object: look at the GlScene class and its usage in the initScene() function. Introduce some more interesting and complicated object using triangles, quads, lines, etc.

Momentum: the object doesn't stop immediately after you release the mouse button. If you just lash the mouse (release the button while in /fast/ motion), examined object still rotates for a small/longer period of time. If you release the button while standing still, no consequent movement should be introduced.

Documentation: write brief documentation about your sources, even if you were adopting the C# solution. Don't forget to include your new commands in the "Console help" (SDLK_F1 key).

Deadline

Hand in before: 23. 4. 2017

Points

Basis: 12 points for functional trackball implementation,
bonuses: up to 3 points for orthographic/perspective camera switch (with reasonable zoom-factor adjustment),
up to 9 points for implementation of momentum (object decelerates for a moment)
up to 4 points for nicer 3D object..

Project

Visual Studio project: template01.

Source file

Modify and hand in the source file: main.cpp.
In the comment at the beginning of the file, please include your name!


Copyright (C) 2016-2017 J. Pelikán, last change: 2017-03-16 01:46:56 +0100 (Thu, 16 Mar 2017)