示例#1
0
        public bool IntersectsPlane(GodotPlane plane)
        {
            GodotVector3[] vector3Array = new GodotVector3[8]
            {
                new GodotVector3(position.x, position.y, position.z),
                new GodotVector3(position.x, position.y, position.z + size.z),
                new GodotVector3(position.x, position.y + size.y, position.z),
                new GodotVector3(position.x, position.y + size.y, position.z + size.z),
                new GodotVector3(position.x + size.x, position.y, position.z),
                new GodotVector3(position.x + size.x, position.y, position.z + size.z),
                new GodotVector3(position.x + size.x, position.y + size.y, position.z),
                new GodotVector3(position.x + size.x, position.y + size.y, position.z + size.z)
            };
            bool flag1 = false;
            bool flag2 = false;

            for (int index = 0; index < 8; ++index)
            {
                if (plane.DistanceTo(vector3Array[index]) > 0.0)
                {
                    flag1 = true;
                }
                else
                {
                    flag2 = true;
                }
            }
            return(flag2 & flag1);
        }
示例#2
0
        public GodotAABB Expand(GodotVector3 to_point)
        {
            GodotVector3 position = this.position;
            GodotVector3 vector3  = this.position + size;

            if (to_point.x < (double)position.x)
            {
                position.x = to_point.x;
            }
            if (to_point.y < (double)position.y)
            {
                position.y = to_point.y;
            }
            if (to_point.z < (double)position.z)
            {
                position.z = to_point.z;
            }
            if (to_point.x > (double)vector3.x)
            {
                vector3.x = to_point.x;
            }
            if (to_point.y > (double)vector3.y)
            {
                vector3.y = to_point.y;
            }
            if (to_point.z > (double)vector3.z)
            {
                vector3.z = to_point.z;
            }
            return(new GodotAABB(position, vector3 - position));
        }
示例#3
0
        public GodotAABB Intersection(GodotAABB with)
        {
            GodotVector3 position1 = position;
            GodotVector3 vector3_1 = position + size;
            GodotVector3 position2 = with.position;
            GodotVector3 vector3_2 = with.position + with.size;

            if (position1.x > vector3_2.x || vector3_1.x < position2.x)
            {
                return(new GodotAABB());
            }
            GodotVector3 position3;

            position3.x = position1.x > position2.x ? position1.x : position2.x;
            GodotVector3 vector3_3;

            vector3_3.x = vector3_1.x < vector3_2.x ? vector3_1.x : vector3_2.x;
            if (position1.y > vector3_2.y || vector3_1.y < position2.y)
            {
                return(new GodotAABB());
            }
            position3.y = position1.y > position2.y ? position1.y : position2.y;
            vector3_3.y = vector3_1.y < vector3_2.y ? vector3_1.y : vector3_2.y;
            if (position1.z > vector3_2.z || vector3_1.z < position2.z)
            {
                return(new GodotAABB());
            }
            position3.z = position1.z > position2.z ? position1.z : position2.z;
            vector3_3.z = vector3_1.z < vector3_2.z ? vector3_1.z : vector3_2.z;
            return(new GodotAABB(position3, vector3_3 - position3));
        }
示例#4
0
        public GodotTransform LookingAt(GodotVector3 target, GodotVector3 up)
        {
            GodotTransform transform = this;

            transform.SetLookAt(origin, target, up);
            return(transform);
        }
示例#5
0
        public GodotBasis(GodotVector3 axis, float phi)
        {
            GodotVector3 vector3 = new GodotVector3(axis.x * axis.x, axis.y * axis.y, axis.z * axis.z);
            float        num1    = GodotMathf.Cos(phi);
            float        num2    = GodotMathf.Sin(phi);

            x = new GodotVector3(vector3.x + (num1 * (1f - vector3.x)), (float)((axis.x * axis.y * (1.0 - num1)) - (axis.z * num2)), (float)((axis.z * axis.x * (1.0 - num1)) + (axis.y * num2)));
            y = new GodotVector3((float)((axis.x * axis.y * (1.0 - num1)) + (axis.z * num2)), vector3.y + (num1 * (1f - vector3.y)), (float)((axis.y * axis.z * (1.0 - num1)) - (axis.x * num2)));
            z = new GodotVector3((float)((axis.z * axis.x * (1.0 - num1)) - (axis.y * num2)), (float)((axis.y * axis.z * (1.0 - num1)) + (axis.x * num2)), vector3.z + (num1 * (1f - vector3.z)));
        }
