changing view with mouse

i’m new to openGl and am doing an assignment for a university course, which is to make a humanoid model. I’ve been trying to make a function to be called by glutMotionFunc() so that when i move my mouse left or right, it rotates the model that way, and when i move the mouse up or down, it zooms in and out, as this would be really handy for my own use in building the assignment. Can someone please explain how i would do this, im pretty sure ive got the rotating part down, but i have no idea how to do the zooming. Any hint in the right direction or example of code would greatly help!
Thanks, link664

Hello there,
Well as you have already done the rotation stuff zooming in/out would not be a problem. Well you can do it in two ways

  1. Using gltranslate and changing the z coordinate value (simply put just take a global value and alter it in your motion function pass that as the last paramter to gltranslate).
    Eg: glTranslate(0,0,zoom);

  2. Changing the cam position in gluLookAt. LookAt takes three basic parameters first camera position, second the pt to view and the third the view up vector. Now assuming that you have your model situated at origin then you can use

       |Cam pos|view pt|view up|

gluLookAt(0,0,zoom,0, 0, 0, 0 ,1,0);

That’s about it. See if this makes sense to you. Have a look at the red book and ofcourse Take care