Retrieving new object coordinates after translation/rotation - Printable Version +- iDevGames Forums ( http://www.idevgames.com/forums)+-- Forum: Development Zone ( /forum-3.html)+--- Forum: Graphics & Audio Programming ( /forum-9.html)+--- Thread: Retrieving new object coordinates after translation/rotation ( /thread-2674.html) |

Retrieving new object coordinates after translation/rotation - chris69m - Apr 12, 2008 04:25 PM
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 Retrieving new object coordinates after translation/rotation - ThemsAllTook - Apr 13, 2008 07:20 AM
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/Quaternions/Quaternions.xhtml Retrieving new object coordinates after translation/rotation - chris69m - Apr 13, 2008 07:38 AM
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 Retrieving new object coordinates after translation/rotation - ThemsAllTook - Apr 13, 2008 04:11 PM
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/Matrices/Matrices.xhtml Retrieving new object coordinates after translation/rotation - chris69m - Apr 13, 2008 06:47 PM
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 |