, , ,

[SOLVED] Cmsi 281/371 assignment 1 to 4 solutions

$25

File Name: Cmsi_281_371_assignment_1_to_4_solutions.zip
File Size: 376.8 KB

5/5 - (1 vote)

The assignment will focus on the concept of Chaikin, Bézier curve algorithm. Given a headshot photo of an individual (e.g. the headshot of Ed Sheeran), generate the cartoon version of the photo by sketching it using Chaikin or Bézier curves. Skeleton code has been provided to guide you along the way. The places that you will be required to implement has been marked with a TODO. I have provided you with a simple Vertex class that allows you to specify the x and y values of a point. You will utilize this class for modeling the control points of your sketch. **Note: the C++ vector class is the equivalent to a list in most other languages. You may use the push_back(Object o) function of the vector class to hold your set of points. You will complete the following functions for the assignment: 1) generate_points : a function that generates takes in a set of control points for your Chaikin or Bézier curve algorithm and returns the new set of control points parameters: vector returns: vector 2) draw_curve : calls generate_points to generate the control points using the Chaikin or Bézier curve algorithm and forms a curve by connecting the points with lines parameters: vector, int returns: none The parameter n_iter refers to the number of iterations to run the Chaikin or Bézier algorithm. Recall that each time the algorithm is ran, you will obtain a set of new points. Submission: You will submit the following to Bright Space 1) “assignment1.cpp” 2) Your sketch in JPEG, JPG, or PNG: results.{jpeg, jpg, png} 3) The photo your sketch was based on in JPEG, JPG or PNG: photo.{jpeg, jpg, png} Grading: I will be compiling the assignment using the following command: gcc -o assignment1 assignment1.cpp -std=c++14 -lGL -lGLU -lglut Your code must compile for me to assign points! Your assignment will be graded on: 1) 80% the correctness of your implementation of Bézier’s algorithm 2) 20% effort placed recreating the subject via your sketch e.g. a simple happy face does not do Ed Sheeran justice Late Policy: For each day the assignment is late, 50% of its worth will be deducted, e.g. 100% on time, 50% 1 day late, 25% 2 days late, etc.

Given a set of data points that describe a cube centered at the origin in 3-dimensional space, our goal is to rotate the cube about an axis. This assignment will introduce Vertex Arrays in OpenGL for modeling sets of points in 3D space. The skeleton code is provided to guide the assignment. I have provided you with a simple degree to radian function for converting a given degree theta to radian as input to your rotation matrix. In addition, you are also given a vector2array function that converts a vector of GLfloat to an array of GLfloat to be rendered. **Note: the C++ vector class is the equivalent to a list in most other languages. You will complete the following functions for the assignment marked with TODO: 1) to_homogenous_coord : converts a vector of cartesian coordinates (x, y, z) to homogeneous coordinates (x, y, z, 1) 2) to_cartesian_coord : converts a vector of homogeneous coordinates (x, y, z, 1) to cartesian coordinates (x, y, z) 3) rotation_matrix_x : outputs the rotation matrix along the x-axis 4) rotation_matrix_y : outputs the rotation matrix along the y-axis 5) rotation_matrix_z : outputs the rotation matrix along the z-axis 6) mat_mult : performs matrix multiplication between two matrices The camera has been set up for you to point towards the origin. I have provided points (vector) which contains the set of points defining the cube in 3D space. Your goal is to apply some rotation to the points in 3D space. I have also defined an array of GLfloat called colors. These colors are mapped to the planes so that you will be able to distinguish each plane of the cube. You will notice that there is a global variable theta. theta defines the degree of rotation, which you will need to convert to radian using the provided deg2rad function. Submission: You will submit the following to Bright Space 1) “assignment2.cpp” 2) A recording (avi, mov) of the program running (should show a cube rotating about the axis or axes of your choice (e.g. rotate about x and y axes) Grading: I will be compiling the assignment using the following command: gcc -o assignment2 assignment2.cpp -lGL -lGLU -lglut Your code must compile for me to assign points! Your assignment will be graded on: 1) the correctness of your implementation of the above functions Late Policy: For each day the assignment is late, 50% of its worth will be deducted, e.g. 100% on time, 50% 1 day late, 25% 2 days late, etc.

