Jump to content

  • Log In with Google      Sign In   
  • Create Account

Rotate around model's axes


Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
3 replies to this topic

#1 steven166   Members   -  Reputation: 319

Like
0Likes
Like

Posted 14 May 2014 - 11:55 PM

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.



Sponsor:

#2 phil_t   Crossbones+   -  Reputation: 6562

Like
0Likes
Like

Posted 15 May 2014 - 12:46 AM

To rotate about the y-axis, you would use for D3DXVECTOR3( 0.0f, 1.0f, 0.0f ) for the vector. That's the unit vector representing the +ve y-axis.



#3 slayemin   Members   -  Reputation: 4300

Like
0Likes
Like

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.



#4 Burnt_Fyr   Members   -  Reputation: 1573

Like
0Likes
Like

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[0];
Matrix4 xRot = ARotation(xAxis, radians);
model.worldTransform *= xRot;

Vec3 yAxis = model.worldTransform[1];
Matrix4 yRot= ARotation(yAxis, radians);
mode.worldTransform *= yRot;

Edited by Burnt_Fyr, 22 May 2014 - 11:12 AM.





Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.




PARTNERS