[SOLVED] graph CGT 215 Lab 5

$25

File Name: graph_CGT_215_Lab_5.zip
File Size: 178.98 KB

5/5 - (1 vote)

CGT 215 Lab 5
Nested Loops and Graphic Output
Learning objectives:
Practice loops.
Learn about the customized 3D environment that we will use through the rest of the course.
Description:
Create a program to present four different graphic outputs.
Create a way for the user to alternate between the different scenes.
Introduction:
Make sure the framework compiles.
All your code will be inside the main.cpp file. Do not touch anything else.
This main.cpp includes three functions. Put all your code in the renderFrame function. At the beginning of the function, you should create a 3D context calling the function enable3d(). Also, if you want to draw 3D primitives, it is convenient to call the function setWireframeRendering(false) to create a fully shaded object.
The keyPressed(char key) function tests if a key was pressed in the current frame. You can use it to implement your user interaction logicfor example, using it with a globally defined variable.
Another two functions that can be of your interest are:
setColor(double red, double green, double blue) sets the color to the desired RGB color. All
arguments must be double numbers between 0.0 and 1.0 for the consequent drawings.
drawSphere(double x, double y, double z, double radius) draws a sphere with center at the
point (x, y, z), with the specified radius using a current color.
NOTE: Whenever you have trouble tracking down how to use a function, the cgt215.h file contains all of these functions in their original source, or see the demo.cpp for implementations! Open it up, then use Ctrl+F to search for a term, which should guide you on how to use it back in your own main.cpp!
See the next page for the requirements of the Lab, the four different graphic outputs to create:

Implement the following four graphic outputs:
1. A row of spheres with increasing radius as shown below:
2. A row of spheres alternating the radius from smallest, biggest, second smallest, second biggest, etc.
See the final two requirements below:

3. A rectangular grid of spheres augmenting the radius along the x and y coordinates.
4. A three-dimensional grid of spheres of the same size with procedural colors.
HINT: Make sure that any numbers used for calculations with a For Loops incrementing variable uses the amount of decimal places you want to end with.
e.g. To divide your incrementing variable by two, resulting in a double with decimal values, you would need (i / 2.0), not (i / 2).
2 is an integer, 2.0 is a double, 2.0f is a float

Reviews

There are no reviews yet.

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

Shopping Cart
[SOLVED] graph CGT 215 Lab 5
$25