Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C + + code for OpenGL DO NOT USE M _ PI build a parametric torus object based on parameters r

C++ code for OpenGL
DO NOT USE ""M_PI""
build a parametric torus object based on parameters r and R, and also controlling the resolution (number
of triangles) of your approximation.
Using Parametric equations:
x(,)=(R+rcos)cos
y(,)=(R+rcos)sin
z(,)=rsin
Requirement 1 Parameterized torus using triangle primitives:
You will use the torus parametric equation to build a torus based on 3 parameters: r, R, and
n, where n controls the number of triangles that are generated.
The number of triangles does not need to be parameterized exactly. Parameter n just needs
to control the resolution in a way to properly control a finer or coarser subdivision of the
surface in triangles. You will typically have two nested for loops to vary the 2 parameters (r
and R) of the parametric equation, and n will control how large are the increments applied to
the two parameters of the for loops. As triangles are created, push them to an array to be
sent to OpenGL. You will likely want to use a dynamically sized structure like a vector.
Note 1: Remember, for the built-in OpenGL back-face culling to work properly, make sure
the order of the vertices in each triangle is always counter-clockwise, when seen from outside
the torus. This is almost always an important thing to get right in Computer Graphics.
Note 2: It will probably be better to inspect your torus in wireframe since at this point your
object will not be shaded. We will cover shading and illumination in a future assignment. By
default in the support code, pressing w will toggle wireframe (or line rendering) mode.
Requirement 2 Interaction:
In this requirement the previously described parameters are controlled with keys such that
you can test your implementation and generate shapes with different properties. Use the
callback functions to change the values of your parameters in response to key presses, and
then regenerate the torus with the new parameters. Please use the following keys:
-'q' : increment the number of triangles (n)
-'a' : decrement the number of triangles (n)
-'w' : increment the r radius (by a small value)
-'s' : decrement the r radius (by a small value)
-'e' : increment the R radius (by a small value)
-'d' : decrement the R radius (by a small value)
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Development Of Knowledge Framework For Affective Content Analysis

Authors: Swarnangini Sinha

1st Edition

B0CQJ13WZ1, 979-8223977490

More Books

Students also viewed these Databases questions

Question

Explain the importance of Human Resource Management

Answered: 1 week ago

Question

Discuss the scope of Human Resource Management

Answered: 1 week ago

Question

Discuss the different types of leadership

Answered: 1 week ago

Question

Write a note on Organisation manuals

Answered: 1 week ago

Question

Define Scientific Management

Answered: 1 week ago