View Full Version : transform rotate -> x,y,z
hello all, hope u are all well ?
i was just wondering if anyone can help me ?
i have made a little app where i'm do loads of transformations and rotaions. but i need to find out where my objects have been moved to by all these rotations and stuff.
i have an object that starts say at 0,0,0 and i do some nice transformed and spin it about a tad. how can i work out where the x, y, z of the object is now ?
10-17-2000, 10:25 PM
You can ask OpenGL with (in C) glGetFloatv(GL_MODELVIEW_MATRIX, lMatrix) lMatrix being a array of 16 floats. The transformed position is components 12, 13 & 14 of the array. That's ok if you do that once in a while but in a tight rendering loop, its usually faster to keep track of that yourself by doing your own transformations.
aNt, I would suggest that you wrap all these transformations to a class (that is if you are using C++ or other oop) that have for example Move and Rotate as member functions. The class can neatly keep track of 'everything' in (private) members. Ofcourse when you have wrapped transformations you start thinking that 'hmm, maybe i should do the same thing with textures' and so on and so on.
Happened to me and now I have a nice ogl library http://www.opengl.org/discussion_boards/ubb/wink.gif
i've done a:
float mat = new float;
s.tx = mat;
s.ty = mat;
s.tz = mat;
at the end of my transformations well at the point at where i finish all my rotaions, and translations.
but it seems to be out. but it dont look like its out. very strange.
what i'm doing is linking the objects up with lines. my line code is simple as:
i move aload of dots, then i draw lines like:
gl.glVertex3f(sOne.tx, sOne.ty, sOne.tz);
gl.glVertex3f(sTwo.tx, sTwo.ty, sTwo.tz);
so the sOne is one object witch has the stored transformations after all the moves, it holds the floats in a propertys called tx, ty, tz.. same with sTwo but sTwo is in a diffrent location.
so far as i can see the lines code is ok? or am i missing something ?
the lines dont connect to the dots full on, they are nearly there mind http://www.opengl.org/discussion_boards/ubb/smile.gif. can lines draw in 'z' ? thought they could.
any help would be coolll.....
it dont seem to work. gluProject(); or something like that ?
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.