The task is to design and implement an animated camera "fly-through" in a real-time 3D renderer. Your camera will be used in a 3D scene viewer 086shader as an alternative to the interactive "Trackball" used by default. You will only need to modify the "Model-View" and "Projection" matrices used for rendering the scene, but you will not need to modify the scene rendering code itself.
The basis is the project 086shaders from the
grcis repository.
The application can read a 3D scene from a file (Wavefront OBJ) or generate it procedurally (you may use your solution of the assignment 057
or the implicit SFC curve implemented in the previous year by the student Matúš Goliaš).
The scene is then rendered using the GPU renderer (be sure to check out the code, so you know how things work).
You may enable smooth shading, for which your geometry must contain per-vertex normal vectors.
After checking the Animation check-box, the code in the AnimatedCamera
class will be used (see the source file Camera.cs).
The animation curve can define the camera trajectory, orientation, or both.
The user can also load the camera script from an external file using the button Load cam
(implementing this functionality is optional).
The Start/Stop button resumes/stops the animation, Reset cam sets the camera to its initial state.
Whenever the Animation check-box is off, the interactive Trackball is (re-)enabled.
All the necessary details are available in the lecture Mathematics for 3D graphics,
in the part concerned with matrix transformation, quaternions, and animation curves.
You will define the "Model-View" matrix, which places and orients
the camera in the world-space (this can also be regarded as transforming the
entire world so that the viewer, i.e. the camera position, is at the origin looking down the negative z-axis).
Furthermore, you can also set the "Projection" matrix,
which defines the parameters of the perspective projection.
(A side note: The former matrix describes what is in computer vision called the
"Extrinsic camera parameters" while the latter
defines the "Intrinsic parameters", i.e. the parameters of the optical system proper).
You may set reasonable projection parameters and never change them during the animation. A reasonable maximum camera angle is 80° or less.
Of course, your may implement zooming in and out as a part of the fly-through, for which you would need to modify the projection matrix as function of time.
Camera movement: it is necessary to move the camera along a smooth animation curve
(defined either using goniometry or - even better - though a general interpolation curve, such as Catmull-Rom or Bezier).
Camera orientation: the camera orientation should have the maximum possible degree of continuity,
for example using the quaternion interpolation or using a smoothly moving target object (cf Matrix4.LookAt()).
The IDynamicCamera interface defines the dynamic camera API.
You can derive your camera from the class DefaultDynamicCamera,
in which most of the interface methods are already reasonably implemented, and you will only have to
worry about the calculation of the time-varying transformation matrices.
Implementation of your camera is in the source file Camera.cs, the class is called
AnimatedCamera.
Its default behavior is to fly around the origin on a circle-like trajectory with
the view fixed at the origin (i.e. the scene center).
The following section describes the most important properties and functions of the API,
which you will need to implement or at least understand.
Functions used only for the interactive camera (Trackball) are intentionally skipped as they
are not needed for the animated camera.
You may read up on the IDynamicCamera API in the file Trackball.cs.
One line of a text file = one key-frame. The line can be read e.g. by the function TextReader.ReadLine(). Parameters are in the format Util.ParseKeyValueList(), and the only mandatory item on each line is the time. Parameters:
Items that are not set are copied from the previous line. So when you only set the time, it means a constant segment from the previous key frame.
The due date is: 28. 2. 2023
7 pts: smooth camera movement defined procedurally in the program or a smooth interpolation of a trajectory defined by key-frames
up to 4 pts: smooth interpolation of camera orientation (quaternions or a non-trivial moving tracking target)
up to 5 pts: scripted animation (externally defined animation script using your own format)
up to 5 pts: bonus for an interesting/nice-looking script
Visual Studio project: 086shader
Modify and hand-in the file: Camera.cs.
Remember to set your name in the InitParams() function!
Copyright (C) 2018-2020 J.Pelikán and J.Krivánek, last change: 2022-12-08 12:17:14 +0100 (Thu, 08 Dec 2022)