D3DXMATRIX worldMatrix;
D3DXMatrixIdentity(&worldMatrix);
D3DXMatrixTranslation(&worldMatrix, 0, 0, tz);
D3DXMATRIX tempMatrix;
D3DXMatrixRotationY(&tempMatrix, ry);
D3DXMatrixMultiply(&worldMatrix, &worldMatrix, &tempMatrix);
d3d_dev->SetTransform(D3DTS_WORLD, &worldMatrix);
Note: tz is a variable which value increases when up arrow key is pressed and decreases when down arrow key is pressed. Same for ry, when left arrow key is pressed, its value decreases and when right arrow key is pressed its value increases.
The Problem: The car is always rotated around the origin, which makes the movement unrealistic. So, if the car is like far away from the origin, it is not rotated around itself but around the origin.
I have tried with D3DXMatrixRotationAxis() function but with no success..
Another thing, if i do the rotation first and then the translation, the car rotate around itself anywhere it is, even far from the origin. BUT, the translation of the car is messed up!
Any1 can help please?