Starting from:

$34.99

CS4392.001 Assignment 1- OpenGL program Solution


Write an OpenGL program that display a rotating bunny.
1) Initially place a bunny 5 units along the x-axis at (5, 0, 0) of world coordinate system. This is already implemented in the provided starting code.
2) Draw a ground plane and y-axis of world coordinate system. Draw xyz axis from an arrow object. This is already implemented in the provided starting code.
3) Rotate the bunny around the global y-axis of world coordinate system (WCS) and at the same time rotate around its own x-axis of local coordinate system (LCS).
For the rotating bunny, do the following transformation in order:
a. rotate the bunny around its own x-axis of local coordinate system by 'a' degree; (grade: 4 points)
b. then rotate the bunny by 'b' degrees around the global y-axis of world coordinate system. (grade: 3 points)
Note that the rotation around its own x-axis will not change the center position of bunny. The center position of bunny is changed when it rotates around the global y-axis. Some implementation hints are given below.
4) The program should have user-interaction controls to allow users to interactively increase and decrease a and b. The controls can be buttons, checkboxes, mouse clicks, mouse motion, etc. as long as it is easy to use. (grade: 2 points)
A starting code (C++) animating a bunny has been provided. GUI is implemented by Nanogui and GLFW. To build the code, the following libraries are needed: GLEW, GLFW, Nanogui.
Hints:
1. Every bunny transformation can be implemented by modifying the “Model” matrix in the OpenGL code. The Model matrix is used to transform the vertex coordinates from model’s local coordinate system (LCS) to world coordinate system (WCS).
2. How to rotate the bunny around its own x-axis of local coordinate system (LCS)? Here are some hints that you can consider:
a. Track the direction of the bunny’s x-axis of LCS and represent it in WCS.
b. Construct a rotation matrix, with the rotation axis to be the bunny’s x-axis and the rotation angle to be 'a' degree. Rodrigues’ rotation formula gives the form of this matrix.
c. The rotation pivot point is the origin of bunny’s LCS, but not the origin of WCS. Think about how to make the bunny rotate around its own origin.

More products