I am making a game engine and a found this problem with the y axis:
- if i position something at -200 on the z pane it should is in front of the camera
- if i position something at 200 on the x pane and:
- - rotate it -90 it should be in front of the camera
- - rotate it 90 it should be behind the camera
This is not the case.
-90 is behind
90 is in front
At the moment i am just inverting the angle when you try to rotate on the y axis
I have not found this problem with any other axis
Why is this happening?
How do i fix it?
p.s. this is my first time starting a topic on this forum
THX :)
Is anyone going to answer this?
Sorry if I'm being impatient...
I just need this fixed
Hi
I'd be patient, people are from all different regions of the world and this is forum is typically a lwjgl forum. (opengl.org has its own forums)
To answer your question you are seeing expected behavior. You can use your eyes to replicate the very problem. If you rotate your head clockwise, objects will appear to your eyes to have rotated anti/counter clockwise. If you move your head forwards towards an object, your eye effectely sees that object come closer to you. Your monitor are your eyes to opengl. Your monitor doesn't move so the effect you see is like the examples I described above
You haven't said how you are rotating things so I'm going to assume you are using the glRotate() function. Now this is from that functions documentation:
Quote
This rotation follows the right-hand rule, so if the vector x y z points toward the user, the rotation will be counterclockwise.
In short, this happens because of maths. I'm not a mathematician so I can't explain it any further than via the right hand rule. I could throw some examples at you but I doubt it would help. Sorry if I seem blunt.
If you want a solution that doesn't involve negating the y-angle, then negate the vector you pass to the function. Ie.
//Instead of
glRotatef(yAngle, 0, 1, 0);
//Use
glRotatef(yAngle, 0, -1, 0);
I don't particularly see that this solution is better than the one you already have but it's up to you.
Quote from: abcdef on March 19, 2014, 15:15:21
Hi
I'd be patient, people are from all different regions of the world and this is forum is typically a lwjgl forum. (opengl.org has its own forums)
To answer your question you are seeing expected behavior. You can use your eyes to replicate the very problem. If you rotate your head clockwise, objects will appear to your eyes to have rotated anti/counter clockwise. If you move your head forwards towards an object, your eye effectely sees that object come closer to you. Your monitor are your eyes to opengl. Your monitor doesn't move so the effect you see is like the examples I described above
Thx for your help, but I'm rotating the objects around the player, not rotating the player
Quote from: quew8 on March 19, 2014, 20:15:35
You haven't said how you are rotating things so I'm going to assume you are using the glRotate() function. Now this is from that functions documentation:
Quote
This rotation follows the right-hand rule, so if the vector x y z points toward the user, the rotation will be counterclockwise.
In short, this happens because of maths. I'm not a mathematician so I can't explain it any further than via the right hand rule. I could throw some examples at you but I doubt it would help. Sorry if I seem blunt.
If you want a solution that doesn't involve negating the y-angle, then negate the vector you pass to the function. Ie.
//Instead of
glRotatef(yAngle, 0, 1, 0);
//Use
glRotatef(yAngle, 0, -1, 0);
I don't particularly see that this solution is better than the one you already have but it's up to you.
This could probably help, if I knew what it meant...
Thx for your help anyway, I'll have a look at it and play around a bit as well :)
Yeah I think most of what I said you have to just accept or get a degree in pure mathematics or something (Like I said, I don't have a degree in pure maths so I can't really be sure you'll even understand then).
If it's anything but the maths you don't get then be a little more specific and I'll try to elaborate as best I can.
I'll try to just accept it then...
Btw what did you mean by 'right hand rule'?
http://en.wikipedia.org/wiki/Right-hand_rule#Direction_associated_with_a_rotation (http://en.wikipedia.org/wiki/Right-hand_rule#Direction_associated_with_a_rotation). This explains it (kind of). It's a bit of a weird thing as far as I'm concerned. Also I couldn't find anything explaining it specifically concerning rotation matrices, only showing principles of physics. Still, it's all about the cross product anyway at it's core.