public override void Initialize() { base.Initialize(); // Finally a terrain var terrainMaterial = new StandardTerrainMaterial(); terrainMaterial.MainTexture = Application.Content.Load <Texture2D>("Textures/Terrain/Grass"); terrainMaterial.SandTexture = Application.Content.Load <Texture2D>("Textures/Terrain/Sand"); terrainMaterial.SnowTexture = Application.Content.Load <Texture2D>("Textures/Terrain/Snow"); terrainMaterial.RockTexture = Application.Content.Load <Texture2D>("Textures/Terrain/Rock"); var terrainGo = GameObjectFactory.CreateTerrain(); _terrain = terrainGo.GetComponent <Terrain>(); _terrain.Randomize(4, 12); _terrain.Renderer.Material = terrainMaterial; Add(terrainGo); _terrain.SetWeightData(0.5f, 4, 15, 30); terrainMaterial.WeightTexture = _terrain.GenerateWeightMap(); terrainMaterial.Tiling = new Vector2(4); SetupScene(); _camera.AddComponent <Scripts.VRPlayerEnabler>(); }
public override void Start() { var renderer = GetComponent <MeshRenderer>(); if (renderer == null) { throw new Exception("You need to attach a mesh renderer first."); } var mat = renderer.Material as StandardTerrainMaterial; _material = mat ?? throw new Exception("You need to use a TerrainMaterial with a non null weightMap."); _rect = new Rectangle(0, Screen.VirtualHeight - 200, 150, 150); }
public override void Initialize() { base.Initialize(); var content = Application.Content; _directionalLight.AddComponent <LightMover>(); _directionalLight.AddComponent <LightSwitcher>().SetBoxAlign(true); // Finally a terrain var terrainMaterial = new StandardTerrainMaterial(); terrainMaterial.MainTexture = content.Load <Texture2D>("Textures/Terrain/Grass"); terrainMaterial.SandTexture = content.Load <Texture2D>("Textures/Terrain/Sand"); terrainMaterial.SnowTexture = content.Load <Texture2D>("Textures/Terrain/Snow"); terrainMaterial.RockTexture = content.Load <Texture2D>("Textures/Terrain/Rock"); var terrainGo = GameObjectFactory.CreateTerrain(); _scene.Add(terrainGo); var terrain = terrainGo.GetComponent <Terrain>(); terrain.LoadHeightmap("Textures/heightmap"); terrain.Renderer.Material = terrainMaterial; var weightMap = terrain.GenerateWeightMap(); terrainMaterial.WeightTexture = weightMap; terrainMaterial.Tiling = new Vector2(4); terrainGo.AddComponent <WeightMapViewer>(); // With water ! var waterTexture = content.Load <Texture2D>("Textures/Fluids/water"); var bumpTexture = content.Load <Texture2D>("Textures/Fluids/wavesbump"); var water = GameObjectFactory.CreateWater(waterTexture, bumpTexture, new Vector3(terrain.Width * 0.5f)); water.Transform.Translate(0, 10.0f, 0); _scene.Add(water); // And fog RenderSettings.FogDensity = 0.0085f; RenderSettings.FogMode = FogMode.None; RenderSettings.Skybox.FogSupported = true; RenderSettings.Skybox.OverrideSkyboxFog(FogMode.Exp2, 0.05f, 0, 0); var vrPlayerEnabler = _camera.AddComponent <VRPlayerEnabler>(); vrPlayerEnabler.Position = new Vector3(0, water.Transform.Position.Y + 0.5f, 0); }
public override void Initialize() { base.Initialize(); // And a camera with some components var cameraGo = GameObjectFactory.CreateCamera(); cameraGo.AddComponent <ControllerSwitcher>(); cameraGo.AddComponent <DemoBehaviour>(); Add(cameraGo); // A light is required to illuminate objects. var lightGo = GameObjectFactory.CreateLight(LightType.Directional); lightGo.Transform.LocalRotation = new Vector3(-1, 1, 0); Add(lightGo); // Finally a terrain var terrainMaterial = new StandardTerrainMaterial(m_Scene); terrainMaterial.MainTexture = Application.Content.Load <Texture2D>("Textures/Terrain/Grass"); terrainMaterial.SandTexture = Application.Content.Load <Texture2D>("Textures/Terrain/Sand"); terrainMaterial.SnowTexture = Application.Content.Load <Texture2D>("Textures/Terrain/Snow"); terrainMaterial.RockTexture = Application.Content.Load <Texture2D>("Textures/Terrain/Rock"); var terrainGo = GameObjectFactory.CreateTerrain(); m_Terrain = terrainGo.GetComponent <Terrain>(); m_Terrain.Randomize(4, 12); m_Terrain.Renderer.Material = terrainMaterial; Add(terrainGo); m_Terrain.SetWeightData(0.5f, 4, 15, 30); terrainMaterial.WeightTexture = m_Terrain.GenerateWeightMap(); terrainMaterial.Tiling = new Vector2(4); // Sun Flares var content = Application.Content; var glowTexture = content.Load <Texture2D>("Textures/Flares/glow"); var flareTextures = new Texture2D[] { content.Load <Texture2D>("Textures/Flares/flare1"), content.Load <Texture2D>("Textures/Flares/flare2"), content.Load <Texture2D>("Textures/Flares/flare3") }; var direction = lightGo.Transform.LocalRotation; direction.Normalize(); var sunflares = cameraGo.AddComponent <LensFlare>(); sunflares.LightDirection = direction; sunflares.Setup(glowTexture, flareTextures); SetupScene(); // Skybox RenderSettings.Skybox.Generate(Application.GraphicsDevice, Application.Content, DemoGame.BlueSkybox); }
public DeferredStandardTerrain(StandardTerrainMaterial material) : base(material) { }
public override void Initialize() { base.Initialize(); var content = Application.Content; // Add a camera with a FPS controller var cameraGo = GameObjectFactory.CreateCamera(new Vector3(0, 2, -10), new Vector3(0, 0, 0), Vector3.Up); cameraGo.AddComponent <ControllerSwitcher>(); Add(cameraGo); // And a light var lightGo = GameObjectFactory.CreateLight(LightType.Directional, Color.White, 1f); lightGo.Transform.LocalPosition = new Vector3(250, 500, 100); lightGo.Transform.LocalRotation = new Vector3(1, 0.5f, 0); lightGo.AddComponent <DemoBehaviour>(); lightGo.AddComponent <LightMover>(); lightGo.AddComponent <LightSwitcher>().LogPositionRotation = false; lightGo.GetComponent <Light>().ShadowGenerator.ShadowStrength = 0.5f; Add(lightGo); // Finally a terrain var terrainMaterial = new StandardTerrainMaterial(m_Scene); terrainMaterial.MainTexture = content.Load <Texture2D>("Textures/Terrain/Grass"); terrainMaterial.SandTexture = content.Load <Texture2D>("Textures/Terrain/Sand"); terrainMaterial.SnowTexture = content.Load <Texture2D>("Textures/Terrain/Snow"); terrainMaterial.RockTexture = content.Load <Texture2D>("Textures/Terrain/Rock"); var terrainGo = GameObjectFactory.CreateTerrain(); m_Scene.Add(terrainGo); var terrain = terrainGo.GetComponent <Terrain>(); terrain.LoadHeightmap("Textures/heightmap"); terrain.Renderer.Material = terrainMaterial; var weightMap = terrain.GenerateWeightMap(); terrainMaterial.WeightTexture = weightMap; terrainMaterial.Tiling = new Vector2(4); terrainGo.AddComponent <WeightMapViewer>(); // With water ! var waterTexture = content.Load <Texture2D>("Textures/water"); var bumpTexture = content.Load <Texture2D>("Textures/wavesbump"); var water = GameObjectFactory.CreateWater(waterTexture, bumpTexture, new Vector3(terrain.Width * 0.5f)); water.Transform.Translate(0, 10.0f, 0); m_Scene.Add(water); // Sun Flares var glowTexture = content.Load <Texture2D>("Textures/Flares/glow"); var flareTextures = new Texture2D[] { content.Load <Texture2D>("Textures/Flares/flare1"), content.Load <Texture2D>("Textures/Flares/flare2"), content.Load <Texture2D>("Textures/Flares/flare3") }; var direction = lightGo.Transform.LocalRotation; direction.Normalize(); var sunflares = cameraGo.AddComponent <LensFlare>(); sunflares.LightDirection = direction; sunflares.Setup(glowTexture, flareTextures); Screen.ShowCursor = true; // Don't miss the Skybox ;) RenderSettings.Skybox.Generate(Application.GraphicsDevice, Application.Content, DemoGame.BlueSkybox); RenderSettings.AmbientColor = Color.Black; // And fog RenderSettings.FogDensity = 0.0085f; RenderSettings.FogMode = FogMode.Exp2; RenderSettings.Skybox.FogSupported = true; RenderSettings.Skybox.OverrideSkyboxFog(FogMode.Exp2, 0.05f, 0, 0); }
public LPPStandardTerrain(StandardTerrainMaterial material) { m_Material = material; }
public ForwardStandardTerrain(StandardTerrainMaterial material) { m_Material = material; }