mirror of
https://github.com/Halofreak1990/XFXFramework
synced 2024-12-26 13:49:34 +01:00
Added missing TypeInfos to XFX namespace
Removed excess whitespace
This commit is contained in:
parent
b0dd58a08b
commit
7c5bc83237
@ -33,6 +33,7 @@
|
|||||||
#include <System/Math.h>
|
#include <System/Math.h>
|
||||||
#include <System/Single.h>
|
#include <System/Single.h>
|
||||||
#include <System/String.h>
|
#include <System/String.h>
|
||||||
|
#include <System/Type.h>
|
||||||
|
|
||||||
#include <sassert.h>
|
#include <sassert.h>
|
||||||
|
|
||||||
@ -41,6 +42,7 @@ using namespace System;
|
|||||||
namespace XFX
|
namespace XFX
|
||||||
{
|
{
|
||||||
const int BoundingBox::CornerCount = 8;
|
const int BoundingBox::CornerCount = 8;
|
||||||
|
const Type BoundingBoxTypeInfo("BoundingBox", "XFX::BoundingBox", TypeCode::Object);
|
||||||
|
|
||||||
BoundingBox::BoundingBox(const Vector3 min, const Vector3 max)
|
BoundingBox::BoundingBox(const Vector3 min, const Vector3 max)
|
||||||
: Max(max), Min(min)
|
: Max(max), Min(min)
|
||||||
@ -67,19 +69,27 @@ namespace XFX
|
|||||||
void BoundingBox::Contains(BoundingBox box, out ContainmentType_t& result) const
|
void BoundingBox::Contains(BoundingBox box, out ContainmentType_t& result) const
|
||||||
{
|
{
|
||||||
if( Max.X < box.Min.X || Min.X > box.Max.X )
|
if( Max.X < box.Min.X || Min.X > box.Max.X )
|
||||||
result = ContainmentType::Disjoint;
|
{
|
||||||
|
result = ContainmentType::Disjoint;
|
||||||
|
}
|
||||||
|
|
||||||
if( Max.Y < box.Min.Y || Min.Y > box.Max.Y )
|
if( Max.Y < box.Min.Y || Min.Y > box.Max.Y )
|
||||||
result = ContainmentType::Disjoint;
|
{
|
||||||
|
result = ContainmentType::Disjoint;
|
||||||
|
}
|
||||||
|
|
||||||
if( Max.Z < box.Min.Z || Min.Z > box.Max.Z )
|
if( Max.Z < box.Min.Z || Min.Z > box.Max.Z )
|
||||||
result = ContainmentType::Disjoint;
|
{
|
||||||
|
result = ContainmentType::Disjoint;
|
||||||
|
}
|
||||||
|
|
||||||
if( Min.X <= box.Min.X && box.Max.X <= Max.X && Min.Y <= box.Min.Y &&
|
if( Min.X <= box.Min.X && box.Max.X <= Max.X && Min.Y <= box.Min.Y &&
|
||||||
box.Max.Y <= Max.Y && Min.Z <= box.Min.Z && box.Max.Z <= Max.Z )
|
box.Max.Y <= Max.Y && Min.Z <= box.Min.Z && box.Max.Z <= Max.Z )
|
||||||
result = ContainmentType::Contains;
|
{
|
||||||
|
result = ContainmentType::Contains;
|
||||||
|
}
|
||||||
|
|
||||||
result = ContainmentType::Intersects;
|
result = ContainmentType::Intersects;
|
||||||
}
|
}
|
||||||
|
|
||||||
ContainmentType_t BoundingBox::Contains(BoundingSphere sphere) const
|
ContainmentType_t BoundingBox::Contains(BoundingSphere sphere) const
|
||||||
@ -92,46 +102,54 @@ namespace XFX
|
|||||||
void BoundingBox::Contains(BoundingSphere sphere, out ContainmentType_t& result) const
|
void BoundingBox::Contains(BoundingSphere sphere, out ContainmentType_t& result) const
|
||||||
{
|
{
|
||||||
float dist;
|
float dist;
|
||||||
Vector3 clamped;
|
Vector3 clamped;
|
||||||
|
|
||||||
Vector3::Clamp(sphere.Center, Min, Max, clamped);
|
Vector3::Clamp(sphere.Center, Min, Max, clamped);
|
||||||
|
|
||||||
float x = sphere.Center.X - clamped.X;
|
float x = sphere.Center.X - clamped.X;
|
||||||
float y = sphere.Center.Y - clamped.Y;
|
float y = sphere.Center.Y - clamped.Y;
|
||||||
float z = sphere.Center.Z - clamped.Z;
|
float z = sphere.Center.Z - clamped.Z;
|
||||||
|
|
||||||
dist = (x * x) + (y * y) + (z * z);
|
dist = (x * x) + (y * y) + (z * z);
|
||||||
float radius = sphere.Radius;
|
float radius = sphere.Radius;
|
||||||
|
|
||||||
if(dist > (radius * radius))
|
if(dist > (radius * radius))
|
||||||
result = ContainmentType::Disjoint;
|
{
|
||||||
|
result = ContainmentType::Disjoint;
|
||||||
|
}
|
||||||
|
|
||||||
if(Min.X + radius <= sphere.Center.X && sphere.Center.X <= Max.X - radius &&
|
if(Min.X + radius <= sphere.Center.X && sphere.Center.X <= Max.X - radius &&
|
||||||
Max.X - Min.X > radius && Min.Y + radius <= sphere.Center.Y &&
|
Max.X - Min.X > radius && Min.Y + radius <= sphere.Center.Y &&
|
||||||
sphere.Center.Y <= Max.Y - radius && Max.Y - Min.Y > radius &&
|
sphere.Center.Y <= Max.Y - radius && Max.Y - Min.Y > radius &&
|
||||||
Min.Z + radius <= sphere.Center.Z && sphere.Center.Z <= Max.Z - radius &&
|
Min.Z + radius <= sphere.Center.Z && sphere.Center.Z <= Max.Z - radius &&
|
||||||
Max.X - Min.X > radius)
|
Max.X - Min.X > radius)
|
||||||
result = ContainmentType::Contains;
|
{
|
||||||
|
result = ContainmentType::Contains;
|
||||||
|
}
|
||||||
|
|
||||||
result = ContainmentType::Intersects;
|
result = ContainmentType::Intersects;
|
||||||
}
|
}
|
||||||
|
|
||||||
ContainmentType_t BoundingBox::Contains(const Vector3 vector) const
|
ContainmentType_t BoundingBox::Contains(const Vector3 vector) const
|
||||||
{
|
{
|
||||||
if(Min.X <= vector.X && vector.X <= Max.X && Min.Y <= vector.Y &&
|
if(Min.X <= vector.X && vector.X <= Max.X && Min.Y <= vector.Y &&
|
||||||
vector.Y <= Max.Y && Min.Z <= vector.Z && vector.Z <= Max.Z)
|
vector.Y <= Max.Y && Min.Z <= vector.Z && vector.Z <= Max.Z)
|
||||||
return ContainmentType::Contains;
|
{
|
||||||
|
return ContainmentType::Contains;
|
||||||
|
}
|
||||||
|
|
||||||
return ContainmentType::Disjoint;
|
return ContainmentType::Disjoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BoundingBox::Contains(Vector3 vector, out ContainmentType_t& result) const
|
void BoundingBox::Contains(Vector3 vector, out ContainmentType_t& result) const
|
||||||
{
|
{
|
||||||
if (Min.X <= vector.X && vector.X <= Max.X && Min.Y <= vector.Y &&
|
if (Min.X <= vector.X && vector.X <= Max.X && Min.Y <= vector.Y &&
|
||||||
vector.Y <= Max.Y && Min.Z <= vector.Z && vector.Z <= Max.Z)
|
vector.Y <= Max.Y && Min.Z <= vector.Z && vector.Z <= Max.Z)
|
||||||
result = ContainmentType::Contains;
|
{
|
||||||
|
result = ContainmentType::Contains;
|
||||||
|
}
|
||||||
|
|
||||||
result = ContainmentType::Disjoint;
|
result = ContainmentType::Disjoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
BoundingBox BoundingBox::CreateFromPoints(Vector3 points[], int startIndex, int length)
|
BoundingBox BoundingBox::CreateFromPoints(Vector3 points[], int startIndex, int length)
|
||||||
@ -142,40 +160,40 @@ namespace XFX
|
|||||||
Vector3 max = Single::MaxValue;
|
Vector3 max = Single::MaxValue;
|
||||||
|
|
||||||
for(int i = startIndex; i < length; i++)
|
for(int i = startIndex; i < length; i++)
|
||||||
{
|
{
|
||||||
Vector3::Min(min, points[i], min);
|
Vector3::Min(min, points[i], min);
|
||||||
Vector3::Max(max, points[i], max);
|
Vector3::Max(max, points[i], max);
|
||||||
}
|
}
|
||||||
|
|
||||||
return BoundingBox(min, max);
|
return BoundingBox(min, max);
|
||||||
}
|
}
|
||||||
|
|
||||||
BoundingBox BoundingBox::CreateFromSphere(BoundingSphere sphere)
|
BoundingBox BoundingBox::CreateFromSphere(BoundingSphere sphere)
|
||||||
{
|
{
|
||||||
BoundingBox result;
|
BoundingBox result;
|
||||||
result.Min = Vector3(sphere.Center.X - sphere.Radius, sphere.Center.Y - sphere.Radius, sphere.Center.Z - sphere.Radius );
|
result.Min = Vector3(sphere.Center.X - sphere.Radius, sphere.Center.Y - sphere.Radius, sphere.Center.Z - sphere.Radius );
|
||||||
result.Max = Vector3(sphere.Center.X + sphere.Radius, sphere.Center.Y + sphere.Radius, sphere.Center.Z + sphere.Radius );
|
result.Max = Vector3(sphere.Center.X + sphere.Radius, sphere.Center.Y + sphere.Radius, sphere.Center.Z + sphere.Radius );
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BoundingBox::CreateFromSphere(BoundingSphere sphere, out BoundingBox& result)
|
void BoundingBox::CreateFromSphere(BoundingSphere sphere, out BoundingBox& result)
|
||||||
{
|
{
|
||||||
result.Min = Vector3(sphere.Center.X - sphere.Radius, sphere.Center.Y - sphere.Radius, sphere.Center.Z - sphere.Radius );
|
result.Min = Vector3(sphere.Center.X - sphere.Radius, sphere.Center.Y - sphere.Radius, sphere.Center.Z - sphere.Radius );
|
||||||
result.Max = Vector3(sphere.Center.X + sphere.Radius, sphere.Center.Y + sphere.Radius, sphere.Center.Z + sphere.Radius );
|
result.Max = Vector3(sphere.Center.X + sphere.Radius, sphere.Center.Y + sphere.Radius, sphere.Center.Z + sphere.Radius );
|
||||||
}
|
}
|
||||||
|
|
||||||
BoundingBox BoundingBox::CreateMerged(BoundingBox box1, BoundingBox box2)
|
BoundingBox BoundingBox::CreateMerged(BoundingBox box1, BoundingBox box2)
|
||||||
{
|
{
|
||||||
BoundingBox result;
|
BoundingBox result;
|
||||||
Vector3::Min(box1.Min, box2.Min, result.Min);
|
Vector3::Min(box1.Min, box2.Min, result.Min);
|
||||||
Vector3::Max(box1.Max, box2.Max, result.Max);
|
Vector3::Max(box1.Max, box2.Max, result.Max);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BoundingBox::CreateMerged(BoundingBox box1, BoundingBox box2, out BoundingBox& result)
|
void BoundingBox::CreateMerged(BoundingBox box1, BoundingBox box2, out BoundingBox& result)
|
||||||
{
|
{
|
||||||
Vector3::Min(box1.Min, box2.Min, result.Min);
|
Vector3::Min(box1.Min, box2.Min, result.Min);
|
||||||
Vector3::Max(box1.Max, box2.Max, result.Max);
|
Vector3::Max(box1.Max, box2.Max, result.Max);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BoundingBox::Equals(Object const * const obj) const
|
bool BoundingBox::Equals(Object const * const obj) const
|
||||||
@ -193,9 +211,9 @@ namespace XFX
|
|||||||
return Min.GetHashCode() + Max.GetHashCode();
|
return Min.GetHashCode() + Max.GetHashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
int BoundingBox::GetType()
|
const Type& BoundingBox::GetType()
|
||||||
{
|
{
|
||||||
// TODO: implement
|
return BoundingBoxTypeInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BoundingBox::Intersects(BoundingBox box) const
|
bool BoundingBox::Intersects(BoundingBox box) const
|
||||||
@ -208,12 +226,16 @@ namespace XFX
|
|||||||
void BoundingBox::Intersects(BoundingBox box, out bool& result) const
|
void BoundingBox::Intersects(BoundingBox box, out bool& result) const
|
||||||
{
|
{
|
||||||
if (Max.X < box.Min.X || Min.X > box.Max.X)
|
if (Max.X < box.Min.X || Min.X > box.Max.X)
|
||||||
result = false;
|
{
|
||||||
|
result = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (Max.Y < box.Min.Y || Min.Y > box.Max.Y)
|
if (Max.Y < box.Min.Y || Min.Y > box.Max.Y)
|
||||||
result = false;
|
{
|
||||||
|
result = false;
|
||||||
|
}
|
||||||
|
|
||||||
result = (Max.Z >= box.Min.Z && Min.Z <= box.Max.Z);
|
result = (Max.Z >= box.Min.Z && Min.Z <= box.Max.Z);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BoundingBox::Intersects(BoundingSphere sphere) const
|
bool BoundingBox::Intersects(BoundingSphere sphere) const
|
||||||
@ -226,17 +248,17 @@ namespace XFX
|
|||||||
void BoundingBox::Intersects(BoundingSphere sphere, out bool& result) const
|
void BoundingBox::Intersects(BoundingSphere sphere, out bool& result) const
|
||||||
{
|
{
|
||||||
float dist;
|
float dist;
|
||||||
Vector3 clamped;
|
Vector3 clamped;
|
||||||
|
|
||||||
Vector3::Clamp(sphere.Center, Min, Max, clamped);
|
Vector3::Clamp(sphere.Center, Min, Max, clamped);
|
||||||
|
|
||||||
float x = sphere.Center.X - clamped.X;
|
float x = sphere.Center.X - clamped.X;
|
||||||
float y = sphere.Center.Y - clamped.Y;
|
float y = sphere.Center.Y - clamped.Y;
|
||||||
float z = sphere.Center.Z - clamped.Z;
|
float z = sphere.Center.Z - clamped.Z;
|
||||||
|
|
||||||
dist = (x * x) + (y * y) + (z * z);
|
dist = (x * x) + (y * y) + (z * z);
|
||||||
|
|
||||||
result = (dist <= (sphere.Radius * sphere.Radius));
|
result = (dist <= (sphere.Radius * sphere.Radius));
|
||||||
}
|
}
|
||||||
|
|
||||||
PlaneIntersectionType_t BoundingBox::Intersects(Plane plane) const
|
PlaneIntersectionType_t BoundingBox::Intersects(Plane plane) const
|
||||||
|
@ -142,147 +142,164 @@ namespace XFX
|
|||||||
Vector3 BoundingFrustum::ComputeIntersection(Plane plane, Ray ray)
|
Vector3 BoundingFrustum::ComputeIntersection(Plane plane, Ray ray)
|
||||||
{
|
{
|
||||||
float num = (-plane.D - Vector3::Dot(plane.Normal, ray.Position)) / Vector3::Dot(plane.Normal, ray.Direction);
|
float num = (-plane.D - Vector3::Dot(plane.Normal, ray.Position)) / Vector3::Dot(plane.Normal, ray.Direction);
|
||||||
return (ray.Position + (ray.Direction * num));
|
return (ray.Position + (ray.Direction * num));
|
||||||
}
|
}
|
||||||
|
|
||||||
Ray BoundingFrustum::ComputeIntersectionLine(Plane p1, Plane p2)
|
Ray BoundingFrustum::ComputeIntersectionLine(Plane p1, Plane p2)
|
||||||
{
|
{
|
||||||
Ray ray = Ray();
|
Ray ray = Ray();
|
||||||
ray.Direction = Vector3::Cross(p1.Normal, p2.Normal);
|
ray.Direction = Vector3::Cross(p1.Normal, p2.Normal);
|
||||||
float num = ray.Direction.LengthSquared();
|
float num = ray.Direction.LengthSquared();
|
||||||
ray.Position = (Vector3::Cross(((p2.Normal * -p1.D) + (p1.Normal * p2.D)), ray.Direction) / num);
|
ray.Position = (Vector3::Cross(((p2.Normal * -p1.D) + (p1.Normal * p2.D)), ray.Direction) / num);
|
||||||
return ray;
|
return ray;
|
||||||
}
|
}
|
||||||
|
|
||||||
ContainmentType_t BoundingFrustum::Contains(BoundingBox box)
|
ContainmentType_t BoundingFrustum::Contains(BoundingBox box)
|
||||||
{
|
{
|
||||||
bool flag = false;
|
bool flag = false;
|
||||||
for(int i = 0; i < 6; i++)
|
for(int i = 0; i < 6; i++)
|
||||||
{
|
{
|
||||||
switch (box.Intersects(planes[i]))
|
switch (box.Intersects(planes[i]))
|
||||||
{
|
{
|
||||||
case PlaneIntersectionType::Front:
|
case PlaneIntersectionType::Front:
|
||||||
return ContainmentType::Disjoint;
|
return ContainmentType::Disjoint;
|
||||||
|
|
||||||
case PlaneIntersectionType::Intersecting:
|
case PlaneIntersectionType::Intersecting:
|
||||||
flag = true;
|
flag = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!flag)
|
|
||||||
{
|
if (!flag)
|
||||||
|
{
|
||||||
return ContainmentType::Contains;
|
return ContainmentType::Contains;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ContainmentType::Intersects;
|
return ContainmentType::Intersects;
|
||||||
}
|
}
|
||||||
|
|
||||||
ContainmentType_t BoundingFrustum::Contains(BoundingFrustum frustrum)
|
ContainmentType_t BoundingFrustum::Contains(BoundingFrustum frustrum)
|
||||||
{
|
{
|
||||||
ContainmentType_t disjoint = ContainmentType::Disjoint;
|
ContainmentType_t disjoint = ContainmentType::Disjoint;
|
||||||
if (Intersects(frustrum))
|
|
||||||
{
|
if (Intersects(frustrum))
|
||||||
|
{
|
||||||
disjoint = ContainmentType::Contains;
|
disjoint = ContainmentType::Contains;
|
||||||
for (int i = 0; i < 8; i++)
|
for (int i = 0; i < 8; i++)
|
||||||
{
|
{
|
||||||
if (Contains(frustrum.cornerArray[i]) == ContainmentType::Disjoint)
|
if (Contains(frustrum.cornerArray[i]) == ContainmentType::Disjoint)
|
||||||
{
|
{
|
||||||
return ContainmentType::Intersects;
|
return ContainmentType::Intersects;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return disjoint;
|
|
||||||
|
return disjoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
ContainmentType_t BoundingFrustum::Contains(BoundingSphere sphere)
|
ContainmentType_t BoundingFrustum::Contains(BoundingSphere sphere)
|
||||||
{
|
{
|
||||||
Vector3 center = sphere.Center;
|
Vector3 center = sphere.Center;
|
||||||
float radius = sphere.Radius;
|
float radius = sphere.Radius;
|
||||||
int num2 = 0;
|
int num2 = 0;
|
||||||
for (int i = 0; i < 6; i++)
|
|
||||||
{
|
for (int i = 0; i < 6; i++)
|
||||||
float num5 = ((planes[i].Normal.X * center.X) + (planes[i].Normal.Y * center.Y)) + (planes[i].Normal.Z * center.Z);
|
{
|
||||||
float num3 = num5 + planes[i].D;
|
float num5 = ((planes[i].Normal.X * center.X) + (planes[i].Normal.Y * center.Y)) + (planes[i].Normal.Z * center.Z);
|
||||||
if (num3 > radius)
|
float num3 = num5 + planes[i].D;
|
||||||
{
|
if (num3 > radius)
|
||||||
|
{
|
||||||
return ContainmentType::Disjoint;
|
return ContainmentType::Disjoint;
|
||||||
}
|
}
|
||||||
if (num3 < -radius)
|
if (num3 < -radius)
|
||||||
{
|
{
|
||||||
num2++;
|
num2++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (num2 != 6)
|
|
||||||
{
|
if (num2 != 6)
|
||||||
|
{
|
||||||
return ContainmentType::Intersects;
|
return ContainmentType::Intersects;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ContainmentType::Contains;
|
return ContainmentType::Contains;
|
||||||
}
|
}
|
||||||
|
|
||||||
ContainmentType_t BoundingFrustum::Contains(Vector3 point)
|
ContainmentType_t BoundingFrustum::Contains(Vector3 point)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 6; i++)
|
for (int i = 0; i < 6; i++)
|
||||||
{
|
{
|
||||||
float num2 = (((planes[i].Normal.X * point.X) + (planes[i].Normal.Y * point.Y)) + (planes[i].Normal.Z * point.Z)) + planes[i].D;
|
float num2 = (((planes[i].Normal.X * point.X) + (planes[i].Normal.Y * point.Y)) + (planes[i].Normal.Z * point.Z)) + planes[i].D;
|
||||||
if (num2 > 1E-05f)
|
|
||||||
{
|
if (num2 > 1E-05f)
|
||||||
|
{
|
||||||
return ContainmentType::Disjoint;
|
return ContainmentType::Disjoint;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ContainmentType::Contains;
|
return ContainmentType::Contains;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BoundingFrustum::Contains(BoundingBox box, out ContainmentType_t& result)
|
void BoundingFrustum::Contains(BoundingBox box, out ContainmentType_t& result)
|
||||||
{
|
{
|
||||||
bool flag = false;
|
bool flag = false;
|
||||||
|
|
||||||
for (int i = 0; i < 6; i++)
|
for (int i = 0; i < 6; i++)
|
||||||
{
|
{
|
||||||
switch (box.Intersects(planes[i]))
|
switch (box.Intersects(planes[i]))
|
||||||
{
|
{
|
||||||
case PlaneIntersectionType::Front:
|
case PlaneIntersectionType::Front:
|
||||||
result = ContainmentType::Disjoint;
|
result = ContainmentType::Disjoint;
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case PlaneIntersectionType::Intersecting:
|
case PlaneIntersectionType::Intersecting:
|
||||||
flag = true;
|
flag = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
result = flag ? ContainmentType::Intersects : ContainmentType::Contains;
|
result = flag ? ContainmentType::Intersects : ContainmentType::Contains;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BoundingFrustum::Contains(BoundingSphere sphere, out ContainmentType_t& result)
|
void BoundingFrustum::Contains(BoundingSphere sphere, out ContainmentType_t& result)
|
||||||
{
|
{
|
||||||
Vector3 center = sphere.Center;
|
Vector3 center = sphere.Center;
|
||||||
float radius = sphere.Radius;
|
float radius = sphere.Radius;
|
||||||
int num2 = 0;
|
int num2 = 0;
|
||||||
|
|
||||||
for (int i = 0; i < 6; i++)
|
for (int i = 0; i < 6; i++)
|
||||||
{
|
{
|
||||||
float num5 = ((planes[i].Normal.X * center.X) + (planes[i].Normal.Y * center.Y)) + (planes[i].Normal.Z * center.Z);
|
float num5 = ((planes[i].Normal.X * center.X) + (planes[i].Normal.Y * center.Y)) + (planes[i].Normal.Z * center.Z);
|
||||||
float num3 = num5 + planes[i].D;
|
float num3 = num5 + planes[i].D;
|
||||||
if (num3 > radius)
|
|
||||||
{
|
if (num3 > radius)
|
||||||
|
{
|
||||||
result = ContainmentType::Disjoint;
|
result = ContainmentType::Disjoint;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (num3 < -radius)
|
|
||||||
{
|
if (num3 < -radius)
|
||||||
num2++;
|
{
|
||||||
}
|
num2++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
result = (num2 == 6) ? ContainmentType::Contains : ContainmentType::Intersects;
|
result = (num2 == 6) ? ContainmentType::Contains : ContainmentType::Intersects;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BoundingFrustum::Contains(Vector3 point, out ContainmentType_t& result)
|
void BoundingFrustum::Contains(Vector3 point, out ContainmentType_t& result)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 6; i++)
|
for (int i = 0; i < 6; i++)
|
||||||
{
|
{
|
||||||
float num2 = (((planes[i].Normal.X * point.X) + (planes[i].Normal.Y * point.Y)) + (planes[i].Normal.Z * point.Z)) + planes[i].D;
|
float num2 = (((planes[i].Normal.X * point.X) + (planes[i].Normal.Y * point.Y)) + (planes[i].Normal.Z * point.Z)) + planes[i].D;
|
||||||
if (num2 > 1E-05f)
|
|
||||||
{
|
if (num2 > 1E-05f)
|
||||||
|
{
|
||||||
result = ContainmentType::Disjoint;
|
result = ContainmentType::Disjoint;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
result = ContainmentType::Contains;
|
result = ContainmentType::Contains;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -306,7 +323,9 @@ namespace XFX
|
|||||||
sassert(corners != null, "corners cannot be null.");
|
sassert(corners != null, "corners cannot be null.");
|
||||||
|
|
||||||
for (int i = 0; i < 8; i++)
|
for (int i = 0; i < 8; i++)
|
||||||
|
{
|
||||||
corners[i] = cornerArray[i];
|
corners[i] = cornerArray[i];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int BoundingFrustum::GetHashCode() const
|
int BoundingFrustum::GetHashCode() const
|
||||||
@ -322,8 +341,8 @@ namespace XFX
|
|||||||
bool BoundingFrustum::Intersects(BoundingBox box)
|
bool BoundingFrustum::Intersects(BoundingBox box)
|
||||||
{
|
{
|
||||||
bool flag = false;
|
bool flag = false;
|
||||||
Intersects(box, flag);
|
Intersects(box, flag);
|
||||||
return flag;
|
return flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BoundingFrustum::Intersects(BoundingFrustum frustrum)
|
bool BoundingFrustum::Intersects(BoundingFrustum frustrum)
|
||||||
@ -343,10 +362,12 @@ namespace XFX
|
|||||||
PlaneIntersectionType_t BoundingFrustum::Intersects(Plane plane)
|
PlaneIntersectionType_t BoundingFrustum::Intersects(Plane plane)
|
||||||
{
|
{
|
||||||
int num = 0;
|
int num = 0;
|
||||||
|
|
||||||
for (int i = 0; i < 8; i++)
|
for (int i = 0; i < 8; i++)
|
||||||
{
|
{
|
||||||
float num3 = 0;
|
float num3 = 0;
|
||||||
Vector3::Dot(cornerArray[i], plane.Normal, num3);
|
Vector3::Dot(cornerArray[i], plane.Normal, num3);
|
||||||
|
|
||||||
if ((num3 + plane.D) > 0)
|
if ((num3 + plane.D) > 0)
|
||||||
{
|
{
|
||||||
num |= 1;
|
num |= 1;
|
||||||
@ -355,15 +376,18 @@ namespace XFX
|
|||||||
{
|
{
|
||||||
num |= 2;
|
num |= 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (num == 3)
|
if (num == 3)
|
||||||
{
|
{
|
||||||
return PlaneIntersectionType::Intersecting;
|
return PlaneIntersectionType::Intersecting;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (num != 1)
|
if (num != 1)
|
||||||
{
|
{
|
||||||
return PlaneIntersectionType::Back;
|
return PlaneIntersectionType::Back;
|
||||||
}
|
}
|
||||||
|
|
||||||
return PlaneIntersectionType::Front;
|
return PlaneIntersectionType::Front;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -387,10 +411,12 @@ namespace XFX
|
|||||||
void BoundingFrustum::Intersects(Plane plane, out PlaneIntersectionType_t& result)
|
void BoundingFrustum::Intersects(Plane plane, out PlaneIntersectionType_t& result)
|
||||||
{
|
{
|
||||||
int num = 0;
|
int num = 0;
|
||||||
|
|
||||||
for (int i = 0; i < 8; i++)
|
for (int i = 0; i < 8; i++)
|
||||||
{
|
{
|
||||||
float num3 = 0;
|
float num3 = 0;
|
||||||
Vector3::Dot(cornerArray[i], plane.Normal, num3);
|
Vector3::Dot(cornerArray[i], plane.Normal, num3);
|
||||||
|
|
||||||
if ((num3 + plane.D) > 0)
|
if ((num3 + plane.D) > 0)
|
||||||
{
|
{
|
||||||
num |= 1;
|
num |= 1;
|
||||||
@ -399,18 +425,21 @@ namespace XFX
|
|||||||
{
|
{
|
||||||
num |= 2;
|
num |= 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (num == 3)
|
if (num == 3)
|
||||||
{
|
{
|
||||||
result = PlaneIntersectionType::Intersecting;
|
result = PlaneIntersectionType::Intersecting;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
result = (num == 1) ? PlaneIntersectionType::Front : PlaneIntersectionType::Back;
|
result = (num == 1) ? PlaneIntersectionType::Front : PlaneIntersectionType::Back;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BoundingFrustum::Intersects(Ray ray, out float& result)
|
void BoundingFrustum::Intersects(Ray ray, out float& result)
|
||||||
{
|
{
|
||||||
ContainmentType_t type = Contains(ray.Position);
|
ContainmentType_t type = Contains(ray.Position);
|
||||||
|
|
||||||
if (type == ContainmentType::Contains)
|
if (type == ContainmentType::Contains)
|
||||||
{
|
{
|
||||||
result = 0.0f;
|
result = 0.0f;
|
||||||
@ -420,6 +449,7 @@ namespace XFX
|
|||||||
float minValue = Single::MinValue;
|
float minValue = Single::MinValue;
|
||||||
float maxValue = Single::MaxValue;
|
float maxValue = Single::MaxValue;
|
||||||
result = 0;
|
result = 0;
|
||||||
|
|
||||||
for (int i = 0; i < 6; i++)
|
for (int i = 0; i < 6; i++)
|
||||||
{
|
{
|
||||||
float num3 = 0;
|
float num3 = 0;
|
||||||
@ -428,6 +458,7 @@ namespace XFX
|
|||||||
Vector3::Dot(ray.Direction, normal, num6);
|
Vector3::Dot(ray.Direction, normal, num6);
|
||||||
Vector3::Dot(ray.Position, normal, num3);
|
Vector3::Dot(ray.Position, normal, num3);
|
||||||
num3 += planes[i].D;
|
num3 += planes[i].D;
|
||||||
|
|
||||||
if (Math::Abs(num6) < 1E-05f)
|
if (Math::Abs(num6) < 1E-05f)
|
||||||
{
|
{
|
||||||
if (num3 > 0.0f)
|
if (num3 > 0.0f)
|
||||||
@ -438,12 +469,14 @@ namespace XFX
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
float num = -num3 / num6;
|
float num = -num3 / num6;
|
||||||
|
|
||||||
if (num6 < 0.0f)
|
if (num6 < 0.0f)
|
||||||
{
|
{
|
||||||
if (num > maxValue)
|
if (num > maxValue)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (num > minValue)
|
if (num > minValue)
|
||||||
{
|
{
|
||||||
minValue = num;
|
minValue = num;
|
||||||
@ -455,6 +488,7 @@ namespace XFX
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (num < maxValue)
|
if (num < maxValue)
|
||||||
{
|
{
|
||||||
maxValue = num;
|
maxValue = num;
|
||||||
@ -462,7 +496,9 @@ namespace XFX
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float num7 = (minValue >= 0) ? minValue : maxValue;
|
float num7 = (minValue >= 0) ? minValue : maxValue;
|
||||||
|
|
||||||
if (num7 >= 0)
|
if (num7 >= 0)
|
||||||
{
|
{
|
||||||
result = float(num7);
|
result = float(num7);
|
||||||
@ -497,12 +533,14 @@ namespace XFX
|
|||||||
planes[1].Normal.Y = -value.M24 + value.M23;
|
planes[1].Normal.Y = -value.M24 + value.M23;
|
||||||
planes[1].Normal.Z = -value.M34 + value.M33;
|
planes[1].Normal.Z = -value.M34 + value.M33;
|
||||||
planes[1].D = -value.M44 + value.M43;
|
planes[1].D = -value.M44 + value.M43;
|
||||||
|
|
||||||
for (int i = 0; i < 6; i++)
|
for (int i = 0; i < 6; i++)
|
||||||
{
|
{
|
||||||
float num2 = planes[i].Normal.Length();
|
float num2 = planes[i].Normal.Length();
|
||||||
planes[i].Normal = (planes[i].Normal / num2);
|
planes[i].Normal = (planes[i].Normal / num2);
|
||||||
planes[i].D /= num2;
|
planes[i].D /= num2;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ray ray = ComputeIntersectionLine(planes[0], planes[2]);
|
Ray ray = ComputeIntersectionLine(planes[0], planes[2]);
|
||||||
cornerArray[0] = ComputeIntersection(planes[4], ray);
|
cornerArray[0] = ComputeIntersection(planes[4], ray);
|
||||||
cornerArray[3] = ComputeIntersection(planes[5], ray);
|
cornerArray[3] = ComputeIntersection(planes[5], ray);
|
||||||
|
@ -27,9 +27,12 @@
|
|||||||
|
|
||||||
#include <BoundingSphere.h>
|
#include <BoundingSphere.h>
|
||||||
#include <System/String.h>
|
#include <System/String.h>
|
||||||
|
#include <System/Type.h>
|
||||||
|
|
||||||
namespace XFX
|
namespace XFX
|
||||||
{
|
{
|
||||||
|
const Type BoundingSphereTypeInfo("BoundingSphere", "XFX::BoundingSphere", TypeCode::Object);
|
||||||
|
|
||||||
BoundingSphere::BoundingSphere(const Vector3 center, const float radius)
|
BoundingSphere::BoundingSphere(const Vector3 center, const float radius)
|
||||||
: Center(center), Radius(radius)
|
: Center(center), Radius(radius)
|
||||||
{
|
{
|
||||||
@ -55,6 +58,11 @@ namespace XFX
|
|||||||
return (*this == other);
|
return (*this == other);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const Type& BoundingSphere::GetType()
|
||||||
|
{
|
||||||
|
return BoundingSphereTypeInfo;
|
||||||
|
}
|
||||||
|
|
||||||
int BoundingSphere::GetHashCode() const
|
int BoundingSphere::GetHashCode() const
|
||||||
{
|
{
|
||||||
return Center.GetHashCode() + (int)Radius;
|
return Center.GetHashCode() + (int)Radius;
|
||||||
|
@ -48,8 +48,8 @@ namespace XFX
|
|||||||
float cubed = amount * squared;
|
float cubed = amount * squared;
|
||||||
|
|
||||||
return 0.5f * ((((2.0f * value2) + ((-value1 + value3) * amount)) +
|
return 0.5f * ((((2.0f * value2) + ((-value1 + value3) * amount)) +
|
||||||
(((((2.0f * value1) - (5.0f * value2)) + (4.0f * value3)) - value4) * squared)) +
|
(((((2.0f * value1) - (5.0f * value2)) + (4.0f * value3)) - value4) * squared)) +
|
||||||
((((-value1 + (3.0f * value2)) - (3.0f * value3)) + value4) * cubed));
|
((((-value1 + (3.0f * value2)) - (3.0f * value3)) + value4) * cubed));
|
||||||
}
|
}
|
||||||
|
|
||||||
float MathHelper::Clamp(const float value, const float min, const float max)
|
float MathHelper::Clamp(const float value, const float min, const float max)
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -157,12 +157,16 @@ namespace XFX
|
|||||||
float dot = (Normal.X * max.X) + (Normal.Y * max.Y) + (Normal.Z * max.Z);
|
float dot = (Normal.X * max.X) + (Normal.Y * max.Y) + (Normal.Z * max.Z);
|
||||||
|
|
||||||
if(dot + D > 0.0f)
|
if(dot + D > 0.0f)
|
||||||
|
{
|
||||||
result = PlaneIntersectionType::Front;
|
result = PlaneIntersectionType::Front;
|
||||||
|
}
|
||||||
|
|
||||||
dot = (Normal.X * min.X) + (Normal.Y * min.Y) + (Normal.Z * min.Z);
|
dot = (Normal.X * min.X) + (Normal.Y * min.Y) + (Normal.Z * min.Z);
|
||||||
|
|
||||||
if(dot + D < 0.0f)
|
if(dot + D < 0.0f)
|
||||||
|
{
|
||||||
result = PlaneIntersectionType::Back;
|
result = PlaneIntersectionType::Back;
|
||||||
|
}
|
||||||
|
|
||||||
result = PlaneIntersectionType::Intersecting;
|
result = PlaneIntersectionType::Intersecting;
|
||||||
}
|
}
|
||||||
@ -179,10 +183,14 @@ namespace XFX
|
|||||||
float dot = (sphere.Center.X * Normal.X) + (sphere.Center.Y * Normal.Y) + (sphere.Center.Z * Normal.Z) + D;
|
float dot = (sphere.Center.X * Normal.X) + (sphere.Center.Y * Normal.Y) + (sphere.Center.Z * Normal.Z) + D;
|
||||||
|
|
||||||
if(dot > sphere.Radius)
|
if(dot > sphere.Radius)
|
||||||
|
{
|
||||||
result = PlaneIntersectionType::Front;
|
result = PlaneIntersectionType::Front;
|
||||||
|
}
|
||||||
|
|
||||||
if(dot < -sphere.Radius)
|
if(dot < -sphere.Radius)
|
||||||
|
{
|
||||||
result = PlaneIntersectionType::Back;
|
result = PlaneIntersectionType::Back;
|
||||||
|
}
|
||||||
|
|
||||||
result = PlaneIntersectionType::Intersecting;
|
result = PlaneIntersectionType::Intersecting;
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
#include <System/FrameworkResources.h>
|
#include <System/FrameworkResources.h>
|
||||||
#include <System/Math.h>
|
#include <System/Math.h>
|
||||||
#include <System/String.h>
|
#include <System/String.h>
|
||||||
|
#include <System/Type.h>
|
||||||
|
|
||||||
#include <sassert.h>
|
#include <sassert.h>
|
||||||
|
|
||||||
@ -42,29 +43,26 @@ namespace XFX
|
|||||||
{
|
{
|
||||||
const Vector2 Vector2::One = Vector2(1, 1);
|
const Vector2 Vector2::One = Vector2(1, 1);
|
||||||
const Vector2 Vector2::Zero = Vector2(0, 0);
|
const Vector2 Vector2::Zero = Vector2(0, 0);
|
||||||
|
const Type Vector2TypeInfo("Vector2", "XFX::Vector2", TypeCode::Object);
|
||||||
|
|
||||||
Vector2::Vector2(const float x, const float y)
|
Vector2::Vector2(const float x, const float y)
|
||||||
|
: X(x), Y(y)
|
||||||
{
|
{
|
||||||
X = x;
|
|
||||||
Y = y;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2::Vector2(const float value)
|
Vector2::Vector2(const float value)
|
||||||
|
: X(value), Y(value)
|
||||||
{
|
{
|
||||||
X = value;
|
|
||||||
Y = value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2::Vector2(const Vector2 &obj)
|
Vector2::Vector2(const Vector2 &obj)
|
||||||
|
: X(obj.X), Y(obj.Y)
|
||||||
{
|
{
|
||||||
X = obj.X;
|
|
||||||
Y = obj.Y;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2::Vector2()
|
Vector2::Vector2()
|
||||||
|
: X(0), Y(0)
|
||||||
{
|
{
|
||||||
X = 0;
|
|
||||||
Y = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2 Vector2::Add(const Vector2 value1, const Vector2 value2)
|
Vector2 Vector2::Add(const Vector2 value1, const Vector2 value2)
|
||||||
@ -116,29 +114,29 @@ namespace XFX
|
|||||||
float Vector2::Distance(const Vector2 value1, const Vector2 value2)
|
float Vector2::Distance(const Vector2 value1, const Vector2 value2)
|
||||||
{
|
{
|
||||||
float x = value1.X - value2.X;
|
float x = value1.X - value2.X;
|
||||||
float y = value1.Y - value2.Y;
|
float y = value1.Y - value2.Y;
|
||||||
return Math::Sqrt((x * x) + (y * y));
|
return Math::Sqrt((x * x) + (y * y));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Vector2::Distance(const Vector2& value1, const Vector2& value2, out float& result)
|
void Vector2::Distance(const Vector2& value1, const Vector2& value2, out float& result)
|
||||||
{
|
{
|
||||||
float x = value1.X - value2.X;
|
float x = value1.X - value2.X;
|
||||||
float y = value1.Y - value2.Y;
|
float y = value1.Y - value2.Y;
|
||||||
result = Math::Sqrt((x * x) + (y * y));
|
result = Math::Sqrt((x * x) + (y * y));
|
||||||
}
|
}
|
||||||
|
|
||||||
float Vector2::DistanceSquared(const Vector2 value1, const Vector2 value2)
|
float Vector2::DistanceSquared(const Vector2 value1, const Vector2 value2)
|
||||||
{
|
{
|
||||||
float x = value1.X - value2.X;
|
float x = value1.X - value2.X;
|
||||||
float y = value1.Y - value2.Y;
|
float y = value1.Y - value2.Y;
|
||||||
return (x * x) + (y * y);
|
return (x * x) + (y * y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Vector2::DistanceSquared(const Vector2& value1, const Vector2& value2, out float& result)
|
void Vector2::DistanceSquared(const Vector2& value1, const Vector2& value2, out float& result)
|
||||||
{
|
{
|
||||||
float x = value1.X - value2.X;
|
float x = value1.X - value2.X;
|
||||||
float y = value1.Y - value2.Y;
|
float y = value1.Y - value2.Y;
|
||||||
result = (x * x) + (y * y);
|
result = (x * x) + (y * y);
|
||||||
}
|
}
|
||||||
|
|
||||||
float Vector2::Dot(const Vector2 value1, const Vector2 value2)
|
float Vector2::Dot(const Vector2 value1, const Vector2 value2)
|
||||||
@ -166,9 +164,9 @@ namespace XFX
|
|||||||
return (int)X ^ (int)Y;
|
return (int)X ^ (int)Y;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Vector2::GetType()
|
const Type& Vector2::GetType()
|
||||||
{
|
{
|
||||||
// TODO: implement
|
return Vector2TypeInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2 Vector2::Hermite(const Vector2 value1, const Vector2 tangent1, const Vector2 value2, const Vector2 tangent2, const float amount)
|
Vector2 Vector2::Hermite(const Vector2 value1, const Vector2 tangent1, const Vector2 value2, const Vector2 tangent2, const float amount)
|
||||||
@ -261,28 +259,36 @@ namespace XFX
|
|||||||
void Vector2::Normalize()
|
void Vector2::Normalize()
|
||||||
{
|
{
|
||||||
float length = Length();
|
float length = Length();
|
||||||
if(length == 0)
|
|
||||||
return;
|
if(length == 0)
|
||||||
float num = 1 / length;
|
{
|
||||||
X *= num;
|
return;
|
||||||
Y *= num;
|
}
|
||||||
|
|
||||||
|
float num = 1 / length;
|
||||||
|
X *= num;
|
||||||
|
Y *= num;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2 Vector2::Normalize(const Vector2 value)
|
Vector2 Vector2::Normalize(const Vector2 value)
|
||||||
{
|
{
|
||||||
Vector2 result;
|
Vector2 result;
|
||||||
Normalize(value, result);
|
Normalize(value, result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Vector2::Normalize(const Vector2& value, out Vector2& result)
|
void Vector2::Normalize(const Vector2& value, out Vector2& result)
|
||||||
{
|
{
|
||||||
float length = value.Length();
|
float length = value.Length();
|
||||||
if (length == 0)
|
|
||||||
return;
|
if (length == 0)
|
||||||
float num = 1 / length;
|
{
|
||||||
result.X = value.X * num;
|
return;
|
||||||
result.Y = value.Y * num;
|
}
|
||||||
|
|
||||||
|
float num = 1 / length;
|
||||||
|
result.X = value.X * num;
|
||||||
|
result.Y = value.Y * num;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2 Vector2::Reflect(const Vector2 vector, const Vector2 normal)
|
Vector2 Vector2::Reflect(const Vector2 vector, const Vector2 normal)
|
||||||
@ -341,13 +347,13 @@ namespace XFX
|
|||||||
{
|
{
|
||||||
Vector4 vector;
|
Vector4 vector;
|
||||||
|
|
||||||
vector.X = (vector.X * matrix.M11) + (vector.Y * matrix.M21) + matrix.M41;
|
vector.X = (vector.X * matrix.M11) + (vector.Y * matrix.M21) + matrix.M41;
|
||||||
vector.Y = (vector.X * matrix.M12) + (vector.Y * matrix.M22) + matrix.M42;
|
vector.Y = (vector.X * matrix.M12) + (vector.Y * matrix.M22) + matrix.M42;
|
||||||
vector.Z = (vector.X * matrix.M13) + (vector.Y * matrix.M23) + matrix.M43;
|
vector.Z = (vector.X * matrix.M13) + (vector.Y * matrix.M23) + matrix.M43;
|
||||||
vector.W = 1 / ((vector.X * matrix.M14) + (vector.Y * matrix.M24) + matrix.M44);
|
vector.W = 1 / ((vector.X * matrix.M14) + (vector.Y * matrix.M24) + matrix.M44);
|
||||||
|
|
||||||
result.X = vector.X * vector.W;
|
result.X = vector.X * vector.W;
|
||||||
result.Y = vector.Y * vector.W;
|
result.Y = vector.Y * vector.W;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2 Vector2::Transform(const Vector2 position, const Quaternion rotation)
|
Vector2 Vector2::Transform(const Vector2 position, const Quaternion rotation)
|
||||||
@ -395,16 +401,16 @@ namespace XFX
|
|||||||
Vector2 Vector2::TransformNormal(const Vector2 normal, const Matrix matrix)
|
Vector2 Vector2::TransformNormal(const Vector2 normal, const Matrix matrix)
|
||||||
{
|
{
|
||||||
Vector2 result;
|
Vector2 result;
|
||||||
result.X = (normal.X * matrix.M11) + (normal.Y * matrix.M21);
|
result.X = (normal.X * matrix.M11) + (normal.Y * matrix.M21);
|
||||||
result.Y = (normal.X * matrix.M12) + (normal.Y * matrix.M22);
|
result.Y = (normal.X * matrix.M12) + (normal.Y * matrix.M22);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Vector2::TransformNormal(const Vector2& normal, const Matrix& matrix, out Vector2& result)
|
void Vector2::TransformNormal(const Vector2& normal, const Matrix& matrix, out Vector2& result)
|
||||||
{
|
{
|
||||||
result.X = (normal.X * matrix.M11) + (normal.Y * matrix.M21);
|
result.X = (normal.X * matrix.M11) + (normal.Y * matrix.M21);
|
||||||
result.Y = (normal.X * matrix.M12) + (normal.Y * matrix.M22);
|
result.Y = (normal.X * matrix.M12) + (normal.Y * matrix.M22);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Vector2::TransformNormal(const Vector2 sourceArray[], const int sourceIndex, const Matrix& matrix, Vector2 destinationArray[], const int destinationIndex, const int length)
|
void Vector2::TransformNormal(const Vector2 sourceArray[], const int sourceIndex, const Matrix& matrix, Vector2 destinationArray[], const int destinationIndex, const int length)
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
#include <System/Array.h>
|
#include <System/Array.h>
|
||||||
#include <System/Math.h>
|
#include <System/Math.h>
|
||||||
#include <System/String.h>
|
#include <System/String.h>
|
||||||
|
#include <System/Type.h>
|
||||||
|
|
||||||
#include <sassert.h>
|
#include <sassert.h>
|
||||||
|
|
||||||
@ -52,6 +53,7 @@ namespace XFX
|
|||||||
const Vector3 Vector3::UnitZ = Vector3(0, 0, 1);
|
const Vector3 Vector3::UnitZ = Vector3(0, 0, 1);
|
||||||
const Vector3 Vector3::Up = Vector3(0, 1, 0);
|
const Vector3 Vector3::Up = Vector3(0, 1, 0);
|
||||||
const Vector3 Vector3::Zero = Vector3(0, 0, 0);
|
const Vector3 Vector3::Zero = Vector3(0, 0, 0);
|
||||||
|
const Type Vector3TypeInfo("Vector3", "XFX::Vector3", TypeCode::Object);
|
||||||
|
|
||||||
Vector3::Vector3(float value)
|
Vector3::Vector3(float value)
|
||||||
: X(value), Y(value), Z(value)
|
: X(value), Y(value), Z(value)
|
||||||
@ -157,8 +159,8 @@ namespace XFX
|
|||||||
float Vector3::Distance(Vector3 value1, Vector3 value2)
|
float Vector3::Distance(Vector3 value1, Vector3 value2)
|
||||||
{
|
{
|
||||||
float x = value1.X - value2.X;
|
float x = value1.X - value2.X;
|
||||||
float y = value1.Y - value2.Y;
|
float y = value1.Y - value2.Y;
|
||||||
float z = value1.Z - value2.Z;
|
float z = value1.Z - value2.Z;
|
||||||
|
|
||||||
return Math::Sqrt((x*x) + (y*y) + (z*z));
|
return Math::Sqrt((x*x) + (y*y) + (z*z));
|
||||||
}
|
}
|
||||||
@ -166,8 +168,8 @@ namespace XFX
|
|||||||
void Vector3::Distance(Vector3 value1, Vector3 value2, out float& result)
|
void Vector3::Distance(Vector3 value1, Vector3 value2, out float& result)
|
||||||
{
|
{
|
||||||
float x = value1.X - value2.X;
|
float x = value1.X - value2.X;
|
||||||
float y = value1.Y - value2.Y;
|
float y = value1.Y - value2.Y;
|
||||||
float z = value1.Z - value2.Z;
|
float z = value1.Z - value2.Z;
|
||||||
|
|
||||||
result = Math::Sqrt((x*x) + (y*y) + (z*z));
|
result = Math::Sqrt((x*x) + (y*y) + (z*z));
|
||||||
}
|
}
|
||||||
@ -175,17 +177,17 @@ namespace XFX
|
|||||||
float Vector3::DistanceSquared(Vector3 value1, Vector3 value2)
|
float Vector3::DistanceSquared(Vector3 value1, Vector3 value2)
|
||||||
{
|
{
|
||||||
float x = value1.X - value2.X;
|
float x = value1.X - value2.X;
|
||||||
float y = value1.Y - value2.Y;
|
float y = value1.Y - value2.Y;
|
||||||
float z = value1.Z - value2.Z;
|
float z = value1.Z - value2.Z;
|
||||||
|
|
||||||
return (x*x) + (y*y) + (z*z);
|
return (x*x) + (y*y) + (z*z);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Vector3::DistanceSquared(Vector3 value1, Vector3 value2, out float& result)
|
void Vector3::DistanceSquared(Vector3 value1, Vector3 value2, out float& result)
|
||||||
{
|
{
|
||||||
float x = value1.X - value2.X;
|
float x = value1.X - value2.X;
|
||||||
float y = value1.Y - value2.Y;
|
float y = value1.Y - value2.Y;
|
||||||
float z = value1.Z - value2.Z;
|
float z = value1.Z - value2.Z;
|
||||||
|
|
||||||
result = (x*x) + (y*y) + (z*z);
|
result = (x*x) + (y*y) + (z*z);
|
||||||
}
|
}
|
||||||
@ -243,9 +245,9 @@ namespace XFX
|
|||||||
return ((int)X ^ (int)Y ^ (int)Z);
|
return ((int)X ^ (int)Y ^ (int)Z);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Vector3::GetType()
|
const Type& Vector3::GetType()
|
||||||
{
|
{
|
||||||
// TODO: implement
|
return Vector3TypeInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3 Vector3::Hermite(Vector3 value1, Vector3 tangent1, Vector3 value2, Vector3 tangent2, float amount)
|
Vector3 Vector3::Hermite(Vector3 value1, Vector3 tangent1, Vector3 value2, Vector3 tangent2, float amount)
|
||||||
@ -359,80 +361,92 @@ namespace XFX
|
|||||||
void Vector3::Normalize()
|
void Vector3::Normalize()
|
||||||
{
|
{
|
||||||
float length = Length();
|
float length = Length();
|
||||||
if(length == 0)
|
|
||||||
return;
|
if(length == 0)
|
||||||
float num = 1 / length;
|
{
|
||||||
X *= num;
|
return;
|
||||||
Y *= num;
|
}
|
||||||
Z *= num;
|
|
||||||
|
float num = 1 / length;
|
||||||
|
X *= num;
|
||||||
|
Y *= num;
|
||||||
|
Z *= num;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3 Vector3::Normalize(Vector3 value)
|
Vector3 Vector3::Normalize(Vector3 value)
|
||||||
{
|
{
|
||||||
Vector3 result;
|
Vector3 result;
|
||||||
float length = value.Length();
|
float length = value.Length();
|
||||||
if(length == 0)
|
|
||||||
return Vector3::Zero;
|
if(length == 0)
|
||||||
float num = 1 / length;
|
{
|
||||||
result.X *= num;
|
return Vector3::Zero;
|
||||||
result.Y *= num;
|
}
|
||||||
result.Z *= num;
|
|
||||||
return result;
|
float num = 1 / length;
|
||||||
|
result.X *= num;
|
||||||
|
result.Y *= num;
|
||||||
|
result.Z *= num;
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Vector3::Normalize(Vector3 value, out Vector3& result)
|
void Vector3::Normalize(Vector3 value, out Vector3& result)
|
||||||
{
|
{
|
||||||
float length = value.Length();
|
float length = value.Length();
|
||||||
if(length == 0)
|
|
||||||
return;
|
if(length == 0)
|
||||||
float num = 1 / length;
|
{
|
||||||
result.X *= num;
|
return;
|
||||||
result.Y *= num;
|
}
|
||||||
result.Z *= num;
|
|
||||||
|
float num = 1 / length;
|
||||||
|
result.X *= num;
|
||||||
|
result.Y *= num;
|
||||||
|
result.Z *= num;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3 Vector3::Reflect(Vector3 vector, Vector3 normal)
|
Vector3 Vector3::Reflect(Vector3 vector, Vector3 normal)
|
||||||
{
|
{
|
||||||
Vector3 result;
|
Vector3 result;
|
||||||
Reflect(vector, normal, result);
|
Reflect(vector, normal, result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Vector3::Reflect(Vector3 vector, Vector3 normal, out Vector3& result)
|
void Vector3::Reflect(Vector3 vector, Vector3 normal, out Vector3& result)
|
||||||
{
|
{
|
||||||
float dot = ((vector.X * normal.X) + (vector.Y * normal.Y)) + (vector.Z * normal.Z);
|
float dot = ((vector.X * normal.X) + (vector.Y * normal.Y)) + (vector.Z * normal.Z);
|
||||||
|
|
||||||
result.X = vector.X - ((2.0f * dot) * normal.X);
|
result.X = vector.X - ((2.0f * dot) * normal.X);
|
||||||
result.Y = vector.Y - ((2.0f * dot) * normal.Y);
|
result.Y = vector.Y - ((2.0f * dot) * normal.Y);
|
||||||
result.Z = vector.Z - ((2.0f * dot) * normal.Z);
|
result.Z = vector.Z - ((2.0f * dot) * normal.Z);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3 Vector3::SmoothStep(Vector3 value1, Vector3 value2, float amount)
|
Vector3 Vector3::SmoothStep(Vector3 value1, Vector3 value2, float amount)
|
||||||
{
|
{
|
||||||
Vector3 result;
|
Vector3 result;
|
||||||
SmoothStep(value1, value2, amount, result);
|
SmoothStep(value1, value2, amount, result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Vector3::SmoothStep(Vector3 value1, Vector3 value2, float amount, out Vector3& result)
|
void Vector3::SmoothStep(Vector3 value1, Vector3 value2, float amount, out Vector3& result)
|
||||||
{
|
{
|
||||||
result.X = MathHelper::SmoothStep(value1.X, value2.X, amount);
|
result.X = MathHelper::SmoothStep(value1.X, value2.X, amount);
|
||||||
result.Y = MathHelper::SmoothStep(value1.Y, value2.Y, amount);
|
result.Y = MathHelper::SmoothStep(value1.Y, value2.Y, amount);
|
||||||
result.Z = MathHelper::SmoothStep(value1.Z, value2.Z, amount);
|
result.Z = MathHelper::SmoothStep(value1.Z, value2.Z, amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3 Vector3::Subtract(Vector3 value1, Vector3 value2)
|
Vector3 Vector3::Subtract(Vector3 value1, Vector3 value2)
|
||||||
{
|
{
|
||||||
Vector3 result;
|
Vector3 result;
|
||||||
Subtract(value1, value2, result);
|
Subtract(value1, value2, result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Vector3::Subtract(Vector3 value1, Vector3 value2, out Vector3& result)
|
void Vector3::Subtract(Vector3 value1, Vector3 value2, out Vector3& result)
|
||||||
{
|
{
|
||||||
result.X = value1.X - value2.X;
|
result.X = value1.X - value2.X;
|
||||||
result.Y = value1.Y - value2.Y;
|
result.Y = value1.Y - value2.Y;
|
||||||
result.Z = value1.Z - value2.Z;
|
result.Z = value1.Z - value2.Z;
|
||||||
}
|
}
|
||||||
|
|
||||||
const String Vector3::ToString() const
|
const String Vector3::ToString() const
|
||||||
@ -451,14 +465,14 @@ namespace XFX
|
|||||||
{
|
{
|
||||||
Vector4 vector;
|
Vector4 vector;
|
||||||
|
|
||||||
vector.X = (((vector.X * matrix.M11) + (vector.Y * matrix.M21)) + (vector.Z * matrix.M31)) + matrix.M41;
|
vector.X = (((vector.X * matrix.M11) + (vector.Y * matrix.M21)) + (vector.Z * matrix.M31)) + matrix.M41;
|
||||||
vector.Y = (((vector.X * matrix.M12) + (vector.Y * matrix.M22)) + (vector.Z * matrix.M32)) + matrix.M42;
|
vector.Y = (((vector.X * matrix.M12) + (vector.Y * matrix.M22)) + (vector.Z * matrix.M32)) + matrix.M42;
|
||||||
vector.Z = (((vector.X * matrix.M13) + (vector.Y * matrix.M23)) + (vector.Z * matrix.M33)) + matrix.M43;
|
vector.Z = (((vector.X * matrix.M13) + (vector.Y * matrix.M23)) + (vector.Z * matrix.M33)) + matrix.M43;
|
||||||
vector.W = 1 / ((((vector.X * matrix.M14) + (vector.Y * matrix.M24)) + (vector.Z * matrix.M34)) + matrix.M44);
|
vector.W = 1 / ((((vector.X * matrix.M14) + (vector.Y * matrix.M24)) + (vector.Z * matrix.M34)) + matrix.M44);
|
||||||
|
|
||||||
result.X = vector.X * vector.W;
|
result.X = vector.X * vector.W;
|
||||||
result.Y = vector.Y * vector.W;
|
result.Y = vector.Y * vector.W;
|
||||||
result.Z = vector.Z * vector.W;
|
result.Z = vector.Z * vector.W;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3 Vector3::Transform(Vector3 position, Quaternion rotation)
|
Vector3 Vector3::Transform(Vector3 position, Quaternion rotation)
|
||||||
@ -507,14 +521,14 @@ namespace XFX
|
|||||||
{
|
{
|
||||||
Vector3 result;
|
Vector3 result;
|
||||||
TransformNormal(normal, matrix, result);
|
TransformNormal(normal, matrix, result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Vector3::TransformNormal(Vector3 normal, Matrix matrix, out Vector3& result)
|
void Vector3::TransformNormal(Vector3 normal, Matrix matrix, out Vector3& result)
|
||||||
{
|
{
|
||||||
result.X = ((normal.X * matrix.M11) + (normal.Y * matrix.M21)) + (normal.Z * matrix.M31);
|
result.X = ((normal.X * matrix.M11) + (normal.Y * matrix.M21)) + (normal.Z * matrix.M31);
|
||||||
result.Y = ((normal.X * matrix.M12) + (normal.Y * matrix.M22)) + (normal.Z * matrix.M32);
|
result.Y = ((normal.X * matrix.M12) + (normal.Y * matrix.M22)) + (normal.Z * matrix.M32);
|
||||||
result.Z = ((normal.X * matrix.M13) + (normal.Y * matrix.M23)) + (normal.Z * matrix.M33);
|
result.Z = ((normal.X * matrix.M13) + (normal.Y * matrix.M23)) + (normal.Z * matrix.M33);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Vector3::TransformNormal(const Vector3 sourceArray[], const int sourceIndex, const Matrix matrix, Vector3 destinationArray[], const int destinationIndex, const int length)
|
void Vector3::TransformNormal(const Vector3 sourceArray[], const int sourceIndex, const Matrix matrix, Vector3 destinationArray[], const int destinationIndex, const int length)
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
#include <Vector4.h>
|
#include <Vector4.h>
|
||||||
#include <System/Array.h>
|
#include <System/Array.h>
|
||||||
#include <System/Math.h>
|
#include <System/Math.h>
|
||||||
|
#include <System/Type.h>
|
||||||
|
|
||||||
#include <sassert.h>
|
#include <sassert.h>
|
||||||
|
|
||||||
@ -46,6 +47,7 @@ namespace XFX
|
|||||||
const Vector4 Vector4::UnitY = Vector4(0,1,0,0);
|
const Vector4 Vector4::UnitY = Vector4(0,1,0,0);
|
||||||
const Vector4 Vector4::UnitZ = Vector4(0,0,1,0);
|
const Vector4 Vector4::UnitZ = Vector4(0,0,1,0);
|
||||||
const Vector4 Vector4::Zero = Vector4(0,0,0,0);
|
const Vector4 Vector4::Zero = Vector4(0,0,0,0);
|
||||||
|
const Type Vector4TypeInfo("Vector4", "XFX::Vector4", TypeCode::Object);
|
||||||
|
|
||||||
Vector4::Vector4(float value)
|
Vector4::Vector4(float value)
|
||||||
: X(value), Y(value), Z(value), W(value)
|
: X(value), Y(value), Z(value), W(value)
|
||||||
@ -102,9 +104,9 @@ namespace XFX
|
|||||||
void Vector4::Baricentric(Vector4 value1, Vector4 value2, Vector4 value3, float amount1, float amount2, out Vector4& result)
|
void Vector4::Baricentric(Vector4 value1, Vector4 value2, Vector4 value3, float amount1, float amount2, out Vector4& result)
|
||||||
{
|
{
|
||||||
result.X = MathHelper::Baricentric(value1.X, value2.X, value3.X, amount1, amount2);
|
result.X = MathHelper::Baricentric(value1.X, value2.X, value3.X, amount1, amount2);
|
||||||
result.Y = MathHelper::Baricentric(value1.Y, value2.Y, value3.Y, amount1, amount2);
|
result.Y = MathHelper::Baricentric(value1.Y, value2.Y, value3.Y, amount1, amount2);
|
||||||
result.Z = MathHelper::Baricentric(value1.Z, value2.Z, value3.Z, amount1, amount2);
|
result.Z = MathHelper::Baricentric(value1.Z, value2.Z, value3.Z, amount1, amount2);
|
||||||
result.W = MathHelper::Baricentric(value1.W, value2.W, value3.W, amount1, amount2);
|
result.W = MathHelper::Baricentric(value1.W, value2.W, value3.W, amount1, amount2);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector4 Vector4::CatmullRom(Vector4 value1, Vector4 value2, Vector4 value3, Vector4 value4, float amount)
|
Vector4 Vector4::CatmullRom(Vector4 value1, Vector4 value2, Vector4 value3, Vector4 value4, float amount)
|
||||||
@ -135,38 +137,38 @@ namespace XFX
|
|||||||
void Vector4::Clamp(Vector4 value1, Vector4 min, Vector4 max, out Vector4& result)
|
void Vector4::Clamp(Vector4 value1, Vector4 min, Vector4 max, out Vector4& result)
|
||||||
{
|
{
|
||||||
result = Vector4(
|
result = Vector4(
|
||||||
MathHelper::Clamp(value1.X, min.X, max.X),
|
MathHelper::Clamp(value1.X, min.X, max.X),
|
||||||
MathHelper::Clamp(value1.Y, min.Y, max.Y),
|
MathHelper::Clamp(value1.Y, min.Y, max.Y),
|
||||||
MathHelper::Clamp(value1.Z, min.Z, max.Z),
|
MathHelper::Clamp(value1.Z, min.Z, max.Z),
|
||||||
MathHelper::Clamp(value1.W, min.W, max.W));
|
MathHelper::Clamp(value1.W, min.W, max.W));
|
||||||
}
|
}
|
||||||
|
|
||||||
float Vector4::Distance(Vector4 value1, Vector4 value2)
|
float Vector4::Distance(Vector4 value1, Vector4 value2)
|
||||||
{
|
{
|
||||||
return Math::Sqrt(DistanceSquared(value1, value2));
|
return Math::Sqrt(DistanceSquared(value1, value2));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Vector4::Distance(Vector4 value1, Vector4 value2, out float& result)
|
void Vector4::Distance(Vector4 value1, Vector4 value2, out float& result)
|
||||||
{
|
{
|
||||||
result = Math::Sqrt(DistanceSquared(value1, value2));
|
result = Math::Sqrt(DistanceSquared(value1, value2));
|
||||||
}
|
}
|
||||||
|
|
||||||
float Vector4::DistanceSquared(Vector4 value1, Vector4 value2)
|
float Vector4::DistanceSquared(Vector4 value1, Vector4 value2)
|
||||||
{
|
{
|
||||||
float result = (value1.W - value2.W) * (value1.W - value2.W) +
|
float result = (value1.W - value2.W) * (value1.W - value2.W) +
|
||||||
(value1.X - value2.X) * (value1.X - value2.X) +
|
(value1.X - value2.X) * (value1.X - value2.X) +
|
||||||
(value1.Y - value2.Y) * (value1.Y - value2.Y) +
|
(value1.Y - value2.Y) * (value1.Y - value2.Y) +
|
||||||
(value1.Z - value2.Z) * (value1.Z - value2.Z);
|
(value1.Z - value2.Z) * (value1.Z - value2.Z);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Vector4::DistanceSquared(Vector4 value1, Vector4 value2, out float& result)
|
void Vector4::DistanceSquared(Vector4 value1, Vector4 value2, out float& result)
|
||||||
{
|
{
|
||||||
result = (value1.W - value2.W) * (value1.W - value2.W) +
|
result = (value1.W - value2.W) * (value1.W - value2.W) +
|
||||||
(value1.X - value2.X) * (value1.X - value2.X) +
|
(value1.X - value2.X) * (value1.X - value2.X) +
|
||||||
(value1.Y - value2.Y) * (value1.Y - value2.Y) +
|
(value1.Y - value2.Y) * (value1.Y - value2.Y) +
|
||||||
(value1.Z - value2.Z) * (value1.Z - value2.Z);
|
(value1.Z - value2.Z) * (value1.Z - value2.Z);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector4 Vector4::Divide(Vector4 value, float scale)
|
Vector4 Vector4::Divide(Vector4 value, float scale)
|
||||||
{
|
{
|
||||||
@ -209,153 +211,157 @@ namespace XFX
|
|||||||
return ((int)X ^ (int)Y ^ (int)Z ^ (int)W);
|
return ((int)X ^ (int)Y ^ (int)Z ^ (int)W);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Vector4::GetType()
|
const Type& Vector4::GetType()
|
||||||
{
|
{
|
||||||
// TODO: implement
|
return Vector4TypeInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector4 Vector4::Hermite(Vector4 value1, Vector4 tangent1, Vector4 value2, Vector4 tangent2, float amount)
|
Vector4 Vector4::Hermite(Vector4 value1, Vector4 tangent1, Vector4 value2, Vector4 tangent2, float amount)
|
||||||
{
|
{
|
||||||
Vector4 result;
|
Vector4 result;
|
||||||
Hermite(value1, tangent1, value2, tangent2, amount, result);
|
Hermite(value1, tangent1, value2, tangent2, amount, result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Vector4::Hermite(Vector4 value1, Vector4 tangent1, Vector4 value2, Vector4 tangent2, float amount, out Vector4& result)
|
void Vector4::Hermite(Vector4 value1, Vector4 tangent1, Vector4 value2, Vector4 tangent2, float amount, out Vector4& result)
|
||||||
{
|
{
|
||||||
result.W = MathHelper::Hermite(value1.W, tangent1.W, value2.W, tangent2.W, amount);
|
result.W = MathHelper::Hermite(value1.W, tangent1.W, value2.W, tangent2.W, amount);
|
||||||
result.X = MathHelper::Hermite(value1.X, tangent1.X, value2.X, tangent2.X, amount);
|
result.X = MathHelper::Hermite(value1.X, tangent1.X, value2.X, tangent2.X, amount);
|
||||||
result.Y = MathHelper::Hermite(value1.Y, tangent1.Y, value2.Y, tangent2.Y, amount);
|
result.Y = MathHelper::Hermite(value1.Y, tangent1.Y, value2.Y, tangent2.Y, amount);
|
||||||
result.Z = MathHelper::Hermite(value1.Z, tangent1.Z, value2.Z, tangent2.Z, amount);
|
result.Z = MathHelper::Hermite(value1.Z, tangent1.Z, value2.Z, tangent2.Z, amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
float Vector4::Length()
|
float Vector4::Length()
|
||||||
{
|
{
|
||||||
return Math::Sqrt((X * X) + (Y * Y) + (Z * Z) + (W * W));
|
return Math::Sqrt((X * X) + (Y * Y) + (Z * Z) + (W * W));
|
||||||
}
|
}
|
||||||
|
|
||||||
float Vector4::LengthSquared()
|
float Vector4::LengthSquared()
|
||||||
{
|
{
|
||||||
return (X * X) + (Y * Y) + (Z * Z) + (W * W);
|
return (X * X) + (Y * Y) + (Z * Z) + (W * W);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector4 Vector4::Lerp(Vector4 value1, Vector4 value2, float amount)
|
Vector4 Vector4::Lerp(Vector4 value1, Vector4 value2, float amount)
|
||||||
{
|
{
|
||||||
Vector4 result;
|
Vector4 result;
|
||||||
Lerp(value1, value2, amount, result);
|
Lerp(value1, value2, amount, result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Vector4::Lerp(Vector4 value1, Vector4 value2, float amount, out Vector4& result)
|
void Vector4::Lerp(Vector4 value1, Vector4 value2, float amount, out Vector4& result)
|
||||||
{
|
{
|
||||||
result.X = MathHelper::Lerp(value1.X, value2.X, amount);
|
result.X = MathHelper::Lerp(value1.X, value2.X, amount);
|
||||||
result.Y = MathHelper::Lerp(value1.Y, value2.Y, amount);
|
result.Y = MathHelper::Lerp(value1.Y, value2.Y, amount);
|
||||||
result.Z = MathHelper::Lerp(value1.Z, value2.Z, amount);
|
result.Z = MathHelper::Lerp(value1.Z, value2.Z, amount);
|
||||||
result.W = MathHelper::Lerp(value1.W, value2.W, amount);
|
result.W = MathHelper::Lerp(value1.W, value2.W, amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector4 Vector4::Max(Vector4 value1, Vector4 value2)
|
Vector4 Vector4::Max(Vector4 value1, Vector4 value2)
|
||||||
{
|
{
|
||||||
Vector4 result;
|
Vector4 result;
|
||||||
Max(value1, value2, result);
|
Max(value1, value2, result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Vector4::Max(Vector4 value1, Vector4 value2, out Vector4& result)
|
void Vector4::Max(Vector4 value1, Vector4 value2, out Vector4& result)
|
||||||
{
|
{
|
||||||
result.X = MathHelper::Max(value1.X, value2.X);
|
result.X = MathHelper::Max(value1.X, value2.X);
|
||||||
result.Y = MathHelper::Max(value1.Y, value2.Y);
|
result.Y = MathHelper::Max(value1.Y, value2.Y);
|
||||||
result.Z = MathHelper::Max(value1.Z, value2.Z);
|
result.Z = MathHelper::Max(value1.Z, value2.Z);
|
||||||
result.W = MathHelper::Max(value1.W, value2.W);
|
result.W = MathHelper::Max(value1.W, value2.W);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector4 Vector4::Min(Vector4 value1, Vector4 value2)
|
Vector4 Vector4::Min(Vector4 value1, Vector4 value2)
|
||||||
{
|
{
|
||||||
Vector4 result;
|
Vector4 result;
|
||||||
Min(value1, value2, result);
|
Min(value1, value2, result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Vector4::Min(Vector4 value1, Vector4 value2, out Vector4& result)
|
void Vector4::Min(Vector4 value1, Vector4 value2, out Vector4& result)
|
||||||
{
|
{
|
||||||
result = Vector4(
|
result = Vector4(
|
||||||
MathHelper::Min(value1.X, value2.X),
|
MathHelper::Min(value1.X, value2.X),
|
||||||
MathHelper::Min(value1.Y, value2.Y),
|
MathHelper::Min(value1.Y, value2.Y),
|
||||||
MathHelper::Min(value1.Z, value2.Z),
|
MathHelper::Min(value1.Z, value2.Z),
|
||||||
MathHelper::Min(value1.W, value2.W));
|
MathHelper::Min(value1.W, value2.W));
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector4 Vector4::Multiply(Vector4 value1, float scaleFactor)
|
Vector4 Vector4::Multiply(Vector4 value1, float scaleFactor)
|
||||||
{
|
{
|
||||||
Vector4 result;
|
Vector4 result;
|
||||||
Multiply(value1, scaleFactor, result);
|
Multiply(value1, scaleFactor, result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Vector4::Multiply(Vector4 value1, float scaleFactor, out Vector4& result)
|
void Vector4::Multiply(Vector4 value1, float scaleFactor, out Vector4& result)
|
||||||
{
|
{
|
||||||
result.X = value1.X * scaleFactor;
|
result.X = value1.X * scaleFactor;
|
||||||
result.Y = value1.Y * scaleFactor;
|
result.Y = value1.Y * scaleFactor;
|
||||||
result.Z = value1.Z * scaleFactor;
|
result.Z = value1.Z * scaleFactor;
|
||||||
result.W = value1.W * scaleFactor;
|
result.W = value1.W * scaleFactor;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector4 Vector4::Multiply(Vector4 value1, Vector4 value2)
|
Vector4 Vector4::Multiply(Vector4 value1, Vector4 value2)
|
||||||
{
|
{
|
||||||
Vector4 result;
|
Vector4 result;
|
||||||
Multiply(value1, value2, result);
|
Multiply(value1, value2, result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Vector4::Multiply(Vector4 value1, Vector4 value2, out Vector4& result)
|
void Vector4::Multiply(Vector4 value1, Vector4 value2, out Vector4& result)
|
||||||
{
|
{
|
||||||
result.W = value1.W * value2.W;
|
result.W = value1.W * value2.W;
|
||||||
result.X = value1.X * value2.X;
|
result.X = value1.X * value2.X;
|
||||||
result.Y = value1.Y * value2.Y;
|
result.Y = value1.Y * value2.Y;
|
||||||
result.Z = value1.Z * value2.Z;
|
result.Z = value1.Z * value2.Z;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector4 Vector4::Negate(Vector4 value)
|
Vector4 Vector4::Negate(Vector4 value)
|
||||||
{
|
{
|
||||||
Vector4 result;
|
Vector4 result;
|
||||||
Negate(value, result);
|
Negate(value, result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Vector4::Negate(Vector4 value, out Vector4& result)
|
void Vector4::Negate(Vector4 value, out Vector4& result)
|
||||||
{
|
{
|
||||||
result = Vector4(-value.X, -value.Y, -value.Z, -value.W);
|
result = Vector4(-value.X, -value.Y, -value.Z, -value.W);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Vector4::Normalize()
|
void Vector4::Normalize()
|
||||||
{
|
{
|
||||||
float length = Length();
|
float length = Length();
|
||||||
if( length == 0 )
|
|
||||||
return;
|
|
||||||
float num = 1 / length;
|
|
||||||
X *= num;
|
|
||||||
Y *= num;
|
|
||||||
Z *= num;
|
|
||||||
W *= num;
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector4 Vector4::Normalize(Vector4 value)
|
if(length == 0)
|
||||||
{
|
{
|
||||||
Normalize(value, value);
|
return;
|
||||||
return value;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void Vector4::Normalize(Vector4 value, out Vector4& result)
|
float num = 1 / length;
|
||||||
{
|
X *= num;
|
||||||
float factor;
|
Y *= num;
|
||||||
float length = value.Length();
|
Z *= num;
|
||||||
factor = 1.0f / length;
|
W *= num;
|
||||||
|
}
|
||||||
|
|
||||||
result.W = value.W * factor;
|
Vector4 Vector4::Normalize(Vector4 value)
|
||||||
result.X = value.X * factor;
|
{
|
||||||
result.Y = value.Y * factor;
|
Normalize(value, value);
|
||||||
result.Z = value.Z * factor;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Vector4::Normalize(Vector4 value, out Vector4& result)
|
||||||
|
{
|
||||||
|
float factor;
|
||||||
|
float length = value.Length();
|
||||||
|
factor = 1.0f / length;
|
||||||
|
|
||||||
|
result.W = value.W * factor;
|
||||||
|
result.X = value.X * factor;
|
||||||
|
result.Y = value.Y * factor;
|
||||||
|
result.Z = value.Z * factor;
|
||||||
|
}
|
||||||
|
|
||||||
Vector4 Vector4::SmoothStep(Vector4 value1, Vector4 value2, float amount)
|
Vector4 Vector4::SmoothStep(Vector4 value1, Vector4 value2, float amount)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user