Removed useless functions
Added BoundingFrustum Added StorageDeviceAsyncResult Added Curve and related classes
This commit is contained in:
parent
d4c31e72c2
commit
675695c5c0
1
.gitignore
vendored
1
.gitignore
vendored
@ -6,6 +6,7 @@
|
||||
.metadata
|
||||
bin/
|
||||
tmp/
|
||||
TempFatJarBuildDir_erase_me/
|
||||
*.tmp
|
||||
*.bak
|
||||
*.swp
|
||||
|
@ -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.");
|
||||
|
@ -15,17 +15,17 @@ public final class BoundingBox extends ValueType implements IEquatable<BoundingB
|
||||
* Specifies the total number of corners (8) in the BoundingBox.
|
||||
*/
|
||||
public final int CornerCount = 8;
|
||||
|
||||
|
||||
/**
|
||||
* The maximum point the BoundingBox contains.
|
||||
*/
|
||||
public Vector3 Max;
|
||||
|
||||
|
||||
/**
|
||||
* The minimum point the BoundingBox contains.
|
||||
*/
|
||||
public Vector3 Min;
|
||||
|
||||
|
||||
/**
|
||||
* Creates an instance of BoundingBox.
|
||||
* @param min
|
||||
@ -38,7 +38,7 @@ public final class BoundingBox extends ValueType implements IEquatable<BoundingB
|
||||
Min = min;
|
||||
Max = max;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates an instance of BoundingBox.
|
||||
*/
|
||||
@ -55,25 +55,29 @@ public final class BoundingBox extends ValueType implements IEquatable<BoundingB
|
||||
*/
|
||||
public ContainmentType Contains(BoundingBox box)
|
||||
{
|
||||
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;
|
||||
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<BoundingB
|
||||
*/
|
||||
public ContainmentType Contains(BoundingSphere sphere)
|
||||
{
|
||||
float num2 = 0;
|
||||
Vector3 vector = Vector3.Zero;
|
||||
Vector3.Clamp(sphere.Center, this.Min, this.Max, vector);
|
||||
Vector3.DistanceSquared(sphere.Center, vector, num2);
|
||||
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;
|
||||
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<BoundingB
|
||||
*/
|
||||
public ContainmentType Contains(Vector3 point)
|
||||
{
|
||||
if ((((this.Min.X <= point.X) && (point.X <= this.Max.X)) && ((this.Min.Y <= point.Y) && (point.Y <= this.Max.Y))) && ((this.Min.Z <= point.Z) && (point.Z <= this.Max.Z)))
|
||||
{
|
||||
return ContainmentType.Contains;
|
||||
}
|
||||
return ContainmentType.Disjoint;
|
||||
if ((((this.Min.X <= point.X) && (point.X <= this.Max.X)) && ((this.Min.Y <= point.Y) && (point.Y <= this.Max.Y))) && ((this.Min.Z <= point.Z) && (point.Z <= this.Max.Z)))
|
||||
{
|
||||
return ContainmentType.Contains;
|
||||
}
|
||||
|
||||
return ContainmentType.Disjoint;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates the smallest BoundingBox that will contain the specified BoundingSphere.
|
||||
*
|
||||
@ -121,16 +128,16 @@ public final class BoundingBox extends ValueType implements IEquatable<BoundingB
|
||||
*/
|
||||
public static BoundingBox CreateFromSphere(BoundingSphere sphere)
|
||||
{
|
||||
BoundingBox box = new BoundingBox();
|
||||
box.Min.X = sphere.Center.X - sphere.Radius;
|
||||
box.Min.Y = sphere.Center.Y - sphere.Radius;
|
||||
box.Min.Z = sphere.Center.Z - sphere.Radius;
|
||||
box.Max.X = sphere.Center.X + sphere.Radius;
|
||||
box.Max.Y = sphere.Center.Y + sphere.Radius;
|
||||
box.Max.Z = sphere.Center.Z + sphere.Radius;
|
||||
return box;
|
||||
BoundingBox box = new BoundingBox();
|
||||
box.Min.X = sphere.Center.X - sphere.Radius;
|
||||
box.Min.Y = sphere.Center.Y - sphere.Radius;
|
||||
box.Min.Z = sphere.Center.Z - sphere.Radius;
|
||||
box.Max.X = sphere.Center.X + sphere.Radius;
|
||||
box.Max.Y = sphere.Center.Y + sphere.Radius;
|
||||
box.Max.Z = sphere.Center.Z + sphere.Radius;
|
||||
return box;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates the smallest BoundingBox that will contain the specified BoundingSphere.
|
||||
*
|
||||
@ -142,14 +149,14 @@ public final class BoundingBox extends ValueType implements IEquatable<BoundingB
|
||||
*/
|
||||
public static void CreateFromSphere(BoundingSphere sphere, BoundingBox result)
|
||||
{
|
||||
result.Min.X = sphere.Center.X - sphere.Radius;
|
||||
result.Min.Y = sphere.Center.Y - sphere.Radius;
|
||||
result.Min.Z = sphere.Center.Z - sphere.Radius;
|
||||
result.Max.X = sphere.Center.X + sphere.Radius;
|
||||
result.Max.Y = sphere.Center.Y + sphere.Radius;
|
||||
result.Max.Z = sphere.Center.Z + sphere.Radius;
|
||||
result.Min.X = sphere.Center.X - sphere.Radius;
|
||||
result.Min.Y = sphere.Center.Y - sphere.Radius;
|
||||
result.Min.Z = sphere.Center.Z - sphere.Radius;
|
||||
result.Max.X = sphere.Center.X + sphere.Radius;
|
||||
result.Max.Y = sphere.Center.Y + sphere.Radius;
|
||||
result.Max.Z = sphere.Center.Z + sphere.Radius;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates the smallest BoundingBox that contains the two specified BoundingBox instances.
|
||||
*
|
||||
@ -161,12 +168,12 @@ public final class BoundingBox extends ValueType implements IEquatable<BoundingB
|
||||
*/
|
||||
public static BoundingBox CreateMerged(BoundingBox original, BoundingBox additional)
|
||||
{
|
||||
BoundingBox box = new BoundingBox();
|
||||
Vector3.Min(original.Min, additional.Min, box.Min);
|
||||
Vector3.Max(original.Max, additional.Max, box.Max);
|
||||
return box;
|
||||
BoundingBox box = new BoundingBox();
|
||||
Vector3.Min(original.Min, additional.Min, box.Min);
|
||||
Vector3.Max(original.Max, additional.Max, box.Max);
|
||||
return box;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates the smallest BoundingBox that contains the two specified BoundingBox instances.
|
||||
*
|
||||
@ -181,14 +188,14 @@ public final class BoundingBox extends ValueType implements IEquatable<BoundingB
|
||||
*/
|
||||
public static void CreateMerged(BoundingBox original, BoundingBox additional, BoundingBox result)
|
||||
{
|
||||
Vector3 vector = Vector3.Zero;
|
||||
Vector3 vector2 = Vector3.Zero;
|
||||
Vector3.Min(original.Min, additional.Min, vector2);
|
||||
Vector3.Max(original.Max, additional.Max, vector);
|
||||
result.Min = vector2;
|
||||
result.Max = vector;
|
||||
Vector3 vector = Vector3.Zero;
|
||||
Vector3 vector2 = Vector3.Zero;
|
||||
Vector3.Min(original.Min, additional.Min, vector2);
|
||||
Vector3.Max(original.Max, additional.Max, vector);
|
||||
result.Min = vector2;
|
||||
result.Max = vector;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Determines whether two instances of BoundingBox are equal.
|
||||
*
|
||||
@ -203,7 +210,7 @@ public final class BoundingBox extends ValueType implements IEquatable<BoundingB
|
||||
{
|
||||
return (obj != null && obj instanceof BoundingBox) ? this.Equals((BoundingBox)obj) : false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Determines whether two instances of BoundingBox are equal.
|
||||
*
|
||||
@ -217,7 +224,7 @@ public final class BoundingBox extends ValueType implements IEquatable<BoundingB
|
||||
{
|
||||
return (this.Min.Equals(other.Min) && this.Max.Equals(other.Max));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets an array of points that make up the corners of the BoundingBox.
|
||||
*
|
||||
@ -237,7 +244,7 @@ public final class BoundingBox extends ValueType implements IEquatable<BoundingB
|
||||
new Vector3(this.Min.X, this.Min.Y, this.Min.Z)
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Defines an axis-aligned box-shaped 3D volume.
|
||||
*
|
||||
@ -248,41 +255,43 @@ public final class BoundingBox extends ValueType implements IEquatable<BoundingB
|
||||
* @throws ArgumentOutOfRangeException
|
||||
*/
|
||||
public void GetCorners(Vector3[] corners)
|
||||
{
|
||||
if (corners == null)
|
||||
{
|
||||
throw new ArgumentNullException("corners");
|
||||
}
|
||||
if (corners.length < 8)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("corners", "You have to have at least 8 elements to copy corners.");
|
||||
}
|
||||
corners[0].X = this.Min.X;
|
||||
corners[0].Y = this.Max.Y;
|
||||
corners[0].Z = this.Max.Z;
|
||||
corners[1].X = this.Max.X;
|
||||
corners[1].Y = this.Max.Y;
|
||||
corners[1].Z = this.Max.Z;
|
||||
corners[2].X = this.Max.X;
|
||||
corners[2].Y = this.Min.Y;
|
||||
corners[2].Z = this.Max.Z;
|
||||
corners[3].X = this.Min.X;
|
||||
corners[3].Y = this.Min.Y;
|
||||
corners[3].Z = this.Max.Z;
|
||||
corners[4].X = this.Min.X;
|
||||
corners[4].Y = this.Max.Y;
|
||||
corners[4].Z = this.Min.Z;
|
||||
corners[5].X = this.Max.X;
|
||||
corners[5].Y = this.Max.Y;
|
||||
corners[5].Z = this.Min.Z;
|
||||
corners[6].X = this.Max.X;
|
||||
corners[6].Y = this.Min.Y;
|
||||
corners[6].Z = this.Min.Z;
|
||||
corners[7].X = this.Min.X;
|
||||
corners[7].Y = this.Min.Y;
|
||||
corners[7].Z = this.Min.Z;
|
||||
}
|
||||
|
||||
{
|
||||
if (corners == null)
|
||||
{
|
||||
throw new ArgumentNullException("corners");
|
||||
}
|
||||
|
||||
if (corners.length < 8)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("corners", "You have to have at least 8 elements to copy corners.");
|
||||
}
|
||||
|
||||
corners[0].X = this.Min.X;
|
||||
corners[0].Y = this.Max.Y;
|
||||
corners[0].Z = this.Max.Z;
|
||||
corners[1].X = this.Max.X;
|
||||
corners[1].Y = this.Max.Y;
|
||||
corners[1].Z = this.Max.Z;
|
||||
corners[2].X = this.Max.X;
|
||||
corners[2].Y = this.Min.Y;
|
||||
corners[2].Z = this.Max.Z;
|
||||
corners[3].X = this.Min.X;
|
||||
corners[3].Y = this.Min.Y;
|
||||
corners[3].Z = this.Max.Z;
|
||||
corners[4].X = this.Min.X;
|
||||
corners[4].Y = this.Max.Y;
|
||||
corners[4].Z = this.Min.Z;
|
||||
corners[5].X = this.Max.X;
|
||||
corners[5].Y = this.Max.Y;
|
||||
corners[5].Z = this.Min.Z;
|
||||
corners[6].X = this.Max.X;
|
||||
corners[6].Y = this.Min.Y;
|
||||
corners[6].Z = this.Min.Z;
|
||||
corners[7].X = this.Min.X;
|
||||
corners[7].Y = this.Min.Y;
|
||||
corners[7].Z = this.Min.Z;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the hash code for this instance.
|
||||
*
|
||||
@ -292,9 +301,9 @@ public final class BoundingBox extends ValueType implements IEquatable<BoundingB
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return (this.Min.hashCode() ^ this.Max.hashCode());
|
||||
return (this.Min.hashCode() ^ this.Max.hashCode());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks whether the current BoundingBox intersects another BoundingBox.
|
||||
*
|
||||
@ -306,17 +315,19 @@ public final class BoundingBox extends ValueType implements IEquatable<BoundingB
|
||||
*/
|
||||
public boolean Intersects(BoundingBox box)
|
||||
{
|
||||
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));
|
||||
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<BoundingB
|
||||
*/
|
||||
public boolean Intersects(BoundingSphere sphere)
|
||||
{
|
||||
float num = 0;
|
||||
Vector3 vector = Vector3.Zero;
|
||||
Vector3.Clamp(sphere.Center, this.Min, this.Max, vector);
|
||||
Vector3.DistanceSquared(sphere.Center, vector, num);
|
||||
return (num <= (sphere.Radius * sphere.Radius));
|
||||
Vector3 vector = Vector3.Zero;
|
||||
Vector3.Clamp(sphere.Center, this.Min, this.Max, vector);
|
||||
float num = Vector3.DistanceSquared(sphere.Center, vector);
|
||||
return (num <= (sphere.Radius * sphere.Radius));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks whether the current BoundingBox intersects a Plane.
|
||||
*
|
||||
@ -346,27 +356,31 @@ public final class BoundingBox extends ValueType implements IEquatable<BoundingB
|
||||
*/
|
||||
public PlaneIntersectionType Intersects(Plane plane)
|
||||
{
|
||||
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;
|
||||
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<BoundingB
|
||||
*/
|
||||
public Float Intersects(Ray ray)
|
||||
{
|
||||
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);
|
||||
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<BoundingB
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return String.format(Locale.getDefault(), "{Min:%s Max:%s}", this.Min, this.Max);
|
||||
return String.format(Locale.getDefault(), "{Min:%s Max:%s}", this.Min, this.Max);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,496 @@
|
||||
package Microsoft.Xna.Framework;
|
||||
|
||||
import System.*;
|
||||
|
||||
/**
|
||||
* Defines a frustum and helps determine whether forms intersect with it.
|
||||
*
|
||||
* @author Halofreak1990
|
||||
*/
|
||||
public class BoundingFrustum implements IEquatable<BoundingFrustum>
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
@ -15,12 +15,12 @@ public final class BoundingSphere extends ValueType implements IEquatable<Boundi
|
||||
* The center point of the sphere.
|
||||
*/
|
||||
public Vector3 Center;
|
||||
|
||||
|
||||
/**
|
||||
* The radius of the sphere.
|
||||
*/
|
||||
public float Radius;
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new instance of BoundingSphere.
|
||||
*
|
||||
@ -33,12 +33,14 @@ public final class BoundingSphere extends ValueType implements IEquatable<Boundi
|
||||
public BoundingSphere(Vector3 center, float radius)
|
||||
{
|
||||
if (radius < 0f)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("radius", "Radius must be greater than 0.");
|
||||
|
||||
}
|
||||
|
||||
Center = center;
|
||||
Radius = radius;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new instance of BoundingSphere.
|
||||
*/
|
||||
@ -59,71 +61,89 @@ public final class BoundingSphere extends ValueType implements IEquatable<Boundi
|
||||
*/
|
||||
public ContainmentType Contains(BoundingBox box)
|
||||
{
|
||||
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;
|
||||
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<Boundi
|
||||
*/
|
||||
public ContainmentType Contains(BoundingSphere sphere)
|
||||
{
|
||||
float num3 = 0;
|
||||
Vector3.Distance(this.Center, sphere.Center, num3);
|
||||
float radius = this.Radius;
|
||||
float num = sphere.Radius;
|
||||
if ((radius + num) < num3)
|
||||
{
|
||||
return ContainmentType.Disjoint;
|
||||
}
|
||||
if ((radius - num) < num3)
|
||||
{
|
||||
return ContainmentType.Intersects;
|
||||
}
|
||||
return ContainmentType.Contains;
|
||||
float num3 =Vector3.Distance(this.Center, sphere.Center);
|
||||
float radius = this.Radius;
|
||||
float num = sphere.Radius;
|
||||
|
||||
if ((radius + num) < num3)
|
||||
{
|
||||
return ContainmentType.Disjoint;
|
||||
}
|
||||
|
||||
if ((radius - num) < num3)
|
||||
{
|
||||
return ContainmentType.Intersects;
|
||||
}
|
||||
|
||||
return ContainmentType.Contains;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks whether the current BoundingSphere contains the specified point.
|
||||
*
|
||||
@ -161,121 +183,14 @@ public final class BoundingSphere extends ValueType implements IEquatable<Boundi
|
||||
*/
|
||||
public ContainmentType Contains(Vector3 point)
|
||||
{
|
||||
if (Vector3.DistanceSquared(point, this.Center) >= (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<Boundi
|
||||
*/
|
||||
public static BoundingSphere CreateFromBoundingBox(BoundingBox box)
|
||||
{
|
||||
float num = 0;
|
||||
BoundingSphere sphere = new BoundingSphere();
|
||||
Vector3.Lerp(box.Min, box.Max, 0.5f, sphere.Center);
|
||||
Vector3.Distance(box.Min, box.Max, num);
|
||||
sphere.Radius = num * 0.5f;
|
||||
return sphere;
|
||||
BoundingSphere sphere = new BoundingSphere();
|
||||
Vector3.Lerp(box.Min, box.Max, 0.5f, sphere.Center);
|
||||
float num = Vector3.Distance(box.Min, box.Max);
|
||||
sphere.Radius = num * 0.5f;
|
||||
return sphere;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates the smallest BoundingSphere that can contain a specified BoundingBox.
|
||||
*
|
||||
@ -306,12 +220,11 @@ public final class BoundingSphere extends ValueType implements IEquatable<Boundi
|
||||
*/
|
||||
public static void CreateFromBoundingBox(BoundingBox box, BoundingSphere result)
|
||||
{
|
||||
float num = 0;
|
||||
Vector3.Lerp(box.Min, box.Max, 0.5f, result.Center);
|
||||
Vector3.Distance(box.Min, box.Max, num);
|
||||
result.Radius = num * 0.5f;
|
||||
Vector3.Lerp(box.Min, box.Max, 0.5f, result.Center);
|
||||
float num = Vector3.Distance(box.Min, box.Max);
|
||||
result.Radius = num * 0.5f;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a BoundingSphere that contains the two specified BoundingSphere instances.
|
||||
*
|
||||
@ -326,31 +239,34 @@ public final class BoundingSphere extends ValueType implements IEquatable<Boundi
|
||||
*/
|
||||
public static BoundingSphere CreateMerged(BoundingSphere original, BoundingSphere additional)
|
||||
{
|
||||
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;
|
||||
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<Boundi
|
||||
*/
|
||||
public static void CreateMerged(BoundingSphere original, BoundingSphere additional, BoundingSphere result)
|
||||
{
|
||||
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;
|
||||
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<Boundi
|
||||
{
|
||||
return (obj != null && obj instanceof BoundingSphere) ? this.Equals((BoundingSphere)obj) : false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Determines whether the specified BoundingSphere is equal to the current BoundingSphere.
|
||||
*
|
||||
@ -418,7 +337,7 @@ public final class BoundingSphere extends ValueType implements IEquatable<Boundi
|
||||
{
|
||||
return (this.Center.Equals(other.Center) && this.Radius == other.Radius);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the hash code for this instance.
|
||||
*
|
||||
@ -430,7 +349,7 @@ public final class BoundingSphere extends ValueType implements IEquatable<Boundi
|
||||
{
|
||||
return (this.Center.hashCode() ^ (int)Radius);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks whether the current BoundingSphere intersects with a specified BoundingBox.
|
||||
*
|
||||
@ -442,13 +361,12 @@ public final class BoundingSphere extends ValueType implements IEquatable<Boundi
|
||||
*/
|
||||
public boolean Intersects(BoundingBox box)
|
||||
{
|
||||
float num = 0;
|
||||
Vector3 vector = Vector3.Zero;
|
||||
Vector3.Clamp(this.Center, box.Min, box.Max, vector);
|
||||
Vector3.DistanceSquared(this.Center, vector, num);
|
||||
return (num <= (this.Radius * this.Radius));
|
||||
Vector3 vector = Vector3.Zero;
|
||||
Vector3.Clamp(this.Center, box.Min, box.Max, vector);
|
||||
float num = Vector3.DistanceSquared(this.Center, vector);
|
||||
return (num <= (this.Radius * this.Radius));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks whether the current BoundingSphere intersects with a specified BoundingSphere.
|
||||
*
|
||||
@ -460,17 +378,18 @@ public final class BoundingSphere extends ValueType implements IEquatable<Boundi
|
||||
*/
|
||||
public boolean Intersects(BoundingSphere sphere)
|
||||
{
|
||||
float num3 = 0;
|
||||
Vector3.DistanceSquared(this.Center, sphere.Center, num3);
|
||||
float radius = this.Radius;
|
||||
float num = sphere.Radius;
|
||||
if ((((radius * radius) + ((2f * radius) * num)) + (num * num)) <= num3)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
float num3 = Vector3.DistanceSquared(this.Center, sphere.Center);
|
||||
float radius = this.Radius;
|
||||
float num = sphere.Radius;
|
||||
|
||||
if ((((radius * radius) + ((2f * radius) * num)) + (num * num)) <= num3)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks whether the current BoundingSphere intersects with a specified Plane.
|
||||
*
|
||||
@ -482,9 +401,9 @@ public final class BoundingSphere extends ValueType implements IEquatable<Boundi
|
||||
*/
|
||||
public PlaneIntersectionType Intersects(Plane plane)
|
||||
{
|
||||
return plane.Intersects(this);
|
||||
return plane.Intersects(this);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks whether the current BoundingSphere intersects with a specified Ray.
|
||||
*
|
||||
@ -496,73 +415,9 @@ public final class BoundingSphere extends ValueType implements IEquatable<Boundi
|
||||
*/
|
||||
public Float Intersects(Ray ray)
|
||||
{
|
||||
return ray.Intersects(this);
|
||||
return ray.Intersects(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the current BoundingSphere intersects a BoundingBox.
|
||||
*
|
||||
* @param box
|
||||
* The BoundingBox to check for intersection with.
|
||||
*
|
||||
* @param result
|
||||
* [OutAttribute] true if the BoundingSphere and BoundingBox intersect; false otherwise.
|
||||
*/
|
||||
public void Intersects(BoundingBox box, boolean result)
|
||||
{
|
||||
float num = 0;
|
||||
Vector3 vector = Vector3.Zero;
|
||||
Vector3.Clamp(this.Center, box.Min, box.Max, vector);
|
||||
Vector3.DistanceSquared(this.Center, vector, num);
|
||||
result = num <= (this.Radius * this.Radius);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the current BoundingSphere intersects another BoundingSphere.
|
||||
*
|
||||
* @param sphere
|
||||
* The BoundingSphere to check for intersection with.
|
||||
*
|
||||
* @param result
|
||||
* [OutAttribute] true if the BoundingSphere instances intersect; false otherwise.
|
||||
*/
|
||||
public void Intersects(BoundingSphere sphere, boolean result)
|
||||
{
|
||||
float num3 = 0;
|
||||
Vector3.DistanceSquared(this.Center, sphere.Center, num3);
|
||||
float radius = this.Radius;
|
||||
float num = sphere.Radius;
|
||||
result = (((radius * radius) + ((2f * radius) * num)) + (num * num)) > 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<Boundi
|
||||
{
|
||||
return String.format(Locale.getDefault(), "{Center:%s Radius:%f}", this.Center, Radius);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Translates and scales the BoundingSphere using a given Matrix.
|
||||
*
|
||||
@ -585,16 +440,16 @@ public final class BoundingSphere extends ValueType implements IEquatable<Boundi
|
||||
*/
|
||||
public BoundingSphere Transform(Matrix matrix)
|
||||
{
|
||||
BoundingSphere sphere = new BoundingSphere();
|
||||
sphere.Center = Vector3.Transform(this.Center, matrix);
|
||||
float num4 = ((matrix.M11 * matrix.M11) + (matrix.M12 * matrix.M12)) + (matrix.M13 * matrix.M13);
|
||||
float num3 = ((matrix.M21 * matrix.M21) + (matrix.M22 * matrix.M22)) + (matrix.M23 * matrix.M23);
|
||||
float num2 = ((matrix.M31 * matrix.M31) + (matrix.M32 * matrix.M32)) + (matrix.M33 * matrix.M33);
|
||||
float num = Math.max(num4, Math.max(num3, num2));
|
||||
sphere.Radius = this.Radius * ((float) Math.sqrt((double) num));
|
||||
return sphere;
|
||||
BoundingSphere sphere = new BoundingSphere();
|
||||
sphere.Center = Vector3.Transform(this.Center, matrix);
|
||||
float num4 = ((matrix.M11 * matrix.M11) + (matrix.M12 * matrix.M12)) + (matrix.M13 * matrix.M13);
|
||||
float num3 = ((matrix.M21 * matrix.M21) + (matrix.M22 * matrix.M22)) + (matrix.M23 * matrix.M23);
|
||||
float num2 = ((matrix.M31 * matrix.M31) + (matrix.M32 * matrix.M32)) + (matrix.M33 * matrix.M33);
|
||||
float num = Math.max(num4, Math.max(num3, num2));
|
||||
sphere.Radius = this.Radius * ((float) Math.sqrt((double) num));
|
||||
return sphere;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Translates and scales the BoundingSphere using a given Matrix.
|
||||
*
|
||||
@ -608,11 +463,11 @@ public final class BoundingSphere extends ValueType implements IEquatable<Boundi
|
||||
*/
|
||||
public void Transform(Matrix matrix, BoundingSphere result)
|
||||
{
|
||||
result.Center = Vector3.Transform(this.Center, matrix);
|
||||
float num4 = ((matrix.M11 * matrix.M11) + (matrix.M12 * matrix.M12)) + (matrix.M13 * matrix.M13);
|
||||
float num3 = ((matrix.M21 * matrix.M21) + (matrix.M22 * matrix.M22)) + (matrix.M23 * matrix.M23);
|
||||
float num2 = ((matrix.M31 * matrix.M31) + (matrix.M32 * matrix.M32)) + (matrix.M33 * matrix.M33);
|
||||
float num = Math.max(num4, Math.max(num3, num2));
|
||||
result.Radius = this.Radius * ((float) Math.sqrt((double) num));
|
||||
result.Center = Vector3.Transform(this.Center, matrix);
|
||||
float num4 = ((matrix.M11 * matrix.M11) + (matrix.M12 * matrix.M12)) + (matrix.M13 * matrix.M13);
|
||||
float num3 = ((matrix.M21 * matrix.M21) + (matrix.M22 * matrix.M22)) + (matrix.M23 * matrix.M23);
|
||||
float num2 = ((matrix.M31 * matrix.M31) + (matrix.M32 * matrix.M32)) + (matrix.M33 * matrix.M33);
|
||||
float num = Math.max(num4, Math.max(num3, num2));
|
||||
result.Radius = this.Radius * ((float) Math.sqrt((double) num));
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ import Microsoft.Xna.Framework.Graphics.PackedVector.*;
|
||||
public final class Color extends ValueType implements IEquatable<Color>
|
||||
{
|
||||
private int packedValue;
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new instance of the class.
|
||||
*
|
||||
@ -24,7 +24,7 @@ public final class Color extends ValueType implements IEquatable<Color>
|
||||
{
|
||||
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<Color>
|
||||
{
|
||||
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<Color>
|
||||
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<Color>
|
||||
*/
|
||||
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<Color>
|
||||
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<Color>
|
||||
*/
|
||||
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<Color>
|
||||
|
||||
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<Color>
|
||||
{
|
||||
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<Color>
|
||||
*/
|
||||
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<Color>
|
||||
*/
|
||||
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<Color>
|
||||
{
|
||||
return this.packedValue;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Linearly interpolate a color.
|
||||
*
|
||||
@ -239,26 +248,26 @@ public final class Color extends ValueType implements IEquatable<Color>
|
||||
*/
|
||||
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<Color>
|
||||
*/
|
||||
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<Color>
|
||||
{
|
||||
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.
|
||||
*/
|
||||
|
347
Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/Curve.java
Normal file
347
Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/Curve.java
Normal file
@ -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);
|
||||
}
|
||||
}
|
@ -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
|
||||
}
|
@ -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<CurveKey>, IEquatable<CurveKey>
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
@ -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<CurveKey>, Iterable<CurveKey>
|
||||
{
|
||||
private boolean isReadOnly = false;
|
||||
private List<CurveKey> 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<CurveKey>();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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<CurveKey> 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);
|
||||
}
|
||||
}
|
@ -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
|
||||
}
|
@ -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
|
||||
}
|
@ -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();
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -21,8 +21,7 @@ public final class Album implements IEquatable<Album>, IDisposable
|
||||
private SongCollection songs;
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* Gets the Artist of the Album.
|
||||
*/
|
||||
public Artist getArtist()
|
||||
{
|
||||
@ -34,12 +33,55 @@ public final class Album implements IEquatable<Album>, 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<Album>, 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<Album>, 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<Album>, 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<Album>, 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<Album>, 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;
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,14 @@ public final class Artist implements IEquatable<Artist>, 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<Artist>, 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<Artist>, 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<Artist>, 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<Artist>, 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<Artist>, IDisposable
|
||||
ThrowIfDisposed();
|
||||
return this.name;
|
||||
}
|
||||
|
||||
static
|
||||
{
|
||||
Empty = new Artist();
|
||||
}
|
||||
}
|
||||
|
@ -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<EventArgs> MediaStateChanged = new Event<EventArgs>();
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
@ -13,9 +13,32 @@ public final class Song implements IEquatable<Song>, 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<Song>, 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<Song>, 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<Song>, IDisposable
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@ -102,6 +127,7 @@ public final class Song implements IEquatable<Song>, IDisposable
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
@ -18,477 +18,401 @@ public final class Plane extends ValueType implements IEquatable<Plane>
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ public final class Ray extends ValueType implements IEquatable<Ray>
|
||||
* 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<Ray>
|
||||
*/
|
||||
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<Ray>
|
||||
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<Ray>
|
||||
{
|
||||
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<Ray>
|
||||
{
|
||||
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<Ray>
|
||||
@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<Ray>
|
||||
*/
|
||||
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<Ray>
|
||||
*/
|
||||
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<Ray>
|
||||
*/
|
||||
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<Ray>
|
||||
@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);
|
||||
}
|
||||
}
|
||||
|
@ -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<EventArgs> Disposing = new Event<EventArgs>();
|
||||
|
||||
|
||||
/**
|
||||
* 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("*");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -144,7 +144,7 @@ public final class StorageDevice
|
||||
*/
|
||||
public void DeleteContainer(String titleName)
|
||||
{
|
||||
// TODO: implement
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
@ -50,6 +50,7 @@ public class TitleContainer
|
||||
}
|
||||
|
||||
int startIndex = 1;
|
||||
|
||||
while(startIndex < path.length())
|
||||
{
|
||||
startIndex = path.indexOf("\\..\\", startIndex);
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -15,7 +15,7 @@ import System.*;
|
||||
public class ReadOnlyCollection<T> implements Iterable<T>
|
||||
{
|
||||
private List<T> collection;
|
||||
|
||||
|
||||
/**
|
||||
* Initializes a new instance of the System.Collections.ObjectModel.ReadOnlyCollection<T> class that is a read-only wrapper around the specified list.
|
||||
*
|
||||
@ -31,10 +31,10 @@ public class ReadOnlyCollection<T> implements Iterable<T>
|
||||
{
|
||||
throw new ArgumentNullException("list");
|
||||
}
|
||||
|
||||
|
||||
collection = list;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the number of elements contained in the System.Collections.ObjectModel.ReadOnlyCollection<T> instance.
|
||||
*/
|
||||
@ -42,7 +42,7 @@ public class ReadOnlyCollection<T> implements Iterable<T>
|
||||
{
|
||||
return collection.size();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the System.Collections.Generic.IList<T> that the System.Collections.ObjectModel.ReadOnlyCollection<T> wraps.
|
||||
*
|
||||
@ -53,7 +53,7 @@ public class ReadOnlyCollection<T> implements Iterable<T>
|
||||
{
|
||||
return collection;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the element at the specified index.
|
||||
*
|
||||
@ -72,10 +72,10 @@ public class ReadOnlyCollection<T> implements Iterable<T>
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("index");
|
||||
}
|
||||
|
||||
|
||||
return collection.get(index);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Determines whether an element is in the System.Collections.ObjectModel.ReadOnlyCollection<T>.
|
||||
*
|
||||
@ -89,7 +89,7 @@ public class ReadOnlyCollection<T> implements Iterable<T>
|
||||
{
|
||||
return (IndexOf(value) != -1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Copies the entire System.Collections.ObjectModel.ReadOnlyCollection<T> to a compatible one-dimensional System.Array, starting at the specified index of the target array.
|
||||
*
|
||||
@ -105,13 +105,13 @@ public class ReadOnlyCollection<T> implements Iterable<T>
|
||||
{
|
||||
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<T> implements Iterable<T>
|
||||
{
|
||||
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<T>.
|
||||
*
|
||||
|
132
Microsoft.Xna.Framework/src/System/Single.java
Normal file
132
Microsoft.Xna.Framework/src/System/Single.java
Normal file
@ -0,0 +1,132 @@
|
||||
package System;
|
||||
|
||||
/**
|
||||
* Represents a single-precision floating-point number.
|
||||
*
|
||||
* @author Halofreak1990
|
||||
*/
|
||||
public final class Single extends Number implements Comparable<Single>, IEquatable<Single>
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user