开发者

My object won't rotate and scale in the same time

I'm working to ge开发者_StackOverflow社区t my objects to rotate on my terrain. Now here is my problem, I can rotate my object but not scale them or scale but not rotate. It depends on which of my line of code goes last. For example, If rotation code goes last it will rotate but not scale.

Here is my code

D3DXMatrixMultiply(&currentFrame->exCombinedTransformationMatrix, &currentFrame->TransformationMatrix, parentMatrix);
D3DXMatrixScaling(&currentFrame->exCombinedTransformationMatrix, trans.Sx, trans.Sy, trans.Sz);
D3DXMatrixRotationX(&currentFrame->exCombinedTransformationMatrix, D3DXToRadian(trans.Rx));

One of my buddies, Said that I'm overwriting the matrix.

So I tried this

D3DXMatrixMultiply(&currentFrame->exCombinedTransformationMatrix, &currentFrame->TransformationMatrix, parentMatrix);
D3DXMATRIX w;
D3DXMATRIX s;
D3DXMatrixScaling(&s, trans.Sx, trans.Sy, trans.Sz);
D3DXMatrixRotationX(&w, D3DXToRadian(trans.Rx));
D3DXMatrixMultiply(&currentFrame->exCombinedTransformationMatrix, &s, &w);

The result of the code above is now it will only scale no matter what.


Alternatively, you could try using D3DXMatrixTransformation or D3DXMatrixTransformation2D. These functions seem to take care of all the complexities (well at least the 2D one).

http://msdn.microsoft.com/en-us/library/windows/desktop/bb205365(v=vs.85).aspx and http://msdn.microsoft.com/en-us/library/windows/desktop/bb205366(v=vs.85).aspx

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