Given a real world scene, your goal is to replicate it using hierarchical modeling of the objects. You will begin by building prisms from planes using 3D translations and rotations. These prisms can then be used to form parts of objects. The skeleton code is provided in a separate assignment3.cpp file I have provided you with a function init_plane which initializes a square plane of unit lengths centered at the origin (0, 0, 0). You will utilize this initial plane to form cube, which can then be transformed and used to form objects. I have also provided you with the deg2rad, vector2array, to_homogeneous_coord, to_cartesian_coord, and init_color functions. ● deg2rad — converts degree to radians ● vector2array — converts a vector into an array ● to_homogeneous_coord — converts Cartesian coordinates to homogeneous coordinates ● to_cartesian_coord — converts homogeneous coordinates to Cartesian coordinates ● init_color — creates a color map for the scene As vector2array dynamically allocates space and copies the elements of the vector into the array. You need to remember to deallocate the arrays created via vector2array after you have rendered your scene to prevent memory leak. Since arrays are static, it is easier to work with the vector class before producing the final array of vertices that will be used for rendering. You will need to first implement the build_cube function, which creates an unit cube. Then apply transformations to the cube to create objects in the scene (init_scene). Once the scene is built you will apply rotation to the scene such that the entire scene spins while the camera stays still. You may set the parameters of your camera in init_camera. For the mat_mult function, please implement it such that it multiplies a transformation matrix A by the entire points matrix B rather than transformation A and point by point in B. The math header file that I have included should be sufficient in doing the operations needed for this project. You will complete the following functions for the assignment: 1) translation_matrix (float dx, float dy, float dz) 2) scaling_matrix (float sx, float sy, float sz) 3) rotation_matrix_x (float theta) 4) rotation_matrix_y (float theta) 5) rotation_matrix_z (float theta) 6) mat_mult(vector A, vector B) 7) build_cube() 8) init_camera() 9) init_scene() 10) display_func() Note: functions 1-7 serve as helper functions to generate the objects in the scene (i.e. build_cube will create a cube in which you can then modify to form parts of an object). I would suggest using vector2array as the final step since going from an array to vector requires you to keep track of the number of elements in the array (which could be hard after generating thousands of points). Submission: You will submit the following to Bright Space: 1) assignment2.cpp 2) Either 6 different viewpoints taken from different angles of you scene submitted as JPEG, JPG or PNG with the names: view{1,2,3,4,5,6}.{jpeg, jpg, png} or a short video panning over regions of your scene 3) A photo in the form of JPEG, JPG or PNG (scene.{jpeg, jpg, png}) taken of the scene with which you are basing your model on Grading: I will be compiling the assignment using the following command: g++ -o assignment3 assignment3.cpp -lglut -lGLU -lGL Your code must compile for me to assign points! Your assignment will be graded on: 1) the correctness of your implementation of the hierarchical modeling procedure 2) the correctness of your implementation of your camera and scene modeling 3) effort placed recreating the real world scene Late Policy: For each day the assignment is late, 50% of its worth will be deducted, e.g. 100% on time, 50% 1 day late, 25% 2 days late, etc.

Given a scene, our goal is to generate objects using hierarchical modeling (based on
assignment 3) and add shading (colors) to these objects by defining a light source (a
3-dimensional vector), computing the surface normals, and generating the observed colors
using Gouraud shading.
Note that we define the illumination (e.g. the observed colors) as follows:
Note: you may reuse the objects you defined in assignment 3, but you also MUST make sure
that you have sufficient objects in the scene to make it look interesting (at least a few colors)
Once you have defined an object, I would suggest keeping the operations that generate the
object as a standalone function (e.g. build_chair(…) for generating a chair) such that you may
call these functions to quickly prototype a scene.
We will be working with an ObjectModel class which contains 4 vector objects, holding
information about the points defining each plane, their respective base colors, their normals
(each point on the plane should have the same normal) and the actual observed colors.
I have provided you with an overloaded function init_base_color, which you can use to define
the base colors for each plane (to color a cube, for example, you will need to call this 6 times).
There are 3 portions for this assignment: 1) generating surface normals, 2) applying Gouraud
shading, 3) rendering objects with colors based on camera and light source positions.
The next section of the specification will detail the road map for these portions.
Surface Normals
In order to know how light will interact with an object, we must know the object’s surface normal,
which can be obtained using the cross product of two vectors on the object surface (which is a
plane where normals are well-defined). You will implement the cross_product method and use
it to implement the generate_normals method.
Gouraud Shading
We will implement our shading equation which models how an object will be illuminated. You
will implement the dot_product method in order to measure the strength of the light rays
reflecting off an object. We will use the dot_product to implement the apply_shading method.
Note: for this assignment we are implementing Gouraud shading, which includes the
interpolation of the colors between each point defining the surface. Luckily the interpolation is
already taken care of by OpenGL so all we will need to do is to define the observed colors for
each point via the shading equation.
Rendering Objects with Colors
In the previous assignment, we simply let the colors be defined as a static base color value
(randomly generated). We now know how light behaves and how we should model its
interaction with objects. Hence, we will need to populate each member of ObjectModel. The
scene will be constructed using the defined points. The set of base colors of the scene will be
stored in base_colors.
The apply_shading method will be used to generate the actual observed colors using the
surface normals, light source, and camera. The observed colors are stored as the color member
of ObjectModel.
Submission:
You will submit the following to Bright Space:
1) assignment4.cpp
2) Either 6 different viewpoints taken from different angles of you scene submitted as
JPEG, JPG or PNG with the names: view{1,2,3,4,5,6}.{jpeg, jpg, png}
or a short video panning over regions of your scene
3) A photo in the form of JPEG, JPG or PNG (scene.{jpeg, jpg, png}) taken of the scene
with which you are basing your model on
Grading:
I will be compiling the assignment using the following command:
g++ -o assignment4 assignment4.cpp -lglut -lGLU -lGL
Your code must compile for me to assign points!
Your assignment will be graded on:
1) the correctness of your implementation of the surface normals
2) the correctness of your implementation of the illumination equation
3) effort placed recreating the real world scene
Late Policy:
For each day the assignment is late, 50% of its worth will be deducted, e.g. 100% on time, 50%
1 day late, 25% 2 days late, etc.

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] Cmsi 281/371 assignment 1 to 4 solutions[SOLVED] Cmsi 281/371 assignment 1 to 4 solutions
$25