Skip to main content
GameDev.net gamedev.net
🔒 Locked

Camera

Started by cone3d Nov 23, 2001 at 2:13 PM 2 replies 900+ views
Original Post
cone3d
cone3d
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.
---cone3dhttp://cone3d.gamedev.netMy software never has any bugs - it just generates random features
TipplerP
TipplerP
http://www.gamedev.net/reference/articles/article1591.asp

I hope I could help!

Thorsten
cone3d
cone3d
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.
---cone3dhttp://cone3d.gamedev.netMy software never has any bugs - it just generates random features

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.