C++代写:CS6206 3D Scene Editor

用OpenGL绘制3D图像,画一只3D兔子。

Goal of this exercise

In this exercise you will implement a 3D editor that allows to prepare 3D scenes composed of multiple 3D objects.

Library

You can only use the libraries in the folder. Any external libraries are forbidden.

Eigen

In all exercises you will need to do operations with vectors and matrices. To simplify the code, you will use Eigen. Have a look at the “Getting Started” page of Eigen as well as the Quick Reference page to acquaintain yourselves with the basic matrix operations supported.

OpenGL

In all exercises you will use OpenGL 3.3 with GLSL version 150.

Mandatory Tasks

For each task below, add at least one image in the readme demonstrating the results. The code that you used for all tasks should be provided.

Scene Editor

Implement an interactive application that allows to add, edit, and delete 3D meshes. The scene should always contain at least one light source. New objects can be added to the scene in three ways:

  • The key ‘1’ will add a unit cube in the origin
  • The key ‘2’ will import a new copy of the mesh bumpy cube.off, scale it to fit into a unit cube and center it on the origin
  • The key ‘3’ will import a new copy the mesh ‘bunny.off’, scale it to fit into a unit cube and center it on the origin

Note that you can have multiple copies of the same object in the scene, and each copy can have its own position, scale, and rotation. For this exercise, all transformations MUST be done in the shader. The VBO containing the vertex positions of each object should be uploaded only once to the GPU.

Object Control

Clicking on a object will select the object, changing its color. When an object is selected, it should be possible to translate it, rotate it around its barycenter, and rescale it without changing its barycenter. All these actions should be associated to keyboard keys (and the choice of keys should be detailed in the readme). Each object also has a rendering setting associated with it, which can be one of the following three options:

  1. Wireframe: only the edges of the triangles are drawn

  2. Flat Shading: each triangle is rendered using a unique color (i.e. the normal of all the fragments that compose a triangle is simply the normal of the plane that contains it). On top of the flat shaded triangle, you should draw the wireframe.

  3. Phong Shading: the normals are specified on the vertices of the mesh and interpolated in the interior. The lighting equation should be evaluated for each fragment.

To compute the per-vertex normals you should first compute the per-face normals, and then average them on the neighboring vertices. In other words, the normal of the vertex of a mesh should be the average of the normals of the faces touching it. Remember to normalize the normals after averaging.

When an object is selected, it must be possible to switch between the different rendering modes by pressing three keys on the keyboard.

Camera Control

Add the possibility to translate the position of the camera (similarly to the previous assignment), but in this exercise the camera should always point to the origin. It should be possible to move it around, but the camera should always face the origin.

Implement both a orthographic camera (similar to the one that you used for Assignment 2, but in 3D) and a perspective camera. The cameras should take into account the size of the window, properly adapting the aspect ratio to not distort the image whenever the window is resized. All functionalities should work after resizing the window, including object selection and editing of the scene.