示例#6
0
        public GodotAABB Merge(GodotAABB with)
        {
            GodotVector3 position1 = position;
            GodotVector3 position2 = with.position;
            GodotVector3 vector3_1 = new GodotVector3(size.x, size.y, size.z) + position1;
            GodotVector3 vector3_2 = new GodotVector3(with.size.x, with.size.y, with.size.z) + position2;
            GodotVector3 position3 = new GodotVector3(position1.x < position2.x ? position1.x : position2.x, position1.y < position2.y ? position1.y : position2.y, position1.z < position2.z ? position1.z : position2.z);
            GodotVector3 vector3_3 = new GodotVector3(vector3_1.x > vector3_2.x ? vector3_1.x : vector3_2.x, vector3_1.y > vector3_2.y ? vector3_1.y : vector3_2.y, vector3_1.z > vector3_2.z ? vector3_1.z : vector3_2.z);

            return(new GodotAABB(position3, vector3_3 - position3));
        }
示例#7
0
        public bool Encloses(GodotAABB with)
        {
            GodotVector3 position1 = position;
            GodotVector3 vector3_1 = position + size;
            GodotVector3 position2 = with.position;
            GodotVector3 vector3_2 = with.position + with.size;

            if (position1.x <= position2.x && vector3_1.x > (double)vector3_2.x && (position1.y <= (double)position2.y && vector3_1.y > (double)vector3_2.y) && position1.z <= (double)position2.z)
            {
                return(vector3_1.z > vector3_2.z);
            }
            return(false);
        }
示例#8
0
        public GodotVector3 Xform(GodotVector3 v)
        {
            GodotVector3 vector3 = this[0];
            float        num1    = vector3.Dot(v);

            vector3 = this[1];
            float num2 = vector3.Dot(v);

            vector3 = this[2];
            float num3 = vector3.Dot(v);

            return(new GodotVector3(num1, num2, num3));
        }
示例#9
0
        public void SetLookAt(GodotVector3 eye, GodotVector3 target, GodotVector3 up)
        {
            GodotVector3 vector3_1 = eye - target;

            vector3_1.Normalize();
            GodotVector3 vector3_2 = up.Cross(vector3_1);
            GodotVector3 yAxis     = vector3_1.Cross(vector3_2);

            vector3_2.Normalize();
            yAxis.Normalize();
            basis  = GodotBasis.CreateFromAxes(vector3_2, yAxis, vector3_1);
            origin = eye;
        }
示例#10
0
        public GodotBasis Orthonormalized()
        {
            GodotVector3 axis1 = GetAxis(0);
            GodotVector3 axis2 = GetAxis(1);
            GodotVector3 axis3 = GetAxis(2);

            axis1.Normalize();
            GodotVector3 yAxis = axis2 - (axis1 * axis1.Dot(axis2));

            yAxis.Normalize();
            GodotVector3 zAxis = axis3 - (axis1 * axis1.Dot(axis3)) - (yAxis * yAxis.Dot(axis3));

            zAxis.Normalize();
            return(CreateFromAxes(axis1, yAxis, zAxis));
        }
示例#11
0
 public GodotBasis(
     float xx,
     float xy,
     float xz,
     float yx,
     float yy,
     float yz,
     float zx,
     float zy,
     float zz)
 {
     x = new GodotVector3(xx, xy, xz);
     y = new GodotVector3(yx, yy, yz);
     z = new GodotVector3(zx, zy, zz);
 }
