// Copy the orientation vectors into the rotation matrix
D3DXMatrixIdentity(&Rotation); // Set matrix to identity
Rotation._11 = vRight.x; Rotation._12 = vUp.x; Rotation._13 = vDir.x;
Rotation._21 = vRight.y; Rotation._22 = vUp.y; Rotation._23 = vDir.y;
Rotation._31 = vRight.z; Rotation._32 = vUp.z; Rotation._33 = vDir.z;
Matrix Rotation and Orientation Vectors
I have an object having its position defined by 3 orientation vectors (right, up, direction). My problem is that I apparently don''t know how to convert these vectors into a rotation matrix that will ensure the object points along the correct axis - my matrix will not rotate the object on its local axes and instead seems to do it on the world axes.
This is my current code for translating the orientation vectors (which are correct) into the rotation matrix:
##UnknownPlayer##
##UnknownPlayer##
you can only rotate around the origin.
if you want to keep your object at the same place, you have to project it to the origin (that is, subtract it''s position from it''s coordinates), then rotate it using your rotation matrix, and then project it back where it was by adding the position again.
if you want to keep your object at the same place, you have to project it to the origin (that is, subtract it''s position from it''s coordinates), then rotate it using your rotation matrix, and then project it back where it was by adding the position again.
-----The scheduled downtime is omitted cause of technical problems.
Your indices are backwards for DirectX. They should be _12 _13 _14 etc. The axis vectors should have the same major index for each element just like the translation vector. The translation is _41 _42 _43 so it makes sense that the axis vectors are _1n _2n _3n
Your vRight, vUp, or vDir might be backwards also because of a switched around cross product.
For a normalized direction w, a normalized up vector, and a
translation t:
u = cross(w , up)
v = cross(u, w);
Matrix m;
m._11 = u.x;
m._12 = u.y;
m._13 = u.z;
m._14 = 0.0f;
m._21 = v.x;
m._22 = v.y;
m._23 = v.z;
m._24 = 0.0f;
m._31 = w.x;
m._32 = w.y;
m._33 = w.z;
m._34 = 0.0f;
m._41 = t.x;
m._42 = t.y;
m._43 = t.z;
m._44 = 1.0f;
(removed double post)
[edited by - Ironpoint on February 20, 2003 9:22:44 AM]
[edited by - Ironpoint on February 20, 2003 9:22:44 AM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement