#include "windows.h"
#include "glut.h"
#include "gl/GL.h"
#include "gl/Glu.h"
GLfloat spe_x = 1.0f;
GLfloat spe_y = 1.0f;
GLfloat spe_z = 1.0f;
GLfloat spe_a = 1.0f;
GLfloat wall_1 = 1.0f;
GLfloat translate_x = 0.6f;
GLfloat translate_y = 0.38f;
GLfloat translate_z = 0.5f;
float jack_radius = 0.1;
bool isTrue = false; bool isTrue_r = false;
GLfloat rot = 90.0;
// Wall void wall(double thickness)
{
// draw thin wall with top xz-plane, corner at origin
glPushMatrix(); glTranslated(0.5, 0.5 * thickness, 0.5); glScaled(1.0, thickness, 1.0); glutSolidCube(1.0); glPopMatrix();
}
// table Leg void tableLeg(double thick, double len)
{
glPushMatrix(); glTranslated(0, len/2, 0); glScaled(thick, len, thick); glutSolidCube(1.0); …show more content…
glPopMatrix(); glPushMatrix(); glTranslated(translate_x, translate_y, translate_z); glRotated(rot,0,1,0); glutSolidTeapot(0.08); glPopMatrix(); glPushMatrix(); glTranslated(0.25,0.42,0.35); glutSolidSphere(jack_radius,15,15); glPopMatrix(); glPushMatrix(); glTranslated(0.4,0,0.4); table(0.6,0.02,0.02,0.3); glPopMatrix(); wall(0.02); glPushMatrix(); glRotated(rot,0.0,0.0,1.0); wall(0.02); glPopMatrix(); glPushMatrix(); glRotated(-90.0,1.0,0.0,0.0); wall(0.02); glPopMatrix(); glFlush();
}
void mouse(int button, int state, int x, int y)
{
switch (button) { case GLUT_LEFT_BUTTON: if(state==GLUT_DOWN) { glClearColor((rand()%10)*0.1,(rand()%10)*0.1,(rand()%10)*0.1,0); } glutPostRedisplay(); break;
case GLUT_RIGHT_BUTTON: if(state==GLUT_DOWN) { spe_x = (rand()%10)*0.1; spe_y = (rand()%10)*0.2; spe_z = (rand()%10)*0.4; spe_a = (rand()%10)*0.04; } glutPostRedisplay(); break; }
}
void idleFunc(){
rot += 0.1;
if (!isTrue_r) jack_radius += 0.0005; else if (isTrue_r) jack_radius -= 0.0005; if (jack_radius >= 0.13) isTrue_r = true;
else if (jack_radius =