I have made a tank model, now I am trying to make the tank move FORWARD and then stop and rotate around itself to change its position then move forward again.
When I rotate the tank and change the Z axis to move it forward, it doesn't move FORWARD, it move in another position.
The code is similar to the following:
D3DXMATRIX matRot;
D3DXMATRIX matCenter;
D3DXMATRIX matScale;
D3DXMatrixTranslation(&matCenter, 0.0f, 0.0f, 0.0f); // *** Rotation point ***
D3DXMatrixTranslation(&matPos, tankPosX, -240.0f, tankPosZ);
D3DXMatrixRotationYawPitchRoll(&matRot, D3DXToRadian(tankRotX), D3DXToRadian(0.0f), D3DXToRadian(0.0f));
D3DXMatrixScaling(&matScale, 1.0f, 1.0f, 1.0f);
d3ddev->SetTransform(D3DTS_WORLD, &(matScale * matCenter * matRot * matPos));
Show differencesHistory of post edits
#1Medo3337
Posted 06 May 2012 - 10:15 AM
I have made a tank model, now I am trying to make the tank move FORWARD and then stop and rotate around itself to change its position then move forward again.
When I rotate the tank and change the Z axis to move it forward, it doesn't move FORWARD, it move in another position.
The code is similar to the following:
[left]
When I rotate the tank and change the Z axis to move it forward, it doesn't move FORWARD, it move in another position.
The code is similar to the following:
[left]
[/left]
[color=#000000][font=Courier, monospace][size=2]D3DXMATRIX matRot;[/size][/font][/color]
[color=#000000][font=Courier, monospace][size=2]D3DXMATRIX matCenter;[/size][/font][/color]
[color=#000000][font=Courier, monospace][size=2]D3DXMATRIX matScale;[/size][/font][/color]
[color=#000000][font=Courier, monospace][size=2]D3DXMatrixTranslation(&matCenter, 0.0f, 0.0f, 0.0f); // *** Rotation point ***[/size][/font][/color]
[color=#000000][font=Courier, monospace][size=2]D3DXMatrixTranslation(&matPos, tankPosX, -240.0f, tankPosZ);[/size][/font][/color]
[color=#000000][font=Courier, monospace][size=2]D3DXMatrixRotationYawPitchRoll(&matRot, D3DXToRadian(tankRotX), D3DXToRadian(0.0f), D3DXToRadian(0.0f));[/size][/font][/color]
[color=#000000][font=Courier, monospace][size=2]D3DXMatrixScaling(&matScale, 1.0f, 1.0f, 1.0f);[/size][/font][/color]
[color=#000000][font=Courier, monospace][size=2]d3ddev->SetTransform(D3DTS_WORLD, &(matScale * matCenter * matRot * matPos));[/size][/font][/color]