75#define SOLID_MECH_TORSO 1
76#define SOLID_MECH_HIP 2
77#define SOLID_MECH_SHOULDER 3
78#define SOLID_MECH_UPPER_ARM 4
79#define SOLID_MECH_FOREARM 5
80#define SOLID_MECH_UPPER_LEG 6
81#define SOLID_MECH_FOOT 7
82#define SOLID_MECH_ROCKET 8
83#define SOLID_MECH_VULCAN 9
84#define SOLID_ENVIRO 10
93#define SHOULDER_RATE 5
96#define UPPER_LEG_RATE 3
97#define UPPER_LEG_RATE_GROIN 10
98#define LIGHT_TURN_RATE 10
99#define VIEW_TURN_RATE 10
104#define PI 3.141592654
122{0.628281, 0.555802, 0.366065, 1.0};
124{0.24725, 0.1995, 0.0745, 1.0};
126{0.75164, 0.60648, 0.22648, 1.0};
131{0.508273, 0.508273, 0.508373, 1.0};
133{0.19225, 0.19225, 0.19225, 1.0};
135{0.50754, 0.50754, 0.50754, 1.0};
140{0.296648, 0.296648, 0.296648, 1.0};
142{0.25, 0.20725, 0.20725, 1.0};
144{1, 0.829, 0.829, 1.0};
149{0.633, 0.727811, 0.633, 1.0};
151{0.0215, 0.1745, 0.0215, 1.0};
153{0.07568, 0.61424, 0.07568, 1.0};
158{0.60, 0.60, 0.50, 1.0};
447Box(
float width,
float height,
float depth,
char solid)
450 float x = width / 2.0, y = height / 2.0, z = depth / 2.0;
452 for (i = 0; i < 4; i++) {
510 float x = sin(0.785398163) * side, y = side / 2.0, z = height / 2.0, c;
513 for (j = 0; j < 8; j++) {
547 GLfloat d = sqrt(v[1] * v[1] + v[2] * v[2] + v[3] * v[3]);
550 printf(
"zero length vector");
559NormXprod(
float v1[3],
float v2[3],
float v[3],
float out[3])
564 out[0] = v1[1] * v2[2] - v1[2] * v2[1];
565 out[1] = v1[2] * v2[0] - v1[0] * v2[2];
566 out[2] = v1[0] * v2[1] - v1[1] * v2[0];
590 Box(1.0, 1.0, 3.0, solid);
596 Box(0.5, 0.6, 2.0, solid);
598 Box(0.5, 0.6, 2.0, solid);
616 for (i = 0; i < 2; i++) {
645 Box(1.0, 0.5, 0.5, solid);
673 Box(1.0, 2.0, 1.0, solid);
690 for (i = 0; i < 2; i++) {
699 for (i = 0; i < 2; i++) {
707 gluDisk(joint1[i], 0.2, 0.5, 16, 10);
742 gluDisk(Mount_face, 0.0, 0.5, 16, 10);
744 for (i = 0; i < 5; i++) {
762 gluDisk(BarrelFace[i], 0.1, 0.15, 16, 10);
765 gluDisk(BarrelFace2[i], 0.06, 0.1, 16, 5);
781 for (i = 0; i < 5; i++) {
783 Box(0.6, 0.8, 0.2, solid);
785 Box(0.4, 0.6, 0.1, solid);
788 Box(1.0, 1.0, 2.0, solid);
811 Box(0.4, 1.0, 0.7, solid);
813 for (i = 0; i < 5; i++) {
814 Box(1.2, 0.3, 1.2, solid);
816 Box(1.0, 0.1, 1.0, solid);
820 Box(2.0, 0.5, 2.0, solid);
834 Box(1.5, 3.0, 0.5, solid);
836 Box(2.0, 0.5, 2.0, solid);
843 for (i = 0; i < 2; i++) {
851 gluDisk(joint[i], 0.0, 0.8, 16, 10);
885 for (k = 0.0; k < 2.0; k++) {
886 for (l = 0.0; l < 2.0; l++) {
893 Box(1.0, 0.5, 1.0, solid);
915 Box(0.25, 3.0, 0.25, solid);
935 Box(1.0, 0.5, 1.0, solid);
948 for (j = 0; j < 2; j++) {
956 gluDisk(ankle_face[j], 0.0, 0.8, 16, 10);
986 Box(2.0, 0.5, 3.0, solid);
990 Box(1.2, 0.5, 3.0, solid);
997 Box(2.0, 3.0, 4.0, solid);
999 for (i = 0; i < 2; i++) {
1000 for (j = 0; j < 3; j++) {
1035 Box(20.0, 0.5, 30.0, solid);
1040 for (j = 0; j < 6; j++) {
1041 for (i = 0; i < 2; i++) {
1045 Box(4.0, 8.0, 2.0, solid);
1047 Box(4.0, 6.0, 2.0, solid);
1080 {0.0, 0.0, 2.0, 1.0};
1099 Box(0.1, 0.1, 0.1, 0);
1134 for (i = 0; i < 2; i++) {
1176 for (j = 0; j < 2; j++) {
1291 if (step == 0 || step == 2) {
1296 angle = (180 /
PI) * (acos(((cos((
PI / 180) *
frame) * 2.043) + 1.1625) / 3.2059));
1298 elevation = -(3.2055 - (cos((
PI / 180) * angle) * 3.2055));
1303 if (1.7 *
frame > 15)
1318 if (1.7 *
frame > 15)
1338 if (step == 1 || step == 3) {
1340 if (frame <= 21.0 && frame >= 0.0) {
1341 angle = (180 /
PI) * (acos(((cos((
PI / 180) *
frame) * 2.043) + 1.1625) / 3.2029));
1343 elevation = -(3.2055 - (cos((
PI / 180) * angle) * 3.2055));
1639 printf(
"at the shoulders:");
1640 printf(
"forward : q,w");
1641 printf(
"backwards : a,s");
1642 printf(
"outwards : z,x");
1643 printf(
"inwards : Z,X");
1645 glut_menu[6] = glutCreateMenu(null_select);
1646 printf(
"upwards : Q,W\n");
1647 printf(
"downwards : A,S\n");
1648 printf(
"outwards : 1,2\n");
1649 printf(
"inwards : 3,4\n");
1651 glut_menu[1] = glutCreateMenu(null_select);
1652 printf(
" : Page_up\n");
1654 glut_menu[8] = glutCreateMenu(null_select);
1655 printf(
"forward : y,u\n");
1656 printf(
"backwards : h.j\n");
1657 printf(
"outwards : Y,U\n");
1658 printf(
"inwards : H,J\n");
1660 glut_menu[9] = glutCreateMenu(null_select);
1661 printf(
"forward : n,m\n");
1662 printf(
"backwards : N,M\n");
1664 glut_menu[9] = glutCreateMenu(null_select);
1665 printf(
"forward : n,m\n");
1666 printf(
"backwards : N,M\n");
1668 glut_menu[10] = glutCreateMenu(null_select);
1669 printf(
"toes up : K,L\n");
1670 printf(
"toes down : k,l\n");
1672 glut_menu[11] = glutCreateMenu(null_select);
1673 printf(
"right : right arrow\n");
1674 printf(
"left : left arrow\n");
1675 printf(
"down : up arrow\n");
1676 printf(
"up : down arrow\n");
1678 glut_menu[12] = glutCreateMenu(null_select);
1679 printf(
"right : p\n");
1680 printf(
"left : i\n");
1682 printf(
"down : o\n");
1684 glut_menu[4] = glutCreateMenu(NULL);
1685 glutAddSubMenu(
"at the elbows?", glut_menu[6]);
1687 glut_menu[7] = glutCreateMenu(NULL);
1688 glutAddSubMenu(
"at the hip? ", glut_menu[8]);
1689 glutAddSubMenu(
"at the knees?", glut_menu[9]);
1690 glutAddSubMenu(
"at the ankles? ", glut_menu[10]);
1692 printf(
"turn left : d\n");
1693 printf(
"turn right : g\n");
1695 glut_menu[3] = glutCreateMenu(null_select);
1696 printf(
"tilt backwards : f\n");
1697 printf(
"tilt forwards : r\n");
1699 glut_menu[0] = glutCreateMenu(NULL);
1700 glutAddSubMenu(
"move the arms.. ", glut_menu[4]);
1701 glutAddSubMenu(
"fire the vulcan guns?", glut_menu[1]);
1702 glutAddSubMenu(
"move the legs.. ", glut_menu[7]);
1703 glutAddSubMenu(
"move the torso?", glut_menu[2]);
1704 glutAddSubMenu(
"move the hip?", glut_menu[3]);
1705 glutAddSubMenu(
"rotate the scene..", glut_menu[11]);
1707 glutAddSubMenu(
"rotate the light source..", glut_menu[12]);
1710 glutCreateMenu(menu_select);
1712 printf(
"Start Walk", 1);
1713 printf(
"Stop Walk", 2);
1715 printf(
"Toggle Wireframe", 3);
1716 glutAddSubMenu(
"How do I ..", glut_menu[0]);
1718 glutAttachMenu(GLUT_LEFT_BUTTON);
1719 glutAttachMenu(GLUT_RIGHT_BUTTON);
1737extern int count_triangles;
1742#ifdef LINUX_TEST_FLOAT
1743#include <fpu_control.h>
1749#ifdef LINUX_TEST_FLOAT
1751 __setfpucw ( 0x1372 );
1756 return ui_loop(argc, argv,
"mech");
void glColor3f(float x, float y, float z)
void glVertex3f(float x, float y, float z)
void glNormal3f(float x, float y, float z)
void glCallList(unsigned int list)
void glClearColor(float r, float g, float b, float a)
void glViewport(int x, int y, int width, int height)
void glNewList(unsigned int list, int mode)
void glMatrixMode(int mode)
void glLightf(int light, int type, float v)
void glPolygonMode(int face, int mode)
void glLightfv(int light, int type, float *v)
void glMaterialfv(int mode, int type, float *v)
void glRotatef(float angle, float x, float y, float z)
void glTranslatef(float x, float y, float z)
void glLoadIdentity(void)
void glScalef(float x, float y, float z)
void gluQuadricDrawStyle(GLUquadricObj *obj, int style)
void gluPerspective(GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar)
void gluDisk(GLUquadricObj *qobj, GLdouble innerRadius, GLdouble outerRadius, GLint slices, GLint loops)
void gluSphere(GLUquadricObj *qobj, float radius, int slices, int stacks)
void gluCylinder(GLUquadricObj *qobj, GLdouble baseRadius, GLdouble topRadius, GLdouble height, GLint slices, GLint stacks)
GLUquadricObj * gluNewQuadric(void)
void RaiseLeg1Forward(void)
void elbow1Subtract(void)
void RaiseLeg2Outwards(void)
#define SOLID_MECH_VULCAN
void LowerLeg1Backwards(void)
#define SOLID_MECH_UPPER_LEG
void MechTorso(char solid)
void RaiseLeg1Outwards(void)
int main(int argc, char **argv)
#define SOLID_MECH_FOREARM
void shoulder3Subtract(void)
void LowerLeg(char solid)
void Box(float width, float height, float depth, char solid)
void animation_walk(void)
#define SOLID_MECH_ROCKET
void LowerLeg1Inwards(void)
GLenum key(int key, GLenum mask)
void elbow2Subtract(void)
void Octagon(float side, float height, char solid)
void shoulder2Subtract(void)
void RaiseLeg2Forward(void)
void shoulder1Subtract(void)
void LightBackwards(void)
void SetMaterial(GLfloat spec[], GLfloat amb[], GLfloat diff[], GLfloat shin[])
void Ankle2Subtract(void)
void shoulder4Subtract(void)
void VulcanGun(char solid)
#define SOLID_MECH_UPPER_ARM
void LightTurnRight(void)
void RocketPod(char solid)
void UpperLeg(char solid)
void Ankle1Subtract(void)
void LowerLeg2Backwards(void)
void MechTiltSubtract(void)
void reshape(int w, int h)
void Shoulder(char solid)
void LowerLeg2Inwards(void)
void UpperArm(char solid)
#define SOLID_MECH_SHOULDER
void RotateSubtract(void)
#define UPPER_LEG_RATE_GROIN
int ui_loop(int argc, char **argv, const char *name)