Advertisement

Camera

Started by December 28, 2001 06:23 AM
8 comments, last by ZGL_Sigma 23 years, 1 month ago
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 !
I hate signatures !!!
Post your camera code, so we can help you .
"THE INFORMATION CONTAINED IN THIS REPORT IS CLASSIFIED; DO NOT GO TO FOX NEWS TO READ OR OBTAIN A COPY." , the pentagon
Advertisement
Rotate then translate.
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
I hate signatures !!!
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.
"THE INFORMATION CONTAINED IN THIS REPORT IS CLASSIFIED; DO NOT GO TO FOX NEWS TO READ OR OBTAIN A COPY." , the pentagon
In the last line off my previous reply replace it''s by his
"THE INFORMATION CONTAINED IN THIS REPORT IS CLASSIFIED; DO NOT GO TO FOX NEWS TO READ OR OBTAIN A COPY." , the pentagon
Advertisement
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 ???
I hate signatures !!!
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 ???
I hate signatures !!!
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!
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
I hate signatures !!!

This topic is closed to new replies.

Advertisement