In my project, I draw an object and make transformations (a translation and two rotations). Now, I have to learn the new coordinates of the object. How can I find them?
I think you have multiply the cordanates by the trnsformation matrix.
I think you have to multiply the cordanates by the trnsformation matrix.
given your initial vertex position v = [x,y,z,w]
you can derive the current position v’ by multiplying v with all the individual transformation matrices that you used to transform your vertex
e.g. v’ = M_ROT2 * M_ROT1 * M_TRANS * v
where M_ROT1, M_ROT2 and M_TRANS are 4x4 matrices
I have over 5000 vertices. I have found the transformation matrices and apply glMultMatrixf function instead of using glRotatef or glTranslatef. I have done these because you said i have to multiply the current position with individual transformation matrices. I can do that. However I think it will be time consuming to use both glMultMatrixf function for rotation and multiply these individual matrices with current matrix to find the new location. I feel I am doing the same job twice. Is there a way to learn the new location after making the transformations instead of making new matrix calculations?
I heard it can be performed using feedback method and now I am trying to find tutorials about it. Is there anyone who knows how this method works?
i think you don’t have to recalculate alle the 5000 vertics. do it with a few points. load the transformed matrix and multiplicate the elements witch your old point in the right sequence.
What should I do if I have to calculate the transformed locations of every 5000 vertices (not few points) ? Do I have to recalculate all by matrix multiplication?
you could use feedback rendering mode but it is slow. i suppose you have your “object” in a class. you want the x,y,z of the object after transformation. Right? so you don’t need the position of every vertex after transfomartion. Right? so you don’t need glMulMatr or stuff like that. try do do it like the description in the 2nd post. sorry i don’t understand your problem.
Lastly, the only thing I want to know if I have to learn the coordinates of every 5000 points, which method will be faster? feedback method or the one you have described (multiply current location with the transformation matrices)
first make sure (!) that you really need all these points! i think feedback rendering mode is slower but i don’t know. try it (you could make a testprogram in which you try both with many many points and take the time for it (look for glutGet(GLUT_ELAPSED_TIME) . i know a sgi example about it. search for “feedback.c”. if you would like to do the calculation (not the feedback mode way) every frame the program may be slower (these calculations will be done by the cpu and i don’t know if want this)