public void LoadMap(RawMap mapFile) { GlobalConstantVars.SunColor = mapFile.Sun_Color; GlobalConstantVars.SunDirection.X = (float)Math.Sin(mapFile.Sun_Rotation) * (float)Math.Cos(mapFile.Sun_Height); GlobalConstantVars.SunDirection.Y = (float)Math.Sin(mapFile.Sun_Height); GlobalConstantVars.SunDirection.Z = (float)Math.Cos(mapFile.Sun_Rotation) * (float)Math.Cos(mapFile.Sun_Height); GlobalConstantVars.SunDirection.Normalize(); GlobalConstantVars.AmbientColor = new Vector4(mapFile.Ambient_Color, mapFile.Ambient); ForegroundGame.Map = new TerrainInfo(); ForegroundGame.Map.width = mapFile.Width; ForegroundGame.Map.height = mapFile.Height; ForegroundGame.Map.altitudeData = new float[mapFile.Width, mapFile.Height]; for (int y = 0; y < mapFile.Height; y++) { for (int x = 0; x < mapFile.Width; x++) { float h = mapFile.Data[x + y * mapFile.Width]; ForegroundGame.Map.altitudeData[x, y] = h; if (h > ForegroundGame.Map.maxAltitude) { ForegroundGame.Map.maxAltitude = h; } } } ForegroundGame.Map.accessibilityArray = mapFile.Accessibilty_Array; GlobalConstantVars.SunColor = mapFile.Sun_Color; GlobalConstantVars.SunDirection.X = (float)Math.Sin(mapFile.Sun_Rotation) * (float)Math.Cos(mapFile.Sun_Height); GlobalConstantVars.SunDirection.Y = (float)Math.Sin(mapFile.Sun_Height); GlobalConstantVars.SunDirection.Z = (float)Math.Cos(mapFile.Sun_Rotation) * (float)Math.Cos(mapFile.Sun_Height); GlobalConstantVars.SunDirection.Normalize(); GlobalConstantVars.AmbientColor = new Vector4(mapFile.Ambient_Color, mapFile.Ambient); ForegroundGame.Map.waterColor = new Vector4(mapFile.Water_Color, mapFile.Water_Density); ForegroundGame.Map.waterLevel = mapFile.Water_Level; ForegroundGame.Map.WaterBump = Resources.GetTexture("Maps/Shared/wave"); ForegroundGame.Map.ColorMap = Resources.GetTexture("Maps/" + mapFile.MainPath + "/_colorMap.png", false); ForegroundGame.Map.TextureMap = Resources.GetTexture("Maps/" + mapFile.MainPath + "/_textureMap.png", false); ForegroundGame.Map.Shore = RageEngine.ContentPipeline.Resources.GetTexture("Maps/Shared/shore.jpg"); ForegroundGame.Map.Clouds = RageEngine.ContentPipeline.Resources.GetTexture("Maps/Shared/clouds.jpg"); string[] texturesWithNormal = new string[mapFile.Textures.Length * 2]; for (uint i = 0; i < mapFile.Textures.Length; i++) { texturesWithNormal[i * 2] = "Maps/Shared/" + mapFile.Textures[i]; texturesWithNormal[i * 2 + 1] = "Maps/Shared/" + mapFile.Textures[i] + "_bump"; } ForegroundGame.Map.TextureArray = Resources.GetTextureArray(texturesWithNormal); ForegroundGame.Map.Load(); //----------------------------- form.mapName.Text = mapFile.Name; form.mapAuthor.Text = mapFile.Author; form.mapDesc.Text = mapFile.Description; form.waterLevel.Value = (decimal)ForegroundGame.Map.waterLevel; form.waterDensity.Value = (decimal)mapFile.Water_Density * 100; form.AmbientLight.Value = (decimal)(mapFile.Ambient * 100); form.sunHeight.Value = (int)(mapFile.Sun_Height * 90 / GameUtils.PiOver2); form.sunRotation.Value = (int)(mapFile.Sun_Rotation * 180 / GameUtils.Pi); //-------------------------------------------------------------------------------------- modifiedColorMap = modifiedTextureMap = false; //-------------------------------------------------------------------------------------- Texture2DDescription descHM = new Texture2DDescription() { ArraySize = 1, BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource, CpuAccessFlags = CpuAccessFlags.None, Format = Format.R8G8B8A8_UNorm, Width = ForegroundGame.Map.width, Height = ForegroundGame.Map.height, MipLevels = 1, OptionFlags = ResourceOptionFlags.None, SampleDescription = new SampleDescription(1, 0), Usage = ResourceUsage.Default, }; drawableTexture = new Texture2D(Display.device, descHM); drawableRenderTarget = new RenderTargetView(Display.device, drawableTexture); Terrain = new EditorTerrain(ForegroundGame.Map); TerrainWater = new TerrainWater(ForegroundGame.Map); ForegroundGame.TerrainDecals = new DecalManager(ForegroundGame.Map); //------------------ ForegroundGame.TerrainDebug = new TerrainDebug(ForegroundGame.Map); SceneManager.Add(Terrain); SceneManager.Add(ForegroundGame.TerrainDebug); SceneManager.Add(ForegroundGame.TerrainDecals); SceneManager.Add(TerrainWater); camera.target = new Vector3(ForegroundGame.Map.width / 2, 0, ForegroundGame.Map.height / 2); ForegroundGame.Map.GetHeight(camera.target, ref camera.target.Y); camera.UpdatePosition(); }
public TerrainWaterDrawer(TerrainWater terrainWater) { this.terrainWater = terrainWater; }
public void PrepareTerrainWater(MissionController missionController) { TerrainWater = new TerrainWater(MainGame.GraphicsDevice, this, missionController); }