Exemple #1
0
    public static List <Model3d> Query(OctreeNode node, Sphere3d sphere)
    {
        //std::vector<Model*> result;
        List <Model3d> result = new List <Model3d>();

        if (IntersectionTest3D.Sphere3dWithAABB3d(sphere, node.m_bounds))
        {
            if (node.m_children == null)
            {
                for (int i = 0, size = node.m_models.Count; i < size; ++i)
                {
                    OBB3d bounds = node.m_models[i].GetOBB();
                    if (IntersectionTest3D.Sphere3dWithObb3d(sphere, bounds))
                    {
                        result.Add(node.m_models[i]);
                    }
                }
            }
            else
            {
                for (int i = 0; i < 8; ++i)
                {
                    List <Model3d> child = Query(node.m_children[i], sphere);
                    if (child.Count > 0)
                    {
                        //result.insert(result.end(), child.begin(), child.end());
                        result.AddRange(child);
                    }
                }
            }
        }

        return(result);
    }
 public static bool IsIntersction3d(HitShape3dData hitData, OBB3d obb)
 {
     if (hitData.m_type == HitShape3dType.Sphere)
     {
         //Sphere3d hitSphere = new Sphere3d(hitData.m_pos, hitData.m_radius);
         return(IntersectionTest3D.Sphere3dWithObb3d(hitData.m_sphere, obb));
     }
     else if (hitData.m_type == HitShape3dType.OBB)
     {
         //OBB3d obb2 = new OBB3d(hitData.m_pos, hitData.m_rotation, hitData.m_size);
         return(IntersectionTest3D.OBB3dWithOBB3d(obb, hitData.m_obb));
     }
     else
     {
         return(false);
     }
 }
Exemple #3
0
    public List <Model3d> Query(Sphere3d sphere)
    {
        if (m_octree != null)
        {
            // :: lets the compiler know to look outside class scope
            return(Octree3d.Query(m_octree, sphere));
        }

        List <Model3d> result = new List <Model3d>();

        for (int i = 0, size = m_modleList.Count; i < size; ++i)
        {
            OBB3d bounds = m_modleList[i].GetOBB();
            if (IntersectionTest3D.Sphere3dWithObb3d(sphere, bounds))
            {
                result.Add(m_modleList[i]);
            }
        }
        return(result);
    }
 public static bool IsIntersction3d(HitShape3dData hitData1, HitShape3dData hitData2)
 {
     if (hitData1.m_type == HitShape3dType.Sphere && hitData2.m_type == HitShape3dType.Sphere)
     {
         return(IntersectionTest3D.Sphere3dWithSphere3d(hitData1.m_sphere, hitData2.m_sphere));
     }
     else if (hitData1.m_type == HitShape3dType.Sphere && hitData2.m_type == HitShape3dType.OBB)
     {
         return(IntersectionTest3D.Sphere3dWithObb3d(hitData1.m_sphere, hitData2.m_obb));
     }
     else if (hitData1.m_type == HitShape3dType.OBB && hitData2.m_type == HitShape3dType.Sphere)
     {
         return(IntersectionTest3D.Sphere3dWithObb3d(hitData2.m_sphere, hitData1.m_obb));
     }
     else if (hitData1.m_type == HitShape3dType.OBB && hitData2.m_type == HitShape3dType.OBB)
     {
         return(IntersectionTest3D.OBB3dWithOBB3d(hitData2.m_obb, hitData1.m_obb));
     }
     else
     {
         return(false);
     }
 }