示例#12
0
        public GodotBasis Scaled(GodotVector3 scale)
        {
            GodotBasis basis = this;

            basis[0, 0] *= scale.x;
            basis[0, 1] *= scale.x;
            basis[0, 2] *= scale.x;
            basis[1, 0] *= scale.y;
            basis[1, 1] *= scale.y;
            basis[1, 2] *= scale.y;
            basis[2, 0] *= scale.z;
            basis[2, 1] *= scale.z;
            basis[2, 2] *= scale.z;
            return(basis);
        }
示例#13
0
        public bool IntersectsSegment(GodotVector3 from, GodotVector3 to)
        {
            float num1 = 0.0f;
            float num2 = 1f;

            for (int index = 0; index < 3; ++index)
            {
                float num3 = from[index];
                float num4 = to[index];
                float num5 = position[index];
                float num6 = num5 + size[index];
                float num7;
                float num8;
                if (num3 < num4)
                {
                    if (num3 > num6 || num4 < num5)
                    {
                        return(false);
                    }
                    float num9 = num4 - num3;
                    num7 = num3 < num5 ? (num5 - num3) / num9 : 0.0f;
                    num8 = num4 > num6 ? (num6 - num3) / num9 : 1f;
                }
                else
                {
                    if (num4 > num6 || num3 < num5)
                    {
                        return(false);
                    }
                    float num9 = num4 - num3;
                    num7 = num3 > num6 ? (num6 - num3) / num9 : 0.0f;
                    num8 = num4 < num5 ? (num5 - num3) / num9 : 1f;
                }
                if (num7 > num1)
                {
                    num1 = num7;
                }
                if (num8 < num2)
                {
                    num2 = num8;
                }
                if (num2 < num1)
                {
                    return(false);
                }
            }
            return(true);
        }
示例#14
0
        public GodotVector3 IntersectRay(GodotVector3 from, GodotVector3 dir)
        {
            float s = normal.Dot(dir);

            if (GodotMathf.Abs(s) <= 9.99999997475243E-07)
            {
                return(new GodotVector3());
            }
            float num = (normal.Dot(from) - d) / s;

            if (num > 9.99999997475243E-07)
            {
                return(new GodotVector3());
            }
            return(from + (dir * -num));
        }
示例#15
0
        public GodotVector3 GetShortestAxis()
        {
            GodotVector3 vector3 = new GodotVector3(1f, 0.0f, 0.0f);
            float        num     = size.x;

            if (size.y < num)
            {
                vector3 = new GodotVector3(0.0f, 1f, 0.0f);
                num     = size.y;
            }
            if (size.z < num)
            {
                vector3 = new GodotVector3(0.0f, 0.0f, 1f);
                float z = size.z;
            }
            return(vector3);
        }
示例#16
0
        public GodotVector3 IntersectSegment(GodotVector3 begin, GodotVector3 end)
        {
            GodotVector3 b = begin - end;
            float        s = normal.Dot(b);

            if (GodotMathf.Abs(s) <= 9.99999997475243E-07)
            {
                return(new GodotVector3());
            }
            float num = (normal.Dot(begin) - d) / s;

            if (num < -9.99999997475243E-07 || num > 1.00000095367432)
            {
                return(new GodotVector3());
            }
            return(begin + (b * -num));
        }
示例#17
0
        public GodotBasis(GodotQuat quat)
        {
            float qdot = 2f / quat.LengthSquared();
            float qx   = quat.x * qdot;
            float qy   = quat.y * qdot;
            float qz   = quat.z * qdot;
            float qwx  = quat.w * qx;
            float qwy  = quat.w * qy;
            float qwz  = quat.w * qz;
            float qxx  = quat.x * qx;
            float qxy  = quat.x * qy;
            float qxz  = quat.x * qz;
            float qyy  = quat.y * qy;
            float qyz  = quat.y * qz;
            float qzz  = quat.z * qz;

            x = new GodotVector3(1.0f - (qyy + qzz), qxy - qwz, qxz + qwy);
            y = new GodotVector3(qxy + qwz, 1.0f - (qxx + qzz), qyz - qwx);
            z = new GodotVector3(qxz - qwy, qyz + qwx, 1.0f - (qxx + qyy));
        }
