예제 #1
0
        public void ApplyCamera()
        {
            //PlayerMovement playermovement = PlayerMovement.GetInstance();

            GLMatrix4d cameramatrix = GLMatrix4d.identity();

            // rotate and reflect so x points right, y points backwards, z points up
            cameramatrix.applyRotate(-90, 1.0, 0.0, 0.0);
            cameramatrix.applyScale(1, -1, 1);

            // rotate so x points right, y points forward, z points up
            //cameramatrix.applyRotate(-90, 1.0, 0.0, 0.0);

            // rotate so z axis is up, and x axis is forward, y axis is left
            //cameramatrix.applyRotate(90, 0.0, 0.0, 1.0);
            //cameramatrix.applyRotate( 90, 0.0, 1.0, 0.0 );

            if (bRoamingCameraEnabled)
            {
                Rot inversecamerarot = RoamingCameraRot.Inverse();
                mvMath.ApplyRotToGLMatrix4d(ref cameramatrix, inversecamerarot);
                cameramatrix.applyTranslate(-RoamingCameraPos.x, -RoamingCameraPos.y, -RoamingCameraPos.z);
            }
            else if (viewpoint == Viewpoint.MouseLook)
            {
                //cameramatrix.applyRotate( - playermovement.avataryrot, 0f, 1f, 0f );
                //cameramatrix.applyRotate( - playermovement.avatarzrot, 0f, 0f, 1f );
                //cameramatrix.applyTranslate( - playermovement.avatarpos.x, - playermovement.avatarpos.y, - playermovement.avatarpos.z );
            }
            else if (viewpoint == Viewpoint.BehindPlayer)
            {
                /*
                 * cameramatrix.applyRotate( -18f, 0f, 1f, 0f );
                 *
                 * // Vector3 V = new Vector3( 0, playermovement.avataryrot * mvMath.PiOver180, playermovement.avatarzrot * mvMath.PiOver180 );
                 *
                 * cameramatrix.applyTranslate( 3.0f, 0.0f, -1.0f );
                 *
                 * cameramatrix.applyRotate( - (float)playermovement.avataryrot, 0f, 1f, 0f );
                 * cameramatrix.applyRotate( - (float)playermovement.avatarzrot, 0f, 0f, 1f );
                 *
                 * cameramatrix.applyTranslate( -playermovement.avatarpos.x, -playermovement.avatarpos.y, -playermovement.avatarpos.z );
                 */
            }
            else if (viewpoint == Viewpoint.ThirdParty)
            {
                /*
                 * cameramatrix.applyRotate( -18f, 0f, 1f, 0f );
                 * cameramatrix.applyRotate( -90f, 0f, 0f, 1f );
                 *
                 * cameramatrix.applyTranslate( 0.0, - fThirdPartyViewZoom, fThirdPartyViewZoom / 3.0 );
                 * cameramatrix.applyRotate( - fThirdPartyViewRotate, 0f, 0f, 1f );
                 * cameramatrix.applyTranslate( - playermovement.avatarpos.x, - playermovement.avatarpos.y, - playermovement.avatarpos.z );
                 */
            }

            GraphicsHelperFactory.GetInstance().LoadMatrix(cameramatrix.ToArray());
        }
예제 #2
0
    public static void ApplyRotToGLMatrix4d(ref GLMatrix4d matrix, Rot rot)
    {
        double  fRotAngle = 0;
        Vector3 vAxis     = new Vector3();

        mvMath.Rot2AxisAngle(ref vAxis, ref fRotAngle, rot);

        matrix.applyRotate((float)(fRotAngle / Math.PI * 180), (float)vAxis.x, (float)vAxis.y, (float)vAxis.z);
    }