Advertisement

gluLookAt

Started by August 05, 2002 10:22 PM
3 comments, last by NeXius 22 years, 6 months ago
Hey everyone. I''m trying to design a terrain engine but I''m not sure how to go about moving the camera. I can build the terrain, and move the camera around on top of it, but how to rotate the view, I''m not sure. What''s the best way? Rotate the entire landscape? Use gluLookAt with the viewing position set to the position of the mouse converted to 3d space? How? Thanks guys... any reply would be really appreciated. (except any ones that make fun of my stupidity)
MSN: stupidbackup@hotmail.com (not actual e-mail)ICQ: 26469254(my site)
Check out www.gametutorials.com for the camera tutorials, they go peice by piece through setting up an entire camera system, built around gluLookAt.

And just a side note, as I say to everybody, you have to rotate the entire landscape. The camera is your screen, you can''t move the moniter around.
gluLookAt simply lets you think of it as a camera, but you''ll always be rotating the landscape.

------------
Where''d the engine go? Where''d it go? Aaaaaah!!
MSN: nmaster42@hotmail.com, AIM: LockePick42, ICQ: 74128155
_______________________________________Pixelante Game Studios - Fowl Language
Advertisement
Yeah, those tutorials are great. Be careful not to just cut & paste code though, you won''t learn a thing otherwise.

Death of one is a tragedy, death of a million is just a statistic.
If at first you don't succeed, redefine success.
Here`s all you need :

typedef struct{
float x,y,z;
}POSITION;
typedef struct{
POSITION Position;
POSITION View;
}CAMERA;
CAMERA Camera;
void RotateView(float Y)
{
POSITION Direction;
Direction.x = Camera.Position.x - Camera.View.x; // This gets the direction of the X
Direction.y = Camera.Position.y - Camera.View.y; // This gets the direction of the Y
Direction.z = Camera.Position.z - Camera.View.z; // This gets the direction of the Z
Camera.Position.z = (float)(Camera.View.z + sin(Y)*Direction.x + cos(Y)*vVector.z);
Camera.Position.x = (float)(Camera.View.x + cos(Y)*Direction.x - sin(Y)*vVector.z);
}


I hate it when there`s no code...

Relative Games - My apps

Here`s all you need (UPS!!):

typedef struct{
float x,y,z;
}POSITION;
typedef struct{
POSITION Position;
POSITION View;
}CAMERA;
CAMERA Camera;
void RotateView(float Y)
{
POSITION Direction;
Direction.x = Camera.Position.x - Camera.View.x; // This gets the direction of the X
Direction.y = Camera.Position.y - Camera.View.y; // This gets the direction of the Y
Direction.z = Camera.Position.z - Camera.View.z; // This gets the direction of the Z
Camera.Position.z = (float)(Camera.View.z + sin(Y)*Direction.x + cos(Y)*Direction.z);
Camera.Position.x = (float)(Camera.View.x + cos(Y)*Direction.x - sin(Y)*Direction.z);
}


I hate it when there`s no code...

Relative Games - My apps

This topic is closed to new replies.

Advertisement