Original Post
Well, OK, I 've I have a problem to solve, maybe anyone is able to help... Consider I have 2 objects in a 1 file (3ds or any, ain't matter), and only triangle vertices are known, i.e. there is no orientation matrices available. Now, consider that these objects are exactly the same, but orientation and scale of first object (let it be base object) differs from orientation and scale of second object. The question is : how can I build such rotation matrix, to be able to rotate base object same like the second object is rotated? I mean - I want to keep only 1 mesh, not 2 or N meshes (here might be a lot of copied objects in a file, and all of them are rotated somehow), and also a rotation matrices for any other objects cloned. Note : all triangle indexes are the same for all objects cloned, i.e. 1st triangle of 1st object 1 is the same as 1st triangle of 2nd object in their triangle arrays. I tried to solve this, but the pseudocode below not only rotates the object, but also skews it. vector3 t1,t2,t3,t4,t5,t6; t1 = obj[0].face[0].f_vertex[0]]; t2 = obj[0].face[0].f_vertex[1]]; t3 = obj[0].face[0].f_vertex[2]]; t4 = obj[1].face[0].f_vertex[0]]; t5 = obj[1].face[0].f_vertex[1]]; t6 = obj[1].face[0].f_vertex[2]]; vector3 v = t1 - t3; vector3 v2 = t3 - t2; vector3 normal = vector_normalize(vector_cross_product(v, v2)); vector3 vv = t4 - t6; vector3 vv2 = t6 - t5; vector3 normal2 = vector_normalize(vector_cross_product(vv, vv2)); vector3 up = camera.camera_up_vector; vector3 rght = vector_normalize(vector_cross_product(normal,up)); vector3 upp = vector_normalize(vector_cross_product(rght,normal)); vector3 rght2 = vector_normalize(vector_cross_product(normal2,up)); vector3 upp2 = vector_normalize(vector_cross_product(rght2,normal2)); After this, 2 matrices are constructed from these basis vectors, yielding a final matrix simply multiplying 2 matrices given. Then, I apply final matrix to other object using glMultmatrixf. Is this approach correct? Why object is not only rotated (and rotated right) , but also skewed? How can I avoid the skewing? Or what can I do to get rotation if only mesh data available? Any another way? Any ideas? [Edited by - Wrz on April 17, 2009 7:50:36 AM]