Example #1
0
    // Update is called once per frame
    void Update()
    {
        float h = Input.GetAxis("Horizontal");
        float v = Input.GetAxis("Vertical");

        if (h != 0 || v != 0)
        {
            queryCenter += new Vector3(h * 2, queryCenter.y, v * 2);
        }

        //if(Input.GetKeyDown(KeyCode.Q))
        {
            queryBound = new Bounds(queryCenter, new Vector3(30, 30, 50));

            unLoadNotInside(queryBound);


            goList = root.QueryInBounds(queryBound);

            foreach (ModelObject g in goList)
            {
                g.m_gameObject.GetComponent <MeshRenderer>().material.color = Color.red;
            }
        }

        if (Input.GetKeyDown(KeyCode.T))
        {
            foreach (ModelObject g in root.gameObjectsList)
            {
                Debug.Log(g.m_gameObject.name);
            }
        }
    }
Example #2
0
    // Use this for initialization
    void Start()
    {
        Spawns();

        root = new QctreeNode <ModelObject>(new Bounds(Vector3.zero, new Vector3(100, 100, 100)));

        foreach (ModelObject g in listGo)
        {
            root.Insert(g);
        }

        //queryCenter = new Vector3(100, 100, 100);
        queryBound = new Bounds(queryCenter, new Vector3(30, 30, 30));


        int nnn = root.QueryInBounds(queryBound).Count;

        Debug.Log("Count: " + nnn);

        listOrder = root.preOrder(root);
        Debug.Log(listOrder.Count);
    }