Retrieving new object coordinates after translation/rotation
Hello!
I have a plane loaded in from 3ds max, i have performed many translations / rotations on it. However i'm now adding collision detection and having great difficulty getting the exact coordinates of the plane.
I've tried keeping track using an x,y and z variable however it doesn't seem work 100% after a rotation.
I remember having a lecture at uni on this problem; but i appear to have lost my notes
Hopefully someone reading will have a suggestion..
Thanks for reading!
Chris
I have a plane loaded in from 3ds max, i have performed many translations / rotations on it. However i'm now adding collision detection and having great difficulty getting the exact coordinates of the plane.
I've tried keeping track using an x,y and z variable however it doesn't seem work 100% after a rotation.
I remember having a lecture at uni on this problem; but i appear to have lost my notes
Hopefully someone reading will have a suggestion..
Thanks for reading!
Chris
What probably would most convenient is to keep track of your object's position and orientation with a vector and a quaternion. Given how you phrased "performed many translations / rotations on it", it sounds like you're just letting transforms accumulate in the modelview matrix across frames. Instead, what you'll probably want is to call glLoadIdintity and do your transformations from scratch for each object every time you draw. Then, when you want to get information about current position and orientation in your code, you can simply multiply by the orientation quaternion and add the position vector.
If you need more information about quaternions, look here: http://www.sacredsoftware.net/tutorials/...ions.xhtml
If you need more information about quaternions, look here: http://www.sacredsoftware.net/tutorials/...ions.xhtml
Thanks alot, i never used quaternions before but will look into it
I'm using push and pop around the movements of the plane, sorry i should have mentioned that before.
I did find something on this problem, not sure exactly how to implement it but it might be useful:
9.120 How do I find the coordinates of a vertex transformed only by the ModelView matrix?
It's often useful to obtain the eye coordinate space value of a vertex (i.e., the object space vertex transformed by the ModelView matrix). You can obtain this by retrieving the current ModelView matrix and performing simple vector / matrix multiplication.
Thanks again,
Chris
I'm using push and pop around the movements of the plane, sorry i should have mentioned that before.
I did find something on this problem, not sure exactly how to implement it but it might be useful:
9.120 How do I find the coordinates of a vertex transformed only by the ModelView matrix?
It's often useful to obtain the eye coordinate space value of a vertex (i.e., the object space vertex transformed by the ModelView matrix). You can obtain this by retrieving the current ModelView matrix and performing simple vector / matrix multiplication.
Thanks again,
Chris
That's another way to do it. You can retrieve the modelview matrix with glGetFloatv(GL_MODELVIEW), and multiply a vector by it as demonstrated here (see "Multiplying Vectors"): http://www.sacredsoftware.net/tutorials/...ices.xhtml
Thankyou so much for that! i really do appreciate it!
It's now working I did look at that quaternion idea however i would have had to change alot of my code so i implemented a method using that Matrices tutorial, which i have to say was better than i found.
Ive included a screenshot, which shows a wireframe sphere for my bounding sphere collision detection (i displayed the sphere so i can see where the point is) and thanks to you, the sphere stays with the plane lol.
To view the image copy and paste the link, it doesnt like hotlinking
Thanks again
Chris
It's now working I did look at that quaternion idea however i would have had to change alot of my code so i implemented a method using that Matrices tutorial, which i have to say was better than i found.
Ive included a screenshot, which shows a wireframe sphere for my bounding sphere collision detection (i displayed the sphere so i can see where the point is) and thanks to you, the sphere stays with the plane lol.
To view the image copy and paste the link, it doesnt like hotlinking
Thanks again
Chris
Possibly Related Threads...
Thread:  Author  Replies:  Views:  Last Post  
openal coordinates vs. opengl coordinates  gerald  1  6,027 
Feb 3, 2011 10:04 PM Last Post: OneSadCookie 

OpenGl rotation/translation problems?  wyrmmage  2  4,319 
Jan 6, 2008 01:58 PM Last Post: wyrmmage 

Getting Current Translation And Rotation In OpenGL  Nick  3  3,541 
Jul 26, 2006 11:16 AM Last Post: kelvin 

Object position after rotation  charon  11  6,600 
Mar 2, 2005 11:33 AM Last Post: hangt5 

Quaternion rotation > OpenGL rotation matrix?  DJBlufire  3  3,830 
Sep 6, 2003 08:34 PM Last Post: MattDiamond 