#### Archived

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

# Help me with this camera!!

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

## 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 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 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
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 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 on other sites
I´m afraid I don´t know OGL, I´m currently learning (or at least trying to) D3D 8.0. Is there any tutorial out there based on D3D? Thanks!

1. 1
2. 2
3. 3
Rutin
15
4. 4
khawk
14
5. 5
frob
12

• 9
• 11
• 11
• 23
• 12
• ### Forum Statistics

• Total Topics
633661
• Total Posts
3013225
×