PDA

View Full Version : Simple Newbie Problem



Emrah Bozkurt
11-27-2003, 05:14 AM
Dear All,

I am a mech. eng. and very new to programming..Not only new to OpenGL but also to C++. I am trying to model a 6-DOF robot. I'll simulate its inverse kinematics in Matlab and use the output data in my OpenGL program to animate the robot. In the attachment, you will see that the robot that I modeled has some problems. First one is that I do not have any edges for the cylinders that I used for the robot. Second, when I rotate the body, the colors are getting mixed to each other. Next, I want to add sound to my program. For example, when I rotate one joint, I want the program to play an appropriate sound during that rotation time.
Any help will be appreciated.
Thanks a lot in advance.

emrah bozkurt

Emrah Bozkurt
11-27-2003, 05:25 AM
Sorry, that I am unable to attach the file, but the code is the following:

//Header Files


#include <GL/glaux.h>
#include <GL/glut.h>
#include <GL/glu.h>
#include <GL/gl.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <math.h>
#include <windows.h>


//Variable Initialization


GLuint startList;

static int shoulder = 0.0, elbow = 0.0, root = 0.0, rot1 = 0.0, rot2 = 0.0, rot3 = 0.0;

static int wrst1 = 0.0, wrst2 = 0.0, wrst3 = 0.0;

int k = 0, j = 0;

float x1 = 0.0, x2 = 0.0, x3 = 0.0;

float r1 = 0.0, r2 = 0.0, r3 = 0.0;


//Object Creations


