protected override void LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, PloobsEngine.SceneControl.IContentManager contentManager) { tile = factory.GetTexture2D("Textures/tile"); FarseerWorld fworld = this.World.PhysicWorld as FarseerWorld; ///border border = new Border(fworld, factory, GraphicInfo, factory.CreateTexture2DColor(1, 1, Color.Red)); ///from texture { Texture2D tex = factory.GetTexture2D("Textures//goo"); tex = factory.GetScaledTexture(tex, new Vector2(4)); IModelo2D model = new SpriteFarseer(tex); Basic2DTextureMaterial mat = new Basic2DTextureMaterial(); FarseerObject fs = new FarseerObject(fworld, model); I2DObject o = new I2DObject(fs, mat, model); o.OnHasMoved += new PloobsEngine.SceneControl._2DScene.OnHasMoved(o_OnHasMoved); this.World.AddObject(o); } ///camera this.World.Camera2D = new Camera2D(GraphicInfo); ///Create the Particle System DPFSParticleSystem ps = new DPFSParticleSystem("TESTE", new SpriteParticleSystem(null)); this.World.ParticleManager.AddAndInitializeParticleSystem(ps); ///updateable JointUpdateable ju = new JointUpdateable(this, fworld, this.World.Camera2D); base.LoadContent(GraphicInfo, factory, contentManager); }
protected override void LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, PloobsEngine.SceneControl.IContentManager contentManager) { tile = factory.GetTexture2D("Textures/tile"); FarseerWorld fworld = this.World.PhysicWorld as FarseerWorld; ///border border = new Border(fworld, factory, GraphicInfo, factory.CreateTexture2DColor(1, 1, Color.Red)); ///from texture, scale usage sample { Texture2D tex = factory.GetTexture2D("Textures//goo"); tex = factory.GetScaledTexture(tex, new Vector2(3)); IModelo2D model = new SpriteFarseer(tex); Basic2DTextureMaterial mat = new Basic2DTextureMaterial(); FarseerObject fs = new FarseerObject(fworld, tex); fs.Position = new Vector2(0, 50); partobj = new I2DObject(fs, mat, model); partobj.OnHasMoved += new PloobsEngine.SceneControl._2DScene.OnHasMoved(o_OnHasMoved); this.World.AddObject(partobj); } Vertices verts = PolygonTools.CreateRectangle(150, 150); { IModelo2D model = new SpriteFarseer(factory, verts, Color.Green); Basic2DTextureMaterial mat = new Basic2DTextureMaterial(); FarseerObject fs = new FarseerObject(fworld, model, 1, BodyType.Dynamic); 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, 100); this.World.AddObject(o); } //circle verts = PolygonTools.CreateCircle(150, 150); { IModelo2D model = new SpriteFarseer(factory, verts, Color.Orange); Basic2DTextureMaterial mat = new Basic2DTextureMaterial(); FarseerObject fs = new FarseerObject(fworld, model, 1, BodyType.Dynamic); I2DObject o = new I2DObject(fs, mat, model); o.PhysicObject.Position = new Vector2(-100, -100); this.World.AddObject(o); } ///camera this.World.Camera2D = new Camera2D(GraphicInfo); DPFSParticleSystem ps = new DPFSParticleSystem("TESTE", new SpriteParticleSystem(null)); this.World.ParticleManager.AddAndInitializeParticleSystem(ps); ///updateable ju = new JointUpdateable(this, fworld, this.World.Camera2D); base.LoadContent(GraphicInfo, factory, contentManager); }
protected override void LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, IContentManager contentManager) { base.LoadContent(GraphicInfo, factory, contentManager); #region Models { simpleModel = new SimpleModel(factory, "..\\Content\\Model\\teapot"); simpleModel.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Red), TextureType.DIFFUSE); GhostObject tmesh = new GhostObject(Vector3.Zero, Matrix.Identity, Vector3.One * 2); ///Environment Map Shader, there are 2 options, the first is a fully reflective surface (dont use the object texture) and the second ///is a mix of the object texture and the environment texture ///Used to fake ambient reflection, give metal appearence to an object .... shader = new ForwardEnvironmentShader(factory.GetTextureCube("Textures\\cubeMap"), 1, false); ForwardMaterial fmaterial = new ForwardMaterial(shader); IObject tea = new IObject(fmaterial, simpleModel, tmesh); tea.OnUpdate += new OnUpdate(tea_OnUpdate); this.World.AddObject(tea); } //{ // SimpleModel simpleModel = new SimpleModel(factory, "Model//block"); // simpleModel.SetTexture(factory.CreateTexture2DColor(1, 1, Color.White), TextureType.DIFFUSE); // BoxObject tmesh = new BoxObject(new Vector3(0,-20,0), 1, 1, 1, 10, new Vector3(200, 1, 200), 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); //} #endregion cam = new RotatingCamera(this); this.World.CameraManager.AddCamera(cam); SkyBoxSetTextureCube stc = new SkyBoxSetTextureCube("Textures//cubeMap"); CommandProcessor.getCommandProcessor().SendCommandAssyncronous(stc); }
protected override void LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, IContentManager contentManager) { base.LoadContent(GraphicInfo, factory, contentManager); #region Models createobjs(); ///Some Physic World Parameters ///No accuracy (speed up the simulation) and no gravity BepuPhysicWorld physicWorld = this.World.PhysicWorld as BepuPhysicWorld; physicWorld.Space.Solver.IterationLimit = 1; //Essentially no sustained contacts, so don't need to worry about accuracy. { SimpleModel sm = new SimpleModel(factory, "..\\Content\\Model\\cubo"); sm.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Blue), TextureType.DIFFUSE); MaterialDescription md = MaterialDescription.DefaultBepuMaterial(); md.Bounciness = 1; BoxObject pi = new BoxObject(new Vector3(0, -30, 0), 1, 1, 1, 1, new Vector3(50, 1, 50), Matrix.Identity, md); pi.isMotionLess = true; pi.Entity.AngularDamping = 0f; ForwardXNABasicShader shader = new ForwardXNABasicShader(); IMaterial mat = new ForwardMaterial(shader); IObject obj5 = new IObject(mat, sm, pi); this.World.AddObject(obj5); shader.BasicEffect.EnableDefaultLighting(); } #endregion cam = new RotatingCamera(this); this.World.CameraManager.AddCamera(cam); }
protected override void LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, IContentManager contentManager) { base.LoadContent(GraphicInfo, factory, contentManager); Picking picking = new Picking(this); this.AddScreenUpdateable(picking); #region Models { 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(); IMaterial mat = new DeferredMaterial(shader); IObject obj3 = new IObject(mat, sm, pi); obj3.Name = "cenario"; this.World.AddObject(obj3); } for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { SimpleModel sm = new SimpleModel(factory, "..\\Content\\Model\\cubo"); sm.SetTexture(factory.CreateTexture2DColor(1, 1, Color.White), TextureType.DIFFUSE); BoxObject pi = new BoxObject(new Vector3(i * 10, 100, j * 10), 1, 1, 1, 1, new Vector3(5), Matrix.Identity, MaterialDescription.DefaultBepuMaterial()); pi.isMotionLess = true; DeferredNormalShader shader = new DeferredNormalShader(); IMaterial mat = new DeferredMaterial(shader); IObject obj4 = new IObject(mat, sm, pi); obj4.Name = "Block " + i + " : " + j; this.World.AddObject(obj4); } } #endregion cam = new CameraFirstPerson(GraphicInfo); cam.FarPlane = 3000; #region NormalLight ///Conjunto de luzes direcionais 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.2f; 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(cam); picking.OnPickedNoneButton += new OnPicked(onPick); sp1 = new SpotLightPE(new Vector3(0, 150, 0), new Vector3(0, -1, 0), Color.PapayaWhip, 1, 200, (float)Math.Cos(Math.PI / 12), 2f); this.World.AddLight(sp1); }
protected override void LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, IContentManager contentManager) { base.LoadContent(GraphicInfo, factory, contentManager); #region Models ///Paralelepipelo (cubo com scale ) enviara mensagens quando colidir com objetos ///Object that will send messages when something collides with it { SimpleModel sm = new SimpleModel(factory, "..\\Content\\Model\\cubo"); sm.SetTexture(factory.CreateTexture2DColor(1, 1, Color.White), TextureType.DIFFUSE); BoxObject pi = new BoxObject(new Vector3(100, 40, 0), 1, 1, 1, 25, new Vector3(100, 10, 100), Matrix.Identity, MaterialDescription.DefaultBepuMaterial()); ///Adiciona um handler que sera chamada quando uma colisao acontecer ///Add a handler that will handle the colision =P pi.Entity.CollisionInformation.Events.InitialCollisionDetected += new BEPUphysics.Collidables.Events.InitialCollisionDetectedEventHandler <BEPUphysics.Collidables.MobileCollidables.EntityCollidable>(Events_InitialCollisionDetected); DeferredNormalShader shader = new DeferredNormalShader(); IMaterial mat = new DeferredMaterial(shader); IObject obj3 = new IObject(mat, sm, pi); this.World.AddObject(obj3); } ////CUBO Q VAI MUDAR DE COR ///Object that will recieve the message (collision message send from the above object) and will change color. { SimpleModel sm = new SimpleModel(factory, "..\\Content\\Model\\cubo"); sm.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Yellow), TextureType.DIFFUSE); BoxObject pi = new BoxObject(new Vector3(50, 50, 50), 1, 1, 1, 5, new Vector3(15), Matrix.Identity, MaterialDescription.DefaultBepuMaterial()); pi.isMotionLess = true; DeferredNormalShader shader = new DeferredNormalShader(); IMaterial mat = new DeferredMaterial(shader); IObject obj3 = new IObject(mat, sm, pi); ///Adiciona um handler para tratar das mensagens (existe outra maneira mais robusta de fazer isto, conforme citado no exemplo sobre Triggers) ///hanlde incomming messages obj3.OnRecieveMessage += new OnRecieveMessage(obj3_OnRecieveMessage); ///Forcando um ID, normalmente ele eh setado automaticamente ao adicionar o objeto no mundo ///Set the Id, forcing it (you can only force ids less than 1000) obj3.SetId(77); this.World.AddObject(obj3); long id = obj3.GetId(); ///Testa se o Id atribuido eh o forcado ///Internamente a Engine atribui Ids acima de 1000 (valores abaixo funcionarao, a menos que alguem ja tenha forcado este Id antes) ///Como neste caso nao forcamos o id de ninguem para 77, entao o obj3 tera id 77 ///Soh pra garantir ;) ///Just check Debug.Assert(id == 77); } ////cubo que escuta um canal de mensagens ///Cube that listen a channel { SimpleModel sm = new SimpleModel(factory, "..\\Content\\Model\\cubo"); sm.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Red), TextureType.DIFFUSE); BoxObject pi = new BoxObject(new Vector3(100, 50, 50), 1, 1, 1, 50, new Vector3(15), Matrix.Identity, MaterialDescription.DefaultBepuMaterial()); pi.isMotionLess = true; DeferredNormalShader shader = new DeferredNormalShader(); IMaterial mat = new DeferredMaterial(shader); IObject obj3 = new IObject(mat, sm, pi); ///Adiciona um handler para tratar das mensagens (existe outra maneira mais robusta de fazer isto, conforme citado no exemplo sobre Triggers) ///OBSERVAR QUE FOI USADO O MESMO HANDLER QUE O OBJETO ANTERIOR (JA QUE DESEJA-SE TER O MESMO EFEITO) ///hanle messages obj3.OnRecieveMessage += new OnRecieveMessage(obj3_OnRecieveMessage); this.World.AddObject(obj3); ///Adiciona este objeto ao canal de comunicao chamado "cubo" (recebera mensagens deste grupo tb) ///REGISTER IN THIS MESSAGE CHANNEL EntityMapper.getInstance().AddgrouptagRecieveEntity("cubo", obj3); } { 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(); IMaterial mat = new DeferredMaterial(shader); IObject obj3 = new IObject(mat, sm, pi); this.World.AddObject(obj3); } #endregion cam = new CameraFirstPerson(GraphicInfo); cam.FarPlane = 3000; lt = new LightThrowBepu(this.World, factory); #region NormalLight ///Conjunto de luzes direcionais 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 this.World.CameraManager.AddCamera(cam); }
protected override void LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, PloobsEngine.SceneControl.IContentManager contentManager) { tile = factory.GetTexture2D("Textures/tile"); FarseerWorld fworld = this.World.PhysicWorld as FarseerWorld; ///border border = new Border(fworld, factory, GraphicInfo, factory.CreateTexture2DColor(1, 1, Color.Red)); ///from texture { Texture2D tex = factory.GetTexture2D("Textures//goo"); IModelo2D model = new SpriteFarseer(tex); Basic2DTextureMaterial mat = new Basic2DTextureMaterial(); FarseerObject fs = new FarseerObject(fworld, tex); I2DObject o = new I2DObject(fs, mat, model); o.OnHasMoved += new PloobsEngine.SceneControl._2DScene.OnHasMoved(o_OnHasMoved); this.World.AddObject(o); } ///from texture, scale usage sample { Texture2D tex = factory.GetTexture2D("Textures//goo"); tex = factory.GetScaledTexture(tex, new Vector2(2)); IModelo2D model = new SpriteFarseer(tex); Basic2DTextureMaterial mat = new Basic2DTextureMaterial(); FarseerObject fs = new FarseerObject(fworld, tex); I2DObject o = new I2DObject(fs, mat, model); this.World.AddObject(o); } ///rectangle Vertices verts = PolygonTools.CreateRectangle(5, 5); { IModelo2D model = new SpriteFarseer(factory, verts, Color.Orange); Basic2DTextureMaterial mat = new Basic2DTextureMaterial(); FarseerObject fs = new FarseerObject(fworld, verts); I2DObject o = new I2DObject(fs, mat, model); this.World.AddObject(o); } ///circle CircleShape circle = new CircleShape(5, 1); { IModelo2D model = new SpriteFarseer(factory, circle, Color.Orange); Basic2DTextureMaterial mat = new Basic2DTextureMaterial(); FarseerObject fs = new FarseerObject(fworld, circle); I2DObject o = new I2DObject(fs, mat, model); this.World.AddObject(o); } ///camera this.World.Camera2D = new Camera2D(GraphicInfo); DPFSParticleSystem ps = new DPFSParticleSystem("TESTE", new SpriteParticleSystem(null)); this.World.ParticleManager.AddAndInitializeParticleSystem(ps); ///add a post effect =P //this.RenderTechnic.AddPostEffect(new WigglePostEffect()); ///updateable JointUpdateable ju = new JointUpdateable(this, fworld, this.World.Camera2D); base.LoadContent(GraphicInfo, factory, contentManager); }
protected override void LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, PloobsEngine.SceneControl.IContentManager contentManager) { tile = factory.GetTexture2D("Textures/tile"); FarseerWorld fworld = this.World.PhysicWorld as FarseerWorld; ///border border = new Border(fworld, factory, GraphicInfo, factory.CreateTexture2DColor(1, 1, Color.Red)); ///from texture { Texture2D tex = factory.GetTexture2D("Textures//goo"); IModelo2D model = new SpriteFarseer(tex); Basic2DTextureMaterial mat = new Basic2DTextureMaterial(); FarseerObject fs = new FarseerObject(fworld, model); I2DObject o = new I2DObject(fs, mat, model); o.PhysicObject.Position = new Vector2(200, 0); this.World.AddObject(o); } ///from texture, scale usage sample { Texture2D tex = factory.GetTexture2D("Textures//goo"); tex = factory.GetScaledTexture(tex, new Vector2(2)); IModelo2D model = new SpriteFarseer(tex); Basic2DTextureMaterial mat = new Basic2DTextureMaterial(); FarseerObject fs = new FarseerObject(fworld, model); I2DObject o = new I2DObject(fs, mat, model); o.OnHasMoved += new PloobsEngine.SceneControl._2DScene.OnHasMoved(o_OnHasMoved); this.World.AddObject(o); } ///rectangle Vertices verts = PolygonTools.CreateRectangle(50, 50); { IModelo2D model = new SpriteFarseer(factory, verts, Color.Orange); Basic2DTextureMaterial mat = new Basic2DTextureMaterial(); FarseerObject fs = new FarseerObject(fworld, model); I2DObject o = new I2DObject(fs, mat, model); o.PhysicObject.Position = new Vector2(-200, 0); this.World.AddObject(o); } ///circle CircleShape circle = new CircleShape(50, 1); { IModelo2D model = new SpriteFarseer(factory, circle, Color.Orange); Basic2DTextureMaterial mat = new Basic2DTextureMaterial(); FarseerObject fs = new FarseerObject(fworld, model); I2DObject o = new I2DObject(fs, mat, model); o.PhysicObject.Position = new Vector2(200, -100); this.World.AddObject(o); } ///animated sprite { Texture2D tex = factory.GetTexture2D("Textures//DudeSheet"); SpriteAnimated sa = new SpriteAnimated(tex, 8, 2); sa.AddAnimation("ANIM1", 1, 8, 0); sa.AddAnimation("ANIM2", 2, 4, MathHelper.PiOver2); Basic2DTextureMaterial mat = new Basic2DTextureMaterial(); Texture2D frame = factory.GetTexturePart(tex, sa.GetFrameRectangle("ANIM1", 0)); FarseerObject fs = new FarseerObject(fworld, frame); //GhostObject fs = new GhostObject(Vector2.Zero); sheet = new I2DObject(fs, mat, sa); sheet.PhysicObject.Position = new Vector2(500, 0); this.World.AddObject(sheet); } { PointLight2D l = new PointLight2D(new Vector2(-GraphicInfo.BackBufferWidth / 4, -GraphicInfo.BackBufferWidth / 4), Color.Red, 1); this.World.AddLight(l); } { SpotLight2D l = new SpotLight2D(new Vector2(+GraphicInfo.BackBufferWidth / 4, -GraphicInfo.BackBufferWidth / 4), Color.Blue, new Vector2(0, 1), MathHelper.ToRadians(45)); this.World.AddLight(l); } { SimpleConcreteKeyboardInputPlayable sc = new SimpleConcreteKeyboardInputPlayable(StateKey.PRESS, Keys.Space); sc.KeyStateChange += new KeyStateChange(sc_KeyStateChange); this.BindInput(sc); } ///camera this.World.Camera2D = new Camera2D(GraphicInfo); DPFSParticleSystem ps = new DPFSParticleSystem("TESTE", new SpriteParticleSystem(null)); this.World.ParticleManager.AddAndInitializeParticleSystem(ps); ///add a post effect =P //this.RenderTechnic.AddPostEffect(new WigglePostEffect()); ///updateable JointUpdateable ju = new JointUpdateable(this, fworld, this.World.Camera2D); base.LoadContent(GraphicInfo, factory, contentManager); }
protected override void LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, PloobsEngine.SceneControl.IContentManager contentManager) { tile = factory.GetTexture2D("Textures/tile"); FarseerWorld fworld = this.World.PhysicWorld as FarseerWorld; ///border border = new Border(fworld, factory, GraphicInfo, factory.CreateTexture2DColor(1, 1, Color.Red)); ///from texture { Texture2D tex = factory.GetTexture2D("Textures//goo"); IModelo2D model = new SpriteFarseer(tex); Basic2DTextureMaterial mat = new Basic2DTextureMaterial(); FarseerObject fs = new FarseerObject(fworld, model); I2DObject o = new I2DObject(fs, mat, model); o.PhysicObject.Position = new Vector2(200, 0); this.World.AddObject(o); } ///from texture, scale usage sample { Texture2D tex = factory.GetTexture2D("Textures//goo"); tex = factory.GetScaledTexture(tex, new Vector2(2)); IModelo2D model = new SpriteFarseer(tex); Basic2DTextureMaterial mat = new Basic2DTextureMaterial(); FarseerObject fs = new FarseerObject(fworld, model); I2DObject o = new I2DObject(fs, mat, model); o.OnHasMoved += new PloobsEngine.SceneControl._2DScene.OnHasMoved(o_OnHasMoved); this.World.AddObject(o); } ///rectangle Vertices verts = PolygonTools.CreateRectangle(50, 50); { IModelo2D model = new SpriteFarseer(factory, verts, Color.Orange); Basic2DTextureMaterial mat = new Basic2DTextureMaterial(); FarseerObject fs = new FarseerObject(fworld, model); I2DObject o = new I2DObject(fs, mat, model); o.PhysicObject.Position = new Vector2(-200, 0); this.World.AddObject(o); } ///circle CircleShape circle = new CircleShape(50, 1); { IModelo2D model = new SpriteFarseer(factory, circle, Color.Orange); Basic2DTextureMaterial mat = new Basic2DTextureMaterial(); FarseerObject fs = new FarseerObject(fworld, model); I2DObject o = new I2DObject(fs, mat, model); o.PhysicObject.Position = new Vector2(200, -100); this.World.AddObject(o); } ///animated sprite { Texture2D tex = factory.GetTexture2D("Textures//DudeSheet"); SpriteAnimated sa = new SpriteAnimated(tex, 8, 2); sa.AddAnimation("ANIM1", 1, 8, 0); sa.AddAnimation("ANIM2", 2, 4, MathHelper.PiOver2); Basic2DTextureMaterial mat = new Basic2DTextureMaterial(); Texture2D frame = factory.GetTexturePart(tex, sa.GetFrameRectangle("ANIM1", 0)); FarseerObject fs = new FarseerObject(fworld, frame); //GhostObject fs = new GhostObject(Vector2.Zero); sheet = new I2DObject(fs, mat, sa); sheet.PhysicObject.Position = new Vector2(500, 0); this.World.AddObject(sheet); } { PointLight2D l = new PointLight2D(new Vector2(-GraphicInfo.BackBufferWidth / 4, -GraphicInfo.BackBufferWidth / 4), Color.Red, 1); this.World.AddLight(l); } { SpotLight2D l = new SpotLight2D(new Vector2(+GraphicInfo.BackBufferWidth / 4, -GraphicInfo.BackBufferWidth / 4), Color.Blue, new Vector2(0, 1), MathHelper.ToRadians(45)); this.World.AddLight(l); } { SimpleConcreteKeyboardInputPlayable sc = new SimpleConcreteKeyboardInputPlayable(StateKey.PRESS, Keys.Space); sc.KeyStateChange += new KeyStateChange(sc_KeyStateChange); this.BindInput(sc); } ///camera this.World.Camera2D = new Camera2D(GraphicInfo); DPFSParticleSystem ps = new DPFSParticleSystem("TESTE", new SpriteParticleSystem(null)); this.World.ParticleManager.AddAndInitializeParticleSystem(ps); ///add a post effect =P //this.RenderTechnic.AddPostEffect(new WigglePostEffect()); ///updateable JointUpdateable ju = new JointUpdateable(this, fworld, this.World.Camera2D); base.LoadContent(GraphicInfo, factory, contentManager); { NeoforceGui guiManager = this.Gui as NeoforceGui; System.Diagnostics.Debug.Assert(guiManager != null); // Create and setup Window control. Window window = new Window(guiManager.Manager); window.Init(); window.Text = "Getting Started"; window.Width = 480; window.Height = 200; window.Center(); window.Visible = true; // Create Button control and set the previous window as its parent. Button button = new Button(guiManager.Manager); button.Init(); button.Text = "OK"; button.Width = 72; button.Height = 24; button.Left = (window.ClientWidth / 2) - (button.Width / 2); button.Top = window.ClientHeight - button.Height - 8; button.Anchor = Anchors.Bottom; button.Parent = window; // Add the window control to the manager processing queue. guiManager.Manager.Add(window); } }
protected override void LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, IContentManager contentManager) { base.LoadContent(GraphicInfo, factory, contentManager); #region Models ///Cria uma textura 1x1 com a cor branca Texture2D white = factory.CreateTexture2DColor(1, 1, Color.White); { SimpleModel sm = new SimpleModel(factory, "..\\Content\\Model\\cubo"); sm.SetTexture(white, TextureType.DIFFUSE); BoxObject pi = new BoxObject(new Vector3(100, 20, 0), 1, 1, 1, 5, new Vector3(100, 5, 100), Matrix.Identity, MaterialDescription.DefaultBepuMaterial()); DeferredNormalShader shader = new DeferredNormalShader(); ///Setando alguns parametros do material shader.SpecularIntensity = 0.01f; shader.SpecularPower = 50; IMaterial mat = new DeferredMaterial(shader); IObject obj3 = new IObject(mat, sm, pi); this.World.AddObject(obj3); } { SimpleModel sm = new SimpleModel(factory, "..\\Content\\Model\\cubo"); sm.SetTexture(white, TextureType.DIFFUSE); BoxObject pi = new BoxObject(new Vector3(90, 30, 0), 1, 1, 1, 10, new Vector3(1), Matrix.Identity, MaterialDescription.DefaultBepuMaterial()); DeferredNormalShader shader = new DeferredNormalShader(); IMaterial mat = new DeferredMaterial(shader); IObject obj3 = new IObject(mat, sm, pi); this.World.AddObject(obj3); } { 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(); IMaterial mat = new DeferredMaterial(shader); IObject obj3 = new IObject(mat, sm, pi); this.World.AddObject(obj3); } #endregion #region NormalLight ///Conjunto de luzes direcionais 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 ///Criando uma camera estatica CameraStatic camx = new CameraStatic(new Vector3(130, 100, 700), Vector3.Zero); ///Dando um nome a ela (para poder recupera-la depois) camx.Name = "default"; camx.FarPlane = 3000; ///Adiciona ao Manager (NAO ESTA SENDO ATIVADA, APENAS ADICIONADA) this.World.CameraManager.AddCamera(camx, camx.Name); ///Ativa a camera atual (AO ADICIONAR UMA CAMERA AO WORLD USANDO mundo.AddCamera(cam) A CAMERA EH AUTOMATICAMENTE ATIVADA ) this.World.CameraManager.SetActiveCamera(camx.Name); ///Adiciona na lista circular camerasNames.Value = camx.Name; camerasNames.Next(); ///Idem para uma segunda camera (Porem esta nao eh ativada) CameraStatic cam2 = new CameraStatic(new Vector3(100, 100, 100), Vector3.Zero); cam2.Name = "StaticCamera"; cam2.FarPlane = 3000; this.World.CameraManager.AddCamera(cam2, cam2.Name); camerasNames.Value = cam2.Name; camerasNames.Next(); ///Idem para a terceira CameraStatic cam3 = new CameraStatic(new Vector3(500, 300, 300), Vector3.Zero); cam3.Name = "StaticCamera3"; cam3.FarPlane = 3000; this.World.CameraManager.AddCamera(cam3, cam3.Name); camerasNames.Value = cam3.Name; camerasNames.Next(); SimpleConcreteKeyboardInputPlayable ikp = new SimpleConcreteKeyboardInputPlayable(StateKey.PRESS, Keys.Space, KeyStateChange); bk = new BindKeyCommand(ikp, BindAction.ADD); CommandProcessor.getCommandProcessor().SendCommandAssyncronous(bk); }
protected override void LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, IContentManager contentManager) { base.LoadContent(GraphicInfo, factory, contentManager); #region Models ///Cria um modelo Controlavel pelo teclado { SimpleModel sm = new SimpleModel(factory, "..\\Content\\Model\\cubo"); sm.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Blue), TextureType.DIFFUSE); DeferredNormalShader shader = new DeferredNormalShader(); IMaterial mat = new DeferredMaterial(shader); CharacterControllerInput character = new CharacterControllerInput(this, new Vector3(100, 150, 1), 1, 1, 50, Vector3.One * 10, 0.5f); character.AheadKey = Keys.G; character.BackKey = Keys.T; character.LeftKey = Keys.F; character.RightKey = Keys.H; character.JumpKey = Keys.R; character.Characterobj.CharacterController.MaxSpeed = 35f; character.Characterobj.CharacterController.JumpSpeed = 15f; player = new IObject(mat, sm, character.Characterobj); this.World.AddObject(player); } ///Cria o cenario padrao de sempre ;) { 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(); IMaterial mat = new DeferredMaterial(shader); IObject obj3 = new IObject(mat, sm, pi); this.World.AddObject(obj3); } #endregion #region Cameras cam0 = new CameraFollowObject(player); ///Dando um nome a ela (para poder recupera-la depois) cam0.Name = "follow"; cam0.FarPlane = 3000; ///Adiciona ao Manager (NAO ESTA SENDO ATIVADA, APENAS ADICIONADA) this.World.CameraManager.AddCamera(cam0, cam0.Name); ///Ativa a camera atual (AO ADICIONAR UMA CAMERA AO WORLD USANDO mundo.AddCamera(cam) A CAMERA EH AUTOMATICAMENTE ATIVADA ) this.World.CameraManager.SetActiveCamera(cam0.Name); ///Adiciona na lista circular camerasNames.Value = cam0.Name; camerasNames.Next(); cam1 = new CameraFirstPerson(GraphicInfo); ///Dando um nome a ela (para poder recupera-la depois) cam1.Name = "first person"; cam1.FarPlane = 3000; ///Adiciona ao Manager (NAO ESTA SENDO ATIVADA, APENAS ADICIONADA) this.World.CameraManager.AddCamera(cam1, cam1.Name); ///Ativa a camera atual (AO ADICIONAR UMA CAMERA AO WORLD USANDO mundo.AddCamera(cam) A CAMERA EH AUTOMATICAMENTE ATIVADA ) this.World.CameraManager.SetActiveCamera(cam1.Name); ///Adiciona na lista circular camerasNames.Value = cam1.Name; //camerasNames.Next(); #endregion ///Objeto que permite atirar bolas de luzes na cena lt = new LightThrowBepu(this.World, factory); #region NormalLight ///Conjunto de luzes direcionais 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 { SimpleConcreteKeyboardInputPlayable ik = new SimpleConcreteKeyboardInputPlayable(StateKey.PRESS, Keys.Space, ChangeCamera); BindKeyCommand bk = new BindKeyCommand(ik, BindAction.ADD); CommandProcessor.getCommandProcessor().SendCommandAssyncronous(bk); } }
protected override void LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, IContentManager contentManager) { base.LoadContent(GraphicInfo, factory, contentManager); Picking picking = new Picking(this); this.AddScreenUpdateable(picking); #region Models { 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(); IMaterial mat = new DeferredMaterial(shader); IObject obj3 = new IObject(mat, sm, pi); obj3.Name = "cenario"; this.World.AddObject(obj3); } for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { SimpleModel sm = new SimpleModel(factory, "..\\Content\\Model\\cubo"); sm.SetTexture(factory.CreateTexture2DColor(1, 1, Color.White), TextureType.DIFFUSE); BoxObject pi = new BoxObject(new Vector3(i * 10, 100, j * 10), 1, 1, 1, 1, new Vector3(5), Matrix.Identity, MaterialDescription.DefaultBepuMaterial()); pi.isMotionLess = true; DeferredNormalShader shader = new DeferredNormalShader(); IMaterial mat = new DeferredMaterial(shader); IObject obj4 = new IObject(mat, sm, pi); obj4.Name = "Block " + i + " : " + j; this.World.AddObject(obj4); } } #endregion cam = new CameraFirstPerson(GraphicInfo); cam.FarPlane = 3000; #region NormalLight ///Conjunto de luzes direcionais 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 this.World.CameraManager.AddCamera(cam); ///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(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, PloobsEngine.SceneControl.IContentManager contentManager) { FarseerWorld fworld = this.World.PhysicWorld as FarseerWorld; ///border border = new Border(fworld, factory, GraphicInfo, factory.CreateTexture2DColor(1, 1, Color.Red)); ///from texture //{ // Texture2D tex = factory.GetTexture2D("Textures//goo"); // IModelo2D model = new SpriteFarseer(tex); // Basic2DTextureMaterial mat = new Basic2DTextureMaterial(); // FarseerObject fs = new FarseerObject(fworld, tex); // I2DObject o = new I2DObject(fs, mat, model); // this.World.AddObject(o); //} ///from texture, scale usage sample //{ // Texture2D tex = factory.GetTexture2D("Textures//goo"); // tex = factory.GetScaledTexture(tex, new Vector2(2)); // IModelo2D model = new SpriteFarseer(tex); // Basic2DTextureMaterial mat = new Basic2DTextureMaterial(); // FarseerObject fs = new FarseerObject(fworld, tex); // I2DObject o = new I2DObject(fs, mat, model); // this.World.AddObject(o); //} ///rectangle Vertices verts = PolygonTools.CreateRectangle(5, 5); { IModelo2D model = new SpriteFarseer(factory, verts, Color.Orange); Basic2DTextureMaterial mat = new Basic2DTextureMaterial(); FarseerObject fs = new FarseerObject(fworld, verts); I2DObject o = new I2DObject(fs, mat, model); this.World.AddObject(o); } ///circle CircleShape circle = new CircleShape(5, 1); { IModelo2D model = new SpriteFarseer(factory, circle, Color.Orange); Basic2DTextureMaterial mat = new Basic2DTextureMaterial(); FarseerObject fs = new FarseerObject(fworld, circle); I2DObject o = new I2DObject(fs, mat, model); this.World.AddObject(o); } { PointLight2D l = new PointLight2D(new Vector2(-GraphicInfo.BackBufferWidth / 4, -GraphicInfo.BackBufferWidth / 4), Color.Red, 1); this.World.AddLight(l); } { SpotLight2D l = new SpotLight2D(new Vector2(+GraphicInfo.BackBufferWidth / 4, -GraphicInfo.BackBufferWidth / 4), Color.Blue, new Vector2(0, 1), MathHelper.ToRadians(45)); this.World.AddLight(l); } ///camera this.World.Camera2D = new Camera2D(GraphicInfo); ///add a post effect =P //this.RenderTechnic.AddPostEffect(new WigglePostEffect()); ///updateable JointUpdateable ju = new JointUpdateable(this, fworld, this.World.Camera2D); base.LoadContent(GraphicInfo, factory, contentManager); }
protected override void LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, IContentManager contentManager) { base.LoadContent(GraphicInfo, factory, contentManager); #region Trigger ///Criacao de um Trigger ///Create a trigger { ///Modelo cujo formato sera utilizado para disparar o trigger ///Model used as base the for the trigger SimpleModel sm = new SimpleModel(factory, "..\\Content\\Model\\cubo"); sm.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Red), TextureType.DIFFUSE); ///VERMELHO ///Criacao do Triangle Mesh ///Create the triangle mesh from the model TriangleMeshObject tm = new TriangleMeshObject(sm, new Vector3(200, 5, 0), Matrix.Identity, Vector3.One * 10, MaterialDescription.DefaultBepuMaterial()); ///Criacao do Evento q sera disparado qd o trigger for acionado ///Pode-se criar outros tipos de eventos, basta extender a classe IEvent ///O parametro passado eh o canal em que o trigger enviara suas mensagens ///Qualquer Entidade que extende IRecieveMessageEntity pode receber mensagens ///Create the eventr that the trigger will fire ///TriggerEvent is the name of the CHANNEL (SEE CHANGINGMESSAGESSCREEN.CS) where the trigger will send the messages. (you can change the name at your will, change also the channel that the other objects are listening) TriggerEvent te = new TriggerEvent("TriggerEvent", "TriggerTest1"); ///Criacao do Trigger ///Creating and adding the trigger to the physic world BepuPhysicWorld physicWorld = this.World.PhysicWorld as BepuPhysicWorld; System.Diagnostics.Debug.Assert(physicWorld != null); ///Setting triggers configuration, IT RECIEVES A TRIANGLE MESH ///TRIGGERS ARE ALWAYS TRIANGLE MESHES !!!! BepuTrigger bt = new BepuTrigger(physicWorld, tm, te, true, true, true, true); ///Adiciona o trigger ao mundo this.World.AddTrigger(bt); ///Adicona um objeto na posicao do trigger (Objeto FANTASMA, nao sera detectado pelo trigger) ///Facilita na localizacao do Trigger ///CREATE A VISUAL OBJECT FOR THE TRIGGER (SO WE CAN SEE IT) ///GHOST OBJECT (NO COLLISION) GhostObject ghost = new GhostObject(new Vector3(200, 5, 0), Matrix.Identity, Vector3.One * 10); ///material and shader DeferredNormalShader shader = new DeferredNormalShader(); IMaterial mat = new DeferredMaterial(shader); /// add the visual object (DONT NEED, WE ADDED JUST TO SEE THE TRIGGER) IObject obj3 = new IObject(mat, sm, ghost); this.World.AddObject(obj3); } #endregion ///Criacao de um Objeto q recebera mensagens do trigger ///THIS OBJECT THAT WILL RECIEVE MESSAGE FROM the trigger #region Models { SimpleModel sm = new SimpleModel(factory, "..\\Content\\Model\\cubo"); sm.SetTexture(factory.CreateTexture2DColor(1, 1, Color.White), TextureType.DIFFUSE); ///BRANCO IPhysicObject pi = new TriangleMeshObject(sm, new Vector3(20, 50, 50), Matrix.Identity, Vector3.One * 10, MaterialDescription.DefaultBepuMaterial()); DeferredNormalShader shader = new DeferredNormalShader(); IMaterial mat = new DeferredMaterial(shader); IObject obj3 = new IObject(mat, sm, pi); ///Cadastra uma funcao para tratar das mensagens recebidas ///existem outras maneiras de fazer isso, como Extender a classe IObject e sobrescrever o metodo HandleMessage ///MESSAGE HANDLER obj3.OnRecieveMessage += new OnRecieveMessage(obj3_OnRecieveMessage); this.World.AddObject(obj3); ///Adiciona o Objeto criado ao grupo "TriggerEvent" que recebera as mensagens do trigger ///Register to recieve TriggerEvent Messages (registering to the channel) EntityMapper.getInstance().AddgrouptagRecieveEntity("TriggerEvent", obj3); } ///Cenario de sempre { 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(); IMaterial mat = new DeferredMaterial(shader); IObject obj3 = new IObject(mat, sm, pi); this.World.AddObject(obj3); } #endregion ///Demonstracao de que qualquer entidade pode receber mensagens ///Olhar a implementacao desta classe, esta no fim deste arquivo ///Creating an entity to recieve the trigger message also ///JUST to show that everyone can recieve messages rmessage = new ReciveMessage(); cam = new CameraFirstPerson(GraphicInfo); cam.FarPlane = 2000; lt = new LightThrowBepu(this.World, factory); #region NormalLight ///Conjunto de luzes direcionais 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 this.World.CameraManager.AddCamera(cam); }
protected override void LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, IContentManager contentManager) { ///Must be called before everything in the LoadContent base.LoadContent(GraphicInfo, factory, contentManager); ///Create a Simple Model IModelo sm = new SimpleModel(factory, "..\\Content\\Model\\cenario"); ///Create a Physic Object IPhysicObject pi = new TriangleMeshObject(sm, Vector3.Zero, Matrix.Identity, Vector3.One, MaterialDescription.DefaultBepuMaterial()); pi.isMotionLess = true; ///Create a shader IShader shader = new DeferredNormalShader(); ///Create a Material IMaterial mat = new DeferredMaterial(shader); ///Create a an Object that englobs everything and add it to the world IObject obj4 = new IObject(mat, sm, pi); this.World.AddObject(obj4); ///Create the Physic Objects { for (int i = 0; i < 15; i++) { CreateThrash(new Vector3(-70 + i * 5, 50, 10)); } for (int i = 0; i < 15; i++) { CreateBox(new Vector3(-70 + i * 7, 100, 50)); } for (int i = 0; i < 15; i++) { CreateThrash(new Vector3(-70 + i * 5, 80, 50)); } for (int i = 0; i < 15; i++) { CreateBall(new Vector3(-70 + i * 5, 50, 30)); } for (int i = 0; i < 15; i++) { CreateBox(new Vector3(-70 + i * 7, 130, -20)); } for (int i = 0; i < 15; i++) { CreateBox(new Vector3(-70 + i * 7, 60, -50)); } ///Create A Ghost Object (Do Not Collide) { ///Create a Simple Model SimpleModel model = new SimpleModel(factory, "..\\Content\\Model\\ball"); model.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Purple), TextureType.DIFFUSE); ///Create a Physic Object IPhysicObject pobj = new GhostObject(new Vector3(50, 13f, 50), Matrix.Identity, Vector3.One * 5); pobj.isMotionLess = true; ///Create a shader IShader nd = new DeferredNormalShader(); ///Create a Material IMaterial material = new DeferredMaterial(shader); ///Create a an Object that englobs everything and add it to the world IObject obj = new IObject(material, model, pobj); this.World.AddObject(obj); } } ///Call the function releaseObjects when Space key is pressed InputPlayableKeyBoard ip1 = new SimpleConcreteKeyboardInputPlayable(StateKey.PRESS, Microsoft.Xna.Framework.Input.Keys.Space, releaseObjects); ///Using the Global Method, need to release when screen is cleaned ///Check the KeyboardInputScreen for how to use it locally mm = new BindKeyCommand(ip1, BindAction.ADD); CommandProcessor.getCommandProcessor().SendCommandAssyncronous(mm); ///Create a FirstPerson Camera ///This is a special camera, used in the development ///You can move around using wasd / qz / and the mouse CameraFirstPerson cam = new CameraFirstPerson(GraphicInfo); this.World.CameraManager.AddCamera(cam); ///Create some directionals lights and add to the world DirectionalLightPE ld = new DirectionalLightPE(Vector3.Forward, Color.White); DirectionalLightPE ld2 = new DirectionalLightPE(Vector3.Left, Color.White); DirectionalLightPE ld3 = new DirectionalLightPE(Vector3.Down, Color.White); ld.LightIntensity = 0.5f; ld2.LightIntensity = 0.5f; ld3.LightIntensity = 0.5f; this.World.AddLight(ld); this.World.AddLight(ld2); this.World.AddLight(ld3); lightThrow = new LightThrowBepu(this.World, factory); this.RenderTechnic.AddPostEffect(new AntiAliasingPostEffect()); }
protected override void LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, PloobsEngine.SceneControl.IContentManager contentManager) { tile = factory.GetTexture2D("Textures/tile"); FarseerWorld fworld = this.World.PhysicWorld as FarseerWorld; ///border border = new Border(fworld, factory, GraphicInfo, factory.CreateTexture2DColor(1, 1, Color.Red)); ///from texture { Texture2D tex = factory.GetTexture2D("Textures//goo"); IModelo2D model = new SpriteFarseer(tex); Basic2DTextureMaterial mat = new Basic2DTextureMaterial(); FarseerObject fs = new FarseerObject(fworld, tex); I2DObject o = new I2DObject(fs, mat, model); o.Name = "Goo"; this.World.AddObject(o); } ///rectangle Vertices verts = PolygonTools.CreateRectangle(5, 5); { IModelo2D model = new SpriteFarseer(factory, verts, Color.Orange); Basic2DTextureMaterial mat = new Basic2DTextureMaterial(); FarseerObject fs = new FarseerObject(fworld, verts); I2DObject o = new I2DObject(fs, mat, model); o.Name = "Rectangle"; this.World.AddObject(o); } ///circle CircleShape circle = new CircleShape(5, 1); { IModelo2D model = new SpriteFarseer(factory, circle, Color.Orange); Basic2DTextureMaterial mat = new Basic2DTextureMaterial(); FarseerObject fs = new FarseerObject(fworld, circle); I2DObject o = new I2DObject(fs, mat, model); o.Name = "Circle"; this.World.AddObject(o); } ///camera this.World.Camera2D = new Camera2D(GraphicInfo); base.LoadContent(GraphicInfo, factory, contentManager); this.BindInput(new SimpleConcreteGestureInputPlayable(Microsoft.Xna.Framework.Input.Touch.GestureType.Tap, (sample) => { I2DPhysicObject obj = this.World.PhysicWorld.Picking(this.World.Camera2D.ConvertScreenToWorld(sample.Position)); if (obj != null) { pickedName = obj.Owner.Name + " " + sample.Position; } else { pickedName = null; } } )); }
protected override void LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, IContentManager contentManager) { base.LoadContent(GraphicInfo, factory, contentManager); { SimpleModel sm = new SimpleModel(factory, "..\\Content\\Model\\ball"); sm.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Blue), TextureType.DIFFUSE); IPhysicObject pi = new SphereObject(new Vector3(0, 0, 0), 1, 10, 30, MaterialDescription.DefaultBepuMaterial()); pi.isMotionLess = true; DeferredNormalShader shader = new DeferredNormalShader(); IMaterial mat = new DeferredMaterial(shader); IObject obj3 = new IObject(mat, sm, pi); this.World.AddObject(obj3); BepuPhysicWorld physicWorld; physicWorld = this.World.PhysicWorld as BepuPhysicWorld; System.Diagnostics.Debug.Assert(physicWorld != null); var field = new GravitationalFieldObject(new InfiniteForceFieldShape(), obj3.PhysicObject.Position, 66730 / 2f, 10000, physicWorld); ///This Method is from BepuPhysicWorld not from th IPhysicObject ///You can use everithing from Bepu using this object instead of the interface ///but take care, the engine dont know about THIS !!! it does not manage these things physicWorld.Space.Add(field); } int numColumns = 7; int numRows = 7; int numHigh = 7; float separation = 3; for (int i = 0; i < numRows; i++) { for (int j = 0; j < numColumns; j++) { for (int k = 0; k < numHigh; k++) { SimpleModel sm = new SimpleModel(factory, "..\\Content\\Model\\cubo"); sm.SetTexture(factory.CreateTexture2DColor(1, 1, Color.White), TextureType.DIFFUSE); BoxObject pi = new BoxObject(new Vector3(separation * i - numRows * separation / 2, 40 + k * separation, separation * j - numColumns * separation / 2), 1, 1, 1, 5, new Vector3(1), Matrix.Identity, MaterialDescription.DefaultBepuMaterial()); pi.Entity.LinearDamping = 0; pi.Entity.AngularDamping = 0; DeferredNormalShader shader = new DeferredNormalShader(); IMaterial mat = new DeferredMaterial(shader); IObject obj3 = new IObject(mat, sm, pi); this.World.AddObject(obj3); pi.Entity.LinearVelocity = new Vector3(30, 0, 0); } } } cam = new CameraFirstPerson(GraphicInfo); cam.FarPlane = 3000; 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.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 this.World.CameraManager.AddCamera(cam); }
protected override void LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, IContentManager contentManager) { base.LoadContent(GraphicInfo, factory, contentManager); #region Models ///Some Physic World Parameters ///No accuracy (speed up the simulation) and no gravity BepuPhysicWorld physicWorld = this.World.PhysicWorld as BepuPhysicWorld; System.Diagnostics.Debug.Assert(physicWorld != null); physicWorld.Space.Solver.IterationLimit = 1; //Essentially no sustained contacts, so don't need to worry about accuracy. int numColumns = 10; int numRows = 10; int numHigh = 15; ///1500 box ///1500 luzes ///CREATE LOOOOTS OF OBJECTS AND LIGHTS float separation = 3; for (int i = 0; i < numRows; i++) { for (int j = 0; j < numColumns; j++) { for (int k = 0; k < numHigh; k++) { SimpleModel sm = new SimpleModel(factory, "..\\Content\\Model\\cubo"); sm.SetTexture(factory.CreateTexture2DColor(1, 1, StaticRandom.RandomColor()), TextureType.DIFFUSE); MaterialDescription md = MaterialDescription.DefaultBepuMaterial(); md.Bounciness = 1; BoxObject pi = new BoxObject(new Vector3(separation * i, k * separation, separation * j), 1, 1, 1, 1, new Vector3(1), Matrix.Identity, md); pi.Entity.AngularDamping = 0f; //It looks cooler if boxes don't slowly stop spinning! IShader shader = new DeferredNormalShader(); IMaterial mat = new DeferredMaterial(shader); IObject obj5 = new IObject(mat, sm, pi); this.World.AddObject(obj5); ///Light is atached to the blocks MoveablePointLight pl = new MoveablePointLight(pi, StaticRandom.RandomColor(), 5, 1); this.World.AddLight(pl); } } } #endregion cam = new CameraFirstPerson(GraphicInfo); cam.FarPlane = 3000; this.World.CameraManager.AddCamera(cam); ///THROW THE BALLS IN THE BLOCKS !!!!!! 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.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 }