Exemple #1
0
        public static IntersectResult intersect(this aabb2 aabb, vec2 v)
        {
            if (v.x < aabb.a.x && v.x > aabb.b.x)
            {
                return(IntersectResult.None);
            }
            if (v.y < aabb.a.y && v.y > aabb.b.y)
            {
                return(IntersectResult.None);
            }
            if ((v.x == aabb.a.x || v.x == aabb.b.x) && (v.y == aabb.a.y && v.y == aabb.b.y))
            {
                return(IntersectResult.Intersect);
            }

            return(IntersectResult.Contain1);
        }
Exemple #2
0
        public static IntersectResult intersect(this aabb2 aabb, triangle <vec2> tri)
        {
            int siflags = 0x000000;

            for (int i = 0; i < tri.p.Length; i++)
            {
                var r = aabb.intersect(tri.p[i]);
                siflags = (int)(r) << (i << 8);
            }

            if (siflags == 0x010101)
            {
                return(IntersectResult.Contain1);
            }

            return(IntersectResult.None);
        }
Exemple #3
0
        public void UVMapPlane(Plane plane, vec3 forward, aabb2 uvrect, int[] vs)
        {
            vec2[] pvs = new vec2[vs.Length];

            aabb2      b = aabb2.empty;
            Quaternion q = Quaternion.LookRotation(MathEx.Convert.ToVector3(forward), plane.normal);

            for (int i = 0; i < vs.Length; i++)
            {
                pvs[i] = MathEx.Convert.ToVec3(q * MathEx.Convert.ToVector3(vertices[vs[i]])).xz();
                b      = b.Extend(pvs[i]);
            }

            Debug.Log(b);
            for (int i = 0; i < vs.Length; i++)
            {
                uvs[vs[i]] = uvrect.a + uvrect.size.Mul((pvs[i] - b.a).Div(b.size));
                Debug.Log(uvs[vs[i]]);
            }
        }
Exemple #4
0
        public static IntersectResult intersect(this aabb2 aabb, aabb2 v)
        {
            int resA = aabb.Position(v.a);
            int resB = aabb.Position(v.b);

            if ((resA & resB) != 0)
            {
                return(IntersectResult.None);
            }

            if (resA == 0 && resB == 0)
            {
                return(IntersectResult.Contain1);
            }

            if ((resA | resB) == 15)
            {
                return(IntersectResult.Contain2);
            }

            return(IntersectResult.Intersect);
        }