Exemplo n.º 1
0
    private void Awake()
    {
        noiseFilters = new SimpleNoiseFilter[objectSettings.noiseLayers.Length];
        for (int i = 0; i < noiseFilters.Length; i++)
        {
            noiseFilters[i] = new SimpleNoiseFilter(objectSettings.noiseLayers[i].noiseSettings);
        }

        lastObjectSettings = JsonUtility.ToJson(objectSettings);

        GetComponent <MeshFilter>().mesh   = OctahedronSphereCreator.Create(objectSettings, noiseFilters);;
        GetComponent <Renderer>().material = m_TerrainMaterial;
        texture = new Texture2D(textureResolution, 1);
        updateColours();
        m_TerrainMaterial.SetVector("_elevationMinMax", new Vector4(objectSettings.radius, objectSettings.radius + (0.9f * objectSettings.radius / (objectSettings.radius + objectSettings.radius))));

        noiseFilters = new INoiseFilter[objectSettings.noiseLayers.Length];
        for (int i = 0; i < noiseFilters.Length; i++)
        {
            noiseFilters[i] = NoiseFilterFactory.CreateNoiseFilter(objectSettings.noiseLayers[i].noiseSettings);
        }
        lastObjectSettings = JsonUtility.ToJson(objectSettings);

        mesh = OctahedronSphereCreator.Create(objectSettings, noiseFilters);
        GetComponent <MeshFilter>().mesh = mesh;
        updateColours();
        m_TerrainMaterial.SetVector("_elevationMinMax", new Vector4(objectSettings.radius, objectSettings.radius + (0.9f * objectSettings.radius / (objectSettings.radius + objectSettings.radius))));

        GetComponent <MeshCollider>().sharedMesh = mesh;
    }
Exemplo n.º 2
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] };
    }
Exemplo n.º 3
0
 public ShapeGenerator(ShapeSettings settings)
 {
     this.settings = settings;
     noiseFilters  = new INoiseFilter[settings.noiseLayers.Length];
     for (int i = 0; i < noiseFilters.Length; i++)
     {
         noiseFilters[i] = NoiseFilterFactory.CreateNoiseFilter(settings.noiseLayers[i].noiseSettings);
     }
 }
Exemplo n.º 4
0
 public void UpdateSettings(ShapeSettings settings)
 {
     this.settings = settings;
     noiseFilters  = new INoiseFilter[(settings.noiseLayers.Length)];
     for (int i = 0; i < noiseFilters.Length; i++)
     {
         noiseFilters[i] = NoiseFilterFactory.CreateNoiseFilter(settings.noiseLayers[i].noiseSettings);
     }
 }
Exemplo n.º 5
0
 public void UpdateSettings(ColourSettings settings)
 {
     _settings = settings;
     if (_texture2D == null || _texture2D.height != settings.BiomeColourSettings.Biomes.Length)
     {
         _texture2D = new Texture2D(_textureResolution, settings.BiomeColourSettings.Biomes.Length);
     }
     biomeNoiseFilter = NoiseFilterFactory.CreateNoiseFilter(settings.BiomeColourSettings.NoiseSettings);
 }
 public void UpdateSettings(ColorSettings settings)
 {
     this.settings = settings;
     if (texture == null || texture.height != settings.biomeColorSettings.biomes.Length)
     {
         texture = new Texture2D(textureResolution * 2, settings.biomeColorSettings.biomes.Length, TextureFormat.RGBA32, false);
     }
     biomeNoiseFilter = NoiseFilterFactory.CreateNoiseFilter(settings.biomeColorSettings.noise);
 }
Exemplo n.º 7
0
 public void UpdateSettings(ShapeSettings settings)
 {
     this.settings = settings;
     noiseFilters  = new INoiseFilter[settings.noiseLayers.Length];
     for (int i = 0; i < noiseFilters.Length; i++)
     {
         noiseFilters[i] = NoiseFilterFactory.CreateNoiseFilter(settings.noiseLayers[i].settings);
     }
     elevationMinMax = new MinMax();
 }