示例#18
0
        public GodotQuat(GodotVector3 axis, float angle)
        {
            float num1 = axis.Length();

            if (num1 == 0.0)
            {
                x = 0.0f;
                y = 0.0f;
                z = 0.0f;
                w = 0.0f;
            }
            else
            {
                float num2 = GodotMathf.Sin(angle * 0.5f) / num1;
                x = axis.x * num2;
                y = axis.y * num2;
                z = axis.z * num2;
                w = GodotMathf.Cos(angle * 0.5f);
            }
        }
示例#19
0
        public                             GodotVector3 this[int index]
        {
            get
            {
                switch (index)
                {
                case 0:
                    return(x);

                case 1:
                    return(y);

                case 2:
                    return(z);

                default:
                    throw new IndexOutOfRangeException();
                }
            }
            set
            {
                switch (index)
                {
                case 0:
                    x = value;
                    break;

                case 1:
                    y = value;
                    break;

                case 2:
                    z = value;
                    break;

                default:
                    throw new IndexOutOfRangeException();
                }
            }
        }
示例#20
0
 public bool HasPoint(GodotVector3 point)
 {
     return(point.x >= position.x && point.y >= position.y && (point.z >= position.z && point.x <= position.x + size.x) && (point.y <= position.y + size.y && point.z <= position.z + size.z));
 }
示例#21
0
 public GodotTransform Scaled(GodotVector3 scale)
 {
     return(new GodotTransform(basis.Scaled(scale), origin * scale));
 }
示例#22
0
 public GodotAABB(GodotVector3 position, GodotVector3 size)
 {
     this.position = position;
     this.size     = size;
 }
示例#23
0
 public GodotBasis(GodotVector3 xAxis, GodotVector3 yAxis, GodotVector3 zAxis)
 {
     x = xAxis;
     y = yAxis;
     z = zAxis;
 }
示例#24
0
 public GodotVector3 XformInv(GodotVector3 v)
 {
     return(new GodotVector3((this[0, 0] * v.x) + (this[1, 0] * v.y) + (this[2, 0] * v.z), (this[0, 1] * v.x) + (this[1, 1] * v.y) + (this[2, 1] * v.z), (this[0, 2] * v.x) + (this[1, 2] * v.y) + (this[2, 2] * v.z)));
 }
示例#25
0
        public GodotVector3 Xform(GodotVector3 v)
        {
            GodotQuat quat = this * v *Inverse();

            return(new GodotVector3(quat.x, quat.y, quat.z));
        }
示例#26
0
 public GodotTransform Rotated(GodotVector3 axis, float phi)
 {
     return(new GodotTransform(new GodotBasis(axis, phi), new GodotVector3()) * this);
 }
示例#27
0
 public float Tdotz(GodotVector3 with)
 {
     return((this[0, 2] * with[0]) + (this[1, 2] * with[1]) + (this[2, 2] * with[2]));
 }
示例#28
0
 public GodotTransform Translated(GodotVector3 ofs)
 {
     GodotBasis       basis  = this.basis;
     ref GodotVector3 local1 = ref this.origin;
示例#29
0
 public GodotBasis Rotated(GodotVector3 axis, float phi)
 {
     return(new GodotBasis(axis, phi) * this);
 }
示例#30
0
 internal static GodotBasis CreateFromAxes(GodotVector3 xAxis, GodotVector3 yAxis, GodotVector3 zAxis)
 {
     return(new GodotBasis(new GodotVector3(xAxis.x, yAxis.x, zAxis.x), new GodotVector3(xAxis.y, yAxis.y, zAxis.y), new GodotVector3(xAxis.z, yAxis.z, zAxis.z)));
 }