protected override void LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, IContentManager contentManager) { base.LoadContent(GraphicInfo, factory, contentManager); #region Models ///Cenario { SimpleModel sm = new SimpleModel(factory, "..\\Content\\Model\\cenario"); IPhysicObject pi = new TriangleMeshObject(sm, Vector3.Zero, Matrix.Identity, Vector3.One, MaterialDescription.DefaultBepuMaterial()); DeferredNormalShader shader = new DeferredNormalShader(0.05f, 50); IMaterial mat = new DeferredMaterial(shader); IObject obj3 = new IObject(mat, sm, pi); this.World.AddObject(obj3); } #endregion CameraFirstPerson cam = new CameraFirstPerson(GraphicInfo); cam.FarPlane = 2000; ///Atirador de bolas classico lt = new LightThrowBepu(this.World, factory); ///Interpolador que ira variar a cor das luzes UnitLightInterpolator li = new UnitLightInterpolator(this, true); ///Inicia o funcionamento do componente IScreenUpdateable (classe pai do UnitLightInterpolator) li.Start(); ///Adiciona DIVERSAS luzes pelo cenario for (int i = -10; i < 10; i++) { for (int j = -10; j < 10; j++) { ///Luz Pontual PointLightPE pl = new PointLightPE(new Vector3(i * 20, 10, j * 20), Color.White, 35, 2); //Atenuacao quadratica (inverso do quadrado ao inves do padrao que eh inverso da linear) ///custa mais, mas eh mais bonita pl.UsePointLightQuadraticAttenuation = true; ///adiciona ao mundo this.World.AddLight(pl); ///adiciona ao interpolador li.AddLight(pl, StaticRandom.RandomColor(), StaticRandom.RandomColor(), StaticRandom.RandomBetween(0, 5)); } } ///mais luzes, mais alto for (int i = -5; i < 5; i++) { for (int j = -5; j < 5; j++) { PointLightPE pl = new PointLightPE(new Vector3(i * 50, 140, j * 50), Color.White, 70, 1); pl.UsePointLightQuadraticAttenuation = true; this.World.AddLight(pl); li.AddLight(pl, StaticRandom.RandomColor(), StaticRandom.RandomColor(), StaticRandom.RandomBetween(0, 10)); } } this.World.CameraManager.AddCamera(cam); this.RenderTechnic.AddPostEffect(new AntiAliasingPostEffect()); }
/// <summary> /// Called once to load content /// </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, PloobsEngine.SceneControl.IContentManager contentManager) { ///load background texture tile = factory.GetTexture2D("Textures/tile"); ///recover the physic world reference FarseerWorld fworld = this.World.PhysicWorld as FarseerWorld; ///from vertices { ////creating objects from vertices Vertices Vertices = new Vertices(3); Vertices.Add(new Vector2(0, 0)); Vertices.Add(new Vector2(200, 0)); Vertices.Add(new Vector2(0, -200)); ///creating the IModelo (graphic representation) SpriteFarseer SpriteFarseer = new SpriteFarseer(factory, Vertices, Color.Green); ///The material (how to draw) Basic2DTextureMaterial mat = new Basic2DTextureMaterial(); ///the physic object (physic representation) FarseerObject fs = new FarseerObject(fworld, SpriteFarseer, 1, BodyType.Static); ///the iobject (that comprises all) I2DObject o = new I2DObject(fs, mat, SpriteFarseer); ///adding to the world this.World.AddObject(o); } ///Creating from factory helper Vertices verts = PolygonTools.CreateRectangle(50, 50); { IModelo2D model = new SpriteFarseer(factory, verts, Color.Green); Basic2DTextureMaterial mat = new Basic2DTextureMaterial(); FarseerObject fs = new FarseerObject(fworld, model, 1, BodyType.Static); I2DObject o = new I2DObject(fs, mat, model); ///the origin of the created object will be in the center of it, this mean: if we draw it, the center of mass of it will be on the midle of the screen ///We need to translate it a bit down o.PhysicObject.Position = new Vector2(100, 150); this.World.AddObject(o); } ///Creating from factory helper verts = PolygonTools.CreateRectangle(50, 50); { IModelo2D model = new SpriteFarseer(factory, verts, Color.Yellow); Basic2DTextureMaterial mat = new Basic2DTextureMaterial(); FarseerObject fs = new FarseerObject(fworld, model, 1, BodyType.Static); I2DObject o = new I2DObject(fs, mat, model); ///the origin of the created object will be in the center of it, this mean: if we draw it, the center of mass of it will be on the midle of the screen ///We need to translate it a bit down o.PhysicObject.Position = new Vector2(-100, -150); this.World.AddObject(o); } ///Creating from factory helper verts = PolygonTools.CreateRectangle(GraphicInfo.BackBufferWidth, 100); { IModelo2D model = new SpriteFarseer(factory, verts, Color.Red); Basic2DTextureMaterial mat = new Basic2DTextureMaterial(); FarseerObject fs = new FarseerObject(fworld, model, 1, BodyType.Static); I2DObject o = new I2DObject(fs, mat, model); ///the origin of the created object will be in the center of it, this mean: if we draw it, the center of mass of it will be on the midle of the screen ///We need to translate it a bit down o.PhysicObject.Position = new Vector2(0, 250); this.World.AddObject(o); } ///when tap ... SimpleConcreteGestureInputPlayable SimpleConcreteMouseBottomInputPlayable = null; SimpleConcreteMouseBottomInputPlayable = new SimpleConcreteGestureInputPlayable(Microsoft.Xna.Framework.Input.Touch.GestureType.Tap, (sample) => { Vector2 wpos = this.World.Camera2D.ConvertScreenToWorld(sample.Position); { Texture2D tex = factory.GetTexture2D("Textures//goo"); IModelo2D model = new SpriteFarseer(tex); Basic2DTextureMaterial mat = new Basic2DTextureMaterial(); FarseerObject fs = new FarseerObject(fworld, tex); I2DObject partobj = new I2DObject(fs, mat, model); partobj.PhysicObject.Position = wpos; fs.Body.Friction = StaticRandom.RandomBetween(0, 1); this.World.AddObject(partobj); } } ); this.BindInput(SimpleConcreteMouseBottomInputPlayable); ///the basic ortographic 2D camera this.World.Camera2D = new Camera2D(GraphicInfo); base.LoadContent(GraphicInfo, factory, contentManager); }