how can I circle the scene using camera

Started by
1 comment, last by robococ 13 years ago
How can I circle scene using camera - circle around central point scene ?

I have many objects on scene:

glPushMatrix();
glTranslatef(10, 30, -135);

glRotatef(90, 0, 0, 1);
glScaled(0.2, 1, 0.2);
glutSolidCube(30);
glPopMatrix();

glPushMatrix();
glTranslatef(40, 10, -100);

glRotatef(90, 0, 0, 1);
glScaled(0.2, 1, 0.2);
glutSolidCube(30);
glPopMatrix();

........


And I have that code but this cause that scene circle camera :/ Screen what I want: http://img861.images....us/i/camk.jpg/

//rotateValueX is a value which I am changing using keyboyard to rotate scene
float ray = 20;
float xCircle = ray * cos(PI * rotateValueX / 180);
float zCircle = ray * sin(PI * rotateValueX / 180);

gluLookAt(xCircle, 0, zCircle, 0, 0, 0, 0, 1, 0);
Advertisement
YOur code works fine

And one other thing change ray to float ray = 20.0f;
and divide pi by 180.0 or 180.0f not with 180


you must use floating points not integers


or try to add glulookat after glloadidentity();





if you want to render rotated object etc from diffrent position




ie

glLoadIdentity();

gluLookAt(); // same glullookat values

static scene in example


glPushMatrix(); // <- dynamic scene in example :P
glLoadIdentity();
gluLookAt();// same glullookat values

glTranslatef(pos.x+TstaticX,pos.y+TstaticY,pos.z+TstaticZ);

glRotatef(glop+staticGLOP,0,1,0);
draw sth




glPopMatrix();




//-----------------

float xCircle = ray * cos(rotateValueX*(PI / 180));


float zCircle = ray * sin(rotateValueX *(PI/ 180));

GetTickCount() is WINAPI function

int ROTATION_START;


int ROTATION_TIME;

//at gldraw

at the beggining ROTATION_START = GetTickCount();




ROTATION_TIME = GetTickCount()-ROTATION_START;

ROTATION_SRART = GetTickCount();


otateValueX = otateValueX + 4.0* float(ROTATION_SRART/1000.0f); 4 degrees in one second
thx :)

This topic is closed to new replies.

Advertisement