Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

what is th code Cex.S 326 Gimsifer Cinchies trawcbject 20i r Programming Exercises 1. Open the attuched progren, lab6 problemi.epp 1. Set the world coordinates

what is th code
image text in transcribed
image text in transcribed
Cex.S 326 Gimsifer Cinchies trawcbject 20i r Programming Exercises 1. Open the attuched progren, lab6 problemi.epp 1. Set the world coordinates to be: - Xmin=6 - Xmax=6 - Ymin=6 - Ymax =6 2. Creake a rod square with the following coontinates: - Square =(1,1,0),(1,4,0),(5,4,0),(5,1,0) 3. Dean the x y Coerdinate lines in blue. At this point, your prograns should display the followine: 4. Inplemeet interactive features that will teaslate the drawn square object with the LEFT, RIGiHT, UP or DOWN anrew keys. You will ned to use the efiutspetat rume function, and constants like cent Mrr 3tgir for utilising the arnow keys. 2. Take a lokk at the filee rotating. Cube example. ppp. the file contains the code to rutate a cube bused on mouse input. Read the code, nun it, undentand it. Modify yoer program froen the previous qestion so that the square will continsobly potase around the y-avis aben the user presess the 'r' key and stope neation when the user presses the 's' key. Your code for the keyboerd function should look sinnilar to: 1f (key wn " r2 ) clutidefunc (spans): else if (key an "s') glutidlefunc(nullptr)! To perform transformations on 2D objects using OpenGL programming OpenGL transformation functions OpenGL maintains a 4x4 transformation matrix that is multiplied by every (x,y,z) value sent to glVertex(). This is sometimes referred to as the CT (current transform). The CT can be modified by the following functions: - glMatrixMode(GL_MODELVIEW); - glLoadidentity0: - giTranslate {fd}(dx,dy,dz); - glScale {ffd}(sx,sy,sz); - glRotate\{fd\} ( angleInDegrees, axisXvalue, axisYvalue, axisZvalue); How to use the OpenGl transformation functions There are two different 44 matrices used by OpenGL to produce an image. They are: - Projection matrix - used to "project" a 3D image onto a 2D plane to create an image. - ModelView matrix - used to transform objects and the camera to create the desired scene and view. Commands like glTranslate, gIRotate, and glScale will modify the active matrix. It is the programmer's responsibility to make sure the appropriate matrix is "active." The active matrix is determined by calls to glMatrixMode0, such as: - glMatrixMode(GL_PROJECTION); // make the projection matrix active - glMatrixMode(GL_MODELVIEW); // make the modelview matrix active 2) The transformations caused by glRotate, gITranslate, and gIScale are applied to the CT (current transform). They will accumulate continually unless you reset the matrix back to the Identity matrix. If you want to start a new set of transformations, then call glLoadidentity 0 , as in the following example: g1MatrixMode (GL_MODELVIEW) ; g1Loadidentity(): // start a new sequence of transforms glTranslatef (3,0,4,0,0,0); gIRotatef (90.0,1.0,0.0,0.0); dranobjecti() z qILoadidentity (): // start a nex sequence of transforms g1Translatef (4.0,2.0,1.0)= giscalef (2.0,1.0,1.0)

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

PC Magazine Guide To Client Server Databases

Authors: Joe Salemi

1st Edition

156276070X, 978-1562760700

More Books

Students also viewed these Databases questions