private Vector4 ToEyeCoords(Vector4 clipCoords) { Matrix4 invertedProjection = Matrix4.Invert(ProjectionMatrix); Vector4 eyeCoords = Vector4.Transform(clipCoords, invertedProjection); return(new Vector4(eyeCoords.X, eyeCoords.Y, 1.0f, 0.0f)); }
private Vector3 ToWorldCoords(Vector4 eyeCoords) { Matrix4 invertedView = Matrix4.Invert(VievMatrix); Vector4 rayWorld = Vector4.Transform(eyeCoords, invertedView); Vector3 mouseRay = new Vector3(rayWorld.Xyz); mouseRay.Normalize(); return(mouseRay); }
/// <summary> /// Calcola il centro del "view cuboid" in light space e po lo converte in world space /// </summary> /// <returns>il cento dek view cuboid in world space</returns> public Vector3 GetCenter() { float x = (minX + maxX) / 2f; float y = (minY + maxY) / 2f; float z = (minZ + maxZ) / 2f; Vector4 cen = new Vector4(x, y, z, 1); Matrix4 invertedLight = new Matrix4(); if (lightViewMatrix.Determinant != 0) { Matrix4.Invert(ref lightViewMatrix, out invertedLight); } return(new Vector3(Vector4.Transform(cen, invertedLight))); }