public static void Update(FrustumCone f, Vector3 origin, Matrix4 view, Matrix4 proj) { f.Origin = origin; var inVP = Matrix4.Mult(view, proj).Inverted(); f.LeftBottom = GetDir(origin, new Vector2(-1, -1), inVP); f.RightBottom = GetDir(origin, new Vector2(1, -1), inVP); f.LeftTop = GetDir(origin, new Vector2(-1, 1), inVP); f.RightTop = GetDir(origin, new Vector2(1, 1), inVP); }
public static FrustumCone Create(Vector3 origin, Matrix4 view, Matrix4 proj) { var f = new FrustumCone(); f.Origin = origin; var inVP = Matrix4.Mult(view, proj).Inverted(); f.LeftBottom = GetDir(origin, new Vector2(-1, -1), inVP); f.RightBottom = GetDir(origin, new Vector2(1, -1), inVP); f.LeftTop = GetDir(origin, new Vector2(-1, 1), inVP); f.RightTop = GetDir(origin, new Vector2(1, 1), inVP); return f; }
public static FrustumCone Create(Vector3 origin, Matrix4 view, Matrix4 proj) { var f = new FrustumCone(); f.Origin = origin; var inVP = Matrix4.Mult(view, proj).Inverted(); f.LeftBottom = GetDir(origin, new Vector2(-1, -1), inVP); f.RightBottom = GetDir(origin, new Vector2(1, -1), inVP); f.LeftTop = GetDir(origin, new Vector2(-1, 1), inVP); f.RightTop = GetDir(origin, new Vector2(1, 1), inVP); return(f); }
public void Update() { lock (Transformation) { var tRotationMatrix = Matrix4.CreateFromQuaternion(Transformation.GetOrientation().Inverted()); var tViewMatrix = Matrix4.CreateTranslation(-Transformation.GetPosition()) * RotationMatrix; if (cone == null) { var tcone = FrustumCone.Create(Transformation.GetPosition(), tViewMatrix, ProjectionMatrix); cone = tcone; } else { FrustumCone.Update(cone, Transformation.GetPosition(), tViewMatrix, ProjectionMatrix); } RotationMatrix = tRotationMatrix; ViewMatrix = tViewMatrix; VPMatrix = Matrix4.Mult(ViewMatrix, ProjectionMatrix); } }
public void UpdateFromRollPitch() { lock (Transformation) { var rotationX = Quaternion.FromAxisAngle(Vector3.UnitY, Pitch); var rotationY = Quaternion.FromAxisAngle(Vector3.UnitX, Roll); Transformation.SetOrientation(Quaternion.Multiply(rotationX.Inverted(), rotationY.Inverted())); var tRotationMatrix = Matrix4.CreateFromQuaternion(rotationX) * Matrix4.CreateFromQuaternion(rotationY); var tViewMatrix = Matrix4.CreateTranslation(-Transformation.GetPosition()) * RotationMatrix; if (cone == null) { var tcone = FrustumCone.Create(Transformation.GetPosition(), tViewMatrix, ProjectionMatrix); cone = tcone; } else { FrustumCone.Update(cone, Transformation.GetPosition(), tViewMatrix, ProjectionMatrix); } RotationMatrix = tRotationMatrix; ViewMatrix = tViewMatrix; VPMatrix = Matrix4.Mult(ViewMatrix, ProjectionMatrix); } }
public void UpdateFromRollPitch() { var rotationX = Quaternion.FromAxisAngle(Vector3.UnitY, Pitch); var rotationY = Quaternion.FromAxisAngle(Vector3.UnitX, Roll); Transformation.SetOrientation(Quaternion.Multiply(rotationX.Inverted(), rotationY.Inverted())); RotationMatrix = Matrix4.CreateFromQuaternion(rotationX) * Matrix4.CreateFromQuaternion(rotationY); ViewMatrix = Matrix4.CreateTranslation(-Transformation.GetPosition()) * RotationMatrix; if(cone == null) { var tcone = FrustumCone.Create(Transformation.GetPosition(), ViewMatrix, ProjectionMatrix); cone = tcone; } else FrustumCone.Update(cone, Transformation.GetPosition(), ViewMatrix, ProjectionMatrix); }
public void Update() { lock (Transformation) { var tRotationMatrix = Matrix4.CreateFromQuaternion(Transformation.GetOrientation().Inverted()); var tViewMatrix = Matrix4.CreateTranslation(-Transformation.GetPosition()) * RotationMatrix; if(cone == null) { var tcone = FrustumCone.Create(Transformation.GetPosition(), tViewMatrix, ProjectionMatrix); cone = tcone; } else FrustumCone.Update(cone, Transformation.GetPosition(), tViewMatrix, ProjectionMatrix); RotationMatrix = tRotationMatrix; ViewMatrix = tViewMatrix; } }