Exemplo n.º 8
0
    public ShapeGenerator(ShapeSettings shapeSettings)
    {
        _settings     = shapeSettings;
        _noiseFilters = new INoiseFilter[_settings.noiseLayers.Length];

        for (int i = 0; i < _noiseFilters.Length; i++)
        {
            _noiseFilters[i] = NoiseFilterFactory.CreateNoiseFilter(_settings.noiseLayers[i].noiseSettings);
        }
    }
    public System.Random rand = new System.Random();  // Randomisation of planet settings

    // ********************************************************************** //

    public void UpdateSettings(ColourSettings settings, bool reset, ColourSamplingStatistics colorStats)
    {
        this.settings = reset ? RandomizeColourSettings(settings, colorStats) : settings;       // generate a new random planet
        if (texture == null || texture.height != settings.biomeColourSettings.biomes.Length)
        {
            texture = new Texture2D(textureResolution * 2, settings.biomeColourSettings.biomes.Length, TextureFormat.RGBA32, false);  // first half of this is the ocean, second half is the biomes/icy north pole etc
        }
        biomeNoiseFilter = NoiseFilterFactory.CreateNoiseFilter(settings.biomeColourSettings.noise);
        tintColor        = settings.biomeColourSettings.biomes[0].tint;
    }
Exemplo n.º 10
0
 public void UpdateSettings(ShapeSettings settings)
 {
     _settings     = settings;
     _noiseFilters = new INoiseFilter[settings.NoiseLayers.Length];
     for (int i = 0; i < _noiseFilters.Length; i++)
     {
         _noiseFilters[i] = NoiseFilterFactory.CreateNoiseFilter(settings.NoiseLayers[i].BaseNoiseSettings);
     }
     _elevationMinMax = new MinMax();
 }
Exemplo n.º 11
0
 public void UpdateSettings(ColorSettings settings)
 {
     this.settings = settings;
     if (texture == null || texture.height != settings.biomeColorSettings.biomes.Length)
     {
         //Uing first half of texture for ocean and second half for solid ground
         texture = new Texture2D(textureResolution * 2, settings.biomeColorSettings.biomes.Length, TextureFormat.RGBA32, false);
     }
     biomeNoiseFilter = NoiseFilterFactory.CreateNoiseFilter(settings.biomeColorSettings.noise);
 }
Exemplo n.º 12
0
 // Update the planet according to the current shape settings.
 public void UpdateSettings(ShapeSettings settings)
 {
     this.settings = settings;                     // Assign the current shape settings.
     noiseFilters  = new INoiseFilter[settings.noiseLayers.Length];
     for (int i = 0; i < noiseFilters.Length; i++) // Loop through all noise filters and create a noise layer of the specified type.
     {
         noiseFilters[i] = NoiseFilterFactory.CreateNoiseFilter(settings.noiseLayers[i].noiseSettings);
     }
     elevationMinMax = new MinMax();
 }
Exemplo n.º 13
0
    // ********************************************************************** //

    public void UpdateSettings(ShapeSettings settings, bool reset, ShapeSamplingStatistics shapeSampleStats)
    {
        this.settings = reset ? RandomizeShapeSettings(settings, shapeSampleStats) : settings;       // generate a new random planet
        noiseFilters  = new INoiseFilter[settings.noiseLayers.Length];

        for (int i = 0; i < noiseFilters.Length; i++)
        {
            noiseFilters[i] = NoiseFilterFactory.CreateNoiseFilter(settings.noiseLayers[i].noiseSettings);
        }
        elevationMinMax = new MinMax();
    }
Exemplo n.º 14
0
        public void UpdateSettings(WorldShapeSettings settings)
        {
            shapeSettings = settings;

            noiseFilters = new INoiseFilter[shapeSettings.NoiseLayers.Length];

            for (int i = 0; i < noiseFilters.Length; i++)
            {
                noiseFilters[i] = NoiseFilterFactory.CreateNoiseFilter(shapeSettings.NoiseLayers[i].NoiseSettings);
            }
        }
Exemplo n.º 15
0
    public void UpdateSettings(ColourSettings settings)
    {
        this.settings = settings;
        int numberOfBiomes = settings.biomeColourSettings.biomes.Length;

        if (texture == null || texture.height != numberOfBiomes)
        {
            this.texture = new Texture2D(textureResolution, numberOfBiomes);
        }
        biomeNoiseFilter = NoiseFilterFactory.CreateNoiseFilter(settings.biomeColourSettings.noise);
    }
