void Awake()
    {
        visibleStars       = new List <OctreeObject[]>();
        highDetailStarPool = new PoolManager(highDetailStar, 1000);

        //Reading from file and formating for octree
        StarListToVoxels myVoxelsStringFormat = new StarListToVoxels();

        OctreeObject[] voxels = myVoxelsStringFormat.readData();

        print("Stars parsed from dataset: " + voxels.Length);

        //Initializing root
        Octree = new OctreeDataStructure(voxels);
        timer.Start();
        Octree.init();
        timer.Stop();

        print("Tree built: " + timer.ElapsedMilliseconds);
        print("---------------------------------------");

        if (Octree != null)
        {
            treeFinished = true;
        }

        //Getting secondary camera
        GameObject secondaryObject = GameObject.Find("SecondaryCamera");

        secondaryCamera = secondaryObject.GetComponent <Camera>();

        pointAlreadyPassed = new List <Vector3>();
    }
Exemplo n.º 2
0
    void unitTestOctreePutandGet()
    {
        OctreeObject[] randomStars = new OctreeObject[(int)(max - min)];
        Bounds         testBounds  = new Bounds();

        GameObject testCamera = GameObject.Find("testCamera");
        Camera     test       = testCamera.GetComponent <Camera>();

        List <OctreeObject[]> myList = new List <OctreeObject[]>();

        testBounds.SetMinMax(minV, maxV);

        for (int i = 0; i < randomStars.Length; i++)
        {
            randomStars[i] = new OctreeObject(new Vector3((float)rnd(min, max), (float)rnd(min, max), (float)rnd(min, max)), 1.0f, 1.0f);
        }

        //Expected 0 and 1 due to camera(near=0.3,far=3);
        //for (int i = 0; i < randomStars.Length; i++)
        //{
        //    randomStars[i] = new OctreeObject(new Vector3(i, i, i),1.0f,1.0f);
        //}

        OctreeDataStructure octree = new OctreeDataStructure(testBounds, randomStars);

        b = octree.divideAABB(testBounds);

        octree.init();
        octree.frustumCulling(myList, GeometryUtility.CalculateFrustumPlanes(test));

        foreach (OctreeObject[] oo in myList)
        {
            foreach (OctreeObject o in oo)
            {
                print("X:" + o.spatialPosition.x + " Y:" + o.spatialPosition.y + " Z:" + o.spatialPosition.z);
            }
        }
    }