• 大小: 25KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-06-06
  • 语言: 其他
  • 标签: 八叉树  

资源简介

八叉树Demo - Unity下 , 基于四叉树的修改 https://blog.csdn.net/u010019717/article/details/80789271

资源截图

代码片段和文件信息

using UnityEngine;

public class Main : MonoBehaviour
{
    Octree octTree;

    void Start()
    {
        var areaCenter = new Vector3(0 0 0);
        float width = 10;
        float height = 10;
        float depth = 10;

        Cube boundary = new Cube(areaCenter.x areaCenter.y areaCenter.z width / 2 height / 2 depth / 2);

        int capacity = 4;
        octTree = new Octree(boundary capacity);
    }

    void Update()
    {
        // show current octree
        octTree.DrawDebug();

        // press mouse to insert random point
        if (Input.GetMouseButtonDown(0))
        {
            var b = octTree.boundary;
            var pos = new Vector3(Random.Range(b.centerX - b.width b.centerX + b.width) Random.Range(b.centerY - b.height b.centerY + b.height) Random.Range(b.centerZ - b.depth b.centerZ + b.depth));
            var p = new Point(pos.x pos.y pos.z);
            octTree.Insert(p);
        }
    }

}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     文件       21638  2018-06-24 12:03  Assembly-CSharp.csproj
     目录           0  2018-06-24 12:00  Assets\
     文件         213  2018-05-18 00:56  Assets\Scenes.meta
     目录           0  2018-06-24 12:00  Assets\Scenes\
     文件        6260  2018-05-18 00:56  Assets\Scenes\Octree.unity
     文件         196  2018-05-18 00:56  Assets\Scenes\Octree.unity.meta
     文件         213  2018-05-18 00:56  Assets\scripts.meta
     目录           0  2018-06-24 12:04  Assets\scripts\
     文件         951  2018-06-24 12:04  Assets\scripts\Main.cs
     文件         284  2018-05-18 00:56  Assets\scripts\Main.cs.meta
     文件         213  2018-05-18 00:56  Assets\scripts\Octree.meta
     目录           0  2018-06-24 12:00  Assets\scripts\Octree\
     文件         686  2018-05-18 00:56  Assets\scripts\Octree\Cube.cs
     文件         284  2018-05-18 00:56  Assets\scripts\Octree\Cube.cs.meta
     文件        6791  2018-05-18 00:56  Assets\scripts\Octree\Octree.cs
     文件         284  2018-05-18 00:56  Assets\scripts\Octree\Octree.cs.meta
     文件         392  2018-05-18 00:56  Assets\scripts\Octree\Point.cs
     文件         284  2018-05-18 00:56  Assets\scripts\Octree\Point.cs.meta
     文件         915  2018-06-24 12:03  Octree-master.sln
     目录           0  2018-06-24 12:01  ProjectSettings\
     文件         357  2018-05-18 00:56  ProjectSettings\AudioManager.asset
     文件         114  2018-05-18 00:56  ProjectSettings\ClusterInputManager.asset
     文件        1044  2018-05-18 00:56  ProjectSettings\DynamicsManager.asset
     文件         138  2018-05-18 00:56  ProjectSettings\EditorBuildSettings.asset
     文件         633  2018-05-18 00:56  ProjectSettings\EditorSettings.asset
     文件        2152  2018-05-18 00:56  ProjectSettings\GraphicsSettings.asset
     文件        5793  2018-05-18 00:56  ProjectSettings\InputManager.asset
     文件        1308  2018-05-18 00:56  ProjectSettings\NavMeshAreas.asset
     文件         151  2018-05-18 00:56  ProjectSettings\NetworkManager.asset
     文件        1400  2018-05-18 00:56  ProjectSettings\Physics2DSettings.asset
     文件         120  2018-06-24 12:01  ProjectSettings\PresetManager.asset
............此处省略7个文件信息

评论

共有 条评论