- implemented feature #1026 ("Implement EffectParameter.Semantic")

- fixed issue #583 ("BoundingFrustum corners wrong")
This commit is contained in:
Glatzemann 2012-09-30 10:43:06 +00:00 committed by Konstantin Koch
parent d4cce42aa8
commit 41061f8b12
13 changed files with 320 additions and 464 deletions

View File

@ -144,7 +144,7 @@ namespace ANX.Framework.TestCenter
class AssertHelper
{
private const float epsilon = 0.0000001f;
private const int complementBits = 5;
private const int complementBits = 8;
#region Compare
@ -253,6 +253,30 @@ namespace ANX.Framework.TestCenter
#endregion
#region ConvertEquals
public static void ConvertEquals(Microsoft.Xna.Framework.PlaneIntersectionType xna, ANX.Framework.PlaneIntersectionType anx, String test)
{
if ((int)xna == (int)anx)
{
Assert.Pass(test + " passed");
}
else
{
Assert.Fail(String.Format("{0} failed: xna: ({1}) anx: ({2})", test, xna.ToString(), anx.ToString()));
}
}
public static void ConvertEquals(Microsoft.Xna.Framework.ContainmentType xna, ANX.Framework.ContainmentType anx, String test)
{
if ((int)xna == (int)anx)
{
Assert.Pass(test + " passed");
}
else
{
Assert.Fail(String.Format("{0} failed: xna: ({1}) anx: ({2})", test, xna.ToString(), anx.ToString()));
}
}
public static void ConvertEquals(float xna, float anx, String test)
{
if (AssertHelper.AlmostEqual2sComplement(xna, anx, complementBits) ||

View File

@ -95,10 +95,7 @@ namespace ANX.Framework.TestCenter.Strukturen
Microsoft.Xna.Framework.ContainmentType containsXNA = xnaFrustum.Contains(xnaBox);
ANX.Framework.ContainmentType containsANX = anxFrustum.Contains(anxBox);
if ((int)containsXNA == (int)containsANX)
Assert.Pass("ContainsBoundingBox passed: xna({0}) anx({1})", containsXNA.ToString(), containsANX.ToString());
else
Assert.Fail(String.Format("ContainsBoundingBox failed: xna({0}) anx({1})", containsXNA.ToString(), containsANX.ToString()));
AssertHelper.ConvertEquals(containsXNA, containsANX, "ContainsBoundingBox");
}
[Test, TestCaseSource("thirtytwofloats")]
@ -119,10 +116,7 @@ namespace ANX.Framework.TestCenter.Strukturen
Microsoft.Xna.Framework.ContainmentType containsXNA = xnaFrustum1.Contains(xnaFrustum2);
ANX.Framework.ContainmentType containsANX = anxFrustum1.Contains(anxFrustum2);
if ((int)containsXNA == (int)containsANX)
Assert.Pass("ContainsBoundingFrustum passed");
else
Assert.Fail(String.Format("ContainsBoundingFrustum failed: xna({0}) anx({1})", containsXNA.ToString(), containsANX.ToString()));
AssertHelper.ConvertEquals(containsXNA, containsANX, "ContainsBoundingFrustum");
}
[Test, TestCaseSource("thirtytwofloats")]
@ -144,10 +138,7 @@ namespace ANX.Framework.TestCenter.Strukturen
Microsoft.Xna.Framework.ContainmentType containsXNA = xnaFrustum.Contains(xnaSphere);
ANX.Framework.ContainmentType containsANX = anxFrustum.Contains(anxSphere);
if ((int)containsXNA == (int)containsANX)
Assert.Pass("ContainsBoundingSphere passed");
else
Assert.Fail(String.Format("ContainsBoundingSphere failed: xna({0}) anx({1})", containsXNA.ToString(), containsANX.ToString()));
AssertHelper.ConvertEquals(containsXNA, containsANX, "ContainsBoundingSphere");
}
[Test, TestCaseSource("thirtytwofloats")]
@ -167,10 +158,7 @@ namespace ANX.Framework.TestCenter.Strukturen
Microsoft.Xna.Framework.ContainmentType containsXNA = xnaFrustum.Contains(xnaPoint);
ANX.Framework.ContainmentType containsANX = anxFrustum.Contains(anxPoint);
if ((int)containsXNA == (int)containsANX)
Assert.Pass("ContainsPoint passed");
else
Assert.Fail(String.Format("ContainsPoint failed: xna({0}) anx({1})", containsXNA.ToString(), containsANX.ToString()));
AssertHelper.ConvertEquals(containsXNA, containsANX, "ContainsPoint");
}
[Test, TestCaseSource("thirtytwofloats")]
@ -231,49 +219,7 @@ namespace ANX.Framework.TestCenter.Strukturen
XNAVector3[] xna = xnaFrustum.GetCorners();
ANXVector3[] anx = anxFrustum.GetCorners();
if (xna[0].X == anx[0].X &&
xna[0].Y == anx[0].Y &&
xna[0].Z == anx[0].Z &&
xna[1].X == anx[1].X &&
xna[1].Y == anx[1].Y &&
xna[1].Z == anx[1].Z &&
xna[2].X == anx[2].X &&
xna[2].Y == anx[2].Y &&
xna[2].Z == anx[2].Z &&
xna[3].X == anx[3].X &&
xna[3].Y == anx[3].Y &&
xna[3].Z == anx[3].Z &&
xna[4].X == anx[4].X &&
xna[4].Y == anx[4].Y &&
xna[4].Z == anx[4].Z &&
xna[5].X == anx[5].X &&
xna[5].Y == anx[5].Y &&
xna[5].Z == anx[5].Z &&
xna[6].X == anx[6].X &&
xna[6].Y == anx[6].Y &&
xna[6].Z == anx[6].Z &&
xna[7].X == anx[7].X &&
xna[7].Y == anx[7].Y &&
xna[7].Z == anx[7].Z)
Assert.Pass("GetCorners passed");
else
Assert.Fail("GetCorners failed: xna(" +
xna[0].ToString() + " " +
xna[1].ToString() + " " +
xna[2].ToString() + " " +
xna[3].ToString() + " " +
xna[4].ToString() + " " +
xna[5].ToString() + " " +
xna[6].ToString() + " " +
xna[7].ToString() + ") anx(" +
anx[0].ToString() + " " +
anx[1].ToString() + " " +
anx[2].ToString() + " " +
anx[3].ToString() + " " +
anx[4].ToString() + " " +
anx[5].ToString() + " " +
anx[6].ToString() + " " +
anx[7].ToString() + ")");
AssertHelper.ConvertEquals(xna, anx, "GetCorners");
}
[Test, TestCaseSource("thirtytwofloats")]
@ -312,10 +258,7 @@ namespace ANX.Framework.TestCenter.Strukturen
bool containsXNA = xnaFrustum.Intersects(xnaBox);
bool containsANX = anxFrustum.Intersects(anxBox);
if (containsXNA.Equals(containsANX))
Assert.Pass("IntersectsBoundingBox passed");
else
Assert.Fail(String.Format("IntersectsBoundingBox failed: xna({0}) anx({1})", containsXNA.ToString(), containsANX.ToString()));
AssertHelper.ConvertEquals(containsXNA, containsANX, "IntersectsBoundingBox");
}
[Test, TestCaseSource("thirtytwofloats")]
@ -336,10 +279,7 @@ namespace ANX.Framework.TestCenter.Strukturen
bool xna = xnaFrustum1.Intersects(xnaFrustum2);
bool anx = anxFrustum1.Intersects(anxFrustum2);
if (xna.Equals(anx))
Assert.Pass("IntersectsBoundingFrustum passed");
else
Assert.Fail(String.Format("IntersectsBoundingFrustum failed: xna({0}) anx({1})", xna.ToString(), anx.ToString()));
AssertHelper.ConvertEquals(xna, anx, "IntersectsBoundingFrustum");
}
[Test, TestCaseSource("thirtytwofloats")]
@ -361,10 +301,7 @@ namespace ANX.Framework.TestCenter.Strukturen
bool xna = xnaFrustum.Intersects(xnaSphere);
bool anx = anxFrustum.Intersects(anxSphere);
if (xna.Equals(anx))
Assert.Pass("IntersectsBoundingSphere passed");
else
Assert.Fail(String.Format("IntersectsBoundingSphere failed: xna({0}) anx({1})", xna.ToString(), anx.ToString()));
AssertHelper.ConvertEquals(xna, anx, "IntersectsBoundingSphere");
}
[Test, TestCaseSource("thirtytwofloats")]
@ -384,10 +321,7 @@ namespace ANX.Framework.TestCenter.Strukturen
Microsoft.Xna.Framework.PlaneIntersectionType xna = xnaFrustum.Intersects(xnaPlane);
ANX.Framework.PlaneIntersectionType anx = anxFrustum.Intersects(anxPlane);
if ((int)xna == (int)anx)
Assert.Pass("IntersectsPlane passed");
else
Assert.Fail(String.Format("IntersectsPlane failed: xna({0}) anx({1})", xna.ToString(), anx.ToString()));
AssertHelper.ConvertEquals(xna, anx, "IntersectsPlane");
}
[Test, TestCaseSource("thirtytwofloats")]
@ -407,10 +341,7 @@ namespace ANX.Framework.TestCenter.Strukturen
float? xna = xnaFrustum.Intersects(xnaRay);
float? anx = anxFrustum.Intersects(anxRay);
if (xna.Equals(anx))
Assert.Pass("IntersectsRay passed");
else
Assert.Fail(String.Format("IntersectsRay failed: xna({0}) anx({1})", xna.ToString(), anx.ToString()));
AssertHelper.ConvertEquals(xna, anx, "IntersectsRay");
}
#endregion
@ -537,14 +468,7 @@ namespace ANX.Framework.TestCenter.Strukturen
bool xna = xnaFrustum1 == xnaFrustum2;
bool anx = anxFrustum1 == anxFrustum2;
if (xna.Equals(anx))
{
Assert.Pass("EqualsOperator passed");
}
else
{
Assert.Fail(String.Format("EqualsOperator failed: xna({0}) anx({1})", xna.ToString(), anx.ToString()));
}
AssertHelper.ConvertEquals(xna, anx, "EqualsOperator");
}
[Test, TestCaseSource("thirtytwofloats")]
@ -565,14 +489,7 @@ namespace ANX.Framework.TestCenter.Strukturen
bool xna = xnaFrustum1 != xnaFrustum2;
bool anx = anxFrustum1 != anxFrustum2;
if (xna.Equals(anx))
{
Assert.Pass("UnequalsOperator passed");
}
else
{
Assert.Fail(String.Format("UnequalsOperator failed: xna({0}) anx({1})", xna.ToString(), anx.ToString()));
}
AssertHelper.ConvertEquals(xna, anx, "UnequalsOperator");
}
#endregion
}