void init(void)
{


GLUquadricObj *qobj;


glClearColor (0.0, 0.0, 0.0, 0.0);


glShadeModel (GL_SMOOTH);


startList=glGenLists(22);
qobj=gluNewQuadric();


gluQuadricDrawStyle(qobj,GLU_FILL);
gluQuadricNormals(qobj,GLU_SMOOTH);
glNewList(startList,GL_COMPILE);
gluCylinder(qobj,0.2,0.2,0.6,20,8);
glEndList();


gluQuadricDrawStyle(qobj,GLU_FILL);
gluQuadricNormals(qobj,GLU_NONE);
glNewList(startList+1,GL_COMPILE);
gluPartialDisk(qobj,0.0,0.1,20.0,1.0,0.0,360);
glEndList();

gluQuadricDrawStyle(qobj,GLU_FILL);
gluQuadricNormals(qobj,GLU_SMOOTH);
glNewList(startList+2,GL_COMPILE);
gluCylinder(qobj,0.1,0.1,1.76,20,8);
glEndList();


gluQuadricDrawStyle(qobj,GLU_FILL);
gluQuadricNormals(qobj,GLU_SMOOTH);
glNewList(startList+3,GL_COMPILE);
gluCylinder(qobj,1.2,1.0,0.5,20,8);
glEndList();

gluQuadricDrawStyle(qobj,GLU_FILL);
gluQuadricNormals(qobj,GLU_NONE);
glNewList(startList+4,GL_COMPILE);
gluPartialDisk(qobj,0.0,1.0,20.0,1.0,180,360);
glEndList();


gluQuadricDrawStyle(qobj,GLU_FILL);
gluQuadricNormals(qobj,GLU_SMOOTH);
glNewList(startList+5,GL_COMPILE);
gluCylinder(qobj,0.01,0.01,1.0,20,8);
glEndList();


gluQuadricDrawStyle(qobj,GLU_FILL);
gluQuadricNormals(qobj,GLU_NONE);
glNewList(startList+6,GL_COMPILE);
gluPartialDisk(qobj,0.0,0.15,20.0,1.0,180,360);
glEndList();


gluQuadricDrawStyle(qobj,GLU_FILL);
gluQuadricNormals(qobj,GLU_SMOOTH);
glNewList(startList+7,GL_COMPILE);
gluCylinder(qobj,0.15,0.15,0.2,20,8);
glEndList();


gluQuadricDrawStyle(qobj,GLU_FILL);
gluQuadricNormals(qobj,GLU_SMOOTH);
glNewList(startList+8,GL_COMPILE);
gluCylinder(qobj,0.15,0.15,0.05,20,8);
glEndList();


gluQuadricDrawStyle(qobj,GLU_FILL);
gluQuadricNormals(qobj,GLU_NONE);
glNewList(startList+9,GL_COMPILE);
gluPartialDisk(qobj,0.0,1.2,20.0,1.0,180,360);
glEndList();

gluQuadricDrawStyle(qobj,GLU_FILL);
gluQuadricNormals(qobj,GLU_SMOOTH);
glNewList(startList+10,GL_COMPILE);
gluCylinder(qobj,0.1,0.1,1.80,20,8);
glEndList();

gluQuadricDrawStyle(qobj,GLU_FILL);
gluQuadricNormals(qobj,GLU_SMOOTH);
glNewList(startList+11,GL_COMPILE);
gluCylinder(qobj,0.2,0.15,0.95,20,8);
glEndList();

gluQuadricDrawStyle(qobj,GLU_FILL);
gluQuadricNormals(qobj,GLU_SMOOTH);
glNewList(startList+12,GL_COMPILE);
gluCylinder(qobj,0.1,0.05,0.2,20,8);
glEndList();

gluQuadricDrawStyle(qobj,GLU_FILL);
gluQuadricNormals(qobj,GLU_SMOOTH);
glNewList(startList+13,GL_COMPILE);
gluCylinder(qobj,0.01,0.01,0.5,20,8);
glEndList();

gluQuadricDrawStyle(qobj,GLU_FILL);
gluQuadricNormals(qobj,GLU_SMOOTH);
glNewList(startList+14,GL_COMPILE);
gluCylinder(qobj,0.3,0.3,0.7,20,8);
glEndList();


gluQuadricDrawStyle(qobj,GLU_FILL);
gluQuadricNormals(qobj,GLU_NONE);
glNewList(startList+15,GL_COMPILE);
gluPartialDisk(qobj,0.0,0.3,20.0,1.0,0.0,360);
glEndList();

gluQuadricDrawStyle(qobj,GLU_FILL);
gluQuadricNormals(qobj,GLU_SMOOTH);
glNewList(startList+16,GL_COMPILE);
gluCylinder(qobj,0.55,0.3,1.76,20,8);
glEndList();


gluQuadricDrawStyle(qobj,GLU_FILL);
gluQuadricNormals(qobj,GLU_SMOOTH);
glNewList(startList+17,GL_COMPILE);
gluCylinder(qobj,0.1,0.1,0.4,20,8);
glEndList();


gluQuadricDrawStyle(qobj,GLU_FILL);
gluQuadricNormals(qobj,GLU_NONE);
glNewList(startList+18,GL_COMPILE);
gluPartialDisk(qobj,0.0,0.05,20.0,1.0,180,360);
glEndList();


gluQuadricDrawStyle(qobj,GLU_FILL);
gluQuadricNormals(qobj,GLU_SMOOTH);
glNewList(startList+19,GL_COMPILE);
gluCylinder(qobj,0.05,0.05,0.05,20,8);
glEndList();


gluQuadricDrawStyle(qobj,GLU_FILL);
gluQuadricNormals(qobj,GLU_NONE);
glNewList(startList+20,GL_COMPILE);
gluPartialDisk(qobj,0.0,0.2,20.0,1.0,0.0,360);
glEndList();


gluQuadricDrawStyle(qobj,GLU_FILL);
gluQuadricNormals(qobj,GLU_SMOOTH);
glNewList(startList+21,GL_COMPILE);
gluCylinder(qobj,0.1,0.1,0.95,20,8);
glEndList();


}


//Display Function

void display(void)
{



glClear (GL_COLOR_BUFFER_BIT);



glPushMatrix();


glTranslated (-5.0,0.0,-5.0);


//Screen Adjustments


glPushMatrix();

glRotatef(50,1,0,0);

glRotatef ((GLfloat) rot1, 1.0, 0.0, 0.0);
glRotatef ((GLfloat) rot2, 0.0, 1.0, 0.0);
glRotatef ((GLfloat) rot3, 0.0, 0.0, 1.0);

glTranslated (5.0,0.0,5.0);

glTranslated(0,0,-1.6);
glRotatef(-50,0,1,0);
glRotatef(5,1,0,0);


glTranslated (x1,0.0,0.0);
glTranslated (0.0,x2,0.0);
glTranslated (0.0,0.0,x3);


glRotatef ((GLfloat) r1, 1.0, 0.0, 0.0);
glRotatef ((GLfloat) r2, 0.0, 1.0, 0.0);
glRotatef ((GLfloat) r3, 0.0, 0.0, 1.0);

//Drawing of the white part of the floor


glPushMatrix();

glColor4d(1.0,1.0,1.0,1.0);

glBegin(GL_QUADS);
glVertex3f(-5,0,5);
glVertex3f(5,0,5);
glVertex3f(5,0,-5);
glVertex3f(-5,0,-5);
glEnd();


//Drawing of the black squares of the floor


glColor4d(0.6,0.4,0.8,1.0);

glBegin(GL_QUADS);
for(k=0;k<=2;++k){
glVertex3f(-5,0,5-4*k);
glVertex3f(-3,0,5-4*k);
glVertex3f(-3,0,3-4*k);
glVertex3f(-5,0,3-4*k);
}
glEnd();


glBegin(GL_QUADS);
for(k=0;k<=2;++k){
glVertex3f(-1,0,5-4*k);
glVertex3f(1,0,5-4*k);
glVertex3f(1,0,3-4*k);
glVertex3f(-1,0,3-4*k);
}
glEnd();


glBegin(GL_QUADS);
for(k=0;k<=2;++k){
glVertex3f(3,0,5-4*k);
glVertex3f(5,0,5-4*k);
glVertex3f(5,0,3-4*k);
glVertex3f(3,0,3-4*k);
}
glEnd();


glBegin(GL_QUADS);
for(k=0;k<=1;++k){
glVertex3f(-3,0,3-4*k);
glVertex3f(-1,0,3-4*k);
glVertex3f(-1,0,1-4*k);
glVertex3f(-3,0,1-4*k);
}
glEnd();


glBegin(GL_QUADS);
for(k=0;k<=1;++k){
glVertex3f(1,0,3-4*k);
glVertex3f(3,0,3-4*k);
glVertex3f(3,0,1-4*k);
glVertex3f(1,0,1-4*k);
}
glEnd();


//Drawing of the coordinate system arrows


glTranslated (-5.0,0.0,-5.0);


glPushMatrix();
glColor4d(0.0,1.0,0.0,1.0);
glCallList(startList+5);
glTranslated (0.0,0.0,1.0);

glPushMatrix();
glColor4d(1.0,0.0,0.0,1.0);
glutSolidCone(0.02,0.2,20,8);
glTranslated (0.0,0.0,-1.0);
glRotatef (90.0,0.0,1.0,0.0);

glPushMatrix();
glColor4d(0.0,1.0,0.0,1.0);
glCallList(startList+5);
glTranslated (0.0,0.0,1.0);

glPushMatrix();
glColor4d(1.0,0.0,0.0,1.0);
glutSolidCone(0.02,0.2,20,8);
glTranslated (0.0,0.0,-1.0);
glRotatef (-90.0,0.0,1.0,0.0);
glRotatef (-90.0,1.0,0.0,0.0);

glPushMatrix();
glColor4d(0.0,1.0,0.0,1.0);
glCallList(startList+5);
glTranslated (0.0,0.0,1.0);

glPushMatrix();
glColor4d(1.0,0.0,0.0,1.0);
glutSolidCone(0.02,0.2,20,8);
glTranslated (0.0,0.0,-1.0);
glRotatef (90.0,1.0,0.0,0.0);

glPushMatrix();
glTranslated (5.0,0.0,5.0);
glPushMatrix();
glRotatef (-90.0,1.0,0.0,0.0);


//Drawing of the robot which represents ABB IRB 140


//Base Link


glPushMatrix();
glColor4d(1.0,0.0,0.0,1.0);
glCallList(startList+3);



glPushMatrix();
glTranslated (0.0, 0.0, 0.0);
glPushMatrix();
glColor4d(1.0,0.0,0.0,1.0);
glCallList(startList+9);


//Joint 1 (Actually the top face of the base link but we may assume it to be a pseudo joint)

glPushMatrix();
glRotatef (275, 0.0, 0.0, 1.0);
glRotatef ((GLfloat) root, 0.0, 0.0, 1.0);
glTranslated (0.0, 0.0, 0.5);
glPushMatrix();
glColor4d(0.0,1.0,0.0,1.0);
glCallList(startList+4);


//Link 1


glPushMatrix();
glTranslated (0.35, 0.0, 0.0);
glPushMatrix();
glColor4d(1.0,0.0,0.0,1.0);
glCallList(startList+15);



glPushMatrix();
glTranslated (0.0, 0.0, 0.0);
glPushMatrix();
glColor4d(1.0,0.0,0.0,1.0);
glCallList(startList+16);


glPushMatrix();
glTranslated (0.0, 0.0, 1.76);
glPushMatrix();
glColor4d(1.0,0.0,0.0,1.0);
glCallList(startList+15);


//Joint 2


glPushMatrix();
glRotatef (90.0,1.0,0.0,0.0);
glTranslated (0.0, 0.0, -0.35);
glRotatef ((GLfloat) shoulder, 0.0, 0.0, 1.0);
glColor4d(1.0,1.0,0.0,1.0);
glCallList(startList+15);




glPushMatrix();
glTranslated (0.0, 0.0, 0.0);
glPushMatrix();
glColor4d(1.0,1.0,0.0,1.0);
glCallList(startList+14);



glPushMatrix();
glTranslated (0.0, 0.0, 0.7);
glPushMatrix();
glColor4d(1.0,1.0,0.0,1.0);
glCallList(startList+15);

//Link 2


glPushMatrix();
glTranslated (0.0, 0.0, -0.35);
glTranslated (0.0, 0.0, 0.2);
glRotatef (-90.0,1.0,0.0,0.0);
glPushMatrix();
glColor4d(1.0,0.0,0.0,1.0);
glCallList(startList+1);



glPushMatrix();
glTranslated (0.0,0.0,0.0);
glPushMatrix();
glColor4d(1.0,0.0,0.0,1.0);
glCallList(startList+10);


glPushMatrix();
glRotatef (90.0,1.0,0.0,0.0);
glTranslated (0.0, 0.0, -0.4);
glRotatef (-90.0,1.0,0.0,0.0);
glPushMatrix();
glColor4d(1.0,0.0,0.0,1.0);
glCallList(startList+1);



glPushMatrix();
glTranslated (0.0,0.0,0.0);
glPushMatrix();
glColor4d(1.0,0.0,0.0,1.0);
glCallList(startList+10);



glPushMatrix();
glRotatef (90.0,1.0,0.0,0.0);
glTranslated(0.0,0.0,0.2);
glTranslated (0.0, 0.0, -0.35);
glColor4d(1.0,1.0,0.0,1.0);
glCallList(startList+14);
glTranslated (0.0, 0.0, 0.0);
glCallList(startList+15);
glTranslated (0.0, 0.0, 0.7);
glCallList(startList+15);
glTranslated (0.0, 0.0, -0.35);


glPushMatrix();
glTranslated (0.0, 0.0, 0.2);
glRotatef (-90.0,1.0,0.0,0.0);
glTranslated (0.0,0.0,1.8);
glPushMatrix();
glColor4d(1.0,0.0,0.0,1.0);
glCallList(startList+1);


glPushMatrix();
glRotatef (90.0,1.0,0.0,0.0);
glTranslated (0.0, 0.0, -0.4);
glRotatef (-90.0,1.0,0.0,0.0);
glTranslated (0.0,-0.2,0.0);
glPushMatrix();
glColor4d(1.0,0.0,0.0,1.0);
glCallList(startList+1);


//Joint 3


glPushMatrix();
glTranslated (0.0, 0.3, 0.0);
glRotatef (90.0,1.0,0.0,0.0);
glRotatef ((GLfloat) elbow, 0.0, 0.0, 1.0);
glPushMatrix();
glColor4d(1.0,1.0,0.0,1.0);
glCallList(startList);


glPushMatrix();
glTranslated (0.0, 0.0, 0.0);
glPushMatrix();
glColor4d(1.0,1.0,0.0,1.0);
glCallList(startList+20);


glPushMatrix();
glTranslated (0.0, 0.0, 0.6);
glPushMatrix();
glColor4d(1.0,1.0,0.0,1.0);
glCallList(startList+20);

//link 3


glPushMatrix();
glRotatef (-90.0,1.0,0.0,0.0);
glRotatef (90.0,0.0,1.0,0.0);
glTranslated (0.0, 0.3, 0.0);
glPushMatrix();
glColor4d(1.0,0.0,0.0,1.0);
glCallList(startList+20);


glPushMatrix();
glTranslated (0.0,0.0,0.0);
glPushMatrix();
glColor4d(1.0,0.0,0.0,1.0);
glCallList(startList+11);

glPushMatrix();
glRotatef (90.0,1.0,0.0,0.0);
glTranslated (0.0, 0.0, -0.3);
glColor4d(1.0,1.0,0.0,1.0);
glCallList(startList);
glTranslated (0.0, 0.0, 0.0);
glCallList(startList+20);
glTranslated (0.0, 0.0, 0.6);
glCallList(startList+20);
glTranslated (0.0, 0.0, -0.3);


glPushMatrix();
glRotatef (-90.0,1.0,0.0,0.0);
glTranslated (0.0,0.0,0.95);
glPushMatrix();
glColor4d(1.0,0.0,0.0,1.0);
glCallList(startList+6);


//Joint 4 (First member of the spherical joint)


glPushMatrix();
glTranslated (0.0, 0.0, 0.0);
glRotatef ((GLfloat) wrst1, 0.0, 0.0, 1.0);
glPushMatrix();
glColor4d(0.0,1.0,0.0,1.0);
glCallList(startList+6);


glPushMatrix();
glTranslated (0.0,0.0,0.0);
glPushMatrix();
glColor4d(0.0,1.0,0.0,1.0);
glCallList(startList+7);


glPushMatrix();
glTranslated (0.0, 0.0, 0.2);
glPushMatrix();
glColor4d(0.0,1.0,0.0,1.0);
glCallList(startList+6);

//Link 4

glPushMatrix();
glTranslated (0.0,0.0,-0.2);
glPushMatrix();
glColor4d(1.0,0.0,0.0,1.0);
glCallList(startList+21);

glPushMatrix();
glTranslated (0.0,0.0,0.0);
glPushMatrix();
glColor4d(1.0,0.0,0.0,1.0);
glCallList(startList+1);


glPushMatrix();
glColor4d(0.0,1.0,0.0,1.0);
glCallList(startList+7);
glTranslated (0.0, 0.0, 0.2);
glColor4d(0.0,1.0,0.0,1.0);
glCallList(startList+6);
glTranslated (0.0, 0.0, -0.2);
glCallList(startList+6);

glPushMatrix();
glTranslated (0.0,0.0,0.95);
glPushMatrix();
glColor4d(1.0,0.0,0.0,1.0);
glCallList(startList+1);

//Joint 5 (Second member of the spherical joint)


glPushMatrix();
glRotatef (90.0,1.0,0.0,0.0);
glTranslated (0.0, 0.0, -0.2);
glRotatef ((GLfloat) wrst2, 0.0, 0.0, 1.0);
glColor4d(1.0,1.0,0.0,1.0);
glCallList(startList+1);




glPushMatrix();
glTranslated (0.0, 0.0, 0.0);
glPushMatrix();
glColor4d(1.0,1.0,0.0,1.0);
glCallList(startList+17);



glPushMatrix();
glTranslated (0.0, 0.0, 0.4);
glPushMatrix();
glColor4d(1.0,1.0,0.0,1.0);
glCallList(startList+1);


//Link 5


glPushMatrix();
glTranslated (0.0, 0.0, -0.2);
glRotatef (-90.0,1.0,0.0,0.0);
glPushMatrix();
glColor4d(1.0,0.0,0.0,1.0);
glCallList(startList+1);


glPushMatrix();
glTranslated (0.0,0.0,0.0);
glPushMatrix();
glColor4d(1.0,0.0,0.0,1.0);
glCallList(startList+12);


glPushMatrix();
glRotatef (90.0,1.0,0.0,0.0);
glTranslated (0.0, 0.0, -0.2);
glColor4d(1.0,1.0,0.0,1.0);
glCallList(startList+17);
glTranslated (0.0, 0.0, 0.0);
glCallList(startList+1);
glTranslated (0.0, 0.0, 0.4);
glCallList(startList+1);
glTranslated (0.0, 0.0, -0.2);

glPushMatrix();
glRotatef (-90.0,1.0,0.0,0.0);
glTranslated (0.0,0.0,0.2);
glPushMatrix();
glColor4d(1.0,0.0,0.0,1.0);
glCallList(startList+18);

//Joint 6 (Third and last member of the spherical joint)


glPushMatrix();
glTranslated (0.0, 0.0, 0.0);
glRotatef ((GLfloat) wrst3, 0.0, 0.0, 1.0);
glPushMatrix();
glColor4d(0.0,1.0,0.0,1.0);
glCallList(startList+19);


glPushMatrix();
glTranslated (0.0,0.0,0.0);
glPushMatrix();
glColor4d(0.0,1.0,0.0,1.0);
glCallList(startList+18);


glPushMatrix();
glTranslated (0.0, 0.0, 0.05);
glPushMatrix();
glColor4d(0.0,1.0,0.0,1.0);
glCallList(startList+18);

//Link 6 (including the gripper and the rod which will penetrate the target solid sphere)


glPushMatrix();
glTranslated (0.0, 0.0, 0.0);
glRotated (90,0.0, 0.0, 1.0);
glPushMatrix();
glColor4d(0.0,0.0,1.0,1.0);
glScaled(0.4,0.08,0.025);
glutSolidCube(1);
glScaled(2.5,12.5,40);

//Code for the rod to penetrate the target ball

glPushMatrix();
glRotated (90,0.0, 1.0, 0.0);
glTranslated (-0.075,0.0,-0.25);
glColor4d(1.0,0.0,1.0,1.0);
glCallList(startList+13);
glTranslated (0.075,0.0,0.25);
glRotated (-90,0.0, 1.0, 0.0);
glScaled(0.4,0.08,0.025);

//End of code for the rod to penetrate the target ball


glPushMatrix();

glColor4d(0.0,0.0,1.0,1.0);
glScaled(2.5,12.5,40);
glScaled(0.025,0.08,0.2);
glTranslated (0.0, 0.0, 0.4375);
glPushMatrix();
glTranslated(8.0,0.0,0.0);
glutSolidCube(1);

glPushMatrix();

glColor4d(0.0,0.0,1.0,1.0);
glScaled(40,12.5,5);
glScaled(0.025,0.08,0.2);
glPushMatrix();
glTranslated(-16.0,0.0,0.0);
glutSolidCube(1);

glPushMatrix();

glColor4d(0.0,0.0,1.0,1.0);
glScaled(40,12.5,5);
glScaled(0.1,0.1,0.05);
glPushMatrix();
glTranslated(2.0,0.0,-1.2);
glutSolidCube(0.4);
glScaled(10,10,20);

glPushMatrix();
glTranslated(0.0,0.0,-0.0825);
glRotated(-90,0.0,0.0,1.0);
glColor4d(0.0,1.0,0.0,1.0);
glCallList(startList+18);


glPopMatrix();


glutSwapBuffers();

}


