vivek vyas

06-14-2009, 12:24 PM

i am working on a code to understand working of a camera in way that a first person shooter without weapon walks

i have programmed and at few point i got some headache points in my code

i am giving few parts of code if you need more then post me

1st:

void CameraMan()

{

///gluLookAt(x,y,z,Cx,Cy,Cz,0.0f,1.0f,0.0f);Cx <->x , Cy <-> y Cz <->z

//for circle there must radius let it 0.5f

Cx = sin(alpha*M_PI/180);

Cz = cos(beta*M_PI/180);

Cy = sin(alpha*M_PI/180)*sin(beta*M_PI/180);

gluLookAt(x,y,z,Cx+x,y + 0.1f,Cz+z,0,1,0);

}

2nd:yes depth double buffer turnned on

glMatrixMode(GL_PROJECTION);

glLoadIdentity();

CameraMan();

glPushMatrix();

glRotatef(90.0f,1.0f,0.0f,0.0f);

glColor3f(0.0f,1.0f,0.0f);

glRectf(2.0f,2.0f,-2.0f,-2.0f);

glPopMatrix();

glMatrixMode(GL_MODELVIEW);

glLoadIdentity();

3rd: i found perspective function related to frustum but fovy zNear and zFar are related to each other or not but what there value should be (i am weak in represntin 3d(specially position and angle))

void WinSize(int w,int h)

{

GLfloat As = (GLfloat)w/(GLfloat)h;

glMatrixMode(GL_PROJECTION);

glLoadIdentity();

gluPerspective(180.0f,As,-100.0f,100.0f);

glMatrixMode(GL_MODELVIEW);

glLoadIdentity();

glViewport(0,0,w,h);

}

4th: angle function controll

void Special(int k,int x,int y)

{

switch(k)

{

case GLUT_KEY_UP:

alpha+=0.1;

break;

case GLUT_KEY_DOWN:

alpha-=0.1;

break;

case GLUT_KEY_LEFT:

beta+=0.1;

break;

case GLUT_KEY_RIGHT:

beta-=0.1;

break;

}

}

and there keyboard function also

w-> incremental of z

a-> incremental of x

s-> -ve of w

d-> -ve of s

light and fog also for what is front and how much far

please help me regard tis

thanks in advanced

thanks to jan

Vivek

i have programmed and at few point i got some headache points in my code

i am giving few parts of code if you need more then post me

1st:

void CameraMan()

{

///gluLookAt(x,y,z,Cx,Cy,Cz,0.0f,1.0f,0.0f);Cx <->x , Cy <-> y Cz <->z

//for circle there must radius let it 0.5f

Cx = sin(alpha*M_PI/180);

Cz = cos(beta*M_PI/180);

Cy = sin(alpha*M_PI/180)*sin(beta*M_PI/180);

gluLookAt(x,y,z,Cx+x,y + 0.1f,Cz+z,0,1,0);

}

2nd:yes depth double buffer turnned on

glMatrixMode(GL_PROJECTION);

glLoadIdentity();

CameraMan();

glPushMatrix();

glRotatef(90.0f,1.0f,0.0f,0.0f);

glColor3f(0.0f,1.0f,0.0f);

glRectf(2.0f,2.0f,-2.0f,-2.0f);

glPopMatrix();

glMatrixMode(GL_MODELVIEW);

glLoadIdentity();

3rd: i found perspective function related to frustum but fovy zNear and zFar are related to each other or not but what there value should be (i am weak in represntin 3d(specially position and angle))

void WinSize(int w,int h)

{

GLfloat As = (GLfloat)w/(GLfloat)h;

glMatrixMode(GL_PROJECTION);

glLoadIdentity();

gluPerspective(180.0f,As,-100.0f,100.0f);

glMatrixMode(GL_MODELVIEW);

glLoadIdentity();

glViewport(0,0,w,h);

}

4th: angle function controll

void Special(int k,int x,int y)

{

switch(k)

{

case GLUT_KEY_UP:

alpha+=0.1;

break;

case GLUT_KEY_DOWN:

alpha-=0.1;

break;

case GLUT_KEY_LEFT:

beta+=0.1;

break;

case GLUT_KEY_RIGHT:

beta-=0.1;

break;

}

}

and there keyboard function also

w-> incremental of z

a-> incremental of x

s-> -ve of w

d-> -ve of s

light and fog also for what is front and how much far

please help me regard tis

thanks in advanced

thanks to jan

Vivek