Skip to main content
GameDev.net gamedev.net
🔒 Locked

glulookat problem

Started by laeuchli Oct 8, 2001 at 2:17 PM 4 replies 500+ views
Original Post
laeuchli
laeuchli
Below is my code for looking up. Whenever I use it, it works fine till I get to 90 d, then it start going back down! Anyone know what this could be happening!?!? g_ViewAnglez+=(x*0.017453292519943295769236907684886); eyeVY=-sin(g_ViewAnglez); eyeVZ=cos(g_ViewAnglez); lookDir.y=((eye.y+eyeVY*2)); lookDir.z=((eye.z+eyeVZ*2)); Jesse www.laeuchli.com/jesse/
Prosper/LOADED
Prosper/LOADED
Well... this seems quite logical since the sin and cos functions (I''m talking about math functions, not C/C++ ones) are like periodical waves. Let''s try some ascii art.

  

Here''s the sin function :

y

^ _
| / \
| / \
|/ \
+----------------> x
| \ /
90° \ /
\_/ |
| 360°
180°



As you can seen, from 0 to 90° you go up but after that you go down...

hm... I may not have really understood the question...
GoofProg
GoofProg
Remember cos is sin rotated 90deg
...
Prosper/LOADED did answer the question =)




The nightmare travels across the cosmos with his burning mane.  The trail of ash that is produced. ?Have a nice day!?
Bad Monkey
Bad Monkey
hehe Prosper... thats some sweet ascii art there man
Vlion
Vlion
cos is sin TRANSLATED 90 deg. Not rotated :-D
Otherwise it would be going the Y axis.

And laeuchli, you need to take algerbra 2 or something before gfx programming. Im serious man.

quick reference:
tan/cos/sin are periodic. tan(x) goes to infinity on multiples of either 90 or 180, I forget which.
cos/sin both max out at 1/-1.

I suggest having a struct CAMERA, and using that to store your values. Then modify it whenever/whereever, and in your render function have something like this:

glTranslate(camera.posx,camera.posy,camera.posz);
glRotatef(camera.anglex,1,0,0);
glRotatef(camera.angley,0,1,0);
glRotatef(camera.anglez,0,0,1);

The 3 end parameters to the glRotatef() are the point the rotation is around, relative to the current poition.
Or something like that. Its late and I don
t care to delve into my documentation.

Oh yes.
Learn vector math concepts, along with trigonometry and algerbra 2.

~V''lion

I came, I saw, I got programmers block.
~V''''lion
~V'lionBugle4d
laeuchli
laeuchli
Thanks Prosper/LOADED. I get it, should have figured that out before(Brain was asleep or something :-)).
And laeuchli, you need to take algerbra 2 or something before gfx programming. I`m serious man.
/>
Been there done that. Just needed some reminding about the graph of the sin function. Thanks for the concern though....

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.