Jump to content
  • Advertisement

Archived

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

ZGL_Sigma

Camera

This topic is 6110 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

Well - the question (don''t know if the answer is even) what is wrong with my camera - it keeps moving into one direction even when I rotated it. I think it''s one of those errors which are so simple that they can''t be spotted - but I think some of you might even know that problem so please help !

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
Rotate then translate.

Share this post


Link to post
Share on other sites
code follows :

the mistake was here

///////////////////////////////////////////////////////////////////////////////
//
// FUNCTION : Camera::Update
//
// PURPOSE : Translates rotates etc... all defined coordinates
//
///////////////////////////////////////////////////////////////////////////////

void Camera::Update ()
{
float XTrans, YTrans, ZTrans;
float SCRotY;

XTrans = -Position.x;
YTrans = -Position.y;
ZTrans = -Position.z;

SCRotY = 360.0f - this->m_YRotate;


glRotatef (this->m_XRotate, 1.0f, 0.0f, 0.0f);
glRotatef (this->m_YRotate, 0.0f, 1.0f, 0.0f);

glTranslatef (XTrans, YTrans, ZTrans);

}

Edited by - ZGL_Sigma on December 29, 2001 3:13:16 PM

Share this post


Link to post
Share on other sites
replace this in the function Update

glRotatef (this->m_XRotate, 1.0f, 0.0f, 0.0f);
glRotatef (this->m_YRotate, 0.0f, 1.0f, 0.0f);

by

glRotatef (360.0f - this->m_XRotate, 1.0f, 0.0f, 0.0f);
glRotatef (360.0f - this->m_YRotate, 0.0f, 1.0f, 0.0f);

or

glRotatef (360.0f - m_XRotate, 1.0f, 0.0f, 0.0f);
glRotatef (360.0f - m_YRotate, 0.0f, 1.0f, 0.0f);

and it should work.

Why are you calling the this pointer all the time ?
It''s useless but every body has got it''s own coding style.

Share this post


Link to post
Share on other sites
Hello - thanks for your help man !!!

I like to call the this pointer because it gives me a list of all the variables - and so I don''t have to care about Case sensitivity.

does the this make a difference in speed ???

Share this post


Link to post
Share on other sites
Hello - thanks for your help man !!!

I like to call the this pointer because it gives me a list of all the variables - and so I don''t have to care about Case sensitivity.

does the this make a difference in speed ???

Share this post


Link to post
Share on other sites
You could also do this:

glRotatef (this->m_XRotate,-1.0f, 0.0f, 0.0f);
glRotatef (this->m_YRotate, 0.0f,-1.0f, 0.0f);

notice the -1.0f rather than 1.0f. It has the same effect as what George2 suggested, but saves you from one subtraction... code bumming at its best!

Share this post


Link to post
Share on other sites
wew - well I didn't think of that - thanks.

there is even something to redo in the transform code -

now my camera update code is only three lines instead of nine !!!
and best : it works !

Edited by - ZGL_Sigma on December 29, 2001 3:16:24 PM

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!