Jump to content

  • Log In with Google      Sign In   
  • Create Account


Camera/Object Movement


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
4 replies to this topic

#1 ShawMishrak   Members   -  Reputation: 146

Like
Likes
Like

Posted 30 July 2001 - 09:12 AM

I have a camera system setup that allows me to travel throughout the scene, but I am looking to have a fixed camera and allow the user to control a model in the scene. Using the MODELVIEW matrix mode, the translations/rotations move the camera instead of the model. I use glLoadIdentity() to reset the matrix and gluLookAt to position the camera. When it goes through the movement code, the camera goes to where the model is. If I use PROJECTION for the matrix mode, I just get a blank screen. Does anyone have any tutorials on this subject or know what might be going wrong? Basically, I am looking to have a fixed camera and quite a few fixed objects with one camera controlled object.

Sponsor:

#2 Obelix   Members   -  Reputation: 122

Like
Likes
Like

Posted 30 July 2001 - 09:24 PM

The MODELVIEW matrix is both for the objects (MODEL) and the camera (VIEW). Moving an object 5 units to the right of the camera looks the same as moving the camera 5 units to the left.

You should accumulate the effects of moving the camera and models into the matrix so no call to glLoadIdenty() should be done after the camera movement.

glMatrixMode(MODELVIEW);
glLoadIdentity();
gluLookAt(...);

// Here do you probably have a glLoadIdentity() but that is wrong

drawObject();

#3 Derilect101   Members   -  Reputation: 122

Like
Likes
Like

Posted 31 July 2001 - 01:15 AM

If the above isn''t true try this since I had the same prob
Hope it works!
  
glLoadIdentity();
move camera (aka) gluLookAt() and translate if wanted
glPushMatrix();
move models;
glPopMatrix();

Have fun! please tell me if it works if not try to help again!

#4 Derilect101   Members   -  Reputation: 122

Like
Likes
Like

Posted 31 July 2001 - 01:16 AM

one thing forgot after moving the camera and before pushing the matrix draw the world then push the matrix

#5 ShawMishrak   Members   -  Reputation: 146

Like
Likes
Like

Posted 31 July 2001 - 06:10 AM

With a little work, the glPushMatrix() and glPopMatrix() worked, to an extent. I have the keyboard mapped to move forward/back/left/right using trig, and it works fine when I control the camera that way. When I try to control the model the same way, (passing the same X, Y, Z, Rotation Value that I passed when I was controling the camera) it won''t calculate the heading right. The rotation (left/right keys) work fine, but the up/down keys always move it in the same direction. The math works when the X, Y, Z, rotation values are applied to the camera (not using push/pop), but they don''t seem to work when they are applied to the model. Any ideas/suggestions?




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