Exemplo n.º 1
0
    public OctTree <TriangleBound> ConstructSceneOctree(List <TriangleInfo> sceneTriangles, Bounds bound)
    {
        int          count    = 0;
        AABBBoundBox maxBound = new AABBBoundBox(bound);

        _octree = new OctTree <TriangleBound>(maxBound);
        List <TriangleInfo> triangleList = new List <TriangleInfo>(triangleCountInOneGroup);

        foreach (TriangleInfo tri in sceneTriangles)
        {
            triangleList.Add(tri);
            if (triangleList.Count == triangleCountInOneGroup)
            {
                TriangleBound triangleBound = GroupBoundBox(triangleList);

                //boundList.Add(triangleBound);
                if (maxBound.Contains(triangleBound.GetBoundBox()) || maxBound.Overlap(triangleBound.boundBox))
                {
                    _octree.Insert(triangleBound);
                    count++;
                }
                triangleList.Clear();
            }
        }
        if (triangleList.Count != 0)
        {
            _octree.Insert(GroupBoundBox(triangleList));
            count++;
        }

        Debug.Log(count);
        _octree.UpdateTree();
        return(_octree);
    }
Exemplo n.º 2
0
 public void Voxelize()
 {
     octree = new OctTree <VoxelBound>(new AABBBoundBox(voxelBoundBox.bounds));
     InitVoxelArray();
     foreach (VoxelBound tBound in _voxelArray)
     {
         octree.Insert(tBound);
     }
     octree.UpdateTree();
     InitTriangleInfoDic();
     IntersectTest();
 }
Exemplo n.º 3
0
 private void OctTreeMethod()
 {
     if (Animated)
     {
         OT.UpdateTree(mPointList);
     }
     for (int i = 0; i < PointNum; i++)
     {
         mLineList[i].SetPosition(0, mPointList[i].position);
         mLineList[i].SetPosition(1, OT.FindCloset(mPointList[i]).position);
     }
 }
Exemplo n.º 4
0
    public void CreateOctree()
    {
        octree = new OctTree <BoxObject>(new AABBBoundBox(-5000f * Vector3.one, 5000f * Vector3.one));
        for (int i = 0; i < collisionObjects.Count; i++)
        {
            octree.Insert(collisionObjects[i]);
        }
        octree.UpdateTree();
        int d = octree.GetMaxTreeDepth();

        Debug.Log(d + " " + Mathf.Pow(8, d) / (d - 1));
    }
    // Update is called once per frame
    void Update()
    {
        /*
         * foreach(var point in m_pointCloud.DataPoints)
         * {
         *  point.Position = new Vector3(Random.Range(-25.0f, 25.0f), Random.Range(-25.0f, 25.0f), Random.Range(-25.0f, 25.0f));
         * }
         */

        Profiler.BeginSample("update octtree");
        if (m_pointCloud != null)
        {
            m_octTree.UpdateTree(m_pointCloud);
        }
        Profiler.EndSample();
    }
Exemplo n.º 6
0
 public void RestartOctTree()
 {
     //count = 0;
     if (build)
     {
         octTree      = new OctTree(uBounds, tmp, narrowPhase, minSize);
         octTree.name = "root";
         octTree.BuildTree();
         //octTree.toString ("");
         octTree.GetCollisions();
     }
     else
     {
         //octTree.toString("");
         octTree.UpdateTree();
         //octTree.toString("");
         octTree.GetCollisions();
     }
 }