View File

@ -1,5 +1,6 @@
#region Using Statements
using System;
using ANX.Framework.NonXNA.Development;
#endregion // Using Statements
@ -10,51 +11,35 @@ using System;
namespace ANX.Framework
{
[PercentageComplete(100)]
[TestState(TestStateAttribute.TestState.InProgress)]
[Developer("???, Glatzemann")]
public class BoundingFrustum : IEquatable<BoundingFrustum>
{
#region fields
public const int CornerCount = 8;
#endregion
#region properties
private Vector3[] corners;
private Plane[] planes = new Plane[6];
private Matrix matrix;
public Matrix Matrix
{
get { return this.matrix; }
set
{
this.matrix = value;
this.CreatePlanes();
this.CreateCorners();
}
private enum PlanePosition : int
{
Near = 0,
Far = 1,
Left = 2,
Right = 3,
Top = 4,
Bottom = 5,
}
private Plane near;
public Plane Near { get { return this.near; } }
private Plane far;
public Plane Far { get { return this.far; } }
private Plane top;
public Plane Top { get { return this.top; } }
private Plane bottom;
public Plane Bottom { get { return this.bottom; } }
private Plane right;
public Plane Right { get { return this.right; } }
private Plane left;
public Plane Left { get { return this.left; } }
#endregion
#region constructors
public BoundingFrustum(Matrix value)
{
corners = new Vector3[CornerCount];
this.matrix = value;
CreatePlanes();
CreateCorners();
}
@ -70,244 +55,54 @@ namespace ANX.Framework
public void Contains(ref BoundingBox box, out ContainmentType result)
{
Vector3[] boxCorners = box.GetCorners();
result = ContainmentType.Contains;
Plane plane = Bottom;
Vector3 normal = plane.Normal;
//Vector3.Negate(ref normal, out normal);
float planeDistance = plane.D;
Vector3 pVertex = box.Min;
if (normal.X >= 0)
pVertex.X = box.Max.X;
if (normal.Y >= 0)
pVertex.Y = box.Max.Y;
if (normal.Z < 0)
pVertex.Z = box.Max.Z;
float tempDistP;
Vector3.Dot(ref normal, ref pVertex, out tempDistP);
float distanceP = tempDistP - planeDistance;
Vector3 nVertex = box.Max;
if (normal.X >= 0)
nVertex.X = box.Min.X;
if (normal.Y >= 0)
nVertex.Y = box.Min.Y;
if (normal.Z < 0)
nVertex.Z = box.Min.Z;
float tempDistN;
Vector3.Dot(ref normal, ref pVertex, out tempDistN);
float distanceN = tempDistN - planeDistance;
if (distanceN < 0 && distanceP < 0)
bool flag = false;
Plane[] array = this.planes;
for (int i = 0; i < array.Length; i++)
{
result = ContainmentType.Disjoint;
return;
Plane plane = array[i];
PlaneIntersectionType planeIntersectionType = box.Intersects(plane);
if (planeIntersectionType == PlaneIntersectionType.Front)
{
result = ContainmentType.Disjoint;
return;
}
if (planeIntersectionType == PlaneIntersectionType.Intersecting)
{
flag = true;
}
}
else if (distanceN < 0 || distanceP < 0)
if (!flag)
{
result = ContainmentType.Intersects;
return;
}
plane = Top;
normal = plane.Normal;
//Vector3.Negate(ref normal, out normal);
planeDistance = plane.D;
pVertex = box.Min;
if (normal.X >= 0)
pVertex.X = box.Max.X;
if (normal.Y >= 0)
pVertex.Y = box.Max.Y;
if (normal.Z < 0)
pVertex.Z = box.Max.Z;
Vector3.Dot(ref normal, ref pVertex, out tempDistP);
distanceP = tempDistP - planeDistance;
nVertex = box.Max;
if (normal.X >= 0)
nVertex.X = box.Min.X;
if (normal.Y >= 0)
nVertex.Y = box.Min.Y;
if (normal.Z < 0)
nVertex.Z = box.Min.Z;
Vector3.Dot(ref normal, ref pVertex, out tempDistN);
distanceN = tempDistN - planeDistance;
if (distanceN < 0 && distanceP < 0)
{
result = ContainmentType.Disjoint;
return;
}
else if (distanceN < 0 || distanceP < 0)
{
result = ContainmentType.Intersects;
result = ContainmentType.Contains;
return;
}
plane = Left;
normal = plane.Normal;
//Vector3.Negate(ref normal, out normal);
planeDistance = plane.D;
pVertex = box.Min;
if (normal.X >= 0)
pVertex.X = box.Max.X;
if (normal.Y >= 0)
pVertex.Y = box.Max.Y;
if (normal.Z < 0)
pVertex.Z = box.Max.Z;
Vector3.Dot(ref normal, ref pVertex, out tempDistP);
distanceP = tempDistP - planeDistance;
nVertex = box.Max;
if (normal.X >= 0)
nVertex.X = box.Min.X;
if (normal.Y >= 0)
nVertex.Y = box.Min.Y;
if (normal.Z < 0)
nVertex.Z = box.Min.Z;
Vector3.Dot(ref normal, ref pVertex, out tempDistN);
distanceN = tempDistN - planeDistance;
if (distanceN < 0 && distanceP < 0)
{
result = ContainmentType.Disjoint;
return;
}
else if (distanceN < 0 || distanceP < 0)
{
result = ContainmentType.Intersects;
return;
}
plane = Right;
normal = plane.Normal;
//Vector3.Negate(ref normal, out normal);
planeDistance = plane.D;
pVertex = box.Min;
if (normal.X >= 0)
pVertex.X = box.Max.X;
if (normal.Y >= 0)
pVertex.Y = box.Max.Y;
if (normal.Z < 0)
pVertex.Z = box.Max.Z;
Vector3.Dot(ref normal, ref pVertex, out tempDistP);
distanceP = tempDistP - planeDistance;
nVertex = box.Max;
if (normal.X >= 0)
nVertex.X = box.Min.X;
if (normal.Y >= 0)
nVertex.Y = box.Min.Y;
if (normal.Z < 0)
nVertex.Z = box.Min.Z;
Vector3.Dot(ref normal, ref pVertex, out tempDistN);
distanceN = tempDistN - planeDistance;
if (distanceN < 0 && distanceP < 0)
{
result = ContainmentType.Disjoint;
return;
}
else if (distanceN < 0 || distanceP < 0)
{
result = ContainmentType.Intersects;
return;
}
plane = Near;
normal = plane.Normal;
//Vector3.Negate(ref normal, out normal);
planeDistance = plane.D;
pVertex = box.Min;
if (normal.X >= 0)
pVertex.X = box.Max.X;
if (normal.Y >= 0)
pVertex.Y = box.Max.Y;
if (normal.Z < 0)
pVertex.Z = box.Max.Z;
Vector3.Dot(ref normal, ref pVertex, out tempDistP);
distanceP = tempDistP - planeDistance;
nVertex = box.Max;
if (normal.X >= 0)
nVertex.X = box.Min.X;
if (normal.Y >= 0)
nVertex.Y = box.Min.Y;
if (normal.Z < 0)
nVertex.Z = box.Min.Z;
Vector3.Dot(ref normal, ref pVertex, out tempDistN);
distanceN = tempDistN - planeDistance;
if (distanceN < 0 && distanceP < 0)
{
result = ContainmentType.Disjoint;
return;
}
else if (distanceN < 0 || distanceP < 0)
{
result = ContainmentType.Intersects;
return;
}
plane = Far;
normal = plane.Normal;
//Vector3.Negate(ref normal, out normal);
planeDistance = plane.D;
pVertex = box.Min;
if (normal.X >= 0)
pVertex.X = box.Max.X;
if (normal.Y >= 0)
pVertex.Y = box.Max.Y;
if (normal.Z < 0)
pVertex.Z = box.Max.Z;
Vector3.Dot(ref normal, ref pVertex, out tempDistP);
distanceP = tempDistP - planeDistance;
nVertex = box.Max;
if (normal.X >= 0)
nVertex.X = box.Min.X;
if (normal.Y >= 0)
nVertex.Y = box.Min.Y;
if (normal.Z < 0)
nVertex.Z = box.Min.Z;
Vector3.Dot(ref normal, ref pVertex, out tempDistN);
distanceN = tempDistN - planeDistance;
if (distanceN < 0 && distanceP < 0)
{
result = ContainmentType.Disjoint;
return;
}
else if (distanceN < 0 || distanceP < 0)
{
result = ContainmentType.Intersects;
return;
}
result = ContainmentType.Intersects;
}
public ContainmentType Contains(BoundingFrustum frustum)
{
throw new NotImplementedException();
if (frustum == null)
{
throw new ArgumentNullException("frustum");
}
ContainmentType result = ContainmentType.Disjoint;
if (this.Intersects(frustum))
{
result = ContainmentType.Contains;
for (int i = 0; i < this.corners.Length; i++)
{
if (this.Contains(frustum.corners[i]) == ContainmentType.Disjoint)
{
result = ContainmentType.Intersects;
break;
}
}
}
return result;
}
public ContainmentType Contains(BoundingSphere sphere)
@ -522,10 +317,12 @@ namespace ANX.Framework
{
throw new ArgumentNullException("corners");
}
if (corners.Length < 8)
{
throw new ArgumentOutOfRangeException("corners", "The array to be filled with corner vertices needs at least have a length of 8 Vector3");
}
this.corners.CopyTo(corners, 0);
}
@ -773,27 +570,79 @@ namespace ANX.Framework
}
public override string ToString()
{
// This may look a bit more ugly, but String.Format should
// be avoided cause of it's bad performance!
return "{Near:" + Near.ToString() +
" Far:" + Far.ToString() +
" Left:" + Left.ToString() +
" Right:" + Right.ToString() +
" Top:" + Top.ToString() +
" Bottom:" + Bottom.ToString() + "}";
{
// This may look a bit more ugly, but String.Format should
// be avoided cause of it's bad performance!
return "{Near:" + Near.ToString() +
" Far:" + Far.ToString() +
" Left:" + Left.ToString() +
" Right:" + Right.ToString() +
" Top:" + Top.ToString() +
" Bottom:" + Bottom.ToString() + "}";
}
#endregion
////source: monoxna
// var currentCulture = System.Globalization.CultureInfo.CurrentCulture;
// return string.Format(currentCulture, "{{Near:{0} Far:{1} Left:{2} Right:{3} Top:{4} Bottom:{5}}}", new object[]
//{
// this.Near.ToString(),
// this.Far.ToString(),
// this.Left.ToString(),
// this.Right.ToString(),
// this.Top.ToString(),
// this.Bottom.ToString()
//});
#region public properties
public Matrix Matrix
{
get
{
return this.matrix;
}
set
{
this.matrix = value;
this.CreatePlanes();
this.CreateCorners();
}
}
public Plane Near
{
get
{
return this.planes[0];
}
}
public Plane Far
{
get
{
return this.planes[1];
}
}
public Plane Top
{
get
{
return this.planes[4];
}
}
public Plane Bottom
{
get
{
return this.planes[5];
}
}
public Plane Right
{
get
{
return this.planes[3];
}
}
public Plane Left
{
get
{
return this.planes[2];
}
}
#endregion
@ -801,52 +650,68 @@ namespace ANX.Framework
//algorithm based on but normals were pointing to outside instead of inside: http://crazyjoke.free.fr/doc/3D/plane%20extraction.pdf
private void CreatePlanes()
{
this.near.Normal.X = -this.matrix.M13;
this.near.Normal.Y = -this.matrix.M23;
this.near.Normal.Z = -this.matrix.M33;
this.near.D = -this.matrix.M43;
int idx;
this.far.Normal.X = this.matrix.M14 - this.matrix.M13;
this.far.Normal.Y = this.matrix.M24 - this.matrix.M23;
this.far.Normal.Z = this.matrix.M34 - this.matrix.M33;
this.far.D = this.matrix.M44 - this.matrix.M43;
idx = (int)PlanePosition.Near;
this.planes[idx].Normal.X = -this.matrix.M13;
this.planes[idx].Normal.Y = -this.matrix.M23;
this.planes[idx].Normal.Z = -this.matrix.M33;
this.planes[idx].D = -this.matrix.M43;
this.left.Normal.X = -this.matrix.M14 - this.matrix.M11;
this.left.Normal.Y = -this.matrix.M24 - this.matrix.M21;
this.left.Normal.Z = -this.matrix.M34 - this.matrix.M31;
this.left.D = -this.matrix.M44 - this.matrix.M41;
idx = (int)PlanePosition.Far;
this.planes[idx].Normal.X = -this.matrix.M14 + this.matrix.M13;
this.planes[idx].Normal.Y = -this.matrix.M24 + this.matrix.M23;
this.planes[idx].Normal.Z = -this.matrix.M34 + this.matrix.M33;
this.planes[idx].D = -this.matrix.M44 + this.matrix.M43;
this.right.Normal.X = -this.matrix.M14 + this.matrix.M11;
this.right.Normal.Y = -this.matrix.M24 + this.matrix.M21;
this.right.Normal.Z = -this.matrix.M34 + this.matrix.M31;
this.right.D = -this.matrix.M44 + this.matrix.M41;
idx = (int)PlanePosition.Left;
this.planes[idx].Normal.X = -this.matrix.M14 - this.matrix.M11;
this.planes[idx].Normal.Y = -this.matrix.M24 - this.matrix.M21;
this.planes[idx].Normal.Z = -this.matrix.M34 - this.matrix.M31;
this.planes[idx].D = -this.matrix.M44 - this.matrix.M41;
this.top.Normal.X = -this.matrix.M14 + this.matrix.M12;
this.top.Normal.Y = -this.matrix.M24 + this.matrix.M22;
this.top.Normal.Z = -this.matrix.M34 + this.matrix.M32;
this.top.D = -this.matrix.M44 + this.matrix.M42;
idx = (int)PlanePosition.Right;
this.planes[idx].Normal.X = -this.matrix.M14 + this.matrix.M11;
this.planes[idx].Normal.Y = -this.matrix.M24 + this.matrix.M21;
this.planes[idx].Normal.Z = -this.matrix.M34 + this.matrix.M31;
this.planes[idx].D = -this.matrix.M44 + this.matrix.M41;
this.bottom.Normal.X = -this.matrix.M14 - this.matrix.M12;
this.bottom.Normal.Y = -this.matrix.M24 - this.matrix.M22;
this.bottom.Normal.Z = -this.matrix.M34 - this.matrix.M32;
this.bottom.D = -this.matrix.M44 - this.matrix.M42;
idx = (int)PlanePosition.Top;
this.planes[idx].Normal.X = -this.matrix.M14 + this.matrix.M12;
this.planes[idx].Normal.Y = -this.matrix.M24 + this.matrix.M22;
this.planes[idx].Normal.Z = -this.matrix.M34 + this.matrix.M32;
this.planes[idx].D = -this.matrix.M44 + this.matrix.M42;
NormalizePlane(ref this.left);
NormalizePlane(ref this.right);
NormalizePlane(ref this.bottom);
NormalizePlane(ref this.top);
NormalizePlane(ref this.near);
NormalizePlane(ref this.far);
idx = (int)PlanePosition.Bottom;
this.planes[idx].Normal.X = -this.matrix.M14 - this.matrix.M12;
this.planes[idx].Normal.Y = -this.matrix.M24 - this.matrix.M22;
this.planes[idx].Normal.Z = -this.matrix.M34 - this.matrix.M32;
this.planes[idx].D = -this.matrix.M44 - this.matrix.M42;
for (int i = 0; i < this.planes.Length; i++)
{
this.planes[i].Normalize();
}
}
//source: monoxna
private void NormalizePlane(ref Plane p)
private void CreateCorners()
{
float factor = 1f / p.Normal.Length();
p.Normal.X *= factor;
p.Normal.Y *= factor;
p.Normal.Z *= factor;
p.D *= factor;
Ray rnl = BoundingFrustum.EdgeIntersection(ref this.planes[(int)PlanePosition.Near], ref this.planes[(int)PlanePosition.Left]);
Ray rrn = BoundingFrustum.EdgeIntersection(ref this.planes[(int)PlanePosition.Right], ref this.planes[(int)PlanePosition.Near]);
Ray rlf = BoundingFrustum.EdgeIntersection(ref this.planes[(int)PlanePosition.Left], ref this.planes[(int)PlanePosition.Far]);
Ray rfr = BoundingFrustum.EdgeIntersection(ref this.planes[(int)PlanePosition.Far], ref this.planes[(int)PlanePosition.Right]);
this.corners = new[]
{
BoundingFrustum.PointIntersection(ref this.planes[(int)PlanePosition.Top], ref rnl),
BoundingFrustum.PointIntersection(ref this.planes[(int)PlanePosition.Top], ref rrn),
BoundingFrustum.PointIntersection(ref this.planes[(int)PlanePosition.Bottom], ref rrn),
BoundingFrustum.PointIntersection(ref this.planes[(int)PlanePosition.Bottom], ref rnl),
BoundingFrustum.PointIntersection(ref this.planes[(int)PlanePosition.Top], ref rlf),
BoundingFrustum.PointIntersection(ref this.planes[(int)PlanePosition.Top], ref rfr),
BoundingFrustum.PointIntersection(ref this.planes[(int)PlanePosition.Bottom], ref rfr),
BoundingFrustum.PointIntersection(ref this.planes[(int)PlanePosition.Bottom], ref rlf),
};
}
//source: monoxna
@ -870,19 +735,21 @@ namespace ANX.Framework
return vec / f;
}
//source: monoxna
private void CreateCorners()
private static Ray EdgeIntersection(ref Plane p1, ref Plane p2)
{
this.corners = new Vector3[8];
this.corners[0] = IntersectionPoint(ref this.near, ref this.left, ref this.top);
this.corners[1] = IntersectionPoint(ref this.near, ref this.right, ref this.top);
this.corners[2] = IntersectionPoint(ref this.near, ref this.right, ref this.bottom);
this.corners[3] = IntersectionPoint(ref this.near, ref this.left, ref this.bottom);
this.corners[4] = IntersectionPoint(ref this.far, ref this.left, ref this.top);
this.corners[5] = IntersectionPoint(ref this.far, ref this.right, ref this.top);
this.corners[6] = IntersectionPoint(ref this.far, ref this.right, ref this.bottom);
this.corners[7] = IntersectionPoint(ref this.far, ref this.left, ref this.bottom);
Ray result = default(Ray);
result.Direction = Vector3.Cross(p1.Normal, p2.Normal);
float divider = result.Direction.LengthSquared();
result.Position = Vector3.Cross(-p1.D * p2.Normal + p2.D * p1.Normal, result.Direction) / divider;
return result;
}
private static Vector3 PointIntersection(ref Plane plane, ref Ray ray)
{
float scaleFactor = (-plane.D - Vector3.Dot(plane.Normal, ray.Position)) / Vector3.Dot(plane.Normal, ray.Direction);
return ray.Position + ray.Direction * scaleFactor;
}
#endregion
#region IEquatable implementation
@ -910,6 +777,7 @@ namespace ANX.Framework
{
return object.Equals(a, b);
}
public static bool operator !=(BoundingFrustum a, BoundingFrustum b)
{
return !object.Equals(a, b);

View File

@ -11,6 +11,7 @@ namespace ANX.Framework.Graphics
{
[PercentageComplete(60)]
[TestState(TestStateAttribute.TestState.Untested)]
[Developer("Glatzemann")]
public sealed class EffectParameter
{
#region Public (TODO)
@ -76,7 +77,7 @@ namespace ANX.Framework.Graphics
{
get
{
throw new NotImplementedException();
return this.NativeParameter.Semantic;
}
}

View File

@ -1,6 +1,7 @@
#region Using Statements
using System;
using ANX.Framework.Graphics;
using ANX.Framework.NonXNA.Development;
#endregion // Using Statements
@ -10,58 +11,63 @@ using ANX.Framework.Graphics;
namespace ANX.Framework.NonXNA
{
[PercentageComplete(100)]
[TestState(TestStateAttribute.TestState.Untested)]
[Developer("Glatzemann")]
public interface INativeEffectParameter
{
string Name { get; }
#region GetValue
bool GetValueBoolean();
string Semantic { get; }
bool[] GetValueBooleanArray(int count);
#region GetValue
bool GetValueBoolean();
int GetValueInt32();
bool[] GetValueBooleanArray(int count);
int[] GetValueInt32Array(int count);
int GetValueInt32();
Matrix GetValueMatrix();
int[] GetValueInt32Array(int count);
Matrix[] GetValueMatrixArray(int count);
Matrix GetValueMatrix();
Matrix GetValueMatrixTranspose();
Matrix[] GetValueMatrixArray(int count);
Matrix[] GetValueMatrixTransposeArray(int count);
Matrix GetValueMatrixTranspose();
Quaternion GetValueQuaternion();
Matrix[] GetValueMatrixTransposeArray(int count);
Quaternion[] GetValueQuaternionArray(int count);
Quaternion GetValueQuaternion();
float GetValueSingle();
Quaternion[] GetValueQuaternionArray(int count);
float[] GetValueSingleArray(int count);
float GetValueSingle();
string GetValueString();
float[] GetValueSingleArray(int count);
Texture2D GetValueTexture2D();
string GetValueString();
Texture3D GetValueTexture3D();
Texture2D GetValueTexture2D();
TextureCube GetValueTextureCube();
Texture3D GetValueTexture3D();
Vector2 GetValueVector2();
TextureCube GetValueTextureCube();
Vector2[] GetValueVector2Array(int count);
Vector2 GetValueVector2();
Vector3 GetValueVector3();
Vector2[] GetValueVector2Array(int count);
Vector3[] GetValueVector3Array(int count);
Vector3 GetValueVector3();
Vector4 GetValueVector4();
Vector3[] GetValueVector3Array(int count);
Vector4[] GetValueVector4Array(int count);
#endregion
Vector4 GetValueVector4();
#region SetValue
void SetValue(bool value);
Vector4[] GetValueVector4Array(int count);
#endregion
#region SetValue
void SetValue(bool value);
void SetValue(bool[] value);
@ -69,7 +75,7 @@ namespace ANX.Framework.NonXNA
void SetValue(int[] value);
void SetValue(Matrix value, bool transpose);
void SetValue(Matrix value, bool transpose);
void SetValue(Matrix[] value, bool transpose);
@ -91,11 +97,11 @@ namespace ANX.Framework.NonXNA
void SetValue(Vector4 value);
void SetValue(Vector4[] value);
void SetValue(Vector4[] value);
void SetValue(string value);
void SetValue(string value);
void SetValue(Texture value);
#endregion
}
#endregion
}
}

View File

@ -29,6 +29,14 @@ namespace ANX.RenderSystem.GL3
private set;
}
public string Semantic
{
get
{
throw new NotSupportedException();
}
}
/// <summary>
/// The index of the uniform.
/// </summary>

View File

@ -32,7 +32,7 @@ using System.Runtime.InteropServices;
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
// übernehmen, indem Sie "*" eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.5.13.*")]
[assembly: AssemblyFileVersion("0.5.13.0")]
[assembly: AssemblyVersion("0.5.14.*")]
[assembly: AssemblyFileVersion("0.5.14.0")]
[assembly: InternalsVisibleTo("ANX.Framework.ContentPipeline")]

View File

@ -3,6 +3,7 @@ using ANX.Framework;
using ANX.Framework.Graphics;
using ANX.Framework.NonXNA;
using Dx10 = SharpDX.Direct3D10;
using ANX.Framework.NonXNA.Development;
// This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license.
@ -10,7 +11,10 @@ using Dx10 = SharpDX.Direct3D10;
namespace ANX.RenderSystem.Windows.DX10
{
public class EffectParameter_DX10 : INativeEffectParameter
[PercentageComplete(70)]
[TestState(TestStateAttribute.TestState.Untested)]
[Developer("Glatzemann")]
public class EffectParameter_DX10 : INativeEffectParameter
{
#region Public
public Dx10.EffectVariable NativeParameter
@ -26,6 +30,14 @@ namespace ANX.RenderSystem.Windows.DX10
return NativeParameter.Description.Name;
}
}
public string Semantic
{
get
{
return NativeParameter.Description.Semantic;
}
}
#endregion
#region SetValue (bool)

View File

@ -32,7 +32,7 @@ using System.Runtime.InteropServices;
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
// übernehmen, indem Sie "*" eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.7.23.*")]
[assembly: AssemblyFileVersion("0.7.23.0")]
[assembly: AssemblyVersion("0.7.24.*")]
[assembly: AssemblyFileVersion("0.7.24.0")]
[assembly: InternalsVisibleTo("ANX.Framework.ContentPipeline")]

View File

@ -3,6 +3,7 @@ using ANX.Framework;
using ANX.Framework.Graphics;
using ANX.Framework.NonXNA;
using Dx11 = SharpDX.Direct3D11;
using ANX.Framework.NonXNA.Development;
// This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license.
@ -10,7 +11,10 @@ using Dx11 = SharpDX.Direct3D11;
namespace ANX.RenderSystem.Windows.DX11
{
public class EffectParameter_DX11 : INativeEffectParameter
[PercentageComplete(60)]
[TestState(TestStateAttribute.TestState.Untested)]
[Developer("Glatzemann")]
public class EffectParameter_DX11 : INativeEffectParameter
{
#region Public
public Dx11.EffectVariable NativeParameter
@ -26,6 +30,14 @@ namespace ANX.RenderSystem.Windows.DX11
return NativeParameter.Description.Name;
}
}
public string Semantic
{
get
{
return NativeParameter.Description.Semantic;
}
}
#endregion
#region SetValue (bool)

View File

@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
// Buildnummer
// Revision
//
[assembly: AssemblyVersion("0.7.15.*")]
[assembly: AssemblyFileVersion("0.7.15.0")]
[assembly: AssemblyVersion("0.7.16.*")]
[assembly: AssemblyFileVersion("0.7.16.0")]

View File

@ -25,6 +25,14 @@ namespace ANX.RenderSystem.Windows.Metro
return nativeParameter.Name;
}
}
public string Semantic
{
get
{
return nativeParameter.Semantic;
}
}
#endregion
#region Constructor

View File

@ -24,6 +24,6 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.2.7.*")]
[assembly: AssemblyFileVersion("0.2.7.0")]
[assembly: AssemblyVersion("0.2.8.*")]
[assembly: AssemblyFileVersion("0.2.8.0")]
[assembly: GuidAttribute("855A261E-DB66-4CB2-97F3-34BC9DA4DAA1")]