Archived

This topic is now archived and is closed to further replies.

silvia_steven_2000

orbit camera

Recommended Posts

quote:
Original post by silvia_steven_2000
gluLookAt rovolves the world not the eye !!!

The eye (or camera) is technically -never- rotated or moved at all. It always remains at (0,0,0) looking down the z axis. It is the centre of the universe and everything revolves around it.

Share this post


Link to post
Share on other sites
quote:
Original post by Ostsol
quote:
Original post by silvia_steven_2000
gluLookAt rovolves the world not the eye !!!

The eye (or camera) is technically -never- rotated or moved at all. It always remains at (0,0,0) looking down the z axis. It is the centre of the universe and everything revolves around it.


I think she is likley referring to rotating about some point, other than the viewers local origin.

Share this post


Link to post
Share on other sites
im not sure if that is what you need or something you can build on.

what this does is rotating the "camera" (that doesnt really exist except as a selfmade class) in a way that a specified position in space will always remain at the same position on the screen. that was added to rotate the view in my level around a point i click on.

pos is the position in space, Position,Right,Up,Forward are the 4 vectors of the transformation matrix of the "camera" (that is later inverted to get the view matrix)


float tx,ty,tz;
/*this stores the position of the point in "camera space", ie in the cameras coordinate system*/
if (pos) {
float d[3]={pos[0]-Position[0], pos[1]-Position[1], pos[2]-Position[2]};
tx=d[0]*Right[0] + d[1]*Right[1] + d[2]*Right[2];
ty=d[0]*Up[0] + d[1]*Up[1] + d[2]*Up[2];
tz=d[0]*Forward[0] + d[1]*Forward[1] + d[2]*Forward[2];
}

//lazy today, let opengl do the math

glMatrixMode(GL_MODELVIEW);
glLoadMatrixf(Transform);
glRotatef(-deg, x,y,z);
glGetFloatv(GL_MODELVIEW_MATRIX, Transform);

/*place the "camera" in a way that the point will have the same
position in the new camera coordinate system*/

if (pos) {
Transform[12]=pos[0] - (tx*Right[0] + ty*Up[0] + tz*Forward[0]);
Transform[13]=pos[1] - (tx*Right[1] + ty*Up[1] + tz*Forward[1]);
Transform[14]=pos[2] - (tx*Right[2] + ty*Up[2] + tz*Forward[2]);
}


the only way to truly move the world btw. would be to transform every single vertex yourself. everything you do with translate, rotate etc. will just change the matrix thats used to render your stuff. might be a personal preference if you consider that moving the viewpoint or the world. technically that would of course move the world, but as this math has to do be done anyway its not causing any additional work (except build and multiplying the matrix)

Share this post


Link to post
Share on other sites
The ''observer'' is fixed in the origin and it looks along Z axis forever!!! We move the world (MODELVIEW_MATRIX) in a way that it seems that there is a camera (simply by inverting rotations and translations). In other words we have only two matrices (matrices:right???) MODEL and PROJECTION. Projection is affected by FOV, znear, zfar...the rest is in the MODELVIEW.

PS: rotations are defined by an axis and an angle: you cannot rotate (orbit?) around a point.


Share this post


Link to post
Share on other sites
quote:
Original post by silvia_steven_2000
Hi Guys
I think rotating the whole world around a point in the space is the same as orbiting the eye around the same point, my question is: can I physically orbit the eye while keeping the world stationary? how can we do that ?

thanks

Silvia



It is the same, but that being so, why do you want to do it the other way? The look should be the same, but you''re doing extra work to make it so.

Share this post


Link to post
Share on other sites
Hi blizzard999

I think your point is the most logical, the view point should be all the time on the center of the 2D screen, like TV , even if the camera man physically revolves around the target, on the TV , the view point is the center of the screen. I already know that camera in OpenGL is some concept, may be I did the right thing but I was not sure if it was working fine or not. concerning your point , u have to have an axis to rotate around, I totally agree with u, I assume I am arbiting horizontal or vertical , around the camera''s right and up vectors

Share this post


Link to post
Share on other sites