//Reshaping and viewing function


void reshape (int w, int h)

{
glViewport (0, 0, (GLsizei) w, (GLsizei) h);
glMatrixMode (GL_PROJECTION);
glLoadIdentity();
gluPerspective(85.0,(GLfloat) w/(GLfloat) h,1.0,20.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslated(0.0,3.0,-5.0);

}


//Keyboard inputs


void keyboard (unsigned char key, int x, int y)

{
switch (key) {

case 's':
shoulder = (shoulder + 5);
glutPostRedisplay();
break;
case 'S':
shoulder = (shoulder - 5);
glutPostRedisplay();
break;

case 'e':
elbow = (elbow + 5);
glutPostRedisplay();
break;
case 'E':
elbow = (elbow - 5);
glutPostRedisplay();
break;

case 'r':
root = (root + 5);
glutPostRedisplay();
break;
case 'R':
root = (root - 5);
glutPostRedisplay();
break;

case 'v':
rot1 = (rot1 + 5);
glutPostRedisplay();
break;
case 'V':
rot1 = (rot1 - 5);
glutPostRedisplay();
break;

case 'b':
rot2 = (rot2 + 5);
glutPostRedisplay();
break;
case 'B':
rot2 = (rot2 - 5);
glutPostRedisplay();
break;

case 'n':
rot3 = (rot3 + 5);
glutPostRedisplay();
break;
case 'N':
rot3 = (rot3 - 5);
glutPostRedisplay();
break;

case 'q':
wrst1 = (wrst1 + 5);
glutPostRedisplay();
break;
case 'Q':
wrst1 = (wrst1 - 5);
glutPostRedisplay();
break;

case 'w':
wrst2 = (wrst2 + 5);
glutPostRedisplay();
break;
case 'W':
wrst2 = (wrst2 - 5);
glutPostRedisplay();
break;


case 'x':
wrst3 = (wrst3 + 5);
glutPostRedisplay();
break;
case 'X':
wrst3 = (wrst3 - 5);
glutPostRedisplay();
break;

case 't':
x1 = (x1 + 0.2);
glutPostRedisplay();
break;
case 'T':
x1 = (x1 - 0.2);
glutPostRedisplay();
break;

case 'y':
x2 = (x2 + 0.2);
glutPostRedisplay();
break;
case 'Y':
x2 = (x2 - 0.2);
glutPostRedisplay();
break;

case 'u':
x3 = (x3 + 0.2);
glutPostRedisplay();
break;
case 'U':
x3 = (x3 - 0.2);
glutPostRedisplay();
break;


case 'g':
r1 = (r1 + 5);
glutPostRedisplay();
break;
case 'G':
r1 = (r1 - 5);
glutPostRedisplay();
break;

case 'h':
r2 = (r2 + 5);
glutPostRedisplay();
break;
case 'H':
r2 = (r2 - 5);
glutPostRedisplay();
break;

case 'j':
r3 = (r3 + 5);
glutPostRedisplay();
break;
case 'J':
r3 = (r3 - 5);
glutPostRedisplay();
break;

case 27:
exit(0);
break;

default:
break;
}
}


int main(int argc, char** argv)

{
glutInit(&argc, argv);
glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB );
glutInitWindowSize (600, 600);
glutInitWindowPosition (300, 300);
glutCreateWindow ("Robot Animation");
init ();
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutKeyboardFunc(keyboard);
glutMainLoop();
return 0;
}

nexusone
11-27-2003, 06:24 AM
For sound look fmod is a easy to use sound library, also SDL is another good choice and both are cross platform also.

I don't have time now but will try and run

croce
11-27-2003, 06:54 AM
Looks nice! http://www.opengl.org/discussion_boards/ubb/smile.gif

all you should do is enable depthtest during init(), en clear depthbuffer during display:

first line of init(void):

glEnable(GL_DEPTH_TEST);

first line of display(void):

glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

you just have got some decals (coplanar polygons hiding eachother) that don't show well with the depthtest.

cwc36
11-27-2003, 04:30 PM
Hi,

Fmod is easy to used, but i more prefer to OpenAL. We can do a lot of sound effect with that.