Jump to content
  • Advertisement

Archived

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

cone3d

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.

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

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 this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!