(61d00a474) v0.9.7.1
This commit is contained in:
@@ -1,538 +0,0 @@
|
||||
// MIT License - Copyright (C) The Mono.Xna Team
|
||||
// This file is subject to the terms and conditions defined in
|
||||
// file 'LICENSE.txt', which is part of this source code package.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Microsoft.Xna.Framework
|
||||
{
|
||||
[DataContract]
|
||||
[DebuggerDisplay("{DebugDisplayString,nq}")]
|
||||
public struct BoundingBox : IEquatable<BoundingBox>
|
||||
{
|
||||
|
||||
#region Public Fields
|
||||
|
||||
[DataMember]
|
||||
public Vector3 Min;
|
||||
|
||||
[DataMember]
|
||||
public Vector3 Max;
|
||||
|
||||
public const int CornerCount = 8;
|
||||
|
||||
#endregion Public Fields
|
||||
|
||||
|
||||
#region Public Constructors
|
||||
|
||||
public BoundingBox(Vector3 min, Vector3 max)
|
||||
{
|
||||
this.Min = min;
|
||||
this.Max = max;
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public ContainmentType Contains(BoundingBox box)
|
||||
{
|
||||
//test if all corner is in the same side of a face by just checking min and max
|
||||
if (box.Max.X < Min.X
|
||||
|| box.Min.X > Max.X
|
||||
|| box.Max.Y < Min.Y
|
||||
|| box.Min.Y > Max.Y
|
||||
|| box.Max.Z < Min.Z
|
||||
|| box.Min.Z > Max.Z)
|
||||
return ContainmentType.Disjoint;
|
||||
|
||||
|
||||
if (box.Min.X >= Min.X
|
||||
&& box.Max.X <= Max.X
|
||||
&& box.Min.Y >= Min.Y
|
||||
&& box.Max.Y <= Max.Y
|
||||
&& box.Min.Z >= Min.Z
|
||||
&& box.Max.Z <= Max.Z)
|
||||
return ContainmentType.Contains;
|
||||
|
||||
return ContainmentType.Intersects;
|
||||
}
|
||||
|
||||
public void Contains(ref BoundingBox box, out ContainmentType result)
|
||||
{
|
||||
result = Contains(box);
|
||||
}
|
||||
|
||||
public ContainmentType Contains(BoundingFrustum frustum)
|
||||
{
|
||||
//TODO: bad done here need a fix.
|
||||
//Because question is not frustum contain box but reverse and this is not the same
|
||||
int i;
|
||||
ContainmentType contained;
|
||||
Vector3[] corners = frustum.GetCorners();
|
||||
|
||||
// First we check if frustum is in box
|
||||
for (i = 0; i < corners.Length; i++)
|
||||
{
|
||||
this.Contains(ref corners[i], out contained);
|
||||
if (contained == ContainmentType.Disjoint)
|
||||
break;
|
||||
}
|
||||
|
||||
if (i == corners.Length) // This means we checked all the corners and they were all contain or instersect
|
||||
return ContainmentType.Contains;
|
||||
|
||||
if (i != 0) // if i is not equal to zero, we can fastpath and say that this box intersects
|
||||
return ContainmentType.Intersects;
|
||||
|
||||
|
||||
// If we get here, it means the first (and only) point we checked was actually contained in the frustum.
|
||||
// So we assume that all other points will also be contained. If one of the points is disjoint, we can
|
||||
// exit immediately saying that the result is Intersects
|
||||
i++;
|
||||
for (; i < corners.Length; i++)
|
||||
{
|
||||
this.Contains(ref corners[i], out contained);
|
||||
if (contained != ContainmentType.Contains)
|
||||
return ContainmentType.Intersects;
|
||||
|
||||
}
|
||||
|
||||
// If we get here, then we know all the points were actually contained, therefore result is Contains
|
||||
return ContainmentType.Contains;
|
||||
}
|
||||
|
||||
public ContainmentType Contains(BoundingSphere sphere)
|
||||
{
|
||||
if (sphere.Center.X - Min.X >= sphere.Radius
|
||||
&& sphere.Center.Y - Min.Y >= sphere.Radius
|
||||
&& sphere.Center.Z - Min.Z >= sphere.Radius
|
||||
&& Max.X - sphere.Center.X >= sphere.Radius
|
||||
&& Max.Y - sphere.Center.Y >= sphere.Radius
|
||||
&& Max.Z - sphere.Center.Z >= sphere.Radius)
|
||||
return ContainmentType.Contains;
|
||||
|
||||
double dmin = 0;
|
||||
|
||||
double e = sphere.Center.X - Min.X;
|
||||
if (e < 0)
|
||||
{
|
||||
if (e < -sphere.Radius)
|
||||
{
|
||||
return ContainmentType.Disjoint;
|
||||
}
|
||||
dmin += e * e;
|
||||
}
|
||||
else
|
||||
{
|
||||
e = sphere.Center.X - Max.X;
|
||||
if (e > 0)
|
||||
{
|
||||
if (e > sphere.Radius)
|
||||
{
|
||||
return ContainmentType.Disjoint;
|
||||
}
|
||||
dmin += e * e;
|
||||
}
|
||||
}
|
||||
|
||||
e = sphere.Center.Y - Min.Y;
|
||||
if (e < 0)
|
||||
{
|
||||
if (e < -sphere.Radius)
|
||||
{
|
||||
return ContainmentType.Disjoint;
|
||||
}
|
||||
dmin += e * e;
|
||||
}
|
||||
else
|
||||
{
|
||||
e = sphere.Center.Y - Max.Y;
|
||||
if (e > 0)
|
||||
{
|
||||
if (e > sphere.Radius)
|
||||
{
|
||||
return ContainmentType.Disjoint;
|
||||
}
|
||||
dmin += e * e;
|
||||
}
|
||||
}
|
||||
|
||||
e = sphere.Center.Z - Min.Z;
|
||||
if (e < 0)
|
||||
{
|
||||
if (e < -sphere.Radius)
|
||||
{
|
||||
return ContainmentType.Disjoint;
|
||||
}
|
||||
dmin += e * e;
|
||||
}
|
||||
else
|
||||
{
|
||||
e = sphere.Center.Z - Max.Z;
|
||||
if (e > 0)
|
||||
{
|
||||
if (e > sphere.Radius)
|
||||
{
|
||||
return ContainmentType.Disjoint;
|
||||
}
|
||||
dmin += e * e;
|
||||
}
|
||||
}
|
||||
|
||||
if (dmin <= sphere.Radius * sphere.Radius)
|
||||
return ContainmentType.Intersects;
|
||||
|
||||
return ContainmentType.Disjoint;
|
||||
}
|
||||
|
||||
public void Contains(ref BoundingSphere sphere, out ContainmentType result)
|
||||
{
|
||||
result = this.Contains(sphere);
|
||||
}
|
||||
|
||||
public ContainmentType Contains(Vector3 point)
|
||||
{
|
||||
ContainmentType result;
|
||||
this.Contains(ref point, out result);
|
||||
return result;
|
||||
}
|
||||
|
||||
public void Contains(ref Vector3 point, out ContainmentType result)
|
||||
{
|
||||
//first we get if point is out of box
|
||||
if (point.X < this.Min.X
|
||||
|| point.X > this.Max.X
|
||||
|| point.Y < this.Min.Y
|
||||
|| point.Y > this.Max.Y
|
||||
|| point.Z < this.Min.Z
|
||||
|| point.Z > this.Max.Z)
|
||||
{
|
||||
result = ContainmentType.Disjoint;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = ContainmentType.Contains;
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly Vector3 MaxVector3 = new Vector3(float.MaxValue);
|
||||
private static readonly Vector3 MinVector3 = new Vector3(float.MinValue);
|
||||
|
||||
/// <summary>
|
||||
/// Create a bounding box from the given list of points.
|
||||
/// </summary>
|
||||
/// <param name="points">The list of Vector3 instances defining the point cloud to bound</param>
|
||||
/// <returns>A bounding box that encapsulates the given point cloud.</returns>
|
||||
/// <exception cref="System.ArgumentException">Thrown if the given list has no points.</exception>
|
||||
public static BoundingBox CreateFromPoints(IEnumerable<Vector3> points)
|
||||
{
|
||||
if (points == null)
|
||||
throw new ArgumentNullException();
|
||||
|
||||
var empty = true;
|
||||
var minVec = MaxVector3;
|
||||
var maxVec = MinVector3;
|
||||
foreach (var ptVector in points)
|
||||
{
|
||||
minVec.X = (minVec.X < ptVector.X) ? minVec.X : ptVector.X;
|
||||
minVec.Y = (minVec.Y < ptVector.Y) ? minVec.Y : ptVector.Y;
|
||||
minVec.Z = (minVec.Z < ptVector.Z) ? minVec.Z : ptVector.Z;
|
||||
|
||||
maxVec.X = (maxVec.X > ptVector.X) ? maxVec.X : ptVector.X;
|
||||
maxVec.Y = (maxVec.Y > ptVector.Y) ? maxVec.Y : ptVector.Y;
|
||||
maxVec.Z = (maxVec.Z > ptVector.Z) ? maxVec.Z : ptVector.Z;
|
||||
|
||||
empty = false;
|
||||
}
|
||||
if (empty)
|
||||
throw new ArgumentException();
|
||||
|
||||
return new BoundingBox(minVec, maxVec);
|
||||
}
|
||||
|
||||
public static BoundingBox CreateFromSphere(BoundingSphere sphere)
|
||||
{
|
||||
BoundingBox result;
|
||||
CreateFromSphere(ref sphere, out result);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static void CreateFromSphere(ref BoundingSphere sphere, out BoundingBox result)
|
||||
{
|
||||
var corner = new Vector3(sphere.Radius);
|
||||
result.Min = sphere.Center - corner;
|
||||
result.Max = sphere.Center + corner;
|
||||
}
|
||||
|
||||
public static BoundingBox CreateMerged(BoundingBox original, BoundingBox additional)
|
||||
{
|
||||
BoundingBox result;
|
||||
CreateMerged(ref original, ref additional, out result);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static void CreateMerged(ref BoundingBox original, ref BoundingBox additional, out BoundingBox result)
|
||||
{
|
||||
result.Min.X = Math.Min(original.Min.X, additional.Min.X);
|
||||
result.Min.Y = Math.Min(original.Min.Y, additional.Min.Y);
|
||||
result.Min.Z = Math.Min(original.Min.Z, additional.Min.Z);
|
||||
result.Max.X = Math.Max(original.Max.X, additional.Max.X);
|
||||
result.Max.Y = Math.Max(original.Max.Y, additional.Max.Y);
|
||||
result.Max.Z = Math.Max(original.Max.Z, additional.Max.Z);
|
||||
}
|
||||
|
||||
public bool Equals(BoundingBox other)
|
||||
{
|
||||
return (this.Min == other.Min) && (this.Max == other.Max);
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return (obj is BoundingBox) ? this.Equals((BoundingBox)obj) : false;
|
||||
}
|
||||
|
||||
public Vector3[] GetCorners()
|
||||
{
|
||||
return new Vector3[] {
|
||||
new Vector3(this.Min.X, this.Max.Y, this.Max.Z),
|
||||
new Vector3(this.Max.X, this.Max.Y, this.Max.Z),
|
||||
new Vector3(this.Max.X, this.Min.Y, this.Max.Z),
|
||||
new Vector3(this.Min.X, this.Min.Y, this.Max.Z),
|
||||
new Vector3(this.Min.X, this.Max.Y, this.Min.Z),
|
||||
new Vector3(this.Max.X, this.Max.Y, this.Min.Z),
|
||||
new Vector3(this.Max.X, this.Min.Y, this.Min.Z),
|
||||
new Vector3(this.Min.X, this.Min.Y, this.Min.Z)
|
||||
};
|
||||
}
|
||||
|
||||
public void GetCorners(Vector3[] corners)
|
||||
{
|
||||
if (corners == null)
|
||||
{
|
||||
throw new ArgumentNullException("corners");
|
||||
}
|
||||
if (corners.Length < 8)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("corners", "Not Enought Corners");
|
||||
}
|
||||
corners[0].X = this.Min.X;
|
||||
corners[0].Y = this.Max.Y;
|
||||
corners[0].Z = this.Max.Z;
|
||||
corners[1].X = this.Max.X;
|
||||
corners[1].Y = this.Max.Y;
|
||||
corners[1].Z = this.Max.Z;
|
||||
corners[2].X = this.Max.X;
|
||||
corners[2].Y = this.Min.Y;
|
||||
corners[2].Z = this.Max.Z;
|
||||
corners[3].X = this.Min.X;
|
||||
corners[3].Y = this.Min.Y;
|
||||
corners[3].Z = this.Max.Z;
|
||||
corners[4].X = this.Min.X;
|
||||
corners[4].Y = this.Max.Y;
|
||||
corners[4].Z = this.Min.Z;
|
||||
corners[5].X = this.Max.X;
|
||||
corners[5].Y = this.Max.Y;
|
||||
corners[5].Z = this.Min.Z;
|
||||
corners[6].X = this.Max.X;
|
||||
corners[6].Y = this.Min.Y;
|
||||
corners[6].Z = this.Min.Z;
|
||||
corners[7].X = this.Min.X;
|
||||
corners[7].Y = this.Min.Y;
|
||||
corners[7].Z = this.Min.Z;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return this.Min.GetHashCode() + this.Max.GetHashCode();
|
||||
}
|
||||
|
||||
public bool Intersects(BoundingBox box)
|
||||
{
|
||||
bool result;
|
||||
Intersects(ref box, out result);
|
||||
return result;
|
||||
}
|
||||
|
||||
public void Intersects(ref BoundingBox box, out bool result)
|
||||
{
|
||||
if ((this.Max.X >= box.Min.X) && (this.Min.X <= box.Max.X))
|
||||
{
|
||||
if ((this.Max.Y < box.Min.Y) || (this.Min.Y > box.Max.Y))
|
||||
{
|
||||
result = false;
|
||||
return;
|
||||
}
|
||||
|
||||
result = (this.Max.Z >= box.Min.Z) && (this.Min.Z <= box.Max.Z);
|
||||
return;
|
||||
}
|
||||
|
||||
result = false;
|
||||
return;
|
||||
}
|
||||
|
||||
public bool Intersects(BoundingFrustum frustum)
|
||||
{
|
||||
return frustum.Intersects(this);
|
||||
}
|
||||
|
||||
public bool Intersects(BoundingSphere sphere)
|
||||
{
|
||||
if (sphere.Center.X - Min.X > sphere.Radius
|
||||
&& sphere.Center.Y - Min.Y > sphere.Radius
|
||||
&& sphere.Center.Z - Min.Z > sphere.Radius
|
||||
&& Max.X - sphere.Center.X > sphere.Radius
|
||||
&& Max.Y - sphere.Center.Y > sphere.Radius
|
||||
&& Max.Z - sphere.Center.Z > sphere.Radius)
|
||||
return true;
|
||||
|
||||
double dmin = 0;
|
||||
|
||||
if (sphere.Center.X - Min.X <= sphere.Radius)
|
||||
dmin += (sphere.Center.X - Min.X) * (sphere.Center.X - Min.X);
|
||||
else if (Max.X - sphere.Center.X <= sphere.Radius)
|
||||
dmin += (sphere.Center.X - Max.X) * (sphere.Center.X - Max.X);
|
||||
|
||||
if (sphere.Center.Y - Min.Y <= sphere.Radius)
|
||||
dmin += (sphere.Center.Y - Min.Y) * (sphere.Center.Y - Min.Y);
|
||||
else if (Max.Y - sphere.Center.Y <= sphere.Radius)
|
||||
dmin += (sphere.Center.Y - Max.Y) * (sphere.Center.Y - Max.Y);
|
||||
|
||||
if (sphere.Center.Z - Min.Z <= sphere.Radius)
|
||||
dmin += (sphere.Center.Z - Min.Z) * (sphere.Center.Z - Min.Z);
|
||||
else if (Max.Z - sphere.Center.Z <= sphere.Radius)
|
||||
dmin += (sphere.Center.Z - Max.Z) * (sphere.Center.Z - Max.Z);
|
||||
|
||||
if (dmin <= sphere.Radius * sphere.Radius)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void Intersects(ref BoundingSphere sphere, out bool result)
|
||||
{
|
||||
result = Intersects(sphere);
|
||||
}
|
||||
|
||||
public PlaneIntersectionType Intersects(Plane plane)
|
||||
{
|
||||
PlaneIntersectionType result;
|
||||
Intersects(ref plane, out result);
|
||||
return result;
|
||||
}
|
||||
|
||||
public void Intersects(ref Plane plane, out PlaneIntersectionType result)
|
||||
{
|
||||
// See http://zach.in.tu-clausthal.de/teaching/cg_literatur/lighthouse3d_view_frustum_culling/index.html
|
||||
|
||||
Vector3 positiveVertex;
|
||||
Vector3 negativeVertex;
|
||||
|
||||
if (plane.Normal.X >= 0)
|
||||
{
|
||||
positiveVertex.X = Max.X;
|
||||
negativeVertex.X = Min.X;
|
||||
}
|
||||
else
|
||||
{
|
||||
positiveVertex.X = Min.X;
|
||||
negativeVertex.X = Max.X;
|
||||
}
|
||||
|
||||
if (plane.Normal.Y >= 0)
|
||||
{
|
||||
positiveVertex.Y = Max.Y;
|
||||
negativeVertex.Y = Min.Y;
|
||||
}
|
||||
else
|
||||
{
|
||||
positiveVertex.Y = Min.Y;
|
||||
negativeVertex.Y = Max.Y;
|
||||
}
|
||||
|
||||
if (plane.Normal.Z >= 0)
|
||||
{
|
||||
positiveVertex.Z = Max.Z;
|
||||
negativeVertex.Z = Min.Z;
|
||||
}
|
||||
else
|
||||
{
|
||||
positiveVertex.Z = Min.Z;
|
||||
negativeVertex.Z = Max.Z;
|
||||
}
|
||||
|
||||
// Inline Vector3.Dot(plane.Normal, negativeVertex) + plane.D;
|
||||
var distance = plane.Normal.X * negativeVertex.X + plane.Normal.Y * negativeVertex.Y + plane.Normal.Z * negativeVertex.Z + plane.D;
|
||||
if (distance > 0)
|
||||
{
|
||||
result = PlaneIntersectionType.Front;
|
||||
return;
|
||||
}
|
||||
|
||||
// Inline Vector3.Dot(plane.Normal, positiveVertex) + plane.D;
|
||||
distance = plane.Normal.X * positiveVertex.X + plane.Normal.Y * positiveVertex.Y + plane.Normal.Z * positiveVertex.Z + plane.D;
|
||||
if (distance < 0)
|
||||
{
|
||||
result = PlaneIntersectionType.Back;
|
||||
return;
|
||||
}
|
||||
|
||||
result = PlaneIntersectionType.Intersecting;
|
||||
}
|
||||
|
||||
public Nullable<float> Intersects(Ray ray)
|
||||
{
|
||||
return ray.Intersects(this);
|
||||
}
|
||||
|
||||
public void Intersects(ref Ray ray, out Nullable<float> result)
|
||||
{
|
||||
result = Intersects(ray);
|
||||
}
|
||||
|
||||
public static bool operator ==(BoundingBox a, BoundingBox b)
|
||||
{
|
||||
return a.Equals(b);
|
||||
}
|
||||
|
||||
public static bool operator !=(BoundingBox a, BoundingBox b)
|
||||
{
|
||||
return !a.Equals(b);
|
||||
}
|
||||
|
||||
internal string DebugDisplayString
|
||||
{
|
||||
get
|
||||
{
|
||||
return string.Concat(
|
||||
"Min( ", this.Min.DebugDisplayString, " ) \r\n",
|
||||
"Max( ",this.Max.DebugDisplayString, " )"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return "{{Min:" + this.Min.ToString() + " Max:" + this.Max.ToString() + "}}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deconstruction method for <see cref="BoundingBox"/>.
|
||||
/// </summary>
|
||||
/// <param name="min"></param>
|
||||
/// <param name="max"></param>
|
||||
public void Deconstruct(out Vector3 min, out Vector3 max)
|
||||
{
|
||||
min = Min;
|
||||
max = Max;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
}
|
||||
}
|
||||
@@ -1,578 +0,0 @@
|
||||
// MIT License - Copyright (C) The Mono.Xna Team
|
||||
// This file is subject to the terms and conditions defined in
|
||||
// file 'LICENSE.txt', which is part of this source code package.
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Microsoft.Xna.Framework
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines a viewing frustum for intersection operations.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("{DebugDisplayString,nq}")]
|
||||
public class BoundingFrustum : IEquatable<BoundingFrustum>
|
||||
{
|
||||
#region Private Fields
|
||||
|
||||
private Matrix _matrix;
|
||||
private readonly Vector3[] _corners = new Vector3[CornerCount];
|
||||
private readonly Plane[] _planes = new Plane[PlaneCount];
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Fields
|
||||
|
||||
/// <summary>
|
||||
/// The number of planes in the frustum.
|
||||
/// </summary>
|
||||
public const int PlaneCount = 6;
|
||||
|
||||
/// <summary>
|
||||
/// The number of corner points in the frustum.
|
||||
/// </summary>
|
||||
public const int CornerCount = 8;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the <see cref="Matrix"/> of the frustum.
|
||||
/// </summary>
|
||||
public Matrix Matrix
|
||||
{
|
||||
get { return this._matrix; }
|
||||
set
|
||||
{
|
||||
this._matrix = value;
|
||||
this.CreatePlanes(); // FIXME: The odds are the planes will be used a lot more often than the matrix
|
||||
this.CreateCorners(); // is updated, so this should help performance. I hope ;)
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the near plane of the frustum.
|
||||
/// </summary>
|
||||
public Plane Near
|
||||
{
|
||||
get { return this._planes[0]; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the far plane of the frustum.
|
||||
/// </summary>
|
||||
public Plane Far
|
||||
{
|
||||
get { return this._planes[1]; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the left plane of the frustum.
|
||||
/// </summary>
|
||||
public Plane Left
|
||||
{
|
||||
get { return this._planes[2]; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the right plane of the frustum.
|
||||
/// </summary>
|
||||
public Plane Right
|
||||
{
|
||||
get { return this._planes[3]; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the top plane of the frustum.
|
||||
/// </summary>
|
||||
public Plane Top
|
||||
{
|
||||
get { return this._planes[4]; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the bottom plane of the frustum.
|
||||
/// </summary>
|
||||
public Plane Bottom
|
||||
{
|
||||
get { return this._planes[5]; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Internal Properties
|
||||
|
||||
internal string DebugDisplayString
|
||||
{
|
||||
get
|
||||
{
|
||||
return string.Concat(
|
||||
"Near( ", this._planes[0].DebugDisplayString, " ) \r\n",
|
||||
"Far( ", this._planes[1].DebugDisplayString, " ) \r\n",
|
||||
"Left( ", this._planes[2].DebugDisplayString, " ) \r\n",
|
||||
"Right( ", this._planes[3].DebugDisplayString, " ) \r\n",
|
||||
"Top( ", this._planes[4].DebugDisplayString, " ) \r\n",
|
||||
"Bottom( ", this._planes[5].DebugDisplayString, " ) "
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Constructs the frustum by extracting the view planes from a matrix.
|
||||
/// </summary>
|
||||
/// <param name="value">Combined matrix which usually is (View * Projection).</param>
|
||||
public BoundingFrustum(Matrix value)
|
||||
{
|
||||
this._matrix = value;
|
||||
this.CreatePlanes();
|
||||
this.CreateCorners();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Operators
|
||||
|
||||
/// <summary>
|
||||
/// Compares whether two <see cref="BoundingFrustum"/> instances are equal.
|
||||
/// </summary>
|
||||
/// <param name="a"><see cref="BoundingFrustum"/> instance on the left of the equal sign.</param>
|
||||
/// <param name="b"><see cref="BoundingFrustum"/> instance on the right of the equal sign.</param>
|
||||
/// <returns><c>true</c> if the instances are equal; <c>false</c> otherwise.</returns>
|
||||
public static bool operator ==(BoundingFrustum a, BoundingFrustum b)
|
||||
{
|
||||
if (Equals(a, null))
|
||||
return (Equals(b, null));
|
||||
|
||||
if (Equals(b, null))
|
||||
return (Equals(a, null));
|
||||
|
||||
return a._matrix == (b._matrix);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compares whether two <see cref="BoundingFrustum"/> instances are not equal.
|
||||
/// </summary>
|
||||
/// <param name="a"><see cref="BoundingFrustum"/> instance on the left of the not equal sign.</param>
|
||||
/// <param name="b"><see cref="BoundingFrustum"/> instance on the right of the not equal sign.</param>
|
||||
/// <returns><c>true</c> if the instances are not equal; <c>false</c> otherwise.</returns>
|
||||
public static bool operator !=(BoundingFrustum a, BoundingFrustum b)
|
||||
{
|
||||
return !(a == b);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
|
||||
#region Contains
|
||||
|
||||
/// <summary>
|
||||
/// Containment test between this <see cref="BoundingFrustum"/> and specified <see cref="BoundingBox"/>.
|
||||
/// </summary>
|
||||
/// <param name="box">A <see cref="BoundingBox"/> for testing.</param>
|
||||
/// <returns>Result of testing for containment between this <see cref="BoundingFrustum"/> and specified <see cref="BoundingBox"/>.</returns>
|
||||
public ContainmentType Contains(BoundingBox box)
|
||||
{
|
||||
var result = default(ContainmentType);
|
||||
this.Contains(ref box, out result);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Containment test between this <see cref="BoundingFrustum"/> and specified <see cref="BoundingBox"/>.
|
||||
/// </summary>
|
||||
/// <param name="box">A <see cref="BoundingBox"/> for testing.</param>
|
||||
/// <param name="result">Result of testing for containment between this <see cref="BoundingFrustum"/> and specified <see cref="BoundingBox"/> as an output parameter.</param>
|
||||
public void Contains(ref BoundingBox box, out ContainmentType result)
|
||||
{
|
||||
var intersects = false;
|
||||
for (var i = 0; i < PlaneCount; ++i)
|
||||
{
|
||||
var planeIntersectionType = default(PlaneIntersectionType);
|
||||
box.Intersects(ref this._planes[i], out planeIntersectionType);
|
||||
switch (planeIntersectionType)
|
||||
{
|
||||
case PlaneIntersectionType.Front:
|
||||
result = ContainmentType.Disjoint;
|
||||
return;
|
||||
case PlaneIntersectionType.Intersecting:
|
||||
intersects = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
result = intersects ? ContainmentType.Intersects : ContainmentType.Contains;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Containment test between this <see cref="BoundingFrustum"/> and specified <see cref="BoundingFrustum"/>.
|
||||
/// </summary>
|
||||
/// <param name="frustum">A <see cref="BoundingFrustum"/> for testing.</param>
|
||||
/// <returns>Result of testing for containment between this <see cref="BoundingFrustum"/> and specified <see cref="BoundingFrustum"/>.</returns>
|
||||
public ContainmentType Contains(BoundingFrustum frustum)
|
||||
{
|
||||
if (this == frustum) // We check to see if the two frustums are equal
|
||||
return ContainmentType.Contains;// If they are, there's no need to go any further.
|
||||
|
||||
var intersects = false;
|
||||
for (var i = 0; i < PlaneCount; ++i)
|
||||
{
|
||||
PlaneIntersectionType planeIntersectionType;
|
||||
frustum.Intersects(ref _planes[i], out planeIntersectionType);
|
||||
switch (planeIntersectionType)
|
||||
{
|
||||
case PlaneIntersectionType.Front:
|
||||
return ContainmentType.Disjoint;
|
||||
case PlaneIntersectionType.Intersecting:
|
||||
intersects = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return intersects ? ContainmentType.Intersects : ContainmentType.Contains;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Containment test between this <see cref="BoundingFrustum"/> and specified <see cref="BoundingSphere"/>.
|
||||
/// </summary>
|
||||
/// <param name="sphere">A <see cref="BoundingSphere"/> for testing.</param>
|
||||
/// <returns>Result of testing for containment between this <see cref="BoundingFrustum"/> and specified <see cref="BoundingSphere"/>.</returns>
|
||||
public ContainmentType Contains(BoundingSphere sphere)
|
||||
{
|
||||
var result = default(ContainmentType);
|
||||
this.Contains(ref sphere, out result);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Containment test between this <see cref="BoundingFrustum"/> and specified <see cref="BoundingSphere"/>.
|
||||
/// </summary>
|
||||
/// <param name="sphere">A <see cref="BoundingSphere"/> for testing.</param>
|
||||
/// <param name="result">Result of testing for containment between this <see cref="BoundingFrustum"/> and specified <see cref="BoundingSphere"/> as an output parameter.</param>
|
||||
public void Contains(ref BoundingSphere sphere, out ContainmentType result)
|
||||
{
|
||||
var intersects = false;
|
||||
for (var i = 0; i < PlaneCount; ++i)
|
||||
{
|
||||
var planeIntersectionType = default(PlaneIntersectionType);
|
||||
|
||||
// TODO: we might want to inline this for performance reasons
|
||||
sphere.Intersects(ref this._planes[i], out planeIntersectionType);
|
||||
switch (planeIntersectionType)
|
||||
{
|
||||
case PlaneIntersectionType.Front:
|
||||
result = ContainmentType.Disjoint;
|
||||
return;
|
||||
case PlaneIntersectionType.Intersecting:
|
||||
intersects = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
result = intersects ? ContainmentType.Intersects : ContainmentType.Contains;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Containment test between this <see cref="BoundingFrustum"/> and specified <see cref="Vector3"/>.
|
||||
/// </summary>
|
||||
/// <param name="point">A <see cref="Vector3"/> for testing.</param>
|
||||
/// <returns>Result of testing for containment between this <see cref="BoundingFrustum"/> and specified <see cref="Vector3"/>.</returns>
|
||||
public ContainmentType Contains(Vector3 point)
|
||||
{
|
||||
var result = default(ContainmentType);
|
||||
this.Contains(ref point, out result);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Containment test between this <see cref="BoundingFrustum"/> and specified <see cref="Vector3"/>.
|
||||
/// </summary>
|
||||
/// <param name="point">A <see cref="Vector3"/> for testing.</param>
|
||||
/// <param name="result">Result of testing for containment between this <see cref="BoundingFrustum"/> and specified <see cref="Vector3"/> as an output parameter.</param>
|
||||
public void Contains(ref Vector3 point, out ContainmentType result)
|
||||
{
|
||||
for (var i = 0; i < PlaneCount; ++i)
|
||||
{
|
||||
// TODO: we might want to inline this for performance reasons
|
||||
if (PlaneHelper.ClassifyPoint(ref point, ref this._planes[i]) > 0)
|
||||
{
|
||||
result = ContainmentType.Disjoint;
|
||||
return;
|
||||
}
|
||||
}
|
||||
result = ContainmentType.Contains;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Compares whether current instance is equal to specified <see cref="BoundingFrustum"/>.
|
||||
/// </summary>
|
||||
/// <param name="other">The <see cref="BoundingFrustum"/> to compare.</param>
|
||||
/// <returns><c>true</c> if the instances are equal; <c>false</c> otherwise.</returns>
|
||||
public bool Equals(BoundingFrustum other)
|
||||
{
|
||||
return (this == other);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compares whether current instance is equal to specified <see cref="BoundingFrustum"/>.
|
||||
/// </summary>
|
||||
/// <param name="obj">The <see cref="Object"/> to compare.</param>
|
||||
/// <returns><c>true</c> if the instances are equal; <c>false</c> otherwise.</returns>
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return (obj is BoundingFrustum) && this == ((BoundingFrustum)obj);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a copy of internal corners array.
|
||||
/// </summary>
|
||||
/// <returns>The array of corners.</returns>
|
||||
public Vector3[] GetCorners()
|
||||
{
|
||||
return (Vector3[])this._corners.Clone();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a copy of internal corners array.
|
||||
/// </summary>
|
||||
/// <param name="corners">The array which values will be replaced to corner values of this instance. It must have size of <see cref="BoundingFrustum.CornerCount"/>.</param>
|
||||
public void GetCorners(Vector3[] corners)
|
||||
{
|
||||
if (corners == null) throw new ArgumentNullException("corners");
|
||||
if (corners.Length < CornerCount) throw new ArgumentOutOfRangeException("corners");
|
||||
|
||||
this._corners.CopyTo(corners, 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the hash code of this <see cref="BoundingFrustum"/>.
|
||||
/// </summary>
|
||||
/// <returns>Hash code of this <see cref="BoundingFrustum"/>.</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return this._matrix.GetHashCode();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether or not a specified <see cref="BoundingBox"/> intersects with this <see cref="BoundingFrustum"/>.
|
||||
/// </summary>
|
||||
/// <param name="box">A <see cref="BoundingBox"/> for intersection test.</param>
|
||||
/// <returns><c>true</c> if specified <see cref="BoundingBox"/> intersects with this <see cref="BoundingFrustum"/>; <c>false</c> otherwise.</returns>
|
||||
public bool Intersects(BoundingBox box)
|
||||
{
|
||||
var result = false;
|
||||
this.Intersects(ref box, out result);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether or not a specified <see cref="BoundingBox"/> intersects with this <see cref="BoundingFrustum"/>.
|
||||
/// </summary>
|
||||
/// <param name="box">A <see cref="BoundingBox"/> for intersection test.</param>
|
||||
/// <param name="result"><c>true</c> if specified <see cref="BoundingBox"/> intersects with this <see cref="BoundingFrustum"/>; <c>false</c> otherwise as an output parameter.</param>
|
||||
public void Intersects(ref BoundingBox box, out bool result)
|
||||
{
|
||||
var containment = default(ContainmentType);
|
||||
this.Contains(ref box, out containment);
|
||||
result = containment != ContainmentType.Disjoint;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether or not a specified <see cref="BoundingFrustum"/> intersects with this <see cref="BoundingFrustum"/>.
|
||||
/// </summary>
|
||||
/// <param name="frustum">An other <see cref="BoundingFrustum"/> for intersection test.</param>
|
||||
/// <returns><c>true</c> if other <see cref="BoundingFrustum"/> intersects with this <see cref="BoundingFrustum"/>; <c>false</c> otherwise.</returns>
|
||||
public bool Intersects(BoundingFrustum frustum)
|
||||
{
|
||||
return Contains(frustum) != ContainmentType.Disjoint;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether or not a specified <see cref="BoundingSphere"/> intersects with this <see cref="BoundingFrustum"/>.
|
||||
/// </summary>
|
||||
/// <param name="sphere">A <see cref="BoundingSphere"/> for intersection test.</param>
|
||||
/// <returns><c>true</c> if specified <see cref="BoundingSphere"/> intersects with this <see cref="BoundingFrustum"/>; <c>false</c> otherwise.</returns>
|
||||
public bool Intersects(BoundingSphere sphere)
|
||||
{
|
||||
var result = default(bool);
|
||||
this.Intersects(ref sphere, out result);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether or not a specified <see cref="BoundingSphere"/> intersects with this <see cref="BoundingFrustum"/>.
|
||||
/// </summary>
|
||||
/// <param name="sphere">A <see cref="BoundingSphere"/> for intersection test.</param>
|
||||
/// <param name="result"><c>true</c> if specified <see cref="BoundingSphere"/> intersects with this <see cref="BoundingFrustum"/>; <c>false</c> otherwise as an output parameter.</param>
|
||||
public void Intersects(ref BoundingSphere sphere, out bool result)
|
||||
{
|
||||
var containment = default(ContainmentType);
|
||||
this.Contains(ref sphere, out containment);
|
||||
result = containment != ContainmentType.Disjoint;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets type of intersection between specified <see cref="Plane"/> and this <see cref="BoundingFrustum"/>.
|
||||
/// </summary>
|
||||
/// <param name="plane">A <see cref="Plane"/> for intersection test.</param>
|
||||
/// <returns>A plane intersection type.</returns>
|
||||
public PlaneIntersectionType Intersects(Plane plane)
|
||||
{
|
||||
PlaneIntersectionType result;
|
||||
Intersects(ref plane, out result);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets type of intersection between specified <see cref="Plane"/> and this <see cref="BoundingFrustum"/>.
|
||||
/// </summary>
|
||||
/// <param name="plane">A <see cref="Plane"/> for intersection test.</param>
|
||||
/// <param name="result">A plane intersection type as an output parameter.</param>
|
||||
public void Intersects(ref Plane plane, out PlaneIntersectionType result)
|
||||
{
|
||||
result = plane.Intersects(ref _corners[0]);
|
||||
for (int i = 1; i < _corners.Length; i++)
|
||||
if (plane.Intersects(ref _corners[i]) != result)
|
||||
result = PlaneIntersectionType.Intersecting;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the distance of intersection of <see cref="Ray"/> and this <see cref="BoundingFrustum"/> or null if no intersection happens.
|
||||
/// </summary>
|
||||
/// <param name="ray">A <see cref="Ray"/> for intersection test.</param>
|
||||
/// <returns>Distance at which ray intersects with this <see cref="BoundingFrustum"/> or null if no intersection happens.</returns>
|
||||
public float? Intersects(Ray ray)
|
||||
{
|
||||
float? result;
|
||||
Intersects(ref ray, out result);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the distance of intersection of <see cref="Ray"/> and this <see cref="BoundingFrustum"/> or null if no intersection happens.
|
||||
/// </summary>
|
||||
/// <param name="ray">A <see cref="Ray"/> for intersection test.</param>
|
||||
/// <param name="result">Distance at which ray intersects with this <see cref="BoundingFrustum"/> or null if no intersection happens as an output parameter.</param>
|
||||
public void Intersects(ref Ray ray, out float? result)
|
||||
{
|
||||
ContainmentType ctype;
|
||||
this.Contains(ref ray.Position, out ctype);
|
||||
|
||||
switch (ctype)
|
||||
{
|
||||
case ContainmentType.Disjoint:
|
||||
result = null;
|
||||
return;
|
||||
case ContainmentType.Contains:
|
||||
result = 0.0f;
|
||||
return;
|
||||
case ContainmentType.Intersects:
|
||||
throw new NotImplementedException();
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a <see cref="String"/> representation of this <see cref="BoundingFrustum"/> in the format:
|
||||
/// {Near:[nearPlane] Far:[farPlane] Left:[leftPlane] Right:[rightPlane] Top:[topPlane] Bottom:[bottomPlane]}
|
||||
/// </summary>
|
||||
/// <returns><see cref="String"/> representation of this <see cref="BoundingFrustum"/>.</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return "{Near: " + this._planes[0] +
|
||||
" Far:" + this._planes[1] +
|
||||
" Left:" + this._planes[2] +
|
||||
" Right:" + this._planes[3] +
|
||||
" Top:" + this._planes[4] +
|
||||
" Bottom:" + this._planes[5] +
|
||||
"}";
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private void CreateCorners()
|
||||
{
|
||||
IntersectionPoint(ref this._planes[0], ref this._planes[2], ref this._planes[4], out this._corners[0]);
|
||||
IntersectionPoint(ref this._planes[0], ref this._planes[3], ref this._planes[4], out this._corners[1]);
|
||||
IntersectionPoint(ref this._planes[0], ref this._planes[3], ref this._planes[5], out this._corners[2]);
|
||||
IntersectionPoint(ref this._planes[0], ref this._planes[2], ref this._planes[5], out this._corners[3]);
|
||||
IntersectionPoint(ref this._planes[1], ref this._planes[2], ref this._planes[4], out this._corners[4]);
|
||||
IntersectionPoint(ref this._planes[1], ref this._planes[3], ref this._planes[4], out this._corners[5]);
|
||||
IntersectionPoint(ref this._planes[1], ref this._planes[3], ref this._planes[5], out this._corners[6]);
|
||||
IntersectionPoint(ref this._planes[1], ref this._planes[2], ref this._planes[5], out this._corners[7]);
|
||||
}
|
||||
|
||||
private void CreatePlanes()
|
||||
{
|
||||
this._planes[0] = new Plane(-this._matrix.M13, -this._matrix.M23, -this._matrix.M33, -this._matrix.M43);
|
||||
this._planes[1] = new Plane(this._matrix.M13 - this._matrix.M14, this._matrix.M23 - this._matrix.M24, this._matrix.M33 - this._matrix.M34, this._matrix.M43 - this._matrix.M44);
|
||||
this._planes[2] = new Plane(-this._matrix.M14 - this._matrix.M11, -this._matrix.M24 - this._matrix.M21, -this._matrix.M34 - this._matrix.M31, -this._matrix.M44 - this._matrix.M41);
|
||||
this._planes[3] = new Plane(this._matrix.M11 - this._matrix.M14, this._matrix.M21 - this._matrix.M24, this._matrix.M31 - this._matrix.M34, this._matrix.M41 - this._matrix.M44);
|
||||
this._planes[4] = new Plane(this._matrix.M12 - this._matrix.M14, this._matrix.M22 - this._matrix.M24, this._matrix.M32 - this._matrix.M34, this._matrix.M42 - this._matrix.M44);
|
||||
this._planes[5] = new Plane(-this._matrix.M14 - this._matrix.M12, -this._matrix.M24 - this._matrix.M22, -this._matrix.M34 - this._matrix.M32, -this._matrix.M44 - this._matrix.M42);
|
||||
|
||||
this.NormalizePlane(ref this._planes[0]);
|
||||
this.NormalizePlane(ref this._planes[1]);
|
||||
this.NormalizePlane(ref this._planes[2]);
|
||||
this.NormalizePlane(ref this._planes[3]);
|
||||
this.NormalizePlane(ref this._planes[4]);
|
||||
this.NormalizePlane(ref this._planes[5]);
|
||||
}
|
||||
|
||||
private static void IntersectionPoint(ref Plane a, ref Plane b, ref Plane c, out Vector3 result)
|
||||
{
|
||||
// Formula used
|
||||
// d1 ( N2 * N3 ) + d2 ( N3 * N1 ) + d3 ( N1 * N2 )
|
||||
//P = -------------------------------------------------------------------------
|
||||
// N1 . ( N2 * N3 )
|
||||
//
|
||||
// Note: N refers to the normal, d refers to the displacement. '.' means dot product. '*' means cross product
|
||||
|
||||
Vector3 v1, v2, v3;
|
||||
Vector3 cross;
|
||||
|
||||
Vector3.Cross(ref b.Normal, ref c.Normal, out cross);
|
||||
|
||||
float f;
|
||||
Vector3.Dot(ref a.Normal, ref cross, out f);
|
||||
f *= -1.0f;
|
||||
|
||||
Vector3.Cross(ref b.Normal, ref c.Normal, out cross);
|
||||
Vector3.Multiply(ref cross, a.D, out v1);
|
||||
//v1 = (a.D * (Vector3.Cross(b.Normal, c.Normal)));
|
||||
|
||||
|
||||
Vector3.Cross(ref c.Normal, ref a.Normal, out cross);
|
||||
Vector3.Multiply(ref cross, b.D, out v2);
|
||||
//v2 = (b.D * (Vector3.Cross(c.Normal, a.Normal)));
|
||||
|
||||
|
||||
Vector3.Cross(ref a.Normal, ref b.Normal, out cross);
|
||||
Vector3.Multiply(ref cross, c.D, out v3);
|
||||
//v3 = (c.D * (Vector3.Cross(a.Normal, b.Normal)));
|
||||
|
||||
result.X = (v1.X + v2.X + v3.X) / f;
|
||||
result.Y = (v1.Y + v2.Y + v3.Y) / f;
|
||||
result.Z = (v1.Z + v2.Z + v3.Z) / f;
|
||||
}
|
||||
|
||||
private void NormalizePlane(ref Plane p)
|
||||
{
|
||||
float factor = 1f / p.Normal.Length();
|
||||
p.Normal.X *= factor;
|
||||
p.Normal.Y *= factor;
|
||||
p.Normal.Z *= factor;
|
||||
p.D *= factor;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,640 +0,0 @@
|
||||
// MIT License - Copyright (C) The Mono.Xna Team
|
||||
// This file is subject to the terms and conditions defined in
|
||||
// file 'LICENSE.txt', which is part of this source code package.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Microsoft.Xna.Framework
|
||||
{
|
||||
/// <summary>
|
||||
/// Describes a sphere in 3D-space for bounding operations.
|
||||
/// </summary>
|
||||
[DataContract]
|
||||
[DebuggerDisplay("{DebugDisplayString,nq}")]
|
||||
public struct BoundingSphere : IEquatable<BoundingSphere>
|
||||
{
|
||||
#region Public Fields
|
||||
|
||||
/// <summary>
|
||||
/// The sphere center.
|
||||
/// </summary>
|
||||
[DataMember]
|
||||
public Vector3 Center;
|
||||
|
||||
/// <summary>
|
||||
/// The sphere radius.
|
||||
/// </summary>
|
||||
[DataMember]
|
||||
public float Radius;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Internal Properties
|
||||
|
||||
internal string DebugDisplayString
|
||||
{
|
||||
get
|
||||
{
|
||||
return string.Concat(
|
||||
"Center( ", this.Center.DebugDisplayString, " ) \r\n",
|
||||
"Radius( ", this.Radius.ToString(), " )"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a bounding sphere with the specified center and radius.
|
||||
/// </summary>
|
||||
/// <param name="center">The sphere center.</param>
|
||||
/// <param name="radius">The sphere radius.</param>
|
||||
public BoundingSphere(Vector3 center, float radius)
|
||||
{
|
||||
this.Center = center;
|
||||
this.Radius = radius;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
|
||||
#region Contains
|
||||
|
||||
/// <summary>
|
||||
/// Test if a bounding box is fully inside, outside, or just intersecting the sphere.
|
||||
/// </summary>
|
||||
/// <param name="box">The box for testing.</param>
|
||||
/// <returns>The containment type.</returns>
|
||||
public ContainmentType Contains(BoundingBox box)
|
||||
{
|
||||
//check if all corner is in sphere
|
||||
bool inside = true;
|
||||
foreach (Vector3 corner in box.GetCorners())
|
||||
{
|
||||
if (this.Contains(corner) == ContainmentType.Disjoint)
|
||||
{
|
||||
inside = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (inside)
|
||||
return ContainmentType.Contains;
|
||||
|
||||
//check if the distance from sphere center to cube face < radius
|
||||
double dmin = 0;
|
||||
|
||||
if (Center.X < box.Min.X)
|
||||
dmin += (Center.X - box.Min.X) * (Center.X - box.Min.X);
|
||||
|
||||
else if (Center.X > box.Max.X)
|
||||
dmin += (Center.X - box.Max.X) * (Center.X - box.Max.X);
|
||||
|
||||
if (Center.Y < box.Min.Y)
|
||||
dmin += (Center.Y - box.Min.Y) * (Center.Y - box.Min.Y);
|
||||
|
||||
else if (Center.Y > box.Max.Y)
|
||||
dmin += (Center.Y - box.Max.Y) * (Center.Y - box.Max.Y);
|
||||
|
||||
if (Center.Z < box.Min.Z)
|
||||
dmin += (Center.Z - box.Min.Z) * (Center.Z - box.Min.Z);
|
||||
|
||||
else if (Center.Z > box.Max.Z)
|
||||
dmin += (Center.Z - box.Max.Z) * (Center.Z - box.Max.Z);
|
||||
|
||||
if (dmin <= Radius * Radius)
|
||||
return ContainmentType.Intersects;
|
||||
|
||||
//else disjoint
|
||||
return ContainmentType.Disjoint;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test if a bounding box is fully inside, outside, or just intersecting the sphere.
|
||||
/// </summary>
|
||||
/// <param name="box">The box for testing.</param>
|
||||
/// <param name="result">The containment type as an output parameter.</param>
|
||||
public void Contains(ref BoundingBox box, out ContainmentType result)
|
||||
{
|
||||
result = this.Contains(box);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test if a frustum is fully inside, outside, or just intersecting the sphere.
|
||||
/// </summary>
|
||||
/// <param name="frustum">The frustum for testing.</param>
|
||||
/// <returns>The containment type.</returns>
|
||||
public ContainmentType Contains(BoundingFrustum frustum)
|
||||
{
|
||||
//check if all corner is in sphere
|
||||
bool inside = true;
|
||||
|
||||
Vector3[] corners = frustum.GetCorners();
|
||||
foreach (Vector3 corner in corners)
|
||||
{
|
||||
if (this.Contains(corner) == ContainmentType.Disjoint)
|
||||
{
|
||||
inside = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (inside)
|
||||
return ContainmentType.Contains;
|
||||
|
||||
//check if the distance from sphere center to frustrum face < radius
|
||||
double dmin = 0;
|
||||
//TODO : calcul dmin
|
||||
|
||||
if (dmin <= Radius * Radius)
|
||||
return ContainmentType.Intersects;
|
||||
|
||||
//else disjoint
|
||||
return ContainmentType.Disjoint;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test if a frustum is fully inside, outside, or just intersecting the sphere.
|
||||
/// </summary>
|
||||
/// <param name="frustum">The frustum for testing.</param>
|
||||
/// <param name="result">The containment type as an output parameter.</param>
|
||||
public void Contains(ref BoundingFrustum frustum,out ContainmentType result)
|
||||
{
|
||||
result = this.Contains(frustum);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test if a sphere is fully inside, outside, or just intersecting the sphere.
|
||||
/// </summary>
|
||||
/// <param name="sphere">The other sphere for testing.</param>
|
||||
/// <returns>The containment type.</returns>
|
||||
public ContainmentType Contains(BoundingSphere sphere)
|
||||
{
|
||||
ContainmentType result;
|
||||
Contains(ref sphere, out result);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test if a sphere is fully inside, outside, or just intersecting the sphere.
|
||||
/// </summary>
|
||||
/// <param name="sphere">The other sphere for testing.</param>
|
||||
/// <param name="result">The containment type as an output parameter.</param>
|
||||
public void Contains(ref BoundingSphere sphere, out ContainmentType result)
|
||||
{
|
||||
float sqDistance;
|
||||
Vector3.DistanceSquared(ref sphere.Center, ref Center, out sqDistance);
|
||||
|
||||
if (sqDistance > (sphere.Radius + Radius) * (sphere.Radius + Radius))
|
||||
result = ContainmentType.Disjoint;
|
||||
|
||||
else if (sqDistance <= (Radius - sphere.Radius) * (Radius - sphere.Radius))
|
||||
result = ContainmentType.Contains;
|
||||
|
||||
else
|
||||
result = ContainmentType.Intersects;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test if a point is fully inside, outside, or just intersecting the sphere.
|
||||
/// </summary>
|
||||
/// <param name="point">The vector in 3D-space for testing.</param>
|
||||
/// <returns>The containment type.</returns>
|
||||
public ContainmentType Contains(Vector3 point)
|
||||
{
|
||||
ContainmentType result;
|
||||
Contains(ref point, out result);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test if a point is fully inside, outside, or just intersecting the sphere.
|
||||
/// </summary>
|
||||
/// <param name="point">The vector in 3D-space for testing.</param>
|
||||
/// <param name="result">The containment type as an output parameter.</param>
|
||||
public void Contains(ref Vector3 point, out ContainmentType result)
|
||||
{
|
||||
float sqRadius = Radius * Radius;
|
||||
float sqDistance;
|
||||
Vector3.DistanceSquared(ref point, ref Center, out sqDistance);
|
||||
|
||||
if (sqDistance > sqRadius)
|
||||
result = ContainmentType.Disjoint;
|
||||
|
||||
else if (sqDistance < sqRadius)
|
||||
result = ContainmentType.Contains;
|
||||
|
||||
else
|
||||
result = ContainmentType.Intersects;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CreateFromBoundingBox
|
||||
|
||||
/// <summary>
|
||||
/// Creates the smallest <see cref="BoundingSphere"/> that can contain a specified <see cref="BoundingBox"/>.
|
||||
/// </summary>
|
||||
/// <param name="box">The box to create the sphere from.</param>
|
||||
/// <returns>The new <see cref="BoundingSphere"/>.</returns>
|
||||
public static BoundingSphere CreateFromBoundingBox(BoundingBox box)
|
||||
{
|
||||
BoundingSphere result;
|
||||
CreateFromBoundingBox(ref box, out result);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates the smallest <see cref="BoundingSphere"/> that can contain a specified <see cref="BoundingBox"/>.
|
||||
/// </summary>
|
||||
/// <param name="box">The box to create the sphere from.</param>
|
||||
/// <param name="result">The new <see cref="BoundingSphere"/> as an output parameter.</param>
|
||||
public static void CreateFromBoundingBox(ref BoundingBox box, out BoundingSphere result)
|
||||
{
|
||||
// Find the center of the box.
|
||||
Vector3 center = new Vector3((box.Min.X + box.Max.X) / 2.0f,
|
||||
(box.Min.Y + box.Max.Y) / 2.0f,
|
||||
(box.Min.Z + box.Max.Z) / 2.0f);
|
||||
|
||||
// Find the distance between the center and one of the corners of the box.
|
||||
float radius = Vector3.Distance(center, box.Max);
|
||||
|
||||
result = new BoundingSphere(center, radius);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Creates the smallest <see cref="BoundingSphere"/> that can contain a specified <see cref="BoundingFrustum"/>.
|
||||
/// </summary>
|
||||
/// <param name="frustum">The frustum to create the sphere from.</param>
|
||||
/// <returns>The new <see cref="BoundingSphere"/>.</returns>
|
||||
public static BoundingSphere CreateFromFrustum(BoundingFrustum frustum)
|
||||
{
|
||||
return CreateFromPoints(frustum.GetCorners());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates the smallest <see cref="BoundingSphere"/> that can contain a specified list of points in 3D-space.
|
||||
/// </summary>
|
||||
/// <param name="points">List of point to create the sphere from.</param>
|
||||
/// <returns>The new <see cref="BoundingSphere"/>.</returns>
|
||||
public static BoundingSphere CreateFromPoints(IEnumerable<Vector3> points)
|
||||
{
|
||||
if (points == null )
|
||||
throw new ArgumentNullException("points");
|
||||
|
||||
// From "Real-Time Collision Detection" (Page 89)
|
||||
|
||||
var minx = new Vector3(float.MaxValue, float.MaxValue, float.MaxValue);
|
||||
var maxx = -minx;
|
||||
var miny = minx;
|
||||
var maxy = -minx;
|
||||
var minz = minx;
|
||||
var maxz = -minx;
|
||||
|
||||
// Find the most extreme points along the principle axis.
|
||||
var numPoints = 0;
|
||||
foreach (var pt in points)
|
||||
{
|
||||
++numPoints;
|
||||
|
||||
if (pt.X < minx.X)
|
||||
minx = pt;
|
||||
if (pt.X > maxx.X)
|
||||
maxx = pt;
|
||||
if (pt.Y < miny.Y)
|
||||
miny = pt;
|
||||
if (pt.Y > maxy.Y)
|
||||
maxy = pt;
|
||||
if (pt.Z < minz.Z)
|
||||
minz = pt;
|
||||
if (pt.Z > maxz.Z)
|
||||
maxz = pt;
|
||||
}
|
||||
|
||||
if (numPoints == 0)
|
||||
throw new ArgumentException("You should have at least one point in points.");
|
||||
|
||||
var sqDistX = Vector3.DistanceSquared(maxx, minx);
|
||||
var sqDistY = Vector3.DistanceSquared(maxy, miny);
|
||||
var sqDistZ = Vector3.DistanceSquared(maxz, minz);
|
||||
|
||||
// Pick the pair of most distant points.
|
||||
var min = minx;
|
||||
var max = maxx;
|
||||
if (sqDistY > sqDistX && sqDistY > sqDistZ)
|
||||
{
|
||||
max = maxy;
|
||||
min = miny;
|
||||
}
|
||||
if (sqDistZ > sqDistX && sqDistZ > sqDistY)
|
||||
{
|
||||
max = maxz;
|
||||
min = minz;
|
||||
}
|
||||
|
||||
var center = (min + max) * 0.5f;
|
||||
var radius = Vector3.Distance(max, center);
|
||||
|
||||
// Test every point and expand the sphere.
|
||||
// The current bounding sphere is just a good approximation and may not enclose all points.
|
||||
// From: Mathematics for 3D Game Programming and Computer Graphics, Eric Lengyel, Third Edition.
|
||||
// Page 218
|
||||
float sqRadius = radius * radius;
|
||||
foreach (var pt in points)
|
||||
{
|
||||
Vector3 diff = (pt-center);
|
||||
float sqDist = diff.LengthSquared();
|
||||
if (sqDist > sqRadius)
|
||||
{
|
||||
float distance = (float)Math.Sqrt(sqDist); // equal to diff.Length();
|
||||
Vector3 direction = diff / distance;
|
||||
Vector3 G = center - radius * direction;
|
||||
center = (G + pt) / 2;
|
||||
radius = Vector3.Distance(pt, center);
|
||||
sqRadius = radius * radius;
|
||||
}
|
||||
}
|
||||
|
||||
return new BoundingSphere(center, radius);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates the smallest <see cref="BoundingSphere"/> that can contain two spheres.
|
||||
/// </summary>
|
||||
/// <param name="original">First sphere.</param>
|
||||
/// <param name="additional">Second sphere.</param>
|
||||
/// <returns>The new <see cref="BoundingSphere"/>.</returns>
|
||||
public static BoundingSphere CreateMerged(BoundingSphere original, BoundingSphere additional)
|
||||
{
|
||||
BoundingSphere result;
|
||||
CreateMerged(ref original, ref additional, out result);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates the smallest <see cref="BoundingSphere"/> that can contain two spheres.
|
||||
/// </summary>
|
||||
/// <param name="original">First sphere.</param>
|
||||
/// <param name="additional">Second sphere.</param>
|
||||
/// <param name="result">The new <see cref="BoundingSphere"/> as an output parameter.</param>
|
||||
public static void CreateMerged(ref BoundingSphere original, ref BoundingSphere additional, out BoundingSphere result)
|
||||
{
|
||||
Vector3 ocenterToaCenter = Vector3.Subtract(additional.Center, original.Center);
|
||||
float distance = ocenterToaCenter.Length();
|
||||
if (distance <= original.Radius + additional.Radius)//intersect
|
||||
{
|
||||
if (distance <= original.Radius - additional.Radius)//original contain additional
|
||||
{
|
||||
result = original;
|
||||
return;
|
||||
}
|
||||
if (distance <= additional.Radius - original.Radius)//additional contain original
|
||||
{
|
||||
result = additional;
|
||||
return;
|
||||
}
|
||||
}
|
||||
//else find center of new sphere and radius
|
||||
float leftRadius = Math.Max(original.Radius - distance, additional.Radius);
|
||||
float Rightradius = Math.Max(original.Radius + distance, additional.Radius);
|
||||
ocenterToaCenter = ocenterToaCenter + (((leftRadius - Rightradius) / (2 * ocenterToaCenter.Length())) * ocenterToaCenter);//oCenterToResultCenter
|
||||
|
||||
result = new BoundingSphere();
|
||||
result.Center = original.Center + ocenterToaCenter;
|
||||
result.Radius = (leftRadius + Rightradius) / 2;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compares whether current instance is equal to specified <see cref="BoundingSphere"/>.
|
||||
/// </summary>
|
||||
/// <param name="other">The <see cref="BoundingSphere"/> to compare.</param>
|
||||
/// <returns><c>true</c> if the instances are equal; <c>false</c> otherwise.</returns>
|
||||
public bool Equals(BoundingSphere other)
|
||||
{
|
||||
return this.Center == other.Center && this.Radius == other.Radius;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compares whether current instance is equal to specified <see cref="Object"/>.
|
||||
/// </summary>
|
||||
/// <param name="obj">The <see cref="Object"/> to compare.</param>
|
||||
/// <returns><c>true</c> if the instances are equal; <c>false</c> otherwise.</returns>
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj is BoundingSphere)
|
||||
return this.Equals((BoundingSphere)obj);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the hash code of this <see cref="BoundingSphere"/>.
|
||||
/// </summary>
|
||||
/// <returns>Hash code of this <see cref="BoundingSphere"/>.</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return this.Center.GetHashCode() + this.Radius.GetHashCode();
|
||||
}
|
||||
|
||||
#region Intersects
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether or not a specified <see cref="BoundingBox"/> intersects with this sphere.
|
||||
/// </summary>
|
||||
/// <param name="box">The box for testing.</param>
|
||||
/// <returns><c>true</c> if <see cref="BoundingBox"/> intersects with this sphere; <c>false</c> otherwise.</returns>
|
||||
public bool Intersects(BoundingBox box)
|
||||
{
|
||||
return box.Intersects(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether or not a specified <see cref="BoundingBox"/> intersects with this sphere.
|
||||
/// </summary>
|
||||
/// <param name="box">The box for testing.</param>
|
||||
/// <param name="result"><c>true</c> if <see cref="BoundingBox"/> intersects with this sphere; <c>false</c> otherwise. As an output parameter.</param>
|
||||
public void Intersects(ref BoundingBox box, out bool result)
|
||||
{
|
||||
box.Intersects(ref this, out result);
|
||||
}
|
||||
|
||||
/*
|
||||
TODO : Make the public bool Intersects(BoundingFrustum frustum) overload
|
||||
|
||||
public bool Intersects(BoundingFrustum frustum)
|
||||
{
|
||||
if (frustum == null)
|
||||
throw new NullReferenceException();
|
||||
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether or not the other <see cref="BoundingSphere"/> intersects with this sphere.
|
||||
/// </summary>
|
||||
/// <param name="sphere">The other sphere for testing.</param>
|
||||
/// <returns><c>true</c> if other <see cref="BoundingSphere"/> intersects with this sphere; <c>false</c> otherwise.</returns>
|
||||
public bool Intersects(BoundingSphere sphere)
|
||||
{
|
||||
bool result;
|
||||
Intersects(ref sphere, out result);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether or not the other <see cref="BoundingSphere"/> intersects with this sphere.
|
||||
/// </summary>
|
||||
/// <param name="sphere">The other sphere for testing.</param>
|
||||
/// <param name="result"><c>true</c> if other <see cref="BoundingSphere"/> intersects with this sphere; <c>false</c> otherwise. As an output parameter.</param>
|
||||
public void Intersects(ref BoundingSphere sphere, out bool result)
|
||||
{
|
||||
float sqDistance;
|
||||
Vector3.DistanceSquared(ref sphere.Center, ref Center, out sqDistance);
|
||||
|
||||
if (sqDistance > (sphere.Radius + Radius) * (sphere.Radius + Radius))
|
||||
result = false;
|
||||
else
|
||||
result = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether or not a specified <see cref="Plane"/> intersects with this sphere.
|
||||
/// </summary>
|
||||
/// <param name="plane">The plane for testing.</param>
|
||||
/// <returns>Type of intersection.</returns>
|
||||
public PlaneIntersectionType Intersects(Plane plane)
|
||||
{
|
||||
var result = default(PlaneIntersectionType);
|
||||
// TODO: we might want to inline this for performance reasons
|
||||
this.Intersects(ref plane, out result);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether or not a specified <see cref="Plane"/> intersects with this sphere.
|
||||
/// </summary>
|
||||
/// <param name="plane">The plane for testing.</param>
|
||||
/// <param name="result">Type of intersection as an output parameter.</param>
|
||||
public void Intersects(ref Plane plane, out PlaneIntersectionType result)
|
||||
{
|
||||
var distance = default(float);
|
||||
// TODO: we might want to inline this for performance reasons
|
||||
Vector3.Dot(ref plane.Normal, ref this.Center, out distance);
|
||||
distance += plane.D;
|
||||
if (distance > this.Radius)
|
||||
result = PlaneIntersectionType.Front;
|
||||
else if (distance < -this.Radius)
|
||||
result = PlaneIntersectionType.Back;
|
||||
else
|
||||
result = PlaneIntersectionType.Intersecting;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether or not a specified <see cref="Ray"/> intersects with this sphere.
|
||||
/// </summary>
|
||||
/// <param name="ray">The ray for testing.</param>
|
||||
/// <returns>Distance of ray intersection or <c>null</c> if there is no intersection.</returns>
|
||||
public float? Intersects(Ray ray)
|
||||
{
|
||||
return ray.Intersects(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether or not a specified <see cref="Ray"/> intersects with this sphere.
|
||||
/// </summary>
|
||||
/// <param name="ray">The ray for testing.</param>
|
||||
/// <param name="result">Distance of ray intersection or <c>null</c> if there is no intersection as an output parameter.</param>
|
||||
public void Intersects(ref Ray ray, out float? result)
|
||||
{
|
||||
ray.Intersects(ref this, out result);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Returns a <see cref="String"/> representation of this <see cref="BoundingSphere"/> in the format:
|
||||
/// {Center:[<see cref="Center"/>] Radius:[<see cref="Radius"/>]}
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="String"/> representation of this <see cref="BoundingSphere"/>.</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return "{Center:" + this.Center + " Radius:" + this.Radius + "}";
|
||||
}
|
||||
|
||||
#region Transform
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="BoundingSphere"/> that contains a transformation of translation and scale from this sphere by the specified <see cref="Matrix"/>.
|
||||
/// </summary>
|
||||
/// <param name="matrix">The transformation <see cref="Matrix"/>.</param>
|
||||
/// <returns>Transformed <see cref="BoundingSphere"/>.</returns>
|
||||
public BoundingSphere Transform(Matrix matrix)
|
||||
{
|
||||
BoundingSphere sphere = new BoundingSphere();
|
||||
sphere.Center = Vector3.Transform(this.Center, matrix);
|
||||
sphere.Radius = this.Radius * ((float)Math.Sqrt((double)Math.Max(((matrix.M11 * matrix.M11) + (matrix.M12 * matrix.M12)) + (matrix.M13 * matrix.M13), Math.Max(((matrix.M21 * matrix.M21) + (matrix.M22 * matrix.M22)) + (matrix.M23 * matrix.M23), ((matrix.M31 * matrix.M31) + (matrix.M32 * matrix.M32)) + (matrix.M33 * matrix.M33)))));
|
||||
return sphere;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="BoundingSphere"/> that contains a transformation of translation and scale from this sphere by the specified <see cref="Matrix"/>.
|
||||
/// </summary>
|
||||
/// <param name="matrix">The transformation <see cref="Matrix"/>.</param>
|
||||
/// <param name="result">Transformed <see cref="BoundingSphere"/> as an output parameter.</param>
|
||||
public void Transform(ref Matrix matrix, out BoundingSphere result)
|
||||
{
|
||||
result.Center = Vector3.Transform(this.Center, matrix);
|
||||
result.Radius = this.Radius * ((float)Math.Sqrt((double)Math.Max(((matrix.M11 * matrix.M11) + (matrix.M12 * matrix.M12)) + (matrix.M13 * matrix.M13), Math.Max(((matrix.M21 * matrix.M21) + (matrix.M22 * matrix.M22)) + (matrix.M23 * matrix.M23), ((matrix.M31 * matrix.M31) + (matrix.M32 * matrix.M32)) + (matrix.M33 * matrix.M33)))));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Deconstruction method for <see cref="BoundingSphere"/>.
|
||||
/// </summary>
|
||||
/// <param name="center"></param>
|
||||
/// <param name="radius"></param>
|
||||
public void Deconstruct(out Vector3 center, out float radius)
|
||||
{
|
||||
center = Center;
|
||||
radius = Radius;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Operators
|
||||
|
||||
/// <summary>
|
||||
/// Compares whether two <see cref="BoundingSphere"/> instances are equal.
|
||||
/// </summary>
|
||||
/// <param name="a"><see cref="BoundingSphere"/> instance on the left of the equal sign.</param>
|
||||
/// <param name="b"><see cref="BoundingSphere"/> instance on the right of the equal sign.</param>
|
||||
/// <returns><c>true</c> if the instances are equal; <c>false</c> otherwise.</returns>
|
||||
public static bool operator == (BoundingSphere a, BoundingSphere b)
|
||||
{
|
||||
return a.Equals(b);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compares whether two <see cref="BoundingSphere"/> instances are not equal.
|
||||
/// </summary>
|
||||
/// <param name="a"><see cref="BoundingSphere"/> instance on the left of the not equal sign.</param>
|
||||
/// <param name="b"><see cref="BoundingSphere"/> instance on the right of the not equal sign.</param>
|
||||
/// <returns><c>true</c> if the instances are not equal; <c>false</c> otherwise.</returns>
|
||||
public static bool operator != (BoundingSphere a, BoundingSphere b)
|
||||
{
|
||||
return !a.Equals(b);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,25 +0,0 @@
|
||||
// MIT License - Copyright (C) The Mono.Xna Team
|
||||
// This file is subject to the terms and conditions defined in
|
||||
// file 'LICENSE.txt', which is part of this source code package.
|
||||
|
||||
namespace Microsoft.Xna.Framework
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines how the bounding volumes intersects or contain one another.
|
||||
/// </summary>
|
||||
public enum ContainmentType
|
||||
{
|
||||
/// <summary>
|
||||
/// Indicates that there is no overlap between two bounding volumes.
|
||||
/// </summary>
|
||||
Disjoint,
|
||||
/// <summary>
|
||||
/// Indicates that one bounding volume completely contains another volume.
|
||||
/// </summary>
|
||||
Contains,
|
||||
/// <summary>
|
||||
/// Indicates that bounding volumes partially overlap one another.
|
||||
/// </summary>
|
||||
Intersects
|
||||
}
|
||||
}
|
||||
+3
-2
@@ -216,8 +216,9 @@ namespace Microsoft.Xna.Framework.Content
|
||||
preparedType = preparedType.Replace(", Microsoft.Xna.Framework.Graphics", string.Format(", {0}", _assemblyName));
|
||||
preparedType = preparedType.Replace(", Microsoft.Xna.Framework.Video", string.Format(", {0}", _assemblyName));
|
||||
preparedType = preparedType.Replace(", Microsoft.Xna.Framework", string.Format(", {0}", _assemblyName));
|
||||
|
||||
return preparedType;
|
||||
preparedType = preparedType.Replace(", MonoGame.Framework", string.Format(", {0}", _assemblyName));
|
||||
|
||||
return preparedType;
|
||||
}
|
||||
|
||||
// Static map of type names to creation functions. Required as iOS requires all types at compile time
|
||||
|
||||
@@ -1,330 +0,0 @@
|
||||
#region License
|
||||
/*
|
||||
Microsoft Public License (Ms-PL)
|
||||
MonoGame - Copyright © 2009 The MonoGame Team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
This license governs use of the accompanying software. If you use the software, you accept this license. If you do not
|
||||
accept the license, do not use the software.
|
||||
|
||||
1. Definitions
|
||||
The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under
|
||||
U.S. copyright law.
|
||||
|
||||
A "contribution" is the original software, or any additions or changes to the software.
|
||||
A "contributor" is any person that distributes its contribution under this license.
|
||||
"Licensed patents" are a contributor's patent claims that read directly on its contribution.
|
||||
|
||||
2. Grant of Rights
|
||||
(A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
|
||||
each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create.
|
||||
(B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
|
||||
each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software.
|
||||
|
||||
3. Conditions and Limitations
|
||||
(A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.
|
||||
(B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software,
|
||||
your patent license from such contributor to the software ends automatically.
|
||||
(C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution
|
||||
notices that are present in the software.
|
||||
(D) If you distribute any portion of the software in source code form, you may do so only under this license by including
|
||||
a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object
|
||||
code form, you may only do so under a license that complies with this license.
|
||||
(E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees
|
||||
or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent
|
||||
permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular
|
||||
purpose and non-infringement.
|
||||
*/
|
||||
#endregion License
|
||||
|
||||
#region Using clause
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Runtime.Remoting.Messaging;
|
||||
|
||||
using Microsoft.Xna.Framework.Net;
|
||||
|
||||
|
||||
#endregion Using clause
|
||||
|
||||
namespace Microsoft.Xna.Framework.GamerServices
|
||||
{
|
||||
public static class Guide
|
||||
{
|
||||
private static bool isScreenSaverEnabled;
|
||||
private static bool isTrialMode;
|
||||
private static bool isVisible;
|
||||
private static bool simulateTrialMode;
|
||||
|
||||
delegate string ShowKeyboardInputDelegate(
|
||||
PlayerIndex player,
|
||||
string title,
|
||||
string description,
|
||||
string defaultText,
|
||||
bool usePasswordMode);
|
||||
|
||||
public static string ShowKeyboardInput(
|
||||
PlayerIndex player,
|
||||
string title,
|
||||
string description,
|
||||
string defaultText,
|
||||
bool usePasswordMode)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public static IAsyncResult BeginShowKeyboardInput (
|
||||
PlayerIndex player,
|
||||
string title,
|
||||
string description,
|
||||
string defaultText,
|
||||
AsyncCallback callback,
|
||||
Object state)
|
||||
{
|
||||
return BeginShowKeyboardInput(player, title, description, defaultText, callback, state, false );
|
||||
}
|
||||
|
||||
public static IAsyncResult BeginShowKeyboardInput (
|
||||
PlayerIndex player,
|
||||
string title,
|
||||
string description,
|
||||
string defaultText,
|
||||
AsyncCallback callback,
|
||||
Object state,
|
||||
bool usePasswordMode)
|
||||
{
|
||||
return BeginShowKeyboardInput(player, title, description, defaultText, callback, state, false );
|
||||
}
|
||||
|
||||
public static string EndShowKeyboardInput (IAsyncResult result)
|
||||
{
|
||||
ShowKeyboardInputDelegate ski = (ShowKeyboardInputDelegate)result.AsyncState;
|
||||
|
||||
return ski.EndInvoke(result);
|
||||
}
|
||||
|
||||
delegate Nullable<int> ShowMessageBoxDelegate( string title,
|
||||
string text,
|
||||
IEnumerable<string> buttons,
|
||||
int focusButton,
|
||||
MessageBoxIcon icon);
|
||||
|
||||
public static Nullable<int> ShowMessageBox( string title,
|
||||
string text,
|
||||
IEnumerable<string> buttons,
|
||||
int focusButton,
|
||||
MessageBoxIcon icon)
|
||||
{
|
||||
int? result = null;
|
||||
IsVisible = true;
|
||||
|
||||
IsVisible = false;
|
||||
return result;
|
||||
}
|
||||
|
||||
public static IAsyncResult BeginShowMessageBox(
|
||||
PlayerIndex player,
|
||||
string title,
|
||||
string text,
|
||||
IEnumerable<string> buttons,
|
||||
int focusButton,
|
||||
MessageBoxIcon icon,
|
||||
AsyncCallback callback,
|
||||
Object state
|
||||
)
|
||||
{
|
||||
if (IsVisible)
|
||||
throw new Exception("The function cannot be completed at this time: the Guide UI is already active. Wait until Guide.IsVisible is false before issuing this call.");
|
||||
|
||||
if (player != PlayerIndex.One)
|
||||
throw new ArgumentOutOfRangeException("player", "Specified argument was out of the range of valid values.");
|
||||
if (title == null)
|
||||
throw new ArgumentNullException("title", "This string cannot be null or empty, and must be less than 256 characters long.");
|
||||
if (text == null)
|
||||
throw new ArgumentNullException("text", "This string cannot be null or empty, and must be less than 256 characters long.");
|
||||
if (buttons == null)
|
||||
throw new ArgumentNullException("buttons", "Value can not be null.");
|
||||
|
||||
ShowMessageBoxDelegate smb = ShowMessageBox;
|
||||
|
||||
return smb.BeginInvoke(title, text, buttons, focusButton, icon, callback, smb);
|
||||
}
|
||||
|
||||
public static IAsyncResult BeginShowMessageBox (
|
||||
string title,
|
||||
string text,
|
||||
IEnumerable<string> buttons,
|
||||
int focusButton,
|
||||
MessageBoxIcon icon,
|
||||
AsyncCallback callback,
|
||||
Object state
|
||||
)
|
||||
{
|
||||
return BeginShowMessageBox(PlayerIndex.One, title, text, buttons, focusButton, icon, callback, state);
|
||||
}
|
||||
|
||||
public static Nullable<int> EndShowMessageBox (IAsyncResult result)
|
||||
{
|
||||
return ((ShowMessageBoxDelegate)result.AsyncState).EndInvoke(result);
|
||||
}
|
||||
|
||||
|
||||
public static void ShowMarketplace (PlayerIndex player )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public static void Show ()
|
||||
{
|
||||
ShowSignIn(1, false);
|
||||
}
|
||||
|
||||
public static void ShowSignIn (int paneCount, bool onlineOnly)
|
||||
{
|
||||
if ( paneCount != 1 && paneCount != 2 && paneCount != 4)
|
||||
{
|
||||
new ArgumentException("paneCount Can only be 1, 2 or 4 on Windows");
|
||||
return;
|
||||
}
|
||||
|
||||
Microsoft.Xna.Framework.GamerServices.MonoGameGamerServicesHelper.ShowSigninSheet();
|
||||
if (GamerServicesComponent.LocalNetworkGamer == null)
|
||||
{
|
||||
GamerServicesComponent.LocalNetworkGamer = new LocalNetworkGamer();
|
||||
}
|
||||
else
|
||||
{
|
||||
GamerServicesComponent.LocalNetworkGamer.SignedInGamer.BeginAuthentication(null, null);
|
||||
}
|
||||
}
|
||||
|
||||
public static void ShowLeaderboard()
|
||||
{
|
||||
//if ( ( Gamer.SignedInGamers.Count > 0 ) && ( Gamer.SignedInGamers[0].IsSignedInToLive ) )
|
||||
//{
|
||||
// // Lazy load it
|
||||
// if ( leaderboardController == null )
|
||||
// {
|
||||
// leaderboardController = new GKLeaderboardViewController();
|
||||
// }
|
||||
|
||||
// if (leaderboardController != null)
|
||||
// {
|
||||
// leaderboardController.DidFinish += delegate(object sender, EventArgs e)
|
||||
// {
|
||||
// leaderboardController.DismissModalViewControllerAnimated(true);
|
||||
// isVisible = false;
|
||||
// };
|
||||
|
||||
// if (Window !=null)
|
||||
// {
|
||||
// if(viewController == null)
|
||||
// {
|
||||
// viewController = new UIViewController();
|
||||
// Window.Add(viewController.View);
|
||||
// viewController.View.Hidden = true;
|
||||
// }
|
||||
|
||||
// viewController.PresentModalViewController(leaderboardController, true);
|
||||
// isVisible = true;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
public static void ShowAchievements()
|
||||
{
|
||||
//if ( ( Gamer.SignedInGamers.Count > 0 ) && ( Gamer.SignedInGamers[0].IsSignedInToLive ) )
|
||||
//{
|
||||
// // Lazy load it
|
||||
// if ( achievementController == null )
|
||||
// {
|
||||
// achievementController = new GKAchievementViewController();
|
||||
// }
|
||||
|
||||
// if (achievementController != null)
|
||||
// {
|
||||
// achievementController.DidFinish += delegate(object sender, EventArgs e)
|
||||
// {
|
||||
// leaderboardController.DismissModalViewControllerAnimated(true);
|
||||
// isVisible = false;
|
||||
// };
|
||||
|
||||
// if (Window !=null)
|
||||
// {
|
||||
// if(viewController == null)
|
||||
// {
|
||||
// viewController = new UIViewController();
|
||||
// Window.Add(viewController.View);
|
||||
// viewController.View.Hidden = true;
|
||||
// }
|
||||
|
||||
// viewController.PresentModalViewController(achievementController, true);
|
||||
// isVisible = true;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
#region Properties
|
||||
public static bool IsScreenSaverEnabled
|
||||
{
|
||||
get
|
||||
{
|
||||
return isScreenSaverEnabled;
|
||||
}
|
||||
set
|
||||
{
|
||||
isScreenSaverEnabled = value;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsTrialMode
|
||||
{
|
||||
get
|
||||
{
|
||||
return simulateTrialMode || isTrialMode;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsVisible
|
||||
{
|
||||
get
|
||||
{
|
||||
return isVisible;
|
||||
}
|
||||
set
|
||||
{
|
||||
isVisible = value;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool SimulateTrialMode
|
||||
{
|
||||
get
|
||||
{
|
||||
return simulateTrialMode;
|
||||
}
|
||||
set
|
||||
{
|
||||
simulateTrialMode = value;
|
||||
}
|
||||
}
|
||||
|
||||
public static GameWindow Window
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
#endregion
|
||||
|
||||
internal static void Initialise(Game game)
|
||||
{
|
||||
MonoGameGamerServicesHelper.Initialise(game);
|
||||
}
|
||||
}
|
||||
}
|
||||
-151
@@ -1,151 +0,0 @@
|
||||
using System;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
|
||||
namespace Microsoft.Xna.Framework.GamerServices
|
||||
{
|
||||
internal class MonoGameGamerServicesHelper
|
||||
{
|
||||
private static MonoLiveGuide guide = null;
|
||||
|
||||
|
||||
|
||||
public static void ShowSigninSheet()
|
||||
{
|
||||
guide.Enabled = true;
|
||||
guide.Visible = true;
|
||||
Guide.IsVisible = true;
|
||||
}
|
||||
|
||||
internal static void Initialise(Game game)
|
||||
{
|
||||
if (guide == null)
|
||||
{
|
||||
guide = new MonoLiveGuide(game);
|
||||
game.Components.Add(guide);
|
||||
}
|
||||
}}
|
||||
|
||||
internal class MonoLiveGuide : DrawableGameComponent
|
||||
{
|
||||
SpriteBatch spriteBatch;
|
||||
Texture2D signInProgress;
|
||||
Color alphaColor = new Color(128, 128, 128, 0);
|
||||
byte startalpha = 0;
|
||||
|
||||
public MonoLiveGuide(Game game)
|
||||
: base(game)
|
||||
{
|
||||
this.Enabled = false;
|
||||
this.Visible = false;
|
||||
//Guide.IsVisible = false;
|
||||
this.DrawOrder = Int32.MaxValue;
|
||||
}
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
}
|
||||
|
||||
Texture2D Circle(GraphicsDevice graphics, int radius)
|
||||
{
|
||||
int aDiameter = radius * 2;
|
||||
Vector2 aCenter = new Vector2(radius, radius);
|
||||
|
||||
Texture2D aCircle = new Texture2D(graphics, aDiameter, aDiameter, false, SurfaceFormat.Color);
|
||||
Color[] aColors = new Color[aDiameter * aDiameter];
|
||||
|
||||
for (int i = 0; i < aColors.Length; i++)
|
||||
{
|
||||
int x = (i + 1) % aDiameter;
|
||||
int y = (i + 1) / aDiameter;
|
||||
|
||||
Vector2 aDistance = new Vector2(Math.Abs(aCenter.X - x), Math.Abs(aCenter.Y - y));
|
||||
|
||||
|
||||
if (Math.Sqrt((aDistance.X * aDistance.X) + (aDistance.Y * aDistance.Y)) > radius)
|
||||
{
|
||||
aColors[i] = Color.Transparent;
|
||||
}
|
||||
else
|
||||
{
|
||||
aColors[i] = Color.White;
|
||||
}
|
||||
}
|
||||
|
||||
aCircle.SetData<Color>(aColors);
|
||||
|
||||
return aCircle;
|
||||
}
|
||||
|
||||
protected override void LoadContent()
|
||||
{
|
||||
spriteBatch = new SpriteBatch(this.Game.GraphicsDevice);
|
||||
|
||||
signInProgress = Circle(this.Game.GraphicsDevice, 10);
|
||||
|
||||
base.LoadContent();
|
||||
}
|
||||
|
||||
protected override void UnloadContent()
|
||||
{
|
||||
base.UnloadContent();
|
||||
}
|
||||
|
||||
public override void Draw(GameTime gameTime)
|
||||
{
|
||||
spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend);
|
||||
|
||||
Vector2 center = new Vector2(this.Game.GraphicsDevice.PresentationParameters.BackBufferWidth / 2, this.Game.GraphicsDevice.PresentationParameters.BackBufferHeight - 100);
|
||||
Vector2 loc = Vector2.Zero;
|
||||
alphaColor.A = startalpha;
|
||||
for (int i = 0; i < 12; i++)
|
||||
{
|
||||
float angle = (float)(i / 12.0 * Math.PI * 2);
|
||||
loc = new Vector2(center.X + (float)Math.Cos(angle) * 50, center.Y + (float)Math.Sin(angle) * 50);
|
||||
spriteBatch.Draw(signInProgress, loc, alphaColor);
|
||||
alphaColor.A += 255 / 12;
|
||||
if (alphaColor.A > 255) alphaColor.A = 0;
|
||||
}
|
||||
spriteBatch.End();
|
||||
base.Draw(gameTime);
|
||||
}
|
||||
|
||||
TimeSpan gt = TimeSpan.Zero;
|
||||
TimeSpan last = TimeSpan.Zero;
|
||||
|
||||
public override void Update(GameTime gameTime)
|
||||
{
|
||||
if (gt == TimeSpan.Zero) gt = last = gameTime.TotalGameTime;
|
||||
|
||||
if ((gameTime.TotalGameTime - last).Milliseconds > 100)
|
||||
{
|
||||
last = gameTime.TotalGameTime;
|
||||
startalpha += 255 / 12;
|
||||
}
|
||||
|
||||
if ((gameTime.TotalGameTime - gt).TotalSeconds > 5) // close after 10 seconds
|
||||
{
|
||||
string strUsr = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
|
||||
|
||||
if (strUsr.Contains(@"\"))
|
||||
{
|
||||
int idx = strUsr.IndexOf(@"\") + 1;
|
||||
strUsr = strUsr.Substring(idx, strUsr.Length - idx);
|
||||
}
|
||||
|
||||
SignedInGamer sig = new SignedInGamer();
|
||||
sig.DisplayName = strUsr;
|
||||
sig.Gamertag = strUsr;
|
||||
|
||||
Gamer.SignedInGamers.Add(sig);
|
||||
|
||||
this.Visible = false;
|
||||
this.Enabled = false;
|
||||
//Guide.IsVisible = false;
|
||||
gt = TimeSpan.Zero;
|
||||
}
|
||||
base.Update(gameTime);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
-327
@@ -1,327 +0,0 @@
|
||||
#region License
|
||||
/*
|
||||
Microsoft Public License (Ms-PL)
|
||||
MonoGame - Copyright © 2009 The MonoGame Team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
This license governs use of the accompanying software. If you use the software, you accept this license. If you do not
|
||||
accept the license, do not use the software.
|
||||
|
||||
1. Definitions
|
||||
The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under
|
||||
U.S. copyright law.
|
||||
|
||||
A "contribution" is the original software, or any additions or changes to the software.
|
||||
A "contributor" is any person that distributes its contribution under this license.
|
||||
"Licensed patents" are a contributor's patent claims that read directly on its contribution.
|
||||
|
||||
2. Grant of Rights
|
||||
(A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
|
||||
each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create.
|
||||
(B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
|
||||
each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software.
|
||||
|
||||
3. Conditions and Limitations
|
||||
(A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.
|
||||
(B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software,
|
||||
your patent license from such contributor to the software ends automatically.
|
||||
(C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution
|
||||
notices that are present in the software.
|
||||
(D) If you distribute any portion of the software in source code form, you may do so only under this license by including
|
||||
a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object
|
||||
code form, you may only do so under a license that complies with this license.
|
||||
(E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees
|
||||
or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent
|
||||
permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular
|
||||
purpose and non-infringement.
|
||||
*/
|
||||
#endregion License
|
||||
|
||||
#region Statement
|
||||
using System;
|
||||
|
||||
#endregion Statement
|
||||
|
||||
|
||||
namespace Microsoft.Xna.Framework.GamerServices
|
||||
{
|
||||
public class SignedInGamer : Gamer
|
||||
{
|
||||
private AchievementCollection gamerAchievements;
|
||||
private FriendCollection friendCollection;
|
||||
|
||||
delegate void AuthenticationDelegate();
|
||||
|
||||
public IAsyncResult BeginAuthentication(AsyncCallback callback, Object asyncState)
|
||||
{
|
||||
// Go off authenticate
|
||||
AuthenticationDelegate ad = DoAuthentication;
|
||||
|
||||
return ad.BeginInvoke(callback, ad);
|
||||
}
|
||||
|
||||
public void EndAuthentication( IAsyncResult result )
|
||||
{
|
||||
AuthenticationDelegate ad = (AuthenticationDelegate)result.AsyncState;
|
||||
|
||||
ad.EndInvoke(result);
|
||||
}
|
||||
|
||||
private void DoAuthentication()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public SignedInGamer()
|
||||
{
|
||||
|
||||
var result = BeginAuthentication(null, null);
|
||||
EndAuthentication( result );
|
||||
}
|
||||
|
||||
private void AuthenticationCompletedCallback( IAsyncResult result )
|
||||
{
|
||||
EndAuthentication(result);
|
||||
}
|
||||
|
||||
#region Methods
|
||||
public FriendCollection GetFriends()
|
||||
{
|
||||
if(IsSignedInToLive)
|
||||
{
|
||||
if ( friendCollection == null )
|
||||
{
|
||||
friendCollection = new FriendCollection();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return friendCollection;
|
||||
}
|
||||
|
||||
public bool IsFriend (Gamer gamer)
|
||||
{
|
||||
if ( gamer == null )
|
||||
throw new ArgumentNullException();
|
||||
|
||||
if ( gamer.IsDisposed )
|
||||
throw new ObjectDisposedException(gamer.ToString());
|
||||
|
||||
bool found = false;
|
||||
foreach(FriendGamer f in friendCollection)
|
||||
{
|
||||
if ( f.Gamertag == gamer.Gamertag )
|
||||
{
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
return found;
|
||||
|
||||
}
|
||||
|
||||
delegate AchievementCollection GetAchievementsDelegate();
|
||||
|
||||
public IAsyncResult BeginGetAchievements( AsyncCallback callback, Object asyncState)
|
||||
{
|
||||
// Go off and grab achievements
|
||||
GetAchievementsDelegate gad = GetAchievements;
|
||||
|
||||
return gad.BeginInvoke(callback, gad);
|
||||
}
|
||||
|
||||
private void GetAchievementCompletedCallback( IAsyncResult result )
|
||||
{
|
||||
// get the delegate that was used to call that method
|
||||
GetAchievementsDelegate gad = (GetAchievementsDelegate)result.AsyncState;
|
||||
|
||||
// get the return value from that method call
|
||||
gamerAchievements = gad.EndInvoke(result);
|
||||
}
|
||||
|
||||
public AchievementCollection EndGetAchievements( IAsyncResult result )
|
||||
{
|
||||
GetAchievementsDelegate gad = (GetAchievementsDelegate)result.AsyncState;
|
||||
|
||||
gamerAchievements = gad.EndInvoke(result);
|
||||
|
||||
return gamerAchievements;
|
||||
}
|
||||
|
||||
public AchievementCollection GetAchievements()
|
||||
{
|
||||
if ( IsSignedInToLive )
|
||||
{
|
||||
if (gamerAchievements == null)
|
||||
{
|
||||
gamerAchievements = new AchievementCollection();
|
||||
}
|
||||
|
||||
}
|
||||
return gamerAchievements;
|
||||
}
|
||||
|
||||
delegate void AwardAchievementDelegate(string achievementId, double percentageComplete);
|
||||
|
||||
public IAsyncResult BeginAwardAchievement(string achievementId, AsyncCallback callback, Object state)
|
||||
{
|
||||
return BeginAwardAchievement(achievementId, 100.0, callback, state);
|
||||
}
|
||||
|
||||
public IAsyncResult BeginAwardAchievement(
|
||||
string achievementId,
|
||||
double percentageComplete,
|
||||
AsyncCallback callback,
|
||||
Object state
|
||||
)
|
||||
{
|
||||
// Go off and award the achievement
|
||||
AwardAchievementDelegate aad = DoAwardAchievement;
|
||||
|
||||
return aad.BeginInvoke(achievementId, percentageComplete, callback, aad);
|
||||
}
|
||||
|
||||
public void EndAwardAchievement(IAsyncResult result)
|
||||
{
|
||||
AwardAchievementDelegate aad = (AwardAchievementDelegate)result.AsyncState;
|
||||
|
||||
aad.EndInvoke(result);
|
||||
}
|
||||
|
||||
private void AwardAchievementCompletedCallback( IAsyncResult result )
|
||||
{
|
||||
EndAwardAchievement(result);
|
||||
}
|
||||
|
||||
public void AwardAchievement( string achievementId )
|
||||
{
|
||||
AwardAchievement(achievementId, 100.0f);
|
||||
}
|
||||
|
||||
public void DoAwardAchievement( string achievementId, double percentageComplete )
|
||||
{
|
||||
}
|
||||
|
||||
public void AwardAchievement( string achievementId, double percentageComplete )
|
||||
{
|
||||
if (IsSignedInToLive)
|
||||
{
|
||||
BeginAwardAchievement( achievementId, percentageComplete, AwardAchievementCompletedCallback, null );
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateScore( string aCategory, long aScore )
|
||||
{
|
||||
if (IsSignedInToLive)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public void ResetAchievements()
|
||||
{
|
||||
if (IsSignedInToLive)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
public GameDefaults GameDefaults
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsGuest
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsSignedInToLive
|
||||
{
|
||||
get
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public int PartySize
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
set
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
|
||||
public PlayerIndex PlayerIndex
|
||||
{
|
||||
get
|
||||
{
|
||||
return PlayerIndex.One;
|
||||
}
|
||||
}
|
||||
|
||||
public GamerPresence Presence
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
|
||||
GamerPrivileges _privileges = new GamerPrivileges();
|
||||
public GamerPrivileges Privileges
|
||||
{
|
||||
get
|
||||
{
|
||||
return _privileges;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
protected virtual void OnSignedIn(SignedInEventArgs e)
|
||||
{
|
||||
EventHelpers.Raise(this, SignedIn, e);
|
||||
}
|
||||
|
||||
protected virtual void OnSignedOut(SignedOutEventArgs e)
|
||||
{
|
||||
EventHelpers.Raise(this, SignedOut, e);
|
||||
}
|
||||
|
||||
|
||||
#region Events
|
||||
public static event EventHandler<SignedInEventArgs> SignedIn;
|
||||
|
||||
public static event EventHandler<SignedOutEventArgs> SignedOut;
|
||||
#endregion
|
||||
}
|
||||
|
||||
public class SignedInEventArgs : EventArgs
|
||||
{
|
||||
public SignedInEventArgs ( SignedInGamer gamer )
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public class SignedOutEventArgs : EventArgs
|
||||
{
|
||||
public SignedOutEventArgs (SignedInGamer gamer )
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
// MonoGame - Copyright (C) The MonoGame Team
|
||||
// This file is subject to the terms and conditions defined in
|
||||
// file 'LICENSE.txt', which is part of this source code package.
|
||||
|
||||
using System;
|
||||
|
||||
namespace Microsoft.Xna.Framework
|
||||
{
|
||||
partial class GamePlatform
|
||||
{
|
||||
internal static GamePlatform PlatformCreate(Game game)
|
||||
{
|
||||
#if IOS
|
||||
return new iOSGamePlatform(game);
|
||||
#elif ANDROID
|
||||
return new AndroidGamePlatform(game);
|
||||
#elif WINDOWS_PHONE81
|
||||
return new MetroGamePlatform(game);
|
||||
#elif WEB
|
||||
return new WebGamePlatform(game);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,89 +0,0 @@
|
||||
// #region License
|
||||
// /*
|
||||
// Microsoft Public License (Ms-PL)
|
||||
// MonoGame - Copyright © 2009 The MonoGame Team
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
// This license governs use of the accompanying software. If you use the software, you accept this license. If you do not
|
||||
// accept the license, do not use the software.
|
||||
//
|
||||
// 1. Definitions
|
||||
// The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under
|
||||
// U.S. copyright law.
|
||||
//
|
||||
// A "contribution" is the original software, or any additions or changes to the software.
|
||||
// A "contributor" is any person that distributes its contribution under this license.
|
||||
// "Licensed patents" are a contributor's patent claims that read directly on its contribution.
|
||||
//
|
||||
// 2. Grant of Rights
|
||||
// (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
|
||||
// each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create.
|
||||
// (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
|
||||
// each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software.
|
||||
//
|
||||
// 3. Conditions and Limitations
|
||||
// (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.
|
||||
// (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software,
|
||||
// your patent license from such contributor to the software ends automatically.
|
||||
// (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution
|
||||
// notices that are present in the software.
|
||||
// (D) If you distribute any portion of the software in source code form, you may do so only under this license by including
|
||||
// a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object
|
||||
// code form, you may only do so under a license that complies with this license.
|
||||
// (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees
|
||||
// or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent
|
||||
// permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular
|
||||
// purpose and non-infringement.
|
||||
// */
|
||||
// #endregion License
|
||||
//
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Microsoft.Xna.Framework.GamerServices
|
||||
{
|
||||
[DataContract]
|
||||
public class Achievement
|
||||
{
|
||||
public Achievement ()
|
||||
{
|
||||
}
|
||||
|
||||
[DataMember]
|
||||
public string Description { get; internal set; }
|
||||
|
||||
[DataMember]
|
||||
public bool DisplayBeforeEarned { get; internal set; }
|
||||
|
||||
[DataMember]
|
||||
public DateTime EarnedDateTime { get; internal set; }
|
||||
|
||||
[DataMember]
|
||||
public bool EarnedOnline { get; internal set; }
|
||||
|
||||
[DataMember]
|
||||
public int GamerScore { get; internal set; }
|
||||
|
||||
[DataMember]
|
||||
public string HowToEarn { get; internal set; }
|
||||
|
||||
[DataMember]
|
||||
public bool IsEarned { get; internal set; }
|
||||
|
||||
[DataMember]
|
||||
public string Key { get; internal set; }
|
||||
|
||||
[DataMember]
|
||||
public string Name { get; internal set; }
|
||||
|
||||
/*
|
||||
public Stream GetPicture ()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
-182
@@ -1,182 +0,0 @@
|
||||
// #region License
|
||||
// /*
|
||||
// Microsoft Public License (Ms-PL)
|
||||
// MonoGame - Copyright © 2009 The MonoGame Team
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
// This license governs use of the accompanying software. If you use the software, you accept this license. If you do not
|
||||
// accept the license, do not use the software.
|
||||
//
|
||||
// 1. Definitions
|
||||
// The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under
|
||||
// U.S. copyright law.
|
||||
//
|
||||
// A "contribution" is the original software, or any additions or changes to the software.
|
||||
// A "contributor" is any person that distributes its contribution under this license.
|
||||
// "Licensed patents" are a contributor's patent claims that read directly on its contribution.
|
||||
//
|
||||
// 2. Grant of Rights
|
||||
// (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
|
||||
// each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create.
|
||||
// (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
|
||||
// each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software.
|
||||
//
|
||||
// 3. Conditions and Limitations
|
||||
// (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.
|
||||
// (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software,
|
||||
// your patent license from such contributor to the software ends automatically.
|
||||
// (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution
|
||||
// notices that are present in the software.
|
||||
// (D) If you distribute any portion of the software in source code form, you may do so only under this license by including
|
||||
// a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object
|
||||
// code form, you may only do so under a license that complies with this license.
|
||||
// (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees
|
||||
// or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent
|
||||
// permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular
|
||||
// purpose and non-infringement.
|
||||
// */
|
||||
// #endregion License
|
||||
//
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Microsoft.Xna.Framework.GamerServices
|
||||
{
|
||||
public class AchievementCollection : IList<Achievement>, ICollection<Achievement>, IEnumerable<Achievement>, IEnumerable, IDisposable
|
||||
{
|
||||
private List<Achievement> innerlist;
|
||||
|
||||
public AchievementCollection ()
|
||||
{
|
||||
innerlist = new List<Achievement>();
|
||||
}
|
||||
|
||||
~AchievementCollection()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
#region Properties
|
||||
public int Count
|
||||
{
|
||||
get { return innerlist.Count; }
|
||||
}
|
||||
|
||||
public Achievement this[int index]
|
||||
{
|
||||
get { return innerlist[index]; }
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
throw new ArgumentNullException();
|
||||
|
||||
if (index >= innerlist.Count)
|
||||
throw new IndexOutOfRangeException();
|
||||
|
||||
/*if (innerlist[index].Position == value.Position)
|
||||
innerlist[index] = value;
|
||||
else
|
||||
{
|
||||
innerlist.RemoveAt(index);
|
||||
innerlist.Add(value);
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
private bool isReadOnly = false;
|
||||
public bool IsReadOnly
|
||||
{
|
||||
get
|
||||
{
|
||||
return isReadOnly;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Properties
|
||||
|
||||
#region Public Methods
|
||||
public void Add(Achievement item)
|
||||
{
|
||||
if (item == null)
|
||||
throw new ArgumentNullException();
|
||||
|
||||
if (innerlist.Count == 0)
|
||||
{
|
||||
innerlist.Add(item);
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < innerlist.Count; i++)
|
||||
{
|
||||
/*if (item.Position < innerlist[i].Position)
|
||||
{
|
||||
this.innerlist.Insert(i, item);
|
||||
return;
|
||||
}*/
|
||||
}
|
||||
|
||||
this.innerlist.Add(item);
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
innerlist.Clear();
|
||||
}
|
||||
|
||||
public bool Contains(Achievement item)
|
||||
{
|
||||
return innerlist.Contains(item);
|
||||
}
|
||||
|
||||
public void CopyTo(Achievement[] array, int arrayIndex)
|
||||
{
|
||||
innerlist.CopyTo(array, arrayIndex);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public int IndexOf(Achievement item)
|
||||
{
|
||||
return innerlist.IndexOf(item);
|
||||
}
|
||||
|
||||
public void Insert(int index, Achievement item)
|
||||
{
|
||||
innerlist.Insert(index, item);
|
||||
}
|
||||
|
||||
public bool Remove(Achievement item)
|
||||
{
|
||||
return innerlist.Remove(item);
|
||||
}
|
||||
|
||||
public void RemoveAt(int index)
|
||||
{
|
||||
innerlist.RemoveAt(index);
|
||||
}
|
||||
|
||||
public IEnumerator<Achievement> GetEnumerator()
|
||||
{
|
||||
return innerlist.GetEnumerator();
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return innerlist.GetEnumerator();
|
||||
}
|
||||
|
||||
#endregion Methods
|
||||
}
|
||||
}
|
||||
|
||||
-186
@@ -1,186 +0,0 @@
|
||||
// #region License
|
||||
// /*
|
||||
// Microsoft Public License (Ms-PL)
|
||||
// MonoGame - Copyright © 2009 The MonoGame Team
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
// This license governs use of the accompanying software. If you use the software, you accept this license. If you do not
|
||||
// accept the license, do not use the software.
|
||||
//
|
||||
// 1. Definitions
|
||||
// The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under
|
||||
// U.S. copyright law.
|
||||
//
|
||||
// A "contribution" is the original software, or any additions or changes to the software.
|
||||
// A "contributor" is any person that distributes its contribution under this license.
|
||||
// "Licensed patents" are a contributor's patent claims that read directly on its contribution.
|
||||
//
|
||||
// 2. Grant of Rights
|
||||
// (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
|
||||
// each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create.
|
||||
// (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
|
||||
// each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software.
|
||||
//
|
||||
// 3. Conditions and Limitations
|
||||
// (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.
|
||||
// (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software,
|
||||
// your patent license from such contributor to the software ends automatically.
|
||||
// (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution
|
||||
// notices that are present in the software.
|
||||
// (D) If you distribute any portion of the software in source code form, you may do so only under this license by including
|
||||
// a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object
|
||||
// code form, you may only do so under a license that complies with this license.
|
||||
// (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees
|
||||
// or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent
|
||||
// permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular
|
||||
// purpose and non-infringement.
|
||||
// */
|
||||
// #endregion License
|
||||
//
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Microsoft.Xna.Framework.GamerServices
|
||||
{
|
||||
public class FriendCollection : IList<FriendGamer>, ICollection<FriendGamer>, IEnumerable<FriendGamer>, IEnumerable, IDisposable
|
||||
{
|
||||
private List<FriendGamer> innerlist;
|
||||
|
||||
public FriendCollection ()
|
||||
{
|
||||
innerlist = new List<FriendGamer>();
|
||||
}
|
||||
|
||||
~FriendCollection()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
#region Properties
|
||||
public int Count
|
||||
{
|
||||
get { return innerlist.Count; }
|
||||
}
|
||||
|
||||
public FriendGamer this[int index]
|
||||
{
|
||||
get { return innerlist[index]; }
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
throw new ArgumentNullException();
|
||||
|
||||
if (index >= innerlist.Count)
|
||||
throw new IndexOutOfRangeException();
|
||||
|
||||
/*if (innerlist[index].Position == value.Position)
|
||||
innerlist[index] = value;
|
||||
else
|
||||
{
|
||||
innerlist.RemoveAt(index);
|
||||
innerlist.Add(value);
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
private bool isReadOnly;
|
||||
public bool IsReadOnly
|
||||
{
|
||||
get
|
||||
{
|
||||
return isReadOnly;
|
||||
}
|
||||
private set
|
||||
{
|
||||
isReadOnly = value;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Properties
|
||||
|
||||
#region Public Methods
|
||||
public void Add(FriendGamer item)
|
||||
{
|
||||
if (item == null)
|
||||
throw new ArgumentNullException();
|
||||
|
||||
if (innerlist.Count == 0)
|
||||
{
|
||||
innerlist.Add(item);
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < innerlist.Count; i++)
|
||||
{
|
||||
/*if (item.Position < innerlist[i].Position)
|
||||
{
|
||||
this.innerlist.Insert(i, item);
|
||||
return;
|
||||
}*/
|
||||
}
|
||||
|
||||
this.innerlist.Add(item);
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
innerlist.Clear();
|
||||
}
|
||||
|
||||
public bool Contains(FriendGamer item)
|
||||
{
|
||||
return innerlist.Contains(item);
|
||||
}
|
||||
|
||||
public void CopyTo(FriendGamer[] array, int arrayIndex)
|
||||
{
|
||||
innerlist.CopyTo(array, arrayIndex);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public int IndexOf(FriendGamer item)
|
||||
{
|
||||
return innerlist.IndexOf(item);
|
||||
}
|
||||
|
||||
public void Insert(int index, FriendGamer item)
|
||||
{
|
||||
innerlist.Insert(index, item);
|
||||
}
|
||||
|
||||
public bool Remove(FriendGamer item)
|
||||
{
|
||||
return innerlist.Remove(item);
|
||||
}
|
||||
|
||||
public void RemoveAt(int index)
|
||||
{
|
||||
innerlist.RemoveAt(index);
|
||||
}
|
||||
|
||||
public IEnumerator<FriendGamer> GetEnumerator()
|
||||
{
|
||||
return innerlist.GetEnumerator();
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return innerlist.GetEnumerator();
|
||||
}
|
||||
|
||||
#endregion Methods
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
// #region License
|
||||
// /*
|
||||
// Microsoft Public License (Ms-PL)
|
||||
// MonoGame - Copyright © 2009 The MonoGame Team
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
// This license governs use of the accompanying software. If you use the software, you accept this license. If you do not
|
||||
// accept the license, do not use the software.
|
||||
//
|
||||
// 1. Definitions
|
||||
// The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under
|
||||
// U.S. copyright law.
|
||||
//
|
||||
// A "contribution" is the original software, or any additions or changes to the software.
|
||||
// A "contributor" is any person that distributes its contribution under this license.
|
||||
// "Licensed patents" are a contributor's patent claims that read directly on its contribution.
|
||||
//
|
||||
// 2. Grant of Rights
|
||||
// (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
|
||||
// each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create.
|
||||
// (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
|
||||
// each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software.
|
||||
//
|
||||
// 3. Conditions and Limitations
|
||||
// (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.
|
||||
// (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software,
|
||||
// your patent license from such contributor to the software ends automatically.
|
||||
// (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution
|
||||
// notices that are present in the software.
|
||||
// (D) If you distribute any portion of the software in source code form, you may do so only under this license by including
|
||||
// a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object
|
||||
// code form, you may only do so under a license that complies with this license.
|
||||
// (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees
|
||||
// or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent
|
||||
// permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular
|
||||
// purpose and non-infringement.
|
||||
// */
|
||||
// #endregion License
|
||||
//
|
||||
using System;
|
||||
namespace Microsoft.Xna.Framework.GamerServices
|
||||
{
|
||||
public class FriendGamer : Gamer
|
||||
{
|
||||
public FriendGamer()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,154 +0,0 @@
|
||||
#region License
|
||||
/*
|
||||
Microsoft Public License (Ms-PL)
|
||||
MonoGame - Copyright © 2009 The MonoGame Team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
This license governs use of the accompanying software. If you use the software, you accept this license. If you do not
|
||||
accept the license, do not use the software.
|
||||
|
||||
1. Definitions
|
||||
The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under
|
||||
U.S. copyright law.
|
||||
|
||||
A "contribution" is the original software, or any additions or changes to the software.
|
||||
A "contributor" is any person that distributes its contribution under this license.
|
||||
"Licensed patents" are a contributor's patent claims that read directly on its contribution.
|
||||
|
||||
2. Grant of Rights
|
||||
(A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
|
||||
each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create.
|
||||
(B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
|
||||
each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software.
|
||||
|
||||
3. Conditions and Limitations
|
||||
(A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.
|
||||
(B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software,
|
||||
your patent license from such contributor to the software ends automatically.
|
||||
(C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution
|
||||
notices that are present in the software.
|
||||
(D) If you distribute any portion of the software in source code form, you may do so only under this license by including
|
||||
a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object
|
||||
code form, you may only do so under a license that complies with this license.
|
||||
(E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees
|
||||
or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent
|
||||
permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular
|
||||
purpose and non-infringement.
|
||||
*/
|
||||
#endregion License
|
||||
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Microsoft.Xna.Framework.GamerServices
|
||||
{
|
||||
[DataContract]
|
||||
public abstract class Gamer
|
||||
{
|
||||
static SignedInGamerCollection _signedInGamers = new SignedInGamerCollection();
|
||||
string _gamer = "MonoGame";
|
||||
Object _tag;
|
||||
bool disposed;
|
||||
|
||||
LeaderboardWriter _leaderboardWriter;
|
||||
|
||||
#region Methods
|
||||
|
||||
/*
|
||||
public IAsyncResult BeginGetProfile( AsyncCallback callback, Object asyncState )
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public GamerProfile EndGetProfile(IAsyncResult result)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public GamerProfile GetProfile()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
*/
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return _gamer;
|
||||
}
|
||||
|
||||
internal void Dispose()
|
||||
{
|
||||
disposed = true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
#region Properties
|
||||
[DataMember]
|
||||
public string DisplayName
|
||||
{
|
||||
get;
|
||||
internal set;
|
||||
}
|
||||
|
||||
[DataMember]
|
||||
public string Gamertag
|
||||
{
|
||||
get
|
||||
{
|
||||
return _gamer;
|
||||
}
|
||||
|
||||
internal set
|
||||
{
|
||||
_gamer = value;
|
||||
}
|
||||
}
|
||||
|
||||
[DataMember]
|
||||
public bool IsDisposed
|
||||
{
|
||||
get
|
||||
{
|
||||
return disposed;
|
||||
}
|
||||
}
|
||||
|
||||
public Object Tag
|
||||
{
|
||||
get
|
||||
{
|
||||
return _tag;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (_tag != value)
|
||||
{
|
||||
_tag = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static SignedInGamerCollection SignedInGamers
|
||||
{
|
||||
get
|
||||
{
|
||||
return _signedInGamers;
|
||||
}
|
||||
}
|
||||
|
||||
public LeaderboardWriter LeaderboardWriter
|
||||
{
|
||||
get
|
||||
{
|
||||
return _leaderboardWriter;
|
||||
}
|
||||
|
||||
internal set
|
||||
{
|
||||
_leaderboardWriter = value;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,97 +0,0 @@
|
||||
#region License
|
||||
// /*
|
||||
// Microsoft Public License (Ms-PL)
|
||||
// MonoGame - Copyright © 2009 The MonoGame Team
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
// This license governs use of the accompanying software. If you use the software, you accept this license. If you do not
|
||||
// accept the license, do not use the software.
|
||||
//
|
||||
// 1. Definitions
|
||||
// The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under
|
||||
// U.S. copyright law.
|
||||
//
|
||||
// A "contribution" is the original software, or any additions or changes to the software.
|
||||
// A "contributor" is any person that distributes its contribution under this license.
|
||||
// "Licensed patents" are a contributor's patent claims that read directly on its contribution.
|
||||
//
|
||||
// 2. Grant of Rights
|
||||
// (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
|
||||
// each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create.
|
||||
// (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
|
||||
// each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software.
|
||||
//
|
||||
// 3. Conditions and Limitations
|
||||
// (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.
|
||||
// (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software,
|
||||
// your patent license from such contributor to the software ends automatically.
|
||||
// (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution
|
||||
// notices that are present in the software.
|
||||
// (D) If you distribute any portion of the software in source code form, you may do so only under this license by including
|
||||
// a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object
|
||||
// code form, you may only do so under a license that complies with this license.
|
||||
// (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees
|
||||
// or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent
|
||||
// permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular
|
||||
// purpose and non-infringement.
|
||||
// */
|
||||
#endregion License
|
||||
|
||||
#region Using clause
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
#endregion Using clause
|
||||
|
||||
namespace Microsoft.Xna.Framework.GamerServices
|
||||
{
|
||||
|
||||
|
||||
public class GamerCollection<T> : ReadOnlyCollection<T>, IEnumerable<T>, IEnumerable where T : Gamer
|
||||
{
|
||||
internal GamerCollection(List<T> list): base(list)
|
||||
{
|
||||
}
|
||||
|
||||
internal GamerCollection(): base(new List<T>())
|
||||
{
|
||||
}
|
||||
|
||||
internal void AddGamer (T item) {
|
||||
// need to add gamers at the correct index based on GamerTag
|
||||
if (base.Items.Count > 0)
|
||||
{
|
||||
for (int i = 0; i < base.Items.Count; i++)
|
||||
{
|
||||
if (item.Gamertag.CompareTo(base.Items[i].Gamertag) > 0)
|
||||
{
|
||||
base.Items.Insert(i, item);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
base.Items.Add(item);
|
||||
|
||||
}
|
||||
|
||||
internal void RemoveGamer (T item) {
|
||||
base.Items.Remove (item);
|
||||
}
|
||||
|
||||
internal void RemoveGamerAt (int item) {
|
||||
base.Items.RemoveAt (item);
|
||||
}
|
||||
|
||||
// public IEnumerator<Gamer> GetEnumerator()
|
||||
// {
|
||||
// return this.GetEnumerator();
|
||||
// }
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return this.GetEnumerator();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
#region License
|
||||
// /*
|
||||
// Microsoft Public License (Ms-PL)
|
||||
// MonoGame - Copyright © 2009 The MonoGame Team
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
// This license governs use of the accompanying software. If you use the software, you accept this license. If you do not
|
||||
// accept the license, do not use the software.
|
||||
//
|
||||
// 1. Definitions
|
||||
// The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under
|
||||
// U.S. copyright law.
|
||||
//
|
||||
// A "contribution" is the original software, or any additions or changes to the software.
|
||||
// A "contributor" is any person that distributes its contribution under this license.
|
||||
// "Licensed patents" are a contributor's patent claims that read directly on its contribution.
|
||||
//
|
||||
// 2. Grant of Rights
|
||||
// (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
|
||||
// each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create.
|
||||
// (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
|
||||
// each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software.
|
||||
//
|
||||
// 3. Conditions and Limitations
|
||||
// (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.
|
||||
// (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software,
|
||||
// your patent license from such contributor to the software ends automatically.
|
||||
// (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution
|
||||
// notices that are present in the software.
|
||||
// (D) If you distribute any portion of the software in source code form, you may do so only under this license by including
|
||||
// a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object
|
||||
// code form, you may only do so under a license that complies with this license.
|
||||
// (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees
|
||||
// or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent
|
||||
// permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular
|
||||
// purpose and non-infringement.
|
||||
// */
|
||||
#endregion License
|
||||
|
||||
using System;
|
||||
|
||||
namespace Microsoft.Xna.Framework.GamerServices
|
||||
{
|
||||
public sealed class GameDefaults
|
||||
{
|
||||
public bool AccelerateWithButtons
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
#region License
|
||||
// /*
|
||||
// Microsoft Public License (Ms-PL)
|
||||
// MonoGame - Copyright © 2009 The MonoGame Team
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
// This license governs use of the accompanying software. If you use the software, you accept this license. If you do not
|
||||
// accept the license, do not use the software.
|
||||
//
|
||||
// 1. Definitions
|
||||
// The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under
|
||||
// U.S. copyright law.
|
||||
//
|
||||
// A "contribution" is the original software, or any additions or changes to the software.
|
||||
// A "contributor" is any person that distributes its contribution under this license.
|
||||
// "Licensed patents" are a contributor's patent claims that read directly on its contribution.
|
||||
//
|
||||
// 2. Grant of Rights
|
||||
// (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
|
||||
// each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create.
|
||||
// (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
|
||||
// each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software.
|
||||
//
|
||||
// 3. Conditions and Limitations
|
||||
// (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.
|
||||
// (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software,
|
||||
// your patent license from such contributor to the software ends automatically.
|
||||
// (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution
|
||||
// notices that are present in the software.
|
||||
// (D) If you distribute any portion of the software in source code form, you may do so only under this license by including
|
||||
// a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object
|
||||
// code form, you may only do so under a license that complies with this license.
|
||||
// (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees
|
||||
// or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent
|
||||
// permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular
|
||||
// purpose and non-infringement.
|
||||
// */
|
||||
#endregion License
|
||||
|
||||
using System;
|
||||
|
||||
namespace Microsoft.Xna.Framework.GamerServices
|
||||
{
|
||||
public sealed class GamerPresence
|
||||
{
|
||||
public GamerPresenceMode PresenceMode
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
set
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
|
||||
public int PresenceValue
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
set
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
-108
@@ -1,108 +0,0 @@
|
||||
#region License
|
||||
// /*
|
||||
// Microsoft Public License (Ms-PL)
|
||||
// MonoGame - Copyright © 2009 The MonoGame Team
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
// This license governs use of the accompanying software. If you use the software, you accept this license. If you do not
|
||||
// accept the license, do not use the software.
|
||||
//
|
||||
// 1. Definitions
|
||||
// The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under
|
||||
// U.S. copyright law.
|
||||
//
|
||||
// A "contribution" is the original software, or any additions or changes to the software.
|
||||
// A "contributor" is any person that distributes its contribution under this license.
|
||||
// "Licensed patents" are a contributor's patent claims that read directly on its contribution.
|
||||
//
|
||||
// 2. Grant of Rights
|
||||
// (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
|
||||
// each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create.
|
||||
// (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
|
||||
// each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software.
|
||||
//
|
||||
// 3. Conditions and Limitations
|
||||
// (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.
|
||||
// (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software,
|
||||
// your patent license from such contributor to the software ends automatically.
|
||||
// (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution
|
||||
// notices that are present in the software.
|
||||
// (D) If you distribute any portion of the software in source code form, you may do so only under this license by including
|
||||
// a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object
|
||||
// code form, you may only do so under a license that complies with this license.
|
||||
// (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees
|
||||
// or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent
|
||||
// permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular
|
||||
// purpose and non-infringement.
|
||||
// */
|
||||
#endregion License
|
||||
|
||||
using System;
|
||||
|
||||
namespace Microsoft.Xna.Framework.GamerServices
|
||||
{
|
||||
public enum GamerPresenceMode
|
||||
{
|
||||
ArcadeMode, //Arcade Mode
|
||||
AtMenu, //At Menu
|
||||
BattlingBoss , //Battling Boss
|
||||
CampaignMode, // Campaign Mode
|
||||
ChallengeMode, // Challenge Mode
|
||||
ConfiguringSettings, // // Configuring Settings
|
||||
CoOpLevel, // Co-Op: Level. Includes a numeric value specified with PresenceValue.
|
||||
CoOpStage,// Co-Op: Stage. Includes a numeric value specified with PresenceValue.
|
||||
CornflowerBlue, //Cornflower Blue
|
||||
CustomizingPlayer, //Customizing Player
|
||||
DifficultyEasy, //Difficulty: Easy
|
||||
DifficultyExtreme, //Difficulty: Extreme
|
||||
DifficultyHard, //Difficulty: Hard
|
||||
DifficultyMedium , // Difficulty: Medium
|
||||
EditingLevel , // Editing Level
|
||||
ExplorationMode, //Exploration Mode
|
||||
FoundSecret, //Found Secret
|
||||
FreePlay , // Free Play
|
||||
GameOver , //Game Over
|
||||
InCombat, // In Combat
|
||||
InGameStore, //In Game Store
|
||||
Level, //Level. Includes a numeric value specified with PresenceValue.
|
||||
LocalCoOp, //Local Co-Op
|
||||
LocalVersus, //Local Versus
|
||||
LookingForGames, //Looking For Games
|
||||
Losing, //Losing
|
||||
Multiplayer, //Multiplayer
|
||||
NearlyFinished, // Nearly Finished
|
||||
None , // NoPresence String Displayed
|
||||
OnARoll, // On a Roll
|
||||
OnlineCoOp, //Online Co-Op
|
||||
OnlineVersus, //Online Versus
|
||||
Outnumbered, //Outnumbered
|
||||
Paused, //Paused
|
||||
PlayingMinigame, //Playing Minigame
|
||||
PlayingWithFriends, //Playing With Friends
|
||||
PracticeMode , //Practice Mode
|
||||
PuzzleMode, //Puzzle Mode
|
||||
ScenarioMode , //Scenario Mode
|
||||
Score, //Score. Includes a numeric value specified with PresenceValue.
|
||||
ScoreIsTied, //Score is Tied
|
||||
SettingUpMatch, //Setting Up Match
|
||||
SinglePlayer, // Single Player
|
||||
Stage, //Stage. Includes a numeric value specified with PresenceValue.
|
||||
StartingGame, //Starting Game
|
||||
StoryMode, //Story Mode
|
||||
StuckOnAHardBit, // Stuck on a Hard Bit
|
||||
SurvivalMode , //Survival Mode
|
||||
TimeAttack, //Time Attack
|
||||
TryingForRecord, // Trying For Record
|
||||
TutorialMode , //Tutorial Mode
|
||||
VersusComputer, //Versus Computer
|
||||
VersusScore, // Versus: Score. Includes a numeric value specified with PresenceValue.
|
||||
WaitingForPlayers, //Waiting For Players
|
||||
WaitingInLobby, //Waiting In Lobby
|
||||
WastingTime, // Wasting Time
|
||||
WatchingCredits, // Watching Credits
|
||||
WatchingCutscene, //Watching Cutscene
|
||||
Winning, // Winning
|
||||
WonTheGame, // Won the Game
|
||||
}
|
||||
}
|
||||
-52
@@ -1,52 +0,0 @@
|
||||
#region License
|
||||
/*
|
||||
Microsoft Public License (Ms-PL)
|
||||
MonoGame - Copyright © 2009 The MonoGame Team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
This license governs use of the accompanying software. If you use the software, you accept this license. If you do not
|
||||
accept the license, do not use the software.
|
||||
|
||||
1. Definitions
|
||||
The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under
|
||||
U.S. copyright law.
|
||||
|
||||
A "contribution" is the original software, or any additions or changes to the software.
|
||||
A "contributor" is any person that distributes its contribution under this license.
|
||||
"Licensed patents" are a contributor's patent claims that read directly on its contribution.
|
||||
|
||||
2. Grant of Rights
|
||||
(A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
|
||||
each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create.
|
||||
(B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
|
||||
each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software.
|
||||
|
||||
3. Conditions and Limitations
|
||||
(A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.
|
||||
(B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software,
|
||||
your patent license from such contributor to the software ends automatically.
|
||||
(C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution
|
||||
notices that are present in the software.
|
||||
(D) If you distribute any portion of the software in source code form, you may do so only under this license by including
|
||||
a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object
|
||||
code form, you may only do so under a license that complies with this license.
|
||||
(E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees
|
||||
or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent
|
||||
permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular
|
||||
purpose and non-infringement.
|
||||
*/
|
||||
#endregion License
|
||||
|
||||
|
||||
using System;
|
||||
|
||||
namespace Microsoft.Xna.Framework.GamerServices
|
||||
{
|
||||
public enum GamerPrivilegeSetting
|
||||
{
|
||||
Blocked, // This privilege is not available for the current gamer profile.
|
||||
Everyone, // This privilege is available for the current gamer profile.
|
||||
FriendsOnly, // This privilege is only available for friends of the current gamer profile. Use the IsFriend method to check which gamers are friends.
|
||||
}
|
||||
}
|
||||
@@ -1,111 +0,0 @@
|
||||
#region License
|
||||
/*
|
||||
Microsoft Public License (Ms-PL)
|
||||
MonoGame - Copyright © 2009 The MonoGame Team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
This license governs use of the accompanying software. If you use the software, you accept this license. If you do not
|
||||
accept the license, do not use the software.
|
||||
|
||||
1. Definitions
|
||||
The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under
|
||||
U.S. copyright law.
|
||||
|
||||
A "contribution" is the original software, or any additions or changes to the software.
|
||||
A "contributor" is any person that distributes its contribution under this license.
|
||||
"Licensed patents" are a contributor's patent claims that read directly on its contribution.
|
||||
|
||||
2. Grant of Rights
|
||||
(A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
|
||||
each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create.
|
||||
(B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
|
||||
each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software.
|
||||
|
||||
3. Conditions and Limitations
|
||||
(A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.
|
||||
(B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software,
|
||||
your patent license from such contributor to the software ends automatically.
|
||||
(C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution
|
||||
notices that are present in the software.
|
||||
(D) If you distribute any portion of the software in source code form, you may do so only under this license by including
|
||||
a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object
|
||||
code form, you may only do so under a license that complies with this license.
|
||||
(E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees
|
||||
or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent
|
||||
permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular
|
||||
purpose and non-infringement.
|
||||
*/
|
||||
#endregion License
|
||||
|
||||
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Microsoft.Xna.Framework.GamerServices
|
||||
{
|
||||
#if WINDOWS_UAP
|
||||
[DataContract]
|
||||
#else
|
||||
[Serializable]
|
||||
#endif
|
||||
public class GamerPrivilegeException : Exception
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public class GamerPrivileges
|
||||
{
|
||||
#region Properties
|
||||
public GamerPrivilegeSetting AllowCommunication
|
||||
{
|
||||
get
|
||||
{
|
||||
return GamerPrivilegeSetting.Everyone;
|
||||
}
|
||||
}
|
||||
|
||||
public bool AllowOnlineSessions
|
||||
{
|
||||
get
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public GamerPrivilegeSetting AllowProfileViewing
|
||||
{
|
||||
get
|
||||
{
|
||||
return GamerPrivilegeSetting.Blocked;
|
||||
}
|
||||
}
|
||||
|
||||
public bool AllowPurchaseContent
|
||||
{
|
||||
get
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool AllowTradeContent
|
||||
{
|
||||
get
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public GamerPrivilegeSetting AllowUserCreatedContent
|
||||
{
|
||||
get
|
||||
{
|
||||
return GamerPrivilegeSetting.Blocked;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,133 +0,0 @@
|
||||
#region License
|
||||
/*
|
||||
Microsoft Public License (Ms-PL)
|
||||
MonoGame - Copyright © 2009 The MonoGame Team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
This license governs use of the accompanying software. If you use the software, you accept this license. If you do not
|
||||
accept the license, do not use the software.
|
||||
|
||||
1. Definitions
|
||||
The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under
|
||||
U.S. copyright law.
|
||||
|
||||
A "contribution" is the original software, or any additions or changes to the software.
|
||||
A "contributor" is any person that distributes its contribution under this license.
|
||||
"Licensed patents" are a contributor's patent claims that read directly on its contribution.
|
||||
|
||||
2. Grant of Rights
|
||||
(A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
|
||||
each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create.
|
||||
(B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
|
||||
each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software.
|
||||
|
||||
3. Conditions and Limitations
|
||||
(A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.
|
||||
(B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software,
|
||||
your patent license from such contributor to the software ends automatically.
|
||||
(C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution
|
||||
notices that are present in the software.
|
||||
(D) If you distribute any portion of the software in source code form, you may do so only under this license by including
|
||||
a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object
|
||||
code form, you may only do so under a license that complies with this license.
|
||||
(E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees
|
||||
or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent
|
||||
permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular
|
||||
purpose and non-infringement.
|
||||
*/
|
||||
#endregion License
|
||||
|
||||
#region Using Statements
|
||||
using System;
|
||||
using System.Globalization;
|
||||
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace Microsoft.Xna.Framework.GamerServices
|
||||
{
|
||||
|
||||
public sealed class GamerProfile : IDisposable
|
||||
{
|
||||
~GamerProfile()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
#region IDisposable implementation
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
private void Dispose(bool disposing)
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
/*
|
||||
public Texture2D GamerPicture {
|
||||
get {
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
}
|
||||
|
||||
public int GamerScore {
|
||||
get {
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
}
|
||||
|
||||
public GamerZone GamerZone {
|
||||
get {
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsDisposed {
|
||||
get {
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
}
|
||||
|
||||
public string Motto {
|
||||
get {
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
}
|
||||
|
||||
public RegionInfo Region {
|
||||
get {
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
}
|
||||
|
||||
public float Reputation {
|
||||
get {
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
}
|
||||
|
||||
public int TitlesPlayed {
|
||||
get {
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
}
|
||||
|
||||
public int TotalAchievements {
|
||||
get {
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
-103
@@ -1,103 +0,0 @@
|
||||
#region License
|
||||
/*
|
||||
Microsoft Public License (Ms-PL)
|
||||
MonoGame - Copyright © 2009-2012 The MonoGame Team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
This license governs use of the accompanying software. If you use the software,
|
||||
you accept this license. If you do not accept the license, do not use the
|
||||
software.
|
||||
|
||||
1. Definitions
|
||||
|
||||
The terms "reproduce," "reproduction," "derivative works," and "distribution"
|
||||
have the same meaning here as under U.S. copyright law.
|
||||
|
||||
A "contribution" is the original software, or any additions or changes to the
|
||||
software.
|
||||
|
||||
A "contributor" is any person that distributes its contribution under this
|
||||
license.
|
||||
|
||||
"Licensed patents" are a contributor's patent claims that read directly on its
|
||||
contribution.
|
||||
|
||||
2. Grant of Rights
|
||||
|
||||
(A) Copyright Grant- Subject to the terms of this license, including the
|
||||
license conditions and limitations in section 3, each contributor grants you a
|
||||
non-exclusive, worldwide, royalty-free copyright license to reproduce its
|
||||
contribution, prepare derivative works of its contribution, and distribute its
|
||||
contribution or any derivative works that you create.
|
||||
|
||||
(B) Patent Grant- Subject to the terms of this license, including the license
|
||||
conditions and limitations in section 3, each contributor grants you a
|
||||
non-exclusive, worldwide, royalty-free license under its licensed patents to
|
||||
make, have made, use, sell, offer for sale, import, and/or otherwise dispose of
|
||||
its contribution in the software or derivative works of the contribution in the
|
||||
software.
|
||||
|
||||
3. Conditions and Limitations
|
||||
|
||||
(A) No Trademark License- This license does not grant you rights to use any
|
||||
contributors' name, logo, or trademarks.
|
||||
|
||||
(B) If you bring a patent claim against any contributor over patents that you
|
||||
claim are infringed by the software, your patent license from such contributor
|
||||
to the software ends automatically.
|
||||
|
||||
(C) If you distribute any portion of the software, you must retain all
|
||||
copyright, patent, trademark, and attribution notices that are present in the
|
||||
software.
|
||||
|
||||
(D) If you distribute any portion of the software in source code form, you may
|
||||
do so only under this license by including a complete copy of this license with
|
||||
your distribution. If you distribute any portion of the software in compiled or
|
||||
object code form, you may only do so under a license that complies with this
|
||||
license.
|
||||
|
||||
(E) The software is licensed "as-is." You bear the risk of using it. The
|
||||
contributors give no express warranties, guarantees or conditions. You may have
|
||||
additional consumer rights under your local laws which this license cannot
|
||||
change. To the extent permitted under your local laws, the contributors exclude
|
||||
the implied warranties of merchantability, fitness for a particular purpose and
|
||||
non-infringement.
|
||||
*/
|
||||
#endregion License
|
||||
|
||||
|
||||
#region Using Statements
|
||||
using System;
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Net;
|
||||
#endregion Statements
|
||||
|
||||
namespace Microsoft.Xna.Framework.GamerServices {
|
||||
|
||||
public class GamerServicesComponent : GameComponent {
|
||||
private static LocalNetworkGamer lng;
|
||||
|
||||
internal static LocalNetworkGamer LocalNetworkGamer { get { return lng; } set { lng = value; } }
|
||||
|
||||
public GamerServicesComponent(Game game)
|
||||
: base(game)
|
||||
{
|
||||
Guide.Initialise(game);
|
||||
}
|
||||
|
||||
public override void Update (GameTime gameTime)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public class MonoGameGamerServicesComponent : GamerServicesComponent
|
||||
{
|
||||
public MonoGameGamerServicesComponent(Game game): base (game)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
-69
@@ -1,69 +0,0 @@
|
||||
#region License
|
||||
/*
|
||||
Microsoft Public License (Ms-PL)
|
||||
MonoGame - Copyright © 2009 The MonoGame Team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
This license governs use of the accompanying software. If you use the software, you accept this license. If you do not
|
||||
accept the license, do not use the software.
|
||||
|
||||
1. Definitions
|
||||
The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under
|
||||
U.S. copyright law.
|
||||
|
||||
A "contribution" is the original software, or any additions or changes to the software.
|
||||
A "contributor" is any person that distributes its contribution under this license.
|
||||
"Licensed patents" are a contributor's patent claims that read directly on its contribution.
|
||||
|
||||
2. Grant of Rights
|
||||
(A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
|
||||
each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create.
|
||||
(B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
|
||||
each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software.
|
||||
|
||||
3. Conditions and Limitations
|
||||
(A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.
|
||||
(B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software,
|
||||
your patent license from such contributor to the software ends automatically.
|
||||
(C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution
|
||||
notices that are present in the software.
|
||||
(D) If you distribute any portion of the software in source code form, you may do so only under this license by including
|
||||
a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object
|
||||
code form, you may only do so under a license that complies with this license.
|
||||
(E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees
|
||||
or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent
|
||||
permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular
|
||||
purpose and non-infringement.
|
||||
*/
|
||||
#endregion License
|
||||
|
||||
using System;
|
||||
|
||||
namespace Microsoft.Xna.Framework.GamerServices
|
||||
{
|
||||
public static class GamerServicesDispatcher
|
||||
{
|
||||
/*
|
||||
public static void Initialize ( IServiceProvider serviceProvider )
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
*/
|
||||
|
||||
public static void Update ()
|
||||
{
|
||||
}
|
||||
|
||||
public static bool IsInitialized { get { return false; } }
|
||||
|
||||
public static IntPtr WindowHandle { get; set; }
|
||||
|
||||
public static event EventHandler<EventArgs> InstallingTitleUpdate;
|
||||
|
||||
private static bool SuppressEventHandlerWarningsUntilEventsAreProperlyImplemented()
|
||||
{
|
||||
return InstallingTitleUpdate != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
#region License
|
||||
/*
|
||||
Microsoft Public License (Ms-PL)
|
||||
MonoGame - Copyright © 2009 The MonoGame Team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
This license governs use of the accompanying software. If you use the software, you accept this license. If you do not
|
||||
accept the license, do not use the software.
|
||||
|
||||
1. Definitions
|
||||
The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under
|
||||
U.S. copyright law.
|
||||
|
||||
A "contribution" is the original software, or any additions or changes to the software.
|
||||
A "contributor" is any person that distributes its contribution under this license.
|
||||
"Licensed patents" are a contributor's patent claims that read directly on its contribution.
|
||||
|
||||
2. Grant of Rights
|
||||
(A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
|
||||
each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create.
|
||||
(B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
|
||||
each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software.
|
||||
|
||||
3. Conditions and Limitations
|
||||
(A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.
|
||||
(B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software,
|
||||
your patent license from such contributor to the software ends automatically.
|
||||
(C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution
|
||||
notices that are present in the software.
|
||||
(D) If you distribute any portion of the software in source code form, you may do so only under this license by including
|
||||
a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object
|
||||
code form, you may only do so under a license that complies with this license.
|
||||
(E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees
|
||||
or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent
|
||||
permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular
|
||||
purpose and non-infringement.
|
||||
*/
|
||||
#endregion License
|
||||
|
||||
#region Using Statements
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Microsoft.Xna.Framework.GamerServices
|
||||
{
|
||||
public enum GamerZone
|
||||
{
|
||||
Family, // Family-friendly game play.
|
||||
Pro, // Competitive game play.
|
||||
Recreation, // Non-competitive game play.
|
||||
Underground, // Alternative approach to game play.
|
||||
Unknown, // Unknown.
|
||||
}
|
||||
}
|
||||
-64
@@ -1,64 +0,0 @@
|
||||
#region License
|
||||
// /*
|
||||
// Microsoft Public License (Ms-PL)
|
||||
// MonoGame - Copyright © 2009 The MonoGame Team
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
// This license governs use of the accompanying software. If you use the software, you accept this license. If you do not
|
||||
// accept the license, do not use the software.
|
||||
//
|
||||
// 1. Definitions
|
||||
// The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under
|
||||
// U.S. copyright law.
|
||||
//
|
||||
// A "contribution" is the original software, or any additions or changes to the software.
|
||||
// A "contributor" is any person that distributes its contribution under this license.
|
||||
// "Licensed patents" are a contributor's patent claims that read directly on its contribution.
|
||||
//
|
||||
// 2. Grant of Rights
|
||||
// (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
|
||||
// each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create.
|
||||
// (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
|
||||
// each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software.
|
||||
//
|
||||
// 3. Conditions and Limitations
|
||||
// (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.
|
||||
// (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software,
|
||||
// your patent license from such contributor to the software ends automatically.
|
||||
// (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution
|
||||
// notices that are present in the software.
|
||||
// (D) If you distribute any portion of the software in source code form, you may do so only under this license by including
|
||||
// a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object
|
||||
// code form, you may only do so under a license that complies with this license.
|
||||
// (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees
|
||||
// or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent
|
||||
// permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular
|
||||
// purpose and non-infringement.
|
||||
// */
|
||||
#endregion License
|
||||
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Microsoft.Xna.Framework.GamerServices
|
||||
{
|
||||
[DataContract]
|
||||
public class GuideAlreadyVisibleException : Exception
|
||||
{
|
||||
|
||||
public GuideAlreadyVisibleException ()
|
||||
{
|
||||
}
|
||||
|
||||
public GuideAlreadyVisibleException( string message )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public GuideAlreadyVisibleException(string message, Exception innerException)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Microsoft.Xna.Framework.GamerServices
|
||||
{
|
||||
[DataContract]
|
||||
public sealed class LeaderboardEntry
|
||||
{
|
||||
|
||||
[DataMember]
|
||||
public long Rating { get; set; }
|
||||
|
||||
[DataMember]
|
||||
public PropertyDictionary Columns { get; internal set; }
|
||||
|
||||
[DataMember]
|
||||
public Gamer Gamer { get; internal set; }
|
||||
|
||||
public LeaderboardEntry ()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-26
@@ -1,26 +0,0 @@
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Microsoft.Xna.Framework.GamerServices
|
||||
{
|
||||
[DataContract]
|
||||
public struct LeaderboardIdentity
|
||||
{
|
||||
[DataMember]
|
||||
public int GameMode { get; set; }
|
||||
|
||||
[DataMember]
|
||||
public LeaderboardKey Key { get; set; }
|
||||
|
||||
public static LeaderboardIdentity Create(LeaderboardKey aKey)
|
||||
{
|
||||
return new LeaderboardIdentity() { Key = aKey};
|
||||
}
|
||||
|
||||
public static LeaderboardIdentity Create(LeaderboardKey aKey, int aGameMode)
|
||||
{
|
||||
return new LeaderboardIdentity() { Key = aKey, GameMode = aGameMode};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace Microsoft.Xna.Framework.GamerServices
|
||||
{
|
||||
public enum LeaderboardKey
|
||||
{
|
||||
BestScoreLifeTime,
|
||||
BestScoreRecent,
|
||||
BestTimeLifeTime,
|
||||
BestTimeRecent,
|
||||
}
|
||||
}
|
||||
|
||||
-79
@@ -1,79 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Microsoft.Xna.Framework.GamerServices
|
||||
{
|
||||
public sealed class LeaderboardReader : IDisposable
|
||||
{
|
||||
public LeaderboardReader ()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
public IAsyncResult BeginPageDown(AsyncCallback aAsyncCallback, object aAsyncState)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public IAsyncResult BeginPageUp(AsyncCallback aAsyncCallback, object aAsyncState)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public LeaderboardReader EndPageDown(IAsyncResult result)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public LeaderboardReader EndPageUp(IAsyncResult result)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public static void BeginRead (LeaderboardIdentity id, SignedInGamer gamer, int leaderboardPageSize, AsyncCallback leaderboardReadCallback, SignedInGamer gamer2)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public static LeaderboardReader EndRead(IAsyncResult result)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public void PageDown()
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public void PageUp()
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
*/
|
||||
|
||||
public bool CanPageDown {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public bool CanPageUp {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public IEnumerable<LeaderboardEntry> Entries {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
#region IDisposable implementation
|
||||
|
||||
public void Dispose ()
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
-28
@@ -1,28 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace Microsoft.Xna.Framework.GamerServices
|
||||
{
|
||||
public sealed class LeaderboardWriter : IDisposable
|
||||
{
|
||||
public LeaderboardWriter ()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
public LeaderboardEntry GetLeaderboard(LeaderboardIdentity aLeaderboardIdentity)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
*/
|
||||
|
||||
#region IDisposable implementation
|
||||
|
||||
void IDisposable.Dispose ()
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
// #region License
|
||||
// /*
|
||||
// Microsoft Public License (Ms-PL)
|
||||
// MonoGame - Copyright © 2009 The MonoGame Team
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
// This license governs use of the accompanying software. If you use the software, you accept this license. If you do not
|
||||
// accept the license, do not use the software.
|
||||
//
|
||||
// 1. Definitions
|
||||
// The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under
|
||||
// U.S. copyright law.
|
||||
//
|
||||
// A "contribution" is the original software, or any additions or changes to the software.
|
||||
// A "contributor" is any person that distributes its contribution under this license.
|
||||
// "Licensed patents" are a contributor's patent claims that read directly on its contribution.
|
||||
//
|
||||
// 2. Grant of Rights
|
||||
// (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
|
||||
// each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create.
|
||||
// (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
|
||||
// each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software.
|
||||
//
|
||||
// 3. Conditions and Limitations
|
||||
// (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.
|
||||
// (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software,
|
||||
// your patent license from such contributor to the software ends automatically.
|
||||
// (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution
|
||||
// notices that are present in the software.
|
||||
// (D) If you distribute any portion of the software in source code form, you may do so only under this license by including
|
||||
// a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object
|
||||
// code form, you may only do so under a license that complies with this license.
|
||||
// (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees
|
||||
// or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent
|
||||
// permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular
|
||||
// purpose and non-infringement.
|
||||
// */
|
||||
// #endregion License
|
||||
//
|
||||
using System;
|
||||
namespace Microsoft.Xna.Framework.GamerServices
|
||||
{
|
||||
public enum MessageBoxIcon
|
||||
{
|
||||
Alert, // Displays the Alert icon.
|
||||
Error, // Displays the Error icon.
|
||||
None, // No icon is displayed.
|
||||
Warning, // Displays the Warning icon.
|
||||
}
|
||||
}
|
||||
|
||||
-83
@@ -1,83 +0,0 @@
|
||||
#region License
|
||||
/*
|
||||
Microsoft Public License (Ms-PL)
|
||||
MonoGame - Copyright © 2009-2012 The MonoGame Team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
This license governs use of the accompanying software. If you use the software,
|
||||
you accept this license. If you do not accept the license, do not use the
|
||||
software.
|
||||
|
||||
1. Definitions
|
||||
|
||||
The terms "reproduce," "reproduction," "derivative works," and "distribution"
|
||||
have the same meaning here as under U.S. copyright law.
|
||||
|
||||
A "contribution" is the original software, or any additions or changes to the
|
||||
software.
|
||||
|
||||
A "contributor" is any person that distributes its contribution under this
|
||||
license.
|
||||
|
||||
"Licensed patents" are a contributor's patent claims that read directly on its
|
||||
contribution.
|
||||
|
||||
2. Grant of Rights
|
||||
|
||||
(A) Copyright Grant- Subject to the terms of this license, including the
|
||||
license conditions and limitations in section 3, each contributor grants you a
|
||||
non-exclusive, worldwide, royalty-free copyright license to reproduce its
|
||||
contribution, prepare derivative works of its contribution, and distribute its
|
||||
contribution or any derivative works that you create.
|
||||
|
||||
(B) Patent Grant- Subject to the terms of this license, including the license
|
||||
conditions and limitations in section 3, each contributor grants you a
|
||||
non-exclusive, worldwide, royalty-free license under its licensed patents to
|
||||
make, have made, use, sell, offer for sale, import, and/or otherwise dispose of
|
||||
its contribution in the software or derivative works of the contribution in the
|
||||
software.
|
||||
|
||||
3. Conditions and Limitations
|
||||
|
||||
(A) No Trademark License- This license does not grant you rights to use any
|
||||
contributors' name, logo, or trademarks.
|
||||
|
||||
(B) If you bring a patent claim against any contributor over patents that you
|
||||
claim are infringed by the software, your patent license from such contributor
|
||||
to the software ends automatically.
|
||||
|
||||
(C) If you distribute any portion of the software, you must retain all
|
||||
copyright, patent, trademark, and attribution notices that are present in the
|
||||
software.
|
||||
|
||||
(D) If you distribute any portion of the software in source code form, you may
|
||||
do so only under this license by including a complete copy of this license with
|
||||
your distribution. If you distribute any portion of the software in compiled or
|
||||
object code form, you may only do so under a license that complies with this
|
||||
license.
|
||||
|
||||
(E) The software is licensed "as-is." You bear the risk of using it. The
|
||||
contributors give no express warranties, guarantees or conditions. You may have
|
||||
additional consumer rights under your local laws which this license cannot
|
||||
change. To the extent permitted under your local laws, the contributors exclude
|
||||
the implied warranties of merchantability, fitness for a particular purpose and
|
||||
non-infringement.
|
||||
*/
|
||||
#endregion License
|
||||
|
||||
using System;
|
||||
|
||||
namespace Microsoft.Xna.Framework.GamerServices {
|
||||
public enum NotificationPosition {
|
||||
TopLeft,
|
||||
TopCenter,
|
||||
TopRight,
|
||||
CenterLeft,
|
||||
Center,
|
||||
CenterRight,
|
||||
BottomLeft,
|
||||
BottomCenter,
|
||||
BottomRight
|
||||
}
|
||||
}
|
||||
-33
@@ -1,33 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Microsoft.Xna.Framework.GamerServices
|
||||
{
|
||||
public class PropertyDictionary
|
||||
{
|
||||
private Dictionary<string,object> PropDictionary = new Dictionary<string, object>();
|
||||
public int GetValueInt32 (string aKey)
|
||||
{
|
||||
return (int)PropDictionary[aKey];
|
||||
}
|
||||
|
||||
public DateTime GetValueDateTime (string aKey)
|
||||
{
|
||||
return (DateTime)PropDictionary[aKey];
|
||||
}
|
||||
|
||||
public void SetValue(string aKey, DateTime aValue)
|
||||
{
|
||||
if(PropDictionary.ContainsKey(aKey))
|
||||
{
|
||||
PropDictionary[aKey] = aValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
PropDictionary.Add(aKey,aValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
-61
@@ -1,61 +0,0 @@
|
||||
#region License
|
||||
/*
|
||||
Microsoft Public License (Ms-PL)
|
||||
MonoGame - Copyright © 2009 The MonoGame Team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
This license governs use of the accompanying software. If you use the software, you accept this license. If you do not
|
||||
accept the license, do not use the software.
|
||||
|
||||
1. Definitions
|
||||
The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under
|
||||
U.S. copyright law.
|
||||
|
||||
A "contribution" is the original software, or any additions or changes to the software.
|
||||
A "contributor" is any person that distributes its contribution under this license.
|
||||
"Licensed patents" are a contributor's patent claims that read directly on its contribution.
|
||||
|
||||
2. Grant of Rights
|
||||
(A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
|
||||
each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create.
|
||||
(B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
|
||||
each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software.
|
||||
|
||||
3. Conditions and Limitations
|
||||
(A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.
|
||||
(B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software,
|
||||
your patent license from such contributor to the software ends automatically.
|
||||
(C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution
|
||||
notices that are present in the software.
|
||||
(D) If you distribute any portion of the software in source code form, you may do so only under this license by including
|
||||
a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object
|
||||
code form, you may only do so under a license that complies with this license.
|
||||
(E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees
|
||||
or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent
|
||||
permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular
|
||||
purpose and non-infringement.
|
||||
*/
|
||||
#endregion License
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Microsoft.Xna.Framework.GamerServices
|
||||
{
|
||||
public class SignedInGamerCollection : List<SignedInGamer>
|
||||
{
|
||||
#region Properties
|
||||
// Indexer to get and set words of the containing document:
|
||||
public SignedInGamer this [PlayerIndex index] {
|
||||
get {
|
||||
if (this.Count == 0 || (int)index > this.Count - 1)
|
||||
return null;
|
||||
|
||||
return this [(int)index];
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
// This file is subject to the terms and conditions defined in
|
||||
// file 'LICENSE.txt', which is part of this source code package.
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using MonoGame.Utilities;
|
||||
|
||||
|
||||
@@ -353,6 +353,15 @@ namespace Microsoft.Xna.Framework.Graphics
|
||||
_bufferBindingInfos = new BufferBindingInfo[_maxVertexBufferSlots];
|
||||
for (int i = 0; i < _bufferBindingInfos.Length; i++)
|
||||
_bufferBindingInfos[i] = new BufferBindingInfo(null, IntPtr.Zero, 0, -1);
|
||||
|
||||
Clear(Color.Black);
|
||||
PlatformPresent();
|
||||
}
|
||||
|
||||
partial void PlatformReset()
|
||||
{
|
||||
Clear(Color.Black);
|
||||
PlatformPresent();
|
||||
}
|
||||
|
||||
private DepthStencilState clearDepthStencilState = new DepthStencilState { StencilEnable = true };
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace Microsoft.Xna.Framework.Graphics
|
||||
private bool _blendStateDirty;
|
||||
|
||||
private BlendState _blendStateAdditive;
|
||||
private BlendState _blendStateAlphaBlend;
|
||||
//private BlendState _blendStateAlphaBlend;
|
||||
private BlendState _blendStateNonPremultiplied;
|
||||
private BlendState _blendStateOpaque;
|
||||
|
||||
@@ -74,7 +74,8 @@ namespace Microsoft.Xna.Framework.Graphics
|
||||
// Despite XNA4 using Purple here, we use black (in Release) to avoid
|
||||
// performance warnings on Intel/Mesa
|
||||
#if DEBUG
|
||||
private static readonly Color DiscardColor = new Color(68, 34, 136, 255);
|
||||
// Replicating XNA behavior stopped mattering ages ago
|
||||
private static readonly Color DiscardColor = new Color(0, 0, 0, 255); //new Color(68, 34, 136, 255);
|
||||
#else
|
||||
private static readonly Color DiscardColor = new Color(0, 0, 0, 255);
|
||||
#endif
|
||||
@@ -252,7 +253,7 @@ namespace Microsoft.Xna.Framework.Graphics
|
||||
SamplerStates = new SamplerStateCollection(this, MaxTextureSlots, false);
|
||||
|
||||
_blendStateAdditive = BlendState.Additive.Clone();
|
||||
_blendStateAlphaBlend = BlendState.AlphaBlend.Clone();
|
||||
//_blendStateAlphaBlend = BlendState.AlphaBlend.Clone();
|
||||
_blendStateNonPremultiplied = BlendState.NonPremultiplied.Clone();
|
||||
_blendStateOpaque = BlendState.Opaque.Clone();
|
||||
|
||||
@@ -414,8 +415,8 @@ namespace Microsoft.Xna.Framework.Graphics
|
||||
var newBlendState = _blendState;
|
||||
if (ReferenceEquals(_blendState, BlendState.Additive))
|
||||
newBlendState = _blendStateAdditive;
|
||||
else if (ReferenceEquals(_blendState, BlendState.AlphaBlend))
|
||||
newBlendState = _blendStateAlphaBlend;
|
||||
/*else if (ReferenceEquals(_blendState, BlendState.AlphaBlend))
|
||||
newBlendState = _blendStateAlphaBlend;*/
|
||||
else if (ReferenceEquals(_blendState, BlendState.NonPremultiplied))
|
||||
newBlendState = _blendStateNonPremultiplied;
|
||||
else if (ReferenceEquals(_blendState, BlendState.Opaque))
|
||||
@@ -549,7 +550,7 @@ namespace Microsoft.Xna.Framework.Graphics
|
||||
_blendState = null;
|
||||
_actualBlendState = null;
|
||||
_blendStateAdditive.Dispose();
|
||||
_blendStateAlphaBlend.Dispose();
|
||||
//_blendStateAlphaBlend.Dispose();
|
||||
_blendStateNonPremultiplied.Dispose();
|
||||
_blendStateOpaque.Dispose();
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace Microsoft.Xna.Framework.Graphics
|
||||
/// Begins a new sprite and text batch with the specified render state.
|
||||
/// </summary>
|
||||
/// <param name="sortMode">The drawing order for sprite and text drawing. <see cref="SpriteSortMode.Deferred"/> by default.</param>
|
||||
/// <param name="blendState">State of the blending. Uses <see cref="BlendState.AlphaBlend"/> if null.</param>
|
||||
/// <param name="blendState">State of the blending. Uses <see cref="BlendState.NonPremultiplied"/> if null.</param>
|
||||
/// <param name="samplerState">State of the sampler. Uses <see cref="SamplerState.LinearClamp"/> if null.</param>
|
||||
/// <param name="depthStencilState">State of the depth-stencil buffer. Uses <see cref="DepthStencilState.None"/> if null.</param>
|
||||
/// <param name="rasterizerState">State of the rasterization. Uses <see cref="RasterizerState.CullCounterClockwise"/> if null.</param>
|
||||
@@ -90,7 +90,7 @@ namespace Microsoft.Xna.Framework.Graphics
|
||||
|
||||
// defaults
|
||||
_sortMode = sortMode;
|
||||
_blendState = blendState ?? BlendState.AlphaBlend;
|
||||
_blendState = blendState ?? BlendState.NonPremultiplied;
|
||||
_samplerState = samplerState ?? SamplerState.LinearClamp;
|
||||
_depthStencilState = depthStencilState ?? DepthStencilState.None;
|
||||
_rasterizerState = rasterizerState ?? RasterizerState.CullCounterClockwise;
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace Microsoft.Xna.Framework.Graphics
|
||||
/// <summary>
|
||||
/// No options specified.
|
||||
/// </summary>
|
||||
None = 0,
|
||||
None = 0,
|
||||
/// <summary>
|
||||
/// Render the sprite reversed along the X axis.
|
||||
/// </summary>
|
||||
|
||||
@@ -187,7 +187,7 @@ namespace Microsoft.Xna.Framework.Graphics
|
||||
|
||||
|
||||
public static readonly BlendState Additive;
|
||||
public static readonly BlendState AlphaBlend;
|
||||
//public static readonly BlendState AlphaBlend;
|
||||
public static readonly BlendState NonPremultiplied;
|
||||
public static readonly BlendState Opaque;
|
||||
|
||||
@@ -204,14 +204,14 @@ namespace Microsoft.Xna.Framework.Graphics
|
||||
_independentBlendEnable = false;
|
||||
}
|
||||
|
||||
private BlendState(string name, Blend sourceBlend, Blend destinationBlend)
|
||||
private BlendState(string name, Blend sourceBlend, Blend destinationBlend, Blend? srcAlphaBlend = null, Blend? destAlphaBlend = null)
|
||||
: this()
|
||||
{
|
||||
Name = name;
|
||||
ColorSourceBlend = sourceBlend;
|
||||
AlphaSourceBlend = sourceBlend;
|
||||
AlphaSourceBlend = srcAlphaBlend ?? sourceBlend;
|
||||
ColorDestinationBlend = destinationBlend;
|
||||
AlphaDestinationBlend = destinationBlend;
|
||||
AlphaDestinationBlend = destAlphaBlend ?? destinationBlend;
|
||||
_defaultStateObject = true;
|
||||
}
|
||||
|
||||
@@ -233,8 +233,8 @@ namespace Microsoft.Xna.Framework.Graphics
|
||||
static BlendState()
|
||||
{
|
||||
Additive = new BlendState("BlendState.Additive", Blend.SourceAlpha, Blend.One);
|
||||
AlphaBlend = new BlendState("BlendState.AlphaBlend", Blend.One, Blend.InverseSourceAlpha);
|
||||
NonPremultiplied = new BlendState("BlendState.NonPremultiplied", Blend.SourceAlpha, Blend.InverseSourceAlpha);
|
||||
//AlphaBlend = new BlendState("BlendState.AlphaBlend", Blend.One, Blend.InverseSourceAlpha);
|
||||
NonPremultiplied = new BlendState("BlendState.NonPremultiplied", Blend.SourceAlpha, Blend.InverseSourceAlpha, Blend.One, Blend.InverseSourceAlpha);
|
||||
Opaque = new BlendState("BlendState.Opaque", Blend.One, Blend.Zero);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,633 +0,0 @@
|
||||
// MonoGame - Copyright (C) The MonoGame Team
|
||||
// This file is subject to the terms and conditions defined in
|
||||
// file 'LICENSE.txt', which is part of this source code package.
|
||||
|
||||
using System;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Microsoft.Xna.Framework.Input.Touch;
|
||||
|
||||
#if WINDOWS_UAP
|
||||
using Windows.UI.Xaml.Controls;
|
||||
#endif
|
||||
|
||||
#if ANDROID
|
||||
using Android.Views;
|
||||
#endif
|
||||
|
||||
namespace Microsoft.Xna.Framework
|
||||
{
|
||||
public class GraphicsDeviceManager : IGraphicsDeviceService, IDisposable, IGraphicsDeviceManager
|
||||
{
|
||||
private Game _game;
|
||||
private GraphicsDevice _graphicsDevice;
|
||||
private int _preferredBackBufferHeight;
|
||||
private int _preferredBackBufferWidth;
|
||||
private SurfaceFormat _preferredBackBufferFormat;
|
||||
private DepthFormat _preferredDepthStencilFormat;
|
||||
private bool _preferMultiSampling;
|
||||
private DisplayOrientation _supportedOrientations;
|
||||
private bool _synchronizedWithVerticalRetrace = true;
|
||||
private bool _drawBegun;
|
||||
bool disposed;
|
||||
private bool _hardwareModeSwitch = true;
|
||||
|
||||
#if (WINDOWS || WINDOWS_UAP) && DIRECTX
|
||||
private bool _firstLaunch = true;
|
||||
#endif
|
||||
|
||||
#if !WINRT || WINDOWS_UAP
|
||||
private bool _wantFullScreen = false;
|
||||
#endif
|
||||
public static readonly int DefaultBackBufferHeight = 480;
|
||||
public static readonly int DefaultBackBufferWidth = 800;
|
||||
|
||||
public GraphicsDeviceManager(Game game)
|
||||
{
|
||||
if (game == null)
|
||||
throw new ArgumentNullException("The game cannot be null!");
|
||||
|
||||
_game = game;
|
||||
|
||||
_supportedOrientations = DisplayOrientation.Default;
|
||||
|
||||
#if WINDOWS || MONOMAC || DESKTOPGL
|
||||
_preferredBackBufferHeight = DefaultBackBufferHeight;
|
||||
_preferredBackBufferWidth = DefaultBackBufferWidth;
|
||||
#else
|
||||
// Preferred buffer width/height is used to determine default supported orientations,
|
||||
// so set the default values to match Xna behaviour of landscape only by default.
|
||||
// Note also that it's using the device window dimensions.
|
||||
_preferredBackBufferWidth = Math.Max(_game.Window.ClientBounds.Height, _game.Window.ClientBounds.Width);
|
||||
_preferredBackBufferHeight = Math.Min(_game.Window.ClientBounds.Height, _game.Window.ClientBounds.Width);
|
||||
#endif
|
||||
|
||||
_preferredBackBufferFormat = SurfaceFormat.Color;
|
||||
_preferredDepthStencilFormat = DepthFormat.Depth24;
|
||||
_synchronizedWithVerticalRetrace = true;
|
||||
|
||||
// XNA would read this from the manifest, but it would always default
|
||||
// to Reach unless changed. So lets mimic that without the manifest bit.
|
||||
GraphicsProfile = GraphicsProfile.Reach;
|
||||
|
||||
if (_game.Services.GetService(typeof(IGraphicsDeviceManager)) != null)
|
||||
throw new ArgumentException("Graphics Device Manager Already Present");
|
||||
|
||||
_game.Services.AddService(typeof(IGraphicsDeviceManager), this);
|
||||
_game.Services.AddService(typeof(IGraphicsDeviceService), this);
|
||||
}
|
||||
|
||||
~GraphicsDeviceManager()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
public void CreateDevice()
|
||||
{
|
||||
Initialize();
|
||||
|
||||
OnDeviceCreated(EventArgs.Empty);
|
||||
}
|
||||
|
||||
public bool BeginDraw()
|
||||
{
|
||||
if (_graphicsDevice == null)
|
||||
return false;
|
||||
|
||||
_drawBegun = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
public void EndDraw()
|
||||
{
|
||||
if (_graphicsDevice != null && _drawBegun)
|
||||
{
|
||||
_drawBegun = false;
|
||||
_graphicsDevice.Present();
|
||||
}
|
||||
}
|
||||
|
||||
#region IGraphicsDeviceService Members
|
||||
|
||||
public event EventHandler<EventArgs> DeviceCreated;
|
||||
public event EventHandler<EventArgs> DeviceDisposing;
|
||||
public event EventHandler<EventArgs> DeviceReset;
|
||||
public event EventHandler<EventArgs> DeviceResetting;
|
||||
public event EventHandler<PreparingDeviceSettingsEventArgs> PreparingDeviceSettings;
|
||||
|
||||
// FIXME: Why does the GraphicsDeviceManager not know enough about the
|
||||
// GraphicsDevice to raise these events without help?
|
||||
internal void OnDeviceDisposing(EventArgs e)
|
||||
{
|
||||
EventHelpers.Raise(this, DeviceDisposing, e);
|
||||
}
|
||||
|
||||
// FIXME: Why does the GraphicsDeviceManager not know enough about the
|
||||
// GraphicsDevice to raise these events without help?
|
||||
internal void OnDeviceResetting(EventArgs e)
|
||||
{
|
||||
EventHelpers.Raise(this, DeviceResetting, e);
|
||||
}
|
||||
|
||||
// FIXME: Why does the GraphicsDeviceManager not know enough about the
|
||||
// GraphicsDevice to raise these events without help?
|
||||
internal void OnDeviceReset(EventArgs e)
|
||||
{
|
||||
EventHelpers.Raise(this, DeviceReset, e);
|
||||
}
|
||||
|
||||
// FIXME: Why does the GraphicsDeviceManager not know enough about the
|
||||
// GraphicsDevice to raise these events without help?
|
||||
internal void OnDeviceCreated(EventArgs e)
|
||||
{
|
||||
EventHelpers.Raise(this, DeviceCreated, e);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IDisposable Members
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (!disposed)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
if (_graphicsDevice != null)
|
||||
{
|
||||
_graphicsDevice.Dispose();
|
||||
_graphicsDevice = null;
|
||||
}
|
||||
}
|
||||
disposed = true;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public void ApplyChanges()
|
||||
{
|
||||
// Calling ApplyChanges() before CreateDevice() should have no effect
|
||||
if (_graphicsDevice == null)
|
||||
return;
|
||||
|
||||
#if WINDOWS_UAP
|
||||
|
||||
// TODO: Does this need to occur here?
|
||||
_game.Window.SetSupportedOrientations(_supportedOrientations);
|
||||
|
||||
_graphicsDevice.PresentationParameters.BackBufferFormat = _preferredBackBufferFormat;
|
||||
_graphicsDevice.PresentationParameters.BackBufferWidth = _preferredBackBufferWidth;
|
||||
_graphicsDevice.PresentationParameters.BackBufferHeight = _preferredBackBufferHeight;
|
||||
_graphicsDevice.PresentationParameters.DepthStencilFormat = _preferredDepthStencilFormat;
|
||||
|
||||
// TODO: We probably should be resetting the whole device
|
||||
// if this changes as we are targeting a different
|
||||
// hardware feature level.
|
||||
_graphicsDevice.GraphicsProfile = GraphicsProfile;
|
||||
|
||||
#if WINDOWS_UAP
|
||||
_graphicsDevice.PresentationParameters.DeviceWindowHandle = IntPtr.Zero;
|
||||
_graphicsDevice.PresentationParameters.SwapChainPanel = this.SwapChainPanel;
|
||||
_graphicsDevice.PresentationParameters.IsFullScreen = _wantFullScreen;
|
||||
#else
|
||||
_graphicsDevice.PresentationParameters.IsFullScreen = false;
|
||||
|
||||
// The graphics device can use a XAML panel or a window
|
||||
// to created the default swapchain target.
|
||||
if (this.SwapChainBackgroundPanel != null)
|
||||
{
|
||||
_graphicsDevice.PresentationParameters.DeviceWindowHandle = IntPtr.Zero;
|
||||
_graphicsDevice.PresentationParameters.SwapChainBackgroundPanel = this.SwapChainBackgroundPanel;
|
||||
}
|
||||
else
|
||||
{
|
||||
_graphicsDevice.PresentationParameters.DeviceWindowHandle = _game.Window.Handle;
|
||||
_graphicsDevice.PresentationParameters.SwapChainBackgroundPanel = null;
|
||||
}
|
||||
#endif
|
||||
// Update the back buffer.
|
||||
_graphicsDevice.CreateSizeDependentResources();
|
||||
_graphicsDevice.ApplyRenderTargets(null);
|
||||
|
||||
#if WINDOWS_UAP
|
||||
((UAPGameWindow)_game.Window).SetClientSize(_preferredBackBufferWidth, _preferredBackBufferHeight);
|
||||
#endif
|
||||
|
||||
#elif WINDOWS && DIRECTX
|
||||
|
||||
_graphicsDevice.PresentationParameters.BackBufferFormat = _preferredBackBufferFormat;
|
||||
_graphicsDevice.PresentationParameters.BackBufferWidth = _preferredBackBufferWidth;
|
||||
_graphicsDevice.PresentationParameters.BackBufferHeight = _preferredBackBufferHeight;
|
||||
_graphicsDevice.PresentationParameters.DepthStencilFormat = _preferredDepthStencilFormat;
|
||||
_graphicsDevice.PresentationParameters.PresentationInterval = _synchronizedWithVerticalRetrace ? PresentInterval.Default : PresentInterval.Immediate;
|
||||
_graphicsDevice.PresentationParameters.IsFullScreen = _wantFullScreen;
|
||||
|
||||
// TODO: We probably should be resetting the whole
|
||||
// device if this changes as we are targeting a different
|
||||
// hardware feature level.
|
||||
_graphicsDevice.GraphicsProfile = GraphicsProfile;
|
||||
|
||||
_graphicsDevice.PresentationParameters.DeviceWindowHandle = _game.Window.Handle;
|
||||
|
||||
// Update the back buffer.
|
||||
_graphicsDevice.CreateSizeDependentResources();
|
||||
_graphicsDevice.ApplyRenderTargets(null);
|
||||
|
||||
((MonoGame.Framework.WinFormsGamePlatform)_game.Platform).ResetWindowBounds();
|
||||
|
||||
#elif DESKTOPGL
|
||||
var displayIndex = Sdl.Window.GetDisplayIndex (SdlGameWindow.Instance.Handle);
|
||||
var displayName = Sdl.Display.GetDisplayName (displayIndex);
|
||||
|
||||
_graphicsDevice.PresentationParameters.BackBufferFormat = _preferredBackBufferFormat;
|
||||
_graphicsDevice.PresentationParameters.BackBufferWidth = _preferredBackBufferWidth;
|
||||
_graphicsDevice.PresentationParameters.BackBufferHeight = _preferredBackBufferHeight;
|
||||
_graphicsDevice.PresentationParameters.DepthStencilFormat = _preferredDepthStencilFormat;
|
||||
_graphicsDevice.PresentationParameters.PresentationInterval = _synchronizedWithVerticalRetrace ? PresentInterval.Default : PresentInterval.Immediate;
|
||||
_graphicsDevice.PresentationParameters.IsFullScreen = _wantFullScreen;
|
||||
|
||||
//Set the swap interval based on if vsync is desired or not.
|
||||
//See GetSwapInterval for more details
|
||||
int swapInterval;
|
||||
if (_synchronizedWithVerticalRetrace)
|
||||
swapInterval = _graphicsDevice.PresentationParameters.PresentationInterval.GetSwapInterval();
|
||||
else
|
||||
swapInterval = 0;
|
||||
_graphicsDevice.Context.SwapInterval = swapInterval;
|
||||
|
||||
_graphicsDevice.ApplyRenderTargets (null);
|
||||
|
||||
_game.Platform.BeginScreenDeviceChange (GraphicsDevice.PresentationParameters.IsFullScreen);
|
||||
_game.Platform.EndScreenDeviceChange (displayName, GraphicsDevice.PresentationParameters.BackBufferWidth, GraphicsDevice.PresentationParameters.BackBufferHeight);
|
||||
|
||||
#elif MONOMAC
|
||||
_graphicsDevice.PresentationParameters.IsFullScreen = _wantFullScreen;
|
||||
|
||||
// TODO: Implement multisampling (aka anti-alising) for all platforms!
|
||||
|
||||
_game.applyChanges(this);
|
||||
#else
|
||||
|
||||
#if ANDROID
|
||||
// Trigger a change in orientation in case the supported orientations have changed
|
||||
((AndroidGameWindow)_game.Window).SetOrientation(_game.Window.CurrentOrientation, false);
|
||||
#endif
|
||||
// Ensure the presentation parameter orientation and buffer size matches the window
|
||||
_graphicsDevice.PresentationParameters.DisplayOrientation = _game.Window.CurrentOrientation;
|
||||
|
||||
// Set the presentation parameters' actual buffer size to match the orientation
|
||||
bool isLandscape = (0 != (_game.Window.CurrentOrientation & (DisplayOrientation.LandscapeLeft | DisplayOrientation.LandscapeRight)));
|
||||
int w = PreferredBackBufferWidth;
|
||||
int h = PreferredBackBufferHeight;
|
||||
|
||||
_graphicsDevice.PresentationParameters.BackBufferWidth = isLandscape ? Math.Max(w, h) : Math.Min(w, h);
|
||||
_graphicsDevice.PresentationParameters.BackBufferHeight = isLandscape ? Math.Min(w, h) : Math.Max(w, h);
|
||||
|
||||
ResetClientBounds();
|
||||
#endif
|
||||
|
||||
// Set the new display size on the touch panel.
|
||||
//
|
||||
// TODO: In XNA this seems to be done as part of the
|
||||
// GraphicsDevice.DeviceReset event... we need to get
|
||||
// those working.
|
||||
//
|
||||
TouchPanel.DisplayWidth = _graphicsDevice.PresentationParameters.BackBufferWidth;
|
||||
TouchPanel.DisplayHeight = _graphicsDevice.PresentationParameters.BackBufferHeight;
|
||||
|
||||
#if (WINDOWS || WINDOWS_UAP) && DIRECTX
|
||||
|
||||
if (!_firstLaunch)
|
||||
{
|
||||
if (IsFullScreen)
|
||||
{
|
||||
_game.Platform.EnterFullScreen();
|
||||
}
|
||||
else
|
||||
{
|
||||
_game.Platform.ExitFullScreen();
|
||||
}
|
||||
}
|
||||
_firstLaunch = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
private void Initialize()
|
||||
{
|
||||
var presentationParameters = new PresentationParameters();
|
||||
presentationParameters.DepthStencilFormat = DepthFormat.Depth24;
|
||||
|
||||
#if (WINDOWS || WINRT) && !DESKTOPGL
|
||||
_game.Window.SetSupportedOrientations(_supportedOrientations);
|
||||
|
||||
presentationParameters.BackBufferFormat = _preferredBackBufferFormat;
|
||||
presentationParameters.BackBufferWidth = _preferredBackBufferWidth;
|
||||
presentationParameters.BackBufferHeight = _preferredBackBufferHeight;
|
||||
presentationParameters.DepthStencilFormat = _preferredDepthStencilFormat;
|
||||
presentationParameters.IsFullScreen = false;
|
||||
|
||||
#if WINDOWS_UAP
|
||||
presentationParameters.DeviceWindowHandle = IntPtr.Zero;
|
||||
presentationParameters.SwapChainPanel = this.SwapChainPanel;
|
||||
#else
|
||||
presentationParameters.DeviceWindowHandle = _game.Window.Handle;
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
#if MONOMAC || DESKTOPGL
|
||||
presentationParameters.IsFullScreen = _wantFullScreen;
|
||||
#elif WEB
|
||||
presentationParameters.IsFullScreen = false;
|
||||
#else
|
||||
// Set "full screen" as default
|
||||
presentationParameters.IsFullScreen = true;
|
||||
#endif // MONOMAC
|
||||
|
||||
#endif // WINDOWS || WINRT
|
||||
|
||||
// TODO: Implement multisampling (aka anti-alising) for all platforms!
|
||||
var preparingDeviceSettingsHandler = PreparingDeviceSettings;
|
||||
|
||||
if (preparingDeviceSettingsHandler != null)
|
||||
{
|
||||
GraphicsDeviceInformation gdi = new GraphicsDeviceInformation();
|
||||
gdi.GraphicsProfile = GraphicsProfile; // Microsoft defaults this to Reach.
|
||||
gdi.Adapter = GraphicsAdapter.DefaultAdapter;
|
||||
gdi.PresentationParameters = presentationParameters;
|
||||
PreparingDeviceSettingsEventArgs pe = new PreparingDeviceSettingsEventArgs(gdi);
|
||||
preparingDeviceSettingsHandler(this, pe);
|
||||
presentationParameters = pe.GraphicsDeviceInformation.PresentationParameters;
|
||||
GraphicsProfile = pe.GraphicsDeviceInformation.GraphicsProfile;
|
||||
}
|
||||
|
||||
// Needs to be before ApplyChanges()
|
||||
_graphicsDevice = new GraphicsDevice(GraphicsAdapter.DefaultAdapter, GraphicsProfile, presentationParameters);
|
||||
|
||||
#if !MONOMAC
|
||||
ApplyChanges();
|
||||
#endif
|
||||
|
||||
// Set the new display size on the touch panel.
|
||||
//
|
||||
// TODO: In XNA this seems to be done as part of the
|
||||
// GraphicsDevice.DeviceReset event... we need to get
|
||||
// those working.
|
||||
//
|
||||
TouchPanel.DisplayWidth = _graphicsDevice.PresentationParameters.BackBufferWidth;
|
||||
TouchPanel.DisplayHeight = _graphicsDevice.PresentationParameters.BackBufferHeight;
|
||||
TouchPanel.DisplayOrientation = _graphicsDevice.PresentationParameters.DisplayOrientation;
|
||||
}
|
||||
|
||||
public void ToggleFullScreen()
|
||||
{
|
||||
IsFullScreen = !IsFullScreen;
|
||||
|
||||
#if ((WINDOWS || WINDOWS_UAP) && DIRECTX) || DESKTOPGL
|
||||
ApplyChanges();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#if WINDOWS_UAP
|
||||
[CLSCompliant(false)]
|
||||
public SwapChainPanel SwapChainPanel { get; set; }
|
||||
#endif
|
||||
|
||||
public GraphicsProfile GraphicsProfile { get; set; }
|
||||
|
||||
public GraphicsDevice GraphicsDevice
|
||||
{
|
||||
get
|
||||
{
|
||||
return _graphicsDevice;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsFullScreen
|
||||
{
|
||||
get
|
||||
{
|
||||
#if WINDOWS_UAP
|
||||
return _wantFullScreen;
|
||||
#elif WINRT
|
||||
return true;
|
||||
#else
|
||||
if (_graphicsDevice != null)
|
||||
return _graphicsDevice.PresentationParameters.IsFullScreen;
|
||||
return _wantFullScreen;
|
||||
#endif
|
||||
}
|
||||
set
|
||||
{
|
||||
#if WINDOWS_UAP
|
||||
_wantFullScreen = value;
|
||||
#elif WINRT
|
||||
// Just ignore this as it is not relevant on Windows 8
|
||||
#elif WINDOWS && DIRECTX
|
||||
_wantFullScreen = value;
|
||||
#else
|
||||
_wantFullScreen = value;
|
||||
if (_graphicsDevice != null)
|
||||
{
|
||||
_graphicsDevice.PresentationParameters.IsFullScreen = value;
|
||||
#if ANDROID
|
||||
ForceSetFullScreen();
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#if ANDROID
|
||||
internal void ForceSetFullScreen()
|
||||
{
|
||||
if (IsFullScreen)
|
||||
{
|
||||
Game.Activity.Window.ClearFlags(Android.Views.WindowManagerFlags.ForceNotFullscreen);
|
||||
Game.Activity.Window.SetFlags(WindowManagerFlags.Fullscreen, WindowManagerFlags.Fullscreen);
|
||||
}
|
||||
else
|
||||
Game.Activity.Window.SetFlags(WindowManagerFlags.ForceNotFullscreen, WindowManagerFlags.ForceNotFullscreen);
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the boolean which defines how window switches from windowed to fullscreen state.
|
||||
/// "Hard" mode(true) is slow to switch, but more effecient for performance, while "soft" mode(false) is vice versa.
|
||||
/// The default value is <c>true</c>.
|
||||
/// </summary>
|
||||
public bool HardwareModeSwitch
|
||||
{
|
||||
get { return _hardwareModeSwitch; }
|
||||
set
|
||||
{
|
||||
_hardwareModeSwitch = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool PreferMultiSampling
|
||||
{
|
||||
get
|
||||
{
|
||||
return _preferMultiSampling;
|
||||
}
|
||||
set
|
||||
{
|
||||
_preferMultiSampling = value;
|
||||
}
|
||||
}
|
||||
|
||||
public SurfaceFormat PreferredBackBufferFormat
|
||||
{
|
||||
get
|
||||
{
|
||||
return _preferredBackBufferFormat;
|
||||
}
|
||||
set
|
||||
{
|
||||
_preferredBackBufferFormat = value;
|
||||
}
|
||||
}
|
||||
|
||||
public int PreferredBackBufferHeight
|
||||
{
|
||||
get
|
||||
{
|
||||
return _preferredBackBufferHeight;
|
||||
}
|
||||
set
|
||||
{
|
||||
_preferredBackBufferHeight = value;
|
||||
}
|
||||
}
|
||||
|
||||
public int PreferredBackBufferWidth
|
||||
{
|
||||
get
|
||||
{
|
||||
return _preferredBackBufferWidth;
|
||||
}
|
||||
set
|
||||
{
|
||||
_preferredBackBufferWidth = value;
|
||||
}
|
||||
}
|
||||
|
||||
public DepthFormat PreferredDepthStencilFormat
|
||||
{
|
||||
get
|
||||
{
|
||||
return _preferredDepthStencilFormat;
|
||||
}
|
||||
set
|
||||
{
|
||||
_preferredDepthStencilFormat = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool SynchronizeWithVerticalRetrace
|
||||
{
|
||||
get
|
||||
{
|
||||
return _synchronizedWithVerticalRetrace;
|
||||
}
|
||||
set
|
||||
{
|
||||
_synchronizedWithVerticalRetrace = value;
|
||||
}
|
||||
}
|
||||
|
||||
public DisplayOrientation SupportedOrientations
|
||||
{
|
||||
get
|
||||
{
|
||||
return _supportedOrientations;
|
||||
}
|
||||
set
|
||||
{
|
||||
_supportedOrientations = value;
|
||||
if (_game.Window != null)
|
||||
_game.Window.SetSupportedOrientations(_supportedOrientations);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This method is used by MonoGame Android to adjust the game's drawn to area to fill
|
||||
/// as much of the screen as possible whilst retaining the aspect ratio inferred from
|
||||
/// aspectRatio = (PreferredBackBufferWidth / PreferredBackBufferHeight)
|
||||
///
|
||||
/// NOTE: this is a hack that should be removed if proper back buffer to screen scaling
|
||||
/// is implemented. To disable it's effect, in the game's constructor use:
|
||||
///
|
||||
/// graphics.IsFullScreen = true;
|
||||
/// graphics.PreferredBackBufferHeight = Window.ClientBounds.Height;
|
||||
/// graphics.PreferredBackBufferWidth = Window.ClientBounds.Width;
|
||||
///
|
||||
/// </summary>
|
||||
internal void ResetClientBounds()
|
||||
{
|
||||
#if ANDROID
|
||||
float preferredAspectRatio = (float)PreferredBackBufferWidth /
|
||||
(float)PreferredBackBufferHeight;
|
||||
float displayAspectRatio = (float)GraphicsDevice.DisplayMode.Width /
|
||||
(float)GraphicsDevice.DisplayMode.Height;
|
||||
|
||||
float adjustedAspectRatio = preferredAspectRatio;
|
||||
|
||||
if ((preferredAspectRatio > 1.0f && displayAspectRatio < 1.0f) ||
|
||||
(preferredAspectRatio < 1.0f && displayAspectRatio > 1.0f))
|
||||
{
|
||||
// Invert preferred aspect ratio if it's orientation differs from the display mode orientation.
|
||||
// This occurs when user sets preferredBackBufferWidth/Height and also allows multiple supported orientations
|
||||
adjustedAspectRatio = 1.0f / preferredAspectRatio;
|
||||
}
|
||||
|
||||
const float EPSILON = 0.00001f;
|
||||
var newClientBounds = new Rectangle();
|
||||
if (displayAspectRatio > (adjustedAspectRatio + EPSILON))
|
||||
{
|
||||
// Fill the entire height and reduce the width to keep aspect ratio
|
||||
newClientBounds.Height = _graphicsDevice.DisplayMode.Height;
|
||||
newClientBounds.Width = (int)(newClientBounds.Height * adjustedAspectRatio);
|
||||
newClientBounds.X = (_graphicsDevice.DisplayMode.Width - newClientBounds.Width) / 2;
|
||||
}
|
||||
else if (displayAspectRatio < (adjustedAspectRatio - EPSILON))
|
||||
{
|
||||
// Fill the entire width and reduce the height to keep aspect ratio
|
||||
newClientBounds.Width = _graphicsDevice.DisplayMode.Width;
|
||||
newClientBounds.Height = (int)(newClientBounds.Width / adjustedAspectRatio);
|
||||
newClientBounds.Y = (_graphicsDevice.DisplayMode.Height - newClientBounds.Height) / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Set the ClientBounds to match the DisplayMode
|
||||
newClientBounds.Width = GraphicsDevice.DisplayMode.Width;
|
||||
newClientBounds.Height = GraphicsDevice.DisplayMode.Height;
|
||||
}
|
||||
|
||||
// Ensure buffer size is reported correctly
|
||||
_graphicsDevice.PresentationParameters.BackBufferWidth = newClientBounds.Width;
|
||||
_graphicsDevice.PresentationParameters.BackBufferHeight = newClientBounds.Height;
|
||||
|
||||
// Set the veiwport so the (potentially) resized client bounds are drawn in the middle of the screen
|
||||
_graphicsDevice.Viewport = new Viewport(newClientBounds.X, -newClientBounds.Y, newClientBounds.Width, newClientBounds.Height);
|
||||
|
||||
((AndroidGameWindow)_game.Window).ChangeClientBounds(newClientBounds);
|
||||
|
||||
// Touch panel needs latest buffer size for scaling
|
||||
TouchPanel.DisplayWidth = newClientBounds.Width;
|
||||
TouchPanel.DisplayHeight = newClientBounds.Height;
|
||||
|
||||
Android.Util.Log.Debug("MonoGame", "GraphicsDeviceManager.ResetClientBounds: newClientBounds=" + newClientBounds.ToString());
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
// MonoGame - Copyright (C) The MonoGame Team
|
||||
// This file is subject to the terms and conditions defined in
|
||||
// file 'LICENSE.txt', which is part of this source code package.
|
||||
|
||||
using System;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
|
||||
namespace Microsoft.Xna.Framework
|
||||
{
|
||||
partial class GraphicsDeviceManager
|
||||
{
|
||||
[CLSCompliant(false)]
|
||||
public SwapChainPanel SwapChainPanel { get; set; }
|
||||
|
||||
partial void PlatformPreparePresentationParameters(PresentationParameters presentationParameters)
|
||||
{
|
||||
|
||||
// The graphics device can use a XAML panel or a window
|
||||
// to created the default swapchain target.
|
||||
if (SwapChainPanel != null)
|
||||
{
|
||||
presentationParameters.DeviceWindowHandle = IntPtr.Zero;
|
||||
presentationParameters.SwapChainPanel = this.SwapChainPanel;
|
||||
}
|
||||
else
|
||||
{
|
||||
presentationParameters.DeviceWindowHandle = _game.Window.Handle;
|
||||
presentationParameters.SwapChainPanel = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace Microsoft.Xna.Framework
|
||||
{
|
||||
/// <summary>
|
||||
/// Allows for platform specific handling of the Back button.
|
||||
/// </summary>
|
||||
/// <seealso cref="http://www.monogame.net/documentation/?page=Platform_Specific_Notes"/>
|
||||
public interface IPlatformBackButton
|
||||
{
|
||||
/// <summary>
|
||||
/// Return true if your game has handled the back button event
|
||||
/// retrn false if you want the operating system to handle it.
|
||||
/// </summary>
|
||||
bool Handled();
|
||||
}
|
||||
}
|
||||
@@ -1,272 +0,0 @@
|
||||
#region License
|
||||
/*
|
||||
Microsoft Public License (Ms-PL)
|
||||
MonoGame - Copyright © 2009 The MonoGame Team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
This license governs use of the accompanying software. If you use the software, you accept this license. If you do not
|
||||
accept the license, do not use the software.
|
||||
|
||||
1. Definitions
|
||||
The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under
|
||||
U.S. copyright law.
|
||||
|
||||
A "contribution" is the original software, or any additions or changes to the software.
|
||||
A "contributor" is any person that distributes its contribution under this license.
|
||||
"Licensed patents" are a contributor's patent claims that read directly on its contribution.
|
||||
|
||||
2. Grant of Rights
|
||||
(A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
|
||||
each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create.
|
||||
(B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
|
||||
each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software.
|
||||
|
||||
3. Conditions and Limitations
|
||||
(A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.
|
||||
(B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software,
|
||||
your patent license from such contributor to the software ends automatically.
|
||||
(C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution
|
||||
notices that are present in the software.
|
||||
(D) If you distribute any portion of the software in source code form, you may do so only under this license by including
|
||||
a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object
|
||||
code form, you may only do so under a license that complies with this license.
|
||||
(E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees
|
||||
or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent
|
||||
permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular
|
||||
purpose and non-infringement.
|
||||
*/
|
||||
#endregion License
|
||||
|
||||
#region Using clause
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Runtime.Remoting.Messaging;
|
||||
|
||||
using Microsoft.Xna.Framework.Net;
|
||||
|
||||
#endregion Using clause
|
||||
|
||||
namespace Microsoft.Xna.Framework.GamerServices
|
||||
{
|
||||
public static class Guide
|
||||
{
|
||||
private static bool isScreenSaverEnabled;
|
||||
private static bool isTrialMode;
|
||||
internal static bool isVisible;
|
||||
private static bool simulateTrialMode;
|
||||
|
||||
internal static void Initialise(Game game) {
|
||||
Guide.Window = game.Window;
|
||||
}
|
||||
delegate string ShowKeyboardInputDelegate (
|
||||
PlayerIndex player,
|
||||
string title,
|
||||
string description,
|
||||
string defaultText,
|
||||
bool usePasswordMode);
|
||||
|
||||
public static string ShowKeyboardInput (
|
||||
PlayerIndex player,
|
||||
string title,
|
||||
string description,
|
||||
string defaultText,
|
||||
bool usePasswordMode)
|
||||
{
|
||||
string result = defaultText;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static IAsyncResult BeginShowKeyboardInput (
|
||||
PlayerIndex player,
|
||||
string title,
|
||||
string description,
|
||||
string defaultText,
|
||||
AsyncCallback callback,
|
||||
Object state)
|
||||
{
|
||||
return BeginShowKeyboardInput (player, title, description, defaultText, callback, state, false);
|
||||
}
|
||||
|
||||
public static IAsyncResult BeginShowKeyboardInput (
|
||||
PlayerIndex player,
|
||||
string title,
|
||||
string description,
|
||||
string defaultText,
|
||||
AsyncCallback callback,
|
||||
Object state,
|
||||
bool usePasswordMode)
|
||||
{
|
||||
isVisible = true;
|
||||
|
||||
ShowKeyboardInputDelegate ski = ShowKeyboardInput;
|
||||
|
||||
return ski.BeginInvoke (player, title, description, defaultText, usePasswordMode, callback, ski);
|
||||
}
|
||||
|
||||
public static string EndShowKeyboardInput (IAsyncResult result)
|
||||
{
|
||||
try {
|
||||
ShowKeyboardInputDelegate ski = (ShowKeyboardInputDelegate)result.AsyncState;
|
||||
|
||||
return ski.EndInvoke (result);
|
||||
} finally {
|
||||
isVisible = false;
|
||||
}
|
||||
}
|
||||
|
||||
delegate Nullable<int> ShowMessageBoxDelegate (string title,
|
||||
string text,
|
||||
IEnumerable<string> buttons,
|
||||
int focusButton,
|
||||
MessageBoxIcon icon);
|
||||
|
||||
public static Nullable<int> ShowMessageBox (string title,
|
||||
string text,
|
||||
IEnumerable<string> buttons,
|
||||
int focusButton,
|
||||
MessageBoxIcon icon)
|
||||
{
|
||||
Nullable<int> result = null;
|
||||
|
||||
isVisible = true;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static IAsyncResult BeginShowMessageBox (
|
||||
PlayerIndex player,
|
||||
string title,
|
||||
string text,
|
||||
IEnumerable<string> buttons,
|
||||
int focusButton,
|
||||
MessageBoxIcon icon,
|
||||
AsyncCallback callback,
|
||||
Object state)
|
||||
{
|
||||
isVisible = true;
|
||||
|
||||
ShowMessageBoxDelegate smb = ShowMessageBox;
|
||||
|
||||
return smb.BeginInvoke (title, text, buttons, focusButton, icon, callback, smb);
|
||||
}
|
||||
|
||||
public static IAsyncResult BeginShowMessageBox (
|
||||
string title,
|
||||
string text,
|
||||
IEnumerable<string> buttons,
|
||||
int focusButton,
|
||||
MessageBoxIcon icon,
|
||||
AsyncCallback callback,
|
||||
Object state)
|
||||
{
|
||||
return BeginShowMessageBox (PlayerIndex.One, title, text, buttons, focusButton, icon, callback, state);
|
||||
}
|
||||
|
||||
public static Nullable<int> EndShowMessageBox (IAsyncResult result)
|
||||
{
|
||||
try {
|
||||
ShowMessageBoxDelegate smbd = (ShowMessageBoxDelegate)result.AsyncState;
|
||||
|
||||
return smbd.EndInvoke (result);
|
||||
} finally {
|
||||
isVisible = false;
|
||||
}
|
||||
}
|
||||
|
||||
public static void ShowMarketplace (PlayerIndex player)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public static void Show ()
|
||||
{
|
||||
/*GKPeerPickerController ppc = new GKPeerPickerController();
|
||||
ppc.ConnectionTypesMask = GKPeerPickerConnectionType.Nearby;
|
||||
ppc.Show();*/
|
||||
ShowSignIn (1, false);
|
||||
}
|
||||
|
||||
public static void ShowSignIn (int paneCount, bool onlineOnly)
|
||||
{
|
||||
// if (paneCount != 1) {
|
||||
// new ArgumentException ("paneCount Can only be 1 on iPhone");
|
||||
// return;
|
||||
// }
|
||||
if (isVisible)
|
||||
return;
|
||||
isVisible = true;
|
||||
|
||||
MonoGameGamerServicesHelper.ShowSigninSheet();
|
||||
|
||||
if (GamerServicesComponent.LocalNetworkGamer == null) {
|
||||
GamerServicesComponent.LocalNetworkGamer = new LocalNetworkGamer ();
|
||||
} else {
|
||||
GamerServicesComponent.LocalNetworkGamer.SignedInGamer.BeginAuthentication (null, null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void ShowLeaderboard ()
|
||||
{
|
||||
if ((Gamer.SignedInGamers.Count > 0) && (Gamer.SignedInGamers [0].IsSignedInToLive)) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static void ShowAchievements ()
|
||||
{
|
||||
if ((Gamer.SignedInGamers.Count > 0) && (Gamer.SignedInGamers [0].IsSignedInToLive)) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#region Properties
|
||||
public static bool IsScreenSaverEnabled {
|
||||
get {
|
||||
return isScreenSaverEnabled;
|
||||
}
|
||||
set {
|
||||
isScreenSaverEnabled = value;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsTrialMode {
|
||||
get {
|
||||
return isTrialMode;
|
||||
}
|
||||
set {
|
||||
isTrialMode = value;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsVisible {
|
||||
get {
|
||||
return isVisible;
|
||||
}
|
||||
set {
|
||||
isVisible = value;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool SimulateTrialMode {
|
||||
get {
|
||||
return simulateTrialMode;
|
||||
}
|
||||
set {
|
||||
simulateTrialMode = value;
|
||||
}
|
||||
}
|
||||
|
||||
[CLSCompliant(false)]
|
||||
public static GameWindow Window {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
-91
@@ -1,91 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Runtime.Serialization.Formatters.Binary;
|
||||
using System.Drawing;
|
||||
|
||||
using Foundation;
|
||||
using AppKit;
|
||||
using RectF = CoreGraphics.CGRect;
|
||||
using PointF = CoreGraphics.CGPoint;
|
||||
|
||||
namespace Microsoft.Xna.Framework.GamerServices
|
||||
{
|
||||
internal static class MonoGameGamerServicesHelper
|
||||
{
|
||||
internal static void ShowSigninSheet ()
|
||||
{
|
||||
|
||||
NSApplication NSApp = NSApplication.SharedApplication;
|
||||
NSWindow gameWindow = NSApp.MainWindow;
|
||||
|
||||
SigninController controller = new SigninController ();
|
||||
|
||||
NSWindow window = controller.Window;
|
||||
|
||||
// Something has happened with BeginSheet and needs to be looked into.
|
||||
// Until then just use modal for now.
|
||||
var frame = window.Frame;
|
||||
var location = new PointF (gameWindow.Frame.Bottom, gameWindow.Frame.Left);
|
||||
location = new PointF(gameWindow.Frame.Location.X, gameWindow.Frame.Location.Y);
|
||||
|
||||
window.SetFrameOrigin(location);
|
||||
NSApp.BeginInvokeOnMainThread(delegate {
|
||||
Guide.isVisible = true;
|
||||
// NSApp.BeginSheet (window, gameWindow);
|
||||
NSApp.RunModalForWindow (window);
|
||||
// // sheet is up here.....
|
||||
//
|
||||
// NSApp.EndSheet (window);
|
||||
window.OrderOut (gameWindow);
|
||||
Guide.isVisible = false;
|
||||
//
|
||||
});
|
||||
//window.MakeKeyAndOrderFront(gameWindow);
|
||||
// SignedInGamer sig = new SignedInGamer();
|
||||
// sig.DisplayName = "MonoMac Gamer";
|
||||
// sig.Gamertag = "MonoMac Gamer";
|
||||
// sig.InternalIdentifier = Guid.NewGuid();
|
||||
//
|
||||
// Gamer.SignedInGamers.Add(sig);
|
||||
}
|
||||
|
||||
internal static List<MonoGameLocalGamerProfile> DeserializeProfiles ()
|
||||
{
|
||||
var path = StorageLocation;
|
||||
var fileName = Path.Combine(path, "LocalProfiles.dat");
|
||||
var profiles = new List<MonoGameLocalGamerProfile> ();
|
||||
try {
|
||||
using (Stream stream = File.Open (fileName, FileMode.Open)) {
|
||||
BinaryFormatter bin = new BinaryFormatter ();
|
||||
|
||||
profiles = (List<MonoGameLocalGamerProfile>)bin.Deserialize (stream);
|
||||
}
|
||||
|
||||
} catch (IOException) {
|
||||
}
|
||||
return profiles;
|
||||
}
|
||||
|
||||
internal static void SerializeProfiles (List<MonoGameLocalGamerProfile> profiles)
|
||||
{
|
||||
var path = StorageLocation;
|
||||
var fileName = Path.Combine(path, "LocalProfiles.dat");
|
||||
try {
|
||||
using (Stream stream = File.Open (fileName, FileMode.Create)) {
|
||||
BinaryFormatter bin = new BinaryFormatter ();
|
||||
bin.Serialize (stream, profiles);
|
||||
}
|
||||
} catch (IOException) {
|
||||
}
|
||||
}
|
||||
|
||||
internal static string StorageLocation
|
||||
{
|
||||
get {
|
||||
return Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-77
@@ -1,77 +0,0 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
|
||||
namespace Microsoft.Xna.Framework.GamerServices
|
||||
{
|
||||
[Serializable()]
|
||||
internal class MonoGameLocalGamerProfile
|
||||
{
|
||||
Guid playerGuid;
|
||||
|
||||
internal MonoGameLocalGamerProfile ()
|
||||
{
|
||||
playerGuid = Guid.NewGuid();
|
||||
}
|
||||
|
||||
#region Properties
|
||||
|
||||
internal Guid PlayerInternalIdentifier
|
||||
{
|
||||
get { return playerGuid; }
|
||||
set { playerGuid = value; }
|
||||
}
|
||||
|
||||
internal string DisplayName {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
internal string Gamertag {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
|
||||
internal byte[] GamerPicture {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
internal int GamerScore {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
internal GamerZone GamerZone {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
internal string Motto {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
internal RegionInfo Region {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
internal float Reputation {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
internal int TitlesPlayed {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
internal int TotalAchievements {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
-313
@@ -1,313 +0,0 @@
|
||||
#region License
|
||||
/*
|
||||
Microsoft Public License (Ms-PL)
|
||||
MonoGame - Copyright © 2009 The MonoGame Team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
This license governs use of the accompanying software. If you use the software, you accept this license. If you do not
|
||||
accept the license, do not use the software.
|
||||
|
||||
1. Definitions
|
||||
The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under
|
||||
U.S. copyright law.
|
||||
|
||||
A "contribution" is the original software, or any additions or changes to the software.
|
||||
A "contributor" is any person that distributes its contribution under this license.
|
||||
"Licensed patents" are a contributor's patent claims that read directly on its contribution.
|
||||
|
||||
2. Grant of Rights
|
||||
(A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
|
||||
each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create.
|
||||
(B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
|
||||
each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software.
|
||||
|
||||
3. Conditions and Limitations
|
||||
(A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.
|
||||
(B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software,
|
||||
your patent license from such contributor to the software ends automatically.
|
||||
(C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution
|
||||
notices that are present in the software.
|
||||
(D) If you distribute any portion of the software in source code form, you may do so only under this license by including
|
||||
a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object
|
||||
code form, you may only do so under a license that complies with this license.
|
||||
(E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees
|
||||
or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent
|
||||
permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular
|
||||
purpose and non-infringement.
|
||||
*/
|
||||
#endregion License
|
||||
|
||||
#region Statement
|
||||
using System;
|
||||
|
||||
using Foundation;
|
||||
using AppKit;
|
||||
|
||||
#endregion Statement
|
||||
|
||||
|
||||
namespace Microsoft.Xna.Framework.GamerServices
|
||||
{
|
||||
public class SignedInGamer : Gamer
|
||||
{
|
||||
private AchievementCollection gamerAchievements;
|
||||
private FriendCollection friendCollection;
|
||||
|
||||
internal Guid InternalIdentifier;
|
||||
|
||||
delegate void AuthenticationDelegate ();
|
||||
|
||||
public IAsyncResult BeginAuthentication (AsyncCallback callback,Object asyncState)
|
||||
{
|
||||
// Go off authenticate
|
||||
AuthenticationDelegate ad = DoAuthentication;
|
||||
|
||||
return ad.BeginInvoke (callback, ad);
|
||||
}
|
||||
|
||||
public void EndAuthentication (IAsyncResult result)
|
||||
{
|
||||
AuthenticationDelegate ad = (AuthenticationDelegate)result.AsyncState;
|
||||
|
||||
ad.EndInvoke (result);
|
||||
}
|
||||
|
||||
private void DoAuthentication ()
|
||||
{
|
||||
try {
|
||||
|
||||
} catch (Exception) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public SignedInGamer ()
|
||||
{
|
||||
|
||||
// Register to receive the GKPlayerAuthenticationDidChangeNotificationName so we are notified when
|
||||
// Authentication changes
|
||||
|
||||
}
|
||||
|
||||
private void AuthenticationCompletedCallback (IAsyncResult result)
|
||||
{
|
||||
EndAuthentication (result);
|
||||
}
|
||||
|
||||
#region Methods
|
||||
public FriendCollection GetFriends ()
|
||||
{
|
||||
if (IsSignedInToLive) {
|
||||
if (friendCollection == null) {
|
||||
friendCollection = new FriendCollection ();
|
||||
}
|
||||
}
|
||||
|
||||
return friendCollection;
|
||||
}
|
||||
|
||||
public bool IsFriend (Gamer gamer)
|
||||
{
|
||||
if (gamer == null)
|
||||
throw new ArgumentNullException ();
|
||||
|
||||
if (gamer.IsDisposed)
|
||||
throw new ObjectDisposedException (gamer.ToString ());
|
||||
|
||||
bool found = false;
|
||||
foreach (FriendGamer f in friendCollection) {
|
||||
if (f.Gamertag == gamer.Gamertag) {
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
return found;
|
||||
|
||||
}
|
||||
|
||||
delegate AchievementCollection GetAchievementsDelegate ();
|
||||
|
||||
public IAsyncResult BeginGetAchievements (AsyncCallback callback, Object asyncState)
|
||||
{
|
||||
// Go off and grab achievements
|
||||
GetAchievementsDelegate gad = GetAchievements;
|
||||
|
||||
return gad.BeginInvoke (callback, gad);
|
||||
}
|
||||
|
||||
private void GetAchievementCompletedCallback (IAsyncResult result)
|
||||
{
|
||||
// get the delegate that was used to call that method
|
||||
GetAchievementsDelegate gad = (GetAchievementsDelegate)result.AsyncState;
|
||||
|
||||
// get the return value from that method call
|
||||
gamerAchievements = gad.EndInvoke (result);
|
||||
}
|
||||
|
||||
public AchievementCollection EndGetAchievements (IAsyncResult result)
|
||||
{
|
||||
GetAchievementsDelegate gad = (GetAchievementsDelegate)result.AsyncState;
|
||||
|
||||
gamerAchievements = gad.EndInvoke (result);
|
||||
|
||||
return gamerAchievements;
|
||||
}
|
||||
|
||||
public AchievementCollection GetAchievements ()
|
||||
{
|
||||
if (IsSignedInToLive) {
|
||||
if (gamerAchievements == null) {
|
||||
gamerAchievements = new AchievementCollection ();
|
||||
}
|
||||
}
|
||||
return gamerAchievements;
|
||||
}
|
||||
|
||||
delegate void AwardAchievementDelegate (string achievementId, double percentageComplete);
|
||||
|
||||
public IAsyncResult BeginAwardAchievement(string achievementId, AsyncCallback callback, Object state)
|
||||
{
|
||||
return BeginAwardAchievement(achievementId, 100.0, callback, state);
|
||||
}
|
||||
|
||||
public IAsyncResult BeginAwardAchievement(
|
||||
string achievementId,
|
||||
double percentageComplete,
|
||||
AsyncCallback callback,
|
||||
Object state
|
||||
)
|
||||
{
|
||||
// Go off and award the achievement
|
||||
AwardAchievementDelegate aad = DoAwardAchievement;
|
||||
|
||||
return aad.BeginInvoke (achievementId, percentageComplete, callback, aad);
|
||||
}
|
||||
|
||||
public void EndAwardAchievement (IAsyncResult result)
|
||||
{
|
||||
AwardAchievementDelegate aad = (AwardAchievementDelegate)result.AsyncState;
|
||||
|
||||
aad.EndInvoke (result);
|
||||
}
|
||||
|
||||
private void AwardAchievementCompletedCallback (IAsyncResult result)
|
||||
{
|
||||
EndAwardAchievement (result);
|
||||
}
|
||||
|
||||
public void AwardAchievement (string achievementId)
|
||||
{
|
||||
AwardAchievement (achievementId, 100.0f);
|
||||
}
|
||||
|
||||
public void DoAwardAchievement (string achievementId, double percentageComplete)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void AwardAchievement (string achievementId, double percentageComplete)
|
||||
{
|
||||
if (IsSignedInToLive) {
|
||||
BeginAwardAchievement (achievementId, percentageComplete, AwardAchievementCompletedCallback, null);
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateScore (string aCategory, long aScore)
|
||||
{
|
||||
if (IsSignedInToLive) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void ResetAchievements ()
|
||||
{
|
||||
if (IsSignedInToLive) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
public GameDefaults GameDefaults {
|
||||
get {
|
||||
throw new NotSupportedException ();
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsGuest {
|
||||
get {
|
||||
throw new NotSupportedException ();
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsSignedInToLive {
|
||||
get {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public int PartySize {
|
||||
get {
|
||||
throw new NotSupportedException ();
|
||||
}
|
||||
set {
|
||||
throw new NotSupportedException ();
|
||||
}
|
||||
}
|
||||
|
||||
public PlayerIndex PlayerIndex {
|
||||
get {
|
||||
return PlayerIndex.One;
|
||||
}
|
||||
}
|
||||
|
||||
public GamerPresence Presence {
|
||||
get {
|
||||
throw new NotSupportedException ();
|
||||
}
|
||||
}
|
||||
|
||||
GamerPrivileges _privileges = new GamerPrivileges ();
|
||||
|
||||
public GamerPrivileges Privileges {
|
||||
get {
|
||||
return _privileges;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
protected virtual void OnSignedIn (SignedInEventArgs e)
|
||||
{
|
||||
EventHelpers.Raise(this, SignedIn, e);
|
||||
}
|
||||
|
||||
protected virtual void OnSignedOut (SignedOutEventArgs e)
|
||||
{
|
||||
EventHelpers.Raise(this, SignedOut, e);
|
||||
}
|
||||
|
||||
#region Events
|
||||
public static event EventHandler<SignedInEventArgs> SignedIn;
|
||||
public static event EventHandler<SignedOutEventArgs> SignedOut;
|
||||
#endregion
|
||||
}
|
||||
|
||||
public class SignedInEventArgs : EventArgs
|
||||
{
|
||||
public SignedInEventArgs (SignedInGamer gamer)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public class SignedOutEventArgs : EventArgs
|
||||
{
|
||||
public SignedOutEventArgs (SignedInGamer gamer)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
-274
@@ -1,274 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using System.Drawing;
|
||||
|
||||
using Foundation;
|
||||
using AppKit;
|
||||
using ObjCRuntime;
|
||||
using RectF = CoreGraphics.CGRect;
|
||||
using SizeF = CoreGraphics.CGSize;
|
||||
using PointF = CoreGraphics.CGPoint;
|
||||
|
||||
namespace Microsoft.Xna.Framework.GamerServices
|
||||
{
|
||||
[CLSCompliant(false)]
|
||||
public partial class SigninController : NSWindowController
|
||||
{
|
||||
|
||||
NSApplication NSApp = NSApplication.SharedApplication;
|
||||
|
||||
|
||||
internal List<MonoGameLocalGamerProfile> gamerList;
|
||||
internal NSTableView tableView;
|
||||
|
||||
#region Constructors
|
||||
|
||||
// Called when created from unmanaged code
|
||||
public SigninController (IntPtr handle) : base(handle)
|
||||
{
|
||||
Initialize ();
|
||||
}
|
||||
|
||||
// Called when created directly from a XIB file
|
||||
[Export("initWithCoder:")]
|
||||
public SigninController (NSCoder coder) : base(coder)
|
||||
{
|
||||
Initialize ();
|
||||
}
|
||||
|
||||
// // Call to load from the XIB/NIB file
|
||||
// public SigninController () : base("TableEdit")
|
||||
// {
|
||||
// Initialize ();
|
||||
// }
|
||||
|
||||
public SigninController()
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
|
||||
NSWindow window = null;
|
||||
internal NSButton selectButton;
|
||||
|
||||
// Shared initialization code
|
||||
void Initialize ()
|
||||
{
|
||||
//window = new NSWindow(new RectangleF(0,0, 470, 250), NSWindowStyle.Titled | NSWindowStyle.Closable, NSBackingStore.Buffered, false);
|
||||
window = new NSWindow(new RectF(0,0, 470, 250), NSWindowStyle.Titled, NSBackingStore.Buffered, false);
|
||||
window.HasShadow = true;
|
||||
NSView content = window.ContentView;
|
||||
window.WindowController = this;
|
||||
window.Title = "Sign In";
|
||||
NSTextField signInLabel = new NSTextField(new RectF(17, 190, 109, 17));
|
||||
signInLabel.StringValue = "Sign In:";
|
||||
signInLabel.Editable = false;
|
||||
signInLabel.Bordered = false;
|
||||
signInLabel.BackgroundColor = NSColor.Control;
|
||||
|
||||
content.AddSubview(signInLabel);
|
||||
|
||||
// Create our select button
|
||||
selectButton = new NSButton(new RectF(358,12,96,32));
|
||||
selectButton.Title = "Select";
|
||||
selectButton.SetButtonType(NSButtonType.MomentaryPushIn);
|
||||
selectButton.BezelStyle = NSBezelStyle.Rounded;
|
||||
|
||||
selectButton.Activated += delegate {
|
||||
|
||||
profileSelected();
|
||||
};
|
||||
|
||||
selectButton.Enabled = false;
|
||||
|
||||
content.AddSubview(selectButton);
|
||||
|
||||
// Setup our table view
|
||||
NSScrollView tableContainer = new NSScrollView(new RectF(20,60,428, 123));
|
||||
tableContainer.BorderType = NSBorderType.BezelBorder;
|
||||
tableContainer.AutohidesScrollers = true;
|
||||
tableContainer.HasVerticalScroller = true;
|
||||
|
||||
tableView = new NSTableView(new RectF(0,0,420, 123));
|
||||
tableView.UsesAlternatingRowBackgroundColors = true;
|
||||
|
||||
NSTableColumn colGamerTag = new NSTableColumn("Gamer");
|
||||
tableView.AddColumn(colGamerTag);
|
||||
|
||||
colGamerTag.Width = 420;
|
||||
colGamerTag.HeaderCell.Title = "Gamer Profile";
|
||||
tableContainer.DocumentView = tableView;
|
||||
|
||||
content.AddSubview(tableContainer);
|
||||
|
||||
// Create our add button
|
||||
NSButton addButton = new NSButton(new RectF(20,27,25,25));
|
||||
//Console.WriteLine(NSImage.AddTemplate);
|
||||
addButton.Image = NSImage.ImageNamed("NSAddTemplate");
|
||||
addButton.SetButtonType(NSButtonType.MomentaryPushIn);
|
||||
addButton.BezelStyle = NSBezelStyle.SmallSquare;
|
||||
|
||||
addButton.Activated += delegate {
|
||||
addLocalPlayer();
|
||||
};
|
||||
content.AddSubview(addButton);
|
||||
|
||||
// Create our remove button
|
||||
NSButton removeButton = new NSButton(new RectF(44,27,25,25));
|
||||
removeButton.Image = NSImage.ImageNamed("NSRemoveTemplate");
|
||||
removeButton.SetButtonType(NSButtonType.MomentaryPushIn);
|
||||
removeButton.BezelStyle = NSBezelStyle.SmallSquare;
|
||||
|
||||
removeButton.Activated += delegate {
|
||||
removeLocalPlayer();
|
||||
};
|
||||
content.AddSubview(removeButton);
|
||||
|
||||
gamerList = MonoGameGamerServicesHelper.DeserializeProfiles();
|
||||
|
||||
// for (int x= 1; x< 25; x++) {
|
||||
// gamerList.Add("Player " + x);
|
||||
// }
|
||||
tableView.DataSource = new GamersDataSource(this);
|
||||
tableView.Delegate = new GamersTableDelegate(this);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
public new NSWindow Window {
|
||||
get { return window; }
|
||||
}
|
||||
|
||||
void profileSelected ()
|
||||
{
|
||||
if (tableView.SelectedRowCount > 0) {
|
||||
var rowSelected = tableView.SelectedRow;
|
||||
SignedInGamer sig = new SignedInGamer();
|
||||
sig.DisplayName = gamerList[(int)rowSelected].DisplayName;
|
||||
sig.Gamertag = gamerList[(int)rowSelected].Gamertag;
|
||||
sig.InternalIdentifier = gamerList[(int)rowSelected].PlayerInternalIdentifier;
|
||||
|
||||
Gamer.SignedInGamers.Add(sig);
|
||||
}
|
||||
MonoGameGamerServicesHelper.SerializeProfiles(gamerList);
|
||||
NSApp.StopModal();
|
||||
}
|
||||
|
||||
void removeLocalPlayer ()
|
||||
{
|
||||
Console.WriteLine("Remove local");
|
||||
var rowToRemove = tableView.SelectedRow;
|
||||
if (rowToRemove < 0 || rowToRemove > gamerList.Count -1)
|
||||
return;
|
||||
gamerList.RemoveAt((int)rowToRemove);
|
||||
tableView.ReloadData();
|
||||
}
|
||||
|
||||
void addLocalPlayer ()
|
||||
{
|
||||
MonoGameLocalGamerProfile prof = new MonoGameLocalGamerProfile();
|
||||
prof.Gamertag = "New Player";
|
||||
prof.DisplayName = prof.Gamertag;
|
||||
|
||||
gamerList.Add(prof);
|
||||
|
||||
tableView.ReloadData();
|
||||
int newPlayerRow = gamerList.Count - 1;
|
||||
|
||||
tableView.ScrollRowToVisible(newPlayerRow);
|
||||
tableView.EditColumn(0,newPlayerRow, new NSEvent(), true);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
[CLSCompliant(false)]
|
||||
public class GamersDataSource : NSTableViewDataSource
|
||||
{
|
||||
|
||||
SigninController controller;
|
||||
|
||||
public GamersDataSource (SigninController controller)
|
||||
{
|
||||
this.controller = controller;
|
||||
}
|
||||
|
||||
#if MONOMAC
|
||||
public override nint GetRowCount (NSTableView tableView)
|
||||
{
|
||||
return controller.gamerList.Count;
|
||||
}
|
||||
|
||||
public override NSObject GetObjectValue (NSTableView tableView, NSTableColumn tableColumn, nint row)
|
||||
{
|
||||
return new NSString(controller.gamerList[(int)row].Gamertag);
|
||||
}
|
||||
|
||||
public override void SetObjectValue (NSTableView tableView, NSObject theObject, NSTableColumn tableColumn, nint row)
|
||||
{
|
||||
var proposedValue = theObject.ToString();
|
||||
if (proposedValue.Trim().Length > 0)
|
||||
{
|
||||
controller.gamerList[(int)row].Gamertag = theObject.ToString();
|
||||
controller.gamerList[(int)row].DisplayName = theObject.ToString();
|
||||
}
|
||||
}
|
||||
#else
|
||||
public override int GetRowCount (NSTableView tableView)
|
||||
{
|
||||
return controller.gamerList.Count;
|
||||
}
|
||||
|
||||
public override NSObject GetObjectValue (NSTableView tableView, NSTableColumn tableColumn, int row)
|
||||
{
|
||||
return new NSString(controller.gamerList[row].Gamertag);
|
||||
}
|
||||
|
||||
public override void SetObjectValue (NSTableView tableView, NSObject theObject, NSTableColumn tableColumn, int row)
|
||||
{
|
||||
var proposedValue = theObject.ToString();
|
||||
if (proposedValue.Trim().Length > 0)
|
||||
{
|
||||
controller.gamerList[row].Gamertag = theObject.ToString();
|
||||
controller.gamerList[row].DisplayName = theObject.ToString();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
[CLSCompliant(false)]
|
||||
public class GamersTableDelegate : NSTableViewDelegate
|
||||
{
|
||||
SigninController controller;
|
||||
|
||||
public GamersTableDelegate (SigninController controller)
|
||||
{
|
||||
this.controller = controller;
|
||||
}
|
||||
|
||||
#if MONOMAC
|
||||
public override bool ShouldSelectRow (NSTableView tableView, nint row)
|
||||
#else
|
||||
public override bool ShouldSelectRow (NSTableView tableView, int row)
|
||||
#endif
|
||||
{
|
||||
var profile = controller.gamerList[(int)row];
|
||||
foreach (var gamer in Gamer.SignedInGamers) {
|
||||
if (profile.PlayerInternalIdentifier == gamer.InternalIdentifier)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void SelectionDidChange (NSNotification notification)
|
||||
{
|
||||
if (controller.tableView.SelectedRowCount > 0)
|
||||
controller.selectButton.Enabled = true;
|
||||
else
|
||||
controller.selectButton.Enabled = false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,320 +0,0 @@
|
||||
// MIT License - Copyright (C) The Mono.Xna Team
|
||||
// This file is subject to the terms and conditions defined in
|
||||
// file 'LICENSE.txt', which is part of this source code package.
|
||||
|
||||
using System;
|
||||
|
||||
namespace Microsoft.Xna.Framework
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains commonly used precalculated values and mathematical operations.
|
||||
/// </summary>
|
||||
public static class MathHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the mathematical constant e(2.71828175).
|
||||
/// </summary>
|
||||
public const float E = (float)Math.E;
|
||||
|
||||
/// <summary>
|
||||
/// Represents the log base ten of e(0.4342945).
|
||||
/// </summary>
|
||||
public const float Log10E = 0.4342945f;
|
||||
|
||||
/// <summary>
|
||||
/// Represents the log base two of e(1.442695).
|
||||
/// </summary>
|
||||
public const float Log2E = 1.442695f;
|
||||
|
||||
/// <summary>
|
||||
/// Represents the value of pi(3.14159274).
|
||||
/// </summary>
|
||||
public const float Pi = (float)Math.PI;
|
||||
|
||||
/// <summary>
|
||||
/// Represents the value of pi divided by two(1.57079637).
|
||||
/// </summary>
|
||||
public const float PiOver2 = (float)(Math.PI / 2.0);
|
||||
|
||||
/// <summary>
|
||||
/// Represents the value of pi divided by four(0.7853982).
|
||||
/// </summary>
|
||||
public const float PiOver4 = (float)(Math.PI / 4.0);
|
||||
|
||||
/// <summary>
|
||||
/// Represents the value of pi times two(6.28318548).
|
||||
/// </summary>
|
||||
public const float TwoPi = (float)(Math.PI * 2.0);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the Cartesian coordinate for one axis of a point that is defined by a given triangle and two normalized barycentric (areal) coordinates.
|
||||
/// </summary>
|
||||
/// <param name="value1">The coordinate on one axis of vertex 1 of the defining triangle.</param>
|
||||
/// <param name="value2">The coordinate on the same axis of vertex 2 of the defining triangle.</param>
|
||||
/// <param name="value3">The coordinate on the same axis of vertex 3 of the defining triangle.</param>
|
||||
/// <param name="amount1">The normalized barycentric (areal) coordinate b2, equal to the weighting factor for vertex 2, the coordinate of which is specified in value2.</param>
|
||||
/// <param name="amount2">The normalized barycentric (areal) coordinate b3, equal to the weighting factor for vertex 3, the coordinate of which is specified in value3.</param>
|
||||
/// <returns>Cartesian coordinate of the specified point with respect to the axis being used.</returns>
|
||||
public static float Barycentric(float value1, float value2, float value3, float amount1, float amount2)
|
||||
{
|
||||
return value1 + (value2 - value1) * amount1 + (value3 - value1) * amount2;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Performs a Catmull-Rom interpolation using the specified positions.
|
||||
/// </summary>
|
||||
/// <param name="value1">The first position in the interpolation.</param>
|
||||
/// <param name="value2">The second position in the interpolation.</param>
|
||||
/// <param name="value3">The third position in the interpolation.</param>
|
||||
/// <param name="value4">The fourth position in the interpolation.</param>
|
||||
/// <param name="amount">Weighting factor.</param>
|
||||
/// <returns>A position that is the result of the Catmull-Rom interpolation.</returns>
|
||||
public static float CatmullRom(float value1, float value2, float value3, float value4, float amount)
|
||||
{
|
||||
// Using formula from http://www.mvps.org/directx/articles/catmull/
|
||||
// Internally using doubles not to lose precission
|
||||
double amountSquared = amount * amount;
|
||||
double amountCubed = amountSquared * amount;
|
||||
return (float)(0.5 * (2.0 * value2 +
|
||||
(value3 - value1) * amount +
|
||||
(2.0 * value1 - 5.0 * value2 + 4.0 * value3 - value4) * amountSquared +
|
||||
(3.0 * value2 - value1 - 3.0 * value3 + value4) * amountCubed));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Restricts a value to be within a specified range.
|
||||
/// </summary>
|
||||
/// <param name="value">The value to clamp.</param>
|
||||
/// <param name="min">The minimum value. If <c>value</c> is less than <c>min</c>, <c>min</c> will be returned.</param>
|
||||
/// <param name="max">The maximum value. If <c>value</c> is greater than <c>max</c>, <c>max</c> will be returned.</param>
|
||||
/// <returns>The clamped value.</returns>
|
||||
public static float Clamp(float value, float min, float max)
|
||||
{
|
||||
// First we check to see if we're greater than the max
|
||||
value = (value > max) ? max : value;
|
||||
|
||||
// Then we check to see if we're less than the min.
|
||||
value = (value < min) ? min : value;
|
||||
|
||||
// There's no check to see if min > max.
|
||||
return value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Restricts a value to be within a specified range.
|
||||
/// </summary>
|
||||
/// <param name="value">The value to clamp.</param>
|
||||
/// <param name="min">The minimum value. If <c>value</c> is less than <c>min</c>, <c>min</c> will be returned.</param>
|
||||
/// <param name="max">The maximum value. If <c>value</c> is greater than <c>max</c>, <c>max</c> will be returned.</param>
|
||||
/// <returns>The clamped value.</returns>
|
||||
public static int Clamp(int value, int min, int max)
|
||||
{
|
||||
value = (value > max) ? max : value;
|
||||
value = (value < min) ? min : value;
|
||||
return value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the absolute value of the difference of two values.
|
||||
/// </summary>
|
||||
/// <param name="value1">Source value.</param>
|
||||
/// <param name="value2">Source value.</param>
|
||||
/// <returns>Distance between the two values.</returns>
|
||||
public static float Distance(float value1, float value2)
|
||||
{
|
||||
return Math.Abs(value1 - value2);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Performs a Hermite spline interpolation.
|
||||
/// </summary>
|
||||
/// <param name="value1">Source position.</param>
|
||||
/// <param name="tangent1">Source tangent.</param>
|
||||
/// <param name="value2">Source position.</param>
|
||||
/// <param name="tangent2">Source tangent.</param>
|
||||
/// <param name="amount">Weighting factor.</param>
|
||||
/// <returns>The result of the Hermite spline interpolation.</returns>
|
||||
public static float Hermite(float value1, float tangent1, float value2, float tangent2, float amount)
|
||||
{
|
||||
// All transformed to double not to lose precission
|
||||
// Otherwise, for high numbers of param:amount the result is NaN instead of Infinity
|
||||
double v1 = value1, v2 = value2, t1 = tangent1, t2 = tangent2, s = amount, result;
|
||||
double sCubed = s * s * s;
|
||||
double sSquared = s * s;
|
||||
|
||||
if (amount == 0f)
|
||||
result = value1;
|
||||
else if (amount == 1f)
|
||||
result = value2;
|
||||
else
|
||||
result = (2 * v1 - 2 * v2 + t2 + t1) * sCubed +
|
||||
(3 * v2 - 3 * v1 - 2 * t1 - t2) * sSquared +
|
||||
t1 * s +
|
||||
v1;
|
||||
return (float)result;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Linearly interpolates between two values.
|
||||
/// </summary>
|
||||
/// <param name="value1">Source value.</param>
|
||||
/// <param name="value2">Destination value.</param>
|
||||
/// <param name="amount">Value between 0 and 1 indicating the weight of value2.</param>
|
||||
/// <returns>Interpolated value.</returns>
|
||||
/// <remarks>This method performs the linear interpolation based on the following formula:
|
||||
/// <code>value1 + (value2 - value1) * amount</code>.
|
||||
/// Passing amount a value of 0 will cause value1 to be returned, a value of 1 will cause value2 to be returned.
|
||||
/// See <see cref="MathHelper.LerpPrecise"/> for a less efficient version with more precision around edge cases.
|
||||
/// </remarks>
|
||||
public static float Lerp(float value1, float value2, float amount)
|
||||
{
|
||||
return value1 + (value2 - value1) * amount;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Linearly interpolates between two values.
|
||||
/// This method is a less efficient, more precise version of <see cref="MathHelper.Lerp"/>.
|
||||
/// See remarks for more info.
|
||||
/// </summary>
|
||||
/// <param name="value1">Source value.</param>
|
||||
/// <param name="value2">Destination value.</param>
|
||||
/// <param name="amount">Value between 0 and 1 indicating the weight of value2.</param>
|
||||
/// <returns>Interpolated value.</returns>
|
||||
/// <remarks>This method performs the linear interpolation based on the following formula:
|
||||
/// <code>((1 - amount) * value1) + (value2 * amount)</code>.
|
||||
/// Passing amount a value of 0 will cause value1 to be returned, a value of 1 will cause value2 to be returned.
|
||||
/// This method does not have the floating point precision issue that <see cref="MathHelper.Lerp"/> has.
|
||||
/// i.e. If there is a big gap between value1 and value2 in magnitude (e.g. value1=10000000000000000, value2=1),
|
||||
/// right at the edge of the interpolation range (amount=1), <see cref="MathHelper.Lerp"/> will return 0 (whereas it should return 1).
|
||||
/// This also holds for value1=10^17, value2=10; value1=10^18,value2=10^2... so on.
|
||||
/// For an in depth explanation of the issue, see below references:
|
||||
/// Relevant Wikipedia Article: https://en.wikipedia.org/wiki/Linear_interpolation#Programming_language_support
|
||||
/// Relevant StackOverflow Answer: http://stackoverflow.com/questions/4353525/floating-point-linear-interpolation#answer-23716956
|
||||
/// </remarks>
|
||||
public static float LerpPrecise(float value1, float value2, float amount)
|
||||
{
|
||||
return ((1 - amount) * value1) + (value2 * amount);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the greater of two values.
|
||||
/// </summary>
|
||||
/// <param name="value1">Source value.</param>
|
||||
/// <param name="value2">Source value.</param>
|
||||
/// <returns>The greater value.</returns>
|
||||
public static float Max(float value1, float value2)
|
||||
{
|
||||
return value1 > value2 ? value1 : value2;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the greater of two values.
|
||||
/// </summary>
|
||||
/// <param name="value1">Source value.</param>
|
||||
/// <param name="value2">Source value.</param>
|
||||
/// <returns>The greater value.</returns>
|
||||
public static int Max(int value1, int value2)
|
||||
{
|
||||
return value1 > value2 ? value1 : value2;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the lesser of two values.
|
||||
/// </summary>
|
||||
/// <param name="value1">Source value.</param>
|
||||
/// <param name="value2">Source value.</param>
|
||||
/// <returns>The lesser value.</returns>
|
||||
public static float Min(float value1, float value2)
|
||||
{
|
||||
return value1 < value2 ? value1 : value2;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the lesser of two values.
|
||||
/// </summary>
|
||||
/// <param name="value1">Source value.</param>
|
||||
/// <param name="value2">Source value.</param>
|
||||
/// <returns>The lesser value.</returns>
|
||||
public static int Min(int value1, int value2)
|
||||
{
|
||||
return value1 < value2 ? value1 : value2;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Interpolates between two values using a cubic equation.
|
||||
/// </summary>
|
||||
/// <param name="value1">Source value.</param>
|
||||
/// <param name="value2">Source value.</param>
|
||||
/// <param name="amount">Weighting value.</param>
|
||||
/// <returns>Interpolated value.</returns>
|
||||
public static float SmoothStep(float value1, float value2, float amount)
|
||||
{
|
||||
// It is expected that 0 < amount < 1
|
||||
// If amount < 0, return value1
|
||||
// If amount > 1, return value2
|
||||
float result = MathHelper.Clamp(amount, 0f, 1f);
|
||||
result = MathHelper.Hermite(value1, 0f, value2, 0f, result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts radians to degrees.
|
||||
/// </summary>
|
||||
/// <param name="radians">The angle in radians.</param>
|
||||
/// <returns>The angle in degrees.</returns>
|
||||
/// <remarks>
|
||||
/// This method uses double precission internally,
|
||||
/// though it returns single float
|
||||
/// Factor = 180 / pi
|
||||
/// </remarks>
|
||||
public static float ToDegrees(float radians)
|
||||
{
|
||||
return (float)(radians * 57.295779513082320876798154814105);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts degrees to radians.
|
||||
/// </summary>
|
||||
/// <param name="degrees">The angle in degrees.</param>
|
||||
/// <returns>The angle in radians.</returns>
|
||||
/// <remarks>
|
||||
/// This method uses double precission internally,
|
||||
/// though it returns single float
|
||||
/// Factor = pi / 180
|
||||
/// </remarks>
|
||||
public static float ToRadians(float degrees)
|
||||
{
|
||||
return (float)(degrees * 0.017453292519943295769236907684886);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reduces a given angle to a value between π and -π.
|
||||
/// </summary>
|
||||
/// <param name="angle">The angle to reduce, in radians.</param>
|
||||
/// <returns>The new angle, in radians.</returns>
|
||||
public static float WrapAngle(float angle)
|
||||
{
|
||||
if ((angle > -Pi) && (angle <= Pi))
|
||||
return angle;
|
||||
angle %= TwoPi;
|
||||
if (angle <= -Pi)
|
||||
return angle + TwoPi;
|
||||
if (angle > Pi)
|
||||
return angle - TwoPi;
|
||||
return angle;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines if value is powered by two.
|
||||
/// </summary>
|
||||
/// <param name="value">A value.</param>
|
||||
/// <returns><c>true</c> if <c>value</c> is powered by two; otherwise <c>false</c>.</returns>
|
||||
public static bool IsPowerOfTwo(int value)
|
||||
{
|
||||
return (value > 0) && ((value & (value - 1)) == 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
-23
@@ -1,23 +0,0 @@
|
||||
// MonoGame - Copyright (C) The MonoGame Team
|
||||
// This file is subject to the terms and conditions defined in
|
||||
// file 'LICENSE.txt', which is part of this source code package.
|
||||
|
||||
namespace Microsoft.Devices.Sensors
|
||||
{
|
||||
/// <summary>
|
||||
/// The exception that may be thrown during a call to Start() or Stop(). The Message field describes the reason for the exception and the ErrorId field contains the error code from the underlying native code implementation of the accelerometer framework.
|
||||
/// </summary>
|
||||
public class AccelerometerFailedException : SensorFailedException
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of AccelerometerFailedException
|
||||
/// </summary>
|
||||
/// <param name="message">The descriptive reason for the exception</param>
|
||||
/// <param name="errorId">The native error code that caused the exception</param>
|
||||
internal AccelerometerFailedException(string message, int errorId)
|
||||
: base(message)
|
||||
{
|
||||
ErrorId = errorId;
|
||||
}
|
||||
}
|
||||
}
|
||||
-16
@@ -1,16 +0,0 @@
|
||||
// MonoGame - Copyright (C) The MonoGame Team
|
||||
// This file is subject to the terms and conditions defined in
|
||||
// file 'LICENSE.txt', which is part of this source code package.
|
||||
|
||||
using System;
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
namespace Microsoft.Devices.Sensors
|
||||
{
|
||||
public struct AccelerometerReading : ISensorReading
|
||||
{
|
||||
public Vector3 Acceleration { get; internal set; }
|
||||
public DateTimeOffset Timestamp { get; internal set; }
|
||||
}
|
||||
}
|
||||
|
||||
-24
@@ -1,24 +0,0 @@
|
||||
// MonoGame - Copyright (C) The MonoGame Team
|
||||
// This file is subject to the terms and conditions defined in
|
||||
// file 'LICENSE.txt', which is part of this source code package.
|
||||
|
||||
using System;
|
||||
|
||||
namespace Microsoft.Devices.Sensors
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides data for Calibrate and events.
|
||||
/// </summary>
|
||||
public class CalibrationEventArgs : EventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the CalibrationEventArgs class.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Obtain a CalibrationEventArgs object by implementing a handler for the Compass.Calibrate event.
|
||||
/// </remarks>
|
||||
public CalibrationEventArgs()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
-18
@@ -1,18 +0,0 @@
|
||||
// MonoGame - Copyright (C) The MonoGame Team
|
||||
// This file is subject to the terms and conditions defined in
|
||||
// file 'LICENSE.txt', which is part of this source code package.
|
||||
|
||||
using System;
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
namespace Microsoft.Devices.Sensors
|
||||
{
|
||||
public struct CompassReading : ISensorReading
|
||||
{
|
||||
public double HeadingAccuracy { get; internal set; }
|
||||
public double MagneticHeading { get; internal set; }
|
||||
public Vector3 MagnetometerReading { get; internal set; }
|
||||
public DateTimeOffset Timestamp { get; internal set; }
|
||||
public double TrueHeading { get; internal set; }
|
||||
}
|
||||
}
|
||||
-14
@@ -1,14 +0,0 @@
|
||||
// MonoGame - Copyright (C) The MonoGame Team
|
||||
// This file is subject to the terms and conditions defined in
|
||||
// file 'LICENSE.txt', which is part of this source code package.
|
||||
|
||||
using System;
|
||||
|
||||
namespace Microsoft.Devices.Sensors
|
||||
{
|
||||
public interface ISensorReading
|
||||
{
|
||||
DateTimeOffset Timestamp { get; }
|
||||
}
|
||||
}
|
||||
|
||||
-88
@@ -1,88 +0,0 @@
|
||||
// MonoGame - Copyright (C) The MonoGame Team
|
||||
// This file is subject to the terms and conditions defined in
|
||||
// file 'LICENSE.txt', which is part of this source code package.
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
|
||||
namespace Microsoft.Devices.Sensors
|
||||
{
|
||||
public abstract class SensorBase<TSensorReading> : IDisposable
|
||||
where TSensorReading : ISensorReading
|
||||
{
|
||||
#if IOS
|
||||
[CLSCompliant(false)]
|
||||
protected static readonly CoreMotion.CMMotionManager motionManager = new CoreMotion.CMMotionManager();
|
||||
#endif
|
||||
bool disposed;
|
||||
private TimeSpan timeBetweenUpdates;
|
||||
private TSensorReading currentValue;
|
||||
private SensorReadingEventArgs<TSensorReading> eventArgs = new SensorReadingEventArgs<TSensorReading>(default(TSensorReading));
|
||||
|
||||
public TSensorReading CurrentValue
|
||||
{
|
||||
get { return currentValue; }
|
||||
protected set
|
||||
{
|
||||
currentValue = value;
|
||||
|
||||
var handler = CurrentValueChanged;
|
||||
|
||||
if (handler != null)
|
||||
{
|
||||
eventArgs.SensorReading = value;
|
||||
handler(this, eventArgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
public bool IsDataValid { get; protected set; }
|
||||
public TimeSpan TimeBetweenUpdates
|
||||
{
|
||||
get { return this.timeBetweenUpdates; }
|
||||
set
|
||||
{
|
||||
if (this.timeBetweenUpdates != value)
|
||||
{
|
||||
this.timeBetweenUpdates = value;
|
||||
EventHelpers.Raise(this, TimeBetweenUpdatesChanged, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public event EventHandler<SensorReadingEventArgs<TSensorReading>> CurrentValueChanged;
|
||||
protected event EventHandler<EventArgs> TimeBetweenUpdatesChanged;
|
||||
protected bool IsDisposed { get { return disposed; } }
|
||||
|
||||
public SensorBase()
|
||||
{
|
||||
this.TimeBetweenUpdates = TimeSpan.FromMilliseconds(2);
|
||||
}
|
||||
|
||||
~SensorBase()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (disposed)
|
||||
throw new ObjectDisposedException(GetType().Name);
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Derived classes override this method to dispose of managed and unmanaged resources.
|
||||
/// </summary>
|
||||
/// <param name="disposing">True if unmanaged resources are to be disposed.</param>
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
disposed = true;
|
||||
}
|
||||
|
||||
public abstract void Start();
|
||||
|
||||
public abstract void Stop();
|
||||
}
|
||||
}
|
||||
|
||||
-19
@@ -1,19 +0,0 @@
|
||||
// MonoGame - Copyright (C) The MonoGame Team
|
||||
// This file is subject to the terms and conditions defined in
|
||||
// file 'LICENSE.txt', which is part of this source code package.
|
||||
|
||||
using System;
|
||||
|
||||
namespace Microsoft.Devices.Sensors
|
||||
{
|
||||
public class SensorFailedException : Exception
|
||||
{
|
||||
public int ErrorId { get; protected set; }
|
||||
|
||||
internal SensorFailedException(string message)
|
||||
: base(message)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-20
@@ -1,20 +0,0 @@
|
||||
// MonoGame - Copyright (C) The MonoGame Team
|
||||
// This file is subject to the terms and conditions defined in
|
||||
// file 'LICENSE.txt', which is part of this source code package.
|
||||
|
||||
using System;
|
||||
|
||||
namespace Microsoft.Devices.Sensors
|
||||
{
|
||||
public class SensorReadingEventArgs<T> : EventArgs
|
||||
where T : ISensorReading
|
||||
{
|
||||
public T SensorReading { get; set; }
|
||||
|
||||
public SensorReadingEventArgs(T sensorReading)
|
||||
{
|
||||
this.SensorReading = sensorReading;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-19
@@ -1,19 +0,0 @@
|
||||
// MonoGame - Copyright (C) The MonoGame Team
|
||||
// This file is subject to the terms and conditions defined in
|
||||
// file 'LICENSE.txt', which is part of this source code package.
|
||||
|
||||
using System;
|
||||
|
||||
namespace Microsoft.Devices.Sensors
|
||||
{
|
||||
public enum SensorState
|
||||
{
|
||||
NotSupported,
|
||||
Ready,
|
||||
Initializing,
|
||||
NoData,
|
||||
NoPermissions,
|
||||
Disabled
|
||||
}
|
||||
}
|
||||
|
||||
+43
-99
@@ -1,61 +1,42 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>10.0.0</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{35253CE1-C864-4CD3-8249-4D1319748E8F}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<TargetFramework>netstandard2.1</TargetFramework>
|
||||
<AssemblyName>MonoGame.Framework.Linux.NetStandard</AssemblyName>
|
||||
<RootNamespace>Microsoft.Xna.Framework</RootNamespace>
|
||||
<AssemblyName>MonoGame.Framework</AssemblyName>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<NoWarn>1591,0436</NoWarn>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
<TargetFrameworkProfile />
|
||||
<LangVersion>Default</LangVersion>
|
||||
<Platforms>AnyCPU;x64</Platforms>
|
||||
<Copyright>Copyright © 2009-2016 MonoGame Team</Copyright>
|
||||
<Authors>MonoGame Team</Authors>
|
||||
<Product>MonoGame.Framework</Product>
|
||||
<Version>3.7</Version>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<Optimize>false</Optimize>
|
||||
<DebugType>full</DebugType>
|
||||
<EnableUnmanagedDebugging>true</EnableUnmanagedDebugging>
|
||||
<OutputPath>bin\Linux\AnyCPU\Debug</OutputPath>
|
||||
<IntermediateOutputPath>obj\Linux\AnyCPU\Debug</IntermediateOutputPath>
|
||||
<DocumentationFile>bin\Linux\AnyCPU\Debug\MonoGame.Framework.xml</DocumentationFile>
|
||||
<DefineConstants>DEBUG;OPENGL;OPENAL;XNADESIGNPROVIDED;TRACE;LINUX;DESKTOPGL;SUPPORTS_EFX</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<OutputPath>..\..\DesktopGL\</OutputPath>
|
||||
<IntermediateOutputPath>obj\Linux\AnyCPU\Release</IntermediateOutputPath>
|
||||
<DocumentationFile>..\..\DesktopGL\MonoGame.Framework.xml</DocumentationFile>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||
<DefineConstants>OPENGL;OPENAL;XNADESIGNPROVIDED;TRACE;LINUX;DESKTOPGL;SUPPORTS_EFX</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<DefineConstants>OPENGL;OPENAL;XNADESIGNPROVIDED;TRACE;LINUX;DESKTOPGL;SUPPORTS_EFX</DefineConstants>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<DefineConstants>DEBUG;OPENGL;OPENAL;XNADESIGNPROVIDED;TRACE;LINUX;DESKTOPGL;SUPPORTS_EFX</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<DefineConstants>DEBUG;OPENGL;OPENAL;XNADESIGNPROVIDED;TRACE;LINUX;DESKTOPGL;SUPPORTS_EFX</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Runtime.Serialization" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Remove=".\**" />
|
||||
<EmbeddedResource Remove=".\**" />
|
||||
<None Remove=".\**" />
|
||||
<Compile Include="Clipboard.cs" />
|
||||
<Compile Include="MessageBox.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.DesktopGL.cs">
|
||||
<Platforms>WindowsGL,Linux</Platforms>
|
||||
</Compile>
|
||||
<Compile Include="BoundingBox.cs" />
|
||||
<Compile Include="BoundingFrustum.cs" />
|
||||
<Compile Include="BoundingSphere.cs" />
|
||||
<Compile Include="Color.cs" />
|
||||
<Compile Include="ContainmentType.cs" />
|
||||
<Compile Include="CurveContinuity.cs" />
|
||||
<Compile Include="Curve.cs" />
|
||||
<Compile Include="CurveKeyCollection.cs" />
|
||||
@@ -85,17 +66,9 @@
|
||||
<Compile Include="IGraphicsDeviceManager.cs" />
|
||||
<Compile Include="IUpdateable.cs" />
|
||||
<Compile Include="LaunchParameters.cs" />
|
||||
<Compile Include="MathHelper.cs" />
|
||||
<Compile Include="Matrix.cs" />
|
||||
<Compile Include="NamespaceDocs.cs" />
|
||||
<Compile Include="Plane.cs" />
|
||||
<Compile Include="PlaneIntersectionType.cs" />
|
||||
<Compile Include="PlayerIndex.cs" />
|
||||
<Compile Include="Point.cs" />
|
||||
<Compile Include="PreparingDeviceSettingsEventArgs.cs" />
|
||||
<Compile Include="Quaternion.cs" />
|
||||
<Compile Include="Ray.cs" />
|
||||
<Compile Include="Rectangle.cs" />
|
||||
<Compile Include="ReusableItemList.cs" />
|
||||
<Compile Include="TextInputEventArgs.cs">
|
||||
<Platforms>Angle,Linux,MacOS,Windows,WindowsGL,WindowsUniversal</Platforms>
|
||||
@@ -107,9 +80,6 @@
|
||||
<Compile Include="TitleContainer.Desktop.cs">
|
||||
<Platforms>Angle,Linux,Windows,WindowsGL,Web,MacOS</Platforms>
|
||||
</Compile>
|
||||
<Compile Include="Vector2.cs" />
|
||||
<Compile Include="Vector3.cs" />
|
||||
<Compile Include="Vector4.cs" />
|
||||
<Compile Include="Content\ContentExtensions.cs" />
|
||||
<Compile Include="Content\ContentLoadException.cs" />
|
||||
<Compile Include="Content\ContentManager.cs" />
|
||||
@@ -540,7 +510,7 @@
|
||||
<Services>_XNADesignProvided</Services>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="..\ThirdParty\Dependencies\MonoGame.Framework.dll.config">
|
||||
<Platforms>WindowsGL,Linux,MacOS</Platforms>
|
||||
@@ -598,6 +568,7 @@
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="MonoGame.bmp">
|
||||
<LogicalName>MonoGame.bmp</LogicalName>
|
||||
@@ -626,40 +597,13 @@
|
||||
<Services>_GLCompatible</Services>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<ItemGroup />
|
||||
<ItemGroup />
|
||||
<ItemGroup />
|
||||
<ItemGroup />
|
||||
<ItemGroup />
|
||||
<ItemGroup />
|
||||
<ItemGroup />
|
||||
<ItemGroup />
|
||||
<ItemGroup />
|
||||
<ItemGroup />
|
||||
<ItemGroup />
|
||||
<ItemGroup />
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<_PostBuildHookTimestamp>@(IntermediateAssembly->'%(FullPath).timestamp')</_PostBuildHookTimestamp>
|
||||
<_PostBuildHookHostPlatform>$(Platform)</_PostBuildHookHostPlatform>
|
||||
</PropertyGroup>
|
||||
<Target Name="PostBuildHooks" Inputs="@(IntermediateAssembly);@(ReferencePath)" Outputs="@(IntermediateAssembly);$(_PostBuildHookTimestamp)" AfterTargets="CoreCompile" BeforeTargets="AfterCompile">
|
||||
<Touch Files="$(_PostBuildHookTimestamp)" AlwaysCreate="True" />
|
||||
</Target>
|
||||
<PropertyGroup>
|
||||
<DefineConstants Condition=" '$(TargetFrameworkVersion)' != 'v4.0' And '$(TargetFrameworkVersion)' != 'v3.5' And '$(TargetFrameworkVersion)' != 'v3.0' And '$(TargetFrameworkVersion)' != 'v2.0' ">$(DefineConstants);NET45</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<ItemGroup />
|
||||
<ProjectExtensions>
|
||||
<MonoDevelop>
|
||||
<Properties>
|
||||
<Policies>
|
||||
<TextStylePolicy inheritsSet="VisualStudio" inheritsScope="text/plain" scope="text/x-csharp" />
|
||||
<CSharpFormattingPolicy IndentSwitchSection="True" NewLinesForBracesInProperties="True" NewLinesForBracesInAccessors="True" NewLinesForBracesInAnonymousMethods="True" NewLinesForBracesInControlBlocks="True" NewLinesForBracesInAnonymousTypes="True" NewLinesForBracesInObjectCollectionArrayInitializers="True" NewLinesForBracesInLambdaExpressionBody="True" NewLineForElse="True" NewLineForCatch="True" NewLineForFinally="True" NewLineForMembersInObjectInit="True" NewLineForMembersInAnonymousTypes="True" NewLineForClausesInQuery="True" SpacingAfterMethodDeclarationName="False" SpaceAfterMethodCallName="False" SpaceBeforeOpenSquareBracket="False" inheritsSet="Mono" inheritsScope="text/x-csharp" scope="text/x-csharp" />
|
||||
</Policies>
|
||||
</Properties>
|
||||
</MonoDevelop>
|
||||
</ProjectExtensions>
|
||||
</Project>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Properties\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\XNATypes\XNATypes.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
+568
@@ -0,0 +1,568 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.1</TargetFramework>
|
||||
<AssemblyName>MonoGame.Framework.MacOS.NetStandard</AssemblyName>
|
||||
<RootNamespace>Microsoft.Xna.Framework</RootNamespace>
|
||||
<Platforms>AnyCPU;x64</Platforms>
|
||||
<Copyright>Copyright © 2009-2016 MonoGame Team</Copyright>
|
||||
<Authors>MonoGame Team</Authors>
|
||||
<Product>MonoGame.Framework</Product>
|
||||
<Version>3.7</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||
<DefineConstants>OPENGL;OPENAL;XNADESIGNPROVIDED;TRACE;OSX;DESKTOPGL;SUPPORTS_EFX</DefineConstants>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<DefineConstants>OPENGL;OPENAL;XNADESIGNPROVIDED;TRACE;OSX;DESKTOPGL;SUPPORTS_EFX</DefineConstants>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<DefineConstants>DEBUG;OPENGL;OPENAL;XNADESIGNPROVIDED;TRACE;OSX;DESKTOPGL;SUPPORTS_EFX</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<DefineConstants>DEBUG;OPENGL;OPENAL;XNADESIGNPROVIDED;TRACE;OSX;DESKTOPGL;SUPPORTS_EFX</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove=".\**" />
|
||||
<EmbeddedResource Remove=".\**" />
|
||||
<None Remove=".\**" />
|
||||
<Compile Include="Clipboard.cs" />
|
||||
<Compile Include="MessageBox.cs" />
|
||||
<Compile Include="CurveContinuity.cs" />
|
||||
<Compile Include="Curve.cs" />
|
||||
<Compile Include="CurveKeyCollection.cs" />
|
||||
<Compile Include="CurveKey.cs" />
|
||||
<Compile Include="CurveLoopType.cs" />
|
||||
<Compile Include="CurveTangent.cs" />
|
||||
<Compile Include="DisplayOrientation.cs" />
|
||||
<Compile Include="DrawableGameComponent.cs" />
|
||||
<Compile Include="EventHelpers.cs" />
|
||||
<Compile Include="FrameworkDispatcher.cs" />
|
||||
<Compile Include="FrameworkResources.cs" />
|
||||
<Compile Include="GameComponentCollection.cs" />
|
||||
<Compile Include="GameComponentCollectionEventArgs.cs" />
|
||||
<Compile Include="GameComponent.cs" />
|
||||
<Compile Include="Game.cs" />
|
||||
<Compile Include="GamePlatform.cs" />
|
||||
<Compile Include="GamePlatform.Desktop.cs">
|
||||
<Platforms>Angle,Linux,MacOS,Windows,WindowsGL,WindowsUniversal</Platforms>
|
||||
</Compile>
|
||||
<Compile Include="GameRunBehavior.cs" />
|
||||
<Compile Include="GameServiceContainer.cs" />
|
||||
<Compile Include="GameTime.cs" />
|
||||
<Compile Include="GameUpdateRequiredException.cs" />
|
||||
<Compile Include="GameWindow.cs" />
|
||||
<Compile Include="IDrawable.cs" />
|
||||
<Compile Include="IGameComponent.cs" />
|
||||
<Compile Include="IGraphicsDeviceManager.cs" />
|
||||
<Compile Include="IUpdateable.cs" />
|
||||
<Compile Include="LaunchParameters.cs" />
|
||||
<Compile Include="NamespaceDocs.cs" />
|
||||
<Compile Include="PlayerIndex.cs" />
|
||||
<Compile Include="PreparingDeviceSettingsEventArgs.cs" />
|
||||
<Compile Include="ReusableItemList.cs" />
|
||||
<Compile Include="TextInputEventArgs.cs">
|
||||
<Platforms>Angle,Linux,MacOS,Windows,WindowsGL,WindowsUniversal</Platforms>
|
||||
</Compile>
|
||||
<Compile Include="Threading.cs">
|
||||
<Platforms>Android,Angle,iOS,Linux,MacOS,WindowsGL,tvOS</Platforms>
|
||||
</Compile>
|
||||
<Compile Include="TitleContainer.cs" />
|
||||
<Compile Include="TitleContainer.Desktop.cs">
|
||||
<Platforms>Angle,Linux,Windows,WindowsGL,Web,MacOS</Platforms>
|
||||
</Compile>
|
||||
<Compile Include="Content\ContentExtensions.cs" />
|
||||
<Compile Include="Content\ContentLoadException.cs" />
|
||||
<Compile Include="Content\ContentManager.cs" />
|
||||
<Compile Include="Content\ContentReader.cs" />
|
||||
<Compile Include="Content\ContentReaders\AlphaTestEffectReader.cs" />
|
||||
<Compile Include="Content\ContentReaders\ArrayReader.cs" />
|
||||
<Compile Include="Content\ContentReaders\BasicEffectReader.cs" />
|
||||
<Compile Include="Content\ContentReaders\BooleanReader.cs" />
|
||||
<Compile Include="Content\ContentReaders\BoundingBoxReader.cs" />
|
||||
<Compile Include="Content\ContentReaders\BoundingFrustumReader.cs" />
|
||||
<Compile Include="Content\ContentReaders\BoundingSphereReader.cs" />
|
||||
<Compile Include="Content\ContentReaders\ByteReader.cs" />
|
||||
<Compile Include="Content\ContentReaders\CharReader.cs" />
|
||||
<Compile Include="Content\ContentReaders\ColorReader.cs" />
|
||||
<Compile Include="Content\ContentReaders\CurveReader.cs" />
|
||||
<Compile Include="Content\ContentReaders\DateTimeReader.cs" />
|
||||
<Compile Include="Content\ContentReaders\DecimalReader.cs" />
|
||||
<Compile Include="Content\ContentReaders\DictionaryReader.cs" />
|
||||
<Compile Include="Content\ContentReaders\DoubleReader.cs" />
|
||||
<Compile Include="Content\ContentReaders\DualTextureEffectReader.cs">
|
||||
<ExcludePlatforms>Web</ExcludePlatforms>
|
||||
</Compile>
|
||||
<Compile Include="Content\ContentReaders\EffectMaterialReader.cs" />
|
||||
<Compile Include="Content\ContentReaders\EffectReader.cs" />
|
||||
<Compile Include="Content\ContentReaders\EnumReader.cs" />
|
||||
<Compile Include="Content\ContentReaders\EnvironmentMapEffectReader.cs">
|
||||
<ExcludePlatforms>Web</ExcludePlatforms>
|
||||
</Compile>
|
||||
<Compile Include="Content\ContentReaders\ExternalReferenceReader.cs" />
|
||||
<Compile Include="Content\ContentReaders\IndexBufferReader.cs" />
|
||||
<Compile Include="Content\ContentReaders\Int16Reader.cs" />
|
||||
<Compile Include="Content\ContentReaders\Int32Reader.cs" />
|
||||
<Compile Include="Content\ContentReaders\Int64Reader.cs" />
|
||||
<Compile Include="Content\ContentReaders\ListReader.cs" />
|
||||
<Compile Include="Content\ContentReaders\MatrixReader.cs" />
|
||||
<Compile Include="Content\ContentReaders\ModelReader.cs" />
|
||||
<Compile Include="Content\ContentReaders\MultiArrayReader.cs" />
|
||||
<Compile Include="Content\ContentReaders\NullableReader.cs" />
|
||||
<Compile Include="Content\ContentReaders\PlaneReader.cs" />
|
||||
<Compile Include="Content\ContentReaders\PointReader.cs" />
|
||||
<Compile Include="Content\ContentReaders\QuaternionReader.cs" />
|
||||
<Compile Include="Content\ContentReaders\RayReader.cs" />
|
||||
<Compile Include="Content\ContentReaders\RectangleReader.cs" />
|
||||
<Compile Include="Content\ContentReaders\ReflectiveReader.cs" />
|
||||
<Compile Include="Content\ContentReaders\SByteReader.cs" />
|
||||
<Compile Include="Content\ContentReaders\SingleReader.cs" />
|
||||
<Compile Include="Content\ContentReaders\SkinnedEffectReader.cs">
|
||||
<ExcludePlatforms>Web</ExcludePlatforms>
|
||||
</Compile>
|
||||
<Compile Include="Content\ContentReaders\SpriteFontReader.cs" />
|
||||
<Compile Include="Content\ContentReaders\StringReader.cs" />
|
||||
<Compile Include="Content\ContentReaders\Texture2DReader.cs" />
|
||||
<Compile Include="Content\ContentReaders\Texture3DReader.cs">
|
||||
<ExcludePlatforms>Android,iOS,tvOS,Web</ExcludePlatforms>
|
||||
</Compile>
|
||||
<Compile Include="Content\ContentReaders\TextureCubeReader.cs">
|
||||
<ExcludePlatforms>Web</ExcludePlatforms>
|
||||
</Compile>
|
||||
<Compile Include="Content\ContentReaders\TextureReader.cs">
|
||||
<ExcludePlatforms>Web</ExcludePlatforms>
|
||||
</Compile>
|
||||
<Compile Include="Content\ContentReaders\TimeSpanReader.cs" />
|
||||
<Compile Include="Content\ContentReaders\UInt16Reader.cs" />
|
||||
<Compile Include="Content\ContentReaders\UInt32Reader.cs" />
|
||||
<Compile Include="Content\ContentReaders\UInt64Reader.cs" />
|
||||
<Compile Include="Content\ContentReaders\Vector2Reader.cs" />
|
||||
<Compile Include="Content\ContentReaders\Vector3Reader.cs" />
|
||||
<Compile Include="Content\ContentReaders\Vector4Reader.cs" />
|
||||
<Compile Include="Content\ContentReaders\VertexBufferReader.cs" />
|
||||
<Compile Include="Content\ContentReaders\VertexDeclarationReader.cs" />
|
||||
<Compile Include="Content\ContentSerializerAttribute.cs" />
|
||||
<Compile Include="Content\ContentSerializerCollectionItemNameAttribute.cs" />
|
||||
<Compile Include="Content\ContentSerializerIgnoreAttribute.cs" />
|
||||
<Compile Include="Content\ContentSerializerRuntimeTypeAttribute.cs" />
|
||||
<Compile Include="Content\ContentSerializerTypeVersionAttribute.cs" />
|
||||
<Compile Include="Content\ContentTypeReader.cs" />
|
||||
<Compile Include="Content\ContentTypeReaderManager.cs" />
|
||||
<Compile Include="Content\LzxDecoder.cs" />
|
||||
<Compile Include="Content\ResourceContentManager.cs">
|
||||
<Platforms>Angle,Android,iOS,Linux,Windows,WindowsGL,tvOS</Platforms>
|
||||
</Compile>
|
||||
<Compile Include="Graphics\ClearOptions.cs" />
|
||||
<Compile Include="Graphics\ColorWriteChannels.cs" />
|
||||
<Compile Include="Graphics\CubeMapFace.cs" />
|
||||
<Compile Include="Graphics\DeviceLostException.cs" />
|
||||
<Compile Include="Graphics\DeviceNotResetException.cs" />
|
||||
<Compile Include="GraphicsDeviceInformation.cs" />
|
||||
<Compile Include="GraphicsDeviceManager.cs">
|
||||
<Platforms>Windows,WindowsGL,Linux,WindowsUniversal,Web,MacOS</Platforms>
|
||||
</Compile>
|
||||
<Compile Include="GraphicsDeviceManager.SDL.cs">
|
||||
<Platforms>WindowsGL,Linux,MacOS</Platforms>
|
||||
</Compile>
|
||||
<Compile Include="Graphics\GraphicsMetrics.cs" />
|
||||
<Compile Include="Graphics\DirectionalLight.cs" />
|
||||
<Compile Include="Graphics\DisplayModeCollection.cs" />
|
||||
<Compile Include="Graphics\DisplayMode.cs" />
|
||||
<Compile Include="Graphics\DxtUtil.cs" />
|
||||
<Compile Include="Graphics\Effect\AlphaTestEffect.cs" />
|
||||
<Compile Include="Graphics\Effect\BasicEffect.cs" />
|
||||
<Compile Include="Graphics\Effect\DualTextureEffect.cs">
|
||||
<ExcludePlatforms>Web</ExcludePlatforms>
|
||||
</Compile>
|
||||
<Compile Include="Graphics\Effect\EffectAnnotationCollection.cs" />
|
||||
<Compile Include="Graphics\Effect\EffectAnnotation.cs" />
|
||||
<Compile Include="Graphics\Effect\Effect.cs" />
|
||||
<Compile Include="Graphics\Effect\EffectHelpers.cs" />
|
||||
<Compile Include="Graphics\Effect\EffectMaterial.cs" />
|
||||
<Compile Include="Graphics\Effect\EffectParameterClass.cs" />
|
||||
<Compile Include="Graphics\Effect\EffectParameterCollection.cs" />
|
||||
<Compile Include="Graphics\Effect\EffectParameter.cs" />
|
||||
<Compile Include="Graphics\Effect\EffectParameterType.cs" />
|
||||
<Compile Include="Graphics\Effect\EffectPassCollection.cs" />
|
||||
<Compile Include="Graphics\Effect\EffectPass.cs" />
|
||||
<Compile Include="Graphics\Effect\EffectResource.cs" />
|
||||
<Compile Include="Graphics\Effect\EffectResource.OpenGL.cs">
|
||||
<Services>OpenGLGraphics,WebGraphics</Services>
|
||||
</Compile>
|
||||
<Compile Include="Graphics\Effect\EffectTechniqueCollection.cs" />
|
||||
<Compile Include="Graphics\Effect\EffectTechnique.cs" />
|
||||
<Compile Include="Graphics\Effect\EnvironmentMapEffect.cs">
|
||||
<ExcludePlatforms>Web</ExcludePlatforms>
|
||||
</Compile>
|
||||
<Compile Include="Graphics\Effect\IEffectFog.cs" />
|
||||
<Compile Include="Graphics\Effect\IEffectLights.cs" />
|
||||
<Compile Include="Graphics\Effect\IEffectMatrices.cs" />
|
||||
<Compile Include="Graphics\Effect\SkinnedEffect.cs">
|
||||
<ExcludePlatforms>Web</ExcludePlatforms>
|
||||
</Compile>
|
||||
<Compile Include="Graphics\Effect\SpriteEffect.cs" />
|
||||
<Compile Include="Graphics\GraphicsAdapter.Legacy.cs">
|
||||
<Platforms>Android,Angle,iOS,Linux,MacOS,WindowsGL,tvOS,Web</Platforms>
|
||||
</Compile>
|
||||
<Compile Include="Graphics\GraphicsCapabilities.cs" />
|
||||
<Compile Include="Graphics\GraphicsCapabilities.OpenGL.cs">
|
||||
<Services>OpenGLGraphics,ANGLEGraphics</Services>
|
||||
</Compile>
|
||||
<Compile Include="Graphics\GraphicsContext.SDL.cs">
|
||||
<Platforms>WindowsGL,Linux,MacOS</Platforms>
|
||||
</Compile>
|
||||
<Compile Include="Graphics\GraphicsDebug.cs" />
|
||||
<Compile Include="Graphics\GraphicsDebug.Default.cs">
|
||||
<Services>OpenGLGraphics,WebGraphics,ANGLEGraphics</Services>
|
||||
</Compile>
|
||||
<Compile Include="Graphics\GraphicsDebugMessage.cs" />
|
||||
<Compile Include="Graphics\GraphicsDevice.cs" />
|
||||
<Compile Include="Graphics\GraphicsDevice.OpenGL.cs">
|
||||
<Services>OpenGLGraphics</Services>
|
||||
</Compile>
|
||||
<Compile Include="Graphics\GraphicsDevice.OpenGL.FramebufferHelper.cs">
|
||||
<Services>OpenGLGraphics</Services>
|
||||
</Compile>
|
||||
<Compile Include="Graphics\GraphicsDeviceStatus.cs" />
|
||||
<Compile Include="Graphics\GraphicsExtensions.cs" />
|
||||
<Compile Include="Graphics\GraphicsProfile.cs" />
|
||||
<Compile Include="Graphics\GraphicsResource.cs" />
|
||||
<Compile Include="Graphics\IGraphicsContext.cs" />
|
||||
<Compile Include="Graphics\IGraphicsDeviceService.cs" />
|
||||
<Compile Include="Graphics\IRenderTarget.cs" />
|
||||
<Compile Include="Graphics\IWindowInfo.cs" />
|
||||
<Compile Include="Graphics\ModelBoneCollection.cs" />
|
||||
<Compile Include="Graphics\ModelBone.cs" />
|
||||
<Compile Include="Graphics\Model.cs" />
|
||||
<Compile Include="Graphics\ModelEffectCollection.cs" />
|
||||
<Compile Include="Graphics\ModelMeshCollection.cs" />
|
||||
<Compile Include="Graphics\ModelMesh.cs" />
|
||||
<Compile Include="Graphics\ModelMeshPartCollection.cs" />
|
||||
<Compile Include="Graphics\ModelMeshPart.cs" />
|
||||
<Compile Include="Graphics\NoSuitableGraphicsDeviceException.cs" />
|
||||
<Compile Include="Graphics\OcclusionQuery.cs">
|
||||
<ExcludePlatforms>iOS,Android</ExcludePlatforms>
|
||||
</Compile>
|
||||
<Compile Include="Graphics\OcclusionQuery.OpenGL.cs">
|
||||
<Services>ANGLEGraphics,OpenGLGraphics</Services>
|
||||
<ExcludePlatforms>iOS,Android</ExcludePlatforms>
|
||||
</Compile>
|
||||
<Compile Include="Graphics\OpenGL.cs">
|
||||
<Platforms>WindowsGL,Linux,iOS,MacOS,Android,Ouya,tvOS</Platforms>
|
||||
</Compile>
|
||||
<Compile Include="Graphics\OpenGL.Common.cs">
|
||||
<Platforms>WindowsGL,Linux,Android,Ouya</Platforms>
|
||||
</Compile>
|
||||
<Compile Include="Graphics\OpenGL.SDL.cs">
|
||||
<Platforms>WindowsGL,Linux,MacOS</Platforms>
|
||||
</Compile>
|
||||
<Compile Include="Graphics\PackedVector\Alpha8.cs" />
|
||||
<Compile Include="Graphics\PackedVector\Bgr565.cs" />
|
||||
<Compile Include="Graphics\PackedVector\Bgra4444.cs" />
|
||||
<Compile Include="Graphics\PackedVector\Bgra5551.cs" />
|
||||
<Compile Include="Graphics\PackedVector\Byte4.cs" />
|
||||
<Compile Include="Graphics\PackedVector\HalfSingle.cs" />
|
||||
<Compile Include="Graphics\PackedVector\HalfTypeHelper.cs" />
|
||||
<Compile Include="Graphics\PackedVector\HalfVector2.cs" />
|
||||
<Compile Include="Graphics\PackedVector\HalfVector4.cs" />
|
||||
<Compile Include="Graphics\PackedVector\IPackedVector.cs" />
|
||||
<Compile Include="Graphics\PackedVector\NormalizedByte2.cs" />
|
||||
<Compile Include="Graphics\PackedVector\NormalizedByte4.cs" />
|
||||
<Compile Include="Graphics\PackedVector\NormalizedShort2.cs" />
|
||||
<Compile Include="Graphics\PackedVector\NormalizedShort4.cs" />
|
||||
<Compile Include="Graphics\PackedVector\Rg32.cs" />
|
||||
<Compile Include="Graphics\PackedVector\Rgba64.cs" />
|
||||
<Compile Include="Graphics\PackedVector\Rgba1010102.cs" />
|
||||
<Compile Include="Graphics\PackedVector\Short2.cs" />
|
||||
<Compile Include="Graphics\PackedVector\Short4.cs" />
|
||||
<Compile Include="Graphics\PresentationEventArgs.cs" />
|
||||
<Compile Include="Graphics\PresentationParameters.cs" />
|
||||
<Compile Include="Graphics\PresentInterval.cs" />
|
||||
<Compile Include="Graphics\RenderTarget2D.cs" />
|
||||
<Compile Include="Graphics\RenderTarget2D.OpenGL.cs">
|
||||
<Services>OpenGLGraphics</Services>
|
||||
</Compile>
|
||||
<Compile Include="Graphics\RenderTargetBinding.cs" />
|
||||
<Compile Include="Graphics\RenderTargetCube.cs" />
|
||||
<Compile Include="Graphics\RenderTargetCube.OpenGL.cs">
|
||||
<Services>OpenGLGraphics</Services>
|
||||
</Compile>
|
||||
<Compile Include="Graphics\RenderTargetUsage.cs" />
|
||||
<Compile Include="Graphics\ResourceCreatedEventArgs.cs" />
|
||||
<Compile Include="Graphics\ResourceDestroyedEventArgs.cs" />
|
||||
<Compile Include="Graphics\SamplerStateCollection.cs" />
|
||||
<Compile Include="Graphics\SamplerStateCollection.OpenGL.cs">
|
||||
<Services>OpenGLGraphics</Services>
|
||||
</Compile>
|
||||
<Compile Include="Graphics\SetDataOptions.cs" />
|
||||
<Compile Include="Graphics\Shader\ConstantBufferCollection.cs" />
|
||||
<Compile Include="Graphics\Shader\ConstantBuffer.cs" />
|
||||
<Compile Include="Graphics\Shader\ConstantBuffer.OpenGL.cs">
|
||||
<Services>OpenGLGraphics</Services>
|
||||
</Compile>
|
||||
<Compile Include="Graphics\Shader\Shader.cs" />
|
||||
<Compile Include="Graphics\Shader\Shader.OpenGL.cs">
|
||||
<Services>OpenGLGraphics</Services>
|
||||
</Compile>
|
||||
<Compile Include="Graphics\Shader\ShaderProgramCache.cs">
|
||||
<Platforms>Android,Angle,iOS,Linux,MacOS,WindowsGL,tvOS</Platforms>
|
||||
</Compile>
|
||||
<Compile Include="Graphics\Shader\ShaderStage.cs" />
|
||||
<Compile Include="Graphics\SpriteBatch.cs" />
|
||||
<Compile Include="Graphics\SpriteBatcher.cs" />
|
||||
<Compile Include="Graphics\SpriteBatchItem.cs" />
|
||||
<Compile Include="Graphics\SpriteEffects.cs" />
|
||||
<Compile Include="Graphics\SpriteFont.cs" />
|
||||
<Compile Include="Graphics\SpriteSortMode.cs" />
|
||||
<Compile Include="Graphics\States\Blend.cs" />
|
||||
<Compile Include="Graphics\States\BlendFunction.cs" />
|
||||
<Compile Include="Graphics\States\BlendState.cs" />
|
||||
<Compile Include="Graphics\States\BlendState.OpenGL.cs">
|
||||
<Services>OpenGLGraphics</Services>
|
||||
</Compile>
|
||||
<Compile Include="Graphics\States\CompareFunction.cs" />
|
||||
<Compile Include="Graphics\States\CullMode.cs" />
|
||||
<Compile Include="Graphics\States\DepthFormat.cs" />
|
||||
<Compile Include="Graphics\States\DepthStencilState.cs" />
|
||||
<Compile Include="Graphics\States\DepthStencilState.OpenGL.cs">
|
||||
<Services>OpenGLGraphics</Services>
|
||||
</Compile>
|
||||
<Compile Include="Graphics\States\FillMode.cs" />
|
||||
<Compile Include="Graphics\States\RasterizerState.cs" />
|
||||
<Compile Include="Graphics\States\RasterizerState.OpenGL.cs">
|
||||
<Services>OpenGLGraphics</Services>
|
||||
</Compile>
|
||||
<Compile Include="Graphics\States\SamplerState.cs" />
|
||||
<Compile Include="Graphics\States\SamplerState.OpenGL.cs">
|
||||
<Services>OpenGLGraphics</Services>
|
||||
</Compile>
|
||||
<Compile Include="Graphics\States\StencilOperation.cs" />
|
||||
<Compile Include="Graphics\States\TargetBlendState.cs" />
|
||||
<Compile Include="Graphics\States\TextureAddressMode.cs" />
|
||||
<Compile Include="Graphics\States\TextureFilter.cs" />
|
||||
<Compile Include="Graphics\States\TextureFilterMode.cs" />
|
||||
<Compile Include="Graphics\SurfaceFormat.cs" />
|
||||
<Compile Include="Graphics\Texture2D.cs" />
|
||||
<Compile Include="Graphics\Texture2D.OpenGL.cs">
|
||||
<Services>OpenGLGraphics</Services>
|
||||
</Compile>
|
||||
<Compile Include="Graphics\Texture3D.cs" />
|
||||
<Compile Include="Graphics\Texture3D.OpenGL.cs">
|
||||
<Services>OpenGLGraphics</Services>
|
||||
</Compile>
|
||||
<Compile Include="Graphics\TextureCollection.cs" />
|
||||
<Compile Include="Graphics\TextureCollection.OpenGL.cs">
|
||||
<Services>OpenGLGraphics</Services>
|
||||
</Compile>
|
||||
<Compile Include="Graphics\Texture.cs" />
|
||||
<Compile Include="Graphics\Texture.OpenGL.cs">
|
||||
<Services>OpenGLGraphics</Services>
|
||||
</Compile>
|
||||
<Compile Include="Graphics\TextureCube.cs" />
|
||||
<Compile Include="Graphics\TextureCube.OpenGL.cs">
|
||||
<Services>OpenGLGraphics</Services>
|
||||
</Compile>
|
||||
<Compile Include="Graphics\Vertices\BufferUsage.cs" />
|
||||
<Compile Include="Graphics\Vertices\DynamicIndexBuffer.cs" />
|
||||
<Compile Include="Graphics\Vertices\DynamicVertexBuffer.cs" />
|
||||
<Compile Include="Graphics\Vertices\IndexBuffer.cs" />
|
||||
<Compile Include="Graphics\Vertices\IndexBuffer.OpenGL.cs">
|
||||
<Services>OpenGLGraphics</Services>
|
||||
</Compile>
|
||||
<Compile Include="Graphics\Vertices\IndexElementSize.cs" />
|
||||
<Compile Include="Graphics\Vertices\IVertexType.cs" />
|
||||
<Compile Include="Graphics\Vertices\PrimitiveType.cs" />
|
||||
<Compile Include="Graphics\Vertices\VertexBuffer.cs" />
|
||||
<Compile Include="Graphics\Vertices\VertexBuffer.OpenGL.cs">
|
||||
<Services>OpenGLGraphics</Services>
|
||||
</Compile>
|
||||
<Compile Include="Graphics\Vertices\VertexBufferBinding.cs" />
|
||||
<Compile Include="Graphics\Vertices\VertexBufferBindings.cs" />
|
||||
<Compile Include="Graphics\Vertices\VertexDeclarationCache.cs" />
|
||||
<Compile Include="Graphics\Vertices\VertexDeclaration.cs" />
|
||||
<Compile Include="Graphics\Vertices\VertexDeclaration.OpenGL.cs">
|
||||
<Services>OpenGLGraphics</Services>
|
||||
</Compile>
|
||||
<Compile Include="Graphics\Vertices\VertexElement.cs" />
|
||||
<Compile Include="Graphics\Vertices\VertexElementFormat.cs" />
|
||||
<Compile Include="Graphics\Vertices\VertexElementUsage.cs" />
|
||||
<Compile Include="Graphics\Vertices\VertexInputLayout.cs" />
|
||||
<Compile Include="Graphics\Vertices\VertexPosition.cs" />
|
||||
<Compile Include="Graphics\Vertices\VertexPositionColor.cs" />
|
||||
<Compile Include="Graphics\Vertices\VertexPositionColorTexture.cs" />
|
||||
<Compile Include="Graphics\Vertices\VertexPositionNormalTexture.cs" />
|
||||
<Compile Include="Graphics\Vertices\VertexPositionTexture.cs" />
|
||||
<Compile Include="Graphics\Viewport.cs" />
|
||||
<Compile Include="Graphics\WindowInfo.SDL.cs">
|
||||
<Platforms>WindowsGL,Linux,MacOS</Platforms>
|
||||
</Compile>
|
||||
<Compile Include="Input\Buttons.cs" />
|
||||
<Compile Include="Input\ButtonState.cs" />
|
||||
<Compile Include="Input\GamePad.cs" />
|
||||
<Compile Include="Input\GamePad.SDL.cs">
|
||||
<Platforms>Linux,WindowsGL,MacOS</Platforms>
|
||||
</Compile>
|
||||
<Compile Include="Input\GamePadButtons.cs" />
|
||||
<Compile Include="Input\GamePadCapabilities.cs" />
|
||||
<Compile Include="Input\GamePadDeadZone.cs" />
|
||||
<Compile Include="Input\GamePadDPad.cs" />
|
||||
<Compile Include="Input\GamePadState.cs" />
|
||||
<Compile Include="Input\GamePadThumbSticks.cs" />
|
||||
<Compile Include="Input\GamePadTriggers.cs" />
|
||||
<Compile Include="Input\GamePadType.cs" />
|
||||
<Compile Include="Input\Joystick.cs" />
|
||||
<Compile Include="Input\JoystickCapabilities.cs" />
|
||||
<Compile Include="Input\JoystickHat.cs" />
|
||||
<Compile Include="Input\JoystickState.cs" />
|
||||
<Compile Include="Input\Joystick.SDL.cs">
|
||||
<Platforms>Linux,WindowsGL,MacOS</Platforms>
|
||||
</Compile>
|
||||
<Compile Include="Input\Keyboard.cs">
|
||||
<ExcludePlatforms>Android</ExcludePlatforms>
|
||||
</Compile>
|
||||
<Compile Include="Input\Keyboard.SDL.cs">
|
||||
<Platforms>WindowsGL,Linux,MacOS</Platforms>
|
||||
</Compile>
|
||||
<Compile Include="Input\KeyboardState.cs" />
|
||||
<Compile Include="Input\Keys.cs" />
|
||||
<Compile Include="Input\KeyState.cs" />
|
||||
<Compile Include="Input\Mouse.cs" />
|
||||
<Compile Include="Input\Mouse.SDL.cs">
|
||||
<Platforms>WindowsGL,Linux,MacOS</Platforms>
|
||||
</Compile>
|
||||
<Compile Include="Input\MouseCursor.cs" />
|
||||
<Compile Include="Input\MouseCursor.SDL.cs">
|
||||
<Platforms>Linux,WindowsGL,MacOS</Platforms>
|
||||
</Compile>
|
||||
<Compile Include="Input\MouseState.cs" />
|
||||
<Compile Include="Input\Touch\GestureSample.cs" />
|
||||
<Compile Include="Input\Touch\GestureType.cs" />
|
||||
<Compile Include="Input\Touch\TouchCollection.cs" />
|
||||
<Compile Include="Input\Touch\TouchLocation.cs" />
|
||||
<Compile Include="Input\Touch\TouchLocationState.cs" />
|
||||
<Compile Include="Input\Touch\TouchPanel.cs" />
|
||||
<Compile Include="Input\Touch\TouchPanelCapabilities.cs" />
|
||||
<Compile Include="Input\Touch\TouchPanelState.cs" />
|
||||
<Compile Include="Utilities\AssemblyHelper.cs">
|
||||
<Platforms>Angle,Linux,MacOS,Windows,WindowsGL</Platforms>
|
||||
</Compile>
|
||||
<Compile Include="Utilities\CurrentPlatform.cs">
|
||||
<Platforms>Windows,MacOS,WindowsGL,Linux</Platforms>
|
||||
</Compile>
|
||||
<Compile Include="Utilities\Hash.cs" />
|
||||
<Compile Include="Utilities\FileHelpers.cs" />
|
||||
<Compile Include="Utilities\InteropHelpers.cs">
|
||||
<Services>OpenGLGraphics,OpenALAudio</Services>
|
||||
</Compile>
|
||||
<Compile Include="Utilities\ReflectionHelpers.cs" />
|
||||
<Compile Include="Utilities\ReflectionHelpers.Legacy.cs">
|
||||
<Platforms>Angle,Linux,MacOS,Windows,WindowsGL,Web</Platforms>
|
||||
</Compile>
|
||||
<Compile Include="Utilities\Lz4Stream\Lz4DecoderStream.cs" />
|
||||
<Compile Include="Utilities\LzxStream\LzxDecoderStream.cs" />
|
||||
<Compile Include="Utilities\ZLibStream\ZlibStream.cs" />
|
||||
<Compile Include="Utilities\Png\PngCommon.cs" />
|
||||
<Compile Include="Utilities\Png\PngReader.cs" />
|
||||
<Compile Include="Utilities\Png\PngWriter.cs" />
|
||||
<Compile Include="Utilities\ByteBufferPool.cs" />
|
||||
<Compile Include="Utilities\Imaging\Stb.Image.cs" />
|
||||
<Compile Include="Utilities\Imaging\Stb.Image.Generated.cs" />
|
||||
<Compile Include="Utilities\Imaging\ImageReader.cs" />
|
||||
<Compile Include="Utilities\Imaging\Stb.ImageWrite.cs" />
|
||||
<Compile Include="Utilities\Imaging\Stb.ImageWrite.Generated.cs" />
|
||||
<Compile Include="Utilities\Imaging\ImageWriter.cs" />
|
||||
<Compile Include="Utilities\Imaging\Operations.cs" />
|
||||
<Compile Include="Utilities\Imaging\PinnedArray.cs" />
|
||||
<Compile Include="Utilities\FuncLoader.Desktop.cs">
|
||||
<Platforms>Angle,Linux,WindowsGL,MacOS</Platforms>
|
||||
</Compile>
|
||||
<Compile Include="SDL\SDLGamePlatform.cs">
|
||||
<Platforms>Angle,Linux,WindowsGL,MacOS</Platforms>
|
||||
</Compile>
|
||||
<Compile Include="SDL\SDLGameWindow.cs">
|
||||
<Platforms>Angle,Linux,WindowsGL,MacOS</Platforms>
|
||||
</Compile>
|
||||
<Compile Include="SDL\SDL2.cs">
|
||||
<Platforms>WindowsGL,Linux,MacOS</Platforms>
|
||||
</Compile>
|
||||
<Compile Include="Input\KeyboardUtil.SDL.cs">
|
||||
<Platforms>Angle,Linux,WindowsGL,MacOS</Platforms>
|
||||
</Compile>
|
||||
<Compile Include="Design\VectorConversion.cs">
|
||||
<Services>_XNADesignProvided</Services>
|
||||
</Compile>
|
||||
<Compile Include="Design\Vector2TypeConverter.cs">
|
||||
<Services>_XNADesignProvided</Services>
|
||||
</Compile>
|
||||
<Compile Include="Design\Vector3TypeConverter.cs">
|
||||
<Services>_XNADesignProvided</Services>
|
||||
</Compile>
|
||||
<Compile Include="Design\Vector4TypeConverter.cs">
|
||||
<Services>_XNADesignProvided</Services>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="..\ThirdParty\Dependencies\MonoGame.Framework.dll.config">
|
||||
<Platforms>WindowsGL,Linux,MacOS</Platforms>
|
||||
<Link>MonoGame.Framework.dll.config</Link>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="..\ThirdParty\Dependencies\SDL\MacOS\Universal\libSDL2-2.0.0.dylib">
|
||||
<Platforms>WindowsGL,Linux,MacOS</Platforms>
|
||||
<Link>libSDL2-2.0.0.dylib</Link>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="..\ThirdParty\Dependencies\openal-soft\MacOS\Universal\libopenal.1.dylib">
|
||||
<Platforms>WindowsGL,Linux,MacOS</Platforms>
|
||||
<Link>libopenal.1.dylib</Link>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="MonoGame.bmp">
|
||||
<LogicalName>MonoGame.bmp</LogicalName>
|
||||
<Platforms>Angle,Linux,WindowsGL,MacOS</Platforms>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="..\ThirdParty\SDL_GameControllerDB\gamecontrollerdb.txt">
|
||||
<Platforms>Angle,Linux,WindowsGL,MacOS</Platforms>
|
||||
<LogicalName>gamecontrollerdb.txt</LogicalName>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Graphics\Effect\Resources\AlphaTestEffect.ogl.mgfxo">
|
||||
<Services>_GLCompatible</Services>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Graphics\Effect\Resources\BasicEffect.ogl.mgfxo">
|
||||
<Services>_GLCompatible</Services>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Graphics\Effect\Resources\DualTextureEffect.ogl.mgfxo">
|
||||
<Services>_GLCompatible</Services>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Graphics\Effect\Resources\EnvironmentMapEffect.ogl.mgfxo">
|
||||
<Services>_GLCompatible</Services>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Graphics\Effect\Resources\SkinnedEffect.ogl.mgfxo">
|
||||
<Services>_GLCompatible</Services>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Graphics\Effect\Resources\SpriteEffect.ogl.mgfxo">
|
||||
<Services>_GLCompatible</Services>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Properties\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\XNATypes\XNATypes.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
+58
-152
@@ -1,96 +1,51 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>10.0.0</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{7DE47032-A904-4C29-BD22-2D235E8D91BA}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<TargetFramework>netstandard2.1</TargetFramework>
|
||||
<AssemblyName>MonoGame.Framework.Windows.NetStandard</AssemblyName>
|
||||
<RootNamespace>Microsoft.Xna.Framework</RootNamespace>
|
||||
<AssemblyName>MonoGame.Framework</AssemblyName>
|
||||
<Platforms>AnyCPU;x64</Platforms>
|
||||
<Copyright>Copyright © 2009-2016 MonoGame Team</Copyright>
|
||||
<Authors>MonoGame Team</Authors>
|
||||
<Product>MonoGame.Framework</Product>
|
||||
<Version>3.7</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||
<DefineConstants>TRACE;XNADESIGNPROVIDED;WINDOWS;DIRECTX;WINDOWS_MEDIA_SESSION;NET45</DefineConstants>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<NoWarn>1591,0436</NoWarn>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
<TargetFrameworkProfile />
|
||||
<LangVersion>Default</LangVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<Optimize>false</Optimize>
|
||||
<DebugType>full</DebugType>
|
||||
<EnableUnmanagedDebugging>true</EnableUnmanagedDebugging>
|
||||
<OutputPath>..\..\Windows\</OutputPath>
|
||||
<IntermediateOutputPath>obj\Windows\AnyCPU\Debug</IntermediateOutputPath>
|
||||
<DocumentationFile>..\..\Windows\MonoGame.Framework.xml</DocumentationFile>
|
||||
<DefineConstants>DEBUG;XNADESIGNPROVIDED;TRACE;WINDOWS;DIRECTX;WINDOWS_MEDIA_SESSION</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<DefineConstants>TRACE;XNADESIGNPROVIDED;WINDOWS;DIRECTX;WINDOWS_MEDIA_SESSION;NET45</DefineConstants>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<OutputPath>..\..\Windows\</OutputPath>
|
||||
<IntermediateOutputPath>obj\Windows\AnyCPU\Release</IntermediateOutputPath>
|
||||
<DocumentationFile>..\..\Windows\MonoGame.Framework.xml</DocumentationFile>
|
||||
<DefineConstants>XNADESIGNPROVIDED;TRACE;WINDOWS;DIRECTX;WINDOWS_MEDIA_SESSION</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<DefineConstants>TRACE;XNADESIGNPROVIDED;WINDOWS;DIRECTX;WINDOWS_MEDIA_SESSION;NET45</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<DefineConstants>TRACE;XNADESIGNPROVIDED;WINDOWS;DIRECTX;WINDOWS_MEDIA_SESSION;NET45</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Runtime.Serialization" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Web.Services" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="SharpDX">
|
||||
<HintPath>..\ThirdParty\Dependencies\SharpDX\net40\SharpDX.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="SharpDX.Direct2D1">
|
||||
<HintPath>..\ThirdParty\Dependencies\SharpDX\SharpDX.Direct2D1.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="SharpDX.Direct3D11">
|
||||
<HintPath>..\ThirdParty\Dependencies\SharpDX\SharpDX.Direct3D11.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="SharpDX.DXGI">
|
||||
<HintPath>..\ThirdParty\Dependencies\SharpDX\SharpDX.DXGI.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="SharpDX.MediaFoundation">
|
||||
<HintPath>..\ThirdParty\Dependencies\SharpDX\net40\SharpDX.MediaFoundation.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="SharpDX.XAudio2">
|
||||
<HintPath>..\ThirdParty\Dependencies\SharpDX\net40\SharpDX.XAudio2.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="SharpDX.XInput">
|
||||
<HintPath>..\ThirdParty\Dependencies\SharpDX\net40\SharpDX.XInput.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Remove=".\**" />
|
||||
<EmbeddedResource Remove=".\**" />
|
||||
<None Remove=".\**" />
|
||||
<Compile Include="Clipboard.cs" />
|
||||
<Compile Include="GraphicsDeviceManager.SDL.cs" />
|
||||
<Compile Include="Graphics\SpriteEffects.cs" />
|
||||
<Compile Include="Input\GamePad.SDL.cs" />
|
||||
<Compile Include="Input\Joystick.SDL.cs" />
|
||||
<Compile Include="Input\Keyboard.SDL.cs" />
|
||||
<Compile Include="Input\KeyboardState.cs" />
|
||||
<Compile Include="Input\KeyboardUtil.SDL.cs" />
|
||||
<Compile Include="Input\KeyState.cs" />
|
||||
<Compile Include="Input\Mouse.SDL.cs" />
|
||||
<Compile Include="Input\MouseCursor.SDL.cs" />
|
||||
<Compile Include="MessageBox.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.Windows.cs">
|
||||
<Platforms>Windows</Platforms>
|
||||
</Compile>
|
||||
<Compile Include="BoundingBox.cs" />
|
||||
<Compile Include="BoundingFrustum.cs" />
|
||||
<Compile Include="BoundingSphere.cs" />
|
||||
<Compile Include="Color.cs" />
|
||||
<Compile Include="ContainmentType.cs" />
|
||||
<Compile Include="CurveContinuity.cs" />
|
||||
<Compile Include="Curve.cs" />
|
||||
<Compile Include="CurveKeyCollection.cs" />
|
||||
@@ -120,17 +75,10 @@
|
||||
<Compile Include="IGraphicsDeviceManager.cs" />
|
||||
<Compile Include="IUpdateable.cs" />
|
||||
<Compile Include="LaunchParameters.cs" />
|
||||
<Compile Include="MathHelper.cs" />
|
||||
<Compile Include="Matrix.cs" />
|
||||
<Compile Include="MessageBox.cs" />
|
||||
<Compile Include="NamespaceDocs.cs" />
|
||||
<Compile Include="Plane.cs" />
|
||||
<Compile Include="PlaneIntersectionType.cs" />
|
||||
<Compile Include="PlayerIndex.cs" />
|
||||
<Compile Include="Point.cs" />
|
||||
<Compile Include="PreparingDeviceSettingsEventArgs.cs" />
|
||||
<Compile Include="Quaternion.cs" />
|
||||
<Compile Include="Ray.cs" />
|
||||
<Compile Include="Rectangle.cs" />
|
||||
<Compile Include="ReusableItemList.cs" />
|
||||
<Compile Include="SDL\SDL2.cs" />
|
||||
<Compile Include="SDL\SDLGamePlatform.cs" />
|
||||
@@ -140,14 +88,9 @@
|
||||
</Compile>
|
||||
<Compile Include="Threading.cs" />
|
||||
<Compile Include="TitleContainer.cs" />
|
||||
<Compile Include="TitleContainer.Desktop.cs">
|
||||
<Platforms>Angle,Linux,Windows,WindowsGL,Web,MacOS</Platforms>
|
||||
</Compile>
|
||||
<Compile Include="TitleContainer.Desktop.cs" />
|
||||
<Compile Include="Utilities\FuncLoader.Desktop.cs" />
|
||||
<Compile Include="Utilities\InteropHelpers.cs" />
|
||||
<Compile Include="Vector2.cs" />
|
||||
<Compile Include="Vector3.cs" />
|
||||
<Compile Include="Vector4.cs" />
|
||||
<Compile Include="Content\ContentExtensions.cs" />
|
||||
<Compile Include="Content\ContentLoadException.cs" />
|
||||
<Compile Include="Content\ContentManager.cs" />
|
||||
@@ -375,7 +318,6 @@
|
||||
<Compile Include="Graphics\SpriteBatch.cs" />
|
||||
<Compile Include="Graphics\SpriteBatcher.cs" />
|
||||
<Compile Include="Graphics\SpriteBatchItem.cs" />
|
||||
<Compile Include="Graphics\SpriteEffects.cs" />
|
||||
<Compile Include="Graphics\SpriteFont.cs" />
|
||||
<Compile Include="Graphics\SpriteSortMode.cs" />
|
||||
<Compile Include="Graphics\States\Blend.cs" />
|
||||
@@ -490,9 +432,7 @@
|
||||
<Compile Include="Input\Keyboard.cs">
|
||||
<ExcludePlatforms>Android</ExcludePlatforms>
|
||||
</Compile>
|
||||
<Compile Include="Input\KeyboardState.cs" />
|
||||
<Compile Include="Input\Keys.cs" />
|
||||
<Compile Include="Input\KeyState.cs" />
|
||||
<Compile Include="Input\Mouse.cs" />
|
||||
<Compile Include="Input\MouseCursor.cs" />
|
||||
<Compile Include="Input\MouseState.cs" />
|
||||
@@ -552,63 +492,29 @@
|
||||
<Compile Include="Design\Vector4TypeConverter.cs">
|
||||
<Services>_XNADesignProvided</Services>
|
||||
</Compile>
|
||||
<EmbeddedResource Include="Graphics\Effect\Resources\AlphaTestEffect.dx11.mgfxo" />
|
||||
<EmbeddedResource Include="Graphics\Effect\Resources\BasicEffect.dx11.mgfxo" />
|
||||
<EmbeddedResource Include="Graphics\Effect\Resources\DualTextureEffect.dx11.mgfxo" />
|
||||
<EmbeddedResource Include="Graphics\Effect\Resources\EnvironmentMapEffect.dx11.mgfxo" />
|
||||
<EmbeddedResource Include="Graphics\Effect\Resources\SkinnedEffect.dx11.mgfxo" />
|
||||
<EmbeddedResource Include="Graphics\Effect\Resources\SpriteEffect.dx11.mgfxo" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<ItemGroup />
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Graphics\Effect\Resources\AlphaTestEffect.dx11.mgfxo">
|
||||
<Services>DirectXGraphics</Services>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Graphics\Effect\Resources\BasicEffect.dx11.mgfxo">
|
||||
<Services>DirectXGraphics</Services>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Graphics\Effect\Resources\DualTextureEffect.dx11.mgfxo">
|
||||
<Services>DirectXGraphics</Services>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Graphics\Effect\Resources\EnvironmentMapEffect.dx11.mgfxo">
|
||||
<Services>DirectXGraphics</Services>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Graphics\Effect\Resources\SkinnedEffect.dx11.mgfxo">
|
||||
<Services>DirectXGraphics</Services>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Graphics\Effect\Resources\SpriteEffect.dx11.mgfxo">
|
||||
<Services>DirectXGraphics</Services>
|
||||
</EmbeddedResource>
|
||||
<PackageReference Include="SharpDX" Version="4.2.0" />
|
||||
<PackageReference Include="SharpDX.Direct2D1" Version="4.2.0" />
|
||||
<PackageReference Include="SharpDX.Direct3D11" Version="4.2.0" />
|
||||
<PackageReference Include="SharpDX.DXGI" Version="4.2.0" />
|
||||
<PackageReference Include="SharpDX.MediaFoundation" Version="4.2.0" />
|
||||
<PackageReference Include="SharpDX.XInput" Version="4.2.0" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<ItemGroup />
|
||||
<ItemGroup />
|
||||
<ItemGroup />
|
||||
<ItemGroup />
|
||||
<ItemGroup />
|
||||
<ItemGroup />
|
||||
<ItemGroup />
|
||||
<ItemGroup />
|
||||
<ItemGroup />
|
||||
<ItemGroup />
|
||||
<ItemGroup />
|
||||
<ItemGroup />
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<_PostBuildHookTimestamp>@(IntermediateAssembly->'%(FullPath).timestamp')</_PostBuildHookTimestamp>
|
||||
<_PostBuildHookHostPlatform>$(Platform)</_PostBuildHookHostPlatform>
|
||||
</PropertyGroup>
|
||||
<Target Name="PostBuildHooks" Inputs="@(IntermediateAssembly);@(ReferencePath)" Outputs="@(IntermediateAssembly);$(_PostBuildHookTimestamp)" AfterTargets="CoreCompile" BeforeTargets="AfterCompile">
|
||||
<Touch Files="$(_PostBuildHookTimestamp)" AlwaysCreate="True" />
|
||||
</Target>
|
||||
<PropertyGroup>
|
||||
<DefineConstants Condition=" '$(TargetFrameworkVersion)' != 'v4.0' And '$(TargetFrameworkVersion)' != 'v3.5' And '$(TargetFrameworkVersion)' != 'v3.0' And '$(TargetFrameworkVersion)' != 'v2.0' ">$(DefineConstants);NET45</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<ItemGroup />
|
||||
<ProjectExtensions>
|
||||
<MonoDevelop>
|
||||
<Properties>
|
||||
<Policies>
|
||||
<TextStylePolicy inheritsSet="VisualStudio" inheritsScope="text/plain" scope="text/x-csharp" />
|
||||
<CSharpFormattingPolicy IndentSwitchSection="True" NewLinesForBracesInProperties="True" NewLinesForBracesInAccessors="True" NewLinesForBracesInAnonymousMethods="True" NewLinesForBracesInControlBlocks="True" NewLinesForBracesInAnonymousTypes="True" NewLinesForBracesInObjectCollectionArrayInitializers="True" NewLinesForBracesInLambdaExpressionBody="True" NewLineForElse="True" NewLineForCatch="True" NewLineForFinally="True" NewLineForMembersInObjectInit="True" NewLineForMembersInAnonymousTypes="True" NewLineForClausesInQuery="True" SpacingAfterMethodDeclarationName="False" SpaceAfterMethodCallName="False" SpaceBeforeOpenSquareBracket="False" inheritsSet="Mono" inheritsScope="text/x-csharp" scope="text/x-csharp" />
|
||||
</Policies>
|
||||
</Properties>
|
||||
</MonoDevelop>
|
||||
</ProjectExtensions>
|
||||
</Project>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Properties\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\XNATypes\XNATypes.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -1,296 +0,0 @@
|
||||
// MIT License - Copyright (C) The Mono.Xna Team
|
||||
// This file is subject to the terms and conditions defined in
|
||||
// file 'LICENSE.txt', which is part of this source code package.
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Microsoft.Xna.Framework
|
||||
{
|
||||
internal class PlaneHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns a value indicating what side (positive/negative) of a plane a point is
|
||||
/// </summary>
|
||||
/// <param name="point">The point to check with</param>
|
||||
/// <param name="plane">The plane to check against</param>
|
||||
/// <returns>Greater than zero if on the positive side, less than zero if on the negative size, 0 otherwise</returns>
|
||||
public static float ClassifyPoint(ref Vector3 point, ref Plane plane)
|
||||
{
|
||||
return point.X * plane.Normal.X + point.Y * plane.Normal.Y + point.Z * plane.Normal.Z + plane.D;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the perpendicular distance from a point to a plane
|
||||
/// </summary>
|
||||
/// <param name="point">The point to check</param>
|
||||
/// <param name="plane">The place to check</param>
|
||||
/// <returns>The perpendicular distance from the point to the plane</returns>
|
||||
public static float PerpendicularDistance(ref Vector3 point, ref Plane plane)
|
||||
{
|
||||
// dist = (ax + by + cz + d) / sqrt(a*a + b*b + c*c)
|
||||
return (float)Math.Abs((plane.Normal.X * point.X + plane.Normal.Y * point.Y + plane.Normal.Z * point.Z)
|
||||
/ Math.Sqrt(plane.Normal.X * plane.Normal.X + plane.Normal.Y * plane.Normal.Y + plane.Normal.Z * plane.Normal.Z));
|
||||
}
|
||||
}
|
||||
|
||||
[DataContract]
|
||||
[DebuggerDisplay("{DebugDisplayString,nq}")]
|
||||
public struct Plane : IEquatable<Plane>
|
||||
{
|
||||
#region Public Fields
|
||||
|
||||
[DataMember]
|
||||
public float D;
|
||||
|
||||
[DataMember]
|
||||
public Vector3 Normal;
|
||||
|
||||
#endregion Public Fields
|
||||
|
||||
|
||||
#region Constructors
|
||||
|
||||
public Plane(Vector4 value)
|
||||
: this(new Vector3(value.X, value.Y, value.Z), value.W)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public Plane(Vector3 normal, float d)
|
||||
{
|
||||
Normal = normal;
|
||||
D = d;
|
||||
}
|
||||
|
||||
public Plane(Vector3 a, Vector3 b, Vector3 c)
|
||||
{
|
||||
Vector3 ab = b - a;
|
||||
Vector3 ac = c - a;
|
||||
|
||||
Vector3 cross = Vector3.Cross(ab, ac);
|
||||
Vector3.Normalize(ref cross, out Normal);
|
||||
D = -(Vector3.Dot(Normal, a));
|
||||
}
|
||||
|
||||
public Plane(float a, float b, float c, float d)
|
||||
: this(new Vector3(a, b, c), d)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#endregion Constructors
|
||||
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public float Dot(Vector4 value)
|
||||
{
|
||||
return ((((this.Normal.X * value.X) + (this.Normal.Y * value.Y)) + (this.Normal.Z * value.Z)) + (this.D * value.W));
|
||||
}
|
||||
|
||||
public void Dot(ref Vector4 value, out float result)
|
||||
{
|
||||
result = (((this.Normal.X * value.X) + (this.Normal.Y * value.Y)) + (this.Normal.Z * value.Z)) + (this.D * value.W);
|
||||
}
|
||||
|
||||
public float DotCoordinate(Vector3 value)
|
||||
{
|
||||
return ((((this.Normal.X * value.X) + (this.Normal.Y * value.Y)) + (this.Normal.Z * value.Z)) + this.D);
|
||||
}
|
||||
|
||||
public void DotCoordinate(ref Vector3 value, out float result)
|
||||
{
|
||||
result = (((this.Normal.X * value.X) + (this.Normal.Y * value.Y)) + (this.Normal.Z * value.Z)) + this.D;
|
||||
}
|
||||
|
||||
public float DotNormal(Vector3 value)
|
||||
{
|
||||
return (((this.Normal.X * value.X) + (this.Normal.Y * value.Y)) + (this.Normal.Z * value.Z));
|
||||
}
|
||||
|
||||
public void DotNormal(ref Vector3 value, out float result)
|
||||
{
|
||||
result = ((this.Normal.X * value.X) + (this.Normal.Y * value.Y)) + (this.Normal.Z * value.Z);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Transforms a normalized plane by a matrix.
|
||||
/// </summary>
|
||||
/// <param name="plane">The normalized plane to transform.</param>
|
||||
/// <param name="matrix">The transformation matrix.</param>
|
||||
/// <returns>The transformed plane.</returns>
|
||||
public static Plane Transform(Plane plane, Matrix matrix)
|
||||
{
|
||||
Plane result;
|
||||
Transform(ref plane, ref matrix, out result);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Transforms a normalized plane by a matrix.
|
||||
/// </summary>
|
||||
/// <param name="plane">The normalized plane to transform.</param>
|
||||
/// <param name="matrix">The transformation matrix.</param>
|
||||
/// <param name="result">The transformed plane.</param>
|
||||
public static void Transform(ref Plane plane, ref Matrix matrix, out Plane result)
|
||||
{
|
||||
// See "Transforming Normals" in http://www.glprogramming.com/red/appendixf.html
|
||||
// for an explanation of how this works.
|
||||
|
||||
Matrix transformedMatrix;
|
||||
Matrix.Invert(ref matrix, out transformedMatrix);
|
||||
Matrix.Transpose(ref transformedMatrix, out transformedMatrix);
|
||||
|
||||
var vector = new Vector4(plane.Normal, plane.D);
|
||||
|
||||
Vector4 transformedVector;
|
||||
Vector4.Transform(ref vector, ref transformedMatrix, out transformedVector);
|
||||
|
||||
result = new Plane(transformedVector);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Transforms a normalized plane by a quaternion rotation.
|
||||
/// </summary>
|
||||
/// <param name="plane">The normalized plane to transform.</param>
|
||||
/// <param name="rotation">The quaternion rotation.</param>
|
||||
/// <returns>The transformed plane.</returns>
|
||||
public static Plane Transform(Plane plane, Quaternion rotation)
|
||||
{
|
||||
Plane result;
|
||||
Transform(ref plane, ref rotation, out result);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Transforms a normalized plane by a quaternion rotation.
|
||||
/// </summary>
|
||||
/// <param name="plane">The normalized plane to transform.</param>
|
||||
/// <param name="rotation">The quaternion rotation.</param>
|
||||
/// <param name="result">The transformed plane.</param>
|
||||
public static void Transform(ref Plane plane, ref Quaternion rotation, out Plane result)
|
||||
{
|
||||
Vector3.Transform(ref plane.Normal, ref rotation, out result.Normal);
|
||||
result.D = plane.D;
|
||||
}
|
||||
|
||||
public void Normalize()
|
||||
{
|
||||
float length = Normal.Length();
|
||||
float factor = 1f / length;
|
||||
Vector3.Multiply(ref Normal, factor, out Normal);
|
||||
D = D * factor;
|
||||
}
|
||||
|
||||
public static Plane Normalize(Plane value)
|
||||
{
|
||||
Plane ret;
|
||||
Normalize(ref value, out ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static void Normalize(ref Plane value, out Plane result)
|
||||
{
|
||||
float length = value.Normal.Length();
|
||||
float factor = 1f / length;
|
||||
Vector3.Multiply(ref value.Normal, factor, out result.Normal);
|
||||
result.D = value.D * factor;
|
||||
}
|
||||
|
||||
public static bool operator !=(Plane plane1, Plane plane2)
|
||||
{
|
||||
return !plane1.Equals(plane2);
|
||||
}
|
||||
|
||||
public static bool operator ==(Plane plane1, Plane plane2)
|
||||
{
|
||||
return plane1.Equals(plane2);
|
||||
}
|
||||
|
||||
public override bool Equals(object other)
|
||||
{
|
||||
return (other is Plane) ? this.Equals((Plane)other) : false;
|
||||
}
|
||||
|
||||
public bool Equals(Plane other)
|
||||
{
|
||||
return ((Normal == other.Normal) && (D == other.D));
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Normal.GetHashCode() ^ D.GetHashCode();
|
||||
}
|
||||
|
||||
public PlaneIntersectionType Intersects(BoundingBox box)
|
||||
{
|
||||
return box.Intersects(this);
|
||||
}
|
||||
|
||||
public void Intersects(ref BoundingBox box, out PlaneIntersectionType result)
|
||||
{
|
||||
box.Intersects (ref this, out result);
|
||||
}
|
||||
|
||||
public PlaneIntersectionType Intersects(BoundingFrustum frustum)
|
||||
{
|
||||
return frustum.Intersects(this);
|
||||
}
|
||||
|
||||
public PlaneIntersectionType Intersects(BoundingSphere sphere)
|
||||
{
|
||||
return sphere.Intersects(this);
|
||||
}
|
||||
|
||||
public void Intersects(ref BoundingSphere sphere, out PlaneIntersectionType result)
|
||||
{
|
||||
sphere.Intersects(ref this, out result);
|
||||
}
|
||||
|
||||
internal PlaneIntersectionType Intersects(ref Vector3 point)
|
||||
{
|
||||
float distance;
|
||||
DotCoordinate(ref point, out distance);
|
||||
|
||||
if (distance > 0)
|
||||
return PlaneIntersectionType.Front;
|
||||
|
||||
if (distance < 0)
|
||||
return PlaneIntersectionType.Back;
|
||||
|
||||
return PlaneIntersectionType.Intersecting;
|
||||
}
|
||||
|
||||
internal string DebugDisplayString
|
||||
{
|
||||
get
|
||||
{
|
||||
return string.Concat(
|
||||
this.Normal.DebugDisplayString, " ",
|
||||
this.D.ToString()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return "{Normal:" + Normal + " D:" + D + "}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deconstruction method for <see cref="Plane"/>.
|
||||
/// </summary>
|
||||
/// <param name="normal"></param>
|
||||
/// <param name="d"></param>
|
||||
public void Deconstruct(out Vector3 normal, out float d)
|
||||
{
|
||||
normal = Normal;
|
||||
d = D;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
// MIT License - Copyright (C) The Mono.Xna Team
|
||||
// This file is subject to the terms and conditions defined in
|
||||
// file 'LICENSE.txt', which is part of this source code package.
|
||||
|
||||
namespace Microsoft.Xna.Framework
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines the intersection between a <see cref="Plane"/> and a bounding volume.
|
||||
/// </summary>
|
||||
public enum PlaneIntersectionType
|
||||
{
|
||||
/// <summary>
|
||||
/// There is no intersection, the bounding volume is in the negative half space of the plane.
|
||||
/// </summary>
|
||||
Front,
|
||||
/// <summary>
|
||||
/// There is no intersection, the bounding volume is in the positive half space of the plane.
|
||||
/// </summary>
|
||||
Back,
|
||||
/// <summary>
|
||||
/// The plane is intersected.
|
||||
/// </summary>
|
||||
Intersecting
|
||||
}
|
||||
}
|
||||
@@ -1,234 +0,0 @@
|
||||
// MIT License - Copyright (C) The Mono.Xna Team
|
||||
// This file is subject to the terms and conditions defined in
|
||||
// file 'LICENSE.txt', which is part of this source code package.
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Microsoft.Xna.Framework
|
||||
{
|
||||
/// <summary>
|
||||
/// Describes a 2D-point.
|
||||
/// </summary>
|
||||
[DataContract]
|
||||
[DebuggerDisplay("{DebugDisplayString,nq}")]
|
||||
public struct Point : IEquatable<Point>
|
||||
{
|
||||
#region Private Fields
|
||||
|
||||
private static readonly Point zeroPoint = new Point();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Fields
|
||||
|
||||
/// <summary>
|
||||
/// The x coordinate of this <see cref="Point"/>.
|
||||
/// </summary>
|
||||
[DataMember]
|
||||
public int X;
|
||||
|
||||
/// <summary>
|
||||
/// The y coordinate of this <see cref="Point"/>.
|
||||
/// </summary>
|
||||
[DataMember]
|
||||
public int Y;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// Returns a <see cref="Point"/> with coordinates 0, 0.
|
||||
/// </summary>
|
||||
public static Point Zero
|
||||
{
|
||||
get { return zeroPoint; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Internal Properties
|
||||
|
||||
internal string DebugDisplayString
|
||||
{
|
||||
get
|
||||
{
|
||||
return string.Concat(
|
||||
this.X.ToString(), " ",
|
||||
this.Y.ToString()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a point with X and Y from two values.
|
||||
/// </summary>
|
||||
/// <param name="x">The x coordinate in 2d-space.</param>
|
||||
/// <param name="y">The y coordinate in 2d-space.</param>
|
||||
public Point(int x, int y)
|
||||
{
|
||||
this.X = x;
|
||||
this.Y = y;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a point with X and Y set to the same value.
|
||||
/// </summary>
|
||||
/// <param name="value">The x and y coordinates in 2d-space.</param>
|
||||
public Point(int value)
|
||||
{
|
||||
this.X = value;
|
||||
this.Y = value;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Operators
|
||||
|
||||
/// <summary>
|
||||
/// Adds two points.
|
||||
/// </summary>
|
||||
/// <param name="value1">Source <see cref="Point"/> on the left of the add sign.</param>
|
||||
/// <param name="value2">Source <see cref="Point"/> on the right of the add sign.</param>
|
||||
/// <returns>Sum of the points.</returns>
|
||||
public static Point operator +(Point value1, Point value2)
|
||||
{
|
||||
return new Point(value1.X + value2.X, value1.Y + value2.Y);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Subtracts a <see cref="Point"/> from a <see cref="Point"/>.
|
||||
/// </summary>
|
||||
/// <param name="value1">Source <see cref="Point"/> on the left of the sub sign.</param>
|
||||
/// <param name="value2">Source <see cref="Point"/> on the right of the sub sign.</param>
|
||||
/// <returns>Result of the subtraction.</returns>
|
||||
public static Point operator -(Point value1, Point value2)
|
||||
{
|
||||
return new Point(value1.X - value2.X, value1.Y - value2.Y);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Multiplies the components of two points by each other.
|
||||
/// </summary>
|
||||
/// <param name="value1">Source <see cref="Point"/> on the left of the mul sign.</param>
|
||||
/// <param name="value2">Source <see cref="Point"/> on the right of the mul sign.</param>
|
||||
/// <returns>Result of the multiplication.</returns>
|
||||
public static Point operator *(Point value1, Point value2)
|
||||
{
|
||||
return new Point(value1.X * value2.X, value1.Y * value2.Y);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Divides the components of a <see cref="Point"/> by the components of another <see cref="Point"/>.
|
||||
/// </summary>
|
||||
/// <param name="source">Source <see cref="Point"/> on the left of the div sign.</param>
|
||||
/// <param name="divisor">Divisor <see cref="Point"/> on the right of the div sign.</param>
|
||||
/// <returns>The result of dividing the points.</returns>
|
||||
public static Point operator /(Point source, Point divisor)
|
||||
{
|
||||
return new Point(source.X / divisor.X, source.Y / divisor.Y);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compares whether two <see cref="Point"/> instances are equal.
|
||||
/// </summary>
|
||||
/// <param name="a"><see cref="Point"/> instance on the left of the equal sign.</param>
|
||||
/// <param name="b"><see cref="Point"/> instance on the right of the equal sign.</param>
|
||||
/// <returns><c>true</c> if the instances are equal; <c>false</c> otherwise.</returns>
|
||||
public static bool operator ==(Point a, Point b)
|
||||
{
|
||||
return a.Equals(b);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compares whether two <see cref="Point"/> instances are not equal.
|
||||
/// </summary>
|
||||
/// <param name="a"><see cref="Point"/> instance on the left of the not equal sign.</param>
|
||||
/// <param name="b"><see cref="Point"/> instance on the right of the not equal sign.</param>
|
||||
/// <returns><c>true</c> if the instances are not equal; <c>false</c> otherwise.</returns>
|
||||
public static bool operator !=(Point a, Point b)
|
||||
{
|
||||
return !a.Equals(b);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public methods
|
||||
|
||||
/// <summary>
|
||||
/// Compares whether current instance is equal to specified <see cref="Object"/>.
|
||||
/// </summary>
|
||||
/// <param name="obj">The <see cref="Object"/> to compare.</param>
|
||||
/// <returns><c>true</c> if the instances are equal; <c>false</c> otherwise.</returns>
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return (obj is Point) && Equals((Point)obj);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compares whether current instance is equal to specified <see cref="Point"/>.
|
||||
/// </summary>
|
||||
/// <param name="other">The <see cref="Point"/> to compare.</param>
|
||||
/// <returns><c>true</c> if the instances are equal; <c>false</c> otherwise.</returns>
|
||||
public bool Equals(Point other)
|
||||
{
|
||||
return ((X == other.X) && (Y == other.Y));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the hash code of this <see cref="Point"/>.
|
||||
/// </summary>
|
||||
/// <returns>Hash code of this <see cref="Point"/>.</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
unchecked
|
||||
{
|
||||
var hash = 17;
|
||||
hash = hash * 23 + X.GetHashCode();
|
||||
hash = hash * 23 + Y.GetHashCode();
|
||||
return hash;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a <see cref="String"/> representation of this <see cref="Point"/> in the format:
|
||||
/// {X:[<see cref="X"/>] Y:[<see cref="Y"/>]}
|
||||
/// </summary>
|
||||
/// <returns><see cref="String"/> representation of this <see cref="Point"/>.</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return "{X:" + X + " Y:" + Y + "}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="Vector2"/> representation for this object.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="Vector2"/> representation for this object.</returns>
|
||||
public Vector2 ToVector2()
|
||||
{
|
||||
return new Vector2(X, Y);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deconstruction method for <see cref="Point"/>.
|
||||
/// </summary>
|
||||
/// <param name="x"></param>
|
||||
/// <param name="y"></param>
|
||||
public void Deconstruct(out int x, out int y)
|
||||
{
|
||||
x = X;
|
||||
y = Y;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,88 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Microsoft.Xna.Framework
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface used to add an object to be loaded on the primary thread
|
||||
/// </summary>
|
||||
interface IPrimaryThreadLoaded
|
||||
{
|
||||
bool Load();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Static class that is called before every draw to load resources that need to finish loading on the primary thread
|
||||
/// </summary>
|
||||
internal static class PrimaryThreadLoader
|
||||
{
|
||||
private static readonly object ListLockObject = new object();
|
||||
private static readonly List<IPrimaryThreadLoaded> NeedToLoad = new List<IPrimaryThreadLoaded>();
|
||||
private static readonly List<IPrimaryThreadLoaded> RemoveList = new List<IPrimaryThreadLoaded>();
|
||||
private static DateTime _lastUpdate = DateTime.UtcNow;
|
||||
|
||||
public static void AddToList(IPrimaryThreadLoaded primaryThreadLoaded)
|
||||
{
|
||||
lock (ListLockObject)
|
||||
{
|
||||
NeedToLoad.Add(primaryThreadLoaded);
|
||||
}
|
||||
}
|
||||
|
||||
public static void RemoveFromList(IPrimaryThreadLoaded primaryThreadLoaded)
|
||||
{
|
||||
lock (ListLockObject)
|
||||
{
|
||||
NeedToLoad.Remove(primaryThreadLoaded);
|
||||
}
|
||||
}
|
||||
|
||||
public static void RemoveFromList(List<IPrimaryThreadLoaded> primaryThreadLoadeds)
|
||||
{
|
||||
lock (ListLockObject)
|
||||
{
|
||||
foreach (var primaryThreadLoaded in primaryThreadLoadeds)
|
||||
{
|
||||
NeedToLoad.Remove(primaryThreadLoaded);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void Clear()
|
||||
{
|
||||
lock(ListLockObject)
|
||||
{
|
||||
NeedToLoad.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Loops through list and loads the item. If successful, it is removed from the list.
|
||||
/// </summary>
|
||||
public static void DoLoads()
|
||||
{
|
||||
if((DateTime.UtcNow - _lastUpdate).Milliseconds < 250) return;
|
||||
|
||||
_lastUpdate = DateTime.UtcNow;
|
||||
lock (ListLockObject)
|
||||
{
|
||||
for (int i = 0; i < NeedToLoad.Count; i++)
|
||||
{
|
||||
var primaryThreadLoaded = NeedToLoad[i];
|
||||
if (primaryThreadLoaded.Load())
|
||||
{
|
||||
RemoveList.Add(primaryThreadLoaded);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < RemoveList.Count; i++)
|
||||
{
|
||||
var primaryThreadLoaded = RemoveList[i];
|
||||
NeedToLoad.Remove(primaryThreadLoaded);
|
||||
}
|
||||
|
||||
RemoveList.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,272 +0,0 @@
|
||||
// MIT License - Copyright (C) The Mono.Xna Team
|
||||
// This file is subject to the terms and conditions defined in
|
||||
// file 'LICENSE.txt', which is part of this source code package.
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Microsoft.Xna.Framework
|
||||
{
|
||||
[DataContract]
|
||||
[DebuggerDisplay("{DebugDisplayString,nq}")]
|
||||
public struct Ray : IEquatable<Ray>
|
||||
{
|
||||
#region Public Fields
|
||||
|
||||
[DataMember]
|
||||
public Vector3 Direction;
|
||||
|
||||
[DataMember]
|
||||
public Vector3 Position;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region Public Constructors
|
||||
|
||||
public Ray(Vector3 position, Vector3 direction)
|
||||
{
|
||||
this.Position = position;
|
||||
this.Direction = direction;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return (obj is Ray) ? this.Equals((Ray)obj) : false;
|
||||
}
|
||||
|
||||
|
||||
public bool Equals(Ray other)
|
||||
{
|
||||
return this.Position.Equals(other.Position) && this.Direction.Equals(other.Direction);
|
||||
}
|
||||
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Position.GetHashCode() ^ Direction.GetHashCode();
|
||||
}
|
||||
|
||||
// adapted from http://www.scratchapixel.com/lessons/3d-basic-lessons/lesson-7-intersecting-simple-shapes/ray-box-intersection/
|
||||
public float? Intersects(BoundingBox box)
|
||||
{
|
||||
const float Epsilon = 1e-6f;
|
||||
|
||||
float? tMin = null, tMax = null;
|
||||
|
||||
if (Math.Abs(Direction.X) < Epsilon)
|
||||
{
|
||||
if (Position.X < box.Min.X || Position.X > box.Max.X)
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
tMin = (box.Min.X - Position.X) / Direction.X;
|
||||
tMax = (box.Max.X - Position.X) / Direction.X;
|
||||
|
||||
if (tMin > tMax)
|
||||
{
|
||||
var temp = tMin;
|
||||
tMin = tMax;
|
||||
tMax = temp;
|
||||
}
|
||||
}
|
||||
|
||||
if (Math.Abs(Direction.Y) < Epsilon)
|
||||
{
|
||||
if (Position.Y < box.Min.Y || Position.Y > box.Max.Y)
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
var tMinY = (box.Min.Y - Position.Y) / Direction.Y;
|
||||
var tMaxY = (box.Max.Y - Position.Y) / Direction.Y;
|
||||
|
||||
if (tMinY > tMaxY)
|
||||
{
|
||||
var temp = tMinY;
|
||||
tMinY = tMaxY;
|
||||
tMaxY = temp;
|
||||
}
|
||||
|
||||
if ((tMin.HasValue && tMin > tMaxY) || (tMax.HasValue && tMinY > tMax))
|
||||
return null;
|
||||
|
||||
if (!tMin.HasValue || tMinY > tMin) tMin = tMinY;
|
||||
if (!tMax.HasValue || tMaxY < tMax) tMax = tMaxY;
|
||||
}
|
||||
|
||||
if (Math.Abs(Direction.Z) < Epsilon)
|
||||
{
|
||||
if (Position.Z < box.Min.Z || Position.Z > box.Max.Z)
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
var tMinZ = (box.Min.Z - Position.Z) / Direction.Z;
|
||||
var tMaxZ = (box.Max.Z - Position.Z) / Direction.Z;
|
||||
|
||||
if (tMinZ > tMaxZ)
|
||||
{
|
||||
var temp = tMinZ;
|
||||
tMinZ = tMaxZ;
|
||||
tMaxZ = temp;
|
||||
}
|
||||
|
||||
if ((tMin.HasValue && tMin > tMaxZ) || (tMax.HasValue && tMinZ > tMax))
|
||||
return null;
|
||||
|
||||
if (!tMin.HasValue || tMinZ > tMin) tMin = tMinZ;
|
||||
if (!tMax.HasValue || tMaxZ < tMax) tMax = tMaxZ;
|
||||
}
|
||||
|
||||
// having a positive tMin and a negative tMax means the ray is inside the box
|
||||
// we expect the intesection distance to be 0 in that case
|
||||
if ((tMin.HasValue && tMin < 0) && tMax > 0) return 0;
|
||||
|
||||
// a negative tMin means that the intersection point is behind the ray's origin
|
||||
// we discard these as not hitting the AABB
|
||||
if (tMin < 0) return null;
|
||||
|
||||
return tMin;
|
||||
}
|
||||
|
||||
|
||||
public void Intersects(ref BoundingBox box, out float? result)
|
||||
{
|
||||
result = Intersects(box);
|
||||
}
|
||||
|
||||
/*
|
||||
public float? Intersects(BoundingFrustum frustum)
|
||||
{
|
||||
if (frustum == null)
|
||||
{
|
||||
throw new ArgumentNullException("frustum");
|
||||
}
|
||||
|
||||
return frustum.Intersects(this);
|
||||
}
|
||||
*/
|
||||
|
||||
public float? Intersects(BoundingSphere sphere)
|
||||
{
|
||||
float? result;
|
||||
Intersects(ref sphere, out result);
|
||||
return result;
|
||||
}
|
||||
|
||||
public float? Intersects(Plane plane)
|
||||
{
|
||||
float? result;
|
||||
Intersects(ref plane, out result);
|
||||
return result;
|
||||
}
|
||||
|
||||
public void Intersects(ref Plane plane, out float? result)
|
||||
{
|
||||
var den = Vector3.Dot(Direction, plane.Normal);
|
||||
if (Math.Abs(den) < 0.00001f)
|
||||
{
|
||||
result = null;
|
||||
return;
|
||||
}
|
||||
|
||||
result = (-plane.D - Vector3.Dot(plane.Normal, Position)) / den;
|
||||
|
||||
if (result < 0.0f)
|
||||
{
|
||||
if (result < -0.00001f)
|
||||
{
|
||||
result = null;
|
||||
return;
|
||||
}
|
||||
|
||||
result = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
public void Intersects(ref BoundingSphere sphere, out float? result)
|
||||
{
|
||||
// Find the vector between where the ray starts the the sphere's centre
|
||||
Vector3 difference = sphere.Center - this.Position;
|
||||
|
||||
float differenceLengthSquared = difference.LengthSquared();
|
||||
float sphereRadiusSquared = sphere.Radius * sphere.Radius;
|
||||
|
||||
float distanceAlongRay;
|
||||
|
||||
// If the distance between the ray start and the sphere's centre is less than
|
||||
// the radius of the sphere, it means we've intersected. N.B. checking the LengthSquared is faster.
|
||||
if (differenceLengthSquared < sphereRadiusSquared)
|
||||
{
|
||||
result = 0.0f;
|
||||
return;
|
||||
}
|
||||
|
||||
Vector3.Dot(ref this.Direction, ref difference, out distanceAlongRay);
|
||||
// If the ray is pointing away from the sphere then we don't ever intersect
|
||||
if (distanceAlongRay < 0)
|
||||
{
|
||||
result = null;
|
||||
return;
|
||||
}
|
||||
|
||||
// Next we kinda use Pythagoras to check if we are within the bounds of the sphere
|
||||
// if x = radius of sphere
|
||||
// if y = distance between ray position and sphere centre
|
||||
// if z = the distance we've travelled along the ray
|
||||
// if x^2 + z^2 - y^2 < 0, we do not intersect
|
||||
float dist = sphereRadiusSquared + distanceAlongRay * distanceAlongRay - differenceLengthSquared;
|
||||
|
||||
result = (dist < 0) ? null : distanceAlongRay - (float?)Math.Sqrt(dist);
|
||||
}
|
||||
|
||||
|
||||
public static bool operator !=(Ray a, Ray b)
|
||||
{
|
||||
return !a.Equals(b);
|
||||
}
|
||||
|
||||
|
||||
public static bool operator ==(Ray a, Ray b)
|
||||
{
|
||||
return a.Equals(b);
|
||||
}
|
||||
|
||||
internal string DebugDisplayString
|
||||
{
|
||||
get
|
||||
{
|
||||
return string.Concat(
|
||||
"Pos( ", this.Position.DebugDisplayString, " ) \r\n",
|
||||
"Dir( ", this.Direction.DebugDisplayString, " )"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return "{{Position:" + Position.ToString() + " Direction:" + Direction.ToString() + "}}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deconstruction method for <see cref="Ray"/>.
|
||||
/// </summary>
|
||||
/// <param name="position">Receives the start position of the ray.</param>
|
||||
/// <param name="direction">Receives the direction of the ray.</param>
|
||||
public void Deconstruct(out Vector3 position, out Vector3 direction)
|
||||
{
|
||||
position = Position;
|
||||
direction = Direction;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,539 +0,0 @@
|
||||
// MIT License - Copyright (C) The Mono.Xna Team
|
||||
// This file is subject to the terms and conditions defined in
|
||||
// file 'LICENSE.txt', which is part of this source code package.
|
||||
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Microsoft.Xna.Framework
|
||||
{
|
||||
/// <summary>
|
||||
/// Describes a 2D-rectangle.
|
||||
/// </summary>
|
||||
[DataContract]
|
||||
[DebuggerDisplay("{DebugDisplayString,nq}")]
|
||||
public struct Rectangle : IEquatable<Rectangle>
|
||||
{
|
||||
#region Private Fields
|
||||
|
||||
private static Rectangle emptyRectangle = new Rectangle();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Fields
|
||||
|
||||
/// <summary>
|
||||
/// The x coordinate of the top-left corner of this <see cref="Rectangle"/>.
|
||||
/// </summary>
|
||||
[DataMember]
|
||||
public int X;
|
||||
|
||||
/// <summary>
|
||||
/// The y coordinate of the top-left corner of this <see cref="Rectangle"/>.
|
||||
/// </summary>
|
||||
[DataMember]
|
||||
public int Y;
|
||||
|
||||
/// <summary>
|
||||
/// The width of this <see cref="Rectangle"/>.
|
||||
/// </summary>
|
||||
[DataMember]
|
||||
public int Width;
|
||||
|
||||
/// <summary>
|
||||
/// The height of this <see cref="Rectangle"/>.
|
||||
/// </summary>
|
||||
[DataMember]
|
||||
public int Height;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Properties
|
||||
|
||||
/// <summary>
|
||||
/// Returns a <see cref="Rectangle"/> with X=0, Y=0, Width=0, Height=0.
|
||||
/// </summary>
|
||||
public static Rectangle Empty
|
||||
{
|
||||
get { return emptyRectangle; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the x coordinate of the left edge of this <see cref="Rectangle"/>.
|
||||
/// </summary>
|
||||
public int Left
|
||||
{
|
||||
get { return this.X; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the x coordinate of the right edge of this <see cref="Rectangle"/>.
|
||||
/// </summary>
|
||||
public int Right
|
||||
{
|
||||
get { return (this.X + this.Width); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the y coordinate of the top edge of this <see cref="Rectangle"/>.
|
||||
/// </summary>
|
||||
public int Top
|
||||
{
|
||||
get { return this.Y; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the y coordinate of the bottom edge of this <see cref="Rectangle"/>.
|
||||
/// </summary>
|
||||
public int Bottom
|
||||
{
|
||||
get { return (this.Y + this.Height); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whether or not this <see cref="Rectangle"/> has a <see cref="Width"/> and
|
||||
/// <see cref="Height"/> of 0, and a <see cref="Location"/> of (0, 0).
|
||||
/// </summary>
|
||||
public bool IsEmpty
|
||||
{
|
||||
get
|
||||
{
|
||||
return ((((this.Width == 0) && (this.Height == 0)) && (this.X == 0)) && (this.Y == 0));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The top-left coordinates of this <see cref="Rectangle"/>.
|
||||
/// </summary>
|
||||
public Point Location
|
||||
{
|
||||
get
|
||||
{
|
||||
return new Point(this.X, this.Y);
|
||||
}
|
||||
set
|
||||
{
|
||||
X = value.X;
|
||||
Y = value.Y;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The width-height coordinates of this <see cref="Rectangle"/>.
|
||||
/// </summary>
|
||||
public Point Size
|
||||
{
|
||||
get
|
||||
{
|
||||
return new Point(this.Width,this.Height);
|
||||
}
|
||||
set
|
||||
{
|
||||
Width = value.X;
|
||||
Height = value.Y;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A <see cref="Point"/> located in the center of this <see cref="Rectangle"/>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// If <see cref="Width"/> or <see cref="Height"/> is an odd number,
|
||||
/// the center point will be rounded down.
|
||||
/// </remarks>
|
||||
public Point Center
|
||||
{
|
||||
get
|
||||
{
|
||||
return new Point(this.X + (this.Width / 2), this.Y + (this.Height / 2));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Internal Properties
|
||||
|
||||
internal string DebugDisplayString
|
||||
{
|
||||
get
|
||||
{
|
||||
return string.Concat(
|
||||
this.X, " ",
|
||||
this.Y, " ",
|
||||
this.Width, " ",
|
||||
this.Height
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of <see cref="Rectangle"/> struct, with the specified
|
||||
/// position, width, and height.
|
||||
/// </summary>
|
||||
/// <param name="x">The x coordinate of the top-left corner of the created <see cref="Rectangle"/>.</param>
|
||||
/// <param name="y">The y coordinate of the top-left corner of the created <see cref="Rectangle"/>.</param>
|
||||
/// <param name="width">The width of the created <see cref="Rectangle"/>.</param>
|
||||
/// <param name="height">The height of the created <see cref="Rectangle"/>.</param>
|
||||
public Rectangle(int x, int y, int width, int height)
|
||||
{
|
||||
this.X = x;
|
||||
this.Y = y;
|
||||
this.Width = width;
|
||||
this.Height = height;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of <see cref="Rectangle"/> struct, with the specified
|
||||
/// location and size.
|
||||
/// </summary>
|
||||
/// <param name="location">The x and y coordinates of the top-left corner of the created <see cref="Rectangle"/>.</param>
|
||||
/// <param name="size">The width and height of the created <see cref="Rectangle"/>.</param>
|
||||
public Rectangle(Point location,Point size)
|
||||
{
|
||||
this.X = location.X;
|
||||
this.Y = location.Y;
|
||||
this.Width = size.X;
|
||||
this.Height = size.Y;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Operators
|
||||
|
||||
/// <summary>
|
||||
/// Compares whether two <see cref="Rectangle"/> instances are equal.
|
||||
/// </summary>
|
||||
/// <param name="a"><see cref="Rectangle"/> instance on the left of the equal sign.</param>
|
||||
/// <param name="b"><see cref="Rectangle"/> instance on the right of the equal sign.</param>
|
||||
/// <returns><c>true</c> if the instances are equal; <c>false</c> otherwise.</returns>
|
||||
public static bool operator ==(Rectangle a, Rectangle b)
|
||||
{
|
||||
return ((a.X == b.X) && (a.Y == b.Y) && (a.Width == b.Width) && (a.Height == b.Height));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compares whether two <see cref="Rectangle"/> instances are not equal.
|
||||
/// </summary>
|
||||
/// <param name="a"><see cref="Rectangle"/> instance on the left of the not equal sign.</param>
|
||||
/// <param name="b"><see cref="Rectangle"/> instance on the right of the not equal sign.</param>
|
||||
/// <returns><c>true</c> if the instances are not equal; <c>false</c> otherwise.</returns>
|
||||
public static bool operator !=(Rectangle a, Rectangle b)
|
||||
{
|
||||
return !(a == b);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether or not the provided coordinates lie within the bounds of this <see cref="Rectangle"/>.
|
||||
/// </summary>
|
||||
/// <param name="x">The x coordinate of the point to check for containment.</param>
|
||||
/// <param name="y">The y coordinate of the point to check for containment.</param>
|
||||
/// <returns><c>true</c> if the provided coordinates lie inside this <see cref="Rectangle"/>; <c>false</c> otherwise.</returns>
|
||||
public bool Contains(int x, int y)
|
||||
{
|
||||
return ((((this.X <= x) && (x < (this.X + this.Width))) && (this.Y <= y)) && (y < (this.Y + this.Height)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether or not the provided coordinates lie within the bounds of this <see cref="Rectangle"/>.
|
||||
/// </summary>
|
||||
/// <param name="x">The x coordinate of the point to check for containment.</param>
|
||||
/// <param name="y">The y coordinate of the point to check for containment.</param>
|
||||
/// <returns><c>true</c> if the provided coordinates lie inside this <see cref="Rectangle"/>; <c>false</c> otherwise.</returns>
|
||||
public bool Contains(float x, float y)
|
||||
{
|
||||
return ((((this.X <= x) && (x < (this.X + this.Width))) && (this.Y <= y)) && (y < (this.Y + this.Height)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether or not the provided <see cref="Point"/> lies within the bounds of this <see cref="Rectangle"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">The coordinates to check for inclusion in this <see cref="Rectangle"/>.</param>
|
||||
/// <returns><c>true</c> if the provided <see cref="Point"/> lies inside this <see cref="Rectangle"/>; <c>false</c> otherwise.</returns>
|
||||
public bool Contains(Point value)
|
||||
{
|
||||
return ((((this.X <= value.X) && (value.X < (this.X + this.Width))) && (this.Y <= value.Y)) && (value.Y < (this.Y + this.Height)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether or not the provided <see cref="Point"/> lies within the bounds of this <see cref="Rectangle"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">The coordinates to check for inclusion in this <see cref="Rectangle"/>.</param>
|
||||
/// <param name="result"><c>true</c> if the provided <see cref="Point"/> lies inside this <see cref="Rectangle"/>; <c>false</c> otherwise. As an output parameter.</param>
|
||||
public void Contains(ref Point value, out bool result)
|
||||
{
|
||||
result = ((((this.X <= value.X) && (value.X < (this.X + this.Width))) && (this.Y <= value.Y)) && (value.Y < (this.Y + this.Height)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether or not the provided <see cref="Vector2"/> lies within the bounds of this <see cref="Rectangle"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">The coordinates to check for inclusion in this <see cref="Rectangle"/>.</param>
|
||||
/// <returns><c>true</c> if the provided <see cref="Vector2"/> lies inside this <see cref="Rectangle"/>; <c>false</c> otherwise.</returns>
|
||||
public bool Contains(Vector2 value)
|
||||
{
|
||||
return ((((this.X <= value.X) && (value.X < (this.X + this.Width))) && (this.Y <= value.Y)) && (value.Y < (this.Y + this.Height)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether or not the provided <see cref="Vector2"/> lies within the bounds of this <see cref="Rectangle"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">The coordinates to check for inclusion in this <see cref="Rectangle"/>.</param>
|
||||
/// <param name="result"><c>true</c> if the provided <see cref="Vector2"/> lies inside this <see cref="Rectangle"/>; <c>false</c> otherwise. As an output parameter.</param>
|
||||
public void Contains(ref Vector2 value, out bool result)
|
||||
{
|
||||
result = ((((this.X <= value.X) && (value.X < (this.X + this.Width))) && (this.Y <= value.Y)) && (value.Y < (this.Y + this.Height)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether or not the provided <see cref="Rectangle"/> lies within the bounds of this <see cref="Rectangle"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">The <see cref="Rectangle"/> to check for inclusion in this <see cref="Rectangle"/>.</param>
|
||||
/// <returns><c>true</c> if the provided <see cref="Rectangle"/>'s bounds lie entirely inside this <see cref="Rectangle"/>; <c>false</c> otherwise.</returns>
|
||||
public bool Contains(Rectangle value)
|
||||
{
|
||||
return ((((this.X <= value.X) && ((value.X + value.Width) <= (this.X + this.Width))) && (this.Y <= value.Y)) && ((value.Y + value.Height) <= (this.Y + this.Height)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether or not the provided <see cref="Rectangle"/> lies within the bounds of this <see cref="Rectangle"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">The <see cref="Rectangle"/> to check for inclusion in this <see cref="Rectangle"/>.</param>
|
||||
/// <param name="result"><c>true</c> if the provided <see cref="Rectangle"/>'s bounds lie entirely inside this <see cref="Rectangle"/>; <c>false</c> otherwise. As an output parameter.</param>
|
||||
public void Contains(ref Rectangle value,out bool result)
|
||||
{
|
||||
result = ((((this.X <= value.X) && ((value.X + value.Width) <= (this.X + this.Width))) && (this.Y <= value.Y)) && ((value.Y + value.Height) <= (this.Y + this.Height)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compares whether current instance is equal to specified <see cref="Object"/>.
|
||||
/// </summary>
|
||||
/// <param name="obj">The <see cref="Object"/> to compare.</param>
|
||||
/// <returns><c>true</c> if the instances are equal; <c>false</c> otherwise.</returns>
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return (obj is Rectangle) && this == ((Rectangle)obj);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compares whether current instance is equal to specified <see cref="Rectangle"/>.
|
||||
/// </summary>
|
||||
/// <param name="other">The <see cref="Rectangle"/> to compare.</param>
|
||||
/// <returns><c>true</c> if the instances are equal; <c>false</c> otherwise.</returns>
|
||||
public bool Equals(Rectangle other)
|
||||
{
|
||||
return this == other;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the hash code of this <see cref="Rectangle"/>.
|
||||
/// </summary>
|
||||
/// <returns>Hash code of this <see cref="Rectangle"/>.</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
unchecked
|
||||
{
|
||||
var hash = 17;
|
||||
hash = hash * 23 + X.GetHashCode();
|
||||
hash = hash * 23 + Y.GetHashCode();
|
||||
hash = hash * 23 + Width.GetHashCode();
|
||||
hash = hash * 23 + Height.GetHashCode();
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adjusts the edges of this <see cref="Rectangle"/> by specified horizontal and vertical amounts.
|
||||
/// </summary>
|
||||
/// <param name="horizontalAmount">Value to adjust the left and right edges.</param>
|
||||
/// <param name="verticalAmount">Value to adjust the top and bottom edges.</param>
|
||||
public void Inflate(int horizontalAmount, int verticalAmount)
|
||||
{
|
||||
X -= horizontalAmount;
|
||||
Y -= verticalAmount;
|
||||
Width += horizontalAmount * 2;
|
||||
Height += verticalAmount * 2;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adjusts the edges of this <see cref="Rectangle"/> by specified horizontal and vertical amounts.
|
||||
/// </summary>
|
||||
/// <param name="horizontalAmount">Value to adjust the left and right edges.</param>
|
||||
/// <param name="verticalAmount">Value to adjust the top and bottom edges.</param>
|
||||
public void Inflate(float horizontalAmount, float verticalAmount)
|
||||
{
|
||||
X -= (int)horizontalAmount;
|
||||
Y -= (int)verticalAmount;
|
||||
Width += (int)horizontalAmount * 2;
|
||||
Height += (int)verticalAmount * 2;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether or not the other <see cref="Rectangle"/> intersects with this rectangle.
|
||||
/// </summary>
|
||||
/// <param name="value">The other rectangle for testing.</param>
|
||||
/// <returns><c>true</c> if other <see cref="Rectangle"/> intersects with this rectangle; <c>false</c> otherwise.</returns>
|
||||
public bool Intersects(Rectangle value)
|
||||
{
|
||||
return value.Left < Right &&
|
||||
Left < value.Right &&
|
||||
value.Top < Bottom &&
|
||||
Top < value.Bottom;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether or not the other <see cref="Rectangle"/> intersects with this rectangle.
|
||||
/// </summary>
|
||||
/// <param name="value">The other rectangle for testing.</param>
|
||||
/// <param name="result"><c>true</c> if other <see cref="Rectangle"/> intersects with this rectangle; <c>false</c> otherwise. As an output parameter.</param>
|
||||
public void Intersects(ref Rectangle value, out bool result)
|
||||
{
|
||||
result = value.Left < Right &&
|
||||
Left < value.Right &&
|
||||
value.Top < Bottom &&
|
||||
Top < value.Bottom;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Rectangle"/> that contains overlapping region of two other rectangles.
|
||||
/// </summary>
|
||||
/// <param name="value1">The first <see cref="Rectangle"/>.</param>
|
||||
/// <param name="value2">The second <see cref="Rectangle"/>.</param>
|
||||
/// <returns>Overlapping region of the two rectangles.</returns>
|
||||
public static Rectangle Intersect(Rectangle value1, Rectangle value2)
|
||||
{
|
||||
Rectangle rectangle;
|
||||
Intersect(ref value1, ref value2, out rectangle);
|
||||
return rectangle;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Rectangle"/> that contains overlapping region of two other rectangles.
|
||||
/// </summary>
|
||||
/// <param name="value1">The first <see cref="Rectangle"/>.</param>
|
||||
/// <param name="value2">The second <see cref="Rectangle"/>.</param>
|
||||
/// <param name="result">Overlapping region of the two rectangles as an output parameter.</param>
|
||||
public static void Intersect(ref Rectangle value1, ref Rectangle value2, out Rectangle result)
|
||||
{
|
||||
if (value1.Intersects(value2))
|
||||
{
|
||||
int right_side = Math.Min(value1.X + value1.Width, value2.X + value2.Width);
|
||||
int left_side = Math.Max(value1.X, value2.X);
|
||||
int top_side = Math.Max(value1.Y, value2.Y);
|
||||
int bottom_side = Math.Min(value1.Y + value1.Height, value2.Y + value2.Height);
|
||||
result = new Rectangle(left_side, top_side, right_side - left_side, bottom_side - top_side);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = new Rectangle(0, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Changes the <see cref="Location"/> of this <see cref="Rectangle"/>.
|
||||
/// </summary>
|
||||
/// <param name="offsetX">The x coordinate to add to this <see cref="Rectangle"/>.</param>
|
||||
/// <param name="offsetY">The y coordinate to add to this <see cref="Rectangle"/>.</param>
|
||||
public void Offset(int offsetX, int offsetY)
|
||||
{
|
||||
X += offsetX;
|
||||
Y += offsetY;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Changes the <see cref="Location"/> of this <see cref="Rectangle"/>.
|
||||
/// </summary>
|
||||
/// <param name="offsetX">The x coordinate to add to this <see cref="Rectangle"/>.</param>
|
||||
/// <param name="offsetY">The y coordinate to add to this <see cref="Rectangle"/>.</param>
|
||||
public void Offset(float offsetX, float offsetY)
|
||||
{
|
||||
X += (int)offsetX;
|
||||
Y += (int)offsetY;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Changes the <see cref="Location"/> of this <see cref="Rectangle"/>.
|
||||
/// </summary>
|
||||
/// <param name="amount">The x and y components to add to this <see cref="Rectangle"/>.</param>
|
||||
public void Offset(Point amount)
|
||||
{
|
||||
X += amount.X;
|
||||
Y += amount.Y;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Changes the <see cref="Location"/> of this <see cref="Rectangle"/>.
|
||||
/// </summary>
|
||||
/// <param name="amount">The x and y components to add to this <see cref="Rectangle"/>.</param>
|
||||
public void Offset(Vector2 amount)
|
||||
{
|
||||
X += (int)amount.X;
|
||||
Y += (int)amount.Y;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a <see cref="String"/> representation of this <see cref="Rectangle"/> in the format:
|
||||
/// {X:[<see cref="X"/>] Y:[<see cref="Y"/>] Width:[<see cref="Width"/>] Height:[<see cref="Height"/>]}
|
||||
/// </summary>
|
||||
/// <returns><see cref="String"/> representation of this <see cref="Rectangle"/>.</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return "{X:" + X + " Y:" + Y + " Width:" + Width + " Height:" + Height + "}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Rectangle"/> that completely contains two other rectangles.
|
||||
/// </summary>
|
||||
/// <param name="value1">The first <see cref="Rectangle"/>.</param>
|
||||
/// <param name="value2">The second <see cref="Rectangle"/>.</param>
|
||||
/// <returns>The union of the two rectangles.</returns>
|
||||
public static Rectangle Union(Rectangle value1, Rectangle value2)
|
||||
{
|
||||
int x = Math.Min(value1.X, value2.X);
|
||||
int y = Math.Min(value1.Y, value2.Y);
|
||||
return new Rectangle(x, y,
|
||||
Math.Max(value1.Right, value2.Right) - x,
|
||||
Math.Max(value1.Bottom, value2.Bottom) - y);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Rectangle"/> that completely contains two other rectangles.
|
||||
/// </summary>
|
||||
/// <param name="value1">The first <see cref="Rectangle"/>.</param>
|
||||
/// <param name="value2">The second <see cref="Rectangle"/>.</param>
|
||||
/// <param name="result">The union of the two rectangles as an output parameter.</param>
|
||||
public static void Union(ref Rectangle value1, ref Rectangle value2, out Rectangle result)
|
||||
{
|
||||
result.X = Math.Min(value1.X, value2.X);
|
||||
result.Y = Math.Min(value1.Y, value2.Y);
|
||||
result.Width = Math.Max(value1.Right, value2.Right) - result.X;
|
||||
result.Height = Math.Max(value1.Bottom, value2.Bottom) - result.Y;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deconstruction method for <see cref="Rectangle"/>.
|
||||
/// </summary>
|
||||
/// <param name="x"></param>
|
||||
/// <param name="y"></param>
|
||||
/// <param name="width"></param>
|
||||
/// <param name="height"></param>
|
||||
public void Deconstruct(out int x, out int y, out int width, out int height)
|
||||
{
|
||||
x = X;
|
||||
y = Y;
|
||||
width = Width;
|
||||
height = Height;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
// MonoGame - Copyright (C) The MonoGame Team
|
||||
// This file is subject to the terms and conditions defined in
|
||||
// file 'LICENSE.txt', which is part of this source code package.
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Microsoft.Xna.Framework
|
||||
{
|
||||
partial class TitleContainer
|
||||
{
|
||||
private static Stream PlatformOpenStream(string safeName)
|
||||
{
|
||||
return Android.App.Application.Context.Assets.Open(safeName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
// MonoGame - Copyright (C) The MonoGame Team
|
||||
// This file is subject to the terms and conditions defined in
|
||||
// file 'LICENSE.txt', which is part of this source code package.
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
#if IOS
|
||||
using Foundation;
|
||||
using UIKit;
|
||||
#elif MONOMAC
|
||||
using Foundation;
|
||||
#endif
|
||||
|
||||
namespace Microsoft.Xna.Framework
|
||||
{
|
||||
partial class TitleContainer
|
||||
{
|
||||
static partial void PlatformInit()
|
||||
{
|
||||
Location = NSBundle.MainBundle.ResourcePath;
|
||||
#if IOS
|
||||
SupportRetina = UIScreen.MainScreen.Scale >= 2.0f;
|
||||
RetinaScale = (int)Math.Round(UIScreen.MainScreen.Scale);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if IOS
|
||||
static internal bool SupportRetina { get; private set; }
|
||||
static internal int RetinaScale { get; private set; }
|
||||
#endif
|
||||
|
||||
private static Stream PlatformOpenStream(string safeName)
|
||||
{
|
||||
#if IOS
|
||||
var absolutePath = Path.Combine(Location, safeName);
|
||||
if (SupportRetina)
|
||||
{
|
||||
for (var scale = RetinaScale; scale >= 2; scale--)
|
||||
{
|
||||
// Insert the @#x immediately prior to the extension. If this file exists
|
||||
// and we are on a Retina device, return this file instead.
|
||||
var absolutePathX = Path.Combine(Path.GetDirectoryName(absolutePath),
|
||||
Path.GetFileNameWithoutExtension(absolutePath)
|
||||
+ "@" + scale + "x" + Path.GetExtension(absolutePath));
|
||||
if (File.Exists(absolutePathX))
|
||||
return File.OpenRead(absolutePathX);
|
||||
}
|
||||
}
|
||||
return File.OpenRead(absolutePath);
|
||||
#else
|
||||
var absolutePath = Path.Combine(Location, safeName);
|
||||
return File.OpenRead(absolutePath);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
// MonoGame - Copyright (C) The MonoGame Team
|
||||
// This file is subject to the terms and conditions defined in
|
||||
// file 'LICENSE.txt', which is part of this source code package.
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using Windows.ApplicationModel.Resources.Core;
|
||||
|
||||
namespace Microsoft.Xna.Framework
|
||||
{
|
||||
partial class TitleContainer
|
||||
{
|
||||
static internal ResourceContext ResourceContext;
|
||||
static internal ResourceMap FileResourceMap;
|
||||
|
||||
static partial void PlatformInit()
|
||||
{
|
||||
Location = Windows.ApplicationModel.Package.Current.InstalledLocation.Path;
|
||||
|
||||
ResourceContext = new Windows.ApplicationModel.Resources.Core.ResourceContext();
|
||||
FileResourceMap = ResourceManager.Current.MainResourceMap.GetSubtree("Files");
|
||||
}
|
||||
|
||||
private static async Task<Stream> OpenStreamAsync(string name)
|
||||
{
|
||||
NamedResource result;
|
||||
|
||||
if (FileResourceMap != null && FileResourceMap.TryGetValue(name, out result))
|
||||
{
|
||||
var resolved = result.Resolve(ResourceContext);
|
||||
|
||||
try
|
||||
{
|
||||
var storageFile = await resolved.GetValueAsFileAsync();
|
||||
var randomAccessStream = await storageFile.OpenReadAsync();
|
||||
return randomAccessStream.AsStreamForRead();
|
||||
}
|
||||
catch (IOException)
|
||||
{
|
||||
// The file must not exist... return a null stream.
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static Stream PlatformOpenStream(string safeName)
|
||||
{
|
||||
return Task.Run(() => OpenStreamAsync(safeName).Result).Result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-1
@@ -2467,6 +2467,8 @@ namespace MonoGame.Utilities
|
||||
sbyte* zout = a->zout;
|
||||
for (;;)
|
||||
{
|
||||
if (a->zbuffer >= a->zbuffer_end) return (int)(stbi__err("overread"));
|
||||
|
||||
int z = (int) (stbi__zhuffman_decode(a, &a->z_length));
|
||||
if ((z) < (256))
|
||||
{
|
||||
@@ -4787,4 +4789,4 @@ namespace MonoGame.Utilities
|
||||
return (int) (stbi__info_main(s, x, y, comp));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user