コード例 #1
0
ファイル: Octree.cs プロジェクト: rpenido/obstavoid
 public OctreeNode(Vector3 min, Vector3 max, int level)
 {
     this.min = min;
     this.max = max;
     this.level = level;
     this.obb = new OrientedBoundingBox(min, max);
     triangles = new List<TriangleData>();
 }
コード例 #2
0
ファイル: Link.cs プロジェクト: rpenido/obstavoid
 public bool Intersects(OrientedBoundingBox other)
 {
     foreach (OrientedBoundingBox obb in boundingBoxList)
     {
         obb.Transforms = Transform * obb.BoxTransform;
         if (other.Intersects(obb))
             return true;
     }
     return false;
 }
コード例 #3
0
ファイル: Link.cs プロジェクト: rpenido/obstavoid
 public void AddBoundingBox(OrientedBoundingBox boudingBox)
 {
     boundingBoxList.Add(boudingBox);
 }
コード例 #4
0
        public bool Intersects(OrientedBoundingBox other)
        {
            Matrix m = Transforms;
            Matrix otherM = other.Transforms;

            Vector3[] extentsOther = other.extents;
            Vector3 myCenter = Vector3.Transform(center, m);
            Vector3 centerOther = Vector3.Transform(other.Center, otherM);

            Vector3 distance = centerOther - myCenter;

            if (IsSeparationAxisBoxBox(m.Forward, distance, extents, transforms, extentsOther, otherM))
                return false;

            if (IsSeparationAxisBoxBox(m.Left, distance, extents, transforms, extentsOther, otherM))
                return false;

            if (IsSeparationAxisBoxBox(m.Up, distance, extents, transforms, extentsOther, otherM))
                return false;

            if (IsSeparationAxisBoxBox(otherM.Forward, distance, extents, transforms, extentsOther, otherM))
                return false;

            if (IsSeparationAxisBoxBox(otherM.Left, distance, extents, transforms, extentsOther, otherM))
                return false;

            if (IsSeparationAxisBoxBox(otherM.Up, distance, extents, transforms, extentsOther, otherM))
                return false;

            if (IsSeparationAxisBoxBox(Vector3.Cross(m.Forward, otherM.Forward), distance, extents, transforms, extentsOther, otherM))
                return false;
            if (IsSeparationAxisBoxBox(Vector3.Cross(m.Forward, otherM.Left), distance, extents, transforms, extentsOther, otherM))
                return false;
            if (IsSeparationAxisBoxBox(Vector3.Cross(m.Forward, otherM.Up), distance, extents, transforms, extentsOther, otherM))
                return false;
            if (IsSeparationAxisBoxBox(Vector3.Cross(m.Left, otherM.Forward), distance, extents, transforms, extentsOther, otherM))
                return false;
            if (IsSeparationAxisBoxBox(Vector3.Cross(m.Left, otherM.Left), distance, extents, transforms, extentsOther, otherM))
                return false;
            if (IsSeparationAxisBoxBox(Vector3.Cross(m.Left, otherM.Up), distance, extents, transforms, extentsOther, otherM))
                return false;
            if (IsSeparationAxisBoxBox(Vector3.Cross(m.Up, otherM.Forward), distance, extents, transforms, extentsOther, otherM))
                return false;
            if (IsSeparationAxisBoxBox(Vector3.Cross(m.Up, otherM.Left), distance, extents, transforms, extentsOther, otherM))
                return false;
            if (IsSeparationAxisBoxBox(Vector3.Cross(m.Up, otherM.Up), distance, extents, transforms, extentsOther, otherM))
                return false;

            return true;
        }