Example #1
0
    // Start is called before the first frame update
    void Start()
    {
        meshGenerator = new MeshGenerator(NoiseFilterFactory.CreateNoiseFilter(noiseSettings));
        noiseSettings.settingsUpdated += recomputeTerrain;
        for (int i = 0; i < 6; i++)
        {
            var planetSide = new TerrainQuadTree(
                transform.position,
                Mathf.Pow(2, PLANET_SIZE) * SCALE,
                directions[i],
                3.0f,
                PLANET_SIZE,
                material,
                meshGenerator
                );
            planetSide.terrain.transform.parent = transform;
            planetSide.terrain.name             = directionNames[i];
            planetSides[i] = planetSide;
        }

        planetSides[0].neighbors = new[] { planetSides[2], planetSides[4], planetSides[3], planetSides[5] };
        planetSides[1].neighbors = new[] { planetSides[3], planetSides[4], planetSides[2], planetSides[5] };
        planetSides[2].neighbors = new[] { planetSides[4], planetSides[0], planetSides[5], planetSides[1] };
        planetSides[3].neighbors = new[] { planetSides[5], planetSides[0], planetSides[4], planetSides[1] };
        planetSides[4].neighbors = new[] { planetSides[3], planetSides[0], planetSides[2], planetSides[1] };
        planetSides[5].neighbors = new[] { planetSides[2], planetSides[0], planetSides[3], planetSides[1] };
    }
    public override void OnInspectorGUI()
    {
        TerrainQuadTree terrainQuadTree = (TerrainQuadTree)target;

        DrawDefaultInspector();

        switch (terrainQuadTree.loadType)
        {
        case TerrainLoadType.LOAD:
            terrainQuadTree.filepathPrefixInEditor = EditorGUILayout.TextField("Filepath Prefix In Editor", terrainQuadTree.filepathPrefixInEditor);
            terrainQuadTree.filepathTerrainData    = EditorGUILayout.TextField("Filepath Terrain Data", terrainQuadTree.filepathTerrainData);
            terrainQuadTree.mapFolderName          = EditorGUILayout.TextField("Map Folder Name", terrainQuadTree.mapFolderName);
            break;

        case TerrainLoadType.GENERATE:
            terrainQuadTree.filepathPrefixInEditor = EditorGUILayout.TextField("Filepath Prefix In Editor", terrainQuadTree.filepathPrefixInEditor);
            terrainQuadTree.filepathTerrainData    = EditorGUILayout.TextField("Filepath Terrain Data", terrainQuadTree.filepathTerrainData);
            if (GUILayout.Button("Generate"))
            {
                terrainQuadTree.BuildTree();
            }
            break;

        default:
            break;
        }
    }
Example #3
0
    private void OnDestroy()
    {
        if (quadTree != null)
        {
            quadTree.Release();
            quadTree = null;
        }

        if (perlin != null)
        {
            perlin.Release();
            perlin = null;
        }

        if (meshTerrain != null)
        {
            meshTerrain.Clear();
            meshTerrain = null;
        }

        if (argBuffer != null)
        {
            argBuffer.Release();
            argBuffer.Dispose();
            argBuffer = null;
        }

        renderPatchesBuffer = null;
    }
Example #4
0
 private void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
     else
     {
         Destroy(gameObject);
     }
 }
Example #5
0
    // Start is called before the first frame update
    void Start()
    {
        LodMeshCreator.Generate(Setting.QuadTree.LodMeshStep, Setting.QuadTree.LodMeshRadius, out meshTerrain, out argBuffer);

        quadTree = new TerrainQuadTree(Setting.QuadTree);
        quadTree.Initialize();

        perlin = new PerlinNoise(Setting.Noise);
        perlin.Initialize();

        renderPatchesBuffer = null;

        setQuadTreeTraverDisable(false);

        setTurbulenceType(Setting.Noise.type);
    }