Archived

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

Help me with this camera!!

This topic is 5784 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi there! I´m making a 3D space shooter and I´m currently working on the camera. I would like it to be behind the player´s spaceship no matter which orientation does the spaceship have. I don´t know much about 3D math, only what I´ve learned on the D3D books, but I tought about the following implementation: Get the position (x,y,z) of the player and its yaw, pitch and roll. Set the camera position in the same place as the player´s position. Do the same with the yaw, roll and pitch. Set the camera´s velocity to (0,0,-220). The spaceship is 400 units long, so that would place the camera behind the spaceship. Update the camera. I know there is a flaw somewhere in this implementation, but as I´ve already said I´m pretty new to 3D math, so if somebody can help me I´d be thankful! Edited by - Ignacio Liverotti on February 17, 2002 7:21:48 AM

Share this post


Link to post
Share on other sites
Its ok positioning the camera behind the ship, but if the ship''s backside is up in the air how do you see past it ? (Lara Croft effect)

Why not match the camera''s position to just behind the rear of the ship and point the camera along the ships axis. It will look like the world is moving rather than the ship.


,Jay

Share this post


Link to post
Share on other sites
In my camera orienter I do:

gluLookAt(0.,0.,eyez, 0.,0.,eyez-1, 0.,1.,0.);
glRotatef(-place.orient.x,1,0,0); // pitch
glRotatef(-place.orient.y,0,1,0); // heading
glTranslatef(-place.pos.x,
-place.pos.y
-place.pos.z);


I adjust eyez by the {} keys, with it I can move in and out, and back up as far as I want, always behind the camera.

This is more of a special effect. To do it right you would take your camera position (x/y/z Pt), subtract the matrix forward vector to it to move behind it, then do some collision testing to ensure you dont end up behind a wall.

Personally I despise the Lara Croft View, give me first-person!


zin

zintel.com - 3d graphics & more or less

Share this post


Link to post
Share on other sites
You could try having a look at NeHe''s GAME tutorial #7. That shows a simple space shooter game and gives you all the source. It is designed to be first person, so you can just do the first person rotation and stuff and then just translate backward.

Hope this helps

-Weasalmongler

Share this post


Link to post
Share on other sites