Exemplo n.º 1
0
 public World(Viewer viewer)
 {
     Viewer = viewer;
     PerformanceInitialViewingDistance = Viewer.Settings.ViewingDistance;
     PerformanceInitialLODBias         = Viewer.Settings.LODBias;
     // Control stuff first.
     WeatherControl = new WeatherControl(viewer);
     // Then drawers.
     if (viewer.Settings.UseMSTSEnv)
     {
         MSTSSky = new MSTSSkyDrawer(viewer);
     }
     else
     {
         Sky = new SkyViewer(viewer);
     }
     Precipitation = new PrecipitationViewer(viewer, WeatherControl);
     Terrain       = new TerrainViewer(viewer);
     Scenery       = new SceneryDrawer(viewer);
     Trains        = new TrainDrawer(viewer);
     RoadCars      = new RoadCarViewer(viewer);
     // Then sound.
     if (viewer.Settings.SoundDetailLevel > 0)
     {
         // Keep it silent while loading.
         ALSoundSource.MuteAll();
         // TODO: This looks kinda evil; do something about it.
         GameSounds = new SoundSource(viewer, Events.Source.MSTSInGame, viewer.Simulator.RoutePath + "\\Sound\\ingame.sms", true);
         Viewer.SoundProcess.AddSoundSources(GameSounds.SMSFolder + "\\" + GameSounds.SMSFileName, new List <SoundSourceBase>()
         {
             GameSounds
         });
         Sounds = new WorldSounds(viewer);
     }
 }
Exemplo n.º 2
0
            public float GetHeight(WorldLocation location, TileManager tiles, SceneryDrawer scenery)
            {
                location.Normalize();

                // First, ensure we have the tile in question cached.
                var tile = Tiles.FirstOrDefault(t => t.TileX == location.TileX && t.TileZ == location.TileZ);

                if (tile == null)
                {
                    Tiles.Add(tile = new Tile(location.TileX, location.TileZ, Divisions));
                }

                // Remove excess entries.
                if (Tiles.Count > TileCount)
                {
                    Tiles.RemoveAt(0);
                }

                // Now calculate division to query.
                var x = (int)((location.Location.X + 1024) / BlockSize);
                var z = (int)((location.Location.Z + 1024) / BlockSize);

                // If we don't have it cached, load it.
                if (tile.Height[x, z] == float.MinValue)
                {
                    var position = new WorldLocation(location.TileX, location.TileZ, (x + 0.5f) * BlockSize - 1024, 0, (z + 0.5f) * BlockSize - 1024);
                    tile.Height[x, z] = Math.Max(tiles.GetElevation(position), scenery.GetBoundingBoxTop(position, BlockSize));
                    tile.Used++;
                }

                return(tile.Height[x, z]);
            }