Hallo!
ich habe ein Problem bei der Rotation um die X-Achse. Ich glaube dass diese upVector schuld ist, da sonst auch alles funktioniert.
|
C-/C++-Quelltext
|
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
|
/* @param: float fRotX Rotation um die X-Achse
* @param: float fRotY Rotation um die Y-Achse
*/
void harvesterCamera::rotateCamera(float fRotX, float fRotY)
{
m_fCurrentRotationX += fRotX; // bisher gemachte rotation um x - achse
m_fCurrentRotationY += fRotY; // bisher gemachte rotation um y - achse
D3DXMATRIX mRotX; // Rotationsmatrix X-Achse
D3DXMATRIX mRotY; // Rotationsmatrix Y-Achse
// Rotationsmatrix X-Achse erstellen
D3DXMatrixRotationX(&mRotX,m_fCurrentRotationY);
// Rotationsmatrix Y-Achse erstellen
D3DXMatrixRotationY(&mRotY,m_fCurrentRotationX);
D3DXMatrixMultiply(&m_matView,&m_matView,&mRotX);
D3DXMatrixMultiply(&m_matView,&m_matView,&mRotY);
// @todo: bei der Rotation um die X-Achse gibt es noch ein Problem
D3DXVECTOR3 newEyePoint;
newEyePoint.x = m_vEyePt.x * m_matView[0] + m_vEyePt.y * m_matView[4] + m_vEyePt.z * m_matView[8];
newEyePoint.y = m_vEyePt.x * m_matView[1] + m_vEyePt.y * m_matView[5] + m_vEyePt.z * m_matView[9];
newEyePoint.z = m_vEyePt.x * m_matView[2] + m_vEyePt.y * m_matView[6] + m_vEyePt.z * m_matView[10];
m_vEyePt.x = newEyePoint.x;
m_vEyePt.y = newEyePoint.y;
m_vEyePt.z = newEyePoint.z;
// alle Positionsangaben werden in eine Matrix umgewandelt.
D3DXMatrixLookAtLH( &m_matView, &m_vEyePt, // Position
&m_vLookatPt, // Blickpunkt
&m_vUpVec); // UpVektor
}
|
m_matView ist die aktuelle Matrix für die Kamera.
Wenn ich nun um die x-achse rotiere, klappt das bild plötzlich um. vielleicht weiß jemand rat ?!
m_vLookatPt = (0,0,0)
m_vUpVec = (0,1,0)
m_vEyePt ist die aktuelle pos der kamera..
mfg
soxx