Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C + + code for OpenGL THE FINAL TORUS MUST BE 3 D build a parametric torus object b Dased on parameters r and R

C++ code for OpenGL
THE FINAL TORUS MUST BE 3D
build a parametric torus object b
Dased 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

Flash XML Applications Use AS2 And AS3 To Create Photo Galleries Menus And Databases

Authors: Joachim Schnier

1st Edition

0240809173, 978-0240809175

More Books

Students also viewed these Databases questions

Question

What are the main differences between rigid and flexible pavements?

Answered: 1 week ago

Question

What is the purpose of a retaining wall, and how is it designed?

Answered: 1 week ago

Question

How do you determine the load-bearing capacity of a soil?

Answered: 1 week ago

Question

what is Edward Lemieux effect / Anomeric effect ?

Answered: 1 week ago