#### Archived

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

# Camera

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

## Recommended Posts

Hi all, I''ve got a problem: I''m trying to develop a chase camera system (like in Tomb Raider, for example). Everything is fine, but I can''t put the main character into the right place. I''m using the camera code from NeHe''s lesson 10. I''ve got it nicely rotating around a spot a little bit away from the screen, but I can''t place the player on that spot. This is a really dumb problem, but I''m stuck. Please help me. The code for the camera looks like this:
  // calculate translations and rotations. xtrans = -xpos-(sin(yrot*piover180) * 0.8f); ztrans = -zpos-(cos(yrot*piover180) * 0.8f); ytrans = -0.4; sceneroty = 360.0f - yrot; // Rotate and Translate glRotatef(lookupdown, 1.0f, 0, 0); glRotatef(sceneroty, 0, 1.0f, 0); glTranslatef(xtrans, ytrans, ztrans); // draw the scene 

---
cone3d
http://cone3d.gamedev.net
Multitasking - screwing up several things at once.

##### Share on other sites
http://www.gamedev.net/reference/articles/article1591.asp

I hope I could help!

Thorsten

##### Share on other sites
thanx, that was what I was looking for.

---
cone3d
http://cone3d.gamedev.net
Multitasking - screwing up several things at once.

##### Share on other sites
Ok, now I''ve got the camera nicely rotating around my player on the x and z axises, but I can''t get it rotating around the player on the y axis. On the y axis it just rotates around the 0,0,0 spot.

Here''s what my code looks like:

  GLfloat xtrans, ztrans, ytrans; GLfloat sceneroty; float cameradist=0.8; xtrans = -(cameradist * sin((yrot) * piover180) + xpos); ytrans = -0.4; ztrans = -(cameradist * cos((yrot) * piover180) + zpos); sceneroty = 360.0f - yrot; // Rotate and Translate glRotatef(lookupdown, 1.0f, 0, 0); glRotatef(sceneroty, 0, 1.0f, 0); glTranslatef(xtrans, ytrans, ztrans); // draw the scene glPushMatrix(); glTranslatef(xpos, 0.2f, zpos); glRotatef(-sceneroty+90, 0, 1.0f, 0); // draw the player glPopMatrix();

Any help would be highly apreciated.

---
cone3d
http://cone3d.gamedev.net
Multitasking - screwing up several things at once.

1. 1
Rutin
32
2. 2
3. 3
4. 4
5. 5

• 11
• 13
• 91
• 11
• 10
• ### Forum Statistics

• Total Topics
632973
• Total Posts
3009622
• ### Who's Online (See full list)

There are no registered users currently online

×