...like HL

well guys… i need your help again!

how can i “control” the user view like in
Half-Life ??? i mean… just using the mouse to look up, down, left and right ???

can you share some code ???

thank you…

PS: hmmm, i have to make this control via WM_MOUSEMOVE event, ok ???

thank you again…

[This message has been edited by Gelero (edited 09-03-2001).]

Within your WndProc, on WM_MOUSEMOVE…

mouse.which_button_is_down = wParam;
mouse.x = LOWORD(lParam);
mouse.y = HIWORD(lParam);

mouse.which_button_is_down = wParam;
mouse.x = LOWORD(lParam);
mouse.y = HIWORD(lParam);

but, how about angle of the camera (using glulookat) based on mouse.x and mouse.Y…

PS: i want to know the 3d coordinates correspondents of 2d mouse coordinates…

[This message has been edited by Gelero (edited 09-04-2001).]

In most first person perspective games, the mouse is used for looking around, which only requires two angles. Each angle being taken from scaled mouse coordinates, or by scaling the number of mickeys since the mouse was last checked. The scale is determined by the in game mouse sensitivity you have selected. Something like this for example:

yaw=2PIsensitivity*(mouse.x-center.x)

or

yaw+=sensitivity*mickeys.x

[This message has been edited by DFrey (edited 09-04-2001).]

ok… and how can use the yaw angle in glulookat ???

You can’t directly. That was just an example. To use that with gluLookAt you also need the pitch angle which you get from the y axis. Note that the pitch is normally limited to only 0 to PI radians, whereas the yaw goes the full 2PI radians. That pair of angles uniquely specify a point on a unit sphere. Its that point on the unit sphere that you need to pass to gluLookAt after offsetting it with the view position. Something like:

gluLookAt(r.x,r.y,r.z,r.x+view.x,r.y+view.y,r.z+view.z,0,1,0)

Where r is the view position, and view is the point on the unit sphere. Also in this case, you can’t look either directly straight up or down so pitch would need to be limited to 0 < min_pitch <= pitch <= max_pitch < PI.

view.x=cos(yaw)*cos(pitch)
view.y=sin(pitch)
view.z=sin(yaw)*cos(pitch)

That would be a good beginning, but it does not allow for the view to be kicked or rolled.

Note: I may have some of the trig functions backwards, but its easy enough to figure out if they are.

[This message has been edited by DFrey (edited 09-04-2001).]

hey gallero…
why do u use glulookat?
the easiest and best thing to move cam (is in my eyes) to move the scene against the direction!
so its very easy to realize any think like HL movin!
goto nehe.gamedev.net
there is an demo how to do this with straving and mouselook!
its very simple…believe me!

(i think glulookat does the same to move it into the other direction)

well, MofuX i guess thats very simple really…
but with glulookat i can fix the camera target and move it around looking at target… and i guess using glrotate i have to make too much math!!
thats my weak point…

so, can you share some source???

thanks anyway!

Using gluLookAt is absolutely fine. There is nothing what so ever wrong with using it. It does the same thing that moving the world vertices manually does. In the past it was a bad idea to use gluLookAt because the 3dfx mini-gl did not support any of the glu functions. But now all major video cards have a full ICD so the glu functions are supported.

ok… so i really wanna implement something like HL… move with arrow’s keys and look with mouse…