Camera work v1.1

perhpe’s i don’t need to create it but i change the code

instead of mouse i use glSpecialFunc and there now only problem of Problem of Axis and one’s rotation

Main.cpp:
#include <stdlib.h>
#include <math.h>
#include <GL/glut.h>

#include “Shapes.h”
#define WinWidth 640
#define WinHeight 480
/*This Time

A plane with objects lied on it
i try to move around the world of plane(glRectf is right choice for it instead of those of 4 vertex’s)
*/

//where
GLfloat x = 0.0f,y = 2.0f,z = 0.0f;
//what
GLfloat Cx,Cy,Cz;
GLfloat alpha = 0.0f,beta = 0.0f,gama = 90.0f;
GLfloat col[4] = {0.70f,0.70f,0.70f,0.70f};
// not much but for measureable distance
void fog(GLfloat Density,GLfloat *col)
{
glFogf( GL_FOG_DENSITY, Density );
glFogfv( GL_FOG_COLOR, col );
glFogf( GL_FOG_START, -10.0f );
glFogf( GL_FOG_END, 100.0f );
glFogf( GL_FOG_MODE, GL_EXP );
}

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);
Cy = sin(beta);
Cz = sin(gama);
if(beta > 180.0f)beta = 180.0f;
else if(beta < -180.0f)beta = -180.0f;

gluLookAt(x,y,z,Cx+x,Cy+y,Cz+z,0.0f,1.0f,0.0f);

}
void ReSce()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glClearColor(0.0f,0.0f,0.0f,0.0f);
glEnable(GL_DEPTH_TEST);
fog(1.0f ,col);
glEnable(GL_FOG);

CameraMan();
glMatrixMode(GL_PROJECTION);

glTranslatef(0.0f,0.0f,-1.0f);
glLoadIdentity();

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

glTranslatef(0.0f,-1.0f,0.0f);
glRotatef(90.0f,1.0f,0.0f,0.0f);
glRectf(2.0f,2.0f,-2.0f,-2.0f);
glPopMatrix();

glMatrixMode(GL_MODELVIEW);
glutSwapBuffers();
}

void WinSize(int w,int h)
{
GLfloat As = (GLfloat)w/(GLfloat)h;
glMatrixMode(GL_PROJECTION);
gluPerspective(90.0f,As,-1.0f,500.0f);
glMatrixMode(GL_MODELVIEW);

glViewport(0,0,w,h);
}
void Idle()
{glLoadIdentity();
glutPostRedisplay();
}
void keyb(unsigned char k , int x, int y)
{
switch(k)
{
case 27:
case ‘q’:
exit(0);
break;
case ‘w’:
z+=0.2f;
break;
case ‘a’:
::x-=0.2f;
break;

case ‘s’:
z-=0.2f;
break;
case ‘d’:
::x+=0.2f;
break;

}
}
void Special(int k,int x,int y)
{switch(k)
{
case GLUT_KEY_LEFT:
gama+=0.1;
break;
case GLUT_KEY_RIGHT:
gama-=0.1;
break;
case GLUT_KEY_UP:
beta+=0.1;
break;
case GLUT_KEY_DOWN:
beta-=0.1;
break;
}

}

int main(int argc,char *argv[])
{
glutInit(&argc,argv);
glutInitWindowSize(WinWidth,WinHeight);
glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow(“Win”);
glEnable(GL_FOG);
glutDisplayFunc(ReSce);
glutReshapeFunc(WinSize);
glutKeyboardFunc(keyb);
glutSpecialFunc(Special);
glutIdleFunc(Idle);
glutMainLoop();

}
#ifdef LINUX_USER
LIB = -I/usr/lib
INC = -I/usr/include
SRC = main.cpp
COMP = gcc
LINK = -lglut -lGL

1st:
$(COMP) -o Cam2 $(SRC) $(INC) $(LIB) $(LINK)

#endif

only problem of gama/alpha rotation
and axis motion(z,x)
help me about this(z,x,gama/alpha/beta)

i made some changes

#include <stdlib.h>
#include <math.h>
#include <GL/glut.h>

#include “Shapes.h”
#define WinWidth 640
#define WinHeight 480
/*This Time

A plane with objects lied on it
i try to move around the world of plane(glRectf is right choice for it instead of those of 4 vertex’s)
*/