Exemplo n.º 16
0
 public ShapeGenerator(ShapeSettings settings)
 {
     Settings        = settings;
     ElevationMinMax = new MinMax();
     settingsLayers  = settings.Layers.Where(x => x != null).ToList();
     noiseFilters    = new INoiseFilter[settingsLayers.Count];
     for (int i = 0; i < noiseFilters.Length; i++)
     {
         noiseFilters[i] = NoiseFilterFactory.CreateNoiseFilter(settingsLayers[i]);
     }
 }
    public void UpdateSettings(ColorSettings settings)
    {
        m_settings = settings;

        if (m_texture == null || m_texture.height != m_settings.m_biomeColorSettings.m_biomes.Length)
        {
            m_texture = new Texture2D(m_textureRes, m_settings.m_biomeColorSettings.m_biomes.Length);
        }

        m_biomeNoiseFilter = NoiseFilterFactory.CreateNoiseFilter(m_settings.m_biomeColorSettings.m_noise);
    }
Exemplo n.º 18
0
    public void UpdateSettings(ColorSettings colorSettings)
    {
        this.colorSettings = colorSettings;

        //the first `textureResolution` keeps data for `ocean`, the second part keeps data for `lands`
        if (texture == null || texture.height != colorSettings.biomeColorSettings.biomes.Length)
        {
            texture = new Texture2D(textureResolution * 2, colorSettings.biomeColorSettings.biomes.Length, TextureFormat.RGBA32, false);
        }

        biomeNoiseFilter = NoiseFilterFactory.CreateNoiseFilter(colorSettings.biomeColorSettings.noise);
    }
Exemplo n.º 19
0
    public void UpdateSettings(ShapeSettings _settings)
    {
        settings     = _settings;
        noiseFilters = new INoiseFilter[settings.noiseLayers.Length];

        for (int i = 0; i < noiseFilters.Length; i++)
        {
            noiseFilters[i] = NoiseFilterFactory.CreateNoiseFilter(_settings.noiseLayers[i].noiseSettings);
        }

        minMaxHeightInPlanet = new MinMaxHeightInPlanet();
    }
Exemplo n.º 20
0
    public void Initialize()
    {
        cameraController.AddPostProcessingClient(this);

        //worleyNoiseGenerator = new WorleyNoiseGenerator(worleyComputeShader);
        //cloudSettings.texture = worleyNoiseGenerator.RunShader();

        noiseFilter      = NoiseFilterFactory.CreateNoiseFilter(settings.noiseSettings);
        settings.texture = new Texture3D(40, 40, 40, TextureFormat.RGBA32, true);

        GenerateTexture();
    }
Exemplo n.º 21
0
    public void UpdateSettings(ShapeSettings settings)
    {
        shapeSettings = settings;
        noiseFilters  = new iNoiseFilter[settings.noiseLayers.Length];

        for (int i = 0; i < noiseFilters.Length; ++i)
        {
            noiseFilters[i] = NoiseFilterFactory.CreateNoiseFilter(settings.noiseLayers[i].noiseSettings);
        }

        elevationRange = new MinMax();
    }
Exemplo n.º 22
0
 // Initialize settings and apply texture if none is selected.
 public void UpdateSettings(ColorSettings settings)
 {
     this.settings = settings;
     if (texture == null || texture.height != settings.biomeColorSettings.biomes.Length)
     {
         // Height corresponds to num of biomes.
         // Store biome and ocean textures.
         texture = new Texture2D(textureResolution * 2, settings.biomeColorSettings.biomes.Length, TextureFormat.RGBA32, false);
     }
     // Initialize the noise settings of the biome.
     biomeNoisefilter = NoiseFilterFactory.CreateNoiseFilter(settings.biomeColorSettings.noise);
 }
Exemplo n.º 23
0
    public void UpdateSettings(ShapeSettings settings)
    {
        m_settings     = settings;
        m_noiseFilters = new INoiseFilter[m_settings.m_noiseLayers.Length];

        for (int i = 0; i < m_settings.m_noiseLayers.Length; i++)
        {
            m_noiseFilters[i] = NoiseFilterFactory.CreateNoiseFilter(m_settings.m_noiseLayers[i].m_noiseSettings);
        }

        m_elevationMinMax = new MinMax();
    }
Exemplo n.º 24
0
    public void UpdateSettings(ColourSettings settings)
    {
        this.settings = settings;

        if (texture == null || texture.height != settings.biomeColourSettings.biomes.Length) // update texture if null or if height not equal to nb of biomes
        {
            // first half of each texture strip is ocean texture
            texture = new Texture2D(textureResolution * 2, settings.biomeColourSettings.biomes.Length, TextureFormat.RGBA32, false); // width, height (each row stores the colour for a biome) // disable mipmapping (lowres texture version for viewing from far away)
        }

        // Initialise biome noise filter
        biomeNoiseFilter = NoiseFilterFactory.CreateNoiseFilter(settings.biomeColourSettings.noise);
    }
