1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
D3DXVECTOR3 vDifference;
vDifference.x = - this->m_fPosX + vPosOfAxis.x;
vDifference.y = - this->m_fPosY + vPosOfAxis.y;
vDifference.z = - this->m_fPosZ + vPosOfAxis.z;
D3DXVECTOR3 vTransformedCoords;
ZeroMemory(&vTransformedCoords, sizeof(D3DXVECTOR3));
vTransformedCoords = ::vectorCrossMatrix16(vDifference, this->m_mMeshMatrix);
D3DXMatrixTranslation(&mTranslation1, -vTransformedCoords.x, -vTransformedCoords.y, -vTransformedCoords.z); // um die Differenz zwischen Nullpunkt und eigentlichem Rotationspunkt verschieben
if (bX) // um x-achse rotieren ?
{
D3DXVECTOR3 vLocalXAxis = this->computeLocalAxis(D3DXVECTOR3(1.0f, 0.0f, 0.0f), vInclinationXYZ);
D3DXMatrixRotationAxis(&mRotX, &vLocalXAxis, vRotation_new.x); // Rotation durchfuehren
D3DXMatrixMultiply(&mTranslation1, &mTranslation1, &mRotX);
}
if (bY) // um y-achse rotieren ?
{
D3DXVECTOR3 vLocalYAxis = this->computeLocalAxis(D3DXVECTOR3(0.0f, 1.0f, 0.0f), vInclinationXYZ);
D3DXMatrixRotationAxis(&mRotY, &vLocalYAxis, vRotation_new.y); // Rotation durchfuehren
D3DXMatrixMultiply(&mTranslation1, &mTranslation1, &mRotY);
}
if (bZ) // um z-achse rotieren ?
{
D3DXVECTOR3 vLocalZAxis = this->computeLocalAxis(D3DXVECTOR3(0.0f, 0.0f, 1.0f), vInclinationXYZ);
D3DXMatrixRotationAxis(&mRotZ, &vLocalZAxis, vRotation_new.z); // Rotation durchfuehren
D3DXMatrixMultiply(&mTranslation1, &mTranslation1, &mRotZ);
}
//D3DXMatrixTranslation(&mTranslation2, vTransformedCoords.x, vTransformedCoords.y, vTransformedCoords.z); // wieder um die Differenz zwischen Nullpunkt und eigentlichem Rotationspunkt verschieben (also zurueck zum Ausgangspunkt)
//D3DXMatrixMultiply(&mTransition, &mTranslation1, &mTranslation2);
D3DXMatrixMultiply(&this->m_mMeshMatrix, &mTranslation1, &this->m_mMeshMatrix);
ZeroMemory(&vTransformedCoords, sizeof(D3DXVECTOR3));
vTransformedCoords = ::vectorCrossMatrix16(vDifference, this->m_mMeshMatrix);
D3DXMatrixTranslation(&mTranslation2, vTransformedCoords.x, vTransformedCoords.y, vTransformedCoords.z); // wieder um die Differenz zwischen Nullpunkt und eigentlichem Rotationspunkt verschieben (also zurueck zum Ausgangspunkt)
D3DXMatrixMultiply(&this->m_mMeshMatrix, &mTranslation2, &this->m_mMeshMatrix);
}
|