/// <summary> /// Load content for the screen. /// </summary> /// <param name="GraphicInfo"></param> /// <param name="factory"></param> /// <param name="contentManager"></param> protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager) { base.LoadContent(GraphicInfo, factory, contentManager); { for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { float x, y; x = -i * 100; y = -j * 100; TreeModel tm = new TreeModel(factory, "Trees\\Pine", null, null); ForwardTreeShader ts = new ForwardTreeShader(); TreeMaterial tmat = new TreeMaterial(ts, new WindStrengthSin()); GhostObject go = new GhostObject(new Vector3(x, 0, y), Matrix.Identity, new Vector3(0.05f)); IObject ox = new IObject(tmat, tm, go); this.World.AddObject(ox); } } } ///add a camera this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo)); }
/// <summary> /// Load content for the screen. /// </summary> /// <param name="GraphicInfo"></param> /// <param name="factory"></param> /// <param name="contentManager"></param> protected override void LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, IContentManager contentManager) { ///must be called before all base.LoadContent(GraphicInfo, factory, contentManager); { for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { float x, y; x = -i * 100; y = -j * 100; TreeModel tm = new TreeModel(factory, "Trees\\Pine", null, null); DeferredTreeShader ts = new DeferredTreeShader(); TreeMaterial tmat = new TreeMaterial(ts, new WindStrengthSin()); GhostObject go = new GhostObject(new Vector3(x, 0, y), Matrix.Identity, new Vector3(0.05f)); IObject ox = new IObject(tmat, tm, go); this.World.AddObject(ox); } } } ///Add some directional lights to completely iluminate the world #region Lights 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.4f; 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 ///Add a AA post effect this.RenderTechnic.AddPostEffect(new AntiAliasingPostEffect()); ///add a camera this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo)); }
private Material SetupTreeMaterial(String baseMaterialName, String texture1, String texture2, String texture3, TreeMaterial treeMaterial, bool setupGPUParams, int tech ) { Material baseMaterial = MaterialManager.Instance.GetByName(baseMaterialName); String newMatName = String.Format("{0}/{1}", baseMaterialName, treeNum++); Material material = baseMaterial.Clone(newMatName); if ( setupGPUParams ) { // material lighting properties material.GetTechnique(tech).GetPass(0).VertexProgramParameters.SetNamedConstant( "g_vMaterialDiffuse", SpeedTreeUtil.FromSpeedTree(treeMaterial.Diffuse)); material.GetTechnique(tech).GetPass(0).VertexProgramParameters.SetNamedConstant( "g_vMaterialAmbient", SpeedTreeUtil.FromSpeedTree(treeMaterial.Ambient)); } material.GetTechnique(tech).GetPass(0).GetTextureUnitState(0).SetTextureName(ConvertTextureName(texture1)); if (texture2 != null) { // deal with lack of shadow map if (texture2 == "") { texture2 = "White.dds"; } // self shadow map material.GetTechnique(tech).GetPass(0).GetTextureUnitState(1).SetTextureName(ConvertTextureName(texture2)); if ((texture3 != null) && normalMapped) { // normal map material.GetTechnique(tech).GetPass(0).GetTextureUnitState(2).SetTextureName(ConvertTextureName(texture3)); // material lighting properties for normal mapping material.GetTechnique(tech).GetPass(0).FragmentProgramParameters.SetNamedConstant("g_vMaterialDiffuse", SpeedTreeUtil.FromSpeedTree(treeMaterial.Diffuse)); material.GetTechnique(tech).GetPass(0).FragmentProgramParameters.SetNamedConstant("g_vMaterialAmbient", SpeedTreeUtil.FromSpeedTree(treeMaterial.Ambient)); } } material.Load(); material.Lighting = true; return material; }