Exemple #1
0
//////////////////////////////////////////////////////////
//  Rotate a frame around it's local X axis
void gltRotateFrameLocalX(GLTFrame *pFrame, GLfloat fAngle)
    {
	GLTMatrix mRotation;
    GLTVector3 vNewForward;
    
//    gltRotationMatrix((float)gltDegToRad(fAngle), 1.0f, 0.0f, 0.0f, mRotation);
    gltRotationMatrix(fAngle, 1, 0, 0, mRotation);

    gltRotateVector(pFrame->vForward, mRotation, vNewForward);
    memcpy(pFrame->vForward, vNewForward, sizeof(GLTVector3));

   /* GLTMatrix mRotation;
    GLTVector3 vCross;
    GLTVector3 vNewVect;

    gltVectorCrossProduct(pFrame->vUp, pFrame->vForward, vCross);
    gltRotationMatrix(fAngle, vCross[0], vCross[1], vCross[2], mRotation);

    
    // Inline 3x3 matrix multiply for rotation only
    vNewVect[0] = mRotation[0] * pFrame->vForward[0] + mRotation[4] * pFrame->vForward[1] + mRotation[8] *  pFrame->vForward[2];	
    vNewVect[1] = mRotation[1] * pFrame->vForward[0] + mRotation[5] * pFrame->vForward[1] + mRotation[9] *  pFrame->vForward[2];	
    vNewVect[2] = mRotation[2] * pFrame->vForward[0] + mRotation[6] * pFrame->vForward[1] + mRotation[10] * pFrame->vForward[2];	
    memcpy(pFrame->vForward, vNewVect, sizeof(GLfloat)*3);

    // Update pointing up vector
    /*vNewVect[0] = mRotation[0] * pFrame->vUp[0] + mRotation[4] * pFrame->vUp[1] + mRotation[8] *  pFrame->vUp[2];	
    vNewVect[1] = mRotation[1] * pFrame->vUp[0] + mRotation[5] * pFrame->vUp[1] + mRotation[9] *  pFrame->vUp[2];	
    vNewVect[2] = mRotation[2] * pFrame->vUp[0] + mRotation[6] * pFrame->vUp[1] + mRotation[10] * pFrame->vUp[2];	
    memcpy(pFrame->vUp, vNewVect, sizeof(GLfloat) * 3);*/
	}
Exemple #2
0
/////////////////////////////////////////////////////////
// Rotate a frame around it's local Y axis
void gltRotateFrameLocalY(GLTFrame *pFrame, GLfloat fAngle)
    {
    GLTMatrix mRotation;
    GLTVector3 vNewForward;
    
    gltRotationMatrix((float)gltDegToRad(fAngle), 0.0f, 1.0f, 0.0f, mRotation);
    gltRotationMatrix(fAngle, pFrame->vUp[0], pFrame->vUp[1], pFrame->vUp[2], mRotation);

    gltRotateVector(pFrame->vForward, mRotation, vNewForward);
    memcpy(pFrame->vForward, vNewForward, sizeof(GLTVector3));
    }