diff --git a/.gitignore b/.gitignore index be26d03..dcf1d1b 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ .metadata bin/ tmp/ +TempFatJarBuildDir_erase_me/ *.tmp *.bak *.swp diff --git a/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/Audio/SoundEffectInstance.java b/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/Audio/SoundEffectInstance.java index 3956fff..2fda399 100644 --- a/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/Audio/SoundEffectInstance.java +++ b/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/Audio/SoundEffectInstance.java @@ -158,6 +158,7 @@ public class SoundEffectInstance implements IDisposable { this.currentVolume = 1f; this.VoiceHandleLock = new Object(); + if (parentEffect.IsDisposed()) { throw new ObjectDisposedException(SoundEffect.class.getName(), "This object has already been disposed."); diff --git a/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/BoundingBox.java b/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/BoundingBox.java index 708c8f0..4de0ce6 100644 --- a/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/BoundingBox.java +++ b/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/BoundingBox.java @@ -15,17 +15,17 @@ public final class BoundingBox extends ValueType implements IEquatable box.Max.X)) - { - return ContainmentType.Disjoint; - } - if ((this.Max.Y < box.Min.Y) || (this.Min.Y > box.Max.Y)) - { - return ContainmentType.Disjoint; - } - if ((this.Max.Z < box.Min.Z) || (this.Min.Z > box.Max.Z)) - { - return ContainmentType.Disjoint; - } - if ((((this.Min.X <= box.Min.X) && (box.Max.X <= this.Max.X)) && ((this.Min.Y <= box.Min.Y) && (box.Max.Y <= this.Max.Y))) && ((this.Min.Z <= box.Min.Z) && (box.Max.Z <= this.Max.Z))) - { - return ContainmentType.Contains; - } - return ContainmentType.Intersects; + if ((this.Max.X < box.Min.X) || (this.Min.X > box.Max.X)) + { + return ContainmentType.Disjoint; + } + + if ((this.Max.Y < box.Min.Y) || (this.Min.Y > box.Max.Y)) + { + return ContainmentType.Disjoint; + } + + if ((this.Max.Z < box.Min.Z) || (this.Min.Z > box.Max.Z)) + { + return ContainmentType.Disjoint; + } + + if ((((this.Min.X <= box.Min.X) && (box.Max.X <= this.Max.X)) && ((this.Min.Y <= box.Min.Y) && (box.Max.Y <= this.Max.Y))) && ((this.Min.Z <= box.Min.Z) && (box.Max.Z <= this.Max.Z))) + { + return ContainmentType.Contains; + } + + return ContainmentType.Intersects; } - + /** * Tests whether the BoundingBox contains a BoundingSphere. * @@ -82,22 +86,24 @@ public final class BoundingBox extends ValueType implements IEquatable (radius * radius)) - { - return ContainmentType.Disjoint; - } - if (((((this.Min.X + radius) <= sphere.Center.X) && (sphere.Center.X <= (this.Max.X - radius))) && (((this.Max.X - this.Min.X) > radius) && ((this.Min.Y + radius) <= sphere.Center.Y))) && (((sphere.Center.Y <= (this.Max.Y - radius)) && ((this.Max.Y - this.Min.Y) > radius)) && ((((this.Min.Z + radius) <= sphere.Center.Z) && (sphere.Center.Z <= (this.Max.Z - radius))) && ((this.Max.X - this.Min.X) > radius)))) - { - return ContainmentType.Contains; - } - return ContainmentType.Intersects; + Vector3 vector = Vector3.Zero; + Vector3.Clamp(sphere.Center, this.Min, this.Max, vector); + float num2 = Vector3.DistanceSquared(sphere.Center, vector); + float radius = sphere.Radius; + + if (num2 > (radius * radius)) + { + return ContainmentType.Disjoint; + } + + if (((((this.Min.X + radius) <= sphere.Center.X) && (sphere.Center.X <= (this.Max.X - radius))) && (((this.Max.X - this.Min.X) > radius) && ((this.Min.Y + radius) <= sphere.Center.Y))) && (((sphere.Center.Y <= (this.Max.Y - radius)) && ((this.Max.Y - this.Min.Y) > radius)) && ((((this.Min.Z + radius) <= sphere.Center.Z) && (sphere.Center.Z <= (this.Max.Z - radius))) && ((this.Max.X - this.Min.X) > radius)))) + { + return ContainmentType.Contains; + } + + return ContainmentType.Intersects; } - + /** * Tests whether the BoundingBox contains a point. * @@ -106,13 +112,14 @@ public final class BoundingBox extends ValueType implements IEquatable box.Max.X)) - { - return false; - } - if ((this.Max.Y < box.Min.Y) || (this.Min.Y > box.Max.Y)) - { - return false; - } - return ((this.Max.Z >= box.Min.Z) && (this.Min.Z <= box.Max.Z)); + if ((this.Max.X < box.Min.X) || (this.Min.X > box.Max.X)) + { + return false; + } + + if ((this.Max.Y < box.Min.Y) || (this.Min.Y > box.Max.Y)) + { + return false; + } + + return ((this.Max.Z >= box.Min.Z) && (this.Min.Z <= box.Max.Z)); } - + /** * Checks whether the current BoundingBox intersects a BoundingSphere. * @@ -328,13 +339,12 @@ public final class BoundingBox extends ValueType implements IEquatable= 0f) ? this.Min.X : this.Max.X; - vector2.Y = (plane.Normal.Y >= 0f) ? this.Min.Y : this.Max.Y; - vector2.Z = (plane.Normal.Z >= 0f) ? this.Min.Z : this.Max.Z; - vector.X = (plane.Normal.X >= 0f) ? this.Max.X : this.Min.X; - vector.Y = (plane.Normal.Y >= 0f) ? this.Max.Y : this.Min.Y; - vector.Z = (plane.Normal.Z >= 0f) ? this.Max.Z : this.Min.Z; - float num = ((plane.Normal.X * vector2.X) + (plane.Normal.Y * vector2.Y)) + (plane.Normal.Z * vector2.Z); - if ((num + plane.D) > 0f) - { - return PlaneIntersectionType.Front; - } - num = ((plane.Normal.X * vector.X) + (plane.Normal.Y * vector.Y)) + (plane.Normal.Z * vector.Z); - if ((num + plane.D) < 0f) - { - return PlaneIntersectionType.Back; - } - return PlaneIntersectionType.Intersecting; + Vector3 vector = Vector3.Zero; + Vector3 vector2 = Vector3.Zero; + vector2.X = (plane.Normal.X >= 0f) ? this.Min.X : this.Max.X; + vector2.Y = (plane.Normal.Y >= 0f) ? this.Min.Y : this.Max.Y; + vector2.Z = (plane.Normal.Z >= 0f) ? this.Min.Z : this.Max.Z; + vector.X = (plane.Normal.X >= 0f) ? this.Max.X : this.Min.X; + vector.Y = (plane.Normal.Y >= 0f) ? this.Max.Y : this.Min.Y; + vector.Z = (plane.Normal.Z >= 0f) ? this.Max.Z : this.Min.Z; + float num = ((plane.Normal.X * vector2.X) + (plane.Normal.Y * vector2.Y)) + (plane.Normal.Z * vector2.Z); + + if ((num + plane.D) > 0f) + { + return PlaneIntersectionType.Front; + } + + num = ((plane.Normal.X * vector.X) + (plane.Normal.Y * vector.Y)) + (plane.Normal.Z * vector.Z); + + if ((num + plane.D) < 0f) + { + return PlaneIntersectionType.Back; + } + + return PlaneIntersectionType.Intersecting; } - + /** * Checks whether the current BoundingBox intersects a Ray. * @@ -378,252 +392,99 @@ public final class BoundingBox extends ValueType implements IEquatable this.Max.X)) - { - return null; - } - } - else - { - float num11 = 1f / ray.Direction.X; - float num8 = (this.Min.X - ray.Position.X) * num11; - float num7 = (this.Max.X - ray.Position.X) * num11; - if (num8 > num7) - { - float num14 = num8; - num8 = num7; - num7 = num14; - } - num = MathHelper.Max(num8, num); - maxValue = MathHelper.Min(num7, maxValue); - if (num > maxValue) - { - return null; - } - } - if (Math.abs(ray.Direction.Y) < 1E-06f) - { - if ((ray.Position.Y < this.Min.Y) || (ray.Position.Y > this.Max.Y)) - { - return null; - } - } - else - { - float num10 = 1f / ray.Direction.Y; - float num6 = (this.Min.Y - ray.Position.Y) * num10; - float num5 = (this.Max.Y - ray.Position.Y) * num10; - if (num6 > num5) - { - float num13 = num6; - num6 = num5; - num5 = num13; - } - num = MathHelper.Max(num6, num); - maxValue = MathHelper.Min(num5, maxValue); - if (num > maxValue) - { - return null; - } - } - if (Math.abs(ray.Direction.Z) < 1E-06f) - { - if ((ray.Position.Z < this.Min.Z) || (ray.Position.Z > this.Max.Z)) - { - return null; - } - } - else - { - float num9 = 1f / ray.Direction.Z; - float num4 = (this.Min.Z - ray.Position.Z) * num9; - float num3 = (this.Max.Z - ray.Position.Z) * num9; - if (num4 > num3) - { - float num12 = num4; - num4 = num3; - num3 = num12; - } - num = MathHelper.Max(num4, num); - maxValue = MathHelper.Min(num3, maxValue); - if (num > maxValue) - { - return null; - } - } - return new Float(num); + float num = 0f; + float maxValue = Float.MAX_VALUE; + + if (Math.abs(ray.Direction.X) < 1E-06f) + { + if ((ray.Position.X < this.Min.X) || (ray.Position.X > this.Max.X)) + { + return null; + } + } + else + { + float num11 = 1f / ray.Direction.X; + float num8 = (this.Min.X - ray.Position.X) * num11; + float num7 = (this.Max.X - ray.Position.X) * num11; + + if (num8 > num7) + { + float num14 = num8; + num8 = num7; + num7 = num14; + } + + num = MathHelper.Max(num8, num); + maxValue = MathHelper.Min(num7, maxValue); + + if (num > maxValue) + { + return null; + } + } + + if (Math.abs(ray.Direction.Y) < 1E-06f) + { + if ((ray.Position.Y < this.Min.Y) || (ray.Position.Y > this.Max.Y)) + { + return null; + } + } + else + { + float num10 = 1f / ray.Direction.Y; + float num6 = (this.Min.Y - ray.Position.Y) * num10; + float num5 = (this.Max.Y - ray.Position.Y) * num10; + + if (num6 > num5) + { + float num13 = num6; + num6 = num5; + num5 = num13; + } + + num = MathHelper.Max(num6, num); + maxValue = MathHelper.Min(num5, maxValue); + + if (num > maxValue) + { + return null; + } + } + + if (Math.abs(ray.Direction.Z) < 1E-06f) + { + if ((ray.Position.Z < this.Min.Z) || (ray.Position.Z > this.Max.Z)) + { + return null; + } + } + else + { + float num9 = 1f / ray.Direction.Z; + float num4 = (this.Min.Z - ray.Position.Z) * num9; + float num3 = (this.Max.Z - ray.Position.Z) * num9; + + if (num4 > num3) + { + float num12 = num4; + num4 = num3; + num3 = num12; + } + + num = MathHelper.Max(num4, num); + maxValue = MathHelper.Min(num3, maxValue); + + if (num > maxValue) + { + return null; + } + } + + return new Float(num); } - - /** - * Checks whether the current BoundingBox intersects another BoundingBox. - * - * @param box - * The BoundingBox to check for intersection with. - * - * @param result - * [OutAttribute] true if the BoundingBox instances intersect; false otherwise. - */ - public void Intersects(BoundingBox box, boolean result) - { - result = false; - if ((((this.Max.X >= box.Min.X) && (this.Min.X <= box.Max.X)) && ((this.Max.Y >= box.Min.Y) && (this.Min.Y <= box.Max.Y))) && ((this.Max.Z >= box.Min.Z) && (this.Min.Z <= box.Max.Z))) - { - result = true; - } - } - - /** - * Checks whether the current BoundingBox intersects a BoundingSphere. - * - * @param sphere - * The BoundingSphere to check for intersection with. - * - * @param result - * [OutAttribute] true if the BoundingBox and BoundingSphere intersect; false otherwise. - */ - public void Intersects(BoundingSphere sphere, boolean result) - { - float num = 0; - Vector3 vector = Vector3.Zero; - Vector3.Clamp(sphere.Center, this.Min, this.Max, vector); - Vector3.DistanceSquared(sphere.Center, vector, num); - result = num <= (sphere.Radius * sphere.Radius); - } - - /** - * Checks whether the current BoundingBox intersects a Plane. - * - * @param plane - * The Plane to check for intersection with. - * - * @param result - * [OutAttribute] An enumeration indicating whether the BoundingBox intersects the Plane. - */ - public void Intersects(Plane plane, PlaneIntersectionType result) - { - Vector3 vector = Vector3.Zero; - Vector3 vector2 = Vector3.Zero; - vector2.X = (plane.Normal.X >= 0f) ? this.Min.X : this.Max.X; - vector2.Y = (plane.Normal.Y >= 0f) ? this.Min.Y : this.Max.Y; - vector2.Z = (plane.Normal.Z >= 0f) ? this.Min.Z : this.Max.Z; - vector.X = (plane.Normal.X >= 0f) ? this.Max.X : this.Min.X; - vector.Y = (plane.Normal.Y >= 0f) ? this.Max.Y : this.Min.Y; - vector.Z = (plane.Normal.Z >= 0f) ? this.Max.Z : this.Min.Z; - float num = ((plane.Normal.X * vector2.X) + (plane.Normal.Y * vector2.Y)) + (plane.Normal.Z * vector2.Z); - if ((num + plane.D) > 0f) - { - result = PlaneIntersectionType.Front; - } - else - { - num = ((plane.Normal.X * vector.X) + (plane.Normal.Y * vector.Y)) + (plane.Normal.Z * vector.Z); - if ((num + plane.D) < 0f) - { - result = PlaneIntersectionType.Back; - } - else - { - result = PlaneIntersectionType.Intersecting; - } - } - } - - /** - * Checks whether the current BoundingBox intersects a Ray. - * - * @param ray - * The Ray to check for intersection with. - * - * @param result - * [OutAttribute] Distance at which the ray intersects the BoundingBox, or null if there is no intersection. - */ - public void Intersects(Ray ray, Float result) - { - result = 0f; - float num = 0f; - float maxValue = Float.MAX_VALUE; - if (Math.abs(ray.Direction.X) < 1E-06f) - { - if ((ray.Position.X < this.Min.X) || (ray.Position.X > this.Max.X)) - { - return; - } - } - else - { - float num11 = 1f / ray.Direction.X; - float num8 = (this.Min.X - ray.Position.X) * num11; - float num7 = (this.Max.X - ray.Position.X) * num11; - if (num8 > num7) - { - float num14 = num8; - num8 = num7; - num7 = num14; - } - num = MathHelper.Max(num8, num); - maxValue = MathHelper.Min(num7, maxValue); - if (num > maxValue) - { - return; - } - } - if (Math.abs(ray.Direction.Y) < 1E-06f) - { - if ((ray.Position.Y < this.Min.Y) || (ray.Position.Y > this.Max.Y)) - { - return; - } - } - else - { - float num10 = 1f / ray.Direction.Y; - float num6 = (this.Min.Y - ray.Position.Y) * num10; - float num5 = (this.Max.Y - ray.Position.Y) * num10; - if (num6 > num5) - { - float num13 = num6; - num6 = num5; - num5 = num13; - } - num = MathHelper.Max(num6, num); - maxValue = MathHelper.Min(num5, maxValue); - if (num > maxValue) - { - return; - } - } - if (Math.abs(ray.Direction.Z) < 1E-06f) - { - if ((ray.Position.Z < this.Min.Z) || (ray.Position.Z > this.Max.Z)) - { - return; - } - } - else - { - float num9 = 1f / ray.Direction.Z; - float num4 = (this.Min.Z - ray.Position.Z) * num9; - float num3 = (this.Max.Z - ray.Position.Z) * num9; - if (num4 > num3) - { - float num12 = num4; - num4 = num3; - num3 = num12; - } - num = MathHelper.Max(num4, num); - maxValue = MathHelper.Min(num3, maxValue); - if (num > maxValue) - { - return; - } - } - result = new Float(num); - } - + /** * Returns a String that represents the current BoundingBox. * @@ -633,6 +494,6 @@ public final class BoundingBox extends ValueType implements IEquatable +{ + private final Vector3[] cornerArray = new Vector3[CornerCount]; + private Matrix matrix; + private static final int PlaneCount = 6; + private final Plane[] planes = new Plane[PlaneCount]; + + /** + * Specifies the total number of corners (8) in the BoundingFrustum. + */ + public static final int CornerCount = 8; + + /** + * Gets the bottom plane of the BoundingFrustum. + * + * @return + * The bottom plane of the BoundingFrustum. + */ + public Plane getBottom() + { + return planes[5]; + } + + /** + * Gets the far plane of the BoundingFrustum. + * + * @return + * The far plane of the BoundingFrustum. + */ + public Plane getFar() + { + return this.planes[1]; + } + + /** + * Gets the left plane of the BoundingFrustum. + * + * @return + * The left plane of the BoundingFrustum. + */ + public Plane getLeft() + { + return this.planes[2]; + } + + /** + * Gets the Matrix that describes this bounding frustum. + * + * @return + * The Matrix that describes this bounding frustum. + */ + public Matrix getMatrix() + { + return this.matrix; + } + + /** + * Sets the Matrix that describes this bounding frustum. + * + * @param value + * + */ + public void setMatrix(Matrix value) + { + matrix = value; + planes[2].Normal.X = -value.M14 - value.M11; + planes[2].Normal.Y = -value.M24 - value.M21; + planes[2].Normal.Z = -value.M34 - value.M31; + planes[2].D = -value.M44 - value.M41; + planes[3].Normal.X = -value.M14 + value.M11; + planes[3].Normal.Y = -value.M24 + value.M21; + planes[3].Normal.Z = -value.M34 + value.M31; + planes[3].D = -value.M44 + value.M41; + planes[4].Normal.X = -value.M14 + value.M12; + planes[4].Normal.Y = -value.M24 + value.M22; + planes[4].Normal.Z = -value.M34 + value.M32; + planes[4].D = -value.M44 + value.M42; + planes[5].Normal.X = -value.M14 - value.M12; + planes[5].Normal.Y = -value.M24 - value.M22; + planes[5].Normal.Z = -value.M34 - value.M32; + planes[5].D = -value.M44 - value.M42; + planes[0].Normal.X = -value.M13; + planes[0].Normal.Y = -value.M23; + planes[0].Normal.Z = -value.M33; + planes[0].D = -value.M43; + planes[1].Normal.X = -value.M14 + value.M13; + planes[1].Normal.Y = -value.M24 + value.M23; + planes[1].Normal.Z = -value.M34 + value.M33; + planes[1].D = -value.M44 + value.M43; + + for (int i = 0; i < 6; i++) + { + float num2 = planes[i].Normal.Length(); + planes[i].Normal = Vector3.Divide(planes[i].Normal, num2); + planes[i].D /= num2; + } + + Ray ray = ComputeIntersectionLine(planes[0], planes[2]); + cornerArray[0] = ComputeIntersection(planes[4], ray); + cornerArray[3] = ComputeIntersection(planes[5], ray); + ray = ComputeIntersectionLine(planes[3], planes[0]); + cornerArray[1] = ComputeIntersection(planes[4], ray); + cornerArray[2] = ComputeIntersection(planes[5], ray); + ray = ComputeIntersectionLine(planes[2], planes[1]); + cornerArray[4] = ComputeIntersection(planes[4], ray); + cornerArray[7] = ComputeIntersection(planes[5], ray); + ray = ComputeIntersectionLine(planes[1], planes[3]); + cornerArray[5] = ComputeIntersection(planes[4], ray); + cornerArray[6] = ComputeIntersection(planes[5], ray); + } + + /** + * Gets the near plane of the BoundingFrustum. + * + * @return + * The near plane of the BoundingFrustum. + */ + public Plane getNear() + { + return this.planes[0]; + } + + /** + * Gets the right plane of the BoundingFrustum. + * + * @return + * The right plane of the BoundingFrustum. + */ + public Plane getRight() + { + return this.planes[3]; + } + + /** + * + * @return + */ + public Plane getTop() + { + return this.planes[4]; + } + + + /** + * Creates a new instance of BoundingFrustum. + * + * @param value + * Combined matrix that usually takes view × projection matrix. + */ + public BoundingFrustum(Matrix value) + { + planes[0] = new Plane(); + planes[1] = new Plane(); + planes[2] = new Plane(); + planes[3] = new Plane(); + planes[4] = new Plane(); + planes[5] = new Plane(); + cornerArray[0] = new Vector3(); + cornerArray[1] = new Vector3(); + cornerArray[2] = new Vector3(); + cornerArray[3] = new Vector3(); + cornerArray[4] = new Vector3(); + cornerArray[5] = new Vector3(); + cornerArray[6] = new Vector3(); + cornerArray[7] = new Vector3(); + + setMatrix(value); + } + + private static Vector3 ComputeIntersection(Plane plane, Ray ray) + { + float num = (-plane.D - Vector3.Dot(plane.Normal, ray.Position)) / Vector3.Dot(plane.Normal, ray.Direction); + + return Vector3.Add(ray.Position, Vector3.Multiply(ray.Direction, num)); + } + + private Ray ComputeIntersectionLine(Plane p1, Plane p2) + { + Ray ray = new Ray(); + ray.Direction = Vector3.Cross(p1.Normal, p2.Normal); + float num = ray.Direction.LengthSquared(); + ray.Position = Vector3.Divide( + Vector3.Cross( + Vector3.Add(Vector3.Multiply(p2.Normal, -p1.D), Vector3.Multiply(p1.Normal, p2.D)), + ray.Direction + ), num); + return ray; + } + + /** + * Checks whether the current BoundingFrustum contains the specified BoundingSphere. + * + * @param sphere + * The BoundingSphere to check against the current BoundingFrustum. + * + * @return + */ + @SuppressWarnings("incomplete-switch") + public ContainmentType Contains(BoundingSphere sphere) + { + boolean intersects = false; + + for (int i = 0; i < PlaneCount; ++i) + { + PlaneIntersectionType planeIntersectionType = sphere.Intersects(this.planes[i]); + + switch (planeIntersectionType) + { + case Front: + return ContainmentType.Disjoint; + + case Intersecting: + intersects = true; + break; + } + } + + return intersects ? ContainmentType.Intersects : ContainmentType.Contains; + } + + /** + * Checks whether the current BoundingFrustum contains the specified point. + * + * @param point + * The point to check against the current BoundingFrustum. + * + * @return + */ + public ContainmentType Contains(Vector3 point) + { + for (int i = 0; i < PlaneCount; ++i) + { + if (this.planes[i].DotCoordinate(point) > 0) + { + return ContainmentType.Disjoint; + } + } + + return ContainmentType.Contains; + } + + /** + * Checks whether the current BoundingFrustum contains the specified BoundingFrustum. + * + * @param frustrum + * The BoundingFrustum to check against the current BoundingFrustum. + * + * @return + */ + public ContainmentType Contains(BoundingFrustum frustrum) + { + ContainmentType disjoint = ContainmentType.Disjoint; + + if (Intersects(frustrum)) + { + disjoint = ContainmentType.Contains; + + for (int i = 0; i < 8; i++) + { + if (Contains(frustrum.cornerArray[i]) == ContainmentType.Disjoint) + { + return ContainmentType.Intersects; + } + } + } + + return disjoint; + } + + /** + * Checks whether the current BoundingFrustum contains the specified BoundingBox. + * + * @param box + * The BoundingBox to check against the current BoundingFrustum. + * + * @return + */ + @SuppressWarnings("incomplete-switch") + public ContainmentType Contains(BoundingBox box) + { + boolean flag = false; + + for(int i = 0; i < 6; i++) + { + switch (box.Intersects(planes[i])) + { + case Front: + return ContainmentType.Disjoint; + + case Intersecting: + flag = true; + break; + } + } + + if (!flag) + { + return ContainmentType.Contains; + } + + return ContainmentType.Intersects; + } + + /** + * Determines whether the specified Object is equal to the BoundingFrustum. + * + * @param obj + * The Object to compare with the current BoundingFrustum. + */ + @Override + public boolean equals(Object obj) + { + return (obj != null && obj instanceof BoundingFrustum) ? this.Equals((BoundingFrustum)obj) : false; + } + + /** + * Determines whether the specified BoundingFrustum is equal to the current BoundingFrustum. + * + * @param other + * The BoundingFrustum to compare with the current BoundingFrustum. + */ + public boolean Equals(BoundingFrustum other) + { + return this.matrix.Equals(other.matrix); + } + + /** + * Gets an array of points that make up the corners of the BoundingFrustum. + * + * @param corners + * An existing array of at least 8 Vector3 points where the corners of the BoundingFrustum are written. + */ + public void GetCorners(Vector3[] corners) + { + if (corners == null) + { + throw new ArgumentNullException("corners"); + } + + if (corners.length < CornerCount) + { + throw new ArgumentOutOfRangeException("corners"); + } + + System.arraycopy(this.cornerArray, 0, corners, 0, CornerCount); + } + + /** + * Gets an array of points that make up the corners of the BoundingFrustum. + * + * @return + * An array of points that make up the corners of the BoundingFrustum. + */ + public Vector3[] GetCorners() + { + Vector3[] array = new Vector3[CornerCount]; + + System.arraycopy(this.cornerArray, 0, array, 0, CornerCount); + + return array; + } + + /** + * Gets the hash code for this instance. + */ + @Override + public int hashCode() + { + return matrix.hashCode(); + } + + /** + * Checks whether the current BoundingFrustum intersects the specified BoundingBox. + * + * @param box + * The BoundingBox to check for intersection. + * + * @return + */ + public boolean Intersects(BoundingBox box) + { + return this.Contains(box) != ContainmentType.Disjoint; + } + + /** + * Checks whether the current BoundingFrustum intersects the specified BoundingFrustum. + * + * @param frustrum + * The BoundingFrustum to check for intersection. + * + * @return + */ + public boolean Intersects(BoundingFrustum frustrum) + { + // TODO Auto-generated method stub + throw new NotImplementedException(); + } + + /** + * Checks whether the current BoundingFrustum intersects the specified BoundingSphere. + * + * @param sphere + * The BoundingSphere to check for intersection. + * + * @return + */ + public boolean Intersects(BoundingSphere sphere) + { + return this.Contains(sphere) != ContainmentType.Disjoint; + } + + /** + * Checks whether the current BoundingFrustum intersects the specified Plane. + * + * @param plane + * The Plane to check for intersection. + * + * @return + */ + public PlaneIntersectionType Intersects(Plane plane) + { + int num = 0; + + for (int i = 0; i < 8; i++) + { + float num3 = Vector3.Dot(cornerArray[i], plane.Normal); + + if ((num3 + plane.D) > 0) + { + num |= 1; + } + else + { + num |= 2; + } + + if (num == 3) + { + return PlaneIntersectionType.Intersecting; + } + } + + if (num != 1) + { + return PlaneIntersectionType.Back; + } + + return PlaneIntersectionType.Front; + } + + /** + * Checks whether the current BoundingFrustum intersects the specified Ray. + * + * @param ray + * The Ray to check for intersection. + * + * @return + */ + public Float Intersects(Ray ray) + { + // TODO Auto-generated method stub + throw new NotImplementedException(); + } + + /** + * Returns a String that represents the current BoundingFrustum. + */ + @Override + public String toString() + { + StringBuilder sb = new StringBuilder(256); + sb.append("{Near:"); + sb.append(this.planes[0].toString()); + sb.append(" Far:"); + sb.append(this.planes[1].toString()); + sb.append(" Left:"); + sb.append(this.planes[2].toString()); + sb.append(" Right:"); + sb.append(this.planes[3].toString()); + sb.append(" Top:"); + sb.append(this.planes[4].toString()); + sb.append(" Bottom:"); + sb.append(this.planes[5].toString()); + sb.append("}"); + return sb.toString(); + } +} diff --git a/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/BoundingSphere.java b/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/BoundingSphere.java index 4c7e82e..ebd5d36 100644 --- a/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/BoundingSphere.java +++ b/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/BoundingSphere.java @@ -15,12 +15,12 @@ public final class BoundingSphere extends ValueType implements IEquatable num) - { - return ContainmentType.Intersects; - } - vector.X = this.Center.X - box.Max.X; - vector.Y = this.Center.Y - box.Max.Y; - vector.Z = this.Center.Z - box.Max.Z; - if (vector.LengthSquared() > num) - { - return ContainmentType.Intersects; - } - vector.X = this.Center.X - box.Max.X; - vector.Y = this.Center.Y - box.Min.Y; - vector.Z = this.Center.Z - box.Max.Z; - if (vector.LengthSquared() > num) - { - return ContainmentType.Intersects; - } - vector.X = this.Center.X - box.Min.X; - vector.Y = this.Center.Y - box.Min.Y; - vector.Z = this.Center.Z - box.Max.Z; - if (vector.LengthSquared() > num) - { - return ContainmentType.Intersects; - } - vector.X = this.Center.X - box.Min.X; - vector.Y = this.Center.Y - box.Max.Y; - vector.Z = this.Center.Z - box.Min.Z; - if (vector.LengthSquared() > num) - { - return ContainmentType.Intersects; - } - vector.X = this.Center.X - box.Max.X; - vector.Y = this.Center.Y - box.Max.Y; - vector.Z = this.Center.Z - box.Min.Z; - if (vector.LengthSquared() > num) - { - return ContainmentType.Intersects; - } - vector.X = this.Center.X - box.Max.X; - vector.Y = this.Center.Y - box.Min.Y; - vector.Z = this.Center.Z - box.Min.Z; - if (vector.LengthSquared() > num) - { - return ContainmentType.Intersects; - } - vector.X = this.Center.X - box.Min.X; - vector.Y = this.Center.Y - box.Min.Y; - vector.Z = this.Center.Z - box.Min.Z; - if (vector.LengthSquared() > num) - { - return ContainmentType.Intersects; - } - return ContainmentType.Contains; + Vector3 vector = Vector3.Zero; + + if (!box.Intersects(this)) + { + return ContainmentType.Disjoint; + } + + float num = this.Radius * this.Radius; + vector.X = this.Center.X - box.Min.X; + vector.Y = this.Center.Y - box.Max.Y; + vector.Z = this.Center.Z - box.Max.Z; + + if (vector.LengthSquared() > num) + { + return ContainmentType.Intersects; + } + + vector.X = this.Center.X - box.Max.X; + vector.Y = this.Center.Y - box.Max.Y; + vector.Z = this.Center.Z - box.Max.Z; + + if (vector.LengthSquared() > num) + { + return ContainmentType.Intersects; + } + + vector.X = this.Center.X - box.Max.X; + vector.Y = this.Center.Y - box.Min.Y; + vector.Z = this.Center.Z - box.Max.Z; + + if (vector.LengthSquared() > num) + { + return ContainmentType.Intersects; + } + + vector.X = this.Center.X - box.Min.X; + vector.Y = this.Center.Y - box.Min.Y; + vector.Z = this.Center.Z - box.Max.Z; + + if (vector.LengthSquared() > num) + { + return ContainmentType.Intersects; + } + + vector.X = this.Center.X - box.Min.X; + vector.Y = this.Center.Y - box.Max.Y; + vector.Z = this.Center.Z - box.Min.Z; + + if (vector.LengthSquared() > num) + { + return ContainmentType.Intersects; + } + + vector.X = this.Center.X - box.Max.X; + vector.Y = this.Center.Y - box.Max.Y; + vector.Z = this.Center.Z - box.Min.Z; + + if (vector.LengthSquared() > num) + { + return ContainmentType.Intersects; + } + + vector.X = this.Center.X - box.Max.X; + vector.Y = this.Center.Y - box.Min.Y; + vector.Z = this.Center.Z - box.Min.Z; + + if (vector.LengthSquared() > num) + { + return ContainmentType.Intersects; + } + + vector.X = this.Center.X - box.Min.X; + vector.Y = this.Center.Y - box.Min.Y; + vector.Z = this.Center.Z - box.Min.Z; + + if (vector.LengthSquared() > num) + { + return ContainmentType.Intersects; + } + + return ContainmentType.Contains; } - + /** * Checks whether the current BoundingSphere contains the specified BoundingSphere. * @@ -135,21 +155,23 @@ public final class BoundingSphere extends ValueType implements IEquatable= (this.Radius * this.Radius)) - { - return ContainmentType.Disjoint; - } - return ContainmentType.Contains; + if (Vector3.DistanceSquared(point, this.Center) >= (this.Radius * this.Radius)) + { + return ContainmentType.Disjoint; + } + + return ContainmentType.Contains; } - - /** - * Checks whether the current BoundingSphere contains the specified BoundingBox. - * - * @param box - * The BoundingBox to test for overlap. - * - * @param result - * [OutAttribute] Enumeration indicating the extent of overlap. - */ - public void Contains(BoundingBox box, ContainmentType result) - { - boolean flag = false; - box.Intersects(this, flag); - if (!flag) - { - result = ContainmentType.Disjoint; - } - else - { - Vector3 vector = Vector3.Zero; - float num = this.Radius * this.Radius; - result = ContainmentType.Intersects; - vector.X = this.Center.X - box.Min.X; - vector.Y = this.Center.Y - box.Max.Y; - vector.Z = this.Center.Z - box.Max.Z; - if (vector.LengthSquared() <= num) - { - vector.X = this.Center.X - box.Max.X; - vector.Y = this.Center.Y - box.Max.Y; - vector.Z = this.Center.Z - box.Max.Z; - if (vector.LengthSquared() <= num) - { - vector.X = this.Center.X - box.Max.X; - vector.Y = this.Center.Y - box.Min.Y; - vector.Z = this.Center.Z - box.Max.Z; - if (vector.LengthSquared() <= num) - { - vector.X = this.Center.X - box.Min.X; - vector.Y = this.Center.Y - box.Min.Y; - vector.Z = this.Center.Z - box.Max.Z; - if (vector.LengthSquared() <= num) - { - vector.X = this.Center.X - box.Min.X; - vector.Y = this.Center.Y - box.Max.Y; - vector.Z = this.Center.Z - box.Min.Z; - if (vector.LengthSquared() <= num) - { - vector.X = this.Center.X - box.Max.X; - vector.Y = this.Center.Y - box.Max.Y; - vector.Z = this.Center.Z - box.Min.Z; - if (vector.LengthSquared() <= num) - { - vector.X = this.Center.X - box.Max.X; - vector.Y = this.Center.Y - box.Min.Y; - vector.Z = this.Center.Z - box.Min.Z; - if (vector.LengthSquared() <= num) - { - vector.X = this.Center.X - box.Min.X; - vector.Y = this.Center.Y - box.Min.Y; - vector.Z = this.Center.Z - box.Min.Z; - if (vector.LengthSquared() <= num) - { - result = ContainmentType.Contains; - } - } - } - } - } - } - } - } - } - } - - /** - * Checks whether the current BoundingSphere contains the specified BoundingSphere. - * - * @param sphere - * The BoundingSphere to test for overlap. - * - * @param result - * [OutAttribute] Enumeration indicating the extent of overlap. - */ - public void Contains(BoundingSphere sphere, ContainmentType result) - { - float num3 = 0; - Vector3.Distance(this.Center, sphere.Center, num3); - float radius = this.Radius; - float num = sphere.Radius; - result = ((radius + num) >= num3) ? (((radius - num) >= num3) ? ContainmentType.Contains : ContainmentType.Intersects) : ContainmentType.Disjoint; - } - - /** - * Checks whether the current BoundingSphere contains the specified point. - * - * @param point - * The point to test for overlap. - * - * @param result - * [OutAttribute] Enumeration indicating the extent of overlap. - */ - public void Contains(Vector3 point, ContainmentType result) - { - float num = 0; - Vector3.DistanceSquared(point, this.Center, num); - result = (num < (this.Radius * this.Radius)) ? ContainmentType.Contains : ContainmentType.Disjoint; - } - + /** * Creates the smallest BoundingSphere that can contain a specified BoundingBox. * @@ -287,14 +202,13 @@ public final class BoundingSphere extends ValueType implements IEquatable= num) - { - if ((radius - num2) >= num) - { - return original; - } - if ((num2 - radius) >= num) - { - return additional; - } - } - Vector3 vector = Vector3.Multiply(vector2, 1f / num); - float num5 = MathHelper.Min(-radius, num - num2); - float num4 = (MathHelper.Max(radius, num + num2) - num5) * 0.5f; - sphere.Center = Vector3.Add(original.Center, Vector3.Multiply(vector, num4 + num5)); - sphere.Radius = num4; - return sphere; + BoundingSphere sphere = new BoundingSphere(); + Vector3 vector2 = Vector3.Zero; + Vector3.Subtract(additional.Center, original.Center, vector2); + float num = vector2.Length(); + float radius = original.Radius; + float num2 = additional.Radius; + + if ((radius + num2) >= num) + { + if ((radius - num2) >= num) + { + return original; + } + + if ((num2 - radius) >= num) + { + return additional; + } + } + + Vector3 vector = Vector3.Multiply(vector2, 1f / num); + float num5 = MathHelper.Min(-radius, num - num2); + float num4 = (MathHelper.Max(radius, num + num2) - num5) * 0.5f; + sphere.Center = Vector3.Add(original.Center, Vector3.Multiply(vector, num4 + num5)); + sphere.Radius = num4; + return sphere; } - + /** * Creates a BoundingSphere that contains the two specified BoundingSphere instances. * @@ -365,31 +281,34 @@ public final class BoundingSphere extends ValueType implements IEquatable= num) - { - if ((radius - num2) >= num) - { - result = original; - return; - } - if ((num2 - radius) >= num) - { - result = additional; - return; - } - } - Vector3 vector = Vector3.Multiply(vector2, 1f / num); - float num5 = MathHelper.Min(-radius, num - num2); - float num4 = (MathHelper.Max(radius, num + num2) - num5) * 0.5f; - result.Center = Vector3.Add(original.Center, Vector3.Multiply(vector, num4 + num5)); - result.Radius = num4; + Vector3 vector2 = Vector3.Zero; + Vector3.Subtract(additional.Center, original.Center, vector2); + float num = vector2.Length(); + float radius = original.Radius; + float num2 = additional.Radius; + + if ((radius + num2) >= num) + { + if ((radius - num2) >= num) + { + result = original; + return; + } + + if ((num2 - radius) >= num) + { + result = additional; + return; + } + } + + Vector3 vector = Vector3.Multiply(vector2, 1f / num); + float num5 = MathHelper.Min(-radius, num - num2); + float num4 = (MathHelper.Max(radius, num + num2) - num5) * 0.5f; + result.Center = Vector3.Add(original.Center, Vector3.Multiply(vector, num4 + num5)); + result.Radius = num4; } - + /** * Determines whether the specified Object is equal to the BoundingSphere. * @@ -404,7 +323,7 @@ public final class BoundingSphere extends ValueType implements IEquatable num3; - } - - /** - * Checks whether the current BoundingSphere intersects a Plane. - * - * @param plane - * The Plane to check for intersection with. - * - * @param result - * [OutAttribute] An enumeration indicating whether the BoundingSphere intersects the Plane. - */ - public void Intersects(Plane plane, PlaneIntersectionType result) - { - plane.Intersects(this, result); - } - - /** - * Checks whether the current BoundingSphere intersects a Ray. - * - * @param ray - * The Ray to check for intersection with. - * - * @param result - * [OutAttribute] Distance at which the ray intersects the BoundingSphere or null if there is no intersection. - */ - public void Intersects(Ray ray, Float result) - { - ray.Intersects(this, result); - } - + /** * Returns a String that represents the current BoundingSphere. * @@ -574,7 +429,7 @@ public final class BoundingSphere extends ValueType implements IEquatable { private int packedValue; - + /** * Creates a new instance of the class. * @@ -24,7 +24,7 @@ public final class Color extends ValueType implements IEquatable { this.packedValue = PackHelper(vector.X, vector.Y, vector.Z, 1f); } - + /** * Creates a new instance of the class. * @@ -35,12 +35,12 @@ public final class Color extends ValueType implements IEquatable { this.packedValue = PackHelper(vector.X, vector.Y, vector.Z, vector.W); } - + private Color(int packedValue) { this.packedValue = packedValue; } - + /** * Creates a new instance of the class. * @@ -56,16 +56,18 @@ public final class Color extends ValueType implements IEquatable public Color(int r, int g, int b) { if ((((r | g) | b) & -256) != 0) - { - r = ClampToByte64((long) r); - g = ClampToByte64((long) g); - b = ClampToByte64((long) b); - } - g = g << 8; - b = b << 0x10; - this.packedValue = (int)(((r | g) | b) | -16777216); + { + r = ClampToByte64((long) r); + g = ClampToByte64((long) g); + b = ClampToByte64((long) b); + } + + g = g << 8; + b = b << 0x10; + + this.packedValue = (int)(((r | g) | b) | -16777216); } - + /** * Creates a new instance of the class. * @@ -80,9 +82,9 @@ public final class Color extends ValueType implements IEquatable */ public Color(float r, float g, float b) { - this.packedValue = PackHelper(r, g, b, 1f); + this.packedValue = PackHelper(r, g, b, 1f); } - + /** * Creates a new instance of the class. * @@ -101,18 +103,20 @@ public final class Color extends ValueType implements IEquatable public Color(int r, int g, int b, int a) { if (((((r | g) | b) | a) & -256) != 0) - { - r = ClampToByte32(r); - g = ClampToByte32(g); - b = ClampToByte32(b); - a = ClampToByte32(a); - } - g = g << 8; - b = b << 0x10; - a = a << 0x18; - this.packedValue = (int)(((r | g) | b) | a); + { + r = ClampToByte32(r); + g = ClampToByte32(g); + b = ClampToByte32(b); + a = ClampToByte32(a); + } + + g = g << 8; + b = b << 0x10; + a = a << 0x18; + + this.packedValue = (int)(((r | g) | b) | a); } - + /** * Creates a new instance of the class. * @@ -130,9 +134,9 @@ public final class Color extends ValueType implements IEquatable */ public Color(float r, float g, float b, float a) { - this.packedValue = PackHelper(r, g, b, a); + this.packedValue = PackHelper(r, g, b, a); } - + public Color() { this.packedValue = Transparent.packedValue; @@ -140,30 +144,34 @@ public final class Color extends ValueType implements IEquatable private static int ClampToByte32(int value) { - if (value < 0) - { - return 0; - } - if (value > 0xff) - { - return 0xff; - } - return value; + if (value < 0) + { + return 0; + } + + if (value > 0xff) + { + return 0xff; + } + + return value; } - + private static int ClampToByte64(long value) { - if (value < 0L) - { - return 0; - } - if (value > 0xffL) - { - return 0xff; - } - return (int) value; + if (value < 0L) + { + return 0; + } + + if (value > 0xffL) + { + return 0xff; + } + + return (int) value; } - + /** * * @param obj @@ -172,12 +180,12 @@ public final class Color extends ValueType implements IEquatable { return ((obj != null) && (obj instanceof Color)) ? (this.packedValue == ((Color)obj).packedValue) : false; } - + public boolean Equals(Color other) { return this.packedValue == other.packedValue; } - + /** * Convert a non premultiplied color into color data that contains alpha. * @@ -186,9 +194,9 @@ public final class Color extends ValueType implements IEquatable */ public static Color FromNonPremultiplied(Vector4 vector) { - return new Color(PackHelper(vector.X * vector.W, vector.Y * vector.W, vector.Z * vector.W, vector.W)); + return new Color(PackHelper(vector.X * vector.W, vector.Y * vector.W, vector.Z * vector.W, vector.W)); } - + /** * Converts a non-premultiplied alpha color to a color that contains premultiplied alpha. * @@ -206,16 +214,17 @@ public final class Color extends ValueType implements IEquatable */ public static Color FromNonPremultiplied(int r, int g, int b, int a) { - r = ClampToByte64((r * a) / 0xffL); - g = ClampToByte64((g * a) / 0xffL); - b = ClampToByte64((b * a) / 0xffL); - a = ClampToByte32(a); - g = g << 8; - b = b << 0x10; - a = a << 0x18; - return new Color((int)(((r | g) | b) | a)); + r = ClampToByte64((r * a) / 0xffL); + g = ClampToByte64((g * a) / 0xffL); + b = ClampToByte64((b * a) / 0xffL); + a = ClampToByte32(a); + g = g << 8; + b = b << 0x10; + a = a << 0x18; + + return new Color((int)(((r | g) | b) | a)); } - + /** * Serves as a hash function for a particular type. */ @@ -224,7 +233,7 @@ public final class Color extends ValueType implements IEquatable { return this.packedValue; } - + /** * Linearly interpolate a color. * @@ -239,26 +248,26 @@ public final class Color extends ValueType implements IEquatable */ public static Color Lerp(Color value1, Color value2, float amount) { - Color color = new Color(Transparent.getPackedValue()); - long packedValue = value1.packedValue; - long num2 = value2.packedValue; - int num7 = (byte) packedValue; - int num6 = (byte) (packedValue >> 8); - int num5 = (byte) (packedValue >> 0x10); - int num4 = (byte) (packedValue >> 0x18); - int num15 = (byte) num2; - int num14 = (byte) (num2 >> 8); - int num13 = (byte) (num2 >> 0x10); - int num12 = (byte) (num2 >> 0x18); - int num = (int) PackUtils.PackUNorm(65536f, amount); - int num11 = num7 + (((num15 - num7) * num) >> 0x10); - int num10 = num6 + (((num14 - num6) * num) >> 0x10); - int num9 = num5 + (((num13 - num5) * num) >> 0x10); - int num8 = num4 + (((num12 - num4) * num) >> 0x10); - color.packedValue = (int)(((num11 | (num10 << 8)) | (num9 << 0x10)) | (num8 << 0x18)); - return color; + Color color = new Color(Transparent.getPackedValue()); + long packedValue = value1.packedValue; + long num2 = value2.packedValue; + int num7 = (byte) packedValue; + int num6 = (byte) (packedValue >> 8); + int num5 = (byte) (packedValue >> 0x10); + int num4 = (byte) (packedValue >> 0x18); + int num15 = (byte) num2; + int num14 = (byte) (num2 >> 8); + int num13 = (byte) (num2 >> 0x10); + int num12 = (byte) (num2 >> 0x18); + int num = (int) PackUtils.PackUNorm(65536f, amount); + int num11 = num7 + (((num15 - num7) * num) >> 0x10); + int num10 = num6 + (((num14 - num6) * num) >> 0x10); + int num9 = num5 + (((num13 - num5) * num) >> 0x10); + int num8 = num4 + (((num12 - num4) * num) >> 0x10); + color.packedValue = (int)(((num11 | (num10 << 8)) | (num9 << 0x10)) | (num8 << 0x18)); + return color; } - + /** * Multiply each color component by the scale factor. * @@ -270,64 +279,72 @@ public final class Color extends ValueType implements IEquatable */ public static Color Multiply(Color value, float scale) { - int num; - Color color = new Color(Transparent.getPackedValue()); - int packedValue = value.packedValue; - int num5 = (byte) packedValue; - int num4 = (byte) (packedValue >> 8); - int num3 = (byte) (packedValue >> 0x10); - int num2 = (byte) (packedValue >> 0x18); - scale *= 65536f; - if (scale < 0f) - { - num = 0; - } - else if (scale > 1.677722E+07f) - { - num = 0xffffff; - } - else - { - num = (int)scale; - } - num5 = (num5 * num) >> 0x10; - num4 = (num4 * num) >> 0x10; - num3 = (num3 * num) >> 0x10; - num2 = (num2 * num) >> 0x10; - if (num5 > 0xff) - { - num5 = 0xff; - } - if (num4 > 0xff) - { - num4 = 0xff; - } - if (num3 > 0xff) - { - num3 = 0xff; - } - if (num2 > 0xff) - { - num2 = 0xff; - } - color.packedValue = ((num5 | (num4 << 8)) | (num3 << 0x10)) | (num2 << 0x18); - return color; + int num; + Color color = new Color(Transparent.getPackedValue()); + int packedValue = value.packedValue; + int num5 = (byte) packedValue; + int num4 = (byte) (packedValue >> 8); + int num3 = (byte) (packedValue >> 0x10); + int num2 = (byte) (packedValue >> 0x18); + scale *= 65536f; + + if (scale < 0f) + { + num = 0; + } + else if (scale > 1.677722E+07f) + { + num = 0xffffff; + } + else + { + num = (int)scale; + } + + num5 = (num5 * num) >> 0x10; + num4 = (num4 * num) >> 0x10; + num3 = (num3 * num) >> 0x10; + num2 = (num2 * num) >> 0x10; + + if (num5 > 0xff) + { + num5 = 0xff; + } + + if (num4 > 0xff) + { + num4 = 0xff; + } + + if (num3 > 0xff) + { + num3 = 0xff; + } + + if (num2 > 0xff) + { + num2 = 0xff; + } + + color.packedValue = ((num5 | (num4 << 8)) | (num3 << 0x10)) | (num2 << 0x18); + return color; } - + static int InitializeFromArgb(byte a, byte r, byte g, byte b) { return (int)(a << 24) + (int)(r << 16) + (int)(g << 8) + b; } - + private static int PackHelper(float vectorX, float vectorY, float vectorZ, float vectorW) { - int num4 = PackUtils.PackUNorm(255f, vectorX); - int num3 = PackUtils.PackUNorm(255f, vectorY) << 8; - int num2 = PackUtils.PackUNorm(255f, vectorZ) << 0x10; - int num = PackUtils.PackUNorm(255f, vectorW) << 0x18; - return (((num4 | num3) | num2) | num); + int num4 = PackUtils.PackUNorm(255f, vectorX); + int num3 = PackUtils.PackUNorm(255f, vectorY) << 8; + int num2 = PackUtils.PackUNorm(255f, vectorZ) << 0x10; + int num = PackUtils.PackUNorm(255f, vectorW) << 0x18; + + return (((num4 | num3) | num2) | num); } - + /** * Gets a string representation of this object. */ @@ -336,32 +353,32 @@ public final class Color extends ValueType implements IEquatable { return String.format(Locale.getDefault(), "{R:%d G:%d B:%d A:%d}", this.R(), this.G(), this.B(), this.A()); } - + /** * Gets a three-component vector representation for this object. */ public Vector3 ToVector3() { Vector3 vector = new Vector3(); - vector.X = PackUtils.UnpackUNorm(0xff, this.packedValue); - vector.Y = PackUtils.UnpackUNorm(0xff, this.packedValue >> 8); - vector.Z = PackUtils.UnpackUNorm(0xff, this.packedValue >> 0x10); - return vector; + vector.X = PackUtils.UnpackUNorm(0xff, this.packedValue); + vector.Y = PackUtils.UnpackUNorm(0xff, this.packedValue >> 8); + vector.Z = PackUtils.UnpackUNorm(0xff, this.packedValue >> 0x10); + return vector; } - + /** * Gets a four-component vector representation for this object. */ public Vector4 ToVector4() { Vector4 vector = new Vector4(); - vector.X = PackUtils.UnpackUNorm(0xff, this.packedValue); - vector.Y = PackUtils.UnpackUNorm(0xff, this.packedValue >> 8); - vector.Z = PackUtils.UnpackUNorm(0xff, this.packedValue >> 0x10); - vector.W = PackUtils.UnpackUNorm(0xff, this.packedValue >> 0x18); - return vector; + vector.X = PackUtils.UnpackUNorm(0xff, this.packedValue); + vector.Y = PackUtils.UnpackUNorm(0xff, this.packedValue >> 8); + vector.Z = PackUtils.UnpackUNorm(0xff, this.packedValue >> 0x10); + vector.W = PackUtils.UnpackUNorm(0xff, this.packedValue >> 0x18); + return vector; } - + /** * Gets the Alpha component of this Color. */ diff --git a/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/Curve.java b/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/Curve.java new file mode 100644 index 0000000..1e95274 --- /dev/null +++ b/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/Curve.java @@ -0,0 +1,347 @@ +package Microsoft.Xna.Framework; + +import System.*; + +/** + * Stores an arbitrary collection of 2D CurveKey points, and provides methods for evaluating features of the curve they define. + * + * @author Halofreak1990 + */ +public class Curve +{ + private CurveKeyCollection keys; + + /** + * Gets a value indicating whether the curve is constant. + * + * @return + * true if the curve is constant; otherwise, false. + */ + public boolean IsConstant() + { + return this.keys.Count() <= 1; + } + + /** + * Gets a collection of CurveKey points that make up the curve. + * + * @return + * The points that make up the curve. + */ + public CurveKeyCollection getKeys() + { + return keys; + } + + /** + * Specifies how to handle weighting values that are greater than the last control point in the curve. + */ + public CurveLoopType PostLoop; + + /** + * Specifies how to handle weighting values that are less than the first control point in the curve. + */ + public CurveLoopType PreLoop; + + /** + * Initializes a new instance of the Curve class. + */ + public Curve() + { + this.keys = new CurveKeyCollection(); + } + + private float GetCurvePosition(float position) + { + // only for position in curve + CurveKey prev = this.keys.get(0); + CurveKey next; + + for (int i = 1; i < this.keys.Count(); i++) + { + next = this.keys.get(i); + + if (next.getPosition() >= position) + { + if (prev.Continuity == CurveContinuity.Step) + { + if (position >= 1f) + { + return next.Value; + } + + return prev.Value; + } + + float t = (position - prev.getPosition()) / (next.getPosition() - prev.getPosition());//to have t in [0,1] + float ts = t * t; + float tss = ts * t; + //After a lot of search on internet I have found all about spline function + // and bezier (phi'sss ancien) but finally use hermite curve + //http://en.wikipedia.org/wiki/Cubic_Hermite_spline + //P(t) = (2*t^3 - 3t^2 + 1)*P0 + (t^3 - 2t^2 + t)m0 + (-2t^3 + 3t^2)P1 + (t^3-t^2)m1 + //with P0.value = prev.value , m0 = prev.tangentOut, P1= next.value, m1 = next.TangentIn + return (2 * tss - 3 * ts + 1f) * prev.Value + (tss - 2 * ts + t) * prev.TangentOut + (3 * ts - 2 * tss) * next.Value + (tss - ts) * next.TangentIn; + } + + prev = next; + } + + return 0f; + } + + private int GetNumberOfCycle(float position) + { + float cycle = (position - keys.get(0).getPosition()) / (keys.get(keys.Count() - 1).getPosition() - keys.get(0).getPosition()); + + if (cycle < 0f) + { + cycle--; + } + + return (int)cycle; + } + + /** + * Creates a copy of this Curve. + * + * @return + * A copy of this Curve. + */ + public Curve Clone() + { + Curve curve = new Curve(); + + curve.keys = this.keys.Clone(); + curve.PreLoop = this.PreLoop; + curve.PostLoop = this.PostLoop; + + return curve; + } + + /** + * Computes a specified type of TangentIn and a specified type of TangentOut for a given CurveKey. + * + * @param keyIndex + * The index of the CurveKey for which to compute tangents (in the Keys collection of the Curve). + * + * @param tangentInType + * The type of TangentIn to compute (one of the types specified in the CurveTangent enumeration). + * + * @param tangentOutType + * The type of TangentOut to compute (one of the types specified in the CurveTangent enumeration). + */ + public void ComputeTangent(int keyIndex, CurveTangent tangentInType, CurveTangent tangentOutType) + { + // See http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.curvetangent.aspx + + CurveKey key = keys.get(keyIndex); + + float p0, p, p1; + p0 = p = p1 = key.getPosition(); + + float v0, v, v1; + v0 = v = v1 = key.Value; + + if ( keyIndex > 0 ) + { + p0 = keys.get(keyIndex - 1).getPosition(); + v0 = keys.get(keyIndex - 1).Value; + } + + if (keyIndex < keys.Count() - 1) + { + p1 = keys.get(keyIndex + 1).getPosition(); + v1 = keys.get(keyIndex + 1).Value; + } + + switch (tangentInType) + { + case Flat: + key.TangentIn = 0; + break; + case Linear: + key.TangentIn = v - v0; + break; + case Smooth: + float pn = p1 - p0; + + if (Math.abs(pn) < Single.Epsilon) + { + key.TangentIn = 0; + } + else + { + key.TangentIn = (v1 - v0) * ((p - p0) / pn); + } + break; + } + + switch (tangentOutType) + { + case Flat: + key.TangentOut = 0; + break; + case Linear: + key.TangentOut = v1 - v; + break; + case Smooth: + float pn = p1 - p0; + + if (Math.abs(pn) < Single.Epsilon) + { + key.TangentOut = 0; + } + else + { + key.TangentOut = (v1 - v0) * ((p1 - p) / pn); + } + break; + } + } + + /** + * Computes both the TangentIn and the TangentOut for a CurveKey specified by its index. + * + * @param keyIndex + * The index of the CurveKey for which to compute tangents (in the Keys collection of the Curve). + * + * @param tangentType + * The type of tangents to compute (one of the types specified in the CurveTangent enumeration). + */ + public void ComputeTangent(int keyIndex, CurveTangent tangentType) + { + this.ComputeTangent(keyIndex, tangentType, tangentType); + } + + /** + * Computes all tangents for all CurveKeys in this Curve, using different tangent types for TangentOut and TangentIn. + * + * @param tangentInType + * The type of TangentIn to compute (one of the types specified in the CurveTangent enumeration). + * + * @param tangentOutType + * The type of TangentOut to compute (one of the types specified in the CurveTangent enumeration). + */ + public void ComputeTangents(CurveTangent tangentInType, CurveTangent tangentOutType) + { + for (int i = 0; i < keys.Count(); i++) + { + ComputeTangent(i, tangentInType, tangentOutType); + } + } + + /** + * Computes all tangents for all CurveKeys in this Curve, using a specified tangent type for both TangentIn and TangentOut. + * + * @param tangentType + * The type of TangentOut and TangentIn to compute (one of the types specified in the CurveTangent enumeration). + */ + public void ComputeTangents(CurveTangent tangentType) + { + this.ComputeTangents(tangentType, tangentType); + } + + /** + * Finds the value at a position on the Curve. + * + * @param position + * The position on the Curve. + * + * @return + */ + public float Evaluate(float position) + { + CurveKey first = keys.get(0); + CurveKey last = keys.get(keys.Count() - 1); + + if (position < first.getPosition()) + { + switch (this.PreLoop) + { + case Constant: + //constant + return first.Value; + + case Linear: + // linear y = a*x +b with a tangent of last point + return first.Value - first.TangentIn * (first.getPosition() - position); + + case Cycle: + //start -> end / start -> end + int cycle = GetNumberOfCycle(position); + float virtualPos = position - (cycle * (last.getPosition() - first.getPosition())); + return GetCurvePosition(virtualPos); + + case CycleOffset: + //make the curve continue (with no step) so must up the curve each cycle of delta(value) + cycle = GetNumberOfCycle(position); + virtualPos = position - (cycle * (last.getPosition() - first.getPosition())); + return (GetCurvePosition(virtualPos) + cycle * (last.Value - first.Value)); + + case Oscillate: + //go back on curve from end and target start + // start-> end / end -> start + cycle = GetNumberOfCycle(position); + + if (0 == cycle % 2f)//if pair + { + virtualPos = position - (cycle * (last.getPosition() - first.getPosition())); + } + else + { + virtualPos = last.getPosition() - position + first.getPosition() + (cycle * (last.getPosition() - first.getPosition())); + } + + return GetCurvePosition(virtualPos); + } + } + else if (position > last.getPosition()) + { + int cycle; + + switch (this.PostLoop) + { + case Constant: + //constant + return last.Value; + + case Linear: + // linear y = a*x +b with a tangent of last point + return last.Value + first.TangentOut * (position - last.getPosition()); + + case Cycle: + //start -> end / start -> end + cycle = GetNumberOfCycle(position); + float virtualPos = position - (cycle * (last.getPosition() - first.getPosition())); + return GetCurvePosition(virtualPos); + + case CycleOffset: + //make the curve continue (with no step) so must up the curve each cycle of delta(value) + cycle = GetNumberOfCycle(position); + virtualPos = position - (cycle * (last.getPosition() - first.getPosition())); + return (GetCurvePosition(virtualPos) + cycle * (last.Value - first.Value)); + + case Oscillate: + //go back on curve from end and target start + // start-> end / end -> start + cycle = GetNumberOfCycle(position); + virtualPos = position - (cycle * (last.getPosition() - first.getPosition())); + + if (0 == cycle % 2f)//if pair + { + virtualPos = position - (cycle * (last.getPosition() - first.getPosition())); + } + else + { + virtualPos = last.getPosition() - position + first.getPosition() + (cycle * (last.getPosition() - first.getPosition())); + } + + return GetCurvePosition(virtualPos); + } + } + + //in curve + return GetCurvePosition(position); + } +} diff --git a/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/CurveContinuity.java b/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/CurveContinuity.java new file mode 100644 index 0000000..5fe7aa2 --- /dev/null +++ b/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/CurveContinuity.java @@ -0,0 +1,18 @@ +package Microsoft.Xna.Framework; + +/** + * Defines the continuity of CurveKeys on a Curve. + * + * @author Halofreak1990 + */ +public enum CurveContinuity +{ + /** + * Interpolation can be used between this CurveKey and the next. + */ + Smooth, + /** + * Interpolation cannot be used between this CurveKey and the next. Specifying a position between the two points returns this point. + */ + Step +} diff --git a/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/CurveKey.java b/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/CurveKey.java new file mode 100644 index 0000000..8aa685d --- /dev/null +++ b/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/CurveKey.java @@ -0,0 +1,171 @@ +package Microsoft.Xna.Framework; + +import System.*; + +/** + * Represents a point in a multi-point curve. + * + * @author Halofreak1990 + */ +public class CurveKey implements Comparable, IEquatable +{ + private final float position; + + /** + * Describes whether the segment between this point and the next point in the curve is discrete or continuous. + */ + public CurveContinuity Continuity; + + /** + * Gets the position of the CurveKey in the curve. + * + * @return + * The position of the CurveKey in the curve. + */ + public float getPosition() + { + return position; + } + + /** + * Describes the tangent when approaching this point from the previous point in the curve. + */ + public float TangentIn; + + /** + * Describes the tangent when leaving this point to the next point in the curve. + */ + public float TangentOut; + + /** + * Describes the value of this point. + */ + public float Value; + + /** + * Initializes a new instance of the CurveKey class. + * + * @param position + * The position in the curve. + * + * @param value + * The value of the control point. + */ + public CurveKey(float position, float value) + { + this(position, value, 0, 0, CurveContinuity.Smooth); + } + + /** + * Initializes a new instance of the CurveKey class. + * + * @param position + * The position in the curve. + * + * @param value + * The value of the control point. + * + * @param tangentIn + * The tangent approaching point from the previous point in the curve. + * + * @param tangentOut + * The tangent leaving point toward next point in the curve. + */ + public CurveKey(float position, float value, float tangentIn, float tangentOut) + { + this(position, value, tangentIn, tangentOut, CurveContinuity.Smooth); + } + + /** + * Initializes a new instance of the CurveKey class. + * + * @param position + * The position in the curve. + * + * @param value + * The value of the control point. + * + * @param tangentIn + * The tangent approaching point from the previous point in the curve. + * + * @param tangentOut + * The tangent leaving point toward next point in the curve. + * + * @param continuity + * Enum indicating whether the curve is discrete or continuous. + */ + public CurveKey(float position, float value, float tangentIn, float tangentOut, CurveContinuity continuity) + { + this.Continuity = continuity; + this.position = position; + this.TangentIn = tangentIn; + this.TangentOut = tangentOut; + this.Value = value; + } + + /** + * Creates a copy of the CurveKey. + */ + public CurveKey Clone() + { + return new CurveKey(this.position, this.Value, this.TangentIn, this.TangentOut, this.Continuity); + } + + /** + * Compares this instance to another CurveKey and returns an indication of their relative values. + * + * @param other + * CurveKey to compare to. + */ + @Override + public int compareTo(CurveKey other) + { + if (position > other.position) + { + return 1; + } + else if (position < other.position) + { + return -1; + } + + return 0; + } + + /** + * Returns a value that indicates whether the current instance is equal to a specified object. + * + * @param obj + * Object with which to make the comparison. + */ + @Override + public boolean equals(Object obj) + { + return (obj != null && obj instanceof CurveKey) ? this.Equals((CurveKey)obj) : false; + } + + /** + * Determines whether the specified Object is equal to the CurveKey. + * + * @param other + * The Object to compare with the current CurveKey. + */ + @Override + public boolean Equals(CurveKey other) + { + return ((this.position == other.position) && + (this.Value == other.Value) && + (this.TangentIn == other.TangentIn) && + (this.TangentOut == other.TangentOut) && + (this.Continuity == other.Continuity)); + } + + /** + * Returns the hash code for this instance. + */ + public int hashCode() + { + return (int)this.position ^ (int)this.Value ^ (int)this.TangentIn ^ + (int)this.TangentOut ^ this.Continuity.hashCode(); + } +} diff --git a/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/CurveKeyCollection.java b/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/CurveKeyCollection.java new file mode 100644 index 0000000..c8870f0 --- /dev/null +++ b/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/CurveKeyCollection.java @@ -0,0 +1,233 @@ +package Microsoft.Xna.Framework; + +import java.util.*; + +import System.*; +import System.Collections.Generic.*; + +/** + * Contains the CurveKeys making up a Curve. + * + * @author Halofreak1990 + */ +public class CurveKeyCollection implements ICollection, Iterable +{ + private boolean isReadOnly = false; + private List innerlist; + + /** + * Gets the number of elements contained in the CurveKeyCollection. + */ + @Override + public int Count() + { + return innerlist.size(); + } + + /** + * Returns a value indicating whether the CurveKeyCollection is read-only. + */ + public boolean IsReadOnly() + { + return this.isReadOnly; + } + + /** + * Gets the element at the specified index. + * + * @param index + * The array index of the element. + * + * @return + * The element at the specified index. + */ + public CurveKey get(int index) + { + return innerlist.get(index); + } + + /** + * Sets the element at the specified index. + * + * @param index + * The array index of the element. + * + * @param value + */ + public void set(int index, CurveKey value) + { + if (value == null) + { + throw new ArgumentNullException(); + } + + if (index >= innerlist.size()) + { + throw new ArgumentOutOfRangeException("index"); + } + + if (innerlist.get(index).getPosition() == value.getPosition()) + { + innerlist.set(index, value); + } + else + { + innerlist.remove(index); + innerlist.add(value); + } + } + + /** + * Initializes a new instance of the CurveKeyCollection class. + */ + public CurveKeyCollection() + { + innerlist = new ArrayList(); + } + + /** + * Adds a CurveKey to the CurveKeyCollection. + * + * @param item + * The CurveKey to add. + */ + @Override + public void Add(CurveKey item) + { + if (item == null) + { + throw new ArgumentNullException(); + } + + if (innerlist.size() == 0) + { + this.innerlist.add(item); + return; + } + + for (int i = 0; i < this.innerlist.size(); i++) + { + if (item.getPosition() < this.innerlist.get(i).getPosition()) + { + this.innerlist.add(i, item); + return; + } + } + + this.innerlist.add(item); + } + + /** + * Removes all CurveKeys from the CurveKeyCollection. + */ + @Override + public void Clear() + { + innerlist.clear(); + } + + /** + * Creates a copy of the CurveKeyCollection. + * + * @return + * A copy of the CurveKeyCollection. + */ + public CurveKeyCollection Clone() + { + CurveKeyCollection clone = new CurveKeyCollection(); + + clone.innerlist.addAll(innerlist); + + return clone; + } + + /** + * Determines whether the CurveKeyCollection contains a specific CurveKey. + * + * @param item + * + * + * @return + * true if the CurveKey is found in the CurveKeyCollection; otherwise, false. + */ + @Override + public boolean Contains(CurveKey item) + { + return innerlist.contains(item); + } + + /** + * Copies the CurveKeys of the CurveKeyCollection to an array, starting at the array index provided. + * + * @param array + * The destination of the CurveKeys copied from CurveKeyCollection. The array must have zero-based indexing. + * + * @param arrayIndex + * The zero-based index in the array to start copying from. + */ + @Override + public void CopyTo(CurveKey[] array, int arrayIndex) + { + CurveKey[] tmp = (CurveKey[])innerlist.toArray(); + + // TODO: verify + System.arraycopy(tmp, arrayIndex, array, 0, tmp.length); + } + + /** + * Determines the index of a CurveKey in the CurveKeyCollection. + * + * @param item + * The CurveKey to locate in the CurveKeyCollection. + * + * @return + * The zero-based index of the specified item, or -1 if the item could not be found. + */ + public int IndexOf(CurveKey item) + { + return innerlist.indexOf(item); + } + + /** + * Returns an Iterator that iterates through the CurveKeyCollection. + */ + @Override + public Iterator iterator() + { + return innerlist.iterator(); + } + + /** + * Removes the first occurrence of a specific CurveKey from the CurveKeyCollection. + * + * @param item + * The CurveKey to remove from the CurveKeyCollection. + * + * @return + * true if the item was successfully removed; otherwise, false. + */ + @Override + public boolean Remove(CurveKey item) + { + int index = this.IndexOf(item); + + if (index != -1) + { + this.RemoveAt(index); + return true; + } + + return false; + } + + /** + * Removes the CurveKey at the specified index. + * + * @param index + * The zero-based index of the item to remove. + */ + public void RemoveAt(int index) + { + innerlist.remove(index); + } +} diff --git a/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/CurveLoopType.java b/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/CurveLoopType.java new file mode 100644 index 0000000..7431fb0 --- /dev/null +++ b/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/CurveLoopType.java @@ -0,0 +1,30 @@ +package Microsoft.Xna.Framework; + +/** + * Defines how the value of a Curve will be determined for positions before the first point on the Curve or after the last point on the Curve. + * + * @author Halofreak1990 + */ +public enum CurveLoopType +{ + /** + * The Curve will evaluate to its first key for positions before the first point in the Curve and to the last key for positions after the last point. + */ + Constant, + /** + * Positions specified past the ends of the curve will wrap around to the opposite side of the Curve. + */ + Cycle, + /** + * Positions specified past the ends of the curve will wrap around to the opposite side of the Curve. The value will be offset by the difference between the values of the first and last CurveKey multiplied by the number of times the position wraps around. If the position is before the first point in the Curve, the difference will be subtracted from its value; otherwise, the difference will be added. + */ + CycleOffset, + /** + * Linear interpolation will be performed to determine the value. + */ + Linear, + /** + * Positions specified past the ends of the Curve act as an offset from the same side of the Curve toward the opposite side. + */ + Oscillate +} diff --git a/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/CurveTangent.java b/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/CurveTangent.java new file mode 100644 index 0000000..3c7ed4e --- /dev/null +++ b/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/CurveTangent.java @@ -0,0 +1,22 @@ +package Microsoft.Xna.Framework; + +/** + * Specifies different tangent types to be calculated for CurveKey points in a Curve. + * + * @author Halofreak1990 + */ +public enum CurveTangent +{ + /** + * A Flat tangent always has a value equal to zero. + */ + Flat, + /** + * A Linear tangent at a CurveKey is equal to the difference between its Value and the Value of the preceding or succeeding CurveKey. For example, in Curve MyCurve, where i is greater than zero and (i + 1) is less than the total number of CurveKeys in MyCurve, the linear TangentIn of MyCurve.Keys[i] is equal to: ( MyCurve.Keys[i].Value - MyCurve.Keys[i - 1].Value ) Similarly, the linear TangentOut is equal to: ( MyCurve.Keys[i + 1].Value - MyCurve.Keys[i].Value.) + */ + Linear, + /** + * A Smooth tangent smooths the inflection between a TangentIn and TangentOut by taking into account the values of both neighbors of the CurveKey. The smooth TangentIn of MyCurve.Keys[i] is equal to: ( ( MyCurve.Keys[i + 1].Value - MyCurve.Keys[i - 1].Value ) * ( ( MyCurve.Keys[i].Position - MyCurve.Keys[i - 1].Position ) / ( MyCurve.Keys[i + 1].Position - MyCurve.Keys[i-1].Position ) ) ) Similarly, the smooth TangentOut is equal to: ( ( MyCurve.Keys[i + 1].Value - MyCurve.Keys[i - 1].Value ) * ( ( MyCurve.Keys[i + 1].Position - MyCurve.Keys[i].Position ) / ( MyCurve.Keys[i + 1].Position - MyCurve.Keys[i - 1].Position ) ) ) + */ + Smooth +} diff --git a/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/FrameworkDispatcher.java b/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/FrameworkDispatcher.java new file mode 100644 index 0000000..b746457 --- /dev/null +++ b/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/FrameworkDispatcher.java @@ -0,0 +1,24 @@ +package Microsoft.Xna.Framework; + +import System.*; + +/** + * Processes XNA Framework event messages. + * + * @author Halofreak1990 + */ +public class FrameworkDispatcher +{ + private FrameworkDispatcher() + { + } + + /** + * Updates the status of various framework components (such as power state and media), and raises related events. + */ + public static void Update() + { + // TODO: auto-generated method stub + throw new NotImplementedException(); + } +} diff --git a/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/Matrix.java b/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/Matrix.java index d58f251..e8c7d11 100644 --- a/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/Matrix.java +++ b/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/Matrix.java @@ -16,68 +16,55 @@ public final class Matrix extends ValueType implements IEquatable */ public Vector3 getBackward() { - Vector3 vector = Vector3.Zero; - vector.X = this.M31; - vector.Y = this.M32; - vector.Z = this.M33; - return vector; + return new Vector3(this.M31, this.M32, this.M33); } - + /** * Sets the backward vector of the Matrix. */ public void setBackward(Vector3 value) { this.M31 = value.X; - this.M32 = value.Y; - this.M33 = value.Z; + this.M32 = value.Y; + this.M33 = value.Z; } - + /** * Gets the down vector of the Matrix. */ public Vector3 getDown() { - Vector3 vector = Vector3.Zero; - vector.X = -this.M21; - vector.Y = -this.M22; - vector.Z = -this.M23; - return vector; + return new Vector3(-this.M21, -this.M22, -this.M23); } - + /** * Sets the down vector of the Matrix. */ public void setDown(Vector3 value) { this.M21 = -value.X; - this.M22 = -value.Y; - this.M23 = -value.Z; + this.M22 = -value.Y; + this.M23 = -value.Z; } - + /** * Gets the forward vector of the Matrix. */ public Vector3 getForward() { - Vector3 vector = Vector3.Zero; - vector.X = -this.M31; - vector.Y = -this.M32; - vector.Z = -this.M33; - return vector; + return new Vector3(-this.M31, -this.M32, -this.M33); } - + /** * Sets the forward vector of the Matrix. */ public void setForward(Vector3 value) { this.M31 = -value.X; - this.M32 = -value.Y; - this.M33 = -value.Z; - + this.M32 = -value.Y; + this.M33 = -value.Z; } - + /** * Returns an instance of the identity matrix. */ @@ -85,95 +72,79 @@ public final class Matrix extends ValueType implements IEquatable { return new Matrix(1f, 0f, 0f, 0f, 0f, 1f, 0f, 0f, 0f, 0f, 1f, 0f, 0f, 0f, 0f, 1f); } - + /** * Gets the left vector of the Matrix. */ public Vector3 getLeft() { - Vector3 vector = Vector3.Zero; - vector.X = -this.M11; - vector.Y = -this.M12; - vector.Z = -this.M13; - return vector; + return new Vector3(-this.M11, -this.M12, -this.M13); } - + /** * Sets the left vector of the Matrix. */ public void setLeft(Vector3 value) { this.M11 = -value.X; - this.M12 = -value.Y; - this.M13 = -value.Z; + this.M12 = -value.Y; + this.M13 = -value.Z; } - + /** * Gets the right vector of the Matrix. */ public Vector3 getRight() { - Vector3 vector = Vector3.Zero; - vector.X = this.M11; - vector.Y = this.M12; - vector.Z = this.M13; - return vector; + return new Vector3(this.M11, this.M12, this.M13); } - + /** * Sets the right vector of the Matrix. */ public void setRight(Vector3 value) { this.M11 = value.X; - this.M12 = value.Y; - this.M13 = value.Z; + this.M12 = value.Y; + this.M13 = value.Z; } - + /** * Gets the translation vector of the Matrix. */ public Vector3 getTranslation() { - Vector3 vector = Vector3.Zero; - vector.X = this.M41; - vector.Y = this.M42; - vector.Z = this.M43; - return vector; + return new Vector3(this.M41, this.M42, this.M43); } - + /** * Sets the translation vector of the Matrix. */ public void setTranslation(Vector3 value) { this.M41 = value.X; - this.M42 = value.Y; - this.M43 = value.Z; + this.M42 = value.Y; + this.M43 = value.Z; } - + /** * Gets the up vector of this Matrix. */ public Vector3 getUp() { - Vector3 vector = Vector3.Zero; - vector.X = this.M21; - vector.Y = this.M22; - vector.Z = this.M23; - return vector; + return new Vector3(this.M21, this.M22, this.M23); } - + /** * Sets the up vector of this Matrix. */ public void setUp(Vector3 value) { this.M21 = value.X; - this.M22 = value.Y; - this.M23 = value.Z; + this.M22 = value.Y; + this.M23 = value.Z; } - + /** * Value at row 1 column 1 of the matrix. */ @@ -238,7 +209,7 @@ public final class Matrix extends ValueType implements IEquatable * Value at row 4 column 4 of the matrix. */ public float M44; - + /** * Initializes a new instance of Matrix. */ @@ -261,7 +232,7 @@ public final class Matrix extends ValueType implements IEquatable M43 = 0.0f; M44 = 0.0f; } - + /** * Initializes a new instance of Matrix. * @@ -315,24 +286,24 @@ public final class Matrix extends ValueType implements IEquatable */ public Matrix(float m11, float m12, float m13, float m14, float m21, float m22, float m23, float m24, float m31, float m32, float m33, float m34, float m41, float m42, float m43, float m44) { - this.M11 = m11; - this.M12 = m12; - this.M13 = m13; - this.M14 = m14; - this.M21 = m21; - this.M22 = m22; - this.M23 = m23; - this.M24 = m24; - this.M31 = m31; - this.M32 = m32; - this.M33 = m33; - this.M34 = m34; - this.M41 = m41; - this.M42 = m42; - this.M43 = m43; - this.M44 = m44; + this.M11 = m11; + this.M12 = m12; + this.M13 = m13; + this.M14 = m14; + this.M21 = m21; + this.M22 = m22; + this.M23 = m23; + this.M24 = m24; + this.M31 = m31; + this.M32 = m32; + this.M33 = m33; + this.M34 = m34; + this.M41 = m41; + this.M42 = m42; + this.M43 = m43; + this.M44 = m44; } - + /** * Adds the current matrix to another matrix. * @@ -343,7 +314,7 @@ public final class Matrix extends ValueType implements IEquatable { Add(this, other, this); } - + /** * Adds a matrix to another matrix. * @@ -355,11 +326,11 @@ public final class Matrix extends ValueType implements IEquatable */ public static Matrix Add(Matrix matrix1, Matrix matrix2) { - Matrix result = new Matrix(); - Add(matrix1, matrix2, result); - return result; + Matrix result = new Matrix(); + Add(matrix1, matrix2, result); + return result; } - + /** * Adds a matrix to another matrix. * @@ -374,24 +345,24 @@ public final class Matrix extends ValueType implements IEquatable */ public static void Add(Matrix matrix1, Matrix matrix2, Matrix result) { - result.M11 = matrix1.M11 + matrix2.M11; - result.M12 = matrix1.M12 + matrix2.M12; - result.M13 = matrix1.M13 + matrix2.M13; - result.M14 = matrix1.M14 + matrix2.M14; - result.M21 = matrix1.M21 + matrix2.M21; - result.M22 = matrix1.M22 + matrix2.M22; - result.M23 = matrix1.M23 + matrix2.M23; - result.M24 = matrix1.M24 + matrix2.M24; - result.M31 = matrix1.M31 + matrix2.M31; - result.M32 = matrix1.M32 + matrix2.M32; - result.M33 = matrix1.M33 + matrix2.M33; - result.M34 = matrix1.M34 + matrix2.M34; - result.M41 = matrix1.M41 + matrix2.M41; - result.M42 = matrix1.M42 + matrix2.M42; - result.M43 = matrix1.M43 + matrix2.M43; - result.M44 = matrix1.M44 + matrix2.M44; + result.M11 = matrix1.M11 + matrix2.M11; + result.M12 = matrix1.M12 + matrix2.M12; + result.M13 = matrix1.M13 + matrix2.M13; + result.M14 = matrix1.M14 + matrix2.M14; + result.M21 = matrix1.M21 + matrix2.M21; + result.M22 = matrix1.M22 + matrix2.M22; + result.M23 = matrix1.M23 + matrix2.M23; + result.M24 = matrix1.M24 + matrix2.M24; + result.M31 = matrix1.M31 + matrix2.M31; + result.M32 = matrix1.M32 + matrix2.M32; + result.M33 = matrix1.M33 + matrix2.M33; + result.M34 = matrix1.M34 + matrix2.M34; + result.M41 = matrix1.M41 + matrix2.M41; + result.M42 = matrix1.M42 + matrix2.M42; + result.M43 = matrix1.M43 + matrix2.M43; + result.M44 = matrix1.M44 + matrix2.M44; } - + /** * Creates a spherical billboard that rotates around a specified object position. * @@ -409,11 +380,11 @@ public final class Matrix extends ValueType implements IEquatable */ public static Matrix CreateBillboard(Vector3 objectPosition, Vector3 cameraPosition, Vector3 cameraUpVector, Vector3 cameraForwardVector) { - Matrix result = new Matrix(); - CreateBillboard(objectPosition, cameraPosition, cameraUpVector, cameraForwardVector, result); - return result; + Matrix result = new Matrix(); + CreateBillboard(objectPosition, cameraPosition, cameraUpVector, cameraForwardVector, result); + return result; } - + /** * Creates a spherical billboard that rotates around a specified object position. * @@ -434,42 +405,44 @@ public final class Matrix extends ValueType implements IEquatable */ public static void CreateBillboard(Vector3 objectPosition, Vector3 cameraPosition, Vector3 cameraUpVector, Vector3 cameraForwardVector, Matrix result) { - Vector3 vector = Vector3.Zero; - Vector3 vector2 = Vector3.Zero; - Vector3 vector3 = Vector3.Zero; - vector.X = objectPosition.X - cameraPosition.X; - vector.Y = objectPosition.Y - cameraPosition.Y; - vector.Z = objectPosition.Z - cameraPosition.Z; - float num = vector.LengthSquared(); - if (num < 0.0001f) - { - vector = (cameraForwardVector != null) ? Vector3.Negate(cameraForwardVector) : Vector3.Forward; - } - else - { - Vector3.Multiply(vector, (float) (1f / ((float) Math.sqrt((double) num))), vector); - } - Vector3.Cross(cameraUpVector, vector, vector3); - vector3.Normalize(); - Vector3.Cross(vector, vector3, vector2); - result.M11 = vector3.X; - result.M12 = vector3.Y; - result.M13 = vector3.Z; - result.M14 = 0f; - result.M21 = vector2.X; - result.M22 = vector2.Y; - result.M23 = vector2.Z; - result.M24 = 0f; - result.M31 = vector.X; - result.M32 = vector.Y; - result.M33 = vector.Z; - result.M34 = 0f; - result.M41 = objectPosition.X; - result.M42 = objectPosition.Y; - result.M43 = objectPosition.Z; - result.M44 = 1f; + Vector3 vector = Vector3.Zero; + Vector3 vector2 = Vector3.Zero; + Vector3 vector3 = Vector3.Zero; + vector.X = objectPosition.X - cameraPosition.X; + vector.Y = objectPosition.Y - cameraPosition.Y; + vector.Z = objectPosition.Z - cameraPosition.Z; + float num = vector.LengthSquared(); + + if (num < 0.0001f) + { + vector = (cameraForwardVector != null) ? Vector3.Negate(cameraForwardVector) : Vector3.Forward; + } + else + { + Vector3.Multiply(vector, (float) (1f / ((float) Math.sqrt((double) num))), vector); + } + + Vector3.Cross(cameraUpVector, vector, vector3); + vector3.Normalize(); + Vector3.Cross(vector, vector3, vector2); + result.M11 = vector3.X; + result.M12 = vector3.Y; + result.M13 = vector3.Z; + result.M14 = 0f; + result.M21 = vector2.X; + result.M22 = vector2.Y; + result.M23 = vector2.Z; + result.M24 = 0f; + result.M31 = vector.X; + result.M32 = vector.Y; + result.M33 = vector.Z; + result.M34 = 0f; + result.M41 = objectPosition.X; + result.M42 = objectPosition.Y; + result.M43 = objectPosition.Z; + result.M44 = 1f; } - + /** * Creates a cylindrical billboard that rotates around a specified axis. * @@ -490,11 +463,11 @@ public final class Matrix extends ValueType implements IEquatable */ public static Matrix CreateConstrainedBillboard(Vector3 objectPosition, Vector3 cameraPosition, Vector3 rotateAxis, Vector3 cameraForwardVector, Vector3 objectForwardVector) { - Matrix result = new Matrix(); - CreateConstrainedBillboard(objectPosition, cameraPosition, rotateAxis, cameraForwardVector, objectForwardVector, result); - return result; + Matrix result = new Matrix(); + CreateConstrainedBillboard(objectPosition, cameraPosition, rotateAxis, cameraForwardVector, objectForwardVector, result); + return result; } - + /** * Creates a cylindrical billboard that rotates around a specified axis. * @@ -518,71 +491,79 @@ public final class Matrix extends ValueType implements IEquatable */ public static void CreateConstrainedBillboard(Vector3 objectPosition, Vector3 cameraPosition, Vector3 rotateAxis, Vector3 cameraForwardVector, Vector3 objectForwardVector, Matrix result) { - float num = 0f; - Vector3 vector = Vector3.Zero; - Vector3 vector2 = Vector3.Zero; - Vector3 vector3 = Vector3.Zero; - vector2.X = objectPosition.X - cameraPosition.X; - vector2.Y = objectPosition.Y - cameraPosition.Y; - vector2.Z = objectPosition.Z - cameraPosition.Z; - float num2 = vector2.LengthSquared(); - if (num2 < 0.0001f) - { - vector2 = (cameraForwardVector != null) ? Vector3.Negate(cameraForwardVector) : Vector3.Forward; - } - else - { - Vector3.Multiply(vector2, (float) (1f / ((float) Math.sqrt((double) num2))), vector2); - } - Vector3 vector4 = rotateAxis; - Vector3.Dot(rotateAxis, vector2, num); - if (Math.abs(num) > 0.9982547f) - { - if (objectForwardVector != null) - { - vector = objectForwardVector; - Vector3.Dot(rotateAxis, vector, num); - if (Math.abs(num) > 0.9982547f) - { - num = ((rotateAxis.X * Vector3.Forward.X) + (rotateAxis.Y * Vector3.Forward.Y)) + (rotateAxis.Z * Vector3.Forward.Z); - vector = (Math.abs(num) > 0.9982547f) ? Vector3.Right : Vector3.Forward; - } - } - else - { - num = ((rotateAxis.X * Vector3.Forward.X) + (rotateAxis.Y * Vector3.Forward.Y)) + (rotateAxis.Z * Vector3.Forward.Z); - vector = (Math.abs(num) > 0.9982547f) ? Vector3.Right : Vector3.Forward; - } - Vector3.Cross(rotateAxis, vector, vector3); - vector3.Normalize(); - Vector3.Cross(vector3, rotateAxis, vector); - vector.Normalize(); - } - else - { - Vector3.Cross(rotateAxis, vector2, vector3); - vector3.Normalize(); - Vector3.Cross(vector3, vector4, vector); - vector.Normalize(); - } - result.M11 = vector3.X; - result.M12 = vector3.Y; - result.M13 = vector3.Z; - result.M14 = 0f; - result.M21 = vector4.X; - result.M22 = vector4.Y; - result.M23 = vector4.Z; - result.M24 = 0f; - result.M31 = vector.X; - result.M32 = vector.Y; - result.M33 = vector.Z; - result.M34 = 0f; - result.M41 = objectPosition.X; - result.M42 = objectPosition.Y; - result.M43 = objectPosition.Z; - result.M44 = 1f; + float num = 0f; + Vector3 vector = Vector3.Zero; + Vector3 vector2 = Vector3.Zero; + Vector3 vector3 = Vector3.Zero; + vector2.X = objectPosition.X - cameraPosition.X; + vector2.Y = objectPosition.Y - cameraPosition.Y; + vector2.Z = objectPosition.Z - cameraPosition.Z; + float num2 = vector2.LengthSquared(); + + if (num2 < 0.0001f) + { + vector2 = (cameraForwardVector != null) ? Vector3.Negate(cameraForwardVector) : Vector3.Forward; + } + else + { + Vector3.Multiply(vector2, (float) (1f / ((float) Math.sqrt((double) num2))), vector2); + } + + Vector3 vector4 = rotateAxis; + + num = Vector3.Dot(rotateAxis, vector2); + + if (Math.abs(num) > 0.9982547f) + { + if (objectForwardVector != null) + { + vector = objectForwardVector; + + num = Vector3.Dot(rotateAxis, vector); + + if (Math.abs(num) > 0.9982547f) + { + num = ((rotateAxis.X * Vector3.Forward.X) + (rotateAxis.Y * Vector3.Forward.Y)) + (rotateAxis.Z * Vector3.Forward.Z); + vector = (Math.abs(num) > 0.9982547f) ? Vector3.Right : Vector3.Forward; + } + } + else + { + num = ((rotateAxis.X * Vector3.Forward.X) + (rotateAxis.Y * Vector3.Forward.Y)) + (rotateAxis.Z * Vector3.Forward.Z); + vector = (Math.abs(num) > 0.9982547f) ? Vector3.Right : Vector3.Forward; + } + + Vector3.Cross(rotateAxis, vector, vector3); + vector3.Normalize(); + Vector3.Cross(vector3, rotateAxis, vector); + vector.Normalize(); + } + else + { + Vector3.Cross(rotateAxis, vector2, vector3); + vector3.Normalize(); + Vector3.Cross(vector3, vector4, vector); + vector.Normalize(); + } + + result.M11 = vector3.X; + result.M12 = vector3.Y; + result.M13 = vector3.Z; + result.M14 = 0f; + result.M21 = vector4.X; + result.M22 = vector4.Y; + result.M23 = vector4.Z; + result.M24 = 0f; + result.M31 = vector.X; + result.M32 = vector.Y; + result.M33 = vector.Z; + result.M34 = 0f; + result.M41 = objectPosition.X; + result.M42 = objectPosition.Y; + result.M43 = objectPosition.Z; + result.M44 = 1f; } - + /** * Creates a new Matrix that rotates around an arbitrary vector. * @@ -594,11 +575,11 @@ public final class Matrix extends ValueType implements IEquatable */ public static Matrix CreateFromAxisAngle(Vector3 axis, float angle) { - Matrix result = new Matrix(); - CreateFromAxisAngle(axis, angle, result); - return result; + Matrix result = new Matrix(); + CreateFromAxisAngle(axis, angle, result); + return result; } - + /** * Creates a new Matrix that rotates around an arbitrary vector. * @@ -613,35 +594,35 @@ public final class Matrix extends ValueType implements IEquatable */ public static void CreateFromAxisAngle(Vector3 axis, float angle, Matrix result) { - float x = axis.X; - float y = axis.Y; - float z = axis.Z; - float num2 = (float) Math.sin((double) angle); - float num = (float) Math.cos((double) angle); - float num11 = x * x; - float num10 = y * y; - float num9 = z * z; - float num8 = x * y; - float num7 = x * z; - float num6 = y * z; - result.M11 = num11 + (num * (1f - num11)); - result.M12 = (num8 - (num * num8)) + (num2 * z); - result.M13 = (num7 - (num * num7)) - (num2 * y); - result.M14 = 0f; - result.M21 = (num8 - (num * num8)) - (num2 * z); - result.M22 = num10 + (num * (1f - num10)); - result.M23 = (num6 - (num * num6)) + (num2 * x); - result.M24 = 0f; - result.M31 = (num7 - (num * num7)) + (num2 * y); - result.M32 = (num6 - (num * num6)) - (num2 * x); - result.M33 = num9 + (num * (1f - num9)); - result.M34 = 0f; - result.M41 = 0f; - result.M42 = 0f; - result.M43 = 0f; - result.M44 = 1f; + float x = axis.X; + float y = axis.Y; + float z = axis.Z; + float num2 = (float) Math.sin((double) angle); + float num = (float) Math.cos((double) angle); + float num11 = x * x; + float num10 = y * y; + float num9 = z * z; + float num8 = x * y; + float num7 = x * z; + float num6 = y * z; + result.M11 = num11 + (num * (1f - num11)); + result.M12 = (num8 - (num * num8)) + (num2 * z); + result.M13 = (num7 - (num * num7)) - (num2 * y); + result.M14 = 0f; + result.M21 = (num8 - (num * num8)) - (num2 * z); + result.M22 = num10 + (num * (1f - num10)); + result.M23 = (num6 - (num * num6)) + (num2 * x); + result.M24 = 0f; + result.M31 = (num7 - (num * num7)) + (num2 * y); + result.M32 = (num6 - (num * num6)) - (num2 * x); + result.M33 = num9 + (num * (1f - num9)); + result.M34 = 0f; + result.M41 = 0f; + result.M42 = 0f; + result.M43 = 0f; + result.M44 = 1f; } - + /** * Creates a rotation Matrix from a Quaternion. * @@ -650,11 +631,11 @@ public final class Matrix extends ValueType implements IEquatable */ public static Matrix CreateFromQuaternion(Quaternion quaternion) { - Matrix result = new Matrix(); - CreateFromQuaternion(quaternion, result); - return result; + Matrix result = new Matrix(); + CreateFromQuaternion(quaternion, result); + return result; } - + /** * Creates a rotation Matrix from a Quaternion. * @@ -666,33 +647,33 @@ public final class Matrix extends ValueType implements IEquatable */ public static void CreateFromQuaternion(Quaternion quaternion, Matrix result) { - float num9 = quaternion.X * quaternion.X; - float num8 = quaternion.Y * quaternion.Y; - float num7 = quaternion.Z * quaternion.Z; - float num6 = quaternion.X * quaternion.Y; - float num5 = quaternion.Z * quaternion.W; - float num4 = quaternion.Z * quaternion.X; - float num3 = quaternion.Y * quaternion.W; - float num2 = quaternion.Y * quaternion.Z; - float num = quaternion.X * quaternion.W; - result.M11 = 1f - (2f * (num8 + num7)); - result.M12 = 2f * (num6 + num5); - result.M13 = 2f * (num4 - num3); - result.M14 = 0f; - result.M21 = 2f * (num6 - num5); - result.M22 = 1f - (2f * (num7 + num9)); - result.M23 = 2f * (num2 + num); - result.M24 = 0f; - result.M31 = 2f * (num4 + num3); - result.M32 = 2f * (num2 - num); - result.M33 = 1f - (2f * (num8 + num9)); - result.M34 = 0f; - result.M41 = 0f; - result.M42 = 0f; - result.M43 = 0f; - result.M44 = 1f; + float num9 = quaternion.X * quaternion.X; + float num8 = quaternion.Y * quaternion.Y; + float num7 = quaternion.Z * quaternion.Z; + float num6 = quaternion.X * quaternion.Y; + float num5 = quaternion.Z * quaternion.W; + float num4 = quaternion.Z * quaternion.X; + float num3 = quaternion.Y * quaternion.W; + float num2 = quaternion.Y * quaternion.Z; + float num = quaternion.X * quaternion.W; + result.M11 = 1f - (2f * (num8 + num7)); + result.M12 = 2f * (num6 + num5); + result.M13 = 2f * (num4 - num3); + result.M14 = 0f; + result.M21 = 2f * (num6 - num5); + result.M22 = 1f - (2f * (num7 + num9)); + result.M23 = 2f * (num2 + num); + result.M24 = 0f; + result.M31 = 2f * (num4 + num3); + result.M32 = 2f * (num2 - num); + result.M33 = 1f - (2f * (num8 + num9)); + result.M34 = 0f; + result.M41 = 0f; + result.M42 = 0f; + result.M43 = 0f; + result.M44 = 1f; } - + /** * Creates a new rotation matrix from a specified yaw, pitch, and roll. * @@ -707,13 +688,13 @@ public final class Matrix extends ValueType implements IEquatable */ public static Matrix CreateFromYawPitchRoll(float yaw, float pitch, float roll) { - Matrix matrix = new Matrix(); - Quaternion quaternion = new Quaternion(); - Quaternion.CreateFromYawPitchRoll(yaw, pitch, roll, quaternion); - CreateFromQuaternion(quaternion, matrix); - return matrix; + Matrix matrix = new Matrix(); + Quaternion quaternion = new Quaternion(); + Quaternion.CreateFromYawPitchRoll(yaw, pitch, roll, quaternion); + CreateFromQuaternion(quaternion, matrix); + return matrix; } - + /** * Creates a new rotation matrix from a specified yaw, pitch, and roll. * @@ -731,11 +712,11 @@ public final class Matrix extends ValueType implements IEquatable */ public static void CreateFromYawPitchRoll(float yaw, float pitch, float roll, Matrix result) { - Quaternion quaternion = new Quaternion(); - Quaternion.CreateFromYawPitchRoll(yaw, pitch, roll, quaternion); - CreateFromQuaternion(quaternion, result); + Quaternion quaternion = new Quaternion(); + Quaternion.CreateFromYawPitchRoll(yaw, pitch, roll, quaternion); + CreateFromQuaternion(quaternion, result); } - + /** * Creates a view matrix. * @@ -750,11 +731,11 @@ public final class Matrix extends ValueType implements IEquatable */ public static Matrix CreateLookAt(Vector3 cameraPosition, Vector3 cameraTarget, Vector3 cameraUpVector) { - Matrix result = new Matrix(); - CreateLookAt(cameraPosition, cameraTarget, cameraUpVector, result); - return result; + Matrix result = new Matrix(); + CreateLookAt(cameraPosition, cameraTarget, cameraUpVector, result); + return result; } - + /** * Creates a view matrix. * @@ -772,27 +753,27 @@ public final class Matrix extends ValueType implements IEquatable */ public static void CreateLookAt(Vector3 cameraPosition, Vector3 cameraTarget, Vector3 cameraUpVector, Matrix result) { - Vector3 vector = Vector3.Normalize(Vector3.Subtract(cameraPosition, cameraTarget)); - Vector3 vector2 = Vector3.Normalize(Vector3.Cross(cameraUpVector, vector)); - Vector3 vector3 = Vector3.Cross(vector, vector2); - result.M11 = vector2.X; - result.M12 = vector3.X; - result.M13 = vector.X; - result.M14 = 0f; - result.M21 = vector2.Y; - result.M22 = vector3.Y; - result.M23 = vector.Y; - result.M24 = 0f; - result.M31 = vector2.Z; - result.M32 = vector3.Z; - result.M33 = vector.Z; - result.M34 = 0f; - result.M41 = -Vector3.Dot(vector2, cameraPosition); - result.M42 = -Vector3.Dot(vector3, cameraPosition); - result.M43 = -Vector3.Dot(vector, cameraPosition); - result.M44 = 1f; + Vector3 vector = Vector3.Normalize(Vector3.Subtract(cameraPosition, cameraTarget)); + Vector3 vector2 = Vector3.Normalize(Vector3.Cross(cameraUpVector, vector)); + Vector3 vector3 = Vector3.Cross(vector, vector2); + result.M11 = vector2.X; + result.M12 = vector3.X; + result.M13 = vector.X; + result.M14 = 0f; + result.M21 = vector2.Y; + result.M22 = vector3.Y; + result.M23 = vector.Y; + result.M24 = 0f; + result.M31 = vector2.Z; + result.M32 = vector3.Z; + result.M33 = vector.Z; + result.M34 = 0f; + result.M41 = -Vector3.Dot(vector2, cameraPosition); + result.M42 = -Vector3.Dot(vector3, cameraPosition); + result.M43 = -Vector3.Dot(vector, cameraPosition); + result.M44 = 1f; } - + /** * Builds an orthogonal projection matrix. * @@ -810,11 +791,11 @@ public final class Matrix extends ValueType implements IEquatable */ public static Matrix CreateOrthographic(float width, float height, float zNearPlane, float zFarPlane) { - Matrix result = new Matrix(); - CreateOrthographic(width, height, zNearPlane, zFarPlane, result); - return result; + Matrix result = new Matrix(); + CreateOrthographic(width, height, zNearPlane, zFarPlane, result); + return result; } - + /** * Builds an orthogonal projection matrix. * @@ -835,17 +816,17 @@ public final class Matrix extends ValueType implements IEquatable */ public static void CreateOrthographic(float width, float height, float zNearPlane, float zFarPlane, Matrix result) { - result.M11 = 2f / width; - result.M12 = result.M13 = result.M14 = 0f; - result.M22 = 2f / height; - result.M21 = result.M23 = result.M24 = 0f; - result.M33 = 1f / (zNearPlane - zFarPlane); - result.M31 = result.M32 = result.M34 = 0f; - result.M41 = result.M42 = 0f; - result.M43 = zNearPlane / (zNearPlane - zFarPlane); - result.M44 = 1f; + result.M11 = 2f / width; + result.M12 = result.M13 = result.M14 = 0f; + result.M22 = 2f / height; + result.M21 = result.M23 = result.M24 = 0f; + result.M33 = 1f / (zNearPlane - zFarPlane); + result.M31 = result.M32 = result.M34 = 0f; + result.M41 = result.M42 = 0f; + result.M43 = zNearPlane / (zNearPlane - zFarPlane); + result.M44 = 1f; } - + /** * Builds a customized, orthogonal projection matrix. * @@ -869,11 +850,11 @@ public final class Matrix extends ValueType implements IEquatable */ public static Matrix CreateOrthographicOffCenter(float left, float right, float bottom, float top, float zNearPlane, float zFarPlane) { - Matrix result = new Matrix(); - CreateOrthographicOffCenter(left, right, bottom, top, zNearPlane, zFarPlane, result); - return result; + Matrix result = new Matrix(); + CreateOrthographicOffCenter(left, right, bottom, top, zNearPlane, zFarPlane, result); + return result; } - + /** * Builds a customized, orthogonal projection matrix. * @@ -900,18 +881,18 @@ public final class Matrix extends ValueType implements IEquatable */ public static void CreateOrthographicOffCenter(float left, float right, float bottom, float top, float zNearPlane, float zFarPlane, Matrix result) { - result.M11 = 2f / (right - left); - result.M12 = result.M13 = result.M14 = 0f; - result.M22 = 2f / (top - bottom); - result.M21 = result.M23 = result.M24 = 0f; - result.M33 = 1f / (zNearPlane - zFarPlane); - result.M31 = result.M32 = result.M34 = 0f; - result.M41 = (left + right) / (left - right); - result.M42 = (top + bottom) / (bottom - top); - result.M43 = zNearPlane / (zNearPlane - zFarPlane); - result.M44 = 1f; + result.M11 = 2f / (right - left); + result.M12 = result.M13 = result.M14 = 0f; + result.M22 = 2f / (top - bottom); + result.M21 = result.M23 = result.M24 = 0f; + result.M33 = 1f / (zNearPlane - zFarPlane); + result.M31 = result.M32 = result.M34 = 0f; + result.M41 = (left + right) / (left - right); + result.M42 = (top + bottom) / (bottom - top); + result.M43 = zNearPlane / (zNearPlane - zFarPlane); + result.M44 = 1f; } - + /** * Builds a perspective projection matrix and returns the result by value. * @@ -929,11 +910,11 @@ public final class Matrix extends ValueType implements IEquatable */ public static Matrix CreatePerspective(float width, float height, float nearPlaneDistance, float farPlaneDistance) { - Matrix result = new Matrix(); - CreatePerspective(width, height, nearPlaneDistance, farPlaneDistance, result); - return result; + Matrix result = new Matrix(); + CreatePerspective(width, height, nearPlaneDistance, farPlaneDistance, result); + return result; } - + /** * Builds a perspective projection matrix and returns the result by reference. * @@ -954,29 +935,32 @@ public final class Matrix extends ValueType implements IEquatable */ public static void CreatePerspective(float width, float height, float nearPlaneDistance, float farPlaneDistance, Matrix result) { - if (nearPlaneDistance <= 0f) - { - throw new ArgumentException(String.format(Locale.getDefault(), "You should specify positive value for %s", "nearPlaneDistance")); - } - if (farPlaneDistance <= 0f) - { - throw new ArgumentException(String.format(Locale.getDefault(), "You should specify positive value for %s", "farPlaneDistance")); - } - if (nearPlaneDistance >= farPlaneDistance) - { - throw new ArgumentException("Near plane distance is larger than Far plane distance. Near plane distance must be smaller than Far plane distance."); - } - result.M11 = (2f * nearPlaneDistance) / width; - result.M12 = result.M13 = result.M14 = 0f; - result.M22 = (2f * nearPlaneDistance) / height; - result.M21 = result.M23 = result.M24 = 0f; - result.M33 = farPlaneDistance / (nearPlaneDistance - farPlaneDistance); - result.M31 = result.M32 = 0f; - result.M34 = -1f; - result.M41 = result.M42 = result.M44 = 0f; - result.M43 = (nearPlaneDistance * farPlaneDistance) / (nearPlaneDistance - farPlaneDistance); + if (nearPlaneDistance <= 0f) + { + throw new ArgumentException(String.format(Locale.getDefault(), "You should specify positive value for %s", "nearPlaneDistance")); + } + + if (farPlaneDistance <= 0f) + { + throw new ArgumentException(String.format(Locale.getDefault(), "You should specify positive value for %s", "farPlaneDistance")); + } + + if (nearPlaneDistance >= farPlaneDistance) + { + throw new ArgumentException("Near plane distance is larger than Far plane distance. Near plane distance must be smaller than Far plane distance."); + } + + result.M11 = (2f * nearPlaneDistance) / width; + result.M12 = result.M13 = result.M14 = 0f; + result.M22 = (2f * nearPlaneDistance) / height; + result.M21 = result.M23 = result.M24 = 0f; + result.M33 = farPlaneDistance / (nearPlaneDistance - farPlaneDistance); + result.M31 = result.M32 = 0f; + result.M34 = -1f; + result.M41 = result.M42 = result.M44 = 0f; + result.M43 = (nearPlaneDistance * farPlaneDistance) / (nearPlaneDistance - farPlaneDistance); } - + /** * Builds a perspective projection matrix based on a field of view and returns by value. * @@ -994,11 +978,11 @@ public final class Matrix extends ValueType implements IEquatable */ public static Matrix CreatePerspectiveFieldOfView(float fieldOfView, float aspectRatio, float nearPlaneDistance, float farPlaneDistance) { - Matrix result = new Matrix(); - CreatePerspectiveFieldOfView(fieldOfView, aspectRatio, nearPlaneDistance, farPlaneDistance, result); - return result; + Matrix result = new Matrix(); + CreatePerspectiveFieldOfView(fieldOfView, aspectRatio, nearPlaneDistance, farPlaneDistance, result); + return result; } - + /** * Builds a perspective projection matrix based on a field of view and returns by reference. * @@ -1020,34 +1004,38 @@ public final class Matrix extends ValueType implements IEquatable public static void CreatePerspectiveFieldOfView(float fieldOfView, float aspectRatio, float nearPlaneDistance, float farPlaneDistance, Matrix result) { if ((fieldOfView <= 0f) || (fieldOfView >= 3.141593f)) - { - throw new ArgumentException(String.format(Locale.getDefault(), "%s takes a value between 0 and Pi (180 degrees) in radians.", "fieldOfView")); - } - if (nearPlaneDistance <= 0f) - { - throw new ArgumentException(String.format(Locale.getDefault(), "You should specify positive value for %s", "nearPlaneDistance")); - } - if (farPlaneDistance <= 0f) - { - throw new ArgumentException(String.format(Locale.getDefault(), "You should specify positive value for %s", "farPlaneDistance")); - } - if (nearPlaneDistance >= farPlaneDistance) - { - throw new ArgumentException("Near plane distance is larger than Far plane distance. Near plane distance must be smaller than Far plane distance."); - } - float num = 1f / ((float) Math.tan((double) (fieldOfView * 0.5f))); - float num9 = num / aspectRatio; - result.M11 = num9; - result.M12 = result.M13 = result.M14 = 0f; - result.M22 = num; - result.M21 = result.M23 = result.M24 = 0f; - result.M31 = result.M32 = 0f; - result.M33 = farPlaneDistance / (nearPlaneDistance - farPlaneDistance); - result.M34 = -1f; - result.M41 = result.M42 = result.M44 = 0f; - result.M43 = (nearPlaneDistance * farPlaneDistance) / (nearPlaneDistance - farPlaneDistance); + { + throw new ArgumentException(String.format(Locale.getDefault(), "%s takes a value between 0 and Pi (180 degrees) in radians.", "fieldOfView")); + } + + if (nearPlaneDistance <= 0f) + { + throw new ArgumentException(String.format(Locale.getDefault(), "You should specify positive value for %s", "nearPlaneDistance")); + } + + if (farPlaneDistance <= 0f) + { + throw new ArgumentException(String.format(Locale.getDefault(), "You should specify positive value for %s", "farPlaneDistance")); + } + + if (nearPlaneDistance >= farPlaneDistance) + { + throw new ArgumentException("Near plane distance is larger than Far plane distance. Near plane distance must be smaller than Far plane distance."); + } + + float num = 1f / ((float) Math.tan((double) (fieldOfView * 0.5f))); + float num9 = num / aspectRatio; + result.M11 = num9; + result.M12 = result.M13 = result.M14 = 0f; + result.M22 = num; + result.M21 = result.M23 = result.M24 = 0f; + result.M31 = result.M32 = 0f; + result.M33 = farPlaneDistance / (nearPlaneDistance - farPlaneDistance); + result.M34 = -1f; + result.M41 = result.M42 = result.M44 = 0f; + result.M43 = (nearPlaneDistance * farPlaneDistance) / (nearPlaneDistance - farPlaneDistance); } - + /** * Builds a customized, perspective projection matrix. * @@ -1071,11 +1059,11 @@ public final class Matrix extends ValueType implements IEquatable */ public static Matrix CreatePerspectiveOffCenter(float left, float right, float bottom, float top, float nearPlaneDistance, float farPlaneDistance) { - Matrix result = new Matrix(); - CreatePerspectiveOffCenter(left, right, bottom, top, nearPlaneDistance, farPlaneDistance, result); - return result; + Matrix result = new Matrix(); + CreatePerspectiveOffCenter(left, right, bottom, top, nearPlaneDistance, farPlaneDistance, result); + return result; } - + /** * Builds a customized, perspective projection matrix. * @@ -1103,29 +1091,32 @@ public final class Matrix extends ValueType implements IEquatable public static void CreatePerspectiveOffCenter(float left, float right, float bottom, float top, float nearPlaneDistance, float farPlaneDistance, Matrix result) { if (nearPlaneDistance <= 0f) - { - throw new ArgumentException(String.format(Locale.getDefault(), "You should specify positive value for %s", "nearPlaneDistance")); - } - if (farPlaneDistance <= 0f) - { - throw new ArgumentException(String.format(Locale.getDefault(), "You should specify positive value for %s", "farPlaneDistance")); - } - if (nearPlaneDistance >= farPlaneDistance) - { - throw new ArgumentException("Near plane distance is larger than Far plane distance. Near plane distance must be smaller than Far plane distance."); - } - result.M11 = (2f * nearPlaneDistance) / (right - left); - result.M12 = result.M13 = result.M14 = 0f; - result.M22 = (2f * nearPlaneDistance) / (top - bottom); - result.M21 = result.M23 = result.M24 = 0f; - result.M31 = (left + right) / (right - left); - result.M32 = (top + bottom) / (top - bottom); - result.M33 = farPlaneDistance / (nearPlaneDistance - farPlaneDistance); - result.M34 = -1f; - result.M43 = (nearPlaneDistance * farPlaneDistance) / (nearPlaneDistance - farPlaneDistance); - result.M41 = result.M42 = result.M44 = 0f; + { + throw new ArgumentException(String.format(Locale.getDefault(), "You should specify positive value for %s", "nearPlaneDistance")); + } + + if (farPlaneDistance <= 0f) + { + throw new ArgumentException(String.format(Locale.getDefault(), "You should specify positive value for %s", "farPlaneDistance")); + } + + if (nearPlaneDistance >= farPlaneDistance) + { + throw new ArgumentException("Near plane distance is larger than Far plane distance. Near plane distance must be smaller than Far plane distance."); + } + + result.M11 = (2f * nearPlaneDistance) / (right - left); + result.M12 = result.M13 = result.M14 = 0f; + result.M22 = (2f * nearPlaneDistance) / (top - bottom); + result.M21 = result.M23 = result.M24 = 0f; + result.M31 = (left + right) / (right - left); + result.M32 = (top + bottom) / (top - bottom); + result.M33 = farPlaneDistance / (nearPlaneDistance - farPlaneDistance); + result.M34 = -1f; + result.M43 = (nearPlaneDistance * farPlaneDistance) / (nearPlaneDistance - farPlaneDistance); + result.M41 = result.M42 = result.M44 = 0f; } - + /** * Creates a Matrix that reflects the coordinate system about a specified Plane. * @@ -1134,11 +1125,11 @@ public final class Matrix extends ValueType implements IEquatable */ public static Matrix CreateReflection(Plane value) { - Matrix result = new Matrix(); - CreateReflection(value, result); - return result; + Matrix result = new Matrix(); + CreateReflection(value, result); + return result; } - + /** * Creates a Matrix that reflects the coordinate system about a specified Plane. * @@ -1150,32 +1141,32 @@ public final class Matrix extends ValueType implements IEquatable */ public static void CreateReflection(Plane value, Matrix result) { - Plane plane = new Plane(); - Plane.Normalize(value, plane); - float x = plane.Normal.X; - float y = plane.Normal.Y; - float z = plane.Normal.Z; - float num3 = -2f * x; - float num2 = -2f * y; - float num = -2f * z; - result.M11 = (num3 * x) + 1f; - result.M12 = num2 * x; - result.M13 = num * x; - result.M14 = 0f; - result.M21 = num3 * y; - result.M22 = (num2 * y) + 1f; - result.M23 = num * y; - result.M24 = 0f; - result.M31 = num3 * z; - result.M32 = num2 * z; - result.M33 = (num * z) + 1f; - result.M34 = 0f; - result.M41 = num3 * plane.D; - result.M42 = num2 * plane.D; - result.M43 = num * plane.D; - result.M44 = 1f; + Plane plane = new Plane(); + Plane.Normalize(value, plane); + float x = plane.Normal.X; + float y = plane.Normal.Y; + float z = plane.Normal.Z; + float num3 = -2f * x; + float num2 = -2f * y; + float num = -2f * z; + result.M11 = (num3 * x) + 1f; + result.M12 = num2 * x; + result.M13 = num * x; + result.M14 = 0f; + result.M21 = num3 * y; + result.M22 = (num2 * y) + 1f; + result.M23 = num * y; + result.M24 = 0f; + result.M31 = num3 * z; + result.M32 = num2 * z; + result.M33 = (num * z) + 1f; + result.M34 = 0f; + result.M41 = num3 * plane.D; + result.M42 = num2 * plane.D; + result.M43 = num * plane.D; + result.M44 = 1f; } - + /** * Returns a matrix that can be used to rotate a set of vertices around the x-axis. * @@ -1184,11 +1175,11 @@ public final class Matrix extends ValueType implements IEquatable */ public static Matrix CreateRotationX(float radians) { - Matrix result = new Matrix(); - CreateRotationX(radians, result); - return result; + Matrix result = new Matrix(); + CreateRotationX(radians, result); + return result; } - + /** * Populates data into a user-specified matrix that can be used to rotate a set of vertices around the x-axis. * @@ -1200,26 +1191,26 @@ public final class Matrix extends ValueType implements IEquatable */ public static void CreateRotationX(float radians, Matrix result) { - float num2 = (float) Math.cos((double) radians); - float num = (float) Math.sin((double) radians); - result.M11 = 1f; - result.M12 = 0f; - result.M13 = 0f; - result.M14 = 0f; - result.M21 = 0f; - result.M22 = num2; - result.M23 = num; - result.M24 = 0f; - result.M31 = 0f; - result.M32 = -num; - result.M33 = num2; - result.M34 = 0f; - result.M41 = 0f; - result.M42 = 0f; - result.M43 = 0f; - result.M44 = 1f; + float num2 = (float) Math.cos((double) radians); + float num = (float) Math.sin((double) radians); + result.M11 = 1f; + result.M12 = 0f; + result.M13 = 0f; + result.M14 = 0f; + result.M21 = 0f; + result.M22 = num2; + result.M23 = num; + result.M24 = 0f; + result.M31 = 0f; + result.M32 = -num; + result.M33 = num2; + result.M34 = 0f; + result.M41 = 0f; + result.M42 = 0f; + result.M43 = 0f; + result.M44 = 1f; } - + /** * Returns a matrix that can be used to rotate a set of vertices around the y-axis. * @@ -1228,11 +1219,11 @@ public final class Matrix extends ValueType implements IEquatable */ public static Matrix CreateRotationY(float radians) { - Matrix result = new Matrix(); - CreateRotationY(radians, result); - return result; + Matrix result = new Matrix(); + CreateRotationY(radians, result); + return result; } - + /** * Populates data into a user-specified matrix that can be used to rotate a set of vertices around the y-axis. * @@ -1244,26 +1235,26 @@ public final class Matrix extends ValueType implements IEquatable */ public static void CreateRotationY(float radians, Matrix result) { - float num2 = (float) Math.cos((double) radians); - float num = (float) Math.sin((double) radians); - result.M11 = num2; - result.M12 = 0f; - result.M13 = -num; - result.M14 = 0f; - result.M21 = 0f; - result.M22 = 1f; - result.M23 = 0f; - result.M24 = 0f; - result.M31 = num; - result.M32 = 0f; - result.M33 = num2; - result.M34 = 0f; - result.M41 = 0f; - result.M42 = 0f; - result.M43 = 0f; - result.M44 = 1f; + float num2 = (float) Math.cos((double) radians); + float num = (float) Math.sin((double) radians); + result.M11 = num2; + result.M12 = 0f; + result.M13 = -num; + result.M14 = 0f; + result.M21 = 0f; + result.M22 = 1f; + result.M23 = 0f; + result.M24 = 0f; + result.M31 = num; + result.M32 = 0f; + result.M33 = num2; + result.M34 = 0f; + result.M41 = 0f; + result.M42 = 0f; + result.M43 = 0f; + result.M44 = 1f; } - + /** * Returns a matrix that can be used to rotate a set of vertices around the z-axis. * @@ -1272,11 +1263,11 @@ public final class Matrix extends ValueType implements IEquatable */ public static Matrix CreateRotationZ(float radians) { - Matrix result = new Matrix(); - CreateRotationZ(radians, result); - return result; + Matrix result = new Matrix(); + CreateRotationZ(radians, result); + return result; } - + /** * Populates data into a user-specified matrix that can be used to rotate a set of vertices around the z-axis. * @@ -1288,26 +1279,26 @@ public final class Matrix extends ValueType implements IEquatable */ public static void CreateRotationZ(float radians, Matrix result) { - float num2 = (float) Math.cos((double) radians); - float num = (float) Math.sin((double) radians); - result.M11 = num2; - result.M12 = num; - result.M13 = 0f; - result.M14 = 0f; - result.M21 = -num; - result.M22 = num2; - result.M23 = 0f; - result.M24 = 0f; - result.M31 = 0f; - result.M32 = 0f; - result.M33 = 1f; - result.M34 = 0f; - result.M41 = 0f; - result.M42 = 0f; - result.M43 = 0f; - result.M44 = 1f; + float num2 = (float) Math.cos((double) radians); + float num = (float) Math.sin((double) radians); + result.M11 = num2; + result.M12 = num; + result.M13 = 0f; + result.M14 = 0f; + result.M21 = -num; + result.M22 = num2; + result.M23 = 0f; + result.M24 = 0f; + result.M31 = 0f; + result.M32 = 0f; + result.M33 = 1f; + result.M34 = 0f; + result.M41 = 0f; + result.M42 = 0f; + result.M43 = 0f; + result.M44 = 1f; } - + /** * Creates a scaling Matrix. * @@ -1316,11 +1307,11 @@ public final class Matrix extends ValueType implements IEquatable */ public static Matrix CreateScale(Vector3 scales) { - Matrix result = new Matrix(); - CreateScale(scales, result); - return result; + Matrix result = new Matrix(); + CreateScale(scales, result); + return result; } - + /** * Creates a scaling Matrix. * @@ -1329,11 +1320,11 @@ public final class Matrix extends ValueType implements IEquatable */ public static Matrix CreateScale(float scale) { - Matrix result = new Matrix(); - CreateScale(scale, result); - return result; + Matrix result = new Matrix(); + CreateScale(scale, result); + return result; } - + /** * Creates a scaling Matrix. * @@ -1345,27 +1336,27 @@ public final class Matrix extends ValueType implements IEquatable */ public static void CreateScale(Vector3 scales, Matrix result) { - float x = scales.X; - float y = scales.Y; - float z = scales.Z; - result.M11 = x; - result.M12 = 0f; - result.M13 = 0f; - result.M14 = 0f; - result.M21 = 0f; - result.M22 = y; - result.M23 = 0f; - result.M24 = 0f; - result.M31 = 0f; - result.M32 = 0f; - result.M33 = z; - result.M34 = 0f; - result.M41 = 0f; - result.M42 = 0f; - result.M43 = 0f; - result.M44 = 1f; + float x = scales.X; + float y = scales.Y; + float z = scales.Z; + result.M11 = x; + result.M12 = 0f; + result.M13 = 0f; + result.M14 = 0f; + result.M21 = 0f; + result.M22 = y; + result.M23 = 0f; + result.M24 = 0f; + result.M31 = 0f; + result.M32 = 0f; + result.M33 = z; + result.M34 = 0f; + result.M41 = 0f; + result.M42 = 0f; + result.M43 = 0f; + result.M44 = 1f; } - + /** * Creates a scaling Matrix. * @@ -1377,25 +1368,25 @@ public final class Matrix extends ValueType implements IEquatable */ public static void CreateScale(float scale, Matrix result) { - float num = scale; - result.M11 = num; - result.M12 = 0f; - result.M13 = 0f; - result.M14 = 0f; - result.M21 = 0f; - result.M22 = num; - result.M23 = 0f; - result.M24 = 0f; - result.M31 = 0f; - result.M32 = 0f; - result.M33 = num; - result.M34 = 0f; - result.M41 = 0f; - result.M42 = 0f; - result.M43 = 0f; - result.M44 = 1f; + float num = scale; + result.M11 = num; + result.M12 = 0f; + result.M13 = 0f; + result.M14 = 0f; + result.M21 = 0f; + result.M22 = num; + result.M23 = 0f; + result.M24 = 0f; + result.M31 = 0f; + result.M32 = 0f; + result.M33 = num; + result.M34 = 0f; + result.M41 = 0f; + result.M42 = 0f; + result.M43 = 0f; + result.M44 = 1f; } - + /** * Creates a scaling Matrix. * @@ -1410,11 +1401,11 @@ public final class Matrix extends ValueType implements IEquatable */ public static Matrix CreateScale(float xScale, float yScale, float zScale) { - Matrix result = new Matrix(); - CreateScale(xScale, yScale, zScale, result); - return result; + Matrix result = new Matrix(); + CreateScale(xScale, yScale, zScale, result); + return result; } - + /** * Creates a scaling Matrix. * @@ -1432,27 +1423,27 @@ public final class Matrix extends ValueType implements IEquatable */ public static void CreateScale(float xScale, float yScale, float zScale, Matrix result) { - float num3 = xScale; - float num2 = yScale; - float num = zScale; - result.M11 = num3; - result.M12 = 0f; - result.M13 = 0f; - result.M14 = 0f; - result.M21 = 0f; - result.M22 = num2; - result.M23 = 0f; - result.M24 = 0f; - result.M31 = 0f; - result.M32 = 0f; - result.M33 = num; - result.M34 = 0f; - result.M41 = 0f; - result.M42 = 0f; - result.M43 = 0f; - result.M44 = 1f; + float num3 = xScale; + float num2 = yScale; + float num = zScale; + result.M11 = num3; + result.M12 = 0f; + result.M13 = 0f; + result.M14 = 0f; + result.M21 = 0f; + result.M22 = num2; + result.M23 = 0f; + result.M24 = 0f; + result.M31 = 0f; + result.M32 = 0f; + result.M33 = num; + result.M34 = 0f; + result.M41 = 0f; + result.M42 = 0f; + result.M43 = 0f; + result.M44 = 1f; } - + /** * Creates a Matrix that flattens geometry into a specified Plane as if casting a shadow from a specified light source. * @@ -1464,11 +1455,11 @@ public final class Matrix extends ValueType implements IEquatable */ public static Matrix CreateShadow(Vector3 lightDirection, Plane plane) { - Matrix result = new Matrix(); - CreateShadow(lightDirection, plane, result); - return result; + Matrix result = new Matrix(); + CreateShadow(lightDirection, plane, result); + return result; } - + /** * Fills in a Matrix to flatten geometry into a specified Plane as if casting a shadow from a specified light source. * @@ -1483,31 +1474,31 @@ public final class Matrix extends ValueType implements IEquatable */ public static void CreateShadow(Vector3 lightDirection, Plane plane, Matrix result) { - Plane plane2 = new Plane(); - Plane.Normalize(plane, plane2); - float num = ((plane2.Normal.X * lightDirection.X) + (plane2.Normal.Y * lightDirection.Y)) + (plane2.Normal.Z * lightDirection.Z); - float num5 = -plane2.Normal.X; - float num4 = -plane2.Normal.Y; - float num3 = -plane2.Normal.Z; - float num2 = -plane2.D; - result.M11 = (num5 * lightDirection.X) + num; - result.M21 = num4 * lightDirection.X; - result.M31 = num3 * lightDirection.X; - result.M41 = num2 * lightDirection.X; - result.M12 = num5 * lightDirection.Y; - result.M22 = (num4 * lightDirection.Y) + num; - result.M32 = num3 * lightDirection.Y; - result.M42 = num2 * lightDirection.Y; - result.M13 = num5 * lightDirection.Z; - result.M23 = num4 * lightDirection.Z; - result.M33 = (num3 * lightDirection.Z) + num; - result.M43 = num2 * lightDirection.Z; - result.M14 = 0f; - result.M24 = 0f; - result.M34 = 0f; - result.M44 = num; + Plane plane2 = new Plane(); + Plane.Normalize(plane, plane2); + float num = ((plane2.Normal.X * lightDirection.X) + (plane2.Normal.Y * lightDirection.Y)) + (plane2.Normal.Z * lightDirection.Z); + float num5 = -plane2.Normal.X; + float num4 = -plane2.Normal.Y; + float num3 = -plane2.Normal.Z; + float num2 = -plane2.D; + result.M11 = (num5 * lightDirection.X) + num; + result.M21 = num4 * lightDirection.X; + result.M31 = num3 * lightDirection.X; + result.M41 = num2 * lightDirection.X; + result.M12 = num5 * lightDirection.Y; + result.M22 = (num4 * lightDirection.Y) + num; + result.M32 = num3 * lightDirection.Y; + result.M42 = num2 * lightDirection.Y; + result.M13 = num5 * lightDirection.Z; + result.M23 = num4 * lightDirection.Z; + result.M33 = (num3 * lightDirection.Z) + num; + result.M43 = num2 * lightDirection.Z; + result.M14 = 0f; + result.M24 = 0f; + result.M34 = 0f; + result.M44 = num; } - + /** * Creates a translation Matrix. * @@ -1516,11 +1507,11 @@ public final class Matrix extends ValueType implements IEquatable */ public static Matrix CreateTranslation(Vector3 position) { - Matrix result = new Matrix(); - CreateTranslation(position, result); - return result; + Matrix result = new Matrix(); + CreateTranslation(position, result); + return result; } - + /** * Creates a translation Matrix. * @@ -1532,24 +1523,24 @@ public final class Matrix extends ValueType implements IEquatable */ public static void CreateTranslation(Vector3 position, Matrix result) { - result.M11 = 1f; - result.M12 = 0f; - result.M13 = 0f; - result.M14 = 0f; - result.M21 = 0f; - result.M22 = 1f; - result.M23 = 0f; - result.M24 = 0f; - result.M31 = 0f; - result.M32 = 0f; - result.M33 = 1f; - result.M34 = 0f; - result.M41 = position.X; - result.M42 = position.Y; - result.M43 = position.Z; - result.M44 = 1f; + result.M11 = 1f; + result.M12 = 0f; + result.M13 = 0f; + result.M14 = 0f; + result.M21 = 0f; + result.M22 = 1f; + result.M23 = 0f; + result.M24 = 0f; + result.M31 = 0f; + result.M32 = 0f; + result.M33 = 1f; + result.M34 = 0f; + result.M41 = position.X; + result.M42 = position.Y; + result.M43 = position.Z; + result.M44 = 1f; } - + /** * Creates a translation Matrix. * @@ -1564,11 +1555,11 @@ public final class Matrix extends ValueType implements IEquatable */ public static Matrix CreateTranslation(float xPosition, float yPosition, float zPosition) { - Matrix result = new Matrix(); - CreateTranslation(xPosition, yPosition, zPosition, result); - return result; + Matrix result = new Matrix(); + CreateTranslation(xPosition, yPosition, zPosition, result); + return result; } - + /** * Creates a translation Matrix. * @@ -1586,24 +1577,24 @@ public final class Matrix extends ValueType implements IEquatable */ public static void CreateTranslation(float xPosition, float yPosition, float zPosition, Matrix result) { - result.M11 = 1f; - result.M12 = 0f; - result.M13 = 0f; - result.M14 = 0f; - result.M21 = 0f; - result.M22 = 1f; - result.M23 = 0f; - result.M24 = 0f; - result.M31 = 0f; - result.M32 = 0f; - result.M33 = 1f; - result.M34 = 0f; - result.M41 = xPosition; - result.M42 = yPosition; - result.M43 = zPosition; - result.M44 = 1f; + result.M11 = 1f; + result.M12 = 0f; + result.M13 = 0f; + result.M14 = 0f; + result.M21 = 0f; + result.M22 = 1f; + result.M23 = 0f; + result.M24 = 0f; + result.M31 = 0f; + result.M32 = 0f; + result.M33 = 1f; + result.M34 = 0f; + result.M41 = xPosition; + result.M42 = yPosition; + result.M43 = zPosition; + result.M44 = 1f; } - + /** * Creates a world matrix with the specified parameters. * @@ -1618,11 +1609,11 @@ public final class Matrix extends ValueType implements IEquatable */ public static Matrix CreateWorld(Vector3 position, Vector3 forward, Vector3 up) { - Matrix result = new Matrix(); - CreateWorld(position, forward, up, result); - return result; + Matrix result = new Matrix(); + CreateWorld(position, forward, up, result); + return result; } - + /** * Creates a world matrix with the specified parameters. * @@ -1640,25 +1631,25 @@ public final class Matrix extends ValueType implements IEquatable */ public static void CreateWorld(Vector3 position, Vector3 forward, Vector3 up, Matrix result) { - Vector3 vector = Vector3.Normalize(Vector3.Negate(forward)); - Vector3 vector2 = Vector3.Normalize(Vector3.Cross(up, vector)); - Vector3 vector3 = Vector3.Cross(vector, vector2); - result.M11 = vector2.X; - result.M12 = vector2.Y; - result.M13 = vector2.Z; - result.M14 = 0f; - result.M21 = vector3.X; - result.M22 = vector3.Y; - result.M23 = vector3.Z; - result.M24 = 0f; - result.M31 = vector.X; - result.M32 = vector.Y; - result.M33 = vector.Z; - result.M34 = 0f; - result.M41 = position.X; - result.M42 = position.Y; - result.M43 = position.Z; - result.M44 = 1f; + Vector3 vector = Vector3.Normalize(Vector3.Negate(forward)); + Vector3 vector2 = Vector3.Normalize(Vector3.Cross(up, vector)); + Vector3 vector3 = Vector3.Cross(vector, vector2); + result.M11 = vector2.X; + result.M12 = vector2.Y; + result.M13 = vector2.Z; + result.M14 = 0f; + result.M21 = vector3.X; + result.M22 = vector3.Y; + result.M23 = vector3.Z; + result.M24 = 0f; + result.M31 = vector.X; + result.M32 = vector.Y; + result.M33 = vector.Z; + result.M34 = 0f; + result.M41 = position.X; + result.M42 = position.Y; + result.M43 = position.Z; + result.M44 = 1f; } /** @@ -1666,31 +1657,31 @@ public final class Matrix extends ValueType implements IEquatable */ public float Determinant() { - float num22 = this.M11; - float num21 = this.M12; - float num20 = this.M13; - float num19 = this.M14; - float num12 = this.M21; - float num11 = this.M22; - float num10 = this.M23; - float num9 = this.M24; - float num8 = this.M31; - float num7 = this.M32; - float num6 = this.M33; - float num5 = this.M34; - float num4 = this.M41; - float num3 = this.M42; - float num2 = this.M43; - float num = this.M44; - float num18 = (num6 * num) - (num5 * num2); - float num17 = (num7 * num) - (num5 * num3); - float num16 = (num7 * num2) - (num6 * num3); - float num15 = (num8 * num) - (num5 * num4); - float num14 = (num8 * num2) - (num6 * num4); - float num13 = (num8 * num3) - (num7 * num4); - return ((((num22 * (((num11 * num18) - (num10 * num17)) + (num9 * num16))) - (num21 * (((num12 * num18) - (num10 * num15)) + (num9 * num14)))) + (num20 * (((num12 * num17) - (num11 * num15)) + (num9 * num13)))) - (num19 * (((num12 * num16) - (num11 * num14)) + (num10 * num13)))); + float num22 = this.M11; + float num21 = this.M12; + float num20 = this.M13; + float num19 = this.M14; + float num12 = this.M21; + float num11 = this.M22; + float num10 = this.M23; + float num9 = this.M24; + float num8 = this.M31; + float num7 = this.M32; + float num6 = this.M33; + float num5 = this.M34; + float num4 = this.M41; + float num3 = this.M42; + float num2 = this.M43; + float num = this.M44; + float num18 = (num6 * num) - (num5 * num2); + float num17 = (num7 * num) - (num5 * num3); + float num16 = (num7 * num2) - (num6 * num3); + float num15 = (num8 * num) - (num5 * num4); + float num14 = (num8 * num2) - (num6 * num4); + float num13 = (num8 * num3) - (num7 * num4); + return ((((num22 * (((num11 * num18) - (num10 * num17)) + (num9 * num16))) - (num21 * (((num12 * num18) - (num10 * num15)) + (num9 * num14)))) + (num20 * (((num12 * num17) - (num11 * num15)) + (num9 * num13)))) - (num19 * (((num12 * num16) - (num11 * num14)) + (num10 * num13)))); } - + /** * Divides the components of the current matrix by the corresponding components of another matrix. * @@ -1701,7 +1692,7 @@ public final class Matrix extends ValueType implements IEquatable { Divide(this, other, this); } - + /** * Divides the components of a matrix by the corresponding components of another matrix. * @@ -1713,26 +1704,26 @@ public final class Matrix extends ValueType implements IEquatable */ public static Matrix Divide(Matrix matrix1, Matrix matrix2) { - Matrix matrix = new Matrix(); - matrix.M11 = matrix1.M11 / matrix2.M11; - matrix.M12 = matrix1.M12 / matrix2.M12; - matrix.M13 = matrix1.M13 / matrix2.M13; - matrix.M14 = matrix1.M14 / matrix2.M14; - matrix.M21 = matrix1.M21 / matrix2.M21; - matrix.M22 = matrix1.M22 / matrix2.M22; - matrix.M23 = matrix1.M23 / matrix2.M23; - matrix.M24 = matrix1.M24 / matrix2.M24; - matrix.M31 = matrix1.M31 / matrix2.M31; - matrix.M32 = matrix1.M32 / matrix2.M32; - matrix.M33 = matrix1.M33 / matrix2.M33; - matrix.M34 = matrix1.M34 / matrix2.M34; - matrix.M41 = matrix1.M41 / matrix2.M41; - matrix.M42 = matrix1.M42 / matrix2.M42; - matrix.M43 = matrix1.M43 / matrix2.M43; - matrix.M44 = matrix1.M44 / matrix2.M44; - return matrix; + Matrix matrix = new Matrix(); + matrix.M11 = matrix1.M11 / matrix2.M11; + matrix.M12 = matrix1.M12 / matrix2.M12; + matrix.M13 = matrix1.M13 / matrix2.M13; + matrix.M14 = matrix1.M14 / matrix2.M14; + matrix.M21 = matrix1.M21 / matrix2.M21; + matrix.M22 = matrix1.M22 / matrix2.M22; + matrix.M23 = matrix1.M23 / matrix2.M23; + matrix.M24 = matrix1.M24 / matrix2.M24; + matrix.M31 = matrix1.M31 / matrix2.M31; + matrix.M32 = matrix1.M32 / matrix2.M32; + matrix.M33 = matrix1.M33 / matrix2.M33; + matrix.M34 = matrix1.M34 / matrix2.M34; + matrix.M41 = matrix1.M41 / matrix2.M41; + matrix.M42 = matrix1.M42 / matrix2.M42; + matrix.M43 = matrix1.M43 / matrix2.M43; + matrix.M44 = matrix1.M44 / matrix2.M44; + return matrix; } - + /** * Divides the components of the current matrix by a scalar. * @@ -1743,7 +1734,7 @@ public final class Matrix extends ValueType implements IEquatable { Divide(this, divider, this); } - + /** * Divides the components of a matrix by a scalar. * @@ -1755,27 +1746,27 @@ public final class Matrix extends ValueType implements IEquatable */ public static Matrix Divide(Matrix matrix1, float divider) { - Matrix matrix = new Matrix(); - float num = 1f / divider; - matrix.M11 = matrix1.M11 * num; - matrix.M12 = matrix1.M12 * num; - matrix.M13 = matrix1.M13 * num; - matrix.M14 = matrix1.M14 * num; - matrix.M21 = matrix1.M21 * num; - matrix.M22 = matrix1.M22 * num; - matrix.M23 = matrix1.M23 * num; - matrix.M24 = matrix1.M24 * num; - matrix.M31 = matrix1.M31 * num; - matrix.M32 = matrix1.M32 * num; - matrix.M33 = matrix1.M33 * num; - matrix.M34 = matrix1.M34 * num; - matrix.M41 = matrix1.M41 * num; - matrix.M42 = matrix1.M42 * num; - matrix.M43 = matrix1.M43 * num; - matrix.M44 = matrix1.M44 * num; - return matrix; + Matrix matrix = new Matrix(); + float num = 1f / divider; + matrix.M11 = matrix1.M11 * num; + matrix.M12 = matrix1.M12 * num; + matrix.M13 = matrix1.M13 * num; + matrix.M14 = matrix1.M14 * num; + matrix.M21 = matrix1.M21 * num; + matrix.M22 = matrix1.M22 * num; + matrix.M23 = matrix1.M23 * num; + matrix.M24 = matrix1.M24 * num; + matrix.M31 = matrix1.M31 * num; + matrix.M32 = matrix1.M32 * num; + matrix.M33 = matrix1.M33 * num; + matrix.M34 = matrix1.M34 * num; + matrix.M41 = matrix1.M41 * num; + matrix.M42 = matrix1.M42 * num; + matrix.M43 = matrix1.M43 * num; + matrix.M44 = matrix1.M44 * num; + return matrix; } - + /** * Divides the components of a matrix by a scalar. * @@ -1790,25 +1781,25 @@ public final class Matrix extends ValueType implements IEquatable */ public static void Divide(Matrix matrix1, float divider, Matrix result) { - float num = 1f / divider; - result.M11 = matrix1.M11 * num; - result.M12 = matrix1.M12 * num; - result.M13 = matrix1.M13 * num; - result.M14 = matrix1.M14 * num; - result.M21 = matrix1.M21 * num; - result.M22 = matrix1.M22 * num; - result.M23 = matrix1.M23 * num; - result.M24 = matrix1.M24 * num; - result.M31 = matrix1.M31 * num; - result.M32 = matrix1.M32 * num; - result.M33 = matrix1.M33 * num; - result.M34 = matrix1.M34 * num; - result.M41 = matrix1.M41 * num; - result.M42 = matrix1.M42 * num; - result.M43 = matrix1.M43 * num; - result.M44 = matrix1.M44 * num; + float num = 1f / divider; + result.M11 = matrix1.M11 * num; + result.M12 = matrix1.M12 * num; + result.M13 = matrix1.M13 * num; + result.M14 = matrix1.M14 * num; + result.M21 = matrix1.M21 * num; + result.M22 = matrix1.M22 * num; + result.M23 = matrix1.M23 * num; + result.M24 = matrix1.M24 * num; + result.M31 = matrix1.M31 * num; + result.M32 = matrix1.M32 * num; + result.M33 = matrix1.M33 * num; + result.M34 = matrix1.M34 * num; + result.M41 = matrix1.M41 * num; + result.M42 = matrix1.M42 * num; + result.M43 = matrix1.M43 * num; + result.M44 = matrix1.M44 * num; } - + /** * Divides the components of a matrix by the corresponding components of another matrix. * @@ -1823,24 +1814,24 @@ public final class Matrix extends ValueType implements IEquatable */ public static void Divide(Matrix matrix1, Matrix matrix2, Matrix result) { - result.M11 = matrix1.M11 / matrix2.M11; - result.M12 = matrix1.M12 / matrix2.M12; - result.M13 = matrix1.M13 / matrix2.M13; - result.M14 = matrix1.M14 / matrix2.M14; - result.M21 = matrix1.M21 / matrix2.M21; - result.M22 = matrix1.M22 / matrix2.M22; - result.M23 = matrix1.M23 / matrix2.M23; - result.M24 = matrix1.M24 / matrix2.M24; - result.M31 = matrix1.M31 / matrix2.M31; - result.M32 = matrix1.M32 / matrix2.M32; - result.M33 = matrix1.M33 / matrix2.M33; - result.M34 = matrix1.M34 / matrix2.M34; - result.M41 = matrix1.M41 / matrix2.M41; - result.M42 = matrix1.M42 / matrix2.M42; - result.M43 = matrix1.M43 / matrix2.M43; - result.M44 = matrix1.M44 / matrix2.M44; + result.M11 = matrix1.M11 / matrix2.M11; + result.M12 = matrix1.M12 / matrix2.M12; + result.M13 = matrix1.M13 / matrix2.M13; + result.M14 = matrix1.M14 / matrix2.M14; + result.M21 = matrix1.M21 / matrix2.M21; + result.M22 = matrix1.M22 / matrix2.M22; + result.M23 = matrix1.M23 / matrix2.M23; + result.M24 = matrix1.M24 / matrix2.M24; + result.M31 = matrix1.M31 / matrix2.M31; + result.M32 = matrix1.M32 / matrix2.M32; + result.M33 = matrix1.M33 / matrix2.M33; + result.M34 = matrix1.M34 / matrix2.M34; + result.M41 = matrix1.M41 / matrix2.M41; + result.M42 = matrix1.M42 / matrix2.M42; + result.M43 = matrix1.M43 / matrix2.M43; + result.M44 = matrix1.M44 / matrix2.M44; } - + /** * Returns a value that indicates whether the current instance is equal to a specified object. * @@ -1854,7 +1845,7 @@ public final class Matrix extends ValueType implements IEquatable { return (obj != null && obj instanceof Matrix) ? this.Equals((Matrix)obj) : false; } - + /** * Determines whether the specified Object is equal to the Matrix. * @@ -1863,18 +1854,18 @@ public final class Matrix extends ValueType implements IEquatable */ public boolean Equals(Matrix other) { - return ((((((this.M11 == other.M11) && (this.M22 == other.M22)) && ((this.M33 == other.M33) && (this.M44 == other.M44))) && (((this.M12 == other.M12) && (this.M13 == other.M13)) && ((this.M14 == other.M14) && (this.M21 == other.M21)))) && ((((this.M23 == other.M23) && (this.M24 == other.M24)) && ((this.M31 == other.M31) && (this.M32 == other.M32))) && (((this.M34 == other.M34) && (this.M41 == other.M41)) && (this.M42 == other.M42)))) && (this.M43 == other.M43)); + return ((((((this.M11 == other.M11) && (this.M22 == other.M22)) && ((this.M33 == other.M33) && (this.M44 == other.M44))) && (((this.M12 == other.M12) && (this.M13 == other.M13)) && ((this.M14 == other.M14) && (this.M21 == other.M21)))) && ((((this.M23 == other.M23) && (this.M24 == other.M24)) && ((this.M31 == other.M31) && (this.M32 == other.M32))) && (((this.M34 == other.M34) && (this.M41 == other.M41)) && (this.M42 == other.M42)))) && (this.M43 == other.M43)); } - + /** * Gets the hash code of this object. */ @Override public int hashCode() { - return ((((((((((((((((int)this.M11 ^ (int)this.M12) ^ (int)this.M13) ^ (int)this.M14) ^ (int)this.M21) ^ (int)this.M22) ^ (int)this.M23) ^ (int)this.M24) ^ (int)this.M31) ^ (int)this.M32) ^ (int)this.M33) ^ (int)this.M34) ^ (int)this.M41) ^ (int)this.M42) ^ (int)this.M43) ^ (int)this.M44); + return ((((((((((((((((int)this.M11 ^ (int)this.M12) ^ (int)this.M13) ^ (int)this.M14) ^ (int)this.M21) ^ (int)this.M22) ^ (int)this.M23) ^ (int)this.M24) ^ (int)this.M31) ^ (int)this.M32) ^ (int)this.M33) ^ (int)this.M34) ^ (int)this.M41) ^ (int)this.M42) ^ (int)this.M43) ^ (int)this.M44); } - + /** * Calculates the inverse of a matrix. * @@ -1883,11 +1874,11 @@ public final class Matrix extends ValueType implements IEquatable */ public static Matrix Invert(Matrix matrix) { - Matrix result = new Matrix(); - Invert(matrix, result); - return result; + Matrix result = new Matrix(); + Invert(matrix, result); + return result; } - + /** * Calculates the inverse of a matrix. * @@ -1899,63 +1890,63 @@ public final class Matrix extends ValueType implements IEquatable */ public static void Invert(Matrix matrix, Matrix result) { - float num5 = matrix.M11; - float num4 = matrix.M12; - float num3 = matrix.M13; - float num2 = matrix.M14; - float num9 = matrix.M21; - float num8 = matrix.M22; - float num7 = matrix.M23; - float num6 = matrix.M24; - float num17 = matrix.M31; - float num16 = matrix.M32; - float num15 = matrix.M33; - float num14 = matrix.M34; - float num13 = matrix.M41; - float num12 = matrix.M42; - float num11 = matrix.M43; - float num10 = matrix.M44; - float num23 = (num15 * num10) - (num14 * num11); - float num22 = (num16 * num10) - (num14 * num12); - float num21 = (num16 * num11) - (num15 * num12); - float num20 = (num17 * num10) - (num14 * num13); - float num19 = (num17 * num11) - (num15 * num13); - float num18 = (num17 * num12) - (num16 * num13); - float num39 = ((num8 * num23) - (num7 * num22)) + (num6 * num21); - float num38 = -(((num9 * num23) - (num7 * num20)) + (num6 * num19)); - float num37 = ((num9 * num22) - (num8 * num20)) + (num6 * num18); - float num36 = -(((num9 * num21) - (num8 * num19)) + (num7 * num18)); - float num = 1f / ((((num5 * num39) + (num4 * num38)) + (num3 * num37)) + (num2 * num36)); - result.M11 = num39 * num; - result.M21 = num38 * num; - result.M31 = num37 * num; - result.M41 = num36 * num; - result.M12 = -(((num4 * num23) - (num3 * num22)) + (num2 * num21)) * num; - result.M22 = (((num5 * num23) - (num3 * num20)) + (num2 * num19)) * num; - result.M32 = -(((num5 * num22) - (num4 * num20)) + (num2 * num18)) * num; - result.M42 = (((num5 * num21) - (num4 * num19)) + (num3 * num18)) * num; - float num35 = (num7 * num10) - (num6 * num11); - float num34 = (num8 * num10) - (num6 * num12); - float num33 = (num8 * num11) - (num7 * num12); - float num32 = (num9 * num10) - (num6 * num13); - float num31 = (num9 * num11) - (num7 * num13); - float num30 = (num9 * num12) - (num8 * num13); - result.M13 = (((num4 * num35) - (num3 * num34)) + (num2 * num33)) * num; - result.M23 = -(((num5 * num35) - (num3 * num32)) + (num2 * num31)) * num; - result.M33 = (((num5 * num34) - (num4 * num32)) + (num2 * num30)) * num; - result.M43 = -(((num5 * num33) - (num4 * num31)) + (num3 * num30)) * num; - float num29 = (num7 * num14) - (num6 * num15); - float num28 = (num8 * num14) - (num6 * num16); - float num27 = (num8 * num15) - (num7 * num16); - float num26 = (num9 * num14) - (num6 * num17); - float num25 = (num9 * num15) - (num7 * num17); - float num24 = (num9 * num16) - (num8 * num17); - result.M14 = -(((num4 * num29) - (num3 * num28)) + (num2 * num27)) * num; - result.M24 = (((num5 * num29) - (num3 * num26)) + (num2 * num25)) * num; - result.M34 = -(((num5 * num28) - (num4 * num26)) + (num2 * num24)) * num; - result.M44 = (((num5 * num27) - (num4 * num25)) + (num3 * num24)) * num; + float num5 = matrix.M11; + float num4 = matrix.M12; + float num3 = matrix.M13; + float num2 = matrix.M14; + float num9 = matrix.M21; + float num8 = matrix.M22; + float num7 = matrix.M23; + float num6 = matrix.M24; + float num17 = matrix.M31; + float num16 = matrix.M32; + float num15 = matrix.M33; + float num14 = matrix.M34; + float num13 = matrix.M41; + float num12 = matrix.M42; + float num11 = matrix.M43; + float num10 = matrix.M44; + float num23 = (num15 * num10) - (num14 * num11); + float num22 = (num16 * num10) - (num14 * num12); + float num21 = (num16 * num11) - (num15 * num12); + float num20 = (num17 * num10) - (num14 * num13); + float num19 = (num17 * num11) - (num15 * num13); + float num18 = (num17 * num12) - (num16 * num13); + float num39 = ((num8 * num23) - (num7 * num22)) + (num6 * num21); + float num38 = -(((num9 * num23) - (num7 * num20)) + (num6 * num19)); + float num37 = ((num9 * num22) - (num8 * num20)) + (num6 * num18); + float num36 = -(((num9 * num21) - (num8 * num19)) + (num7 * num18)); + float num = 1f / ((((num5 * num39) + (num4 * num38)) + (num3 * num37)) + (num2 * num36)); + result.M11 = num39 * num; + result.M21 = num38 * num; + result.M31 = num37 * num; + result.M41 = num36 * num; + result.M12 = -(((num4 * num23) - (num3 * num22)) + (num2 * num21)) * num; + result.M22 = (((num5 * num23) - (num3 * num20)) + (num2 * num19)) * num; + result.M32 = -(((num5 * num22) - (num4 * num20)) + (num2 * num18)) * num; + result.M42 = (((num5 * num21) - (num4 * num19)) + (num3 * num18)) * num; + float num35 = (num7 * num10) - (num6 * num11); + float num34 = (num8 * num10) - (num6 * num12); + float num33 = (num8 * num11) - (num7 * num12); + float num32 = (num9 * num10) - (num6 * num13); + float num31 = (num9 * num11) - (num7 * num13); + float num30 = (num9 * num12) - (num8 * num13); + result.M13 = (((num4 * num35) - (num3 * num34)) + (num2 * num33)) * num; + result.M23 = -(((num5 * num35) - (num3 * num32)) + (num2 * num31)) * num; + result.M33 = (((num5 * num34) - (num4 * num32)) + (num2 * num30)) * num; + result.M43 = -(((num5 * num33) - (num4 * num31)) + (num3 * num30)) * num; + float num29 = (num7 * num14) - (num6 * num15); + float num28 = (num8 * num14) - (num6 * num16); + float num27 = (num8 * num15) - (num7 * num16); + float num26 = (num9 * num14) - (num6 * num17); + float num25 = (num9 * num15) - (num7 * num17); + float num24 = (num9 * num16) - (num8 * num17); + result.M14 = -(((num4 * num29) - (num3 * num28)) + (num2 * num27)) * num; + result.M24 = (((num5 * num29) - (num3 * num26)) + (num2 * num25)) * num; + result.M34 = -(((num5 * num28) - (num4 * num26)) + (num2 * num24)) * num; + result.M44 = (((num5 * num27) - (num4 * num25)) + (num3 * num24)) * num; } - + /** * Linearly interpolates between the corresponding values of two matrices. * @@ -1970,11 +1961,11 @@ public final class Matrix extends ValueType implements IEquatable */ public static Matrix Lerp(Matrix matrix1, Matrix matrix2, float amount) { - Matrix result = new Matrix(); - Lerp(matrix1, matrix2, amount, result); - return result; + Matrix result = new Matrix(); + Lerp(matrix1, matrix2, amount, result); + return result; } - + /** * Linearly interpolates between the corresponding values of two matrices. * @@ -1992,24 +1983,24 @@ public final class Matrix extends ValueType implements IEquatable */ public static void Lerp(Matrix matrix1, Matrix matrix2, float amount, Matrix result) { - result.M11 = matrix1.M11 + ((matrix2.M11 - matrix1.M11) * amount); - result.M12 = matrix1.M12 + ((matrix2.M12 - matrix1.M12) * amount); - result.M13 = matrix1.M13 + ((matrix2.M13 - matrix1.M13) * amount); - result.M14 = matrix1.M14 + ((matrix2.M14 - matrix1.M14) * amount); - result.M21 = matrix1.M21 + ((matrix2.M21 - matrix1.M21) * amount); - result.M22 = matrix1.M22 + ((matrix2.M22 - matrix1.M22) * amount); - result.M23 = matrix1.M23 + ((matrix2.M23 - matrix1.M23) * amount); - result.M24 = matrix1.M24 + ((matrix2.M24 - matrix1.M24) * amount); - result.M31 = matrix1.M31 + ((matrix2.M31 - matrix1.M31) * amount); - result.M32 = matrix1.M32 + ((matrix2.M32 - matrix1.M32) * amount); - result.M33 = matrix1.M33 + ((matrix2.M33 - matrix1.M33) * amount); - result.M34 = matrix1.M34 + ((matrix2.M34 - matrix1.M34) * amount); - result.M41 = matrix1.M41 + ((matrix2.M41 - matrix1.M41) * amount); - result.M42 = matrix1.M42 + ((matrix2.M42 - matrix1.M42) * amount); - result.M43 = matrix1.M43 + ((matrix2.M43 - matrix1.M43) * amount); - result.M44 = matrix1.M44 + ((matrix2.M44 - matrix1.M44) * amount); + result.M11 = matrix1.M11 + ((matrix2.M11 - matrix1.M11) * amount); + result.M12 = matrix1.M12 + ((matrix2.M12 - matrix1.M12) * amount); + result.M13 = matrix1.M13 + ((matrix2.M13 - matrix1.M13) * amount); + result.M14 = matrix1.M14 + ((matrix2.M14 - matrix1.M14) * amount); + result.M21 = matrix1.M21 + ((matrix2.M21 - matrix1.M21) * amount); + result.M22 = matrix1.M22 + ((matrix2.M22 - matrix1.M22) * amount); + result.M23 = matrix1.M23 + ((matrix2.M23 - matrix1.M23) * amount); + result.M24 = matrix1.M24 + ((matrix2.M24 - matrix1.M24) * amount); + result.M31 = matrix1.M31 + ((matrix2.M31 - matrix1.M31) * amount); + result.M32 = matrix1.M32 + ((matrix2.M32 - matrix1.M32) * amount); + result.M33 = matrix1.M33 + ((matrix2.M33 - matrix1.M33) * amount); + result.M34 = matrix1.M34 + ((matrix2.M34 - matrix1.M34) * amount); + result.M41 = matrix1.M41 + ((matrix2.M41 - matrix1.M41) * amount); + result.M42 = matrix1.M42 + ((matrix2.M42 - matrix1.M42) * amount); + result.M43 = matrix1.M43 + ((matrix2.M43 - matrix1.M43) * amount); + result.M44 = matrix1.M44 + ((matrix2.M44 - matrix1.M44) * amount); } - + /** * Multiplies the current matrix by another matrix. * @@ -2020,7 +2011,7 @@ public final class Matrix extends ValueType implements IEquatable { Multiply(this, other, this); } - + /** * Multiplies a matrix by another matrix. * @@ -2032,11 +2023,11 @@ public final class Matrix extends ValueType implements IEquatable */ public static Matrix Multiply(Matrix matrix1, Matrix matrix2) { - Matrix result = new Matrix(); - Multiply(matrix1, matrix2, result); - return result; + Matrix result = new Matrix(); + Multiply(matrix1, matrix2, result); + return result; } - + /** * Multiplies the current matrix by a scalar value. * @@ -2047,7 +2038,7 @@ public final class Matrix extends ValueType implements IEquatable { Multiply(this, scaleFactor, this); } - + /** * Multiplies a matrix by a scalar value. * @@ -2059,11 +2050,11 @@ public final class Matrix extends ValueType implements IEquatable */ public static Matrix Multiply(Matrix matrix1, float scaleFactor) { - Matrix result = new Matrix(); - Multiply(matrix1, scaleFactor, result); - return result; + Matrix result = new Matrix(); + Multiply(matrix1, scaleFactor, result); + return result; } - + /** * Multiplies a matrix by another matrix. * @@ -2078,40 +2069,40 @@ public final class Matrix extends ValueType implements IEquatable */ public static void Multiply(Matrix matrix1, Matrix matrix2, Matrix result) { - float num16 = (((matrix1.M11 * matrix2.M11) + (matrix1.M12 * matrix2.M21)) + (matrix1.M13 * matrix2.M31)) + (matrix1.M14 * matrix2.M41); - float num15 = (((matrix1.M11 * matrix2.M12) + (matrix1.M12 * matrix2.M22)) + (matrix1.M13 * matrix2.M32)) + (matrix1.M14 * matrix2.M42); - float num14 = (((matrix1.M11 * matrix2.M13) + (matrix1.M12 * matrix2.M23)) + (matrix1.M13 * matrix2.M33)) + (matrix1.M14 * matrix2.M43); - float num13 = (((matrix1.M11 * matrix2.M14) + (matrix1.M12 * matrix2.M24)) + (matrix1.M13 * matrix2.M34)) + (matrix1.M14 * matrix2.M44); - float num12 = (((matrix1.M21 * matrix2.M11) + (matrix1.M22 * matrix2.M21)) + (matrix1.M23 * matrix2.M31)) + (matrix1.M24 * matrix2.M41); - float num11 = (((matrix1.M21 * matrix2.M12) + (matrix1.M22 * matrix2.M22)) + (matrix1.M23 * matrix2.M32)) + (matrix1.M24 * matrix2.M42); - float num10 = (((matrix1.M21 * matrix2.M13) + (matrix1.M22 * matrix2.M23)) + (matrix1.M23 * matrix2.M33)) + (matrix1.M24 * matrix2.M43); - float num9 = (((matrix1.M21 * matrix2.M14) + (matrix1.M22 * matrix2.M24)) + (matrix1.M23 * matrix2.M34)) + (matrix1.M24 * matrix2.M44); - float num8 = (((matrix1.M31 * matrix2.M11) + (matrix1.M32 * matrix2.M21)) + (matrix1.M33 * matrix2.M31)) + (matrix1.M34 * matrix2.M41); - float num7 = (((matrix1.M31 * matrix2.M12) + (matrix1.M32 * matrix2.M22)) + (matrix1.M33 * matrix2.M32)) + (matrix1.M34 * matrix2.M42); - float num6 = (((matrix1.M31 * matrix2.M13) + (matrix1.M32 * matrix2.M23)) + (matrix1.M33 * matrix2.M33)) + (matrix1.M34 * matrix2.M43); - float num5 = (((matrix1.M31 * matrix2.M14) + (matrix1.M32 * matrix2.M24)) + (matrix1.M33 * matrix2.M34)) + (matrix1.M34 * matrix2.M44); - float num4 = (((matrix1.M41 * matrix2.M11) + (matrix1.M42 * matrix2.M21)) + (matrix1.M43 * matrix2.M31)) + (matrix1.M44 * matrix2.M41); - float num3 = (((matrix1.M41 * matrix2.M12) + (matrix1.M42 * matrix2.M22)) + (matrix1.M43 * matrix2.M32)) + (matrix1.M44 * matrix2.M42); - float num2 = (((matrix1.M41 * matrix2.M13) + (matrix1.M42 * matrix2.M23)) + (matrix1.M43 * matrix2.M33)) + (matrix1.M44 * matrix2.M43); - float num = (((matrix1.M41 * matrix2.M14) + (matrix1.M42 * matrix2.M24)) + (matrix1.M43 * matrix2.M34)) + (matrix1.M44 * matrix2.M44); - result.M11 = num16; - result.M12 = num15; - result.M13 = num14; - result.M14 = num13; - result.M21 = num12; - result.M22 = num11; - result.M23 = num10; - result.M24 = num9; - result.M31 = num8; - result.M32 = num7; - result.M33 = num6; - result.M34 = num5; - result.M41 = num4; - result.M42 = num3; - result.M43 = num2; - result.M44 = num; + float num16 = (((matrix1.M11 * matrix2.M11) + (matrix1.M12 * matrix2.M21)) + (matrix1.M13 * matrix2.M31)) + (matrix1.M14 * matrix2.M41); + float num15 = (((matrix1.M11 * matrix2.M12) + (matrix1.M12 * matrix2.M22)) + (matrix1.M13 * matrix2.M32)) + (matrix1.M14 * matrix2.M42); + float num14 = (((matrix1.M11 * matrix2.M13) + (matrix1.M12 * matrix2.M23)) + (matrix1.M13 * matrix2.M33)) + (matrix1.M14 * matrix2.M43); + float num13 = (((matrix1.M11 * matrix2.M14) + (matrix1.M12 * matrix2.M24)) + (matrix1.M13 * matrix2.M34)) + (matrix1.M14 * matrix2.M44); + float num12 = (((matrix1.M21 * matrix2.M11) + (matrix1.M22 * matrix2.M21)) + (matrix1.M23 * matrix2.M31)) + (matrix1.M24 * matrix2.M41); + float num11 = (((matrix1.M21 * matrix2.M12) + (matrix1.M22 * matrix2.M22)) + (matrix1.M23 * matrix2.M32)) + (matrix1.M24 * matrix2.M42); + float num10 = (((matrix1.M21 * matrix2.M13) + (matrix1.M22 * matrix2.M23)) + (matrix1.M23 * matrix2.M33)) + (matrix1.M24 * matrix2.M43); + float num9 = (((matrix1.M21 * matrix2.M14) + (matrix1.M22 * matrix2.M24)) + (matrix1.M23 * matrix2.M34)) + (matrix1.M24 * matrix2.M44); + float num8 = (((matrix1.M31 * matrix2.M11) + (matrix1.M32 * matrix2.M21)) + (matrix1.M33 * matrix2.M31)) + (matrix1.M34 * matrix2.M41); + float num7 = (((matrix1.M31 * matrix2.M12) + (matrix1.M32 * matrix2.M22)) + (matrix1.M33 * matrix2.M32)) + (matrix1.M34 * matrix2.M42); + float num6 = (((matrix1.M31 * matrix2.M13) + (matrix1.M32 * matrix2.M23)) + (matrix1.M33 * matrix2.M33)) + (matrix1.M34 * matrix2.M43); + float num5 = (((matrix1.M31 * matrix2.M14) + (matrix1.M32 * matrix2.M24)) + (matrix1.M33 * matrix2.M34)) + (matrix1.M34 * matrix2.M44); + float num4 = (((matrix1.M41 * matrix2.M11) + (matrix1.M42 * matrix2.M21)) + (matrix1.M43 * matrix2.M31)) + (matrix1.M44 * matrix2.M41); + float num3 = (((matrix1.M41 * matrix2.M12) + (matrix1.M42 * matrix2.M22)) + (matrix1.M43 * matrix2.M32)) + (matrix1.M44 * matrix2.M42); + float num2 = (((matrix1.M41 * matrix2.M13) + (matrix1.M42 * matrix2.M23)) + (matrix1.M43 * matrix2.M33)) + (matrix1.M44 * matrix2.M43); + float num = (((matrix1.M41 * matrix2.M14) + (matrix1.M42 * matrix2.M24)) + (matrix1.M43 * matrix2.M34)) + (matrix1.M44 * matrix2.M44); + result.M11 = num16; + result.M12 = num15; + result.M13 = num14; + result.M14 = num13; + result.M21 = num12; + result.M22 = num11; + result.M23 = num10; + result.M24 = num9; + result.M31 = num8; + result.M32 = num7; + result.M33 = num6; + result.M34 = num5; + result.M41 = num4; + result.M42 = num3; + result.M43 = num2; + result.M44 = num; } - + /** * Multiplies a matrix by a scalar value. * @@ -2126,25 +2117,25 @@ public final class Matrix extends ValueType implements IEquatable */ public static void Multiply(Matrix matrix1, float scaleFactor, Matrix result) { - float num = scaleFactor; - result.M11 = matrix1.M11 * num; - result.M12 = matrix1.M12 * num; - result.M13 = matrix1.M13 * num; - result.M14 = matrix1.M14 * num; - result.M21 = matrix1.M21 * num; - result.M22 = matrix1.M22 * num; - result.M23 = matrix1.M23 * num; - result.M24 = matrix1.M24 * num; - result.M31 = matrix1.M31 * num; - result.M32 = matrix1.M32 * num; - result.M33 = matrix1.M33 * num; - result.M34 = matrix1.M34 * num; - result.M41 = matrix1.M41 * num; - result.M42 = matrix1.M42 * num; - result.M43 = matrix1.M43 * num; - result.M44 = matrix1.M44 * num; + float num = scaleFactor; + result.M11 = matrix1.M11 * num; + result.M12 = matrix1.M12 * num; + result.M13 = matrix1.M13 * num; + result.M14 = matrix1.M14 * num; + result.M21 = matrix1.M21 * num; + result.M22 = matrix1.M22 * num; + result.M23 = matrix1.M23 * num; + result.M24 = matrix1.M24 * num; + result.M31 = matrix1.M31 * num; + result.M32 = matrix1.M32 * num; + result.M33 = matrix1.M33 * num; + result.M34 = matrix1.M34 * num; + result.M41 = matrix1.M41 * num; + result.M42 = matrix1.M42 * num; + result.M43 = matrix1.M43 * num; + result.M44 = matrix1.M44 * num; } - + /** * Negates individual elements of the current matrix. */ @@ -2152,7 +2143,7 @@ public final class Matrix extends ValueType implements IEquatable { Negate(this, this); } - + /** * Negates individual elements of a matrix. * @@ -2161,11 +2152,11 @@ public final class Matrix extends ValueType implements IEquatable */ public static Matrix Negate(Matrix matrix) { - Matrix result = new Matrix(); - Negate(matrix, result); - return result; + Matrix result = new Matrix(); + Negate(matrix, result); + return result; } - + /** * Negates individual elements of a matrix. * @@ -2177,24 +2168,24 @@ public final class Matrix extends ValueType implements IEquatable */ public static void Negate(Matrix matrix, Matrix result) { - result.M11 = -matrix.M11; - result.M12 = -matrix.M12; - result.M13 = -matrix.M13; - result.M14 = -matrix.M14; - result.M21 = -matrix.M21; - result.M22 = -matrix.M22; - result.M23 = -matrix.M23; - result.M24 = -matrix.M24; - result.M31 = -matrix.M31; - result.M32 = -matrix.M32; - result.M33 = -matrix.M33; - result.M34 = -matrix.M34; - result.M41 = -matrix.M41; - result.M42 = -matrix.M42; - result.M43 = -matrix.M43; - result.M44 = -matrix.M44; + result.M11 = -matrix.M11; + result.M12 = -matrix.M12; + result.M13 = -matrix.M13; + result.M14 = -matrix.M14; + result.M21 = -matrix.M21; + result.M22 = -matrix.M22; + result.M23 = -matrix.M23; + result.M24 = -matrix.M24; + result.M31 = -matrix.M31; + result.M32 = -matrix.M32; + result.M33 = -matrix.M33; + result.M34 = -matrix.M34; + result.M41 = -matrix.M41; + result.M42 = -matrix.M42; + result.M43 = -matrix.M43; + result.M44 = -matrix.M44; } - + /** * Subtracts the specified matrix from the current matrix. * @@ -2205,7 +2196,7 @@ public final class Matrix extends ValueType implements IEquatable { Subtract(this, other, this); } - + /** * Subtracts matrices. * @@ -2217,11 +2208,11 @@ public final class Matrix extends ValueType implements IEquatable */ public static Matrix Subtract(Matrix matrix1, Matrix matrix2) { - Matrix result = new Matrix(); - Subtract(matrix1, matrix2, result); - return result; + Matrix result = new Matrix(); + Subtract(matrix1, matrix2, result); + return result; } - + /** * Subtracts matrices. * @@ -2236,24 +2227,24 @@ public final class Matrix extends ValueType implements IEquatable */ public static void Subtract(Matrix matrix1, Matrix matrix2, Matrix result) { - result.M11 = matrix1.M11 - matrix2.M11; - result.M12 = matrix1.M12 - matrix2.M12; - result.M13 = matrix1.M13 - matrix2.M13; - result.M14 = matrix1.M14 - matrix2.M14; - result.M21 = matrix1.M21 - matrix2.M21; - result.M22 = matrix1.M22 - matrix2.M22; - result.M23 = matrix1.M23 - matrix2.M23; - result.M24 = matrix1.M24 - matrix2.M24; - result.M31 = matrix1.M31 - matrix2.M31; - result.M32 = matrix1.M32 - matrix2.M32; - result.M33 = matrix1.M33 - matrix2.M33; - result.M34 = matrix1.M34 - matrix2.M34; - result.M41 = matrix1.M41 - matrix2.M41; - result.M42 = matrix1.M42 - matrix2.M42; - result.M43 = matrix1.M43 - matrix2.M43; - result.M44 = matrix1.M44 - matrix2.M44; + result.M11 = matrix1.M11 - matrix2.M11; + result.M12 = matrix1.M12 - matrix2.M12; + result.M13 = matrix1.M13 - matrix2.M13; + result.M14 = matrix1.M14 - matrix2.M14; + result.M21 = matrix1.M21 - matrix2.M21; + result.M22 = matrix1.M22 - matrix2.M22; + result.M23 = matrix1.M23 - matrix2.M23; + result.M24 = matrix1.M24 - matrix2.M24; + result.M31 = matrix1.M31 - matrix2.M31; + result.M32 = matrix1.M32 - matrix2.M32; + result.M33 = matrix1.M33 - matrix2.M33; + result.M34 = matrix1.M34 - matrix2.M34; + result.M41 = matrix1.M41 - matrix2.M41; + result.M42 = matrix1.M42 - matrix2.M42; + result.M43 = matrix1.M43 - matrix2.M43; + result.M44 = matrix1.M44 - matrix2.M44; } - + /** * Retrieves a string representation of the current object. * @@ -2263,9 +2254,9 @@ public final class Matrix extends ValueType implements IEquatable @Override public String toString() { - return ("{ " + String.format(Locale.getDefault(), "{M11:%f M12:%f M13:%f M14:%f} ", this.M11, this.M12, this.M13, this.M14) + String.format(Locale.getDefault(), "{M21:%f M22:%f M23:%f M24:%f} ", this.M21, this.M22, this.M23, this.M24) + String.format(Locale.getDefault(), "{M31:%f M32:%f M33:%f M34:%f} ", this.M31, this.M32, this.M33, this.M34) + String.format(Locale.getDefault(), "{M41:%f M42:%f M43:%f M44:%f} ", this.M41, this.M42, this.M43, this.M44) + "}"); + return ("{ " + String.format(Locale.getDefault(), "{M11:%f M12:%f M13:%f M14:%f} ", this.M11, this.M12, this.M13, this.M14) + String.format(Locale.getDefault(), "{M21:%f M22:%f M23:%f M24:%f} ", this.M21, this.M22, this.M23, this.M24) + String.format(Locale.getDefault(), "{M31:%f M32:%f M33:%f M34:%f} ", this.M31, this.M32, this.M33, this.M34) + String.format(Locale.getDefault(), "{M41:%f M42:%f M43:%f M44:%f} ", this.M41, this.M42, this.M43, this.M44) + "}"); } - + /** * Transforms a Matrix by applying a Quaternion rotation. * @@ -2277,11 +2268,11 @@ public final class Matrix extends ValueType implements IEquatable */ public static Matrix Transform(Matrix value, Quaternion rotation) { - Matrix result = new Matrix(); - Transform(value, rotation, result); - return result; + Matrix result = new Matrix(); + Transform(value, rotation, result); + return result; } - + /** * Transforms a Matrix by applying a Quaternion rotation. * @@ -2296,61 +2287,61 @@ public final class Matrix extends ValueType implements IEquatable */ public static void Transform(Matrix value, Quaternion rotation, Matrix result) { - float num21 = rotation.X + rotation.X; - float num11 = rotation.Y + rotation.Y; - float num10 = rotation.Z + rotation.Z; - float num20 = rotation.W * num21; - float num19 = rotation.W * num11; - float num18 = rotation.W * num10; - float num17 = rotation.X * num21; - float num16 = rotation.X * num11; - float num15 = rotation.X * num10; - float num14 = rotation.Y * num11; - float num13 = rotation.Y * num10; - float num12 = rotation.Z * num10; - float num9 = (1f - num14) - num12; - float num8 = num16 - num18; - float num7 = num15 + num19; - float num6 = num16 + num18; - float num5 = (1f - num17) - num12; - float num4 = num13 - num20; - float num3 = num15 - num19; - float num2 = num13 + num20; - float num = (1f - num17) - num14; - float num37 = ((value.M11 * num9) + (value.M12 * num8)) + (value.M13 * num7); - float num36 = ((value.M11 * num6) + (value.M12 * num5)) + (value.M13 * num4); - float num35 = ((value.M11 * num3) + (value.M12 * num2)) + (value.M13 * num); - float num34 = value.M14; - float num33 = ((value.M21 * num9) + (value.M22 * num8)) + (value.M23 * num7); - float num32 = ((value.M21 * num6) + (value.M22 * num5)) + (value.M23 * num4); - float num31 = ((value.M21 * num3) + (value.M22 * num2)) + (value.M23 * num); - float num30 = value.M24; - float num29 = ((value.M31 * num9) + (value.M32 * num8)) + (value.M33 * num7); - float num28 = ((value.M31 * num6) + (value.M32 * num5)) + (value.M33 * num4); - float num27 = ((value.M31 * num3) + (value.M32 * num2)) + (value.M33 * num); - float num26 = value.M34; - float num25 = ((value.M41 * num9) + (value.M42 * num8)) + (value.M43 * num7); - float num24 = ((value.M41 * num6) + (value.M42 * num5)) + (value.M43 * num4); - float num23 = ((value.M41 * num3) + (value.M42 * num2)) + (value.M43 * num); - float num22 = value.M44; - result.M11 = num37; - result.M12 = num36; - result.M13 = num35; - result.M14 = num34; - result.M21 = num33; - result.M22 = num32; - result.M23 = num31; - result.M24 = num30; - result.M31 = num29; - result.M32 = num28; - result.M33 = num27; - result.M34 = num26; - result.M41 = num25; - result.M42 = num24; - result.M43 = num23; - result.M44 = num22; + float num21 = rotation.X + rotation.X; + float num11 = rotation.Y + rotation.Y; + float num10 = rotation.Z + rotation.Z; + float num20 = rotation.W * num21; + float num19 = rotation.W * num11; + float num18 = rotation.W * num10; + float num17 = rotation.X * num21; + float num16 = rotation.X * num11; + float num15 = rotation.X * num10; + float num14 = rotation.Y * num11; + float num13 = rotation.Y * num10; + float num12 = rotation.Z * num10; + float num9 = (1f - num14) - num12; + float num8 = num16 - num18; + float num7 = num15 + num19; + float num6 = num16 + num18; + float num5 = (1f - num17) - num12; + float num4 = num13 - num20; + float num3 = num15 - num19; + float num2 = num13 + num20; + float num = (1f - num17) - num14; + float num37 = ((value.M11 * num9) + (value.M12 * num8)) + (value.M13 * num7); + float num36 = ((value.M11 * num6) + (value.M12 * num5)) + (value.M13 * num4); + float num35 = ((value.M11 * num3) + (value.M12 * num2)) + (value.M13 * num); + float num34 = value.M14; + float num33 = ((value.M21 * num9) + (value.M22 * num8)) + (value.M23 * num7); + float num32 = ((value.M21 * num6) + (value.M22 * num5)) + (value.M23 * num4); + float num31 = ((value.M21 * num3) + (value.M22 * num2)) + (value.M23 * num); + float num30 = value.M24; + float num29 = ((value.M31 * num9) + (value.M32 * num8)) + (value.M33 * num7); + float num28 = ((value.M31 * num6) + (value.M32 * num5)) + (value.M33 * num4); + float num27 = ((value.M31 * num3) + (value.M32 * num2)) + (value.M33 * num); + float num26 = value.M34; + float num25 = ((value.M41 * num9) + (value.M42 * num8)) + (value.M43 * num7); + float num24 = ((value.M41 * num6) + (value.M42 * num5)) + (value.M43 * num4); + float num23 = ((value.M41 * num3) + (value.M42 * num2)) + (value.M43 * num); + float num22 = value.M44; + result.M11 = num37; + result.M12 = num36; + result.M13 = num35; + result.M14 = num34; + result.M21 = num33; + result.M22 = num32; + result.M23 = num31; + result.M24 = num30; + result.M31 = num29; + result.M32 = num28; + result.M33 = num27; + result.M34 = num26; + result.M41 = num25; + result.M42 = num24; + result.M43 = num23; + result.M44 = num22; } - + /** * Transposes the rows and columns of a matrix. * @@ -2359,11 +2350,11 @@ public final class Matrix extends ValueType implements IEquatable */ public static Matrix Transpose(Matrix matrix) { - Matrix result = new Matrix(); - Transpose(matrix, result); - return result; + Matrix result = new Matrix(); + Transpose(matrix, result); + return result; } - + /** * Transposes the rows and columns of a matrix. * diff --git a/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/Media/Album.java b/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/Media/Album.java index b48fd4e..ae2c851 100644 --- a/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/Media/Album.java +++ b/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/Media/Album.java @@ -21,8 +21,7 @@ public final class Album implements IEquatable, IDisposable private SongCollection songs; /** - * - * @return + * Gets the Artist of the Album. */ public Artist getArtist() { @@ -34,12 +33,55 @@ public final class Album implements IEquatable, IDisposable return this.artist; } + /** + * Gets the duration of the Album. + */ + public TimeSpan getDuration() + { + return this.duration; + } + + /** + * Gets the Genre of the Album. + */ + public Genre getGenre() + { + return this.genre; + } + + /** + * Gets a value indicating whether the Album has associated album art. + */ public boolean HasArt() { ThrowIfDisposed(); return this.hasArt; } + /** + * Gets a value indicating whether the object is disposed. + */ + public boolean IsDisposed() + { + return this.isDisposed; + } + + /** + * Gets the name of the Album. + */ + public String getName() + { + return this.name; + } + + /** + * Gets a SongCollection that contains the songs on the album. + */ + public SongCollection getSongs() + { + return this.songs; + } + private Album() { this.name = ""; @@ -49,15 +91,20 @@ public final class Album implements IEquatable, IDisposable this.duration = TimeSpan.Zero; } - /* - Album(uint handle) - { - this.name = string.Empty; - this.artist = Artist.Empty; - this.genre = Genre.Empty; - this.songs = SongCollection.Empty; - this.duration = TimeSpan.Zero; - }*/ + /* + Album(uint handle) + { + this.name = string.Empty; + this.artist = Artist.Empty; + this.genre = Genre.Empty; + this.songs = SongCollection.Empty; + this.duration = TimeSpan.Zero; + }*/ + + protected void finalize() + { + this.Dispose(false); + } /** * Immediately releases the unmanaged resources used by this object. @@ -80,6 +127,14 @@ public final class Album implements IEquatable, IDisposable } } + private void ThrowIfDisposed() + { + if (this.isDisposed) + { + throw new ObjectDisposedException(this.getClass().toString(), "This object has already been disposed."); + } + } + /** * Determines whether the specified Object is equal to this Album. * @@ -89,7 +144,7 @@ public final class Album implements IEquatable, IDisposable @Override public boolean equals(Object obj) { - return (obj instanceof Album) ? (this == (Album)obj) : false; + return (obj != null && obj instanceof Album) ? this.Equals((Album)obj) : false; } /** @@ -105,11 +160,6 @@ public final class Album implements IEquatable, IDisposable return false; } - protected void finalize() - { - this.Dispose(false); - } - /** * Gets the hash code for this instance. */ @@ -126,20 +176,13 @@ public final class Album implements IEquatable, IDisposable return this.hashcode; } - private void ThrowIfDisposed() - { - if (this.isDisposed) - { - throw new ObjectDisposedException(this.getClass().toString(), "This object has already been disposed."); - } - } - /** * Returns a String representation of this Album. */ public String toString() { ThrowIfDisposed(); + return this.name; } } diff --git a/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/Media/Artist.java b/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/Media/Artist.java index a1d85cd..75b14b3 100644 --- a/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/Media/Artist.java +++ b/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/Media/Artist.java @@ -17,6 +17,14 @@ public final class Artist implements IEquatable, IDisposable private String name; private SongCollection songs; + /** + * Gets the AlbumCollection for the Artist. + */ + public AlbumCollection getAlbums() + { + return this.albums; + } + /** * Gets a value indicating whether the object is disposed. */ @@ -34,6 +42,19 @@ public final class Artist implements IEquatable, IDisposable return this.name; } + /** + * Gets the SongCollection for the Artist. + */ + public SongCollection getSongs() + { + return this.songs; + } + + static + { + Empty = new Artist(); + } + private Artist() { //this.handle = uint.MaxValue; @@ -45,21 +66,22 @@ public final class Artist implements IEquatable, IDisposable /*Artist(uint handle) { - this.handle = uint.MaxValue; - this.hashcode = -1; - this.name = ""; - this.songs = SongCollection.Empty; - this.albums = AlbumCollection.Empty; - this.handle = handle; - - if (this.IsValidHandle) - { - StringBuilder sbName = new StringBuilder(260); - if (Helpers.Succeeded(UnsafeNativeMethods.MediaItem_GetName(handle, sbName, 260))) - { - this.name = sbName.ToString(); - } - } + this.handle = uint.MaxValue; + this.hashcode = -1; + this.name = ""; + this.songs = SongCollection.Empty; + this.albums = AlbumCollection.Empty; + this.handle = handle; + + if (this.IsValidHandle) + { + StringBuilder sbName = new StringBuilder(260); + + if (Helpers.Succeeded(UnsafeNativeMethods.MediaItem_GetName(handle, sbName, 260))) + { + this.name = sbName.ToString(); + } + } }*/ @Override @@ -67,51 +89,19 @@ public final class Artist implements IEquatable, IDisposable { this.Dispose(true); } - + private void Dispose(boolean disposing) { if (!this.isDisposed) - { - this.isDisposed = true; - // TODO: implement - /*if (this.IsValidHandle) - { - UnsafeNativeMethods.MediaItem_Release(this.handle); - this.handle = uint.MaxValue; - }*/ - } - } - - @Override - public boolean equals(Object obj) - { - return (obj instanceof Artist) ? (this == (Artist)obj) : false; - } - - @Override - public boolean Equals(Artist other) - { - // TODO Auto-generated method stub - return false; - } - - protected void finalize() - { - this.Dispose(false); - } - - /** - * Gets the hash code for this instance. - */ - @Override - public int hashCode() - { - ThrowIfDisposed(); - if (this.hashcode == -1) { - this.hashcode = this.name.hashCode(); + this.isDisposed = true; + // TODO: implement + /*if (this.IsValidHandle) + { + UnsafeNativeMethods.MediaItem_Release(this.handle); + this.handle = uint.MaxValue; + }*/ } - return this.hashcode; } private void ThrowIfDisposed() @@ -122,6 +112,40 @@ public final class Artist implements IEquatable, IDisposable } } + @Override + public boolean equals(Object obj) + { + return (obj != null && obj instanceof Artist) ? this.Equals((Artist)obj) : false; + } + + @Override + public boolean Equals(Artist other) + { + // TODO Auto-generated method stub + return false; + } + + protected void finalize() + { + this.Dispose(false); + } + + /** + * Gets the hash code for this instance. + */ + @Override + public int hashCode() + { + ThrowIfDisposed(); + + if (this.hashcode == -1) + { + this.hashcode = this.name.hashCode(); + } + + return this.hashcode; + } + /** * Returns a String representation of the Artist. */ @@ -131,9 +155,4 @@ public final class Artist implements IEquatable, IDisposable ThrowIfDisposed(); return this.name; } - - static - { - Empty = new Artist(); - } } diff --git a/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/Media/MediaPlayer.java b/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/Media/MediaPlayer.java index b5027f8..bdc3146 100644 --- a/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/Media/MediaPlayer.java +++ b/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/Media/MediaPlayer.java @@ -13,6 +13,23 @@ public class MediaPlayer private static boolean shuffle; private static MediaQueue queue; + /** + * Gets the media playback queue, MediaQueue. + */ + public static MediaQueue getQueue() + { + return queue; + } + + /** + * Gets the media playback state. + */ + public MediaState getState() + { + // TODO Auto-generated method stub + throw new NotImplementedException(); + } + /** * Raised when the active song changes due to active playback or due to explicit calls to the MoveNext or MovePrevious methods. */ @@ -23,6 +40,17 @@ public class MediaPlayer */ public static final Event MediaStateChanged = new Event(); + static + { + repeat = false; + shuffle = false; + queue = new MediaQueue(); + } + + private MediaPlayer() + { + } + /** * */ @@ -32,6 +60,8 @@ public class MediaPlayer { ActiveSongChanged.raise(null, EventArgs.Empty); } + + // TODO: implement } /** @@ -43,6 +73,8 @@ public class MediaPlayer { ActiveSongChanged.raise(null, EventArgs.Empty); } + + // TODO: implement } /** @@ -54,6 +86,8 @@ public class MediaPlayer { MediaStateChanged.raise(null, EventArgs.Empty); } + + // TODO: implement } /** @@ -62,7 +96,8 @@ public class MediaPlayer */ public static void Play(Song song) { - + // TODO Auto-generated method stub + throw new NotImplementedException(); } /** @@ -71,7 +106,8 @@ public class MediaPlayer */ public static void Play(SongCollection songs) { - + // TODO Auto-generated method stub + throw new NotImplementedException(); } /** @@ -81,7 +117,8 @@ public class MediaPlayer */ public static void Play(SongCollection songs, int index) { - + // TODO Auto-generated method stub + throw new NotImplementedException(); } /** @@ -93,6 +130,8 @@ public class MediaPlayer { MediaStateChanged.raise(null, EventArgs.Empty); } + + // TODO: implement } /** @@ -104,12 +143,7 @@ public class MediaPlayer { MediaStateChanged.raise(null, EventArgs.Empty); } - } - static - { - repeat = false; - shuffle = false; - queue = new MediaQueue(); + // TODO: implement } } diff --git a/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/Media/Song.java b/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/Media/Song.java index ac29249..4333a7d 100644 --- a/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/Media/Song.java +++ b/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/Media/Song.java @@ -13,9 +13,32 @@ public final class Song implements IEquatable, IDisposable private Artist artist; private boolean isDisposed; + /** + * Gets the Album on which the Song appears. + */ + public Album getAlbum() + { + return this.album; + } + + /** + * Gets the Artist of the Song. + */ + public Artist getArtist() + { + return this.artist; + } + + /** + * Gets a value indicating whether the object is disposed. + */ + public boolean IsDisposed() + { + return this.isDisposed; + } + private Song() { - } Song(String name, String fileName, int duration) @@ -43,7 +66,7 @@ public final class Song implements IEquatable, IDisposable @Override public boolean equals(Object obj) { - return (obj instanceof Song) ? Equals((Song)obj) : false; + return (obj != null && obj instanceof Song) ? this.Equals((Song)obj) : false; } /** @@ -75,6 +98,7 @@ public final class Song implements IEquatable, IDisposable */ public static Song FromUri(String name, Uri uri) { + // TODO Auto-generated method stub throw new NotImplementedException(); } @@ -85,6 +109,7 @@ public final class Song implements IEquatable, IDisposable @Override public int hashCode() { + // TODO Auto-generated method stub throw new NotImplementedException(); } @@ -102,6 +127,7 @@ public final class Song implements IEquatable, IDisposable @Override public String toString() { + // TODO Auto-generated method stub throw new NotImplementedException(); } } diff --git a/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/Plane.java b/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/Plane.java index d6c1483..1130341 100644 --- a/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/Plane.java +++ b/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/Plane.java @@ -18,477 +18,401 @@ public final class Plane extends ValueType implements IEquatable /** * The distance of the Plane along its normal from the origin. */ - public float D; - - /** - * Creates a new instance of Plane. - * - * @param a - * X component of the normal defining the Plane. - * - * @param b - * Y component of the normal defining the Plane. - * - * @param c - * Z component of the normal defining the Plane. - * - * @param d - * Distance of the Plane along its normal from the origin. - */ - public Plane(float a, float b, float c, float d) - { - this.Normal = new Vector3(a, b, c); - this.D = d; - } + public float D; - /** - * Creates a new instance of Plane. - * - * @param normal - * The normal vector to the Plane. - * - * @param d - * The Plane's distance along its normal from the origin. - */ - public Plane(Vector3 normal, float d) - { - this.Normal = new Vector3(normal.X, normal.Y, normal.Z); - this.D = d; - } + /** + * Creates a new instance of Plane. + * + * @param a + * X component of the normal defining the Plane. + * + * @param b + * Y component of the normal defining the Plane. + * + * @param c + * Z component of the normal defining the Plane. + * + * @param d + * Distance of the Plane along its normal from the origin. + */ + public Plane(float a, float b, float c, float d) + { + this.Normal = new Vector3(a, b, c); + this.D = d; + } - /** - * Creates a new instance of Plane. - * - * @param value - * Vector4 with X, Y, and Z components defining the normal of the Plane. The W component defines the distance of the Plane along the normal from the origin. - */ - public Plane(Vector4 value) - { - this.Normal = new Vector3(value.X, value.Y, value.Z); - this.D = value.W; - } + /** + * Creates a new instance of Plane. + * + * @param normal + * The normal vector to the Plane. + * + * @param d + * The Plane's distance along its normal from the origin. + */ + public Plane(Vector3 normal, float d) + { + this.Normal = new Vector3(normal.X, normal.Y, normal.Z); + this.D = d; + } - /** - * Creates a new instance of Plane. - * - * @param point1 - * One point of a triangle defining the Plane. - * - * @param point2 - * One point of a triangle defining the Plane. - * - * @param point3 - * One point of a triangle defining the Plane. - */ - public Plane(Vector3 point1, Vector3 point2, Vector3 point3) - { - float num10 = point2.X - point1.X; - float num9 = point2.Y - point1.Y; - float num8 = point2.Z - point1.Z; - float num7 = point3.X - point1.X; - float num6 = point3.Y - point1.Y; - float num5 = point3.Z - point1.Z; - float num4 = (num9 * num5) - (num8 * num6); - float num3 = (num8 * num7) - (num10 * num5); - float num2 = (num10 * num6) - (num9 * num7); - float num11 = ((num4 * num4) + (num3 * num3)) + (num2 * num2); - float num = 1f / ((float) Math.sqrt((double) num11)); - this.Normal.X = num4 * num; - this.Normal.Y = num3 * num; - this.Normal.Z = num2 * num; - this.D = -(((this.Normal.X * point1.X) + (this.Normal.Y * point1.Y)) + (this.Normal.Z * point1.Z)); - } - - /** - * Creates a new instance of Plane. - */ - public Plane() - { + /** + * Creates a new instance of Plane. + * + * @param value + * Vector4 with X, Y, and Z components defining the normal of the Plane. The W component defines the distance of the Plane along the normal from the origin. + */ + public Plane(Vector4 value) + { + this.Normal = new Vector3(value.X, value.Y, value.Z); + this.D = value.W; + } + + /** + * Creates a new instance of Plane. + * + * @param point1 + * One point of a triangle defining the Plane. + * + * @param point2 + * One point of a triangle defining the Plane. + * + * @param point3 + * One point of a triangle defining the Plane. + */ + public Plane(Vector3 point1, Vector3 point2, Vector3 point3) + { + float num10 = point2.X - point1.X; + float num9 = point2.Y - point1.Y; + float num8 = point2.Z - point1.Z; + float num7 = point3.X - point1.X; + float num6 = point3.Y - point1.Y; + float num5 = point3.Z - point1.Z; + float num4 = (num9 * num5) - (num8 * num6); + float num3 = (num8 * num7) - (num10 * num5); + float num2 = (num10 * num6) - (num9 * num7); + float num11 = ((num4 * num4) + (num3 * num3)) + (num2 * num2); + float num = 1f / ((float) Math.sqrt((double) num11)); + this.Normal.X = num4 * num; + this.Normal.Y = num3 * num; + this.Normal.Z = num2 * num; + this.D = -(((this.Normal.X * point1.X) + (this.Normal.Y * point1.Y)) + (this.Normal.Z * point1.Z)); + } + + /** + * Creates a new instance of Plane. + */ + public Plane() + { Normal = new Vector3(); D = 0; } /** - * Calculates the dot product of a specified Vector4 and this Plane. - * - * @param value - * The Vector4 to multiply this Plane by. - */ - 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)); - } - - /** - * Calculates the dot product of a specified Vector4 and this Plane. - * - * @param value - * The Vector4 to multiply this Plane by. - * - * @param result - * [OutAttribute] The dot product of the specified Vector4 and this Plane. - */ - public void Dot(Vector4 value, float result) - { - result = (((this.Normal.X * value.X) + (this.Normal.Y * value.Y)) + (this.Normal.Z * value.Z)) + (this.D * value.W); - } - - /** - * Returns the dot product of a specified Vector3 and the Normal vector of this Plane plus the distance (D) value of the Plane. - * - * @param value - * The Vector3 to multiply by. - */ - public float DotCoordinate(Vector3 value) - { - return ((((this.Normal.X * value.X) + (this.Normal.Y * value.Y)) + (this.Normal.Z * value.Z)) + this.D); - } - - /** - * Returns the dot product of a specified Vector3 and the Normal vector of this Plane plus the distance (D) value of the Plane. - * - * @param value - * The Vector3 to multiply by. - * - * @param result - * [OutAttribute] The resulting value. - */ - public void DotCoordinate(Vector3 value, float result) - { - result = (((this.Normal.X * value.X) + (this.Normal.Y * value.Y)) + (this.Normal.Z * value.Z)) + this.D; - } - - /** - * Returns the dot product of a specified Vector3 and the Normal vector of this Plane. - * - * @param value - * The Vector3 to multiply by. - */ - public float DotNormal(Vector3 value) - { - return (((this.Normal.X * value.X) + (this.Normal.Y * value.Y)) + (this.Normal.Z * value.Z)); - } - - /** - * Returns the dot product of a specified Vector3 and the Normal vector of this Plane. - * - * @param value - * The Vector3 to multiply by. - * - * @param result - * [OutAttribute] The resulting dot product. - */ - public void DotNormal(Vector3 value, float result) - { - result = ((this.Normal.X * value.X) + (this.Normal.Y * value.Y)) + (this.Normal.Z * value.Z); - } - - /** - * Determines whether the specified Object is equal to the Plane. - * - * @param obj - * The Object to compare with the current Plane. - */ - @Override - public boolean equals(Object obj) - { - return (obj != null && obj instanceof Plane) ? this.Equals((Plane)obj) : false; - } - - /** - * Determines whether the specified Plane is equal to the Plane. - * - * @param other - * The Plane to compare with the current Plane. - */ - public boolean Equals(Plane other) - { - return (this.Normal.Equals(other.Normal) && this.D == other.D); - } - - /** - * Gets the hash code for this object. - */ - @Override - public int hashCode() - { - return (this.Normal.hashCode() ^ (int)this.D); - } - - /** - * Checks whether the current Plane intersects a specified BoundingBox. - * - * @param box - * The BoundingBox to test for intersection with. - */ - public PlaneIntersectionType Intersects(BoundingBox box) - { - PlaneIntersectionType result = PlaneIntersectionType.Front; - Intersects(box, result); - return result; - } + * Calculates the dot product of a specified Vector4 and this Plane. + * + * @param value + * The Vector4 to multiply this Plane by. + */ + 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)); + } - /** - * Checks whether the current Plane intersects a specified BoundingSphere. - * - * @param sphere - * The BoundingSphere to check for intersection with. - */ - public PlaneIntersectionType Intersects(BoundingSphere sphere) - { - float num2 = ((sphere.Center.X * this.Normal.X) + (sphere.Center.Y * this.Normal.Y)) + (sphere.Center.Z * this.Normal.Z); - float num = num2 + this.D; - if (num > sphere.Radius) - { - return PlaneIntersectionType.Front; - } - if (num < -sphere.Radius) - { - return PlaneIntersectionType.Back; - } - return PlaneIntersectionType.Intersecting; - } - - /** - * Checks whether the current Plane intersects a BoundingBox. - * - * @param box - * The BoundingBox to check for intersection with. - * - * @param result - * [OutAttribute] An enumeration indicating whether the Plane intersects the BoundingBox. - */ - public void Intersects(BoundingBox box, PlaneIntersectionType result) - { - Vector3 vector = Vector3.Zero; - Vector3 vector2 = Vector3.Zero; - vector2.X = (this.Normal.X >= 0f) ? box.Min.X : box.Max.X; - vector2.Y = (this.Normal.Y >= 0f) ? box.Min.Y : box.Max.Y; - vector2.Z = (this.Normal.Z >= 0f) ? box.Min.Z : box.Max.Z; - vector.X = (this.Normal.X >= 0f) ? box.Max.X : box.Min.X; - vector.Y = (this.Normal.Y >= 0f) ? box.Max.Y : box.Min.Y; - vector.Z = (this.Normal.Z >= 0f) ? box.Max.Z : box.Min.Z; - float num = ((this.Normal.X * vector2.X) + (this.Normal.Y * vector2.Y)) + (this.Normal.Z * vector2.Z); - if ((num + this.D) > 0f) - { - result = PlaneIntersectionType.Front; - } - else - { - num = ((this.Normal.X * vector.X) + (this.Normal.Y * vector.Y)) + (this.Normal.Z * vector.Z); - if ((num + this.D) < 0f) - { - result = PlaneIntersectionType.Back; - } - else - { - result = PlaneIntersectionType.Intersecting; - } - } - } - - /** - * Checks whether the current Plane intersects a BoundingSphere. - * - * @param sphere - * The BoundingSphere to check for intersection with. - * - * @param result - * [OutAttribute] An enumeration indicating whether the Plane intersects the BoundingSphere. - */ - public void Intersects(BoundingSphere sphere, PlaneIntersectionType result) - { - float num2 = ((sphere.Center.X * this.Normal.X) + (sphere.Center.Y * this.Normal.Y)) + (sphere.Center.Z * this.Normal.Z); - float num = num2 + this.D; - if (num > sphere.Radius) - { - result = PlaneIntersectionType.Front; - } - else if (num < -sphere.Radius) - { - result = PlaneIntersectionType.Back; - } - else - { - result = PlaneIntersectionType.Intersecting; - } - } - - /** - * Changes the coefficients of the Normal vector of this Plane to make it of unit length. - */ - public void Normalize() - { - float num2 = ((this.Normal.X * this.Normal.X) + (this.Normal.Y * this.Normal.Y)) + (this.Normal.Z * this.Normal.Z); - if (Math.abs((float) (num2 - 1f)) >= 1.192093E-07f) - { - float num = 1f / ((float) Math.sqrt((double) num2)); - this.Normal.X *= num; - this.Normal.Y *= num; - this.Normal.Z *= num; - this.D *= num; - } - } - - /** - * Changes the coefficients of the Normal vector of a Plane to make it of unit length. - * - * @param value - * The Plane to normalize. - */ - public static Plane Normalize(Plane value) - { - Plane plane = new Plane(); - float num2 = ((value.Normal.X * value.Normal.X) + (value.Normal.Y * value.Normal.Y)) + (value.Normal.Z * value.Normal.Z); - if (Math.abs((float) (num2 - 1f)) < 1.192093E-07f) - { - plane.Normal = value.Normal; - plane.D = value.D; - return plane; - } - float num = 1f / ((float) Math.sqrt((double) num2)); - plane.Normal.X = value.Normal.X * num; - plane.Normal.Y = value.Normal.Y * num; - plane.Normal.Z = value.Normal.Z * num; - plane.D = value.D * num; - return plane; - } - - /** - * Changes the coefficients of the Normal vector of a Plane to make it of unit length. - * - * @param value - * The Plane to normalize. - * - * @param result - * [OutAttribute] An existing plane Plane filled in with a normalized version of the specified plane. - */ - public static void Normalize(Plane value, Plane result) - { - float num2 = ((value.Normal.X * value.Normal.X) + (value.Normal.Y * value.Normal.Y)) + (value.Normal.Z * value.Normal.Z); - if (Math.abs((float) (num2 - 1f)) < 1.192093E-07f) - { - result.Normal = value.Normal; - result.D = value.D; - } - else - { - float num = 1f / ((float) Math.sqrt((double) num2)); - result.Normal.X = value.Normal.X * num; - result.Normal.Y = value.Normal.Y * num; - result.Normal.Z = value.Normal.Z * num; - result.D = value.D * num; - } - } - - /** - * Returns a String that represents the current Plane. - */ - @Override - public String toString() - { - return String.format(Locale.getDefault(), "{Normal:%s D:%f}", this.Normal, this.D); - } - - /** - * Transforms a normalized Plane by a Matrix. - * - * @param plane - * The normalized Plane to transform. This Plane must already be normalized, so that its Normal vector is of unit length, before this method is called. - * - * @param matrix - * The transform Matrix to apply to the Plane. - */ - public static Plane Transform(Plane plane, Matrix matrix) - { - Plane result = new Plane(); - Transform(plane, matrix, result); - return result; - } - - /** - * Transforms a normalized Plane by a Quaternion rotation. - * - * @param plane - * The normalized Plane to transform. This Plane must already be normalized, so that its Normal vector is of unit length, before this method is called. - * - * @param rotation - * The Quaternion rotation to apply to the Plane. - */ - public static Plane Transform(Plane plane, Quaternion rotation) - { - Plane result = new Plane(); - Transform(plane, rotation, result); - return result; - } - - /** - * Transforms a normalized Plane by a Matrix. - * - * @param plane - * The normalized Plane to transform. This Plane must already be normalized, so that its Normal vector is of unit length, before this method is called. - * - * @param matrix - * The transform Matrix to apply to the Plane. - * - * @param result - * [OutAttribute] An existing Plane filled in with the results of applying the transform. - */ - public static void Transform(Plane plane, Matrix matrix, Plane result) - { - Matrix matrix2 = new Matrix(); - Matrix.Invert(matrix, matrix2); - float x = plane.Normal.X; - float y = plane.Normal.Y; - float z = plane.Normal.Z; - float d = plane.D; - result.Normal.X = (((x * matrix2.M11) + (y * matrix2.M12)) + (z * matrix2.M13)) + (d * matrix2.M14); - result.Normal.Y = (((x * matrix2.M21) + (y * matrix2.M22)) + (z * matrix2.M23)) + (d * matrix2.M24); - result.Normal.Z = (((x * matrix2.M31) + (y * matrix2.M32)) + (z * matrix2.M33)) + (d * matrix2.M34); - result.D = (((x * matrix2.M41) + (y * matrix2.M42)) + (z * matrix2.M43)) + (d * matrix2.M44); - } - - /** - * Transforms a normalized Plane by a Quaternion rotation. - * - * @param plane - * The normalized Plane to transform. This Plane must already be normalized, so that its Normal vector is of unit length, before this method is called. - * - * @param rotation - * The Quaternion rotation to apply to the Plane. - * - * @param result - * [OutAttribute] An existing Plane filled in with the results of applying the rotation. - */ - public static void Transform(Plane plane, Quaternion rotation, Plane result) - { - float num15 = rotation.X + rotation.X; - float num5 = rotation.Y + rotation.Y; - float num = rotation.Z + rotation.Z; - float num14 = rotation.W * num15; - float num13 = rotation.W * num5; - float num12 = rotation.W * num; - float num11 = rotation.X * num15; - float num10 = rotation.X * num5; - float num9 = rotation.X * num; - float num8 = rotation.Y * num5; - float num7 = rotation.Y * num; - float num6 = rotation.Z * num; - float num24 = (1f - num8) - num6; - float num23 = num10 - num12; - float num22 = num9 + num13; - float num21 = num10 + num12; - float num20 = (1f - num11) - num6; - float num19 = num7 - num14; - float num18 = num9 - num13; - float num17 = num7 + num14; - float num16 = (1f - num11) - num8; - float x = plane.Normal.X; - float y = plane.Normal.Y; - float z = plane.Normal.Z; - result.Normal.X = ((x * num24) + (y * num23)) + (z * num22); - result.Normal.Y = ((x * num21) + (y * num20)) + (z * num19); - result.Normal.Z = ((x * num18) + (y * num17)) + (z * num16); - result.D = plane.D; - } + /** + * Returns the dot product of a specified Vector3 and the Normal vector of this Plane plus the distance (D) value of the Plane. + * + * @param value + * The Vector3 to multiply by. + */ + public float DotCoordinate(Vector3 value) + { + return ((((this.Normal.X * value.X) + (this.Normal.Y * value.Y)) + (this.Normal.Z * value.Z)) + this.D); + } + + /** + * Returns the dot product of a specified Vector3 and the Normal vector of this Plane. + * + * @param value + * The Vector3 to multiply by. + */ + public float DotNormal(Vector3 value) + { + return (((this.Normal.X * value.X) + (this.Normal.Y * value.Y)) + (this.Normal.Z * value.Z)); + } + + /** + * Determines whether the specified Object is equal to the Plane. + * + * @param obj + * The Object to compare with the current Plane. + */ + @Override + public boolean equals(Object obj) + { + return (obj != null && obj instanceof Plane) ? this.Equals((Plane)obj) : false; + } + + /** + * Determines whether the specified Plane is equal to the Plane. + * + * @param other + * The Plane to compare with the current Plane. + */ + public boolean Equals(Plane other) + { + return (this.Normal.Equals(other.Normal) && this.D == other.D); + } + + /** + * Gets the hash code for this object. + */ + @Override + public int hashCode() + { + return (this.Normal.hashCode() ^ (int)this.D); + } + + /** + * Checks whether the current Plane intersects a specified BoundingBox. + * + * @param box + * The BoundingBox to test for intersection with. + */ + public PlaneIntersectionType Intersects(BoundingBox box) + { + Vector3 vector = Vector3.Zero; + Vector3 vector2 = Vector3.Zero; + vector2.X = (this.Normal.X >= 0f) ? box.Min.X : box.Max.X; + vector2.Y = (this.Normal.Y >= 0f) ? box.Min.Y : box.Max.Y; + vector2.Z = (this.Normal.Z >= 0f) ? box.Min.Z : box.Max.Z; + vector.X = (this.Normal.X >= 0f) ? box.Max.X : box.Min.X; + vector.Y = (this.Normal.Y >= 0f) ? box.Max.Y : box.Min.Y; + vector.Z = (this.Normal.Z >= 0f) ? box.Max.Z : box.Min.Z; + float num = ((this.Normal.X * vector2.X) + (this.Normal.Y * vector2.Y)) + (this.Normal.Z * vector2.Z); + + if ((num + this.D) > 0f) + { + return PlaneIntersectionType.Front; + } + else + { + num = ((this.Normal.X * vector.X) + (this.Normal.Y * vector.Y)) + (this.Normal.Z * vector.Z); + + if ((num + this.D) < 0f) + { + return PlaneIntersectionType.Back; + } + else + { + return PlaneIntersectionType.Intersecting; + } + } + } + + /** + * Checks whether the current Plane intersects a specified BoundingSphere. + * + * @param sphere + * The BoundingSphere to check for intersection with. + */ + public PlaneIntersectionType Intersects(BoundingSphere sphere) + { + float num2 = ((sphere.Center.X * this.Normal.X) + (sphere.Center.Y * this.Normal.Y)) + (sphere.Center.Z * this.Normal.Z); + float num = num2 + this.D; + + if (num > sphere.Radius) + { + return PlaneIntersectionType.Front; + } + + if (num < -sphere.Radius) + { + return PlaneIntersectionType.Back; + } + + return PlaneIntersectionType.Intersecting; + } + + /** + * Changes the coefficients of the Normal vector of this Plane to make it of unit length. + */ + public void Normalize() + { + float num2 = ((this.Normal.X * this.Normal.X) + (this.Normal.Y * this.Normal.Y)) + (this.Normal.Z * this.Normal.Z); + + if (Math.abs((float) (num2 - 1f)) >= 1.192093E-07f) + { + float num = 1f / ((float) Math.sqrt((double) num2)); + this.Normal.X *= num; + this.Normal.Y *= num; + this.Normal.Z *= num; + this.D *= num; + } + } + + /** + * Changes the coefficients of the Normal vector of a Plane to make it of unit length. + * + * @param value + * The Plane to normalize. + */ + public static Plane Normalize(Plane value) + { + Plane plane = new Plane(); + float num2 = ((value.Normal.X * value.Normal.X) + (value.Normal.Y * value.Normal.Y)) + (value.Normal.Z * value.Normal.Z); + + if (Math.abs((float) (num2 - 1f)) < 1.192093E-07f) + { + plane.Normal = value.Normal; + plane.D = value.D; + return plane; + } + + float num = 1f / ((float) Math.sqrt((double) num2)); + plane.Normal.X = value.Normal.X * num; + plane.Normal.Y = value.Normal.Y * num; + plane.Normal.Z = value.Normal.Z * num; + plane.D = value.D * num; + return plane; + } + + /** + * Changes the coefficients of the Normal vector of a Plane to make it of unit length. + * + * @param value + * The Plane to normalize. + * + * @param result + * [OutAttribute] An existing plane Plane filled in with a normalized version of the specified plane. + */ + public static void Normalize(Plane value, Plane result) + { + float num2 = ((value.Normal.X * value.Normal.X) + (value.Normal.Y * value.Normal.Y)) + (value.Normal.Z * value.Normal.Z); + + if (Math.abs((float) (num2 - 1f)) < 1.192093E-07f) + { + result.Normal = value.Normal; + result.D = value.D; + } + else + { + float num = 1f / ((float) Math.sqrt((double) num2)); + result.Normal.X = value.Normal.X * num; + result.Normal.Y = value.Normal.Y * num; + result.Normal.Z = value.Normal.Z * num; + result.D = value.D * num; + } + } + + /** + * Returns a String that represents the current Plane. + */ + @Override + public String toString() + { + return String.format(Locale.getDefault(), "{Normal:%s D:%f}", this.Normal, this.D); + } + + /** + * Transforms a normalized Plane by a Matrix. + * + * @param plane + * The normalized Plane to transform. This Plane must already be normalized, so that its Normal vector is of unit length, before this method is called. + * + * @param matrix + * The transform Matrix to apply to the Plane. + */ + public static Plane Transform(Plane plane, Matrix matrix) + { + Plane result = new Plane(); + Transform(plane, matrix, result); + return result; + } + + /** + * Transforms a normalized Plane by a Quaternion rotation. + * + * @param plane + * The normalized Plane to transform. This Plane must already be normalized, so that its Normal vector is of unit length, before this method is called. + * + * @param rotation + * The Quaternion rotation to apply to the Plane. + */ + public static Plane Transform(Plane plane, Quaternion rotation) + { + Plane result = new Plane(); + Transform(plane, rotation, result); + return result; + } + + /** + * Transforms a normalized Plane by a Matrix. + * + * @param plane + * The normalized Plane to transform. This Plane must already be normalized, so that its Normal vector is of unit length, before this method is called. + * + * @param matrix + * The transform Matrix to apply to the Plane. + * + * @param result + * [OutAttribute] An existing Plane filled in with the results of applying the transform. + */ + public static void Transform(Plane plane, Matrix matrix, Plane result) + { + Matrix matrix2 = new Matrix(); + Matrix.Invert(matrix, matrix2); + float x = plane.Normal.X; + float y = plane.Normal.Y; + float z = plane.Normal.Z; + float d = plane.D; + result.Normal.X = (((x * matrix2.M11) + (y * matrix2.M12)) + (z * matrix2.M13)) + (d * matrix2.M14); + result.Normal.Y = (((x * matrix2.M21) + (y * matrix2.M22)) + (z * matrix2.M23)) + (d * matrix2.M24); + result.Normal.Z = (((x * matrix2.M31) + (y * matrix2.M32)) + (z * matrix2.M33)) + (d * matrix2.M34); + result.D = (((x * matrix2.M41) + (y * matrix2.M42)) + (z * matrix2.M43)) + (d * matrix2.M44); + } + + /** + * Transforms a normalized Plane by a Quaternion rotation. + * + * @param plane + * The normalized Plane to transform. This Plane must already be normalized, so that its Normal vector is of unit length, before this method is called. + * + * @param rotation + * The Quaternion rotation to apply to the Plane. + * + * @param result + * [OutAttribute] An existing Plane filled in with the results of applying the rotation. + */ + public static void Transform(Plane plane, Quaternion rotation, Plane result) + { + float num15 = rotation.X + rotation.X; + float num5 = rotation.Y + rotation.Y; + float num = rotation.Z + rotation.Z; + float num14 = rotation.W * num15; + float num13 = rotation.W * num5; + float num12 = rotation.W * num; + float num11 = rotation.X * num15; + float num10 = rotation.X * num5; + float num9 = rotation.X * num; + float num8 = rotation.Y * num5; + float num7 = rotation.Y * num; + float num6 = rotation.Z * num; + float num24 = (1f - num8) - num6; + float num23 = num10 - num12; + float num22 = num9 + num13; + float num21 = num10 + num12; + float num20 = (1f - num11) - num6; + float num19 = num7 - num14; + float num18 = num9 - num13; + float num17 = num7 + num14; + float num16 = (1f - num11) - num8; + float x = plane.Normal.X; + float y = plane.Normal.Y; + float z = plane.Normal.Z; + result.Normal.X = ((x * num24) + (y * num23)) + (z * num22); + result.Normal.Y = ((x * num21) + (y * num20)) + (z * num19); + result.Normal.Z = ((x * num18) + (y * num17)) + (z * num16); + result.D = plane.D; + } } diff --git a/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/Ray.java b/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/Ray.java index b3d063f..e96d87c 100644 --- a/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/Ray.java +++ b/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/Ray.java @@ -19,7 +19,7 @@ public final class Ray extends ValueType implements IEquatable * Unit vector specifying the direction the Ray is pointing. */ public Vector3 Direction; - + /** * Creates a new instance of Ray. * @@ -31,10 +31,10 @@ public final class Ray extends ValueType implements IEquatable */ public Ray(Vector3 position, Vector3 direction) { - this.Position = position; - this.Direction = direction; + this.Position = position; + this.Direction = direction; } - + /** * Creates a new instance of Ray. */ @@ -43,7 +43,7 @@ public final class Ray extends ValueType implements IEquatable this.Position = Vector3.Zero; this.Direction = Vector3.Zero; } - + /** * Determines whether two instances of Ray are equal. * @@ -58,7 +58,7 @@ public final class Ray extends ValueType implements IEquatable { return (obj != null && obj instanceof Ray) ? this.Equals((Ray)obj) : false; } - + /** * Determines whether the specified Ray is equal to the current Ray. * @@ -72,7 +72,7 @@ public final class Ray extends ValueType implements IEquatable { return (this.Position.Equals(other.Position) && this.Direction.Equals(other.Direction)); } - + /** * Gets the hash code for this instance. * @@ -82,9 +82,9 @@ public final class Ray extends ValueType implements IEquatable @Override public int hashCode() { - return (this.Position.hashCode() + this.Direction.hashCode()); + return this.Position.hashCode() ^ this.Direction.hashCode(); } - + /** * Checks whether the Ray intersects a specified BoundingBox. * @@ -96,9 +96,9 @@ public final class Ray extends ValueType implements IEquatable */ public Float Intersects(BoundingBox box) { - return box.Intersects(this); + return box.Intersects(this); } - + /** * Checks whether the Ray intersects a specified BoundingSphere. * @@ -110,29 +110,35 @@ public final class Ray extends ValueType implements IEquatable */ public Float Intersects(BoundingSphere sphere) { - float num5 = sphere.Center.X - this.Position.X; - float num4 = sphere.Center.Y - this.Position.Y; - float num3 = sphere.Center.Z - this.Position.Z; - float num7 = ((num5 * num5) + (num4 * num4)) + (num3 * num3); - float num2 = sphere.Radius * sphere.Radius; - if (num7 <= num2) - { - return 0f; - } - float num = ((num5 * this.Direction.X) + (num4 * this.Direction.Y)) + (num3 * this.Direction.Z); - if (num < 0f) - { - return null; - } - float num6 = num7 - (num * num); - if (num6 > num2) - { - return null; - } - float num8 = (float) Math.sqrt((double) (num2 - num6)); - return new Float(num - num8); + float num5 = sphere.Center.X - this.Position.X; + float num4 = sphere.Center.Y - this.Position.Y; + float num3 = sphere.Center.Z - this.Position.Z; + float num7 = ((num5 * num5) + (num4 * num4)) + (num3 * num3); + float num2 = sphere.Radius * sphere.Radius; + + if (num7 <= num2) + { + return 0f; + } + + float num = ((num5 * this.Direction.X) + (num4 * this.Direction.Y)) + (num3 * this.Direction.Z); + + if (num < 0f) + { + return null; + } + + float num6 = num7 - (num * num); + + if (num6 > num2) + { + return null; + } + float num8 = (float) Math.sqrt((double) (num2 - num6)); + + return new Float(num - num8); } - + /** * Determines whether this Ray intersects a specified Plane. * @@ -144,107 +150,28 @@ public final class Ray extends ValueType implements IEquatable */ public Float Intersects(Plane plane) { - float num2 = ((plane.Normal.X * this.Direction.X) + (plane.Normal.Y * this.Direction.Y)) + (plane.Normal.Z * this.Direction.Z); - if (Math.abs(num2) < 1E-05f) - { - return null; - } - float num3 = ((plane.Normal.X * this.Position.X) + (plane.Normal.Y * this.Position.Y)) + (plane.Normal.Z * this.Position.Z); - float num = (-plane.D - num3) / num2; - if (num < 0f) - { - if (num < -1E-05f) - { - return null; - } - num = 0f; - } - return new Float(num); + float den = Vector3.Dot(Direction, plane.Normal); + + if (Math.abs(den) < 0.00001f) + { + return null; + } + + float num = (-plane.D - Vector3.Dot(plane.Normal, Position)) / den; + + if (num < 0f) + { + if (num < -0.00001f) + { + return null; + } + + num = 0f; + } + + return new Float(num); } - - /** - * Checks whether the current Ray intersects a BoundingBox. - * - * @param box - * The BoundingBox to check for intersection with. - * - * @param result - * [OutAttribute] Distance at which the ray intersects the BoundingBox or null if there is no intersection. - */ - public void Intersects(BoundingBox box, Float result) - { - box.Intersects(this, result); - } - - /** - * Checks whether the current Ray intersects a BoundingSphere. - * - * @param sphere - * The BoundingSphere to check for intersection with. - * - * @param result - * [OutAttribute] Distance at which the ray intersects the BoundingSphere or null if there is no intersection. - */ - public void Intersects(BoundingSphere sphere, Float result) - { - float num5 = sphere.Center.X - this.Position.X; - float num4 = sphere.Center.Y - this.Position.Y; - float num3 = sphere.Center.Z - this.Position.Z; - float num7 = ((num5 * num5) + (num4 * num4)) + (num3 * num3); - float num2 = sphere.Radius * sphere.Radius; - if (num7 <= num2) - { - result = 0f; - } - else - { - result = 0f; - float num = ((num5 * this.Direction.X) + (num4 * this.Direction.Y)) + (num3 * this.Direction.Z); - if (num >= 0f) - { - float num6 = num7 - (num * num); - if (num6 <= num2) - { - float num8 = (float) Math.sqrt((double) (num2 - num6)); - result = new Float(num - num8); - } - } - } - } - - /** - * Determines whether this Ray intersects a specified Plane. - * - * @param plane - * The Plane with which to calculate this Ray's intersection. - * - * @param result - * [OutAttribute] The distance at which this Ray intersects the specified Plane, or null if there is no intersection. - */ - public void Intersects(Plane plane, Float result) - { - float num2 = ((plane.Normal.X * this.Direction.X) + (plane.Normal.Y * this.Direction.Y)) + (plane.Normal.Z * this.Direction.Z); - if (Math.abs(num2) < 1E-05f) - { - result = 0f; - } - else - { - float num3 = ((plane.Normal.X * this.Position.X) + (plane.Normal.Y * this.Position.Y)) + (plane.Normal.Z * this.Position.Z); - float num = (-plane.D - num3) / num2; - if (num < 0f) - { - if (num < -1E-05f) - { - result = 0f; - return; - } - result = 0f; - } - result = new Float(num); - } - } - + /** * Returns a String that represents the current Ray. * @@ -254,6 +181,6 @@ public final class Ray extends ValueType implements IEquatable @Override public String toString() { - return String.format(Locale.getDefault(), "{Position:%s Direction:%s}", this.Position, this.Direction); + return String.format(Locale.getDefault(), "{Position:%s Direction:%s}", this.Position, this.Direction); } } diff --git a/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/Storage/StorageContainer.java b/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/Storage/StorageContainer.java index bee54e7..75d8f02 100644 --- a/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/Storage/StorageContainer.java +++ b/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/Storage/StorageContainer.java @@ -14,12 +14,12 @@ public class StorageContainer implements IDisposable String displayName; private boolean isDisposed; StorageDevice parent; - + /** * Occurs when Dispose is called or when this object is finalized and collected by the garbage collector of the Microsoft .NET common language runtime. */ public final Event Disposing = new Event(); - + /** * Gets the name of the title. */ @@ -27,7 +27,7 @@ public class StorageContainer implements IDisposable { return displayName; } - + /** * Gets a value that indicates whether the object is disposed. */ @@ -35,7 +35,7 @@ public class StorageContainer implements IDisposable { return isDisposed; } - + /** * Gets the StorageDevice that holds the files in this container. */ @@ -43,7 +43,7 @@ public class StorageContainer implements IDisposable { return parent; } - + /** * Allows this object to attempt to free resources and perform other cleanup operations before garbage collection reclaims the object. */ @@ -54,18 +54,18 @@ public class StorageContainer implements IDisposable // TODO: implement } } - + /** * Creates a new directory in the StorageContainer scope. * * @param directory - * The relative path of the directory to delete within the StorageContainer scope. + * The relative path of the directory to create within the StorageContainer scope. */ public void CreateDirectory(String directory) { // TODO: implement } - + /** * Creates a file at a specified path in the StorageContainer. * @@ -76,7 +76,7 @@ public class StorageContainer implements IDisposable { throw new NotImplementedException(); } - + /** * Deletes a directory in the StorageContainer scope. * @@ -87,7 +87,7 @@ public class StorageContainer implements IDisposable { // TODO: implement } - + /** * Deletes a file in the StorageContainer. * @@ -98,7 +98,7 @@ public class StorageContainer implements IDisposable { // TODO: implement } - + /** * Determines whether the specified path refers to an existing directory in the StorageContainer. * @@ -109,7 +109,7 @@ public class StorageContainer implements IDisposable { throw new NotImplementedException(); } - + /** * Immediately releases the unmanaged resources used by this object. */ @@ -119,7 +119,7 @@ public class StorageContainer implements IDisposable this.isDisposed = true; } - + /** * Determines whether the specified path refers to an existing file in the StorageContainer. * @@ -130,7 +130,7 @@ public class StorageContainer implements IDisposable { throw new NotImplementedException(); } - + /** * Enumerates the directories in the root of a StorageContainer that conform to a search pattern. * @@ -141,7 +141,7 @@ public class StorageContainer implements IDisposable { throw new NotImplementedException(); } - + /** * Enumerates the directories in the root of a StorageContainer. */ @@ -149,7 +149,7 @@ public class StorageContainer implements IDisposable { return this.GetDirectoryNames("*"); } - + /** * Enumerates files in the root directory of a StorageContainer that match a given pattern. * @@ -160,7 +160,7 @@ public class StorageContainer implements IDisposable { throw new NotImplementedException(); } - + /** * Enumerates files in the root directory of a StorageContainer. */ @@ -168,6 +168,4 @@ public class StorageContainer implements IDisposable { return this.GetFileNames("*"); } - - } diff --git a/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/Storage/StorageDevice.java b/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/Storage/StorageDevice.java index ffb5f61..d2d3c6a 100644 --- a/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/Storage/StorageDevice.java +++ b/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/Storage/StorageDevice.java @@ -144,7 +144,7 @@ public final class StorageDevice */ public void DeleteContainer(String titleName) { - // TODO: implement + throw new NotImplementedException(); } /** diff --git a/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/Storage/StorageDeviceAsyncResult.java b/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/Storage/StorageDeviceAsyncResult.java new file mode 100644 index 0000000..ab7f2eb --- /dev/null +++ b/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/Storage/StorageDeviceAsyncResult.java @@ -0,0 +1,27 @@ +package Microsoft.Xna.Framework.Storage; + +import System.*; + +final class StorageDeviceAsyncResult implements IAsyncResult +{ + @Override + public Object AsyncState() + { + // TODO Auto-generated method stub + return null; + } + + @Override + public boolean CompletedSynchronously() + { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean IsCompleted() + { + // TODO Auto-generated method stub + return false; + } +} diff --git a/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/TitleContainer.java b/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/TitleContainer.java index 5c7f77a..8d08a84 100644 --- a/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/TitleContainer.java +++ b/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/TitleContainer.java @@ -50,6 +50,7 @@ public class TitleContainer } int startIndex = 1; + while(startIndex < path.length()) { startIndex = path.indexOf("\\..\\", startIndex); diff --git a/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/Vector2.java b/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/Vector2.java index 9c56d5c..5363e6d 100644 --- a/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/Vector2.java +++ b/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/Vector2.java @@ -35,7 +35,7 @@ public final class Vector2 extends ValueType implements IEquatable * Returns a Vector2 with all of its components set to zero. */ public static final Vector2 Zero = new Vector2(0f, 0f); - + /** * Initializes a new instance of Vector2. * @@ -50,7 +50,7 @@ public final class Vector2 extends ValueType implements IEquatable this.X = x; this.Y = y; } - + /** * Initializes a new instance of Vector2. * @@ -61,7 +61,7 @@ public final class Vector2 extends ValueType implements IEquatable { this.X = this.Y = value; } - + /** * Initializes a new instance of Vector2. */ @@ -69,7 +69,7 @@ public final class Vector2 extends ValueType implements IEquatable { this.X = this.Y = 0f; } - + /** * Adds the specified Vector2 to the current Vector2. * @@ -80,7 +80,7 @@ public final class Vector2 extends ValueType implements IEquatable { Add(this, other, this); } - + /** * Adds two vectors. * @@ -92,12 +92,9 @@ public final class Vector2 extends ValueType implements IEquatable */ public static Vector2 Add(Vector2 value1, Vector2 value2) { - Vector2 vector = Vector2.Zero; - vector.X = value1.X + value2.X; - vector.Y = value1.Y + value2.Y; - return vector; + return new Vector2(value1.X + value2.X, value1.Y + value2.Y); } - + /** * Adds two vectors. * @@ -112,10 +109,10 @@ public final class Vector2 extends ValueType implements IEquatable */ public static void Add(Vector2 value1, Vector2 value2, Vector2 result) { - result.X = value1.X + value2.X; - result.Y = value1.Y + value2.Y; + result.X = value1.X + value2.X; + result.Y = value1.Y + value2.Y; } - + /** * Returns a Vector2 containing the 2D Cartesian coordinates of a point specified in barycentric (areal) coordinates relative to a 2D triangle. * @@ -136,12 +133,12 @@ public final class Vector2 extends ValueType implements IEquatable */ public static Vector2 Barycentric(Vector2 value1, Vector2 value2, Vector2 value3, float amount1, float amount2) { - Vector2 vector = Vector2.Zero; - vector.X = (value1.X + (amount1 * (value2.X - value1.X))) + (amount2 * (value3.X - value1.X)); - vector.Y = (value1.Y + (amount1 * (value2.Y - value1.Y))) + (amount2 * (value3.Y - value1.Y)); - return vector; + return new Vector2( + (value1.X + (amount1 * (value2.X - value1.X))) + (amount2 * (value3.X - value1.X)), + (value1.Y + (amount1 * (value2.Y - value1.Y))) + (amount2 * (value3.Y - value1.Y)) + ); } - + /** * Returns a Vector2 containing the 2D Cartesian coordinates of a point specified in barycentric (areal) coordinates relative to a 2D triangle. * @@ -165,10 +162,10 @@ public final class Vector2 extends ValueType implements IEquatable */ public static void Barycentric(Vector2 value1, Vector2 value2, Vector2 value3, float amount1, float amount2, Vector2 result) { - result.X = (value1.X + (amount1 * (value2.X - value1.X))) + (amount2 * (value3.X - value1.X)); - result.Y = (value1.Y + (amount1 * (value2.Y - value1.Y))) + (amount2 * (value3.Y - value1.Y)); + result.X = (value1.X + (amount1 * (value2.X - value1.X))) + (amount2 * (value3.X - value1.X)); + result.Y = (value1.Y + (amount1 * (value2.Y - value1.Y))) + (amount2 * (value3.Y - value1.Y)); } - + /** * Performs a Catmull-Rom interpolation using the specified positions. * @@ -189,14 +186,14 @@ public final class Vector2 extends ValueType implements IEquatable */ public static Vector2 CatmullRom(Vector2 value1, Vector2 value2, Vector2 value3, Vector2 value4, float amount) { - Vector2 vector = Vector2.Zero; - float num = amount * amount; - float num2 = amount * num; - vector.X = 0.5f * ((((2f * value2.X) + ((-value1.X + value3.X) * amount)) + (((((2f * value1.X) - (5f * value2.X)) + (4f * value3.X)) - value4.X) * num)) + ((((-value1.X + (3f * value2.X)) - (3f * value3.X)) + value4.X) * num2)); - vector.Y = 0.5f * ((((2f * value2.Y) + ((-value1.Y + value3.Y) * amount)) + (((((2f * value1.Y) - (5f * value2.Y)) + (4f * value3.Y)) - value4.Y) * num)) + ((((-value1.Y + (3f * value2.Y)) - (3f * value3.Y)) + value4.Y) * num2)); - return vector; + Vector2 vector = new Vector2(); + float num = amount * amount; + float num2 = amount * num; + vector.X = 0.5f * ((((2f * value2.X) + ((-value1.X + value3.X) * amount)) + (((((2f * value1.X) - (5f * value2.X)) + (4f * value3.X)) - value4.X) * num)) + ((((-value1.X + (3f * value2.X)) - (3f * value3.X)) + value4.X) * num2)); + vector.Y = 0.5f * ((((2f * value2.Y) + ((-value1.Y + value3.Y) * amount)) + (((((2f * value1.Y) - (5f * value2.Y)) + (4f * value3.Y)) - value4.Y) * num)) + ((((-value1.Y + (3f * value2.Y)) - (3f * value3.Y)) + value4.Y) * num2)); + return vector; } - + /** * Performs a Catmull-Rom interpolation using the specified positions. * @@ -220,12 +217,12 @@ public final class Vector2 extends ValueType implements IEquatable */ public static void CatmullRom(Vector2 value1, Vector2 value2, Vector2 value3, Vector2 value4, float amount, Vector2 result) { - float num = amount * amount; - float num2 = amount * num; - result.X = 0.5f * ((((2f * value2.X) + ((-value1.X + value3.X) * amount)) + (((((2f * value1.X) - (5f * value2.X)) + (4f * value3.X)) - value4.X) * num)) + ((((-value1.X + (3f * value2.X)) - (3f * value3.X)) + value4.X) * num2)); - result.Y = 0.5f * ((((2f * value2.Y) + ((-value1.Y + value3.Y) * amount)) + (((((2f * value1.Y) - (5f * value2.Y)) + (4f * value3.Y)) - value4.Y) * num)) + ((((-value1.Y + (3f * value2.Y)) - (3f * value3.Y)) + value4.Y) * num2)); + float num = amount * amount; + float num2 = amount * num; + result.X = 0.5f * ((((2f * value2.X) + ((-value1.X + value3.X) * amount)) + (((((2f * value1.X) - (5f * value2.X)) + (4f * value3.X)) - value4.X) * num)) + ((((-value1.X + (3f * value2.X)) - (3f * value3.X)) + value4.X) * num2)); + result.Y = 0.5f * ((((2f * value2.Y) + ((-value1.Y + value3.Y) * amount)) + (((((2f * value1.Y) - (5f * value2.Y)) + (4f * value3.Y)) - value4.Y) * num)) + ((((-value1.Y + (3f * value2.Y)) - (3f * value3.Y)) + value4.Y) * num2)); } - + /** * Restricts a value to be within a specified range. * @@ -240,18 +237,16 @@ public final class Vector2 extends ValueType implements IEquatable */ public static Vector2 Clamp(Vector2 value1, Vector2 min, Vector2 max) { - Vector2 vector = Vector2.Zero; - float x = value1.X; - x = (x > max.X) ? max.X : x; - x = (x < min.X) ? min.X : x; - float y = value1.Y; - y = (y > max.Y) ? max.Y : y; - y = (y < min.Y) ? min.Y : y; - vector.X = x; - vector.Y = y; - return vector; + float x = value1.X; + x = (x > max.X) ? max.X : x; + x = (x < min.X) ? min.X : x; + float y = value1.Y; + y = (y > max.Y) ? max.Y : y; + y = (y < min.Y) ? min.Y : y; + + return new Vector2(x, y); } - + /** * Restricts a value to be within a specified range. * @@ -269,16 +264,16 @@ public final class Vector2 extends ValueType implements IEquatable */ public static void Clamp(Vector2 value1, Vector2 min, Vector2 max, Vector2 result) { - float x = value1.X; - x = (x > max.X) ? max.X : x; - x = (x < min.X) ? min.X : x; - float y = value1.Y; - y = (y > max.Y) ? max.Y : y; - y = (y < min.Y) ? min.Y : y; - result.X = x; - result.Y = y; + float x = value1.X; + x = (x > max.X) ? max.X : x; + x = (x < min.X) ? min.X : x; + float y = value1.Y; + y = (y > max.Y) ? max.Y : y; + y = (y < min.Y) ? min.Y : y; + result.X = x; + result.Y = y; } - + /** * Calculates the distance between two vectors. * @@ -290,32 +285,13 @@ public final class Vector2 extends ValueType implements IEquatable */ public static float Distance(Vector2 value1, Vector2 value2) { - float num2 = value1.X - value2.X; - float num = value1.Y - value2.Y; - float num3 = (num2 * num2) + (num * num); - return (float) Math.sqrt((double) num3); + float num2 = value1.X - value2.X; + float num = value1.Y - value2.Y; + float num3 = (num2 * num2) + (num * num); + + return (float) Math.sqrt((double) num3); } - - /** - * Calculates the distance between two vectors. - * - * @param value1 - * Source vector. - * - * @param value2 - * Source vector. - * - * @param result - * [OutAttribute] The distance between the vectors. - */ - public static void Distance(Vector2 value1, Vector2 value2, float result) - { - float num2 = value1.X - value2.X; - float num = value1.Y - value2.Y; - float num3 = (num2 * num2) + (num * num); - result = (float) Math.sqrt((double) num3); - } - + /** * Calculates the distance between two vectors squared. * @@ -327,30 +303,12 @@ public final class Vector2 extends ValueType implements IEquatable */ public static float DistanceSquared(Vector2 value1, Vector2 value2) { - float num2 = value1.X - value2.X; - float num = value1.Y - value2.Y; - return ((num2 * num2) + (num * num)); + float num2 = value1.X - value2.X; + float num = value1.Y - value2.Y; + + return ((num2 * num2) + (num * num)); } - - /** - * Calculates the distance between two vectors squared. - * - * @param value1 - * Source vector. - * - * @param value2 - * Source vector. - * - * @param result - * [OutAttribute] The distance between the vectors squared. - */ - public static void DistanceSquared(Vector2 value1, Vector2 value2, float result) - { - float num2 = value1.X - value2.X; - float num = value1.Y - value2.Y; - result = (num2 * num2) + (num * num); - } - + /** * Divides the components of the current vector by the components of another vector. * @@ -361,7 +319,7 @@ public final class Vector2 extends ValueType implements IEquatable { Divide(this, other, this); } - + /** * Divides the components of a vector by the components of another vector. * @@ -373,12 +331,9 @@ public final class Vector2 extends ValueType implements IEquatable */ public static Vector2 Divide(Vector2 value1, Vector2 value2) { - Vector2 vector = Vector2.Zero; - vector.X = value1.X / value2.X; - vector.Y = value1.Y / value2.Y; - return vector; + return new Vector2(value1.X / value2.X, value1.Y / value2.Y); } - + /** * Divides the current vector by a scalar value. * @@ -389,7 +344,7 @@ public final class Vector2 extends ValueType implements IEquatable { Divide(this, divider, this); } - + /** * Divides a vector by a scalar value. * @@ -401,13 +356,11 @@ public final class Vector2 extends ValueType implements IEquatable */ public static Vector2 Divide(Vector2 value1, float divider) { - Vector2 vector = Vector2.Zero; - float num = 1f / divider; - vector.X = value1.X * num; - vector.Y = value1.Y * num; - return vector; + float num = 1f / divider; + + return new Vector2(value1.X * num, value1.Y * num); } - + /** * Divides the components of a vector by the components of another vector. * @@ -422,10 +375,10 @@ public final class Vector2 extends ValueType implements IEquatable */ public static void Divide(Vector2 value1, Vector2 value2, Vector2 result) { - result.X = value1.X / value2.X; - result.Y = value1.Y / value2.Y; + result.X = value1.X / value2.X; + result.Y = value1.Y / value2.Y; } - + /** * Divides a vector by a scalar value. * @@ -440,11 +393,11 @@ public final class Vector2 extends ValueType implements IEquatable */ public static void Divide(Vector2 value1, float divider, Vector2 result) { - float num = 1f / divider; - result.X = value1.X * num; - result.Y = value1.Y * num; + float num = 1f / divider; + result.X = value1.X * num; + result.Y = value1.Y * num; } - + /** * Calculates the dot product of two vectors. If the two vectors are unit vectors, the dot product returns a floating point value between -1 and 1 that can be used to * determine some properties of the angle between two vectors. For example, it can show whether the vectors are orthogonal, parallel, or have an acute or obtuse @@ -458,9 +411,9 @@ public final class Vector2 extends ValueType implements IEquatable */ public static float Dot(Vector2 value1, Vector2 value2) { - return ((value1.X * value2.X) + (value1.Y * value2.Y)); + return ((value1.X * value2.X) + (value1.Y * value2.Y)); } - + /** * Calculates the dot product of two vectors and writes the result to a user-specified variable. If the two vectors are unit vectors, the dot product returns a floating * point value between -1 and 1 that can be used to determine some properties of the angle between two vectors. For example, it can show whether the vectors are @@ -477,9 +430,9 @@ public final class Vector2 extends ValueType implements IEquatable */ public static void Dot(Vector2 value1, Vector2 value2, float result) { - result = (value1.X * value2.X) + (value1.Y * value2.Y); + result = (value1.X * value2.X) + (value1.Y * value2.Y); } - + /** * Returns a value that indicates whether the current instance is equal to a specified object. * @@ -492,9 +445,9 @@ public final class Vector2 extends ValueType implements IEquatable @Override public boolean equals(Object obj) { - return (obj instanceof Vector2) ? this.Equals((Vector2)obj) : false; + return (obj != null && obj instanceof Vector2) ? this.Equals((Vector2)obj) : false; } - + /** * Determines whether the specified Object is equal to the Vector2. * @@ -503,9 +456,9 @@ public final class Vector2 extends ValueType implements IEquatable */ public boolean Equals(Vector2 other) { - return ((this.X == other.X) && (this.Y == other.Y)); + return ((this.X == other.X) && (this.Y == other.Y)); } - + /** * Gets the hash code of the vector object. * @@ -514,9 +467,9 @@ public final class Vector2 extends ValueType implements IEquatable */ public int hashCode() { - return ((int)this.X ^ (int)this.Y); + return ((int)this.X ^ (int)this.Y); } - + /** * Performs a Hermite spline interpolation. * @@ -537,18 +490,19 @@ public final class Vector2 extends ValueType implements IEquatable */ public static Vector2 Hermite(Vector2 value1, Vector2 tangent1, Vector2 value2, Vector2 tangent2, float amount) { - Vector2 vector = Vector2.Zero; - float num = amount * amount; - float num2 = amount * num; - float num6 = ((2f * num2) - (3f * num)) + 1f; - float num5 = (-2f * num2) + (3f * num); - float num4 = (num2 - (2f * num)) + amount; - float num3 = num2 - num; - vector.X = (((value1.X * num6) + (value2.X * num5)) + (tangent1.X * num4)) + (tangent2.X * num3); - vector.Y = (((value1.Y * num6) + (value2.Y * num5)) + (tangent1.Y * num4)) + (tangent2.Y * num3); - return vector; + float num = amount * amount; + float num2 = amount * num; + float num6 = ((2f * num2) - (3f * num)) + 1f; + float num5 = (-2f * num2) + (3f * num); + float num4 = (num2 - (2f * num)) + amount; + float num3 = num2 - num; + + return new Vector2( + (((value1.X * num6) + (value2.X * num5)) + (tangent1.X * num4)) + (tangent2.X * num3), + (((value1.Y * num6) + (value2.Y * num5)) + (tangent1.Y * num4)) + (tangent2.Y * num3) + ); } - + /** * Performs a Hermite spline interpolation. * @@ -572,33 +526,34 @@ public final class Vector2 extends ValueType implements IEquatable */ public static void Hermite(Vector2 value1, Vector2 tangent1, Vector2 value2, Vector2 tangent2, float amount, Vector2 result) { - float num = amount * amount; - float num2 = amount * num; - float num6 = ((2f * num2) - (3f * num)) + 1f; - float num5 = (-2f * num2) + (3f * num); - float num4 = (num2 - (2f * num)) + amount; - float num3 = num2 - num; - result.X = (((value1.X * num6) + (value2.X * num5)) + (tangent1.X * num4)) + (tangent2.X * num3); - result.Y = (((value1.Y * num6) + (value2.Y * num5)) + (tangent1.Y * num4)) + (tangent2.Y * num3); + float num = amount * amount; + float num2 = amount * num; + float num6 = ((2f * num2) - (3f * num)) + 1f; + float num5 = (-2f * num2) + (3f * num); + float num4 = (num2 - (2f * num)) + amount; + float num3 = num2 - num; + result.X = (((value1.X * num6) + (value2.X * num5)) + (tangent1.X * num4)) + (tangent2.X * num3); + result.Y = (((value1.Y * num6) + (value2.Y * num5)) + (tangent1.Y * num4)) + (tangent2.Y * num3); } - + /** * Calculates the length of the vector. */ public float Length() { - float num = (this.X * this.X) + (this.Y * this.Y); - return (float) Math.sqrt((double) num); + float num = (this.X * this.X) + (this.Y * this.Y); + + return (float) Math.sqrt((double) num); } - + /** * Calculates the length of the vector squared. */ public float LengthSquared() { - return ((this.X * this.X) + (this.Y * this.Y)); + return ((this.X * this.X) + (this.Y * this.Y)); } - + /** * Performs a linear interpolation between two vectors. * @@ -613,12 +568,9 @@ public final class Vector2 extends ValueType implements IEquatable */ public static Vector2 Lerp(Vector2 value1, Vector2 value2, float amount) { - Vector2 vector = Vector2.Zero; - vector.X = value1.X + ((value2.X - value1.X) * amount); - vector.Y = value1.Y + ((value2.Y - value1.Y) * amount); - return vector; + return new Vector2(value1.X + ((value2.X - value1.X) * amount), value1.Y + ((value2.Y - value1.Y) * amount)); } - + /** * Performs a linear interpolation between two vectors. * @@ -636,10 +588,10 @@ public final class Vector2 extends ValueType implements IEquatable */ public static void Lerp(Vector2 value1, Vector2 value2, float amount, Vector2 result) { - result.X = value1.X + ((value2.X - value1.X) * amount); - result.Y = value1.Y + ((value2.Y - value1.Y) * amount); + result.X = value1.X + ((value2.X - value1.X) * amount); + result.Y = value1.Y + ((value2.Y - value1.Y) * amount); } - + /** * Returns a vector that contains the highest value from each matching pair of components. * @@ -651,12 +603,9 @@ public final class Vector2 extends ValueType implements IEquatable */ public static Vector2 Max(Vector2 value1, Vector2 value2) { - Vector2 vector = Vector2.Zero; - vector.X = (value1.X > value2.X) ? value1.X : value2.X; - vector.Y = (value1.Y > value2.Y) ? value1.Y : value2.Y; - return vector; + return new Vector2((value1.X > value2.X) ? value1.X : value2.X, (value1.Y > value2.Y) ? value1.Y : value2.Y); } - + /** * Returns a vector that contains the highest value from each matching pair of components. * @@ -671,10 +620,10 @@ public final class Vector2 extends ValueType implements IEquatable */ public static void Max(Vector2 value1, Vector2 value2, Vector2 result) { - result.X = (value1.X > value2.X) ? value1.X : value2.X; - result.Y = (value1.Y > value2.Y) ? value1.Y : value2.Y; + result.X = (value1.X > value2.X) ? value1.X : value2.X; + result.Y = (value1.Y > value2.Y) ? value1.Y : value2.Y; } - + /** * Returns a vector that contains the lowest value from each matching pair of components. * @@ -686,12 +635,9 @@ public final class Vector2 extends ValueType implements IEquatable */ public static Vector2 Min(Vector2 value1, Vector2 value2) { - Vector2 vector = Vector2.Zero; - vector.X = (value1.X < value2.X) ? value1.X : value2.X; - vector.Y = (value1.Y < value2.Y) ? value1.Y : value2.Y; - return vector; + return new Vector2((value1.X < value2.X) ? value1.X : value2.X, (value1.Y < value2.Y) ? value1.Y : value2.Y); } - + /** * Returns a vector that contains the lowest value from each matching pair of components. * @@ -706,10 +652,10 @@ public final class Vector2 extends ValueType implements IEquatable */ public static void Min(Vector2 value1, Vector2 value2, Vector2 result) { - result.X = (value1.X < value2.X) ? value1.X : value2.X; - result.Y = (value1.Y < value2.Y) ? value1.Y : value2.Y; + result.X = (value1.X < value2.X) ? value1.X : value2.X; + result.Y = (value1.Y < value2.Y) ? value1.Y : value2.Y; } - + /** * Multiplies the components of the current vector by the components of another vector. * @@ -720,7 +666,7 @@ public final class Vector2 extends ValueType implements IEquatable { Multiply(this, other, this); } - + /** * Multiplies the current vector by a scalar value. * @@ -731,7 +677,7 @@ public final class Vector2 extends ValueType implements IEquatable { Multiply(this, scaleFactor, this); } - + /** * Multiplies the components of two vectors by each other. * @@ -743,12 +689,9 @@ public final class Vector2 extends ValueType implements IEquatable */ public static Vector2 Multiply(Vector2 value1, Vector2 value2) { - Vector2 vector = Vector2.Zero; - vector.X = value1.X * value2.X; - vector.Y = value1.Y * value2.Y; - return vector; + return new Vector2(value1.X * value2.X, value1.Y * value2.Y); } - + /** * Multiplies a vector by a scalar value. * @@ -760,12 +703,9 @@ public final class Vector2 extends ValueType implements IEquatable */ public static Vector2 Multiply(Vector2 value1, float scaleFactor) { - Vector2 vector = Vector2.Zero; - vector.X = value1.X * scaleFactor; - vector.Y = value1.Y * scaleFactor; - return vector; + return new Vector2(value1.X * scaleFactor, value1.Y * scaleFactor); } - + /** * Multiplies the components of two vectors by each other. * @@ -780,10 +720,10 @@ public final class Vector2 extends ValueType implements IEquatable */ public static void Multiply(Vector2 value1, Vector2 value2, Vector2 result) { - result.X = value1.X * value2.X; - result.Y = value1.Y * value2.Y; + result.X = value1.X * value2.X; + result.Y = value1.Y * value2.Y; } - + /** * Multiplies a vector by a scalar value. * @@ -798,10 +738,10 @@ public final class Vector2 extends ValueType implements IEquatable */ public static void Multiply(Vector2 value1, float scaleFactor, Vector2 result) { - result.X = value1.X * scaleFactor; - result.Y = value1.Y * scaleFactor; + result.X = value1.X * scaleFactor; + result.Y = value1.Y * scaleFactor; } - + /** * Returns the current vector pointing in the opposite direction. */ @@ -809,7 +749,7 @@ public final class Vector2 extends ValueType implements IEquatable { Negate(this, this); } - + /** * Returns a vector pointing in the opposite direction. * @@ -818,12 +758,9 @@ public final class Vector2 extends ValueType implements IEquatable */ public static Vector2 Negate(Vector2 value) { - Vector2 vector = Vector2.Zero; - vector.X = -value.X; - vector.Y = -value.Y; - return vector; + return new Vector2(-value.X, -value.Y); } - + /** * Returns a vector pointing in the opposite direction. * @@ -835,21 +772,21 @@ public final class Vector2 extends ValueType implements IEquatable */ public static void Negate(Vector2 value, Vector2 result) { - result.X = -value.X; - result.Y = -value.Y; + result.X = -value.X; + result.Y = -value.Y; } - + /** * Turns the current vector into a unit vector. The result is a vector one unit in length pointing in the same direction as the original vector. */ public void Normalize() { - float num2 = (this.X * this.X) + (this.Y * this.Y); - float num = 1f / ((float) Math.sqrt((double) num2)); - this.X *= num; - this.Y *= num; + float num2 = (this.X * this.X) + (this.Y * this.Y); + float num = 1f / ((float) Math.sqrt((double) num2)); + this.X *= num; + this.Y *= num; } - + /** * Creates a unit vector from the specified vector. The result is a vector one unit in length pointing in the same direction as the original vector. * @@ -858,14 +795,12 @@ public final class Vector2 extends ValueType implements IEquatable */ public static Vector2 Normalize(Vector2 value) { - Vector2 vector = Vector2.Zero; - float num2 = (value.X * value.X) + (value.Y * value.Y); - float num = 1f / ((float) Math.sqrt((double) num2)); - vector.X = value.X * num; - vector.Y = value.Y * num; - return vector; + float num2 = (value.X * value.X) + (value.Y * value.Y); + float num = 1f / ((float) Math.sqrt((double) num2)); + + return new Vector2(value.X * num, value.Y * num); } - + /** * Creates a unit vector from the specified vector, writing the result to a user-specified variable. The result is a vector one unit in length pointing in the same direction * as the original vector. @@ -878,12 +813,12 @@ public final class Vector2 extends ValueType implements IEquatable */ public static void Normalize(Vector2 value, Vector2 result) { - float num2 = (value.X * value.X) + (value.Y * value.Y); - float num = 1f / ((float) Math.sqrt((double) num2)); - result.X = value.X * num; - result.Y = value.Y * num; + float num2 = (value.X * value.X) + (value.Y * value.Y); + float num = 1f / ((float) Math.sqrt((double) num2)); + result.X = value.X * num; + result.Y = value.Y * num; } - + /** * Determines the reflect vector of the given vector and normal. * @@ -895,13 +830,11 @@ public final class Vector2 extends ValueType implements IEquatable */ public static Vector2 Reflect(Vector2 vector, Vector2 normal) { - Vector2 vector2 = Vector2.Zero; - float num = (vector.X * normal.X) + (vector.Y * normal.Y); - vector2.X = vector.X - ((2f * num) * normal.X); - vector2.Y = vector.Y - ((2f * num) * normal.Y); - return vector2; + float num = (vector.X * normal.X) + (vector.Y * normal.Y); + + return new Vector2(vector.X - ((2f * num) * normal.X), vector.Y - ((2f * num) * normal.Y)); } - + /** * Determines the reflect vector of the given vector and normal. * @@ -916,11 +849,11 @@ public final class Vector2 extends ValueType implements IEquatable */ public static void Reflect(Vector2 vector, Vector2 normal, Vector2 result) { - float num = (vector.X * normal.X) + (vector.Y * normal.Y); - result.X = vector.X - ((2f * num) * normal.X); - result.Y = vector.Y - ((2f * num) * normal.Y); + float num = (vector.X * normal.X) + (vector.Y * normal.Y); + result.X = vector.X - ((2f * num) * normal.X); + result.Y = vector.Y - ((2f * num) * normal.Y); } - + /** * Interpolates between two values using a cubic equation. * @@ -935,14 +868,12 @@ public final class Vector2 extends ValueType implements IEquatable */ public static Vector2 SmoothStep(Vector2 value1, Vector2 value2, float amount) { - Vector2 vector = Vector2.Zero; - amount = (amount > 1f) ? 1f : ((amount < 0f) ? 0f : amount); - amount = (amount * amount) * (3f - (2f * amount)); - vector.X = value1.X + ((value2.X - value1.X) * amount); - vector.Y = value1.Y + ((value2.Y - value1.Y) * amount); - return vector; + amount = (amount > 1f) ? 1f : ((amount < 0f) ? 0f : amount); + amount = (amount * amount) * (3f - (2f * amount)); + + return new Vector2(value1.X + ((value2.X - value1.X) * amount), value1.Y + ((value2.Y - value1.Y) * amount)); } - + /** * Interpolates between two values using a cubic equation. * @@ -960,12 +891,12 @@ public final class Vector2 extends ValueType implements IEquatable */ public static void SmoothStep(Vector2 value1, Vector2 value2, float amount, Vector2 result) { - amount = (amount > 1f) ? 1f : ((amount < 0f) ? 0f : amount); - amount = (amount * amount) * (3f - (2f * amount)); - result.X = value1.X + ((value2.X - value1.X) * amount); - result.Y = value1.Y + ((value2.Y - value1.Y) * amount); + amount = (amount > 1f) ? 1f : ((amount < 0f) ? 0f : amount); + amount = (amount * amount) * (3f - (2f * amount)); + result.X = value1.X + ((value2.X - value1.X) * amount); + result.Y = value1.Y + ((value2.Y - value1.Y) * amount); } - + /** * Subtracts a vector from the current vector. * @@ -976,7 +907,7 @@ public final class Vector2 extends ValueType implements IEquatable { Subtract(this, other, this); } - + /** * Subtracts a vector from a vector. * @@ -988,12 +919,9 @@ public final class Vector2 extends ValueType implements IEquatable */ public static Vector2 Subtract(Vector2 value1, Vector2 value2) { - Vector2 vector = Vector2.Zero; - vector.X = value1.X - value2.X; - vector.Y = value1.Y - value2.Y; - return vector; + return new Vector2(value1.X - value2.X, value1.Y - value2.Y); } - + /** * Subtracts a vector from a vector. * @@ -1008,19 +936,19 @@ public final class Vector2 extends ValueType implements IEquatable */ public static void Subtract(Vector2 value1, Vector2 value2, Vector2 result) { - result.X = value1.X - value2.X; - result.Y = value1.Y - value2.Y; + result.X = value1.X - value2.X; + result.Y = value1.Y - value2.Y; } - + /** * Retrieves a string representation of the current object. */ @Override public String toString() { - return String.format(Locale.getDefault(), "{{X:%f Y:%f}}", this.X, this.Y); + return String.format(Locale.getDefault(), "{X:%f Y:%f}", this.X, this.Y); } - + /** * Transforms the vector (x, y, 0, 1) by the specified matrix. * @@ -1032,12 +960,10 @@ public final class Vector2 extends ValueType implements IEquatable */ public static Vector2 Transform(Vector2 position, Matrix matrix) { - Vector2 vector = Vector2.Zero; - float num2 = ((position.X * matrix.M11) + (position.Y * matrix.M21)) + matrix.M41; - float num = ((position.X * matrix.M12) + (position.Y * matrix.M22)) + matrix.M42; - vector.X = num2; - vector.Y = num; - return vector; + float num2 = ((position.X * matrix.M11) + (position.Y * matrix.M21)) + matrix.M41; + float num = ((position.X * matrix.M12) + (position.Y * matrix.M22)) + matrix.M42; + + return new Vector2(num2, num); } /** @@ -1051,22 +977,20 @@ public final class Vector2 extends ValueType implements IEquatable */ public static Vector2 Transform(Vector2 value, Quaternion rotation) { - Vector2 vector = Vector2.Zero; - float num10 = rotation.X + rotation.X; - float num5 = rotation.Y + rotation.Y; - float num4 = rotation.Z + rotation.Z; - float num3 = rotation.W * num4; - float num9 = rotation.X * num10; - float num2 = rotation.X * num5; - float num8 = rotation.Y * num5; - float num = rotation.Z * num4; - float num7 = (value.X * ((1f - num8) - num)) + (value.Y * (num2 - num3)); - float num6 = (value.X * (num2 + num3)) + (value.Y * ((1f - num9) - num)); - vector.X = num7; - vector.Y = num6; - return vector; + float num10 = rotation.X + rotation.X; + float num5 = rotation.Y + rotation.Y; + float num4 = rotation.Z + rotation.Z; + float num3 = rotation.W * num4; + float num9 = rotation.X * num10; + float num2 = rotation.X * num5; + float num8 = rotation.Y * num5; + float num = rotation.Z * num4; + float num7 = (value.X * ((1f - num8) - num)) + (value.Y * (num2 - num3)); + float num6 = (value.X * (num2 + num3)) + (value.Y * ((1f - num9) - num)); + + return new Vector2(num7, num6); } - + /** * Transforms the vector (x, y, 0, 1) by the specified matrix. * @@ -1081,12 +1005,12 @@ public final class Vector2 extends ValueType implements IEquatable */ public static void Transform(Vector2 position, Matrix matrix, Vector2 result) { - float num2 = ((position.X * matrix.M11) + (position.Y * matrix.M21)) + matrix.M41; - float num = ((position.X * matrix.M12) + (position.Y * matrix.M22)) + matrix.M42; - result.X = num2; - result.Y = num; + float num2 = ((position.X * matrix.M11) + (position.Y * matrix.M21)) + matrix.M41; + float num = ((position.X * matrix.M12) + (position.Y * matrix.M22)) + matrix.M42; + result.X = num2; + result.Y = num; } - + /** * Transforms an array of Vector2s by a specified Matrix. * @@ -1107,27 +1031,30 @@ public final class Vector2 extends ValueType implements IEquatable */ public static void Transform(Vector2[] sourceArray, Matrix matrix, Vector2[] destinationArray) { - if (sourceArray == null) - { - throw new ArgumentNullException("sourceArray"); - } - if (destinationArray == null) - { - throw new ArgumentNullException("destinationArray"); - } - if (destinationArray.length < sourceArray.length) - { - throw new ArgumentException("Target array size must be equal to or bigger than source array size.", "destinationArray"); - } - for (int i = 0; i < sourceArray.length; i++) - { - float x = sourceArray[i].X; - float y = sourceArray[i].Y; - destinationArray[i].X = ((x * matrix.M11) + (y * matrix.M21)) + matrix.M41; - destinationArray[i].Y = ((x * matrix.M12) + (y * matrix.M22)) + matrix.M42; - } + if (sourceArray == null) + { + throw new ArgumentNullException("sourceArray"); + } + + if (destinationArray == null) + { + throw new ArgumentNullException("destinationArray"); + } + + if (destinationArray.length < sourceArray.length) + { + throw new ArgumentException("Target array size must be equal to or bigger than source array size.", "destinationArray"); + } + + for (int i = 0; i < sourceArray.length; i++) + { + float x = sourceArray[i].X; + float y = sourceArray[i].Y; + destinationArray[i].X = ((x * matrix.M11) + (y * matrix.M21)) + matrix.M41; + destinationArray[i].Y = ((x * matrix.M12) + (y * matrix.M22)) + matrix.M42; + } } - + /** * Transforms an array of Vector2s by a specified Quaternion. * @@ -1148,39 +1075,43 @@ public final class Vector2 extends ValueType implements IEquatable */ public static void Transform(Vector2[] sourceArray, Quaternion rotation, Vector2[] destinationArray) { - if (sourceArray == null) - { - throw new ArgumentNullException("sourceArray"); - } - if (destinationArray == null) - { - throw new ArgumentNullException("destinationArray"); - } - if (destinationArray.length < sourceArray.length) - { - throw new ArgumentException("Target array size must be equal or bigger than source array size.", "destinationArray"); - } - float num15 = rotation.X + rotation.X; - float num8 = rotation.Y + rotation.Y; - float num7 = rotation.Z + rotation.Z; - float num6 = rotation.W * num7; - float num14 = rotation.X * num15; - float num5 = rotation.X * num8; - float num13 = rotation.Y * num8; - float num4 = rotation.Z * num7; - float num12 = (1f - num13) - num4; - float num11 = num5 - num6; - float num10 = num5 + num6; - float num9 = (1f - num14) - num4; - for (int i = 0; i < sourceArray.length; i++) - { - float x = sourceArray[i].X; - float y = sourceArray[i].Y; - destinationArray[i].X = (x * num12) + (y * num11); - destinationArray[i].Y = (x * num10) + (y * num9); - } + if (sourceArray == null) + { + throw new ArgumentNullException("sourceArray"); + } + + if (destinationArray == null) + { + throw new ArgumentNullException("destinationArray"); + } + + if (destinationArray.length < sourceArray.length) + { + throw new ArgumentException("Target array size must be equal or bigger than source array size.", "destinationArray"); + } + + float num15 = rotation.X + rotation.X; + float num8 = rotation.Y + rotation.Y; + float num7 = rotation.Z + rotation.Z; + float num6 = rotation.W * num7; + float num14 = rotation.X * num15; + float num5 = rotation.X * num8; + float num13 = rotation.Y * num8; + float num4 = rotation.Z * num7; + float num12 = (1f - num13) - num4; + float num11 = num5 - num6; + float num10 = num5 + num6; + float num9 = (1f - num14) - num4; + + for (int i = 0; i < sourceArray.length; i++) + { + float x = sourceArray[i].X; + float y = sourceArray[i].Y; + destinationArray[i].X = (x * num12) + (y * num11); + destinationArray[i].Y = (x * num10) + (y * num9); + } } - + /** * Transforms a Vector2, or the vector normal (x, y, 0, 0), by a specified Quaternion rotation. * @@ -1195,20 +1126,20 @@ public final class Vector2 extends ValueType implements IEquatable */ public static void Transform(Vector2 value, Quaternion rotation, Vector2 result) { - float num10 = rotation.X + rotation.X; - float num5 = rotation.Y + rotation.Y; - float num4 = rotation.Z + rotation.Z; - float num3 = rotation.W * num4; - float num9 = rotation.X * num10; - float num2 = rotation.X * num5; - float num8 = rotation.Y * num5; - float num = rotation.Z * num4; - float num7 = (value.X * ((1f - num8) - num)) + (value.Y * (num2 - num3)); - float num6 = (value.X * (num2 + num3)) + (value.Y * ((1f - num9) - num)); - result.X = num7; - result.Y = num6; + float num10 = rotation.X + rotation.X; + float num5 = rotation.Y + rotation.Y; + float num4 = rotation.Z + rotation.Z; + float num3 = rotation.W * num4; + float num9 = rotation.X * num10; + float num2 = rotation.X * num5; + float num8 = rotation.Y * num5; + float num = rotation.Z * num4; + float num7 = (value.X * ((1f - num8) - num)) + (value.Y * (num2 - num3)); + float num6 = (value.X * (num2 + num3)) + (value.Y * ((1f - num9) - num)); + result.X = num7; + result.Y = num6; } - + /** * Transforms a specified range in an array of Vector2s by a specified Matrix and places the results in a specified range in a destination array. * @@ -1232,34 +1163,38 @@ public final class Vector2 extends ValueType implements IEquatable */ public static void Transform(Vector2[] sourceArray, int sourceIndex, Matrix matrix, Vector2[] destinationArray, int destinationIndex, int length) { - if (sourceArray == null) - { - throw new ArgumentNullException("sourceArray"); - } - if (destinationArray == null) - { - throw new ArgumentNullException("destinationArray"); - } - if (sourceArray.length < (sourceIndex + length)) - { - throw new ArgumentException("Source array must be equal to or bigger than requested length.", "sourceArray"); - } - if (destinationArray.length < (destinationIndex + length)) - { - throw new ArgumentException("Target array size must be equal to or bigger than source array size.", "destinationArray"); - } - while (length > 0) - { - float x = sourceArray[sourceIndex].X; - float y = sourceArray[sourceIndex].Y; - destinationArray[destinationIndex].X = ((x * matrix.M11) + (y * matrix.M21)) + matrix.M41; - destinationArray[destinationIndex].Y = ((x * matrix.M12) + (y * matrix.M22)) + matrix.M42; - sourceIndex++; - destinationIndex++; - length--; - } + if (sourceArray == null) + { + throw new ArgumentNullException("sourceArray"); + } + + if (destinationArray == null) + { + throw new ArgumentNullException("destinationArray"); + } + + if (sourceArray.length < (sourceIndex + length)) + { + throw new ArgumentException("Source array must be equal to or bigger than requested length.", "sourceArray"); + } + + if (destinationArray.length < (destinationIndex + length)) + { + throw new ArgumentException("Target array size must be equal to or bigger than source array size.", "destinationArray"); + } + + while (length > 0) + { + float x = sourceArray[sourceIndex].X; + float y = sourceArray[sourceIndex].Y; + destinationArray[destinationIndex].X = ((x * matrix.M11) + (y * matrix.M21)) + matrix.M41; + destinationArray[destinationIndex].Y = ((x * matrix.M12) + (y * matrix.M22)) + matrix.M42; + sourceIndex++; + destinationIndex++; + length--; + } } - + /** * Transforms a specified range in an array of Vector2s by a specified Quaternion and places the results in a specified range in a destination array. * @@ -1283,46 +1218,51 @@ public final class Vector2 extends ValueType implements IEquatable */ public static void Transform(Vector2[] sourceArray, int sourceIndex, Quaternion rotation, Vector2[] destinationArray, int destinationIndex, int length) { - if (sourceArray == null) - { - throw new ArgumentNullException("sourceArray"); - } - if (destinationArray == null) - { - throw new ArgumentNullException("destinationArray"); - } - if (sourceArray.length < (sourceIndex + length)) - { - throw new ArgumentException("Source array must be equal or bigger than requested length.", "sourceArray"); - } - if (destinationArray.length < (destinationIndex + length)) - { - throw new ArgumentException("Target array size must be equal or bigger than source array size.", "destinationArray"); - } - float num14 = rotation.X + rotation.X; - float num7 = rotation.Y + rotation.Y; - float num6 = rotation.Z + rotation.Z; - float num5 = rotation.W * num6; - float num13 = rotation.X * num14; - float num4 = rotation.X * num7; - float num12 = rotation.Y * num7; - float num3 = rotation.Z * num6; - float num11 = (1f - num12) - num3; - float num10 = num4 - num5; - float num9 = num4 + num5; - float num8 = (1f - num13) - num3; - while (length > 0) - { - float x = sourceArray[sourceIndex].X; - float y = sourceArray[sourceIndex].Y; - destinationArray[destinationIndex].X = (x * num11) + (y * num10); - destinationArray[destinationIndex].Y = (x * num9) + (y * num8); - sourceIndex++; - destinationIndex++; - length--; - } + if (sourceArray == null) + { + throw new ArgumentNullException("sourceArray"); + } + + if (destinationArray == null) + { + throw new ArgumentNullException("destinationArray"); + } + + if (sourceArray.length < (sourceIndex + length)) + { + throw new ArgumentException("Source array must be equal or bigger than requested length.", "sourceArray"); + } + + if (destinationArray.length < (destinationIndex + length)) + { + throw new ArgumentException("Target array size must be equal or bigger than source array size.", "destinationArray"); + } + + float num14 = rotation.X + rotation.X; + float num7 = rotation.Y + rotation.Y; + float num6 = rotation.Z + rotation.Z; + float num5 = rotation.W * num6; + float num13 = rotation.X * num14; + float num4 = rotation.X * num7; + float num12 = rotation.Y * num7; + float num3 = rotation.Z * num6; + float num11 = (1f - num12) - num3; + float num10 = num4 - num5; + float num9 = num4 + num5; + float num8 = (1f - num13) - num3; + + while (length > 0) + { + float x = sourceArray[sourceIndex].X; + float y = sourceArray[sourceIndex].Y; + destinationArray[destinationIndex].X = (x * num11) + (y * num10); + destinationArray[destinationIndex].Y = (x * num9) + (y * num8); + sourceIndex++; + destinationIndex++; + length--; + } } - + /** * Transforms a 2D vector normal by a matrix. * @@ -1334,14 +1274,12 @@ public final class Vector2 extends ValueType implements IEquatable */ public static Vector2 TransformNormal(Vector2 normal, Matrix matrix) { - Vector2 vector = Vector2.Zero; - float num2 = (normal.X * matrix.M11) + (normal.Y * matrix.M21); - float num = (normal.X * matrix.M12) + (normal.Y * matrix.M22); - vector.X = num2; - vector.Y = num; - return vector; + float num2 = (normal.X * matrix.M11) + (normal.Y * matrix.M21); + float num = (normal.X * matrix.M12) + (normal.Y * matrix.M22); + + return new Vector2(num2, num); } - + /** * Transforms a vector normal by a matrix. * @@ -1356,12 +1294,12 @@ public final class Vector2 extends ValueType implements IEquatable */ public static void TransformNormal(Vector2 normal, Matrix matrix, Vector2 result) { - float num2 = (normal.X * matrix.M11) + (normal.Y * matrix.M21); - float num = (normal.X * matrix.M12) + (normal.Y * matrix.M22); - result.X = num2; - result.Y = num; + float num2 = (normal.X * matrix.M11) + (normal.Y * matrix.M21); + float num = (normal.X * matrix.M12) + (normal.Y * matrix.M22); + result.X = num2; + result.Y = num; } - + /** * Transforms an array of Vector2 vector normals by a specified Matrix. * @@ -1382,24 +1320,27 @@ public final class Vector2 extends ValueType implements IEquatable */ public static void TransformNormal(Vector2[] sourceArray, Matrix matrix, Vector2[] destinationArray) { - if (sourceArray == null) - { - throw new ArgumentNullException("sourceArray"); - } - if (destinationArray == null) - { - throw new ArgumentNullException("destinationArray"); - } - if (destinationArray.length < sourceArray.length) - { - throw new ArgumentException("Target array size must be equal or bigger than source array size.", "destinationArray"); - } - for (int i = 0; i < sourceArray.length; i++) - { - TransformNormal(sourceArray[i], matrix, destinationArray[i]); - } + if (sourceArray == null) + { + throw new ArgumentNullException("sourceArray"); + } + + if (destinationArray == null) + { + throw new ArgumentNullException("destinationArray"); + } + + if (destinationArray.length < sourceArray.length) + { + throw new ArgumentException("Target array size must be equal or bigger than source array size.", "destinationArray"); + } + + for (int i = 0; i < sourceArray.length; i++) + { + TransformNormal(sourceArray[i], matrix, destinationArray[i]); + } } - + /** * Transforms a specified range in an array of Vector2 vector normals by a specified Matrix and places the results in a specified range in a destination array. * @@ -1426,31 +1367,35 @@ public final class Vector2 extends ValueType implements IEquatable */ public static void TransformNormal(Vector2[] sourceArray, int sourceIndex, Matrix matrix, Vector2[] destinationArray, int destinationIndex, int length) { - if (sourceArray == null) - { - throw new ArgumentNullException("sourceArray"); - } - if (destinationArray == null) - { - throw new ArgumentNullException("destinationArray"); - } - if (sourceArray.length < (sourceIndex + length)) - { - throw new ArgumentException("Source array must be equal to or bigger than requested length.", "sourceArray"); - } - if (destinationArray.length < (destinationIndex + length)) - { - throw new ArgumentException("Target array size must be equal to or bigger than source array size.", "destinationArray"); - } - while (length > 0) - { - float x = sourceArray[sourceIndex].X; - float y = sourceArray[sourceIndex].Y; - destinationArray[destinationIndex].X = (x * matrix.M11) + (y * matrix.M21); - destinationArray[destinationIndex].Y = (x * matrix.M12) + (y * matrix.M22); - sourceIndex++; - destinationIndex++; - length--; - } + if (sourceArray == null) + { + throw new ArgumentNullException("sourceArray"); + } + + if (destinationArray == null) + { + throw new ArgumentNullException("destinationArray"); + } + + if (sourceArray.length < (sourceIndex + length)) + { + throw new ArgumentException("Source array must be equal to or bigger than requested length.", "sourceArray"); + } + + if (destinationArray.length < (destinationIndex + length)) + { + throw new ArgumentException("Target array size must be equal to or bigger than source array size.", "destinationArray"); + } + + while (length > 0) + { + float x = sourceArray[sourceIndex].X; + float y = sourceArray[sourceIndex].Y; + destinationArray[destinationIndex].X = (x * matrix.M11) + (y * matrix.M21); + destinationArray[destinationIndex].Y = (x * matrix.M12) + (y * matrix.M22); + sourceIndex++; + destinationIndex++; + length--; + } } } diff --git a/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/Vector3.java b/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/Vector3.java index d92f7f4..328a3de 100644 --- a/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/Vector3.java +++ b/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/Vector3.java @@ -63,7 +63,7 @@ public final class Vector3 extends ValueType implements IEquatable * Returns a Vector3 with all of its components set to zero. */ public static final Vector3 Zero = new Vector3(0, 0, 0); - + /** * Creates a new instance of Vector3. * @@ -74,7 +74,7 @@ public final class Vector3 extends ValueType implements IEquatable { this.X = this.Y = this.Z = value; } - + /** * Initializes a new instance of Vector3. * @@ -87,10 +87,10 @@ public final class Vector3 extends ValueType implements IEquatable public Vector3(Vector2 value, float z) { this.X = value.X; - this.Y = value.Y; - this.Z = z; + this.Y = value.Y; + this.Z = z; } - + /** * Creates a new instance of Vector3. * @@ -109,7 +109,7 @@ public final class Vector3 extends ValueType implements IEquatable this.Y = y; this.Z = z; } - + /** * Creates a new instance of Vector3. */ @@ -119,7 +119,7 @@ public final class Vector3 extends ValueType implements IEquatable this.Y = 0; this.Z = 0; } - + /** * Adds the specified vector to the current vector. * @@ -130,7 +130,7 @@ public final class Vector3 extends ValueType implements IEquatable { Add(this, other, this); } - + /** * Adds two vectors. * @@ -142,11 +142,11 @@ public final class Vector3 extends ValueType implements IEquatable */ public static Vector3 Add(Vector3 value1, Vector3 value2) { - Vector3 result = new Vector3(); - Add(value1, value2, result); - return result; + Vector3 result = new Vector3(); + Add(value1, value2, result); + return result; } - + /** * Adds two vectors. * @@ -161,11 +161,11 @@ public final class Vector3 extends ValueType implements IEquatable */ public static void Add(Vector3 value1, Vector3 value2, Vector3 result) { - result.X = value1.X + value2.X; - result.Y = value1.Y + value2.Y; - result.Z = value1.Z + value2.Z; + result.X = value1.X + value2.X; + result.Y = value1.Y + value2.Y; + result.Z = value1.Z + value2.Z; } - + /** * Returns a Vector3 containing the 3D Cartesian coordinates of a point specified in Barycentric coordinates relative to a 3D triangle. * @@ -186,11 +186,11 @@ public final class Vector3 extends ValueType implements IEquatable */ public static Vector3 Barycentric(Vector3 value1, Vector3 value2, Vector3 value3, float amount1, float amount2) { - Vector3 result = new Vector3(); - Barycentric(value1, value2, value3, amount1, amount2, result); - return result; + Vector3 result = new Vector3(); + Barycentric(value1, value2, value3, amount1, amount2, result); + return result; } - + /** * Returns a Vector3 containing the 3D Cartesian coordinates of a point specified in Barycentric coordinates relative to a 3D triangle. * @@ -214,11 +214,11 @@ public final class Vector3 extends ValueType implements IEquatable */ public static void Barycentric(Vector3 value1, Vector3 value2, Vector3 value3, float amount1, float amount2, Vector3 result) { - result.X = (value1.X + (amount1 * (value2.X - value1.X))) + (amount2 * (value3.X - value1.X)); - result.Y = (value1.Y + (amount1 * (value2.Y - value1.Y))) + (amount2 * (value3.Y - value1.Y)); - result.Z = (value1.Z + (amount1 * (value2.Z - value1.Z))) + (amount2 * (value3.Z - value1.Z)); + result.X = (value1.X + (amount1 * (value2.X - value1.X))) + (amount2 * (value3.X - value1.X)); + result.Y = (value1.Y + (amount1 * (value2.Y - value1.Y))) + (amount2 * (value3.Y - value1.Y)); + result.Z = (value1.Z + (amount1 * (value2.Z - value1.Z))) + (amount2 * (value3.Z - value1.Z)); } - + /** * Performs a Catmull-Rom interpolation using the specified positions. * @@ -239,11 +239,11 @@ public final class Vector3 extends ValueType implements IEquatable */ public static Vector3 CatmullRom(Vector3 value1, Vector3 value2, Vector3 value3, Vector3 value4, float amount) { - Vector3 result = new Vector3(); - CatmullRom(value1, value2, value3, value4, amount, result); - return result; + Vector3 result = new Vector3(); + CatmullRom(value1, value2, value3, value4, amount, result); + return result; } - + /** * Performs a Catmull-Rom interpolation using the specified positions. * @@ -267,13 +267,13 @@ public final class Vector3 extends ValueType implements IEquatable */ public static void CatmullRom(Vector3 value1, Vector3 value2, Vector3 value3, Vector3 value4, float amount, Vector3 result) { - float num = amount * amount; - float num2 = amount * num; - result.X = 0.5f * ((((2f * value2.X) + ((-value1.X + value3.X) * amount)) + (((((2f * value1.X) - (5f * value2.X)) + (4f * value3.X)) - value4.X) * num)) + ((((-value1.X + (3f * value2.X)) - (3f * value3.X)) + value4.X) * num2)); - result.Y = 0.5f * ((((2f * value2.Y) + ((-value1.Y + value3.Y) * amount)) + (((((2f * value1.Y) - (5f * value2.Y)) + (4f * value3.Y)) - value4.Y) * num)) + ((((-value1.Y + (3f * value2.Y)) - (3f * value3.Y)) + value4.Y) * num2)); - result.Z = 0.5f * ((((2f * value2.Z) + ((-value1.Z + value3.Z) * amount)) + (((((2f * value1.Z) - (5f * value2.Z)) + (4f * value3.Z)) - value4.Z) * num)) + ((((-value1.Z + (3f * value2.Z)) - (3f * value3.Z)) + value4.Z) * num2)); + float num = amount * amount; + float num2 = amount * num; + result.X = 0.5f * ((((2f * value2.X) + ((-value1.X + value3.X) * amount)) + (((((2f * value1.X) - (5f * value2.X)) + (4f * value3.X)) - value4.X) * num)) + ((((-value1.X + (3f * value2.X)) - (3f * value3.X)) + value4.X) * num2)); + result.Y = 0.5f * ((((2f * value2.Y) + ((-value1.Y + value3.Y) * amount)) + (((((2f * value1.Y) - (5f * value2.Y)) + (4f * value3.Y)) - value4.Y) * num)) + ((((-value1.Y + (3f * value2.Y)) - (3f * value3.Y)) + value4.Y) * num2)); + result.Z = 0.5f * ((((2f * value2.Z) + ((-value1.Z + value3.Z) * amount)) + (((((2f * value1.Z) - (5f * value2.Z)) + (4f * value3.Z)) - value4.Z) * num)) + ((((-value1.Z + (3f * value2.Z)) - (3f * value3.Z)) + value4.Z) * num2)); } - + /** * Restricts a value to be within a specified range. * @@ -288,11 +288,11 @@ public final class Vector3 extends ValueType implements IEquatable */ public static Vector3 Clamp(Vector3 value1, Vector3 min, Vector3 max) { - Vector3 result = new Vector3(); - Clamp(value1, min, max, result); - return result; + Vector3 result = new Vector3(); + Clamp(value1, min, max, result); + return result; } - + /** * Restricts a value to be within a specified range. * @@ -310,20 +310,20 @@ public final class Vector3 extends ValueType implements IEquatable */ public static void Clamp(Vector3 value1, Vector3 min, Vector3 max, Vector3 result) { - float x = value1.X; - x = (x > max.X) ? max.X : x; - x = (x < min.X) ? min.X : x; - float y = value1.Y; - y = (y > max.Y) ? max.Y : y; - y = (y < min.Y) ? min.Y : y; - float z = value1.Z; - z = (z > max.Z) ? max.Z : z; - z = (z < min.Z) ? min.Z : z; - result.X = x; - result.Y = y; - result.Z = z; + float x = value1.X; + x = (x > max.X) ? max.X : x; + x = (x < min.X) ? min.X : x; + float y = value1.Y; + y = (y > max.Y) ? max.Y : y; + y = (y < min.Y) ? min.Y : y; + float z = value1.Z; + z = (z > max.Z) ? max.Z : z; + z = (z < min.Z) ? min.Z : z; + result.X = x; + result.Y = y; + result.Z = z; } - + /** * Calculates the cross product of two vectors. * @@ -335,11 +335,11 @@ public final class Vector3 extends ValueType implements IEquatable */ public static Vector3 Cross(Vector3 vector1, Vector3 vector2) { - Vector3 result = new Vector3(); - Cross(vector1, vector2, result); - return result; + Vector3 result = new Vector3(); + Cross(vector1, vector2, result); + return result; } - + /** * Calculates the cross product of two vectors. * @@ -354,14 +354,14 @@ public final class Vector3 extends ValueType implements IEquatable */ public static void Cross(Vector3 vector1, Vector3 vector2, Vector3 result) { - float num3 = (vector1.Y * vector2.Z) - (vector1.Z * vector2.Y); - float num2 = (vector1.Z * vector2.X) - (vector1.X * vector2.Z); - float num = (vector1.X * vector2.Y) - (vector1.Y * vector2.X); - result.X = num3; - result.Y = num2; - result.Z = num; + float num3 = (vector1.Y * vector2.Z) - (vector1.Z * vector2.Y); + float num2 = (vector1.Z * vector2.X) - (vector1.X * vector2.Z); + float num = (vector1.X * vector2.Y) - (vector1.Y * vector2.X); + result.X = num3; + result.Y = num2; + result.Z = num; } - + /** * Calculates the distance between two vectors. * @@ -373,32 +373,14 @@ public final class Vector3 extends ValueType implements IEquatable */ public static float Distance(Vector3 value1, Vector3 value2) { - float result = 0; - Distance(value1, value2, result); - return result; + float num3 = value1.X - value2.X; + float num2 = value1.Y - value2.Y; + float num = value1.Z - value2.Z; + float num4 = ((num3 * num3) + (num2 * num2)) + (num * num); + + return (float) Math.sqrt((double) num4); } - - /** - * Calculates the distance between two vectors. - * - * @param value1 - * Source vector. - * - * @param value2 - * Source vector. - * - * @param result - * [OutAttribute] The distance between the vectors. - */ - public static void Distance(Vector3 value1, Vector3 value2, float result) - { - float num3 = value1.X - value2.X; - float num2 = value1.Y - value2.Y; - float num = value1.Z - value2.Z; - float num4 = ((num3 * num3) + (num2 * num2)) + (num * num); - result = (float) Math.sqrt((double) num4); - } - + /** * Calculates the distance between two vectors squared. * @@ -410,32 +392,13 @@ public final class Vector3 extends ValueType implements IEquatable */ public static float DistanceSquared(Vector3 value1, Vector3 value2) { - float num3 = value1.X - value2.X; - float num2 = value1.Y - value2.Y; - float num = value1.Z - value2.Z; - return (((num3 * num3) + (num2 * num2)) + (num * num)); + float num3 = value1.X - value2.X; + float num2 = value1.Y - value2.Y; + float num = value1.Z - value2.Z; + + return (((num3 * num3) + (num2 * num2)) + (num * num)); } - - /** - * Calculates the distance between two vectors squared. - * - * @param value1 - * Source vector. - * - * @param value2 - * Source vector. - * - * @param result - * [OutAttribute] The distance between the two vectors squared. - */ - public static void DistanceSquared(Vector3 value1, Vector3 value2, float result) - { - float num3 = value1.X - value2.X; - float num2 = value1.Y - value2.Y; - float num = value1.Z - value2.Z; - result = ((num3 * num3) + (num2 * num2)) + (num * num); - } - + /** * Divides the components of the current vector by the components of another vector. * @@ -446,7 +409,7 @@ public final class Vector3 extends ValueType implements IEquatable { Divide(this, other, this); } - + /** * Divides the components of a vector by the components of another vector. * @@ -458,11 +421,11 @@ public final class Vector3 extends ValueType implements IEquatable */ public static Vector3 Divide(Vector3 value1, Vector3 value2) { - Vector3 result = new Vector3(); - Divide(value1, value2, result); - return result; + Vector3 result = new Vector3(); + Divide(value1, value2, result); + return result; } - + /** * Divides the current vector by a scalar value. * @@ -473,7 +436,7 @@ public final class Vector3 extends ValueType implements IEquatable { Divide(this, value, this); } - + /** * Divides a vector by a scalar value. * @@ -485,11 +448,11 @@ public final class Vector3 extends ValueType implements IEquatable */ public static Vector3 Divide(Vector3 value1, float value2) { - Vector3 result = new Vector3(); - Divide(value1, value2, result); - return result; + Vector3 result = new Vector3(); + Divide(value1, value2, result); + return result; } - + /** * Divides the components of a vector by the components of another vector. * @@ -504,11 +467,11 @@ public final class Vector3 extends ValueType implements IEquatable */ public static void Divide(Vector3 value1, Vector3 value2, Vector3 result) { - result.X = value1.X / value2.X; - result.Y = value1.Y / value2.Y; - result.Z = value1.Z / value2.Z; + result.X = value1.X / value2.X; + result.Y = value1.Y / value2.Y; + result.Z = value1.Z / value2.Z; } - + /** * Divides a vector by a scalar value. * @@ -523,12 +486,12 @@ public final class Vector3 extends ValueType implements IEquatable */ public static void Divide(Vector3 value1, float value2, Vector3 result) { - float num = 1f / value2; - result.X = value1.X * num; - result.Y = value1.Y * num; - result.Z = value1.Z * num; + float num = 1f / value2; + result.X = value1.X * num; + result.Y = value1.Y * num; + result.Z = value1.Z * num; } - + /** * Calculates the dot product of two vectors. If the two vectors are unit vectors, the dot product returns a floating point value between -1 and 1 that can be used to * determine some properties of the angle between two vectors. For example, it can show whether the vectors are orthogonal, parallel, or have an acute or obtuse @@ -542,28 +505,9 @@ public final class Vector3 extends ValueType implements IEquatable */ public static float Dot(Vector3 vector1, Vector3 vector2) { - return (((vector1.X * vector2.X) + (vector1.Y * vector2.Y)) + (vector1.Z * vector2.Z)); + return (((vector1.X * vector2.X) + (vector1.Y * vector2.Y)) + (vector1.Z * vector2.Z)); } - - /** - * Calculates the dot product of two vectors. If the two vectors are unit vectors, the dot product returns a floating point value between -1 and 1 that can be used to - * determine some properties of the angle between two vectors. For example, it can show whether the vectors are orthogonal, parallel, or have an acute or obtuse - * angle between them. - * - * @param vector1 - * Source vector. - * - * @param vector2 - * Source vector. - * - * @param result - * [OutAttribute] The dot product of the two vectors. - */ - public static void Dot(Vector3 vector1, Vector3 vector2, float result) - { - result = ((vector1.X * vector2.X) + (vector1.Y * vector2.Y)) + (vector1.Z * vector2.Z); - } - + /** * Returns a value that indicates whether the current instance is equal to a specified object. * @@ -573,12 +517,9 @@ public final class Vector3 extends ValueType implements IEquatable @Override public boolean equals(Object obj) { - if (obj == null) - return false; - - return (obj instanceof Vector3) ? this.Equals((Vector3)obj) : false; + return (obj != null && obj instanceof Vector3) ? this.Equals((Vector3)obj) : false; } - + /** * Determines whether the specified Object is equal to the Vector3. * @@ -598,7 +539,7 @@ public final class Vector3 extends ValueType implements IEquatable { return ((int)X ^ (int)Y ^ (int)Z); } - + /** * Performs a Hermite spline interpolation. * @@ -619,11 +560,11 @@ public final class Vector3 extends ValueType implements IEquatable */ public static Vector3 Hermite(Vector3 value1, Vector3 tangent1, Vector3 value2, Vector3 tangent2, float amount) { - Vector3 result = new Vector3(); - Hermite(value1, tangent1, value2, tangent2, amount, result); - return result; + Vector3 result = new Vector3(); + Hermite(value1, tangent1, value2, tangent2, amount, result); + return result; } - + /** * Performs a Hermite spline interpolation. * @@ -647,34 +588,35 @@ public final class Vector3 extends ValueType implements IEquatable */ public static void Hermite(Vector3 value1, Vector3 tangent1, Vector3 value2, Vector3 tangent2, float amount, Vector3 result) { - float num = amount * amount; - float num2 = amount * num; - float num6 = ((2f * num2) - (3f * num)) + 1f; - float num5 = (-2f * num2) + (3f * num); - float num4 = (num2 - (2f * num)) + amount; - float num3 = num2 - num; - result.X = (((value1.X * num6) + (value2.X * num5)) + (tangent1.X * num4)) + (tangent2.X * num3); - result.Y = (((value1.Y * num6) + (value2.Y * num5)) + (tangent1.Y * num4)) + (tangent2.Y * num3); - result.Z = (((value1.Z * num6) + (value2.Z * num5)) + (tangent1.Z * num4)) + (tangent2.Z * num3); + float num = amount * amount; + float num2 = amount * num; + float num6 = ((2f * num2) - (3f * num)) + 1f; + float num5 = (-2f * num2) + (3f * num); + float num4 = (num2 - (2f * num)) + amount; + float num3 = num2 - num; + result.X = (((value1.X * num6) + (value2.X * num5)) + (tangent1.X * num4)) + (tangent2.X * num3); + result.Y = (((value1.Y * num6) + (value2.Y * num5)) + (tangent1.Y * num4)) + (tangent2.Y * num3); + result.Z = (((value1.Z * num6) + (value2.Z * num5)) + (tangent1.Z * num4)) + (tangent2.Z * num3); } - + /** * Calculates the length of the vector. */ public float Length() { float num = ((this.X * this.X) + (this.Y * this.Y)) + (this.Z * this.Z); + return (float) Math.sqrt((double) num); } - + /** * Calculates the length of the vector squared. */ public float LengthSquared() { - return (((this.X * this.X) + (this.Y * this.Y)) + (this.Z * this.Z)); + return (((this.X * this.X) + (this.Y * this.Y)) + (this.Z * this.Z)); } - + /** * Performs a linear interpolation between two vectors. * @@ -689,9 +631,9 @@ public final class Vector3 extends ValueType implements IEquatable */ public static Vector3 Lerp(Vector3 value1, Vector3 value2, float amount) { - Vector3 result = new Vector3(); - Lerp(value1, value2, amount, result); - return result; + Vector3 result = new Vector3(); + Lerp(value1, value2, amount, result); + return result; } /** @@ -711,11 +653,11 @@ public final class Vector3 extends ValueType implements IEquatable */ public static void Lerp(Vector3 value1, Vector3 value2, float amount, Vector3 result) { - result.X = value1.X + ((value2.X - value1.X) * amount); - result.Y = value1.Y + ((value2.Y - value1.Y) * amount); - result.Z = value1.Z + ((value2.Z - value1.Z) * amount); + result.X = value1.X + ((value2.X - value1.X) * amount); + result.Y = value1.Y + ((value2.Y - value1.Y) * amount); + result.Z = value1.Z + ((value2.Z - value1.Z) * amount); } - + /** * Returns a vector that contains the highest value from each matching pair of components. * @@ -727,11 +669,11 @@ public final class Vector3 extends ValueType implements IEquatable */ public static Vector3 Max(Vector3 value1, Vector3 value2) { - Vector3 result = new Vector3(); - Max(value1, value2, result); - return result; + Vector3 result = new Vector3(); + Max(value1, value2, result); + return result; } - + /** * Returns a vector that contains the highest value from each matching pair of components. * @@ -746,11 +688,11 @@ public final class Vector3 extends ValueType implements IEquatable */ public static void Max(Vector3 value1, Vector3 value2, Vector3 result) { - result.X = (value1.X > value2.X) ? value1.X : value2.X; - result.Y = (value1.Y > value2.Y) ? value1.Y : value2.Y; - result.Z = (value1.Z > value2.Z) ? value1.Z : value2.Z; + result.X = (value1.X > value2.X) ? value1.X : value2.X; + result.Y = (value1.Y > value2.Y) ? value1.Y : value2.Y; + result.Z = (value1.Z > value2.Z) ? value1.Z : value2.Z; } - + /** * Returns a vector that contains the lowest value from each matching pair of components. * @@ -762,11 +704,11 @@ public final class Vector3 extends ValueType implements IEquatable */ public static Vector3 Min(Vector3 value1, Vector3 value2) { - Vector3 result = new Vector3(); - Min(value1, value2, result); - return result; + Vector3 result = new Vector3(); + Min(value1, value2, result); + return result; } - + /** * Returns a vector that contains the lowest value from each matching pair of components. * @@ -781,11 +723,11 @@ public final class Vector3 extends ValueType implements IEquatable */ public static void Min(Vector3 value1, Vector3 value2, Vector3 result) { - result.X = (value1.X < value2.X) ? value1.X : value2.X; - result.Y = (value1.Y < value2.Y) ? value1.Y : value2.Y; - result.Z = (value1.Z < value2.Z) ? value1.Z : value2.Z; + result.X = (value1.X < value2.X) ? value1.X : value2.X; + result.Y = (value1.Y < value2.Y) ? value1.Y : value2.Y; + result.Z = (value1.Z < value2.Z) ? value1.Z : value2.Z; } - + /** * Multiplies the components of the current vector by the components of another vector. * @@ -796,7 +738,7 @@ public final class Vector3 extends ValueType implements IEquatable { Multiply(this, other, this); } - + /** * Multiplies the components of two vectors by each other. * @@ -808,11 +750,11 @@ public final class Vector3 extends ValueType implements IEquatable */ public static Vector3 Multiply(Vector3 value1, Vector3 value2) { - Vector3 result = new Vector3(); - Multiply(value1, value2, result); - return result; + Vector3 result = new Vector3(); + Multiply(value1, value2, result); + return result; } - + /** * Multiplies the current vector by a scalar value. * @@ -823,7 +765,7 @@ public final class Vector3 extends ValueType implements IEquatable { Multiply(this, scaleFactor, this); } - + /** * Multiplies a vector by a scalar value. * @@ -835,11 +777,11 @@ public final class Vector3 extends ValueType implements IEquatable */ public static Vector3 Multiply(Vector3 value1, float scaleFactor) { - Vector3 result = new Vector3(); - Multiply(value1, scaleFactor, result); - return result; + Vector3 result = new Vector3(); + Multiply(value1, scaleFactor, result); + return result; } - + /** * Multiplies a vector by a scalar value. * @@ -854,11 +796,11 @@ public final class Vector3 extends ValueType implements IEquatable */ public static void Multiply(Vector3 value1, float scaleFactor, Vector3 result) { - result.X = value1.X * scaleFactor; - result.Y = value1.Y * scaleFactor; - result.Z = value1.Z * scaleFactor; + result.X = value1.X * scaleFactor; + result.Y = value1.Y * scaleFactor; + result.Z = value1.Z * scaleFactor; } - + /** * Multiplies the components of two vectors by each other. * @@ -873,11 +815,11 @@ public final class Vector3 extends ValueType implements IEquatable */ public static void Multiply(Vector3 value1, Vector3 value2, Vector3 result) { - result.X = value1.X * value2.X; - result.Y = value1.Y * value2.Y; - result.Z = value1.Z * value2.Z; + result.X = value1.X * value2.X; + result.Y = value1.Y * value2.Y; + result.Z = value1.Z * value2.Z; } - + /** * Returns the current vector pointing in the opposite direction. */ @@ -885,7 +827,7 @@ public final class Vector3 extends ValueType implements IEquatable { Negate(this, this); } - + /** * Returns a vector pointing in the opposite direction. * @@ -894,11 +836,11 @@ public final class Vector3 extends ValueType implements IEquatable */ public static Vector3 Negate(Vector3 value) { - Vector3 result = new Vector3(); - Negate(value, result); - return result; + Vector3 result = new Vector3(); + Negate(value, result); + return result; } - + /** * Returns a vector pointing in the opposite direction. * @@ -910,23 +852,23 @@ public final class Vector3 extends ValueType implements IEquatable */ public static void Negate(Vector3 value, Vector3 result) { - result.X = -value.X; - result.Y = -value.Y; - result.Z = -value.Z; + result.X = -value.X; + result.Y = -value.Y; + result.Z = -value.Z; } - + /** * Turns the current vector into a unit vector. The result is a vector one unit in length pointing in the same direction as the original vector. */ public void Normalize() { - float num2 = ((this.X * this.X) + (this.Y * this.Y)) + (this.Z * this.Z); - float num = 1f / ((float) Math.sqrt((double) num2)); - this.X *= num; - this.Y *= num; - this.Z *= num; + float num2 = ((this.X * this.X) + (this.Y * this.Y)) + (this.Z * this.Z); + float num = 1f / ((float) Math.sqrt((double) num2)); + this.X *= num; + this.Y *= num; + this.Z *= num; } - + /** * Creates a unit vector from the specified vector. The result is a vector one unit in length pointing in the same direction as the original vector. * @@ -935,11 +877,11 @@ public final class Vector3 extends ValueType implements IEquatable */ public static Vector3 Normalize(Vector3 value) { - Vector3 result = new Vector3(); - Normalize(value, result); - return result; + Vector3 result = new Vector3(); + Normalize(value, result); + return result; } - + /** * Creates a unit vector from the specified vector, writing the result to a user-specified variable. The result is a vector one unit in length pointing in the same direction * as the original vector. @@ -952,13 +894,13 @@ public final class Vector3 extends ValueType implements IEquatable */ public static void Normalize(Vector3 value, Vector3 result) { - float num2 = ((value.X * value.X) + (value.Y * value.Y)) + (value.Z * value.Z); - float num = 1f / ((float) Math.sqrt((double) num2)); - result.X = value.X * num; - result.Y = value.Y * num; - result.Z = value.Z * num; + float num2 = ((value.X * value.X) + (value.Y * value.Y)) + (value.Z * value.Z); + float num = 1f / ((float) Math.sqrt((double) num2)); + result.X = value.X * num; + result.Y = value.Y * num; + result.Z = value.Z * num; } - + /** * Returns the reflection of a vector off a surface that has the specified normal. * @@ -970,11 +912,11 @@ public final class Vector3 extends ValueType implements IEquatable */ public static Vector3 Reflect(Vector3 vector, Vector3 normal) { - Vector3 result = new Vector3(); - Reflect(vector, normal, result); - return result; + Vector3 result = new Vector3(); + Reflect(vector, normal, result); + return result; } - + /** * Returns the reflection of a vector off a surface that has the specified normal. * @@ -989,12 +931,12 @@ public final class Vector3 extends ValueType implements IEquatable */ public static void Reflect(Vector3 vector, Vector3 normal, Vector3 result) { - float num = ((vector.X * normal.X) + (vector.Y * normal.Y)) + (vector.Z * normal.Z); - result.X = vector.X - ((2f * num) * normal.X); - result.Y = vector.Y - ((2f * num) * normal.Y); - result.Z = vector.Z - ((2f * num) * normal.Z); + float num = ((vector.X * normal.X) + (vector.Y * normal.Y)) + (vector.Z * normal.Z); + result.X = vector.X - ((2f * num) * normal.X); + result.Y = vector.Y - ((2f * num) * normal.Y); + result.Z = vector.Z - ((2f * num) * normal.Z); } - + /** * Interpolates between two values using a cubic equation. * @@ -1009,11 +951,11 @@ public final class Vector3 extends ValueType implements IEquatable */ public static Vector3 SmoothStep(Vector3 value1, Vector3 value2, float amount) { - Vector3 result = new Vector3(); - SmoothStep(value1, value2, amount, result); - return result; + Vector3 result = new Vector3(); + SmoothStep(value1, value2, amount, result); + return result; } - + /** * Interpolates between two values using a cubic equation. * @@ -1031,13 +973,13 @@ public final class Vector3 extends ValueType implements IEquatable */ public static void SmoothStep(Vector3 value1, Vector3 value2, float amount, Vector3 result) { - amount = (amount > 1f) ? 1f : ((amount < 0f) ? 0f : amount); - amount = (amount * amount) * (3f - (2f * amount)); - result.X = value1.X + ((value2.X - value1.X) * amount); - result.Y = value1.Y + ((value2.Y - value1.Y) * amount); - result.Z = value1.Z + ((value2.Z - value1.Z) * amount); + amount = (amount > 1f) ? 1f : ((amount < 0f) ? 0f : amount); + amount = (amount * amount) * (3f - (2f * amount)); + result.X = value1.X + ((value2.X - value1.X) * amount); + result.Y = value1.Y + ((value2.Y - value1.Y) * amount); + result.Z = value1.Z + ((value2.Z - value1.Z) * amount); } - + /** * Subtracts the specified vector from the current vector. * @@ -1048,7 +990,7 @@ public final class Vector3 extends ValueType implements IEquatable { Subtract(this, other, this); } - + /** * Subtracts a vector from a vector. * @@ -1060,11 +1002,11 @@ public final class Vector3 extends ValueType implements IEquatable */ public static Vector3 Subtract(Vector3 value1, Vector3 value2) { - Vector3 result = new Vector3(); - Subtract(value1, value2, result); - return result; + Vector3 result = new Vector3(); + Subtract(value1, value2, result); + return result; } - + /** * Subtracts a vector from a vector. * @@ -1079,9 +1021,9 @@ public final class Vector3 extends ValueType implements IEquatable */ public static void Subtract(Vector3 value1, Vector3 value2, Vector3 result) { - result.X = value1.X - value2.X; - result.Y = value1.Y - value2.Y; - result.Z = value1.Z - value2.Z; + result.X = value1.X - value2.X; + result.Y = value1.Y - value2.Y; + result.Z = value1.Z - value2.Z; } /** @@ -1104,11 +1046,11 @@ public final class Vector3 extends ValueType implements IEquatable */ public static Vector3 Transform(Vector3 position, Matrix matrix) { - Vector3 result = new Vector3(); - Transform(position, matrix, result); - return result; + Vector3 result = new Vector3(); + Transform(position, matrix, result); + return result; } - + /** * Transforms a Vector3 by a specified Quaternion rotation. * @@ -1120,11 +1062,11 @@ public final class Vector3 extends ValueType implements IEquatable */ public static Vector3 Transform(Vector3 value, Quaternion rotation) { - Vector3 result = new Vector3(); - Transform(value, rotation, result); - return result; + Vector3 result = new Vector3(); + Transform(value, rotation, result); + return result; } - + /** * Transforms a source array of Vector3s by a specified Matrix and writes the results to an existing destination array. * @@ -1141,7 +1083,7 @@ public final class Vector3 extends ValueType implements IEquatable { Transform(sourceArray, 0, matrix, destinationArray, 0, sourceArray.length); } - + /** * Transforms a source array of Vector3s by a specified Quaternion rotation and writes the results to an existing destination array. * @@ -1158,7 +1100,7 @@ public final class Vector3 extends ValueType implements IEquatable { Transform(sourceArray, 0, rotation, destinationArray, 0, sourceArray.length); } - + /** * Transforms a Vector3 by the given Matrix. * @@ -1173,14 +1115,14 @@ public final class Vector3 extends ValueType implements IEquatable */ public static void Transform(Vector3 position, Matrix matrix, Vector3 result) { - float num3 = (((position.X * matrix.M11) + (position.Y * matrix.M21)) + (position.Z * matrix.M31)) + matrix.M41; - float num2 = (((position.X * matrix.M12) + (position.Y * matrix.M22)) + (position.Z * matrix.M32)) + matrix.M42; - float num = (((position.X * matrix.M13) + (position.Y * matrix.M23)) + (position.Z * matrix.M33)) + matrix.M43; - result.X = num3; - result.Y = num2; - result.Z = num; + float num3 = (((position.X * matrix.M11) + (position.Y * matrix.M21)) + (position.Z * matrix.M31)) + matrix.M41; + float num2 = (((position.X * matrix.M12) + (position.Y * matrix.M22)) + (position.Z * matrix.M32)) + matrix.M42; + float num = (((position.X * matrix.M13) + (position.Y * matrix.M23)) + (position.Z * matrix.M33)) + matrix.M43; + result.X = num3; + result.Y = num2; + result.Z = num; } - + /** * Transforms a Vector3 by a specified Quaternion rotation. * @@ -1195,26 +1137,26 @@ public final class Vector3 extends ValueType implements IEquatable */ public static void Transform(Vector3 value, Quaternion rotation, Vector3 result) { - float num12 = rotation.X + rotation.X; - float num2 = rotation.Y + rotation.Y; - float num = rotation.Z + rotation.Z; - float num11 = rotation.W * num12; - float num10 = rotation.W * num2; - float num9 = rotation.W * num; - float num8 = rotation.X * num12; - float num7 = rotation.X * num2; - float num6 = rotation.X * num; - float num5 = rotation.Y * num2; - float num4 = rotation.Y * num; - float num3 = rotation.Z * num; - float num15 = ((value.X * ((1f - num5) - num3)) + (value.Y * (num7 - num9))) + (value.Z * (num6 + num10)); - float num14 = ((value.X * (num7 + num9)) + (value.Y * ((1f - num8) - num3))) + (value.Z * (num4 - num11)); - float num13 = ((value.X * (num6 - num10)) + (value.Y * (num4 + num11))) + (value.Z * ((1f - num8) - num5)); - result.X = num15; - result.Y = num14; - result.Z = num13; + float num12 = rotation.X + rotation.X; + float num2 = rotation.Y + rotation.Y; + float num = rotation.Z + rotation.Z; + float num11 = rotation.W * num12; + float num10 = rotation.W * num2; + float num9 = rotation.W * num; + float num8 = rotation.X * num12; + float num7 = rotation.X * num2; + float num6 = rotation.X * num; + float num5 = rotation.Y * num2; + float num4 = rotation.Y * num; + float num3 = rotation.Z * num; + float num15 = ((value.X * ((1f - num5) - num3)) + (value.Y * (num7 - num9))) + (value.Z * (num6 + num10)); + float num14 = ((value.X * (num7 + num9)) + (value.Y * ((1f - num8) - num3))) + (value.Z * (num4 - num11)); + float num13 = ((value.X * (num6 - num10)) + (value.Y * (num4 + num11))) + (value.Z * ((1f - num8) - num5)); + result.X = num15; + result.Y = num14; + result.Z = num13; } - + /** * Applies a specified transform Matrix to a specified range of an array of Vector3s and writes the results into a specified range of a destination array. * @@ -1238,36 +1180,40 @@ public final class Vector3 extends ValueType implements IEquatable */ public static void Transform(Vector3[] sourceArray, int sourceIndex, Matrix matrix, Vector3[] destinationArray, int destinationIndex, int length) { - if (sourceArray == null) - { - throw new ArgumentNullException("sourceArray"); - } - if (destinationArray == null) - { - throw new ArgumentNullException("destinationArray"); - } - if (sourceArray.length < (sourceIndex + length)) - { - throw new ArgumentException("Source array must be equal or bigger than requested length."); - } - if (destinationArray.length < (destinationIndex + length)) - { - throw new ArgumentException("Target array size must be equal or bigger than source array size."); - } - while (length > 0) - { - float x = sourceArray[sourceIndex].X; - float y = sourceArray[sourceIndex].Y; - float z = sourceArray[sourceIndex].Z; - destinationArray[destinationIndex].X = (((x * matrix.M11) + (y * matrix.M21)) + (z * matrix.M31)) + matrix.M41; - destinationArray[destinationIndex].Y = (((x * matrix.M12) + (y * matrix.M22)) + (z * matrix.M32)) + matrix.M42; - destinationArray[destinationIndex].Z = (((x * matrix.M13) + (y * matrix.M23)) + (z * matrix.M33)) + matrix.M43; - sourceIndex++; - destinationIndex++; - length--; - } + if (sourceArray == null) + { + throw new ArgumentNullException("sourceArray"); + } + + if (destinationArray == null) + { + throw new ArgumentNullException("destinationArray"); + } + + if (sourceArray.length < (sourceIndex + length)) + { + throw new ArgumentException("Source array must be equal or bigger than requested length."); + } + + if (destinationArray.length < (destinationIndex + length)) + { + throw new ArgumentException("Target array size must be equal or bigger than source array size."); + } + + while (length > 0) + { + float x = sourceArray[sourceIndex].X; + float y = sourceArray[sourceIndex].Y; + float z = sourceArray[sourceIndex].Z; + destinationArray[destinationIndex].X = (((x * matrix.M11) + (y * matrix.M21)) + (z * matrix.M31)) + matrix.M41; + destinationArray[destinationIndex].Y = (((x * matrix.M12) + (y * matrix.M22)) + (z * matrix.M32)) + matrix.M42; + destinationArray[destinationIndex].Z = (((x * matrix.M13) + (y * matrix.M23)) + (z * matrix.M33)) + matrix.M43; + sourceIndex++; + destinationIndex++; + length--; + } } - + /** * Applies a specified Quaternion rotation to a specified range of an array of Vector3s and writes the results into a specified range of a destination array. * @@ -1291,57 +1237,62 @@ public final class Vector3 extends ValueType implements IEquatable */ public static void Transform(Vector3[] sourceArray, int sourceIndex, Quaternion rotation, Vector3[] destinationArray, int destinationIndex, int length) { - if (sourceArray == null) - { - throw new ArgumentNullException("sourceArray"); - } - if (destinationArray == null) - { - throw new ArgumentNullException("destinationArray"); - } - if (sourceArray.length < (sourceIndex + length)) - { - throw new ArgumentException("Source array must be equal or bigger than requested length."); - } - if (destinationArray.length < (destinationIndex + length)) - { - throw new ArgumentException("Target array size must be equal to, or bigger than source array size."); - } - float num15 = rotation.X + rotation.X; - float num5 = rotation.Y + rotation.Y; - float num = rotation.Z + rotation.Z; - float num14 = rotation.W * num15; - float num13 = rotation.W * num5; - float num12 = rotation.W * num; - float num11 = rotation.X * num15; - float num10 = rotation.X * num5; - float num9 = rotation.X * num; - float num8 = rotation.Y * num5; - float num7 = rotation.Y * num; - float num6 = rotation.Z * num; - float num24 = (1f - num8) - num6; - float num23 = num10 - num12; - float num22 = num9 + num13; - float num21 = num10 + num12; - float num20 = (1f - num11) - num6; - float num19 = num7 - num14; - float num18 = num9 - num13; - float num17 = num7 + num14; - float num16 = (1f - num11) - num8; - while (length > 0) - { - float x = sourceArray[sourceIndex].X; - float y = sourceArray[sourceIndex].Y; - float z = sourceArray[sourceIndex].Z; - destinationArray[destinationIndex].X = ((x * num24) + (y * num23)) + (z * num22); - destinationArray[destinationIndex].Y = ((x * num21) + (y * num20)) + (z * num19); - destinationArray[destinationIndex].Z = ((x * num18) + (y * num17)) + (z * num16); - sourceIndex++; - destinationIndex++; - length--; - } + if (sourceArray == null) + { + throw new ArgumentNullException("sourceArray"); + } + + if (destinationArray == null) + { + throw new ArgumentNullException("destinationArray"); + } + + if (sourceArray.length < (sourceIndex + length)) + { + throw new ArgumentException("Source array must be equal or bigger than requested length."); + } + + if (destinationArray.length < (destinationIndex + length)) + { + throw new ArgumentException("Target array size must be equal to, or bigger than source array size."); + } + + float num15 = rotation.X + rotation.X; + float num5 = rotation.Y + rotation.Y; + float num = rotation.Z + rotation.Z; + float num14 = rotation.W * num15; + float num13 = rotation.W * num5; + float num12 = rotation.W * num; + float num11 = rotation.X * num15; + float num10 = rotation.X * num5; + float num9 = rotation.X * num; + float num8 = rotation.Y * num5; + float num7 = rotation.Y * num; + float num6 = rotation.Z * num; + float num24 = (1f - num8) - num6; + float num23 = num10 - num12; + float num22 = num9 + num13; + float num21 = num10 + num12; + float num20 = (1f - num11) - num6; + float num19 = num7 - num14; + float num18 = num9 - num13; + float num17 = num7 + num14; + float num16 = (1f - num11) - num8; + + while (length > 0) + { + float x = sourceArray[sourceIndex].X; + float y = sourceArray[sourceIndex].Y; + float z = sourceArray[sourceIndex].Z; + destinationArray[destinationIndex].X = ((x * num24) + (y * num23)) + (z * num22); + destinationArray[destinationIndex].Y = ((x * num21) + (y * num20)) + (z * num19); + destinationArray[destinationIndex].Z = ((x * num18) + (y * num17)) + (z * num16); + sourceIndex++; + destinationIndex++; + length--; + } } - + /** * Transforms a 3D vector normal by a matrix. * @@ -1353,11 +1304,11 @@ public final class Vector3 extends ValueType implements IEquatable */ public static Vector3 TransformNormal(Vector3 normal, Matrix matrix) { - Vector3 result = new Vector3(); - TransformNormal(normal, matrix, result); - return result; + Vector3 result = new Vector3(); + TransformNormal(normal, matrix, result); + return result; } - + /** * Transforms an array of 3D vector normals by a specified Matrix. * @@ -1372,9 +1323,9 @@ public final class Vector3 extends ValueType implements IEquatable */ public static void TransformNormal(Vector3[] sourceArray, Matrix matrix, Vector3[] destinationArray) { - TransformNormal(sourceArray, 0, matrix, destinationArray, 0, sourceArray.length); + TransformNormal(sourceArray, 0, matrix, destinationArray, 0, sourceArray.length); } - + /** * Transforms a vector normal by a matrix. * @@ -1389,14 +1340,14 @@ public final class Vector3 extends ValueType implements IEquatable */ public static void TransformNormal(Vector3 normal, Matrix matrix, Vector3 result) { - float num3 = ((normal.X * matrix.M11) + (normal.Y * matrix.M21)) + (normal.Z * matrix.M31); - float num2 = ((normal.X * matrix.M12) + (normal.Y * matrix.M22)) + (normal.Z * matrix.M32); - float num = ((normal.X * matrix.M13) + (normal.Y * matrix.M23)) + (normal.Z * matrix.M33); - result.X = num3; - result.Y = num2; - result.Z = num; + float num3 = ((normal.X * matrix.M11) + (normal.Y * matrix.M21)) + (normal.Z * matrix.M31); + float num2 = ((normal.X * matrix.M12) + (normal.Y * matrix.M22)) + (normal.Z * matrix.M32); + float num = ((normal.X * matrix.M13) + (normal.Y * matrix.M23)) + (normal.Z * matrix.M33); + result.X = num3; + result.Y = num2; + result.Z = num; } - + /** * Transforms a specified range in an array of 3D vector normals by a specified Matrix and writes the results to a specified range in a destination array. * @@ -1420,33 +1371,37 @@ public final class Vector3 extends ValueType implements IEquatable */ public static void TransformNormal(Vector3[] sourceArray, int sourceIndex, Matrix matrix, Vector3[] destinationArray, int destinationIndex, int length) { - if (sourceArray == null) - { - throw new ArgumentNullException("sourceArray"); - } - if (destinationArray == null) - { - throw new ArgumentNullException("destinationArray"); - } - if (sourceArray.length < (sourceIndex + length)) - { - throw new ArgumentException("Source array must be equal or bigger than requested length."); - } - if (destinationArray.length < (destinationIndex + length)) - { - throw new ArgumentException("Target array size must be equal to, or bigger than source array size."); - } - while (length > 0) - { - float x = sourceArray[sourceIndex].X; - float y = sourceArray[sourceIndex].Y; - float z = sourceArray[sourceIndex].Z; - destinationArray[destinationIndex].X = ((x * matrix.M11) + (y * matrix.M21)) + (z * matrix.M31); - destinationArray[destinationIndex].Y = ((x * matrix.M12) + (y * matrix.M22)) + (z * matrix.M32); - destinationArray[destinationIndex].Z = ((x * matrix.M13) + (y * matrix.M23)) + (z * matrix.M33); - sourceIndex++; - destinationIndex++; - length--; - } + if (sourceArray == null) + { + throw new ArgumentNullException("sourceArray"); + } + + if (destinationArray == null) + { + throw new ArgumentNullException("destinationArray"); + } + + if (sourceArray.length < (sourceIndex + length)) + { + throw new ArgumentException("Source array must be equal or bigger than requested length."); + } + + if (destinationArray.length < (destinationIndex + length)) + { + throw new ArgumentException("Target array size must be equal to, or bigger than source array size."); + } + + while (length > 0) + { + float x = sourceArray[sourceIndex].X; + float y = sourceArray[sourceIndex].Y; + float z = sourceArray[sourceIndex].Z; + destinationArray[destinationIndex].X = ((x * matrix.M11) + (y * matrix.M21)) + (z * matrix.M31); + destinationArray[destinationIndex].Y = ((x * matrix.M12) + (y * matrix.M22)) + (z * matrix.M32); + destinationArray[destinationIndex].Z = ((x * matrix.M13) + (y * matrix.M23)) + (z * matrix.M33); + sourceIndex++; + destinationIndex++; + length--; + } } } diff --git a/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/Vector4.java b/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/Vector4.java index 83b16d2..996121c 100644 --- a/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/Vector4.java +++ b/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/Vector4.java @@ -51,7 +51,7 @@ public final class Vector4 extends ValueType implements IEquatable * Returns a Vector4 with all of its components set to zero. */ public static final Vector4 Zero = new Vector4(0f, 0f, 0f, 0f); - + /** * Creates a new instance of Vector4. * @@ -60,9 +60,9 @@ public final class Vector4 extends ValueType implements IEquatable */ public Vector4(float value) { - this.X = this.Y = this.Z = this.W = value; + this.X = this.Y = this.Z = this.W = value; } - + /** * Creates a new instance of Vector4. * @@ -74,12 +74,12 @@ public final class Vector4 extends ValueType implements IEquatable */ public Vector4(Vector3 value, float w) { - this.X = value.X; - this.Y = value.Y; - this.Z = value.Z; - this.W = w; + this.X = value.X; + this.Y = value.Y; + this.Z = value.Z; + this.W = w; } - + /** * Creates a new instance of Vector4. * @@ -94,12 +94,12 @@ public final class Vector4 extends ValueType implements IEquatable */ public Vector4(Vector2 value, float z, float w) { - this.X = value.X; - this.Y = value.Y; - this.Z = z; - this.W = w; + this.X = value.X; + this.Y = value.Y; + this.Z = z; + this.W = w; } - + /** * Creates a new instance of Vector4. * @@ -115,10 +115,10 @@ public final class Vector4 extends ValueType implements IEquatable */ public Vector4(float x, float y, float z, float w) { - this.X = x; - this.Y = y; - this.Z = z; - this.W = w; + this.X = x; + this.Y = y; + this.Z = z; + this.W = w; } /** @@ -128,7 +128,7 @@ public final class Vector4 extends ValueType implements IEquatable { this.X = this.Y = this.Z = this.W = 0f; } - + /** * Adds the specified vector to the current vector. * @@ -139,7 +139,7 @@ public final class Vector4 extends ValueType implements IEquatable { Add(this, other, this); } - + /** * Adds two vectors. * @@ -151,11 +151,11 @@ public final class Vector4 extends ValueType implements IEquatable */ public static Vector4 Add(Vector4 value1, Vector4 value2) { - Vector4 result = new Vector4(); - Add(value1, value2, result); - return result; + Vector4 result = new Vector4(); + Add(value1, value2, result); + return result; } - + /** * Adds two vectors. * @@ -170,12 +170,12 @@ public final class Vector4 extends ValueType implements IEquatable */ public static void Add(Vector4 value1, Vector4 value2, Vector4 result) { - result.X = value1.X + value2.X; - result.Y = value1.Y + value2.Y; - result.Z = value1.Z + value2.Z; - result.W = value1.W + value2.W; + result.X = value1.X + value2.X; + result.Y = value1.Y + value2.Y; + result.Z = value1.Z + value2.Z; + result.W = value1.W + value2.W; } - + /** * Returns a Vector4 containing the 4D Cartesian coordinates of a point specified in barycentric (areal) coordinates relative to a 4D triangle. * @@ -196,11 +196,11 @@ public final class Vector4 extends ValueType implements IEquatable */ public static Vector4 Barycentric(Vector4 value1, Vector4 value2, Vector4 value3, float amount1, float amount2) { - Vector4 result = new Vector4(); - Barycentric(value1, value2, value3, amount1, amount2, result); - return result; + Vector4 result = new Vector4(); + Barycentric(value1, value2, value3, amount1, amount2, result); + return result; } - + /** * Returns a Vector4 containing the 4D Cartesian coordinates of a point specified in barycentric (areal) coordinates relative to a 4D triangle. * @@ -224,12 +224,12 @@ public final class Vector4 extends ValueType implements IEquatable */ public static void Barycentric(Vector4 value1, Vector4 value2, Vector4 value3, float amount1, float amount2, Vector4 result) { - result.X = (value1.X + (amount1 * (value2.X - value1.X))) + (amount2 * (value3.X - value1.X)); - result.Y = (value1.Y + (amount1 * (value2.Y - value1.Y))) + (amount2 * (value3.Y - value1.Y)); - result.Z = (value1.Z + (amount1 * (value2.Z - value1.Z))) + (amount2 * (value3.Z - value1.Z)); - result.W = (value1.W + (amount1 * (value2.W - value1.W))) + (amount2 * (value3.W - value1.W)); + result.X = (value1.X + (amount1 * (value2.X - value1.X))) + (amount2 * (value3.X - value1.X)); + result.Y = (value1.Y + (amount1 * (value2.Y - value1.Y))) + (amount2 * (value3.Y - value1.Y)); + result.Z = (value1.Z + (amount1 * (value2.Z - value1.Z))) + (amount2 * (value3.Z - value1.Z)); + result.W = (value1.W + (amount1 * (value2.W - value1.W))) + (amount2 * (value3.W - value1.W)); } - + /** * Performs a Catmull-Rom interpolation using the specified positions. * @@ -250,11 +250,11 @@ public final class Vector4 extends ValueType implements IEquatable */ public static Vector4 CatmullRom(Vector4 value1, Vector4 value2, Vector4 value3, Vector4 value4, float amount) { - Vector4 result = new Vector4(); - CatmullRom(value1, value2, value3, value4, amount, result); - return result; + Vector4 result = new Vector4(); + CatmullRom(value1, value2, value3, value4, amount, result); + return result; } - + /** * Performs a Catmull-Rom interpolation using the specified positions. * @@ -278,14 +278,14 @@ public final class Vector4 extends ValueType implements IEquatable */ public static void CatmullRom(Vector4 value1, Vector4 value2, Vector4 value3, Vector4 value4, float amount, Vector4 result) { - float num = amount * amount; - float num2 = amount * num; - result.X = 0.5f * ((((2f * value2.X) + ((-value1.X + value3.X) * amount)) + (((((2f * value1.X) - (5f * value2.X)) + (4f * value3.X)) - value4.X) * num)) + ((((-value1.X + (3f * value2.X)) - (3f * value3.X)) + value4.X) * num2)); - result.Y = 0.5f * ((((2f * value2.Y) + ((-value1.Y + value3.Y) * amount)) + (((((2f * value1.Y) - (5f * value2.Y)) + (4f * value3.Y)) - value4.Y) * num)) + ((((-value1.Y + (3f * value2.Y)) - (3f * value3.Y)) + value4.Y) * num2)); - result.Z = 0.5f * ((((2f * value2.Z) + ((-value1.Z + value3.Z) * amount)) + (((((2f * value1.Z) - (5f * value2.Z)) + (4f * value3.Z)) - value4.Z) * num)) + ((((-value1.Z + (3f * value2.Z)) - (3f * value3.Z)) + value4.Z) * num2)); - result.W = 0.5f * ((((2f * value2.W) + ((-value1.W + value3.W) * amount)) + (((((2f * value1.W) - (5f * value2.W)) + (4f * value3.W)) - value4.W) * num)) + ((((-value1.W + (3f * value2.W)) - (3f * value3.W)) + value4.W) * num2)); + float num = amount * amount; + float num2 = amount * num; + result.X = 0.5f * ((((2f * value2.X) + ((-value1.X + value3.X) * amount)) + (((((2f * value1.X) - (5f * value2.X)) + (4f * value3.X)) - value4.X) * num)) + ((((-value1.X + (3f * value2.X)) - (3f * value3.X)) + value4.X) * num2)); + result.Y = 0.5f * ((((2f * value2.Y) + ((-value1.Y + value3.Y) * amount)) + (((((2f * value1.Y) - (5f * value2.Y)) + (4f * value3.Y)) - value4.Y) * num)) + ((((-value1.Y + (3f * value2.Y)) - (3f * value3.Y)) + value4.Y) * num2)); + result.Z = 0.5f * ((((2f * value2.Z) + ((-value1.Z + value3.Z) * amount)) + (((((2f * value1.Z) - (5f * value2.Z)) + (4f * value3.Z)) - value4.Z) * num)) + ((((-value1.Z + (3f * value2.Z)) - (3f * value3.Z)) + value4.Z) * num2)); + result.W = 0.5f * ((((2f * value2.W) + ((-value1.W + value3.W) * amount)) + (((((2f * value1.W) - (5f * value2.W)) + (4f * value3.W)) - value4.W) * num)) + ((((-value1.W + (3f * value2.W)) - (3f * value3.W)) + value4.W) * num2)); } - + /** * Restricts a value to be within a specified range. * @@ -300,11 +300,11 @@ public final class Vector4 extends ValueType implements IEquatable */ public static Vector4 Clamp(Vector4 value1, Vector4 min, Vector4 max) { - Vector4 result = new Vector4(); - Clamp(value1, min, max, result); - return result; + Vector4 result = new Vector4(); + Clamp(value1, min, max, result); + return result; } - + /** * Restricts a value to be within a specified range. * @@ -327,7 +327,7 @@ public final class Vector4 extends ValueType implements IEquatable result.Z = MathHelper.Clamp(value1.Z, min.Z, max.Z); result.W = MathHelper.Clamp(value1.W, min.W, max.W); } - + /** * Calculates the distance between two vectors. * @@ -339,36 +339,15 @@ public final class Vector4 extends ValueType implements IEquatable */ public static float Distance(Vector4 value1, Vector4 value2) { - float num4 = value1.X - value2.X; - float num3 = value1.Y - value2.Y; - float num2 = value1.Z - value2.Z; - float num = value1.W - value2.W; - float num5 = (((num4 * num4) + (num3 * num3)) + (num2 * num2)) + (num * num); - return (float) Math.sqrt((double) num5); + float num4 = value1.X - value2.X; + float num3 = value1.Y - value2.Y; + float num2 = value1.Z - value2.Z; + float num = value1.W - value2.W; + float num5 = (((num4 * num4) + (num3 * num3)) + (num2 * num2)) + (num * num); + + return (float) Math.sqrt((double) num5); } - - /** - * Calculates the distance between two vectors. - * - * @param value1 - * Source vector. - * - * @param value2 - * Source vector. - * - * @param result - * [OutAttribute] The distance between the vectors. - */ - public static void Distance(Vector4 value1, Vector4 value2, float result) - { - float num4 = value1.X - value2.X; - float num3 = value1.Y - value2.Y; - float num2 = value1.Z - value2.Z; - float num = value1.W - value2.W; - float num5 = (((num4 * num4) + (num3 * num3)) + (num2 * num2)) + (num * num); - result = (float) Math.sqrt((double) num5); - } - + /** * Calculates the distance between two vectors squared. * @@ -380,34 +359,14 @@ public final class Vector4 extends ValueType implements IEquatable */ public static float DistanceSquared(Vector4 value1, Vector4 value2) { - float num4 = value1.X - value2.X; - float num3 = value1.Y - value2.Y; - float num2 = value1.Z - value2.Z; - float num = value1.W - value2.W; - return ((((num4 * num4) + (num3 * num3)) + (num2 * num2)) + (num * num)); + float num4 = value1.X - value2.X; + float num3 = value1.Y - value2.Y; + float num2 = value1.Z - value2.Z; + float num = value1.W - value2.W; + + return ((((num4 * num4) + (num3 * num3)) + (num2 * num2)) + (num * num)); } - - /** - * Calculates the distance between two vectors squared. - * - * @param value1 - * Source vector. - * - * @param value2 - * Source vector. - * - * @param result - * [OutAttribute] The distance between the two vectors squared. - */ - public static void DistanceSquared(Vector4 value1, Vector4 value2, float result) - { - float num4 = value1.X - value2.X; - float num3 = value1.Y - value2.Y; - float num2 = value1.Z - value2.Z; - float num = value1.W - value2.W; - result = (((num4 * num4) + (num3 * num3)) + (num2 * num2)) + (num * num); - } - + /** * Divides the components of the current vector by the components of another vector. * @@ -418,7 +377,7 @@ public final class Vector4 extends ValueType implements IEquatable { Divide(this, other, this); } - + /** * Divides the components of a vector by the components of another vector. * @@ -430,11 +389,11 @@ public final class Vector4 extends ValueType implements IEquatable */ public static Vector4 Divide(Vector4 value1, Vector4 value2) { - Vector4 result = new Vector4(); - Divide(value1, value2, result); - return result; + Vector4 result = new Vector4(); + Divide(value1, value2, result); + return result; } - + /** * Divides the current vector by a scalar value. * @@ -445,7 +404,7 @@ public final class Vector4 extends ValueType implements IEquatable { Divide(this, divider, this); } - + /** * Divides a vector by a scalar value. * @@ -457,11 +416,11 @@ public final class Vector4 extends ValueType implements IEquatable */ public static Vector4 Divide(Vector4 value1, float divider) { - Vector4 result = new Vector4(); - Divide(value1, divider, result); - return result; + Vector4 result = new Vector4(); + Divide(value1, divider, result); + return result; } - + /** * Divides the components of a vector by the components of another vector. * @@ -476,12 +435,12 @@ public final class Vector4 extends ValueType implements IEquatable */ public static void Divide(Vector4 value1, Vector4 value2, Vector4 result) { - result.X = value1.X / value2.X; - result.Y = value1.Y / value2.Y; - result.Z = value1.Z / value2.Z; - result.W = value1.W / value2.W; + result.X = value1.X / value2.X; + result.Y = value1.Y / value2.Y; + result.Z = value1.Z / value2.Z; + result.W = value1.W / value2.W; } - + /** * Divides a vector by a scalar value. * @@ -496,13 +455,13 @@ public final class Vector4 extends ValueType implements IEquatable */ public static void Divide(Vector4 value1, float divider, Vector4 result) { - float num = 1f / divider; - result.X = value1.X * num; - result.Y = value1.Y * num; - result.Z = value1.Z * num; - result.W = value1.W * num; + float num = 1f / divider; + result.X = value1.X * num; + result.Y = value1.Y * num; + result.Z = value1.Z * num; + result.W = value1.W * num; } - + /** * Calculates the dot product of two vectors. * @@ -514,26 +473,9 @@ public final class Vector4 extends ValueType implements IEquatable */ public static float Dot(Vector4 vector1, Vector4 vector2) { - return ((((vector1.X * vector2.X) + (vector1.Y * vector2.Y)) + (vector1.Z * vector2.Z)) + (vector1.W * vector2.W)); + return ((((vector1.X * vector2.X) + (vector1.Y * vector2.Y)) + (vector1.Z * vector2.Z)) + (vector1.W * vector2.W)); } - - /** - * Calculates the dot product of two vectors. - * - * @param vector1 - * Source vector. - * - * @param vector2 - * Source vector. - * - * @param result - * [OutAttribute] The dot product of the two vectors. - */ - public static void Dot(Vector4 vector1, Vector4 vector2, float result) - { - result = (((vector1.X * vector2.X) + (vector1.Y * vector2.Y)) + (vector1.Z * vector2.Z)) + (vector1.W * vector2.W); - } - + /** * Returns a value that indicates whether the current instance is equal to a specified object. * @@ -545,7 +487,7 @@ public final class Vector4 extends ValueType implements IEquatable { return (obj != null && obj instanceof Vector4) ? this.Equals((Vector4)obj) : false; } - + /** * Determines whether the specified Object is equal to the Vector4. * @@ -554,18 +496,18 @@ public final class Vector4 extends ValueType implements IEquatable */ public boolean Equals(Vector4 other) { - return ((((this.X == other.X) && (this.Y == other.Y)) && (this.Z == other.Z)) && (this.W == other.W)); + return ((((this.X == other.X) && (this.Y == other.Y)) && (this.Z == other.Z)) && (this.W == other.W)); } - + /** * Gets the hash code of this object. */ @Override public int hashCode() { - return ((((int)this.X ^ (int)this.Y) ^ (int)this.Z) ^ (int)this.W); + return ((((int)this.X ^ (int)this.Y) ^ (int)this.Z) ^ (int)this.W); } - + /** * Performs a Hermite spline interpolation. * @@ -586,11 +528,11 @@ public final class Vector4 extends ValueType implements IEquatable */ public static Vector4 Hermite(Vector4 value1, Vector4 tangent1, Vector4 value2, Vector4 tangent2, float amount) { - Vector4 result = new Vector4(); - Hermite(value1, tangent1, value2, tangent2, amount, result); - return result; + Vector4 result = new Vector4(); + Hermite(value1, tangent1, value2, tangent2, amount, result); + return result; } - + /** * Performs a Hermite spline interpolation. * @@ -614,25 +556,26 @@ public final class Vector4 extends ValueType implements IEquatable */ public static void Hermite(Vector4 value1, Vector4 tangent1, Vector4 value2, Vector4 tangent2, float amount, Vector4 result) { - float num = amount * amount; - float num6 = amount * num; - float num5 = ((2f * num6) - (3f * num)) + 1f; - float num4 = (-2f * num6) + (3f * num); - float num3 = (num6 - (2f * num)) + amount; - float num2 = num6 - num; - result.X = (((value1.X * num5) + (value2.X * num4)) + (tangent1.X * num3)) + (tangent2.X * num2); - result.Y = (((value1.Y * num5) + (value2.Y * num4)) + (tangent1.Y * num3)) + (tangent2.Y * num2); - result.Z = (((value1.Z * num5) + (value2.Z * num4)) + (tangent1.Z * num3)) + (tangent2.Z * num2); - result.W = (((value1.W * num5) + (value2.W * num4)) + (tangent1.W * num3)) + (tangent2.W * num2); + float num = amount * amount; + float num6 = amount * num; + float num5 = ((2f * num6) - (3f * num)) + 1f; + float num4 = (-2f * num6) + (3f * num); + float num3 = (num6 - (2f * num)) + amount; + float num2 = num6 - num; + result.X = (((value1.X * num5) + (value2.X * num4)) + (tangent1.X * num3)) + (tangent2.X * num2); + result.Y = (((value1.Y * num5) + (value2.Y * num4)) + (tangent1.Y * num3)) + (tangent2.Y * num2); + result.Z = (((value1.Z * num5) + (value2.Z * num4)) + (tangent1.Z * num3)) + (tangent2.Z * num2); + result.W = (((value1.W * num5) + (value2.W * num4)) + (tangent1.W * num3)) + (tangent2.W * num2); } - + /** * Calculates the length of the vector. */ public float Length() { - float num = (((this.X * this.X) + (this.Y * this.Y)) + (this.Z * this.Z)) + (this.W * this.W); - return (float) Math.sqrt((double) num); + float num = (((this.X * this.X) + (this.Y * this.Y)) + (this.Z * this.Z)) + (this.W * this.W); + + return (float) Math.sqrt((double) num); } /** @@ -640,9 +583,9 @@ public final class Vector4 extends ValueType implements IEquatable */ public float LengthSquared() { - return ((((this.X * this.X) + (this.Y * this.Y)) + (this.Z * this.Z)) + (this.W * this.W)); + return ((((this.X * this.X) + (this.Y * this.Y)) + (this.Z * this.Z)) + (this.W * this.W)); } - + /** * Performs a linear interpolation between two vectors. * @@ -657,11 +600,11 @@ public final class Vector4 extends ValueType implements IEquatable */ public static Vector4 Lerp(Vector4 value1, Vector4 value2, float amount) { - Vector4 result = new Vector4(); - Lerp(value1, value2, amount); - return result; + Vector4 result = new Vector4(); + Lerp(value1, value2, amount); + return result; } - + /** * Performs a linear interpolation between two vectors. * @@ -679,12 +622,12 @@ public final class Vector4 extends ValueType implements IEquatable */ public static void Lerp(Vector4 value1, Vector4 value2, float amount, Vector4 result) { - result.X = value1.X + ((value2.X - value1.X) * amount); - result.Y = value1.Y + ((value2.Y - value1.Y) * amount); - result.Z = value1.Z + ((value2.Z - value1.Z) * amount); - result.W = value1.W + ((value2.W - value1.W) * amount); + result.X = value1.X + ((value2.X - value1.X) * amount); + result.Y = value1.Y + ((value2.Y - value1.Y) * amount); + result.Z = value1.Z + ((value2.Z - value1.Z) * amount); + result.W = value1.W + ((value2.W - value1.W) * amount); } - + /** * Returns a vector that contains the highest value from each matching pair of components. * @@ -696,11 +639,11 @@ public final class Vector4 extends ValueType implements IEquatable */ public static Vector4 Max(Vector4 value1, Vector4 value2) { - Vector4 result = new Vector4(); - Max(value1, value2, result); - return result; + Vector4 result = new Vector4(); + Max(value1, value2, result); + return result; } - + /** * Returns a vector that contains the highest value from each matching pair of components. * @@ -715,12 +658,12 @@ public final class Vector4 extends ValueType implements IEquatable */ public static void Max(Vector4 value1, Vector4 value2, Vector4 result) { - result.X = (value1.X > value2.X) ? value1.X : value2.X; - result.Y = (value1.Y > value2.Y) ? value1.Y : value2.Y; - result.Z = (value1.Z > value2.Z) ? value1.Z : value2.Z; - result.W = (value1.W > value2.W) ? value1.W : value2.W; + result.X = (value1.X > value2.X) ? value1.X : value2.X; + result.Y = (value1.Y > value2.Y) ? value1.Y : value2.Y; + result.Z = (value1.Z > value2.Z) ? value1.Z : value2.Z; + result.W = (value1.W > value2.W) ? value1.W : value2.W; } - + /** * Returns a vector that contains the lowest value from each matching pair of components. * @@ -732,11 +675,11 @@ public final class Vector4 extends ValueType implements IEquatable */ public static Vector4 Min(Vector4 value1, Vector4 value2) { - Vector4 result = new Vector4(); - Min(value1, value2, result); - return result; + Vector4 result = new Vector4(); + Min(value1, value2, result); + return result; } - + /** * Returns a vector that contains the lowest value from each matching pair of components. * @@ -751,12 +694,12 @@ public final class Vector4 extends ValueType implements IEquatable */ public static void Min(Vector4 value1, Vector4 value2, Vector4 result) { - result.X = (value1.X < value2.X) ? value1.X : value2.X; - result.Y = (value1.Y < value2.Y) ? value1.Y : value2.Y; - result.Z = (value1.Z < value2.Z) ? value1.Z : value2.Z; - result.W = (value1.W < value2.W) ? value1.W : value2.W; + result.X = (value1.X < value2.X) ? value1.X : value2.X; + result.Y = (value1.Y < value2.Y) ? value1.Y : value2.Y; + result.Z = (value1.Z < value2.Z) ? value1.Z : value2.Z; + result.W = (value1.W < value2.W) ? value1.W : value2.W; } - + /** * Multiplies the components of the current vector by the components of another vector. * @@ -767,7 +710,7 @@ public final class Vector4 extends ValueType implements IEquatable { Multiply(this, other, this); } - + /** * Multiplies the components of two vectors by each other. * @@ -779,11 +722,11 @@ public final class Vector4 extends ValueType implements IEquatable */ public static Vector4 Multiply(Vector4 value1, Vector4 value2) { - Vector4 result = new Vector4(); - Multiply(value1, value2, result); - return result; + Vector4 result = new Vector4(); + Multiply(value1, value2, result); + return result; } - + /** * Multiplies the current vector by a scalar. * @@ -794,7 +737,7 @@ public final class Vector4 extends ValueType implements IEquatable { Multiply(this, scaleFactor, this); } - + /** * Multiplies a vector by a scalar. * @@ -806,11 +749,11 @@ public final class Vector4 extends ValueType implements IEquatable */ public static Vector4 Multiply(Vector4 value1, float scaleFactor) { - Vector4 result = new Vector4(); - Multiply(value1, scaleFactor, result); - return result; + Vector4 result = new Vector4(); + Multiply(value1, scaleFactor, result); + return result; } - + /** * Multiplies the components of two vectors by each other. * @@ -825,12 +768,12 @@ public final class Vector4 extends ValueType implements IEquatable */ public static void Multiply(Vector4 value1, Vector4 value2, Vector4 result) { - result.X = value1.X * value2.X; - result.Y = value1.Y * value2.Y; - result.Z = value1.Z * value2.Z; - result.W = value1.W * value2.W; + result.X = value1.X * value2.X; + result.Y = value1.Y * value2.Y; + result.Z = value1.Z * value2.Z; + result.W = value1.W * value2.W; } - + /** * Multiplies a vector by a scalar. * @@ -845,12 +788,12 @@ public final class Vector4 extends ValueType implements IEquatable */ public static void Multiply(Vector4 value1, float scaleFactor, Vector4 result) { - result.X = value1.X * scaleFactor; - result.Y = value1.Y * scaleFactor; - result.Z = value1.Z * scaleFactor; - result.W = value1.W * scaleFactor; + result.X = value1.X * scaleFactor; + result.Y = value1.Y * scaleFactor; + result.Z = value1.Z * scaleFactor; + result.W = value1.W * scaleFactor; } - + /** * Returns the current vector pointing in the opposite direction. */ @@ -858,7 +801,7 @@ public final class Vector4 extends ValueType implements IEquatable { Negate(this, this); } - + /** * Returns a vector pointing in the opposite direction. * @@ -867,11 +810,11 @@ public final class Vector4 extends ValueType implements IEquatable */ public static Vector4 Negate(Vector4 value) { - Vector4 result = new Vector4(); - Negate(value, result); - return result; + Vector4 result = new Vector4(); + Negate(value, result); + return result; } - + /** * Returns a vector pointing in the opposite direction. * @@ -883,25 +826,25 @@ public final class Vector4 extends ValueType implements IEquatable */ public static void Negate(Vector4 value, Vector4 result) { - result.X = -value.X; - result.Y = -value.Y; - result.Z = -value.Z; - result.W = -value.W; + result.X = -value.X; + result.Y = -value.Y; + result.Z = -value.Z; + result.W = -value.W; } - + /** * Turns the current vector into a unit vector. */ public void Normalize() { - float num2 = (((this.X * this.X) + (this.Y * this.Y)) + (this.Z * this.Z)) + (this.W * this.W); - float num = 1f / ((float) Math.sqrt((double) num2)); - this.X *= num; - this.Y *= num; - this.Z *= num; - this.W *= num; + float num2 = (((this.X * this.X) + (this.Y * this.Y)) + (this.Z * this.Z)) + (this.W * this.W); + float num = 1f / ((float) Math.sqrt((double) num2)); + this.X *= num; + this.Y *= num; + this.Z *= num; + this.W *= num; } - + /** * Creates a unit vector from the specified vector. * @@ -910,11 +853,11 @@ public final class Vector4 extends ValueType implements IEquatable */ public static Vector4 Normalize(Vector4 vector) { - Vector4 result = new Vector4(); - Normalize(vector, result); - return result; + Vector4 result = new Vector4(); + Normalize(vector, result); + return result; } - + /** * Returns a normalized version of the specified vector. * @@ -926,14 +869,14 @@ public final class Vector4 extends ValueType implements IEquatable */ public static void Normalize(Vector4 vector, Vector4 result) { - float num2 = (((vector.X * vector.X) + (vector.Y * vector.Y)) + (vector.Z * vector.Z)) + (vector.W * vector.W); - float num = 1f / ((float) Math.sqrt((double) num2)); - result.X = vector.X * num; - result.Y = vector.Y * num; - result.Z = vector.Z * num; - result.W = vector.W * num; + float num2 = (((vector.X * vector.X) + (vector.Y * vector.Y)) + (vector.Z * vector.Z)) + (vector.W * vector.W); + float num = 1f / ((float) Math.sqrt((double) num2)); + result.X = vector.X * num; + result.Y = vector.Y * num; + result.Z = vector.Z * num; + result.W = vector.W * num; } - + /** * Interpolates between two values using a cubic equation. * @@ -948,11 +891,11 @@ public final class Vector4 extends ValueType implements IEquatable */ public static Vector4 SmoothStep(Vector4 value1, Vector4 value2, float amount) { - Vector4 result = new Vector4(); - SmoothStep(value1, value2, amount, result); - return result; + Vector4 result = new Vector4(); + SmoothStep(value1, value2, amount, result); + return result; } - + /** * Interpolates between two values using a cubic equation. * @@ -970,14 +913,14 @@ public final class Vector4 extends ValueType implements IEquatable */ public static void SmoothStep(Vector4 value1, Vector4 value2, float amount, Vector4 result) { - amount = (amount > 1f) ? 1f : ((amount < 0f) ? 0f : amount); - amount = (amount * amount) * (3f - (2f * amount)); - result.X = value1.X + ((value2.X - value1.X) * amount); - result.Y = value1.Y + ((value2.Y - value1.Y) * amount); - result.Z = value1.Z + ((value2.Z - value1.Z) * amount); - result.W = value1.W + ((value2.W - value1.W) * amount); + amount = (amount > 1f) ? 1f : ((amount < 0f) ? 0f : amount); + amount = (amount * amount) * (3f - (2f * amount)); + result.X = value1.X + ((value2.X - value1.X) * amount); + result.Y = value1.Y + ((value2.Y - value1.Y) * amount); + result.Z = value1.Z + ((value2.Z - value1.Z) * amount); + result.W = value1.W + ((value2.W - value1.W) * amount); } - + /** * Subtracts a vector from the current vector. * @@ -987,7 +930,7 @@ public final class Vector4 extends ValueType implements IEquatable { Subtract(this, other, this); } - + /** * Subtracts a vector from a vector. * @@ -999,11 +942,11 @@ public final class Vector4 extends ValueType implements IEquatable */ public static Vector4 Subtract(Vector4 value1, Vector4 value2) { - Vector4 result = new Vector4(); - Subtract(value1, value2, result); - return result; + Vector4 result = new Vector4(); + Subtract(value1, value2, result); + return result; } - + /** * Subtracts a vector from a vector. * @@ -1018,21 +961,21 @@ public final class Vector4 extends ValueType implements IEquatable */ public static void Subtract(Vector4 value1, Vector4 value2, Vector4 result) { - result.X = value1.X - value2.X; - result.Y = value1.Y - value2.Y; - result.Z = value1.Z - value2.Z; - result.W = value1.W - value2.W; + result.X = value1.X - value2.X; + result.Y = value1.Y - value2.Y; + result.Z = value1.Z - value2.Z; + result.W = value1.W - value2.W; } - + /** * Retrieves a string representation of the current object. */ @Override public String toString() { - return String.format(Locale.getDefault(), "{X:%f Y:%f Z:%f W:%f}", this.X, this.Y, this.Z, this.W); + return String.format(Locale.getDefault(), "{X:%f Y:%f Z:%f W:%f}", this.X, this.Y, this.Z, this.W); } - + /** * Transforms a Vector2 by the given Matrix. * @@ -1044,11 +987,11 @@ public final class Vector4 extends ValueType implements IEquatable */ public static Vector4 Transform(Vector2 position, Matrix matrix) { - Vector4 result = new Vector4(); - Transform(position, matrix, result); - return result; + Vector4 result = new Vector4(); + Transform(position, matrix, result); + return result; } - + /** * Transforms a Vector2 by a specified Quaternion into a Vector4. * @@ -1060,11 +1003,11 @@ public final class Vector4 extends ValueType implements IEquatable */ public static Vector4 Transform(Vector2 value, Quaternion rotation) { - Vector4 result = new Vector4(); - Transform(value, rotation, result); - return result; + Vector4 result = new Vector4(); + Transform(value, rotation, result); + return result; } - + /** * Transforms a Vector3 by the given Matrix. * @@ -1076,11 +1019,11 @@ public final class Vector4 extends ValueType implements IEquatable */ public static Vector4 Transform(Vector3 position, Matrix matrix) { - Vector4 result = new Vector4(); - Transform(position, matrix, result); - return result; + Vector4 result = new Vector4(); + Transform(position, matrix, result); + return result; } - + /** * Transforms a Vector3 by a specified Quaternion into a Vector4. * @@ -1092,11 +1035,11 @@ public final class Vector4 extends ValueType implements IEquatable */ public static Vector4 Transform(Vector3 value, Quaternion rotation) { - Vector4 result = new Vector4(); - Transform(value, rotation, result); - return result; + Vector4 result = new Vector4(); + Transform(value, rotation, result); + return result; } - + /** * Transforms a Vector4 by the specified Matrix. * @@ -1108,11 +1051,11 @@ public final class Vector4 extends ValueType implements IEquatable */ public static Vector4 Transform(Vector4 vector, Matrix matrix) { - Vector4 result = new Vector4(); - Transform(vector, matrix, result); - return result; + Vector4 result = new Vector4(); + Transform(vector, matrix, result); + return result; } - + /** * Transforms a Vector4 by a specified Quaternion. * @@ -1128,7 +1071,7 @@ public final class Vector4 extends ValueType implements IEquatable Transform(value, rotation, result); return result; } - + /** * Transforms an array of Vector4s by a specified Quaternion. * @@ -1145,7 +1088,7 @@ public final class Vector4 extends ValueType implements IEquatable { Transform(sourceArray, 0, rotation, destinationArray, 0, sourceArray.length); } - + /** * Transforms a Vector2 by the given Matrix. * @@ -1160,16 +1103,16 @@ public final class Vector4 extends ValueType implements IEquatable */ public static void Transform(Vector2 position, Matrix matrix, Vector4 result) { - float num4 = ((position.X * matrix.M11) + (position.Y * matrix.M21)) + matrix.M41; - float num3 = ((position.X * matrix.M12) + (position.Y * matrix.M22)) + matrix.M42; - float num2 = ((position.X * matrix.M13) + (position.Y * matrix.M23)) + matrix.M43; - float num = ((position.X * matrix.M14) + (position.Y * matrix.M24)) + matrix.M44; - result.X = num4; - result.Y = num3; - result.Z = num2; - result.W = num; + float num4 = ((position.X * matrix.M11) + (position.Y * matrix.M21)) + matrix.M41; + float num3 = ((position.X * matrix.M12) + (position.Y * matrix.M22)) + matrix.M42; + float num2 = ((position.X * matrix.M13) + (position.Y * matrix.M23)) + matrix.M43; + float num = ((position.X * matrix.M14) + (position.Y * matrix.M24)) + matrix.M44; + result.X = num4; + result.Y = num3; + result.Z = num2; + result.W = num; } - + /** * Transforms a Vector2 by a specified Quaternion into a Vector4. * @@ -1184,27 +1127,27 @@ public final class Vector4 extends ValueType implements IEquatable */ public static void Transform(Vector2 value, Quaternion rotation, Vector4 result) { - float num6 = rotation.X + rotation.X; - float num2 = rotation.Y + rotation.Y; - float num = rotation.Z + rotation.Z; - float num15 = rotation.W * num6; - float num14 = rotation.W * num2; - float num5 = rotation.W * num; - float num13 = rotation.X * num6; - float num4 = rotation.X * num2; - float num12 = rotation.X * num; - float num11 = rotation.Y * num2; - float num10 = rotation.Y * num; - float num3 = rotation.Z * num; - float num9 = (value.X * ((1f - num11) - num3)) + (value.Y * (num4 - num5)); - float num8 = (value.X * (num4 + num5)) + (value.Y * ((1f - num13) - num3)); - float num7 = (value.X * (num12 - num14)) + (value.Y * (num10 + num15)); - result.X = num9; - result.Y = num8; - result.Z = num7; - result.W = 1f; + float num6 = rotation.X + rotation.X; + float num2 = rotation.Y + rotation.Y; + float num = rotation.Z + rotation.Z; + float num15 = rotation.W * num6; + float num14 = rotation.W * num2; + float num5 = rotation.W * num; + float num13 = rotation.X * num6; + float num4 = rotation.X * num2; + float num12 = rotation.X * num; + float num11 = rotation.Y * num2; + float num10 = rotation.Y * num; + float num3 = rotation.Z * num; + float num9 = (value.X * ((1f - num11) - num3)) + (value.Y * (num4 - num5)); + float num8 = (value.X * (num4 + num5)) + (value.Y * ((1f - num13) - num3)); + float num7 = (value.X * (num12 - num14)) + (value.Y * (num10 + num15)); + result.X = num9; + result.Y = num8; + result.Z = num7; + result.W = 1f; } - + /** * Transforms an array of Vector4s by a specified Matrix. * @@ -1221,7 +1164,7 @@ public final class Vector4 extends ValueType implements IEquatable { Transform(sourceArray, 0, matrix, destinationArray, 0, sourceArray.length); } - + /** * Transforms a Vector3 by the given Matrix. * @@ -1236,16 +1179,16 @@ public final class Vector4 extends ValueType implements IEquatable */ public static void Transform(Vector3 position, Matrix matrix, Vector4 result) { - float num4 = (((position.X * matrix.M11) + (position.Y * matrix.M21)) + (position.Z * matrix.M31)) + matrix.M41; - float num3 = (((position.X * matrix.M12) + (position.Y * matrix.M22)) + (position.Z * matrix.M32)) + matrix.M42; - float num2 = (((position.X * matrix.M13) + (position.Y * matrix.M23)) + (position.Z * matrix.M33)) + matrix.M43; - float num = (((position.X * matrix.M14) + (position.Y * matrix.M24)) + (position.Z * matrix.M34)) + matrix.M44; - result.X = num4; - result.Y = num3; - result.Z = num2; - result.W = num; + float num4 = (((position.X * matrix.M11) + (position.Y * matrix.M21)) + (position.Z * matrix.M31)) + matrix.M41; + float num3 = (((position.X * matrix.M12) + (position.Y * matrix.M22)) + (position.Z * matrix.M32)) + matrix.M42; + float num2 = (((position.X * matrix.M13) + (position.Y * matrix.M23)) + (position.Z * matrix.M33)) + matrix.M43; + float num = (((position.X * matrix.M14) + (position.Y * matrix.M24)) + (position.Z * matrix.M34)) + matrix.M44; + result.X = num4; + result.Y = num3; + result.Z = num2; + result.W = num; } - + /** * Transforms a Vector3 by a specified Quaternion into a Vector4. * @@ -1260,27 +1203,27 @@ public final class Vector4 extends ValueType implements IEquatable */ public static void Transform(Vector3 value, Quaternion rotation, Vector4 result) { - float num12 = rotation.X + rotation.X; - float num2 = rotation.Y + rotation.Y; - float num = rotation.Z + rotation.Z; - float num11 = rotation.W * num12; - float num10 = rotation.W * num2; - float num9 = rotation.W * num; - float num8 = rotation.X * num12; - float num7 = rotation.X * num2; - float num6 = rotation.X * num; - float num5 = rotation.Y * num2; - float num4 = rotation.Y * num; - float num3 = rotation.Z * num; - float num15 = ((value.X * ((1f - num5) - num3)) + (value.Y * (num7 - num9))) + (value.Z * (num6 + num10)); - float num14 = ((value.X * (num7 + num9)) + (value.Y * ((1f - num8) - num3))) + (value.Z * (num4 - num11)); - float num13 = ((value.X * (num6 - num10)) + (value.Y * (num4 + num11))) + (value.Z * ((1f - num8) - num5)); - result.X = num15; - result.Y = num14; - result.Z = num13; - result.W = 1f; + float num12 = rotation.X + rotation.X; + float num2 = rotation.Y + rotation.Y; + float num = rotation.Z + rotation.Z; + float num11 = rotation.W * num12; + float num10 = rotation.W * num2; + float num9 = rotation.W * num; + float num8 = rotation.X * num12; + float num7 = rotation.X * num2; + float num6 = rotation.X * num; + float num5 = rotation.Y * num2; + float num4 = rotation.Y * num; + float num3 = rotation.Z * num; + float num15 = ((value.X * ((1f - num5) - num3)) + (value.Y * (num7 - num9))) + (value.Z * (num6 + num10)); + float num14 = ((value.X * (num7 + num9)) + (value.Y * ((1f - num8) - num3))) + (value.Z * (num4 - num11)); + float num13 = ((value.X * (num6 - num10)) + (value.Y * (num4 + num11))) + (value.Z * ((1f - num8) - num5)); + result.X = num15; + result.Y = num14; + result.Z = num13; + result.W = 1f; } - + /** * Transforms a Vector4 by the given Matrix. * @@ -1295,16 +1238,16 @@ public final class Vector4 extends ValueType implements IEquatable */ public static void Transform(Vector4 vector, Matrix matrix, Vector4 result) { - float num4 = (((vector.X * matrix.M11) + (vector.Y * matrix.M21)) + (vector.Z * matrix.M31)) + (vector.W * matrix.M41); - float num3 = (((vector.X * matrix.M12) + (vector.Y * matrix.M22)) + (vector.Z * matrix.M32)) + (vector.W * matrix.M42); - float num2 = (((vector.X * matrix.M13) + (vector.Y * matrix.M23)) + (vector.Z * matrix.M33)) + (vector.W * matrix.M43); - float num = (((vector.X * matrix.M14) + (vector.Y * matrix.M24)) + (vector.Z * matrix.M34)) + (vector.W * matrix.M44); - result.X = num4; - result.Y = num3; - result.Z = num2; - result.W = num; + float num4 = (((vector.X * matrix.M11) + (vector.Y * matrix.M21)) + (vector.Z * matrix.M31)) + (vector.W * matrix.M41); + float num3 = (((vector.X * matrix.M12) + (vector.Y * matrix.M22)) + (vector.Z * matrix.M32)) + (vector.W * matrix.M42); + float num2 = (((vector.X * matrix.M13) + (vector.Y * matrix.M23)) + (vector.Z * matrix.M33)) + (vector.W * matrix.M43); + float num = (((vector.X * matrix.M14) + (vector.Y * matrix.M24)) + (vector.Z * matrix.M34)) + (vector.W * matrix.M44); + result.X = num4; + result.Y = num3; + result.Z = num2; + result.W = num; } - + /** * Transforms a Vector4 by a specified Quaternion. * @@ -1319,27 +1262,27 @@ public final class Vector4 extends ValueType implements IEquatable */ public static void Transform(Vector4 value, Quaternion rotation, Vector4 result) { - float num12 = rotation.X + rotation.X; - float num2 = rotation.Y + rotation.Y; - float num = rotation.Z + rotation.Z; - float num11 = rotation.W * num12; - float num10 = rotation.W * num2; - float num9 = rotation.W * num; - float num8 = rotation.X * num12; - float num7 = rotation.X * num2; - float num6 = rotation.X * num; - float num5 = rotation.Y * num2; - float num4 = rotation.Y * num; - float num3 = rotation.Z * num; - float num15 = ((value.X * ((1f - num5) - num3)) + (value.Y * (num7 - num9))) + (value.Z * (num6 + num10)); - float num14 = ((value.X * (num7 + num9)) + (value.Y * ((1f - num8) - num3))) + (value.Z * (num4 - num11)); - float num13 = ((value.X * (num6 - num10)) + (value.Y * (num4 + num11))) + (value.Z * ((1f - num8) - num5)); - result.X = num15; - result.Y = num14; - result.Z = num13; - result.W = value.W; + float num12 = rotation.X + rotation.X; + float num2 = rotation.Y + rotation.Y; + float num = rotation.Z + rotation.Z; + float num11 = rotation.W * num12; + float num10 = rotation.W * num2; + float num9 = rotation.W * num; + float num8 = rotation.X * num12; + float num7 = rotation.X * num2; + float num6 = rotation.X * num; + float num5 = rotation.Y * num2; + float num4 = rotation.Y * num; + float num3 = rotation.Z * num; + float num15 = ((value.X * ((1f - num5) - num3)) + (value.Y * (num7 - num9))) + (value.Z * (num6 + num10)); + float num14 = ((value.X * (num7 + num9)) + (value.Y * ((1f - num8) - num3))) + (value.Z * (num4 - num11)); + float num13 = ((value.X * (num6 - num10)) + (value.Y * (num4 + num11))) + (value.Z * ((1f - num8) - num5)); + result.X = num15; + result.Y = num14; + result.Z = num13; + result.W = value.W; } - + /** * Transforms a specified range in an array of Vector4s by a specified Matrix into a specified range in a destination array. * @@ -1364,37 +1307,41 @@ public final class Vector4 extends ValueType implements IEquatable public static void Transform(Vector4[] sourceArray, int sourceIndex, Matrix matrix, Vector4[] destinationArray, int destinationIndex, int length) { if (sourceArray == null) - { - throw new ArgumentNullException("sourceArray"); - } - if (destinationArray == null) - { - throw new ArgumentNullException("destinationArray"); - } - if (sourceArray.length < (sourceIndex + length)) - { - throw new ArgumentException("Source array must be equal or bigger than requested length."); - } - if (destinationArray.length < (destinationIndex + length)) - { - throw new ArgumentException("Target array size must be equal to, or bigger than source array size."); - } - while (length > 0) - { - float x = sourceArray[sourceIndex].X; - float y = sourceArray[sourceIndex].Y; - float z = sourceArray[sourceIndex].Z; - float w = sourceArray[sourceIndex].W; - destinationArray[destinationIndex].X = (((x * matrix.M11) + (y * matrix.M21)) + (z * matrix.M31)) + (w * matrix.M41); - destinationArray[destinationIndex].Y = (((x * matrix.M12) + (y * matrix.M22)) + (z * matrix.M32)) + (w * matrix.M42); - destinationArray[destinationIndex].Z = (((x * matrix.M13) + (y * matrix.M23)) + (z * matrix.M33)) + (w * matrix.M43); - destinationArray[destinationIndex].W = (((x * matrix.M14) + (y * matrix.M24)) + (z * matrix.M34)) + (w * matrix.M44); - sourceIndex++; - destinationIndex++; - length--; - } + { + throw new ArgumentNullException("sourceArray"); + } + + if (destinationArray == null) + { + throw new ArgumentNullException("destinationArray"); + } + + if (sourceArray.length < (sourceIndex + length)) + { + throw new ArgumentException("Source array must be equal or bigger than requested length."); + } + + if (destinationArray.length < (destinationIndex + length)) + { + throw new ArgumentException("Target array size must be equal to, or bigger than source array size."); + } + + while (length > 0) + { + float x = sourceArray[sourceIndex].X; + float y = sourceArray[sourceIndex].Y; + float z = sourceArray[sourceIndex].Z; + float w = sourceArray[sourceIndex].W; + destinationArray[destinationIndex].X = (((x * matrix.M11) + (y * matrix.M21)) + (z * matrix.M31)) + (w * matrix.M41); + destinationArray[destinationIndex].Y = (((x * matrix.M12) + (y * matrix.M22)) + (z * matrix.M32)) + (w * matrix.M42); + destinationArray[destinationIndex].Z = (((x * matrix.M13) + (y * matrix.M23)) + (z * matrix.M33)) + (w * matrix.M43); + destinationArray[destinationIndex].W = (((x * matrix.M14) + (y * matrix.M24)) + (z * matrix.M34)) + (w * matrix.M44); + sourceIndex++; + destinationIndex++; + length--; + } } - + /** * Transforms a specified range in an array of Vector4s by a specified Quaternion into a specified range in a destination array. * @@ -1419,55 +1366,60 @@ public final class Vector4 extends ValueType implements IEquatable public static void Transform(Vector4[] sourceArray, int sourceIndex, Quaternion rotation, Vector4[] destinationArray, int destinationIndex, int length) { if (sourceArray == null) - { - throw new ArgumentNullException("sourceArray"); - } - if (destinationArray == null) - { - throw new ArgumentNullException("destinationArray"); - } - if (sourceArray.length < (sourceIndex + length)) - { - throw new ArgumentException("Source array must be equal to, or bigger than requested length."); - } - if (destinationArray.length < (destinationIndex + length)) - { - throw new ArgumentException("Target array size must be equal to, or bigger than source array size."); - } - float num15 = rotation.X + rotation.X; - float num5 = rotation.Y + rotation.Y; - float num = rotation.Z + rotation.Z; - float num14 = rotation.W * num15; - float num13 = rotation.W * num5; - float num12 = rotation.W * num; - float num11 = rotation.X * num15; - float num10 = rotation.X * num5; - float num9 = rotation.X * num; - float num8 = rotation.Y * num5; - float num7 = rotation.Y * num; - float num6 = rotation.Z * num; - float num25 = (1f - num8) - num6; - float num24 = num10 - num12; - float num23 = num9 + num13; - float num22 = num10 + num12; - float num21 = (1f - num11) - num6; - float num20 = num7 - num14; - float num19 = num9 - num13; - float num18 = num7 + num14; - float num17 = (1f - num11) - num8; - while (length > 0) - { - float x = sourceArray[sourceIndex].X; - float y = sourceArray[sourceIndex].Y; - float z = sourceArray[sourceIndex].Z; - float w = sourceArray[sourceIndex].W; - destinationArray[destinationIndex].X = ((x * num25) + (y * num24)) + (z * num23); - destinationArray[destinationIndex].Y = ((x * num22) + (y * num21)) + (z * num20); - destinationArray[destinationIndex].Z = ((x * num19) + (y * num18)) + (z * num17); - destinationArray[destinationIndex].W = w; - sourceIndex++; - destinationIndex++; - length--; - } + { + throw new ArgumentNullException("sourceArray"); + } + + if (destinationArray == null) + { + throw new ArgumentNullException("destinationArray"); + } + + if (sourceArray.length < (sourceIndex + length)) + { + throw new ArgumentException("Source array must be equal to, or bigger than requested length."); + } + + if (destinationArray.length < (destinationIndex + length)) + { + throw new ArgumentException("Target array size must be equal to, or bigger than source array size."); + } + + float num15 = rotation.X + rotation.X; + float num5 = rotation.Y + rotation.Y; + float num = rotation.Z + rotation.Z; + float num14 = rotation.W * num15; + float num13 = rotation.W * num5; + float num12 = rotation.W * num; + float num11 = rotation.X * num15; + float num10 = rotation.X * num5; + float num9 = rotation.X * num; + float num8 = rotation.Y * num5; + float num7 = rotation.Y * num; + float num6 = rotation.Z * num; + float num25 = (1f - num8) - num6; + float num24 = num10 - num12; + float num23 = num9 + num13; + float num22 = num10 + num12; + float num21 = (1f - num11) - num6; + float num20 = num7 - num14; + float num19 = num9 - num13; + float num18 = num7 + num14; + float num17 = (1f - num11) - num8; + + while (length > 0) + { + float x = sourceArray[sourceIndex].X; + float y = sourceArray[sourceIndex].Y; + float z = sourceArray[sourceIndex].Z; + float w = sourceArray[sourceIndex].W; + destinationArray[destinationIndex].X = ((x * num25) + (y * num24)) + (z * num23); + destinationArray[destinationIndex].Y = ((x * num22) + (y * num21)) + (z * num20); + destinationArray[destinationIndex].Z = ((x * num19) + (y * num18)) + (z * num17); + destinationArray[destinationIndex].W = w; + sourceIndex++; + destinationIndex++; + length--; + } } } diff --git a/Microsoft.Xna.Framework/src/System/Collections/ObjectModel/ReadOnlyCollection.java b/Microsoft.Xna.Framework/src/System/Collections/ObjectModel/ReadOnlyCollection.java index a0f5f9a..689c254 100644 --- a/Microsoft.Xna.Framework/src/System/Collections/ObjectModel/ReadOnlyCollection.java +++ b/Microsoft.Xna.Framework/src/System/Collections/ObjectModel/ReadOnlyCollection.java @@ -15,7 +15,7 @@ import System.*; public class ReadOnlyCollection implements Iterable { private List collection; - + /** * Initializes a new instance of the System.Collections.ObjectModel.ReadOnlyCollection class that is a read-only wrapper around the specified list. * @@ -31,10 +31,10 @@ public class ReadOnlyCollection implements Iterable { throw new ArgumentNullException("list"); } - + collection = list; } - + /** * Gets the number of elements contained in the System.Collections.ObjectModel.ReadOnlyCollection instance. */ @@ -42,7 +42,7 @@ public class ReadOnlyCollection implements Iterable { return collection.size(); } - + /** * Returns the System.Collections.Generic.IList that the System.Collections.ObjectModel.ReadOnlyCollection wraps. * @@ -53,7 +53,7 @@ public class ReadOnlyCollection implements Iterable { return collection; } - + /** * Gets the element at the specified index. * @@ -72,10 +72,10 @@ public class ReadOnlyCollection implements Iterable { throw new ArgumentOutOfRangeException("index"); } - + return collection.get(index); } - + /** * Determines whether an element is in the System.Collections.ObjectModel.ReadOnlyCollection. * @@ -89,7 +89,7 @@ public class ReadOnlyCollection implements Iterable { return (IndexOf(value) != -1); } - + /** * Copies the entire System.Collections.ObjectModel.ReadOnlyCollection to a compatible one-dimensional System.Array, starting at the specified index of the target array. * @@ -105,13 +105,13 @@ public class ReadOnlyCollection implements Iterable { throw new ArgumentNullException(); } - + // TODO: verify if ((index + collection.size()) > array.length) { throw new ArgumentException(""); } - + System.arraycopy(collection, 0, array, index, collection.size()); } @@ -123,7 +123,7 @@ public class ReadOnlyCollection implements Iterable { return collection.iterator(); } - + /** * Searches for the specified object and returns the zero-based index of the first occurrence within the entire System.Collections.ObjectModel.ReadOnlyCollection. * diff --git a/Microsoft.Xna.Framework/src/System/Single.java b/Microsoft.Xna.Framework/src/System/Single.java new file mode 100644 index 0000000..b50a36a --- /dev/null +++ b/Microsoft.Xna.Framework/src/System/Single.java @@ -0,0 +1,132 @@ +package System; + +/** + * Represents a single-precision floating-point number. + * + * @author Halofreak1990 + */ +public final class Single extends Number implements Comparable, IEquatable +{ + private static final long serialVersionUID = -6474377828799507953L; + + private float value; + + /** + * Represents the smallest positive System.Single value that is greater than zero. This field is constant. + */ + public static final float Epsilon = 1.401298E-45f; + + /** + * Initializes a new instance of the System.Single class with the specified value. + * + * @param value + * + */ + public Single(float value) + { + this.value = value; + } + + /** + * Compares this instance to a specified single-precision floating-point number and returns an integer that indicates whether the value of this instance is less than, equal to, or greater than the value of the specified single-precision floating-point number. + * + * @param other + * A single-precision floating-point number to compare. + * + * @return + * A signed number indicating the relative values of this instance and value.Return Value Description Less than zero This instance is less than value.-or- This instance is not a number (System.Single.NaN) and value is a number. Zero This instance is equal to value.-or- Both this instance and value are not a number (System.Single.NaN), System.Single.PositiveInfinity, or System.Single.NegativeInfinity. Greater than zero This instance is greater than value.-or- This instance is a number and value is not a number (System.Single.NaN). + */ + public int compareTo(Single other) + { + // TODO: implement NaN + + if (value < other.value) + { + return -1; + } + else if (value > other.value) + { + return 1; + } + + return 0; + } + + /** + * Returns a value indicating whether this instance is equal to a specified object. + * + * @param obj + * An object to compare with this instance. + * + * @return + * true if obj is an instance of System.Single and equals the value of this instance; otherwise, false. + */ + @Override + public boolean equals(Object obj) + { + return (obj != null && obj instanceof Single) ? this.Equals((Single)obj) : false; + } + + /** + * Returns a value indicating whether this instance and a specified System.Single object represent the same value. + * + * @param other + * A System.Single object to compare to this instance. + * + * @return + * true if obj is equal to this instance; otherwise, false. + */ + @Override + public boolean Equals(Single other) + { + return value == other.value; + } + + /** + * Returns the hash code for this instance. + * + * @return + * A 32-bit signed integer hash code. + */ + @Override + public int hashCode() + { + return (int)value; + } + + @Override + public double doubleValue() + { + return (double)value; + } + + @Override + public float floatValue() + { + return value; + } + + @Override + public int intValue() + { + return (int)value; + } + + @Override + public long longValue() + { + return (long)value; + } + + /** + * Converts the numeric value of this instance to its equivalent string representation. + * + * @return + * The string representation of the value of this instance. + */ + @Override + public String toString() + { + return Float.toString(value); + } +}