public Vector2 IntersectPlane(Plane plane, Vector2 relativeMousePos) { // Relative screen position. float xRayView = relativeMousePos.X / Projection.M11; float yRayView = relativeMousePos.Y / Projection.M22; viewDirection.Normalize(); Vector3 ray = viewDirection + rightVec * xRayView - upVec * yRayView; Vector4 pointVec = new Vector4(position - plane.Origin, 0); Matrix dirMat = new Matrix(); Matrix test = Matrix.Translation(1, 1, 1); //var x = test.get_Rows(3); dirMat.set_Rows(0, new Vector4(plane.XAxis, 0)); dirMat.set_Rows(1, new Vector4(plane.YAxis, 0)); dirMat.set_Rows(2, new Vector4(-ray, 0)); dirMat.set_Rows(3, Vector4.UnitW); dirMat.Invert(); Vector4 res = Vector4.Transform(pointVec, dirMat); Vector2 xy = new Vector2(Vector4.Dot(dirMat.get_Rows(0), pointVec), Vector4.Dot(dirMat.get_Rows(1), pointVec)); return new Vector2(res.X, res.Y); }
public VertexPropInstance(Matrix matrix, CompressedLightCube light) { row1 = matrix.get_Rows(0); row2 = matrix.get_Rows(1); row3 = matrix.get_Rows(2); Vector4 vec = matrix.get_Rows(3); row1.W = vec.X; row2.W = vec.Y; row3.W = vec.Z; cubex = light.Color[0]; cubex1 = light.Color[1]; cubey = light.Color[2]; cubey1 = light.Color[3]; cubez = light.Color[4]; cubez1 = light.Color[5]; }