I want to rotate around model's y-axis, but I do not know how to do it. There is a same topic but I do not completely understand and it is closed. There is a function name D3DXMatrixRotationAxis in DX, but the problem is how to set the vector value, to rotate around, after loading a model.
Members - Reputation: 5428
Posted 15 May 2014 - 12:59 AM
Phil_t is correct. Here is the MSDN reference for that method. Just to add one small extra note: You'll want to make sure that your model is in "model space", which means you haven't applied any transformations to it. The center should be very near (0,0,0) and it should be oriented towards your preferred standard orientation (I use [1,0,0] as my facing direction). Apply your rotation to get your rotation matrix, then apply your rotation matrix to your model.
Members - Reputation: 1621
Posted 22 May 2014 - 11:10 AM
From what i gather, it's not the performing of the rotation that you have an issue with, but the actually finding of that axis of rotation. If you have a world transform already, you can extract the local X Y and Z vectors from it, and use those to rotate around. this will be different depending on your matrix layout, but you should be able to use the  operator on the world matrix to get each axis individually(i think anyway, I have never used the d3d math library).
// psuedo code // matrix layout // x.x, x.y, x.z 0 // y.x, y.y, y.z, 0 // z.x, z.y, z.z, 0 // t.x, t.y, t.z, 1 Vec3 xAxis = model.worldTransform; Matrix4 xRot = ARotation(xAxis, radians); model.worldTransform *= xRot; Vec3 yAxis = model.worldTransform; Matrix4 yRot= ARotation(yAxis, radians); mode.worldTransform *= yRot;
Edited by Burnt_Fyr, 22 May 2014 - 11:12 AM.