Camera Rotation

Started by
27 comments, last by glProgram 22 years, 7 months ago
Personally I''ve never used gluLookAt(), I hardly use the glu library except for mipmaps and quadratic shapes. You could try it using just the standard glRotatef() and glTranslatef(), or you could do what I do in my basic 3D engine and translate all the co-ordinates by generating my own translation matrix and keeping the camera at 0,0,0.

Or, one thing you could try:

glLoadIdentity();
glPushMatrix();
// translate, rotate, render
glPopMatrix();

I''m not too sure about it though, so I may be totally wrong on the matrix push/pops... I hardly use them

(BTW, if you want to use your own translation matrix then I''m more than happy to help you if you don''t know how.)

DeathWish
Advertisement
Another thought... you could try reverse transforming your camera. (Transform -x -y -z, rotate -z -y -x)

DeathWish
quote:Original post by Anonymous Poster
inline float cosd(float p_angle)
{
return cos(p_angle * (3.141592654 / 180));
}

wouldnt it be better to precalculate 3.141592654 / 180
this would speed the function up!


The compiler will do that for you. The only real optimization with sine and cosine is to precalculate them (they are horrendously expensive functions):
  float Sine[360], Cosine[360];const float M_PI = 3.141592654;void CreateTrigLUTs( void ){  for( int i = 0; i < 360; i++ )  {    Sine[i] = (float)sin( i * M_PI / 180 );    Cosine[i] = (float)cos( i * M_PI / 180 );  }}  


EDIT: i as array index.


Edited by - Oluseyi on September 17, 2001 1:10:35 PM
using a LUT for a couple of sin''s cos''s will most likely be slower than using sin(A).
the LUT really is only benificial when youre doing heaps of sin''s at a time

http://members.xoom.com/myBollux
Hey, none of that was really a reply to my last post.
Does anybody got any clues about the distance problem?
Ok, I''ve got an idea:

glMatrixMode(GL_PERSPECTIVE);
gluPerspective(...);

glMatrixMode(GL_MODELVIEW);
gluLookAt(...);
glBegin(...);
...
glEnd();
Actually I believe it''s GL_PROJECTION, not GL_PERSPECTIVE.
And that didn''t help at ALL.
You can''t use gluLookAt() in the GL_MODELVIEW matrix.
And I already do use gluPerspective in GL_PROJECTION and it can only be used in that matrix.
>>There''s still that problem with distance.(You have to be REAL close)(And also note that when rotating the camera I can
see that object wireframes will get cut off near the camera<<

decrease your near planes depth value + increase the far planes value
in gluPerspective they are the 3rd+4th variable

http://members.xoom.com/myBollux
I meant GL_PROJECTION... sorry I can''t help you then....
zedzeek, that is very obvious and it keeps getting repeated here. I have tried that 3 times! I''ve tried a near distance
of 0.0f and a far distance of 100000.0f, no effect.

This topic is closed to new replies.

Advertisement