Sign in to follow this  
robococ

how can I circle the scene using camera

Recommended Posts

How can I circle scene using camera - circle around central point scene ?

I have many objects on scene:
[code]
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();

........
[/code]

And I have that code but this cause that scene circle camera :/ Screen what I want: [url="http://img861.imageshack.us/i/camk.jpg/"]http://img861.images....us/i/camk.jpg/[/url]
[code]
//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);
[/code]

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this