protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager) { base.LoadContent(GraphicInfo, factory, contentManager); ///Create the Terrain Object ///Controls how the heigh map is loaded TerrainObject to = new TerrainObject(factory, "..\\Content\\Textures\\Untitled", Vector3.Zero, Matrix.Identity, MaterialDescription.DefaultBepuMaterial(), 1, 1,10); ///Create the Model using the Terrain Object. Here we pass the textures used, in our case we are using MultiTextured Terrain so we pass lots of textures TerrainModel stm = new TerrainModel(factory, to, "TerrainName", "..\\Content\\Textures\\Terraingrass"); stm.SetTexture(factory.CreateTexture2DColor(1,1,Color.Green), TextureType.DIFFUSE); ///Create the shader ///In this sample we passed lots of textures, each one describe a level in the terrain, the ground is the sand and grass. the hills are rocks and the "mountains" are snow ///They are interpolated in the shader, you can control how using the shader parameters exposed in the DeferredTerrainShader ForwardXNABasicShader shader = new ForwardXNABasicShader(); ///Deferred material ForwardMaterial fmaterial = new ForwardMaterial(shader); ///The object itself IObject obj = new IObject(fmaterial, stm, to); ///Add to the world this.World.AddObject(obj); shader.BasicEffect.EnableDefaultLighting(); CameraFirstPerson cam = new CameraFirstPerson(GraphicInfo.Viewport); this.World.CameraManager.AddCamera(cam); }
void createterrain(int height = 5) { ///Create the Terrain Object ///Controls how the heigh map is loaded TerrainObject to = new TerrainObject(GraphicFactory, "..\\Content\\Textures\\hmap", new Vector3(0, -30, 0), Matrix.Identity, MaterialDescription.DefaultBepuMaterial(), 3, 3, height); ///Create the Model using the Terrain Object. Here we pass the textures used TerrainModel stm = new TerrainModel(GraphicFactory, to, "TerrainName", "..\\Content\\Textures\\Terraingrass"); stm.SetTexture("..\\Content\\Textures\\Terraingrass", TextureType.DIFFUSE); ForwardXNABasicShader shader = new ForwardXNABasicShader(); ForwardMaterial fmaterial = new ForwardMaterial(shader); ///The object itself obj = new IObject(fmaterial, stm, to); ///Add to the world this.World.AddObject(obj); ///light =p shader.BasicEffect.EnableDefaultLighting(); shader.BasicEffect.SpecularPower = 250; shader.BasicEffect.PreferPerPixelLighting = true; //Fog =P shader.BasicEffect.FogEnabled = true; shader.BasicEffect.FogColor = new Vector3(0.1f, 0.1f, 0.1f); // Dark grey shader.BasicEffect.FogStart = 30; shader.BasicEffect.FogEnd = 300; }
protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory ,IContentManager contentManager) { base.LoadContent(GraphicInfo,factory, contentManager); Picking picking = new Picking(this); this.AddScreenUpdateable(picking); perlim = factory.CreateTexture2DPerlinNoise(512, 512, 0.03f, 3f, 0.5f, 1); to = new TerrainObject(factory,perlim, Vector3.Zero, Matrix.Identity, MaterialDescription.DefaultBepuMaterial(), 2, 2); //TerrainObject to = new TerrainObject(factory,"..\\Content\\Textures\\Untitled",Vector3.Zero,Matrix.Identity,MaterialDescription.DefaultBepuMaterial(),2,1); TerrainModel stm = new TerrainModel(factory, to,"TerrainName","..\\Content\\Textures\\Terraingrass", "..\\Content\\Textures\\rock", "..\\Content\\Textures\\sand", "..\\Content\\Textures\\snow"); DeferredTerrainShader shader = new DeferredTerrainShader(TerrainType.MULTITEXTURE); DeferredMaterial mat = new DeferredMaterial(shader); IObject obj3 = new IObject(mat, stm, to); this.World.AddObject(obj3); #region NormalLight DirectionalLightPE ld1 = new DirectionalLightPE(Vector3.Left, Color.White); DirectionalLightPE ld2 = new DirectionalLightPE(Vector3.Right, Color.White); DirectionalLightPE ld3 = new DirectionalLightPE(Vector3.Backward, Color.White); DirectionalLightPE ld4 = new DirectionalLightPE(Vector3.Forward, Color.White); DirectionalLightPE ld5 = new DirectionalLightPE(Vector3.Down, Color.White); float li = 0.5f; ld1.LightIntensity = li; ld2.LightIntensity = li; ld3.LightIntensity = li; ld4.LightIntensity = li; ld5.LightIntensity = li; this.World.AddLight(ld1); this.World.AddLight(ld2); this.World.AddLight(ld3); this.World.AddLight(ld4); this.World.AddLight(ld5); #endregion this.World.CameraManager.AddCamera(new CameraFirstPerson(true,GraphicInfo)); SkyBoxSetTextureCube stc = new SkyBoxSetTextureCube("Textures//cubemap"); CommandProcessor.getCommandProcessor().SendCommandAssyncronous(stc); ///O PICKING FUNCIONA APENAS COM OBJETOS QUE TENHAM CORPO FISICO REAL !!! ///OS GHOST E OS DUMMY NUNCA SERAO SELECIONADOS ///Para ser informado a todo frame sobre as colisoes do raio, basta utilizar o outro construtor picking.OnPickedLeftButton += new OnPicked(onPick); }
protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory ,IContentManager contentManager) { base.LoadContent(GraphicInfo,factory, contentManager); ///Create the Terrain Object ///Controls how the heigh map is loaded TerrainObject to = new TerrainObject(factory,"..\\Content\\Textures\\Untitled",Vector3.Zero,Matrix.Identity,MaterialDescription.DefaultBepuMaterial(),2,1); ///Create the Model using the Terrain Object. Here we pass the textures used, in our case we are using MultiTextured Terrain so we pass lots of textures TerrainModel stm = new TerrainModel(factory, to,"TerrainName","..\\Content\\Textures\\Terraingrass", "..\\Content\\Textures\\rock", "..\\Content\\Textures\\sand", "..\\Content\\Textures\\snow"); ///Create the shader ///In this sample we passed lots of textures, each one describe a level in the terrain, the ground is the sand and grass. the hills are rocks and the "mountains" are snow ///They are interpolated in the shader, you can control how using the shader parameters exposed in the DeferredTerrainShader DeferredTerrainShader shader = new DeferredTerrainShader(TerrainType.MULTITEXTURE); ///the classic material DeferredMaterial mat = new DeferredMaterial(shader); IObject obj3 = new IObject(mat, stm, to); this.World.AddObject(obj3); lt = new LightThrowBepu(this.World, factory); #region NormalLight DirectionalLightPE ld1 = new DirectionalLightPE(Vector3.Left, Color.White); DirectionalLightPE ld2 = new DirectionalLightPE(Vector3.Right, Color.White); DirectionalLightPE ld3 = new DirectionalLightPE(Vector3.Backward, Color.White); DirectionalLightPE ld4 = new DirectionalLightPE(Vector3.Forward, Color.White); DirectionalLightPE ld5 = new DirectionalLightPE(Vector3.Down, Color.White); float li = 0.5f; ld1.LightIntensity = li; ld2.LightIntensity = li; ld3.LightIntensity = li; ld4.LightIntensity = li; ld5.LightIntensity = li; this.World.AddLight(ld1); this.World.AddLight(ld2); this.World.AddLight(ld3); this.World.AddLight(ld4); this.World.AddLight(ld5); #endregion CameraFirstPerson cam = new CameraFirstPerson(MathHelper.ToRadians(30), MathHelper.ToRadians(-10), new Vector3(200, 150, 250), GraphicInfo); this.World.CameraManager.AddCamera(cam); SkyBoxSetTextureCube stc = new SkyBoxSetTextureCube("Textures//grassCube"); CommandProcessor.getCommandProcessor().SendCommandAssyncronous(stc); this.RenderTechnic.AddPostEffect(new AntiAliasingPostEffectStalker()); }
protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory ,IContentManager contentManager) { base.LoadContent(GraphicInfo,factory, contentManager); TerrainObject to = new TerrainObject(factory,"..\\Content\\Textures\\Untitled",Vector3.Zero,Matrix.Identity,MaterialDescription.DefaultBepuMaterial(),2,1); TerrainModel stm = new TerrainModel(factory, to,"TerrainName","..\\Content\\Textures\\Terraingrass", "..\\Content\\Textures\\rock", "..\\Content\\Textures\\sand", "..\\Content\\Textures\\snow"); DeferredTerrainShader shader = new DeferredTerrainShader(TerrainType.MULTITEXTURE); DeferredMaterial mat = new DeferredMaterial(shader); IObject obj3 = new IObject(mat, stm, to); this.World.AddObject(obj3); LightThrowBepu lt = new LightThrowBepu(this.World, factory); #region NormalLight DirectionalLightPE ld1 = new DirectionalLightPE(Vector3.Left, Color.White); DirectionalLightPE ld2 = new DirectionalLightPE(Vector3.Right, Color.White); DirectionalLightPE ld3 = new DirectionalLightPE(Vector3.Backward, Color.White); DirectionalLightPE ld4 = new DirectionalLightPE(Vector3.Forward, Color.White); DirectionalLightPE ld5 = new DirectionalLightPE(Vector3.Down, Color.White); float li = 0.5f; ld1.LightIntensity = li; ld2.LightIntensity = li; ld3.LightIntensity = li; ld4.LightIntensity = li; ld5.LightIntensity = li; this.World.AddLight(ld1); this.World.AddLight(ld2); this.World.AddLight(ld3); this.World.AddLight(ld4); this.World.AddLight(ld5); #endregion this.World.CameraManager.AddCamera(new CameraFirstPerson(true,GraphicInfo)); SkyBoxSetTextureCube stc = new SkyBoxSetTextureCube("Textures//cubemap"); CommandProcessor.getCommandProcessor().SendCommandAssyncronous(stc); }