# Assignment 2: Modeling

Out: Apr 09. Due: Apr 23.

### Introduction

In your second assignment, you will perform basic tasks in interactive rendering related to modeling. Since GPU can only render points, triangles and lines, all other shapes need to be transformed to these representation. The bulk of your work will be relate to just this.

You are to perform this assignment using C++. To ease your development, we are providing a C++ framework to load a scene, perform basic mathematical calculations, and save your image results. Included with the framework are scene files in JSON file format, the correct output images, and scripts to generate the output images from the scene files. This time though, we include in the package a documentation unser doc/html/index.html.

Also you can use the layout of the code as an indication of how to structure your code. We have removed the code of each of the functions you are expected to fill in. If you feel this structure does not suit your needs, feel free to change it, but please leave comments as to what your new functions are meant to do to help us evaluate your code in case of errors.

We also provide a reference executable for OS X and Win32. You can use these to interactively check whether your solution meets the requirements. You can run the program interactively by calling it with the filename. When running, hit h for help.

The final result of this assignment is a simple ray tracer with support for the following features:

• Tesselation
• Cylinder uniform tesselation
• Catmull-Clark Subdivision Surfaces recursive tesselation
• Bezier splines uniform tesselation
• Transformation
• Implement simple function transformation

### Requirements

Search for the function not_implemented_warning to know what parts you are required to implement. In implementing these requirements, do not worry about malformed input. Below is a itemized summary of these requirements.

1. Cylinder Tesselation. Implement a uniform tesselation for cylinders. You can use the provide cylinder_frame that evaluates the cylinder for a specific $(u,v)$. To perform uniform tesselation, follow the slides notes. In particular, create a $k \xx k$ quad grid where vertex positions and normals are set using the given frame function. Hint: The provided Sphere tesselation is quite similar and you can reuse its code.

2. Quad/Triangle Mesh Tesselation. Implement one step of a recursive tesselation for collection of quads and triangles, stored in a Mesh in _tesselate_mesh_once. The topology and geometry of the split should be the same as the one introduced in the Subdivision Surface lecture. Hint: The provided TriangleMesh tesselation is quite similar and you can reuse this code.

3. Catmull-Clark Subdiv Tesselation. Implement one step of a recursive tesselation for a Catmull-Clark subdiv of only quads. Use the three step refactoring method described in the notes. Hint: The provided Subdiv tesselation is a superset of the one you have to create and you can reuse this code.

4. Bezier Sline Tesselation. Implement uniform subdivision for Bezier splines. You can assume all segments are adjacent and the $t$ interval is split at integer values.

5. Transformation. Implement the matrix computation for a transformed surface. The surface has rotation, scale and rotation along the major axis. Compute both the transformation matrix and the inverse of it (but without using the inverse function). Note also that a pivot is defined, but you can ignore it for this homework. The overall transformation is: $M = T_\mathbf{t} \* R^z_{\theta_z} \* R^y_{\theta_y} \* R^x_{\theta_x} \* S_\mathbf{s}$

### Submission

Please send your code as well as the images generated by your code to pellacini-at-di-dot-uniroma1-dot-it. We will run your code by calling the main method provided. We will your images for correctness with ours.

### Extra Credit

1. Implement the De-Casteliaue recursive algorithm for Bezier splines.