//Conditions
GLfloat col[4] = {0.0f,0.0f,0.0f,0.0f};
GLfloat Mcol[4] = {1.0f,1.0f,0.0f,0.0f};
GLfloat amb[] = {0.28,0.6,0.9,0.3};
GLfloat dif[] = {0.2,0.2,0.1,0.6};
GLfloat pos[] = {1.0f,1.0f,1.0f};
//where
GLfloat x = 0.0f,y = 1.0f,z = 0.0f;
//what
GLfloat Cx,Cy,Cz;
GLfloat alpha = 0.0f,beta = 0.0f,gama = 90.0f;

//not much but for Orientation of tough thing
void light()
{
glEnable(GL_LIGHT0);
glEnable(GL_LIGHTING);
glShadeModel( GL_SMOOTH );

glLightfv( GL_LIGHT0, GL_AMBIENT , amb );
glLightfv( GL_LIGHT0, GL_DIFFUSE, dif );
glLightfv( GL_LIGHT0, GL_POSITION, pos);
glLightfv( GL_LIGHT0, GL_SHININESS, pos);
glMaterialfv( GL_FRONT_AND_BACK, GL_COLOR_MATERIAL, Mcol );

}
// not much but for measureable distance
void fog(GLfloat Density,GLfloat *col)
{
glFogf( GL_FOG_DENSITY, Density );
glFogfv( GL_FOG_COLOR, col );
glFogf( GL_FOG_START, -10.0f );
glFogf( GL_FOG_END, 100.0f );
glFogf( GL_FOG_MODE, GL_EXP );
}

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(alphaM_PI/180);
Cz = cos(beta
M_PI/180);
Cy = sin(alpha*M_PI/180)sin(betaM_PI/180);
gluLookAt(x,y,z,Cx+x,Cy,Cz+z,0.0f,1.0f,0.0f);

}
void ReSce()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glClearColor(0.0f,0.0f,0.0f,0.0f);
glEnable(GL_DEPTH_TEST);

light();
fog(10.0f ,col);
glEnable(GL_FOG);

CameraMan();
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glPushMatrix();

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

glutSolidCube(5.0);

glPopMatrix();

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

glutSwapBuffers();
}

void WinSize(int w,int h)
{
GLfloat As = (GLfloat)w/(GLfloat)h;
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(60.0f,As,-10000.0f,500.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glViewport(0,0,w,h);
}
void Idle()
{glLoadIdentity();
glutPostRedisplay();
}
void keyb(unsigned char k , int x, int y)
{
switch(k)
{
case 27:
case ‘q’:
exit(0);
break;
case ‘w’:
::z+=0.2f;
break;
case ‘a’:
::x+=0.2f;
break;

case ‘s’:
::z-=0.2f;
break;
case ‘d’:
::x-=0.2f;
break;

}
}
void Special(int k,int x,int y)
{switch(k)
{
case GLUT_KEY_LEFT:
alpha+=0.5;
break;
case GLUT_KEY_RIGHT:
alpha-=0.5;
break;
case GLUT_KEY_UP:
beta+=0.5;
break;
case GLUT_KEY_DOWN:
beta-=0.5;
break;
}

}

int main(int argc,char *argv[])
{
glutInit(&argc,argv);
glutInitWindowSize(WinWidth,WinHeight);
glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow(“Win”);
glEnable(GL_FOG);

glutDisplayFunc(ReSce);
glutReshapeFunc(WinSize);
glutKeyboardFunc(keyb);
glutSpecialFunc(Special);
glutIdleFunc(Idle);
glutMainLoop();

}
#ifdef LINUX_USER
LIB = -I/usr/lib
INC = -I/usr/include
SRC = main.cpp
COMP = gcc
LINK = -lglut -lGL

1st:
$(COMP) -o Cam2 $(SRC) $(INC) $(LIB) $(LINK)

#endif
my Question is
why i can’t see the wall of cube
at 2.0 cube visible and on moving it get partially cutted
why i can’t see inside of it while i not enabled GL_CULL_FACE
and also light is on
H E L P

ME
E
E
E
E
E
E
E

Its only rotate the cube not the viewer if anyone
<#include <all.h> > can help please help me
is it a perspective problem
i know glFrustum create a shape Frustum(a kind of box one side area small then other opposite )
also
glOrtho2D (for 2D projections)
and in gluPerspective(fovy(angle in somewhere y ),Aspect ratio,nearest point,farther point );
what how i change thing
and relation of these thing
i tried Mesa <tunnel & fire example both same in camera function>
i know matrix multiplication addition inverse formulas(not usable in OpenGL programming if yes how and where)

i also find out matrix function and theory
but can’t get it :-((((((((((((((((