/// <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); { IModelo sm = new SimpleModel(factory, "Model\\block"); Matrix trans = Matrix.CreateTranslation(new Vector3(100, 50, 0)); Plane plano = Plane.Transform(new Plane(0, 1, 0, 0), trans); IPhysicObject pi = new BoxObject(Vector3.Zero, 1, 1, 1, 5, new Vector3(1300, 0.1f, 1300), trans, MaterialDescription.DefaultBepuMaterial()); pi.isMotionLess = true; ///Water shader, will refract and reflect according to the plano passed in the parameter ///Using default Parameters, there are lots of things that can be changed. See WaterCompleteShader DeferredWaterCompleteShader shader = new DeferredWaterCompleteShader(800, 600, plano, 0); shader.SpecularIntensity = 0.01f; shader.SpecularPower = 50; IMaterial mat = new DeferredMaterial(shader); IObject obj4 = new IObject(mat, sm, pi); this.World.AddObject(obj4); } { ///Need to load the height, the normal texture and the difuse texture SimpleModel sm = new SimpleModel(factory, "..\\Content\\Model\\block", "..\\Content\\Textures\\color_map"); sm.SetTexture("Textures\\normal_map", TextureType.BUMP); sm.SetCubeTexture(factory.GetTextureCube("Textures//cubemap"), TextureType.ENVIRONMENT); BoxObject pi = new BoxObject(new Vector3(200, 110, 0), 1, 1, 1, 5, new Vector3(100, 100, 100), Matrix.Identity, MaterialDescription.DefaultBepuMaterial()); DeferredEnvironmentCustomShader DeferredEnvironmentCustomShader = new DeferredEnvironmentCustomShader(false, true, false); DeferredEnvironmentCustomShader.SpecularIntensity = 0.2f; DeferredEnvironmentCustomShader.SpecularPower = 30; DeferredEnvironmentCustomShader.ShaderId = ShaderUtils.CreateSpecificBitField(true); IMaterial mat = new DeferredMaterial(DeferredEnvironmentCustomShader); IObject obj3 = new IObject(mat, sm, pi); this.World.AddObject(obj3); } { List <Vector3> poss = new List <Vector3>(); for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { float x, y; x = i * 100; y = j * 100; poss.Add(new Vector3(x, 100, y)); } } StaticBilboardModel bm = new StaticBilboardModel(factory, "Bilbs", "..\\Content\\Textures\\tree", poss); DeferredCilindricGPUBilboardShader cb = new DeferredCilindricGPUBilboardShader(); DeferredMaterial matfor = new DeferredMaterial(cb); GhostObject go = new GhostObject(); IObject obj2 = new IObject(matfor, bm, go); this.World.AddObject(obj2); } ///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)); }
/// <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); SimpleModel simpleModel = new SimpleModel(factory, "Model//cenario"); TriangleMeshObject tmesh = new TriangleMeshObject(simpleModel, Vector3.Zero, Matrix.Identity, Vector3.One, MaterialDescription.DefaultBepuMaterial()); DeferredNormalShader shader = new DeferredNormalShader(); DeferredMaterial fmaterial = new DeferredMaterial(shader); IObject obj = new IObject(fmaterial, simpleModel, tmesh); this.World.AddObject(obj); { List <Vector3> poss = new List <Vector3>(); for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { float x, y; x = i * 15; y = j * 15; poss.Add(new Vector3(x, 5, y)); } } ///The Bilboard Model StaticBilboardModel bm = new StaticBilboardModel(factory, "Bilbs", "Textures\\grama2", poss); ///The Procedural Animated BilboardShader DeferredProceduralAnimatedcilindricBilboardShader cb = new DeferredProceduralAnimatedcilindricBilboardShader(); ///You can change parameters like Amplitude and Speed to control the movement cb.MovimentSpeedControl = 1000; DeferredMaterial matfor = new DeferredMaterial(cb); GhostObject go = new GhostObject(); go.Position = new Vector3(70, 0, 0); IObject obj2 = new IObject(matfor, bm, go); this.World.AddObject(obj2); } #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(-40), MathHelper.ToRadians(-5), new Vector3(-50, 50, 250), GraphicInfo); this.World.CameraManager.AddCamera(cam); SkyBoxSetTextureCube stc = new SkyBoxSetTextureCube("Textures//grassCube"); CommandProcessor.getCommandProcessor().SendCommandAssyncronous(stc); }
protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager) { base.LoadContent(GraphicInfo, factory, contentManager); SimpleModel simpleModel = new SimpleModel(factory, "Model//cenario"); TriangleMeshObject tmesh = new TriangleMeshObject(simpleModel, Vector3.Zero, Matrix.Identity, Vector3.One, MaterialDescription.DefaultBepuMaterial()); DeferredNormalShader shader = new DeferredNormalShader(); DeferredMaterial fmaterial = new DeferredMaterial(shader); IObject obj = new IObject(fmaterial, simpleModel, tmesh); this.World.AddObject(obj); //{ // List<Vector3> poss = new List<Vector3>(); // for (int i = 0; i < 10; i++) // { // for (int j = 0; j < 10; j++) // { // float x, y; // x = i * 100; // y = j * 100; // poss.Add(new Vector3(x, 5, y)); // } // } // StaticBilboardModel bm = new StaticBilboardModel(factory, "Bilbs", "..\\Content\\Textures\\tree", poss); // DeferredCilindricGPUBilboardShader cb = new DeferredCilindricGPUBilboardShader(); // DeferredMaterial matfor = new DeferredMaterial(cb); // GhostObject go = new GhostObject(); // IObject obj2 = new IObject(matfor, bm, go); // this.World.AddObject(obj2); //} //{ // List<Vector3> poss = new List<Vector3>(); // for (int i = 0; i < 10; i++) // { // for (int j = 0; j < 10; j++) // { // float x, y; // x = i * 100; // y = j * 100; // poss.Add(new Vector3(x, 5, y)); // } // } // StaticBilboardModel bm = new StaticBilboardModel(factory, "Bilbs", "..\\Content\\Textures\\tree", poss); // DeferredSphericalBilboardShader cb = new DeferredSphericalBilboardShader(); // DeferredMaterial matfor = new DeferredMaterial(cb); // GhostObject go = new GhostObject(); // IObject obj2 = new IObject(matfor, bm, go); // this.World.AddObject(obj2); //} // { // List<Vector3> poss = new List<Vector3>(); // for (int i = 0; i < 10; i++) // { // for (int j = 0; j < 10; j++) // { // float x, y; // x = i * 100; // y = j * 100; // poss.Add(new Vector3(x, 5, y)); // } // } // StaticBilboardModel bm = new StaticBilboardModel(factory, "Bilbs", "Textures\\grama1", poss); // DeferredProceduralAnimatedcilindricBilboardShader cb = new DeferredProceduralAnimatedcilindricBilboardShader(); // DeferredMaterial matfor = new DeferredMaterial(cb); // GhostObject go = new GhostObject(); // IObject obj2 = new IObject(matfor, bm, go); // this.World.AddObject(obj2); //} { List <Vector3> poss = new List <Vector3>(); for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { float x, y; x = i * 100; y = j * 100; poss.Add(new Vector3(x, 5, y)); } } StaticBilboardModel bm = new StaticBilboardModel(factory, "Bilbs", "Textures\\wizard", poss); DeferredAnimatedTextureShader cb = new DeferredAnimatedTextureShader(3, 100, BilboardType.Cilindric); cb.Amplitude = 0f; cb.Scale = new Vector2(50, 50); cb.Atenuation = new Vector4(0.4f, 0.4f, 0.4f, 1); DeferredMaterial matfor = new DeferredMaterial(cb); GhostObject go = new GhostObject(new Vector3(0, 10, 0), Matrix.Identity, Vector3.One); IObject obj2 = new IObject(matfor, bm, go); this.World.AddObject(obj2); } //{ // List<BilboardInstance> poss = new List<BilboardInstance>(); // for (int i = 0; i < 10; i++) // { // for (int j = 0; j < 10; j++) // { // float x, y; // x = i * 100; // y = j * 100; // BilboardInstance bi = new BilboardInstance(); // bi.Scale = new Vector2(100, 100); // bi.Position = new Vector3(x, 5, y); // poss.Add(bi); // } // } // InstancedBilboardModel bm = new InstancedBilboardModel(factory, "Bilbs", "..\\Content\\Textures\\tree",poss.ToArray()); // DeferredInstancedBilboardShader cb = new DeferredInstancedBilboardShader(BilboardType.Cilindric); // DeferredMaterial matfor = new DeferredMaterial(cb); // GhostObject go = new GhostObject(); // IObject obj2 = new IObject(matfor, bm, go); // this.World.AddObject(obj2); //} #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); }
protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager) { base.LoadContent(GraphicInfo, factory, contentManager); SimpleModel simpleModel = new SimpleModel(factory, "Model//block"); simpleModel.SetTexture(factory.CreateTexture2DColor(1, 1, Color.White), TextureType.DIFFUSE); BoxObject tmesh = new BoxObject(new Vector3(0, 10, 0), 1, 1, 1, 50, new Vector3(5000, 1, 5000), Matrix.Identity, MaterialDescription.DefaultBepuMaterial()); tmesh.isMotionLess = true; DeferredNormalShader shader = new DeferredNormalShader(); DeferredMaterial fmaterial = new DeferredMaterial(shader); IObject obj = new IObject(fmaterial, simpleModel, tmesh); this.World.AddObject(obj); { List <Vector3> poss = new List <Vector3>(); for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { float x, y; x = i * 100; y = j * 100; poss.Add(new Vector3(x, 5, y)); } } ///Bilboard Model StaticBilboardModel bm = new StaticBilboardModel(factory, "Bilbs", "..\\Content\\Textures\\tree", poss); ///Bilboard Shader, this one is otimized for Cilindrical Bilboard only DeferredCilindricGPUBilboardShader cb = new DeferredCilindricGPUBilboardShader(); cb.Atenuation = new Vector4(0.8f, 0.8f, 0.8f, 1); DeferredMaterial matfor = new DeferredMaterial(cb); ///You can Change Parameters (position, scale ...) of ALL bilboards changing the World Matrix of the physical Object ///for Ghost Object we can use go.setInternalWorldMatrix. GhostObject go = new GhostObject(); go.Position = new Vector3(200, -10f, 0); IObject obj2 = new IObject(matfor, bm, go); this.World.AddObject(obj2); } #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(-60), MathHelper.ToRadians(-10), new Vector3(-200, 150, 250), GraphicInfo); this.World.CameraManager.AddCamera(cam); SkyBoxSetTextureCube stc = new SkyBoxSetTextureCube("Textures//grassCube"); CommandProcessor.getCommandProcessor().SendCommandAssyncronous(stc); }
protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager) { base.LoadContent(GraphicInfo, factory, contentManager); ///The Animated Bilboard { ///A lits with all the bilboards positions List <Vector3> poss = new List <Vector3>(); for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { float x, y; x = i * 100; y = j * 100; poss.Add(new Vector3(x, 5, y)); } } ///Create the Bilboard Model ///the Textures\\coin Texture is a Horizontal animated texture StaticBilboardModel bm = new StaticBilboardModel(factory, "Bilbs", "Textures\\coin", poss); ///The shader that will render it, pass the number of frames, the time to wait between frames and the type of the bilboard ///Spherical ALWAYS face the camera ///Cilindric has a axis that the bilboard can rotate around, to face the camera DeferredAnimatedTextureShader cb = new DeferredAnimatedTextureShader(6, 100, BilboardType.Cilindric); ///We can animated the two up vertices of the bilboard quad (useful in grass for example) cb.Amplitude = 0f; ///Quad Scale cb.Scale = new Vector2(50, 50); ///Color atenuation, this will multiply the Texture colors cb.Atenuation = new Vector4(0.4f, 0.4f, 0.4f, 1); DeferredMaterial matfor = new DeferredMaterial(cb); ///no physical representation (REMEMBER; all bilboards are the SAME OBJECT) GhostObject go = new GhostObject(new Vector3(70, 0, 0), Matrix.Identity, Vector3.One); IObject obj2 = new IObject(matfor, bm, go); this.World.AddObject(obj2); } #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(-60), MathHelper.ToRadians(-10), new Vector3(-200, 150, 250), GraphicInfo); this.World.CameraManager.AddCamera(cam); SkyBoxSetTextureCube stc = new SkyBoxSetTextureCube("Textures//grassCube"); CommandProcessor.getCommandProcessor().SendCommandAssyncronous(stc); }