Exemplo n.º 25
0
    public void UpdateSettings(ShapeSettings settings)
    {
        this.settings = settings;

        // Initialize noiseFilters array of noise filters
        noiseFilters = new INoiseFilter[settings.noiseLayers.Length];

        // Populate noiseFilters array
        for (int i = 0; i < noiseFilters.Length; i++)
        {
            noiseFilters[i] = NoiseFilterFactory.CreateNoiseFilter(settings.noiseLayers[i].noiseSettings);//new SimpleNoiseFilter(settings.noiseLayers[i].noiseSettings); // new noise filter with settings
        }

        // Generate elevationMinMax
        elevationMinMax = new MinMax();
    }
Exemplo n.º 26
0
 public void UpdateSettings(ShapeSettings shapeSettings)
 {
     this.settings = shapeSettings;
     if (settings.noiseLayers != null)
     {
         simpleNoiseFilters = new iNoiseFilter[settings.noiseLayers.Length];//SimpleNoiseFilter(settings.noiseSettings);
         for (int i = 0; i < simpleNoiseFilters.Length; i++)
         {
             simpleNoiseFilters[i] = NoiseFilterFactory.CreateNoiseFilter(settings.noiseLayers[i].noiseSettings);
         }
     }
     else
     {
         Debug.Log("Error in shapeGenerator: no noiseLayers found!");
     }
     elevationMinMax = new MinMax();
 }
Exemplo n.º 27
0
    void Update()
    {
        if (lastObjectSettings != JsonUtility.ToJson(objectSettings))
        {
            noiseFilters = new INoiseFilter[objectSettings.noiseLayers.Length];
            for (int i = 0; i < noiseFilters.Length; i++)
            {
                noiseFilters[i] = NoiseFilterFactory.CreateNoiseFilter(objectSettings.noiseLayers[i].noiseSettings);
            }
            lastObjectSettings = JsonUtility.ToJson(objectSettings);

            mesh = OctahedronSphereCreator.Create(objectSettings, noiseFilters);
            GetComponent <MeshFilter>().mesh = mesh;
            updateColours();
            m_TerrainMaterial.SetVector("_elevationMinMax", new Vector4(objectSettings.radius, objectSettings.radius + (0.9f * objectSettings.radius / (objectSettings.radius + objectSettings.radius))));
            GetComponent <MeshCollider>().sharedMesh = mesh;
        }
        transform.Rotate(Vector3.up * 0.1f * rotationSpeed);
    }
Exemplo n.º 28
0
    protected virtual void OnValidate()
    {
        minMax       = new MinMax();
        vertexCount  = 0;
        noiseFilters = new INoiseFilter[noiseLayers.Length];

        for (int i = 0; i < noiseFilters.Length; i++)
        {
            noiseFilters[i] = NoiseFilterFactory.CreateNoiseFilter(noiseLayers[i].noiseSettings);
        }
        if (Application.isPlaying)
        {
            if (!builded)
            {
                BuildPlanet();
            }
        }
        else
        {
            BuildPlanet();
        }

        // base.OnValidate();
    }
Exemplo n.º 29
0
    public void Initialize()
    {
        simpleNoise      = (SimpleNoiseFilter)NoiseFilterFactory.CreateNoiseFilter(terrainSettings.noiseLayers[0].noiseSettings);
        fragmentObjPool  = new FragmentObjectPool(material, transform);
        viewerPosition   = viewer.transform.position;
        visibleFragments = new Dictionary <Vector2, TerrainFragment>();
        for (int i = 0; i < transform.childCount; i++) //destroy editor terrain fragments
        {
            Destroy(transform.GetChild(i).gameObject);
        }

        oldViewerPosition = viewer.transform.position;
        if (viewerPosition == null)
        {
            viewerPosition = viewer.transform.position;
        }

        visibleLastframeFragments = new Dictionary <Vector2, TerrainFragment>();

        setResolutionLevels();

        fragmentVisibleInViewDistance = Mathf.RoundToInt(terrainSettings.maxViewDistance / (float)terrainSettings.fragmentSize);
        GenerateFragements();
    }
    public NoiseOccupancyDescriptor(NoiseOccupancySettings settings)
    {
        this.settings = settings;

        noiseFilter3D = NoiseFilterFactory.CreateNoiseFilter(settings.noiseSettings);
    }