msmsms Posted June 2, 2014 at 09:43 PM Report #557996 Posted June 2, 2014 at 09:43 PM estou com este exemplo de codigo e estou a obter o erro error C2668: 'cos' : ambiguous call to overloaded function alguem me pode ajudar a executar este codigo? /* * horse.c * 1.It uses animation by pressing the left button of your mouse. * 2.It manipulates 3D Object by using glTranslate*(), glRotate*(), glScale*(). * 3.The program renders illumination by defining the desired light location. * 4.It sets material properties for the objects in the scene. * 5.It maximize performance by using Display List command. */ #include <stdlib.h> #include <stdio.h> #include <math.h> #include <windows.h> #include <glut.h> //#include <GL/glut.h> #ifndef M_PI #define M_PI 3.141592654 #endif #define NECKCON_LIST 1 #define NECKHEA_LIST 2 #define SHOULDER_LIST 3 #define HORSEBOD_LIST 4 #define HORSEFOO_LIST 5 #define CONNECT_LIST 6 #define FOOTTOE_LIST 7 #define HORSEHAN_LIST 8 #define TAIL_LIST 9 #define HEADGUN_LIST 10 #define FOREHED_LIST 11 #define HORSUPLEG_LIST 12 #define MONTAIN_LIST 13 //Start Motion Rate Variables #define LIGHT_TURN_RATE 10 #define TURN_RATE_VIEW 10 #define LEG1_RATE 10 #define UPPER_LEG_RATE 10 #define GUNHEAD_RATE -1 //End Motion Rate Variables static int solid_object = 0, TurnLight1 = 0, TurnLight2 = 0; static int neck1 = 0, angle = 0, step = 0, turn = 0, foreh = 0, GunHeadMove = 0; static int hip11 = 0, hip21 = 0, heel1 = 0, heel2, ankle1 = 0, ankle2 = 0 ; static int firstleg = 0, secondleg = 0, thirdleg = 0, fourthleg = 0, leg = 0; float elevation = 0.0, distance = 0.0, frame = 3.0; GLUquadricObj *qobj; /* start of material definitions */ GLfloat mat_specular[] = {0.628281, 0.555802, 0.366065, 1.0}; GLfloat mat_ambient[] = {0.24725, 0.1995, 0.0745, 1.0}; GLfloat mat_diffuse[] = {0.75164, 0.60648, 0.22648, 1.0}; GLfloat mat_shininess[] = {128.0 * 0.4}; GLfloat mat_specular2[] = {0.508273, 0.508273, 0.508373}; GLfloat mat_ambient2[] = {0.19225, 0.19225, 0.19225}; GLfloat mat_diffuse2[] = {0.50754, 0.50754, 0.50754}; GLfloat mat_shininess2[] = {128.0 * 0.6}; GLfloat mat_specular3[] = {0.296648, 0.296648, 0.296648}; GLfloat mat_ambient3[] = {0.25, 0.20725, 0.20725}; GLfloat mat_diffuse3[] = {1.0, 0.829, 0.829}; GLfloat mat_shininess3[] = {128.0 * 0.088}; GLfloat mat_specular4[] = {0.633, 0.727811, 0.633}; GLfloat mat_ambient4[] = {0.0215, 0.1745, 0.0215}; GLfloat mat_diffuse4[] = {0.07568, 0.61424, 0.07568}; GLfloat mat_shininess4[] = {128.0 * 0.6}; GLfloat mat_specular5[] = {0.60, 0.60, 0.50}; GLfloat mat_ambient5[] = {0.0, 0.0, 0.0}; GLfloat mat_diffuse5[] = {0.5, 0.5, 0.0}; GLfloat mat_shininess5[] = {128.0 * 0.25}; /* end of material definitions */ //Use for Debugging of Movements-Start void RaiseLeg1Forward(void) { foreh = (foreh + UPPER_LEG_RATE) % 360; } void //MaterialSet(float spec, float amb, float diff, float shin) MaterialSet(GLfloat spec[], GLfloat amb[], GLfloat diff[], GLfloat shin[]) //MaterialSet(void) { glMaterialfv(GL_FRONT, GL_SPECULAR, spec); glMaterialfv(GL_FRONT, GL_AMBIENT, amb); glMaterialfv(GL_FRONT, GL_DIFFUSE, diff); glMaterialfv(GL_FRONT, GL_SHININESS, shin); } void GunMove(void) { GunHeadMove = (GunHeadMove + GUNHEAD_RATE); } //Use for Debugging of Movements-Start void Box(float width, float height, float depth, char solid) { char i, j = 0; float x = width / 2.0, y = height / 2.0, z = depth / 2.0; for (i = 0; i < 4; i++) { glRotatef(90.0, 0.0, 0.0, 1.0); if (j) { if (!solid) glBegin(GL_LINE_LOOP); else glBegin(GL_QUADS); glNormal3f(-1.0, 0.0, 0.0); glVertex3f(-x, y, z); glVertex3f(-x, -y, z); glVertex3f(-x, -y, -z); glVertex3f(-x, y, -z); glEnd(); if (solid) { glBegin(GL_TRIANGLES); glNormal3f(0.0, 0.0, 1.0); glVertex3f(0.0, 0.0, z); glVertex3f(-x, y, z); glVertex3f(-x, -y, z); glNormal3f(0.0, 0.0, -1.0); glVertex3f(0.0, 0.0, -z); glVertex3f(-x, -y, -z); glVertex3f(-x, y, -z); glEnd(); } j = 0; } else { if (!solid) glBegin(GL_LINE_LOOP); else glBegin(GL_QUADS); glNormal3f(-1.0, 0.0, 0.0); glVertex3f(-y, x, z); glVertex3f(-y, -x, z); glVertex3f(-y, -x, -z); glVertex3f(-y, x, -z); glEnd(); if (solid) { glBegin(GL_TRIANGLES); glNormal3f(0.0, 0.0, 1.0); glVertex3f(0.0, 0.0, z); glVertex3f(-y, x, z); glVertex3f(-y, -x, z); glNormal3f(0.0, 0.0, -1.0); glVertex3f(0.0, 0.0, -z); glVertex3f(-y, -x, -z); glVertex3f(-y, x, -z); glEnd(); } j = 1; } } } void Triad(float width, float height, float depth, char solid) { char i, j = 0; float x = width / 2.0, y = height / 2.0, z = depth / 2.0; for (i = 0; i < 3; i++) { glRotatef(90.0, 0.0, 0.0, 1.0); if (j) { if (!solid) glBegin(GL_LINE_LOOP); else glBegin(GL_TRIANGLE_FAN); glNormal3f(-1.0, 0.0, 0.0); glVertex3f(-x, y, z); glVertex3f(-x, -y, z); glVertex3f(-x, -y, -z); glVertex3f(-x, y, -z); glEnd(); if (solid) { glBegin(GL_TRIANGLE_FAN); glNormal3f(0.0, 0.0, 1.0); glVertex3f(0.0, 0.0, z); glVertex3f(-x, y, z); glVertex3f(-x, -y, z); glNormal3f(0.0, 0.0, -1.0); glVertex3f(0.0, 0.0, -z); glVertex3f(-x, -y, -z); glVertex3f(-x, y, -z); glEnd(); } j = 0; } else { if (!solid) glBegin(GL_LINE_LOOP); else glBegin(GL_TRIANGLE_FAN); glNormal3f(-1.0, 0.0, 0.0); glVertex3f(-y, x, z); glVertex3f(-y, -x, z); glVertex3f(-y, -x, -z); glVertex3f(-y, x, -z); glEnd(); if (solid) { glBegin(GL_TRIANGLE_FAN); glNormal3f(0.0, 0.0, 1.0); glVertex3f(0.0, 0.0, z); glVertex3f(-y, x, z); glVertex3f(-y, -x, z); glNormal3f(0.0, 0.0, -1.0); glVertex3f(0.0, 0.0, -z); glVertex3f(-y, -x, -z); glVertex3f(-y, x, -z); glEnd(); } j = 1; } } } void Mountain(char solid) { int i, j; glNewList(MONTAIN_LIST, GL_COMPILE); MaterialSet(mat_specular4, mat_ambient4, mat_diffuse4, mat_shininess4); glColor3f(0.0, 0.0, 1.0); //Triad(2.75, 1.25, 2.5, solid); Box(20.0, 0.5, 30.0, solid); MaterialSet(mat_specular4, mat_ambient4, mat_diffuse4, mat_shininess4); glColor3f(0.6, 0.6, 0.6); glTranslatef(0.0, 0.0, -10.0); for (j = 0; j < 6; j++) { for (i = 0; i < 2; i++) { if (i) glScalef(-1.0, 1.0, 1.0); glTranslatef(10.0, 4.0, 0.0); Box(4.0, 8.0, 2.0, solid); // Triad(2.75, 2.25, 1.5, solid); glTranslatef(0.0, -1.0, -3.0); Box(4.0, 6.0, 2.0, solid); //Triad(3.75, 3.25, 2.5, solid); glTranslatef(-10.0, -3.0, 3.0); } glScalef(-1.0, 1.0, 1.0); glTranslatef(0.0, 0.0, 5.0); } glEndList(); } void Octagon(float side, float height, char solid) { char j; float x = sin(0.785398163) * side, y = side / 2.0, z = height / 2.0, c; c = x + y; for (j = 0; j < 8; j++) { glTranslatef(-c, 0.0, 0.0); if (!solid) glBegin(GL_LINE_LOOP); else glBegin(GL_QUADS); glNormal3f(-1.0, 0.0, 0.0); glVertex3f(0.0, -y, z); glVertex3f(0.0, y, z); glVertex3f(0.0, y, -z); glVertex3f(0.0, -y, -z); glEnd(); glTranslatef(c, 0.0, 0.0); if (solid) { glBegin(GL_TRIANGLES); glNormal3f(0.0, 0.0, 1.0); glVertex3f(0.0, 0.0, z); glVertex3f(-c, -y, z); glVertex3f(-c, y, z); glNormal3f(0.0, 0.0, -1.0); glVertex3f(0.0, 0.0, -z); glVertex3f(-c, y, -z); glVertex3f(-c, -y, -z); glEnd(); } glRotatef(45.0, 0.0, 0.0, 1.0); } } void gear(GLfloat inner_radius, GLfloat outer_radius, GLfloat width, GLint teeth, GLfloat tooth_depth) { GLint i; GLfloat r0, r1, r2; GLfloat angle, da; GLfloat u, v, len; r0 = inner_radius; r1 = outer_radius - tooth_depth / 2.0; r2 = outer_radius + tooth_depth / 2.0; da = 2.0 * M_PI / teeth / 4.0; glShadeModel(GL_FLAT); glNormal3f(0.0, 0.0, 1.0); /* draw front face */ glBegin(GL_QUAD_STRIP); for (i = 0; i <= teeth; i++) { angle = i * 2.0 * M_PI / teeth; glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5); glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5); if (i < teeth) { glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5); glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), width * 0.5); } } glEnd(); /* draw front sides of teeth */ glBegin(GL_QUADS); da = 2.0 * M_PI / teeth / 4.0; for (i = 0; i < teeth; i++) { angle = i * 2.0 * M_PI / teeth; glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5); glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), width * 0.5); glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), width * 0.5); glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), width * 0.5); } glEnd(); glNormal3f(0.0, 0.0, -1.0); /* draw back face */ glBegin(GL_QUAD_STRIP); for (i = 0; i <= teeth; i++) { angle = i * 2.0 * M_PI / teeth; glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5); glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5); if (i < teeth) { glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), -width * 0.5); glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5); } } glEnd(); /* draw back sides of teeth */ glBegin(GL_QUADS); da = 2.0 * M_PI / teeth / 4.0; for (i = 0; i < teeth; i++) { angle = i * 2.0 * M_PI / teeth; glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), -width * 0.5); glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), -width * 0.5); glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), -width * 0.5); glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5); } glEnd(); /* draw outward faces of teeth */ glBegin(GL_QUAD_STRIP); for (i = 0; i < teeth; i++) { angle = i * 2.0 * M_PI / teeth; glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5); glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5); u = r2 * cos(angle + da) - r1 * cos(angle); v = r2 * sin(angle + da) - r1 * sin(angle); len = sqrt(u * u + v * v); u /= len; v /= len; glNormal3f(v, -u, 0.0); glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), width * 0.5); glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), -width * 0.5); glNormal3f(cos(angle), sin(angle), 0.0); glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), width * 0.5); glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), -width * 0.5); u = r1 * cos(angle + 3 * da) - r2 * cos(angle + 2 * da); v = r1 * sin(angle + 3 * da) - r2 * sin(angle + 2 * da); glNormal3f(v, -u, 0.0); glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), width * 0.5); glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), -width * 0.5); glNormal3f(cos(angle), sin(angle), 0.0); } glVertex3f(r1 * cos(0), r1 * sin(0), width * 0.5); glVertex3f(r1 * cos(0), r1 * sin(0), -width * 0.5); glEnd(); glShadeModel(GL_SMOOTH); /* draw inside radius cylinder */ glBegin(GL_QUAD_STRIP); for (i = 0; i <= teeth; i++) { angle = i * 2.0 * M_PI / teeth; glNormal3f(-cos(angle), -sin(angle), 0.0); glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5); glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5); } glEnd(); } void RightTurnLight(void) { TurnLight1 = (TurnLight1 + LIGHT_TURN_RATE) % 360; } void LeftTurnLight(void) { TurnLight1 = (TurnLight1 - LIGHT_TURN_RATE) % 360; } void ForwardLight(void) { TurnLight2 = (TurnLight2 + LIGHT_TURN_RATE) % 360; } void BackwardLight(void) { TurnLight2 = (TurnLight2 - LIGHT_TURN_RATE) % 360; } /* end of light source position functions */ void RightTurn(void) { turn = (turn - TURN_RATE_VIEW) % 360; } void LeftTurn(void) { turn = (turn + TURN_RATE_VIEW) % 360; } void disable(void) { glDisable(GL_LIGHTING); glDisable(GL_DEPTH_TEST); glDisable(GL_NORMALIZE); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); } void lighting(void) { GLfloat position[] = {0.0, 0.0, 5.0, 1.0}; glRotatef((GLfloat) TurnLight1, 1.0, 0.0, 0.0); glRotatef((GLfloat) TurnLight2, 0.0, 1.0, 0.0); glRotatef(0.0, 1.0, 0.0, 0.0); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glEnable(GL_NORMALIZE); glDepthFunc(GL_LESS); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glLightfv(GL_LIGHT0, GL_POSITION, position); glLightf(GL_LIGHT0, GL_SPOT_CUTOFF, 80.0); glTranslatef(0.0, 0.0, 2.0); glDisable(GL_LIGHTING); Box(0.1, 0.1, 0.1, 0); glEnable(GL_LIGHTING); } //sphere neck void NeckConnect(char solid) { glNewList(NECKCON_LIST, GL_COMPILE); MaterialSet(mat_specular2, mat_ambient2, mat_diffuse2, mat_shininess2); glColor3f(0.0, 1.0, 0.0); if (!solid) gluQuadricDrawStyle(qobj, GLU_LINE); gluSphere(qobj, 0.6, 16, 16); glEndList(); } void NeckHead(char solid) { int i; glNewList(NECKHEA_LIST, GL_COMPILE); MaterialSet(mat_specular, mat_ambient, mat_diffuse, mat_shininess); glColor3f(1.0, 1.0, 0.0); Box(1.0, 2.0, 1.0, solid); glTranslatef(0.0, -0.95, 0.0); glRotatef(90.0, 1.0, 0.0, 0.0); MaterialSet(mat_specular2, mat_ambient2, mat_diffuse2, mat_shininess2); glColor3f(0.5, 0.5, 0.5); if (!solid) gluQuadricDrawStyle(qobj, GLU_LINE); gluCylinder(qobj, 0.4, 0.4, 1.5, 16, 10); MaterialSet(mat_specular, mat_ambient, mat_diffuse, mat_shininess); glColor3f(1.0, 1.0, 0.0); glRotatef(-90.0, 1.0, 0.0, 0.0); glTranslatef(-0.4, -1.85, 0.0); glRotatef(90.0, 0.0, 1.0, 0.0); for (i = 0; i < 2; i++) { if (!solid) gluQuadricDrawStyle(qobj, GLU_LINE); if (i) gluCylinder(qobj, 0.5, 0.5, 0.8, 16, 10); else gluCylinder(qobj, 0.2, 0.2, 0.8, 16, 10); } for (i = 0; i < 2; i++) { if (i) glScalef(-1.0, 1.0, 1.0); if (!solid) gluQuadricDrawStyle(qobj, GLU_LINE); if (i) glTranslatef(0.0, 0.0, 0.8); gluDisk(qobj, 0.2, 0.5, 16, 10); if (i) glTranslatef(0.0, 0.0, -0.8); } glScalef(-1.0, 1.0, 1.0); glRotatef(-90.0, 0.0, 1.0, 0.0); glTranslatef(0.4, 2.9, 0.0); glEndList(); } Shoulder(char solid) { int i; glNewList(SHOULDER_LIST, GL_COMPILE); MaterialSet(mat_specular, mat_ambient, mat_diffuse, mat_shininess); glColor3f(1.0, 1.0, 0.0); Octagon(0.7, 0.5, solid); for (i = 0; i < 2; i++) { if (i) glScalef(-1.0, 1.0, 1.0); glTranslatef(1.0, 0.0, 0.0); MaterialSet(mat_specular2, mat_ambient2, mat_diffuse2, mat_shininess2); glColor3f(0.5, 0.5, 0.5); if (!solid) gluQuadricDrawStyle(qobj, GLU_LINE); gluSphere(qobj, 0.2, 16, 16); glTranslatef(-1.0, 0.0, 0.0); } glScalef(-1.0, 1.0, 1.0); glEndList(); } void HorseBody(char solid) { glNewList(HORSEBOD_LIST, GL_COMPILE); MaterialSet(mat_specular2, mat_ambient2, mat_diffuse2, mat_shininess2); glColor3f(1.0, 1.0, 0.0); glTranslatef(1.0, 1.0, 1.0); if (!solid) { gluQuadricDrawStyle(qobj, GLU_LINE); } MaterialSet(mat_specular2, mat_ambient2, mat_diffuse2, mat_shininess2); glColor3f(0.0, 1.0, 0.0); glRotatef(90.0, 1.0 , 0.0, 0.0); gluCylinder(qobj, 2.0, 1.5, 2.0, 16, 10); glEndList(); } void HorseUpLeg(char solid) { int i; glNewList(HORSUPLEG_LIST, GL_COMPILE); MaterialSet(mat_specular, mat_ambient, mat_diffuse, mat_shininess); glColor3f(1.0, 1.0, 0.0); if (!solid) { gluQuadricDrawStyle(qobj, GLU_LINE); } glTranslatef(0.0, -1.0, 0.0); Box(0.4, 1.0, 0.7, solid); glTranslatef(0.0, -0.65, 0.0); for (i = 0; i < 5; i++) { Box(1.2, 0.3, 1.2, solid); glTranslatef(0.0, -0.2, 0.0); Box(1.0, 0.1, 1.0, solid); glTranslatef(0.0, -0.2, 0.0); } glTranslatef(0.0, -0.15, -0.4); Box(2.0, 0.5, 2.0, solid); glTranslatef(0.0, -0.3, -0.2); glRotatef(90.0, 1.0, 0.0, 0.0); MaterialSet(mat_specular2, mat_ambient2, mat_diffuse2, mat_shininess2); glColor3f(0.5, 0.5, 0.5); gluCylinder(qobj, 0.6, 0.6, 3.0, 16, 10); MaterialSet(mat_specular, mat_ambient, mat_diffuse, mat_shininess); glColor3f(1.0, 1.0, 0.0); glRotatef(-90.0, 1.0, 0.0, 0.0); glTranslatef(0.0, -1.5, 1.0); Box(1.5, 3.0, 0.5, solid); glTranslatef(0.0, -1.75, -0.8); Box(2.0, 0.5, 2.0, solid); glTranslatef(0.0, -0.9, -0.85); MaterialSet(mat_specular2, mat_ambient2, mat_diffuse2, mat_shininess2); glColor3f(0.5, 0.5, 0.5); gluCylinder(qobj, 0.8, 0.8, 1.8, 16, 10); for (i = 0; i < 2; i++) { if (i) glScalef(-1.0, 1.0, 1.0); if (!solid) gluQuadricDrawStyle(qobj, GLU_LINE); if (i) glTranslatef(0.0, 0.0, 1.8); gluDisk(qobj, 0.0, 0.8, 16, 10); if (i) glTranslatef(0.0, 0.0, -1.8); } glScalef(-1.0, 1.0, 1.0); glEndList(); } void HorseLowLeg(char solid) { float k, l; MaterialSet(mat_specular, mat_ambient, mat_diffuse, mat_shininess); glColor3f(1.0, 1.0, 0.0); for (k = 0.0; k < 2.0; k++) { for (l = 0.0; l < 2.0; l++) { glPushMatrix(); glTranslatef(k, 0.0, l); MaterialSet(mat_specular, mat_ambient, mat_diffuse, mat_shininess); glColor3f(1.0, 1.0, 0.0); Box(1.0, 0.5, 1.0, solid); glTranslatef(0.0, -0.45, 0.0); MaterialSet(mat_specular2, mat_ambient2, mat_diffuse2, mat_shininess2); glColor3f(0.5, 0.5, 0.5); if (!solid) glutWireSphere(0.2, 16, 10); else glutSolidSphere(0.2, 16, 10); if (leg) glRotatef((GLfloat) heel1, 1.0, 0.0, 0.0); else glRotatef((GLfloat) heel2, 1.0, 0.0, 0.0); /* glTranslatef(0.0, -0.2, 0.0); */ glTranslatef(0.0, -1.7, 0.0); MaterialSet(mat_specular, mat_ambient, mat_diffuse, mat_shininess); glColor3f(1.0, 1.0, 0.0); Box(0.25, 3.0, 0.25, solid); glTranslatef(0.0, -1.7, 0.0); MaterialSet(mat_specular2, mat_ambient2, mat_diffuse2, mat_shininess2); glColor3f(0.5, 0.5, 0.5); if (!solid) glutWireSphere(0.2, 16, 10); else glutSolidSphere(0.2, 16, 10); if (leg) glRotatef((GLfloat) - heel1, 1.0, 0.0, 0.0); else glRotatef((GLfloat) - heel2, 1.0, 0.0, 0.0); glTranslatef(0.0, -0.45, 0.0); MaterialSet(mat_specular, mat_ambient, mat_diffuse, mat_shininess); glColor3f(1.0, 1.0, 0.0); Box(1.0, 0.5, 1.0, solid); if (!k && !l) { int j; glTranslatef(-0.4, -0.8, 0.5); if (leg) glRotatef((GLfloat) ankle1, 1.0, 0.0, 0.0); else glRotatef((GLfloat) ankle2, 1.0, 0.0, 0.0); glRotatef(90.0, 0.0, 1.0, 0.0); if (!solid) gluQuadricDrawStyle(qobj, GLU_LINE); gluCylinder(qobj, 0.8, 0.8, 1.8, 16, 10); for (j = 0; j < 2; j++) { if (!solid) gluQuadricDrawStyle(qobj, GLU_LINE); if (j) { glScalef(-1.0, 1.0, 1.0); glTranslatef(0.0, 0.0, 1.8); } gluDisk(qobj, 0.0, 0.8, 16, 10); if (j) glTranslatef(0.0, 0.0, -1.8); } glScalef(-1.0, 1.0, 1.0); glRotatef(-90.0, 0.0, 1.0, 0.0); glTranslatef(0.95, -0.8, 0.0); glCallList(HORSEFOO_LIST); } glPopMatrix(); } } } void HorseFoot(char solid) { glNewList(HORSEFOO_LIST, GL_COMPILE); MaterialSet(mat_specular2, mat_ambient2, mat_diffuse2, mat_shininess2); glColor3f(0.5, 0.5, 0.5); glRotatef(90.0, 1.0, 0.0, 0.0); Octagon(1.5, 0.6, solid); glRotatef(-90.0, 1.0, 0.0, 0.0); glEndList(); } void Connector(char solid) { glNewList(CONNECT_LIST, GL_COMPILE); MaterialSet(mat_specular2, mat_ambient2, mat_diffuse2, mat_shininess2); glColor3f(0.0, 1.0, 0.0); //Green Knee glRotatef(95.0, 1.0, 0.0, 0.0); gear(1.25, 2.0, 1.25, 20, 0.7); glColor3f(0.0, 1.0, 0.0); //Green Knee gear(1.25, 2.0, 1.25, 20, 0.7); glRotatef(-95.0, 1.0, 0.0, 0.0); glEndList(); } void FootToes(char solid) { glNewList(FOOTTOE_LIST, GL_COMPILE); MaterialSet(mat_specular2, mat_ambient2, mat_diffuse2, mat_shininess2); glColor3f(0.0, 1.0, 0.0); //Green Knee glRotatef(95.0, 1.0, 0.0, 0.0); gear(1.25, 2.0, 1.25, 3, 0.7); glColor3f(0.0, 1.0, 0.0); //Green Knee glRotatef(-95.0, 1.0, 0.0, 0.0); glEndList(); } void Tail(char solid) { //t i, j, k = 0; glNewList(TAIL_LIST, GL_COMPILE); MaterialSet(mat_specular2, mat_ambient2, mat_diffuse2, mat_shininess2); glPushMatrix(); glPushMatrix(); glTranslatef(-0.25, 0.25, 0.0); Box(1.0, 0.25, 0.5, solid); //width, height, depth glPopMatrix(); glRotatef(90.0, 0.0, 0.0, 1.0); glTranslatef(-0.5, -0.25, 0.0); Triad(1.75, 0.25, 0.5, solid); //width, height, depth glPopMatrix(); glEndList(); } void HeadGun(char solid) { int i; glNewList(HEADGUN_LIST, GL_COMPILE); MaterialSet(mat_specular2, mat_ambient2, mat_diffuse2, mat_shininess2); glColor3f(0.5, 0.5, 0.5); if (!solid) { gluQuadricDrawStyle(qobj, GLU_LINE); } gluCylinder(qobj, 0.5, 0.5, 0.5, 16, 10); glTranslatef(0.0, 0.0, 0.5); gluDisk(qobj, 0.0, 0.5, 16, 10); for (i = 0; i < 5; i++) { glRotatef(72.0, 0.0, 0.0, 1.0); glTranslatef(0.0, 0.3, 0.0); if (!solid) { gluQuadricDrawStyle(qobj, GLU_LINE); } gluCylinder(qobj, 0.15, 0.15, 2.0, 16, 10); gluCylinder(qobj, 0.06, 0.06, 2.0, 16, 10); glTranslatef(0.0, 0.0, 2.0); gluDisk(qobj, 0.1, 0.15, 16, 10); gluCylinder(qobj, 0.1, 0.1, 0.1, 16, 5); glTranslatef(0.0, 0.0, 0.1); gluDisk(qobj, 0.06, 0.1, 16, 5); glTranslatef(0.0, -0.3, -2.1); } glEndList(); } void ForeHead(char solid) { char i; glNewList(FOREHED_LIST, GL_COMPILE); MaterialSet(mat_specular, mat_ambient, mat_diffuse, mat_shininess); glColor3f(1.0, 1.0, 0.0); for (i = 0; i < 5; i++) { glTranslatef(0.0, -0.1, -0.15); Box(0.6, 0.8, 0.2, solid); glTranslatef(0.0, 0.1, -0.15); Box(0.4, 0.6, 0.1, solid); } glTranslatef(0.0, 0.0, 2.45); Box(1.0, 1.0, 2.0, solid); glTranslatef(0.0, 0.0, -1.0); glEndList(); } void DrawHorse(void) { int i, j; // glPushMatrix(); //overall2 glScalef(0.85, 0.85, 0.85); glTranslatef(0.0, 0.0, 0.0); glPushMatrix(); glScalef(0.75, 0.75, 0.75); glPushMatrix(); glTranslatef(-1.5, 0.0, 0.0); glScalef(0.75, 0.75, 0.75); glCallList(NECKCON_LIST); glPopMatrix(); glPushMatrix(); glTranslatef(-2.0, 0.5, 0.0); glScalef(0.5, 0.5, 0.5); glRotatef(180.0, 0.0, 0.0, 1.0); glRotatef(45.0, 0.0, 0.0, 1.0); glRotatef(90.0, 0.0, 1.0, 0.0); glCallList(NECKHEA_LIST); glPopMatrix(); glPushMatrix(); glTranslatef(-1.0, -0.5, 0.0); glRotatef(90.0, 0.0, 1.0, 0.0); glRotatef(45.0, 1.0, 0.0, 0.0); glCallList(SHOULDER_LIST); //octagon glPopMatrix(); glPushMatrix(); glTranslatef(0.0, -1.25, 0.0); glScalef(2.5, 1.5, 2.0); glCallList(NECKCON_LIST); //sphere glPopMatrix(); glPushMatrix(); glTranslatef(1.5, -1.25, 0.0); glScalef(2.5, 1.5, 2.0); glCallList(NECKCON_LIST); //sphere glPopMatrix(); glPushMatrix(); glTranslatef(-0.25, -0.75, 0.75); glScalef(0.5, 0.5, 0.5); glRotatef(180.0, 0.0, 0.0, 1.0); glRotatef(45.0, 0.0, 0.0, 1.0); glRotatef(90.0, 0.0, 1.0, 0.0); glCallList(HORSEBOD_LIST); //Cone glPopMatrix(); glPopMatrix(); glPushMatrix(); glRotatef(firstleg, 0.0, 0.0, 1.0); //{ //1st Up Leg glPushMatrix(); glTranslatef(-0.28, -1.0, -0.5); glScalef(0.15, 0.15, 0.15); glRotatef(90.0, 0.0, 1.0, 0.0); glCallList(HORSUPLEG_LIST); glPopMatrix(); //1st Low Leg glPushMatrix(); glTranslatef(-0.5, -2.38, -0.4); glScalef(0.25, 0.25, 0.25); glRotatef(90.0, 0.0, 1.0, 0.0); HorseLowLeg(i); glPopMatrix(); glPopMatrix(); //} glPushMatrix(); glRotatef(fourthleg, 0.0, 0.0, 1.0); //{ //4rth Up Leg glPushMatrix(); glTranslatef(-0.28, -1.0, 0.9); glScalef(0.15, 0.15, 0.15); glRotatef(90.0, 0.0, 1.0, 0.0); glCallList(HORSUPLEG_LIST); glPopMatrix(); //4rth Low Leg glPushMatrix(); glTranslatef(-0.5, -2.38, 1.0); glScalef(0.25, 0.25, 0.25); glRotatef(90.0, 0.0, 1.0, 0.0); HorseLowLeg(i); glPopMatrix(); glPopMatrix(); //} glPushMatrix(); glRotatef(secondleg, 0.0, 0.0, 1.0); //{ //2nd Up Leg glPushMatrix(); glTranslatef(1.22, -1.0, -0.5); glScalef(0.15, 0.15, 0.15); glRotatef(90.0, 0.0, 1.0, 0.0); glCallList(HORSUPLEG_LIST); glPopMatrix(); //2nd Low Leg glPushMatrix(); glTranslatef(1.0, -2.38, -0.4); glScalef(0.25, 0.25, 0.25); glRotatef(90.0, 0.0, 1.0, 0.0); HorseLowLeg(i); glPopMatrix(); glPopMatrix(); //End 2nd Leg} glPushMatrix(); glRotatef(thirdleg, 0.0, 0.0, 1.0); //{ //3rd Up Leg glPushMatrix(); glTranslatef(1.22, -1.0, 0.9); glScalef(0.15, 0.15, 0.15); glRotatef(90.0, 0.0, 1.0, 0.0); glCallList(HORSUPLEG_LIST); glPopMatrix(); //3rd Low Leg glPushMatrix(); glTranslatef(1.0, -2.38, 1.0); glScalef(0.25, 0.25, 0.25); glRotatef(90.0, 0.0, 1.0, 0.0); HorseLowLeg(i); glPopMatrix(); glPopMatrix(); //End 3rd Leg} glPushMatrix(); //head group glRotatef(65.0, 0.0, 1.0, 0.0); glTranslatef(2.0, -1.0, -2.0); glPushMatrix(); glScalef(0.65, 0.65, 0.65); glTranslatef(-3.75, 3.25, 0.0); glRotatef(90.0, 1.0, 1.0, 0.0); glRotatef(-80.0, 0.0, 1.0, 0.0); glRotatef(150.0, 0.0, 1.0, 0.0); glRotatef(90.0, 1.0, 0.0, 0.0); glTranslatef(-0.5, 0.0, 1.0); //glTranslatef(1.0, GunHeadMove, 0.0); glTranslatef(1.0, -1.0, 0.0); glCallList(HEADGUN_LIST); glPopMatrix(); glPushMatrix(); glScalef(0.75, 0.75, 0.75); glTranslatef(-3.5, 3.5, 1.0); glRotatef(90.0, 1.0, 1.0, 0.0); glRotatef(-80.0, 0.0, 1.0, 0.0); // glRotatef(foreh, 1.0, 0.0, 0.0); glRotatef(100.0, 1.0, 0.0, 0.0); glCallList(FOREHED_LIST); glPopMatrix(); glPopMatrix(); //head group glPushMatrix(); glTranslatef(2.5, -1.0, 0.0); glCallList(TAIL_LIST); glPopMatrix(); glPopMatrix(); //Start Mountain glPushMatrix(); glRotatef(90.0, 0.0, 1.0, 0.0); //if (distance >= 20.136) if (distance >= 6.5) //if (distance <= 20.136) distance = 0.0; //glTranslatef(0.0, -5.0, -distance); glTranslatef(0.0, -5.0, distance); glCallList(MONTAIN_LIST); glTranslatef(0.0, 0.0, 10.0); glCallList(MONTAIN_LIST); glPopMatrix(); //End Mountain //overall2 glPopMatrix(); } void horse_walk(void) { float angle; static int step; if (step == 0 || step == 2) { /* for(frame=3.0; frame<=21.0; frame=frame+3.0){ */ if (frame >= 0.0 && frame <= 21.0) { if (frame == 0.0) frame = 3.0; angle = 90.0; if (frame > 0) { elevation = -(3.2055 - (cos((M_PI / 180) * angle) * 3.2055)); } else elevation = 0.0; if (step == 0) { hip11 = -(frame * 1.7); if (1.7 * frame > 15) heel1 = frame * 1.7; heel2 = 0; ankle1 = frame * 1.7; firstleg = frame * 0.5; secondleg = frame * 0.5; thirdleg = -frame * 0.5; fourthleg = -frame * 0.5; } else { if (1.7 * frame > 15) heel2 = frame * 1.7; heel1 = 0; ankle2 = frame * 1.7; if (frame > 0) hip11 = angle; else hip11 = 0; ankle1 = -hip11; firstleg = -frame * 0.5; secondleg = -frame * 0.5; thirdleg = frame * 0.5; fourthleg = frame * 0.5; } if (frame == 21) step++; if (frame < 21) frame = frame + 3.0; } } if (step == 1 || step == 3) { /* for(x=21.0; x>=0.0; x=x-3.0){ */ if (frame <= 21.0 && frame >= 0.0) { angle = 90.0; if (frame > 0) elevation = -(3.2055 - (cos((M_PI / 180) * angle) * 3.2055)); else elevation = 0.0; if (step == 1) { heel2 = 15; ankle1 = frame; if (frame > 0) hip21 = angle; else hip21 = 0; ankle2 = -hip21; firstleg = 0.5 * frame; secondleg = 0.5 * frame; thirdleg = -frame * 0.5; fourthleg = -frame * 0.5; } else { heel1 = 15; ankle2 = frame; if (frame > 0) hip11 = angle; else hip11 = 0; ankle1 = -hip11; firstleg = -frame * 0.5; secondleg = -frame * 0.5; thirdleg = frame * 0.5; fourthleg = frame * 0.5; } if (frame == 0.0) step++; if (frame > 0) frame = frame - 3.0; } } if (step == 4) step = 0; distance += 0.1678; glutPostRedisplay(); } void animation(void) { horse_walk(); } void Switcher(void) { if (solid_object) solid_object = 0; else solid_object = 1; } void menu_select(int mode) { switch (mode) { case 1: glutIdleFunc(animation); break; case 2: Switcher(); glutPostRedisplay(); break; case 3: exit(EXIT_SUCCESS); } } void init(void) { char i = 1; qobj = gluNewQuadric(); MaterialSet(mat_specular2, mat_ambient2, mat_diffuse2, mat_shininess2); glEnable(GL_DEPTH_TEST); NeckConnect(i); NeckHead(i); Shoulder(i); HorseBody(i); HorseFoot(i); HorseLowLeg(i); Connector(i); FootToes(i); Tail(i); HeadGun(i); ForeHead(i); HorseUpLeg(i); Mountain(i); } void display(void) { glClearColor(0.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glEnable(GL_DEPTH_TEST); glPushMatrix(); glRotatef((GLfloat) turn, 0.0, 1.0, 0.0); if (solid_object) { glPushMatrix(); lighting(); glPopMatrix(); } else disable(); glPushMatrix(); DrawHorse(); glPopMatrix(); glFlush(); glutSwapBuffers(); glPopMatrix(); } void reshape(int w, int h) { glViewport(0, 0, w, h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(65.0, (GLfloat) w / (GLfloat) h, 1.0, 20.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslatef(0.0, 1.2, -5.5); /* viewing transform */ } /* ARGSUSED1 */ void keyboard (unsigned char key, int x, int y) { int i; switch (key) { case 'k': { GunMove(); i++; glutPostRedisplay(); } break; case 'j': { RaiseLeg1Forward(); i++; glutPostRedisplay(); } break; case 27: exit(0); break; default: break; } } void keyspecial(int key, int x, int y) { int i = 0; switch (key) { case GLUT_KEY_RIGHT:{ RightTurn(); i++; } break; case GLUT_KEY_LEFT:{ LeftTurn(); i++; } break; } if (i) glutPostRedisplay(); } void MakeMenu(void) { int glut_menu[3]; glutCreateMenu(menu_select); glutAddMenuEntry("Start Walk", 1); glutAddMenuEntry("Toggle Wireframe", 2); glutAddMenuEntry("Quit", 3); glutAttachMenu(GLUT_LEFT_BUTTON); //glutAttachMenu(GLUT_RIGHT_BUTTON); } int main(int argc, char** argv) { sin((double)iX * iY); glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH); glutInitWindowSize(800, 600); glutInitWindowPosition (100, 100); glutCreateWindow ("ROBOTIC HORSE by Erwin L. De Rama"); init (); glutDisplayFunc(display); glutReshapeFunc(reshape); glutKeyboardFunc(keyboard); glutSpecialFunc(keyspecial); MakeMenu(); glutMainLoop(); return 0; }
Baderous Posted June 5, 2014 at 02:38 PM Report #558341 Posted June 5, 2014 at 02:38 PM http://cboard.cprogramming.com/cplusplus-programming/71392-c2668-ambiguous-call-overloaded-function.html http://stackoverflow.com/questions/6233132/c-compiler-error-ambiguous-call-to-overloaded-function
HappyHippyHippo Posted June 5, 2014 at 02:52 PM Report #558347 Posted June 5, 2014 at 02:52 PM (edited) parece que estas a compilar o código com um compilador de c++ que não sabe como converter os parâmetros da função cos. o meu gcc (compilador de C) compila isso sem problemas (tirando uma linha a mais na função main que parece ter sido um copy-paste perdido) terás de fazer um cast explícito para ele perceber qual das funções cos terá de chamar Edited June 5, 2014 at 02:53 PM by HappyHippyHippo IRC : sim, é algo que ainda existe >> #p@p Portugol Plus
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now