Esempio n. 1
0
        public static Matrix3f createNormalMatrix(Matrix4f viewMatrix, Matrix4f modelMatrix)
        {
            Matrix3f result;

            result = MatrixTransforms.Transpose(MatrixTransforms.Inverse(viewMatrix * modelMatrix)).toMatrix3();
            return(result);
        }
Esempio n. 2
0
        /// <summary>
        /// Map the specified window coordinates (win.x, win.y, win.z) into object coordinates.
        /// </summary>
        /// <param name="win">The win.</param>
        /// <param name="model">The model.</param>
        /// <param name="proj">The proj.</param>
        /// <param name="viewport">The viewport.</param>
        /// <returns></returns>
        public static Vector3f unProject(Vector3f win, Matrix4f model, Matrix4f proj, Vector4f viewport)
        {
            Matrix4f Inverse = MatrixTransforms.Inverse(proj * model);

            Vector4f tmp = new Vector4f(win, (1f));

            tmp.x = (tmp.x - (viewport[0])) / (viewport[2]);
            tmp.y = (tmp.y - (viewport[1])) / (viewport[3]);
            tmp   = tmp * (2f) - (1f);

            Vector4f obj = Inverse * tmp;

            obj /= obj.w;

            return(new Vector3f(obj));
        }