Answered step by step
Verified Expert Solution
Question
1 Approved Answer
( Help with part B ) Modify the code developed on the homework # 1 to a ) Translate ( move ) the whole object
Help with part B Modify the code developed on the homework # to
a Translate move the whole object the star, the circle and the point that moves around along the x axis using the and keys on the keyboard
b Rotate the whole object around the z axis using the shift and shift keys on the keyboard.
Heres the already developed code, part A is already done.
#include
#include
const int windowWidth ;
const int windowHeight ;
const float circleRadius f;
const float pointSize f;
const float pointSpeed f;
float pointAngle f;
float figurePositionX f; Initial xposition of the figures
void init
glClearColorffff; color violeta dark
glMatrixModeGLPROJECTION;
glLoadIdentity;
gluOrthoD;
void drawCircle
glColorf; color rosa
glBeginGLLINELOOP;
for int i ; i ; i
float angle i ;
glVertexfcircleRadius cosangle figurePositionX, circleRadius sinangle;
glEnd;
void drawPoint
glColorf; color verde
glPointSizepointSize;
glBeginGLPOINTS;
glVertexfcircleRadius cospointAngle figurePositionX, circleRadius sinpointAngle;
glEnd;
void drawStar
glColorf; color amarillo
glLineWidth; intentando hacer la estrella mas gruesa
float innerRadius circleRadius f;
glPushMatrix;
glTranslateffigurePositionXff; Translate along xaxis
glRotatefffff; enderezala
glBeginGLLINELOOP;
for int i ; i ; i
float angle i ;
glVertexfcircleRadius cosangle circleRadius sinangle;
angle ;
glVertexfinnerRadius cosangle innerRadius sinangle;
glEnd;
glPopMatrix;
void display
glClearGLCOLORBUFFERBIT;
glMatrixModeGLMODELVIEW;
glLoadIdentity;
drawCircle;
drawStar;
drawPoint;
glutSwapBuffers;
void updateint value
pointAngle pointSpeed;
if pointAngle
pointAngle
const int windowWidth ;
const int windowHeight ;
const float circleRadius f;
const float pointSize f;
const float pointSpeed f;
float pointAngle f;
float figurePositionX f; Initial xposition of the figures
void init
glClearColorffff; color violeta dark
glMatrixModeGLPROJECTION;
glLoadIdentity;
gluOrthoD;
void drawCircle
glColorf; color rosa
glBeginGLLINELOOP;
for int i ; i ; i
float angle i ;
glVertexfcircleRadius cosangle figurePositionX, circleRadius sinangle;
glEnd;
void drawPoint
glColorf; color verde
glPointSizepointSize;
glBeginGLPOINTS;
glVertexfcircleRadius cospointAngle figurePositionX, circleRadius sinpointAngle;
glEnd;
void drawStar
glColorf; color amarillo
glLineWidth; intentando hacer la estrella mas gruesa
float innerRadius circleRadius f;
glPushMatrix;
glTranslateffigurePositionXff; Translate along xaxis
glRotatefffff; enderezala
glBeginGLLINELOOP;
for int i ; i ; i
float angle i ;
glVertexfcircleRadius cosangle circleRadius sinangle;
angle ;
glVertexfinnerRadius cosangle innerRadius sinangle;
glEnd;
glPopMatrix;
void display
glClearGLCOLORBUFFERBIT;
glMatrixModeGLMODELVIEW;
glLoadIdentity;
drawCircle;
drawStar;
drawPoint;
glutSwapBuffers;
void updateint value
pointAngle pointSpeed;
if pointAngle
pointAngle ;
glutPostRedisplay;
glutTimerFunc update, ;
void specialKeysint key, int x int y
switch key
case GLUTKEYLEFT:
figurePositionX f; Move figures left
break;
case GLUTKEYRIGHT:
figurePositionX f; Move figures right
break;
glutPostRedisplay;
int mainint argc, char argv
glutInit&argc, argv;
glutInitDisplayModeGLUTDOUBLE GLUTRGB;
glutInitWindowSizewindowWidth windowHeight;
glutCreateWindowStar and Moving Point";
init;
glutDisplayFuncdisplay;
glutSpecialFuncspecialKeys; Register special key callback
glutTimerFunc update, ;
glutMainLoop;
return ;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started