Exemplo n.º 1
0
        private void InitWeatherSim()
        {
            weatherSim = new WeatherSimulation(this);
            if (api.Side == EnumAppSide.Client)
            {
                cloudRenderer = new CloudRenderer(capi, weatherSim);
            }

            weatherSim.Initialize();

            if (initialWeatherFromServer != null)
            {
                OnWeatherUpdate(initialWeatherFromServer);
                initialWeatherFromServer = null;
            }

            // Pre init the clouds.
            if (api.Side == EnumAppSide.Client)
            {
                capi.Ambient.UpdateAmbient(0.1f);
                CloudRenderer renderer = this.cloudRenderer as CloudRenderer;

                renderer.blendedCloudDensity          = capi.Ambient.BlendedCloudDensity;
                renderer.blendedGlobalCloudBrightness = capi.Ambient.BlendedCloudBrightness;
                renderer.UpdateWindAndClouds(0.1f);
            }
        }
Exemplo n.º 2
0
        public CloudRenderer(ICoreClientAPI capi, WeatherSimulation weatherSim)
        {
            this.capi = capi;
            capi.Event.RegisterRenderer(this, EnumRenderStage.OIT);
            capi.Event.RegisterGameTickListener(OnGameTick, 20);

            this.weatherSim = weatherSim;

            capi.Event.ReloadShader += LoadShader;
            LoadShader();

            rand           = new Random(capi.World.Seed);
            brightnessRand = new FastPositionalRandom(rand.Next());

            double time = capi.World.Calendar.TotalHours * 60;

            windOffsetX += 2f * time;
            windOffsetZ += 0.1f * time;

            tileOffsetX += (int)(windOffsetX / CloudTileSize);
            windOffsetX %= CloudTileSize;

            tileOffsetZ += (int)(windOffsetZ / CloudTileSize);
            windOffsetZ %= CloudTileSize;


            InitCloudTiles((9 * capi.World.Player.WorldData.DesiredViewDistance));
            LoadCloudModel();


            capi.Settings.AddWatcher <int>("viewDistance", OnViewDistanceChanged);
            capi.Settings.AddWatcher <bool>("renderClouds", (val) => renderClouds = val);

            renderClouds = capi.Settings.Bool["renderClouds"];

            InitCustomDataBuffers(updateMesh);
        }