26

Odp: stawianie punktu w 3d

juppi!!!
udało się znaleźć rozwiązanie. Tak jak przypuszczałem na początku okazało się, że aby obrócić kamerę wokół własnych osi trzeba przemnożyć ruchome osie przez wartości cos i sin , rozwiązanie znalazłem na tej ciekawej stronce z tutorkami opengl

A tutaj kod w C++:

void CCamera::RotateX (GLfloat Angle)
{
    RotatedX += Angle;
    
    //Rotate viewdir around the right vector:
    ViewDir = Normalize3dVector(ViewDir*cos(Angle*PIdiv180)
                                + UpVector*sin(Angle*PIdiv180));

    //now compute the new UpVector (by cross product)
    UpVector = CrossProduct(&ViewDir, &RightVector)*-1;

    
}

void CCamera::RotateY (GLfloat Angle)
{
    RotatedY += Angle;
    
    //Rotate viewdir around the up vector:
    ViewDir = Normalize3dVector(ViewDir*cos(Angle*PIdiv180)
                                - RightVector*sin(Angle*PIdiv180));

    //now compute the new RightVector (by cross product)
    RightVector = CrossProduct(&ViewDir, &UpVector);
}

void CCamera::RotateZ (GLfloat Angle)
{
    RotatedZ += Angle;
    
    //Rotate viewdir around the right vector:
    RightVector = Normalize3dVector(RightVector*cos(Angle*PIdiv180)
                                + UpVector*sin(Angle*PIdiv180));

    //now compute the new UpVector (by cross product)
    UpVector = CrossProduct(&ViewDir, &RightVector)*-1;

Dzięki za zainteresowanie tematem,
pozdrawiam