Du bist nicht angemeldet.

Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!

Werbeanzeige

soxx

Frischling

  • »soxx« ist der Autor dieses Themas

Beiträge: 53

Wohnort: Klagenfurt

  • Private Nachricht senden

1

23.03.2006, 09:21

Kamerarotation um X-Achse

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

soxx

Frischling

  • »soxx« ist der Autor dieses Themas

Beiträge: 53

Wohnort: Klagenfurt

  • Private Nachricht senden

2

23.03.2006, 10:16

upvector war schuld

C-/C++-Quelltext

1
2
3
4
5
6
7
8
9
10
11
12
13
if (RAD2DEG(m_fCurrentRotationY) < -90)
    {
        m_fCurrentRotationY += 2*D3DX_PI;
        this->m_vUpVec.y *= -1;
    }
    else if (RAD2DEG(m_fCurrentRotationY) < 90 && this->m_vUpVec.y==-1)
    {
        this->m_vUpVec.y *= -1;
    }
    else if (RAD2DEG(m_fCurrentRotationY) > 90 && this->m_vUpVec.y==1)
    {
        this->m_vUpVec.y *= -1;
    }