Jump to content

  • Log In with Google      Sign In   
  • Create Account


First person camera


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 Slushy   Members   -  Reputation: 168

Like
0Likes
Like

Posted 30 October 2012 - 10:59 AM

Hello!
Im trying to create a first person camera, and I've been successful in understanding how to do so thus far. I've read up on alot of vector math and matrix stuff and I know the basics. Although I got a few problems when I try to implement it into my code.

I have 3 main vectors, which are position, direction and up. I am trying to use
glTranslatef(x, y, z);
to update my camera-position, but Im not a 100% sure on what values I want to update it with. If I keep updating with my position vector, like so:
glTranslatef(position.x, position.y, position.z);

I will keep moving in one direction, even if im not pressing any buttons. (Moving in the direction that the results of all three values in the position vector will be.) I've been able to work around this by using
glLoadIdentity();
In the main loop, before I do all the translating. Is this the correct way of doing it? Or do I add another vector and translate with that one? Im a bit of a perfectionst, and I want to do it correctly the first time. So I don't have to relearn!

Thanks! I hope im clear enough on what my problem is, I'll be happy to post my sourcecode if you really need it, I felt like it was a bit unnecessary though.

Sponsor:

#2 Faelenor   Members   -  Reputation: 396

Like
0Likes
Like

Posted 30 October 2012 - 11:13 AM

Yes, you have to reset the matrix to identity before applying a new transformation, otherwise, you're applying the same operation over and over.

#3 Slushy   Members   -  Reputation: 168

Like
0Likes
Like

Posted 30 October 2012 - 11:24 AM

Yes, you have to reset the matrix to identity before applying a new transformation, otherwise, you're applying the same operation over and over.

But I get the feeling that this isnt the most effective way of doing it? Since glLoadIdentity(); moves it back to the origin again. I have to move it back to the position I want it in every single frame. Shouldn't there be a way to only move the camera when I tell it to do so, with my WASD keys?




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS