Beispiel #1
0
        /// <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);

            List <IObject> balls = new List <IObject>();
            Vector3        pos1, pos2;

            pos1 = new Vector3(0, 20, 0);
            pos2 = new Vector3(0, -50, 0);

            IObject ball1 = CreateSphere(pos1, Matrix.Identity, Color.Red);

            ball1.PhysicObject.isMotionLess = true; // Setting the Parent object as static

            World.AddObject(ball1);

            IObject ball2 = CreateSphere(pos2, Matrix.Identity, Color.White);

            World.AddObject(ball2);
            balls.Add(ball2);

            constraint = new PointPointConstraint((pos1 + pos2) / 2, ball1.PhysicObject, ball2.PhysicObject);


            World.PhysicWorld.AddConstraint(constraint);


            ///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

            lt       = new LightThrowBepu(this.World, factory);
            lt.force = 60;

            ///add a camera
            this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo));
        }
Beispiel #2
0
        protected override void  LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, IContentManager contentManager)
        {
            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);

            lt = new LightThrowBepu(this.World, factory);

            ///Create a FirstPerson Camera
            ///This is a special camera, used in the development
            ///You can move around using wasd / qz / and the mouse
            ICamera cam = new CameraFirstPerson(GraphicInfo);

            this.World.CameraManager.AddCamera(cam);

            PointLightCircularUpdater lcu = new PointLightCircularUpdater(this);

            ///Create 100 moving point lights and add to the world
            ///IF the radius of the point light is TOO big like 250, it will make the game slower
            for (int i = 0; i < 10; i++)
            {
                for (int j = 0; j < 10; j++)
                {
                    PointLightPE pl0 = new PointLightPE(new Vector3(i * 5, 25, j * 5), StaticRandom.RandomColor(), 100, 2);
                    pl0.UsePointLightQuadraticAttenuation = true;
                    lcu.AddLight(pl0, 0.01f, 50 * i, j / StaticRandom.Random());
                    this.World.AddLight(pl0);
                }
            }

            lcu.Start();
            this.RenderTechnic.AddPostEffect(new AntiAliasingPostEffect());
        }
        protected override void  LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, IContentManager contentManager)
        {
 	        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);

            lt = new LightThrowBepu(this.World, factory);  

            ///Create a FirstPerson Camera
            ///This is a special camera, used in the development
            ///You can move around using wasd / qz / and the mouse
            ICamera cam = new CameraFirstPerson(GraphicInfo);
            this.World.CameraManager.AddCamera(cam);

            PointLightCircularUpdater lcu = new PointLightCircularUpdater(this);

            ///Create 100 moving point lights and add to the world
            ///IF the radius of the point light is TOO big like 250, it will make the game slower
            for (int i = 0; i < 10; i++)
            {
                for (int j = 0; j < 10; j++)
                {
                    PointLightPE pl0 = new PointLightPE(new Vector3(i * 5, 25, j * 5), StaticRandom.RandomColor(), 100, 2);
                    pl0.UsePointLightQuadraticAttenuation = true;
                    lcu.AddLight(pl0, 0.01f, 50 * i, j / StaticRandom.Random());                    
                    this.World.AddLight(pl0);
                }
            }

            lcu.Start();
            this.RenderTechnic.AddPostEffect(new AntiAliasingPostEffect());
        }
        protected override void  LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, IContentManager contentManager)
        {
            base.LoadContent(GraphicInfo, factory, contentManager);
            
            #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();
                shader.SpecularIntensity = 0;
                shader.SpecularPower = 0;                
                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
            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);            
            

            ///Bind a Key event (combination of Key + state(pressed, Released ...) + inputMask ) to a function
            SimpleConcreteKeyboardInputPlayable ik1 = new SimpleConcreteKeyboardInputPlayable(StateKey.PRESS, Keys.T,g1, InputMask.G1);
            ///When you use the method Bind of a IScreen, The key event will be sent by the engine while this screen remains added in the ScreenManager.
            ///TO create a Gloal Input (Keep working even if the screen goes away), see the DemosHomeScreen.cs
            this.BindInput(ik1);            
           
            SimpleConcreteKeyboardInputPlayable ik2 = new SimpleConcreteKeyboardInputPlayable(StateKey.PRESS, Keys.Y, g2,InputMask.G2);
            this.BindInput(ik2);
            
            ///The SYSTEM Mask is Always On (cant be turned off)
            SimpleConcreteKeyboardInputPlayable ik3 = new SimpleConcreteKeyboardInputPlayable(StateKey.PRESS, Keys.Space, ChangeGroup,InputMask.GSYSTEM);
            this.BindInput(ik3);            
            
            ///StateKey.DOWN mean when the key is down the event will be fired --looooots of times(samae as UP)
            ///StateKey.PRESS is fired ONCE when the key is pressed (same as RELEASE)
            ///WHEN USING COMBOS, use DOWN AND UP (better for precision)
            ///The parameter EntityType is not used internaly 
            SimpleConcreteKeyboardInputPlayable ik4 = new SimpleConcreteKeyboardInputPlayable(StateKey.DOWN, new Keys[] { Keys.LeftControl, Keys.U }, Multiple);
            this.BindInput(ik4);

            ///Send a command (design pattern) to the InputSystem to change the InputMask            
            TurnOnInputMaskCommand tom = new TurnOnInputMaskCommand(InputMask.GALL);
            CommandProcessor.getCommandProcessor().SendCommandAssyncronous(tom);

            isAllActive = true;

            this.RenderTechnic.AddPostEffect(new AntiAliasingPostEffect());
        }
        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, IContentManager contentManager)
        {
            base.LoadContent(GraphicInfo, factory, contentManager);

            #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();
                shader.SpecularIntensity = 0;
                shader.SpecularPower     = 0;
                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
            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);


            ///Bind a Key event (combination of Key + state(pressed, Released ...) + inputMask ) to a function
            SimpleConcreteKeyboardInputPlayable ik1 = new SimpleConcreteKeyboardInputPlayable(StateKey.PRESS, Keys.T, g1, InputMask.G1);
            ///When you use the method Bind of a IScreen, The key event will be sent by the engine while this screen remains added in the ScreenManager.
            ///TO create a Gloal Input (Keep working even if the screen goes away), see the DemosHomeScreen.cs
            this.BindInput(ik1);

            SimpleConcreteKeyboardInputPlayable ik2 = new SimpleConcreteKeyboardInputPlayable(StateKey.PRESS, Keys.Y, g2, InputMask.G2);
            this.BindInput(ik2);

            ///The SYSTEM Mask is Always On (cant be turned off)
            SimpleConcreteKeyboardInputPlayable ik3 = new SimpleConcreteKeyboardInputPlayable(StateKey.PRESS, Keys.Space, ChangeGroup, InputMask.GSYSTEM);
            this.BindInput(ik3);

            ///StateKey.DOWN mean when the key is down the event will be fired --looooots of times(samae as UP)
            ///StateKey.PRESS is fired ONCE when the key is pressed (same as RELEASE)
            ///WHEN USING COMBOS, use DOWN AND UP (better for precision)
            ///The parameter EntityType is not used internaly
            SimpleConcreteKeyboardInputPlayable ik4 = new SimpleConcreteKeyboardInputPlayable(StateKey.DOWN, new Keys[] { Keys.LeftControl, Keys.U }, Multiple);
            this.BindInput(ik4);

            ///Send a command (design pattern) to the InputSystem to change the InputMask
            TurnOnInputMaskCommand tom = new TurnOnInputMaskCommand(InputMask.GALL);
            CommandProcessor.getCommandProcessor().SendCommandAssyncronous(tom);

            isAllActive = true;

            this.RenderTechnic.AddPostEffect(new AntiAliasingPostEffect());
        }
        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)
        {
            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());
            ///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);

            lt = new LightThrowBepu(this.World,factory);

            ///Create a FirstPerson Camera
            ///This is a special camera, used in the development
            ///You can move around using wasd / qz / and the mouse
            ICamera cam = new CameraFirstPerson(GraphicInfo);
            this.World.CameraManager.AddCamera(cam);

            {
                SpotLightPE sp1 = new SpotLightPE(new Vector3(0, 150, 0), new Vector3(0, -1, 0), Color.YellowGreen, 1, 600, (float)Math.Cos(Math.PI / 7), 0.5f);
                SpotLightCircularUpdater spc1 = new SpotLightCircularUpdater(this, sp1, 0.01f, 1, 0, true);
                this.World.AddLight(sp1);

                SpotLightPE sp2 = new SpotLightPE(new Vector3(0, 150, 0), new Vector3(0, -1, 0),Color.Red, 1, 600, (float)Math.Cos(Math.PI / 7), 0.5f);
                SpotLightCircularUpdater spc2 = new SpotLightCircularUpdater(this, sp2, 0.01f, 1, (float)Math.PI / 2, true);
                this.World.AddLight(sp2);

                SpotLightPE sp3 = new SpotLightPE(new Vector3(0, 150, 0), new Vector3(0, -1, 0), Color.Red, 1, 600, (float)Math.Cos(Math.PI / 7), 0.5f);
                SpotLightCircularUpdater spc3 = new SpotLightCircularUpdater(this, sp3, 0.01f, 1, (float)Math.PI, true);
                this.World.AddLight(sp3);

                SpotLightPE sp4 = new SpotLightPE(new Vector3(0, 150, 0), new Vector3(0, -1, 0), Color.Green, 1, 600, (float)Math.Cos(Math.PI / 7), 0.5f);
                SpotLightCircularUpdater spc4 = new SpotLightCircularUpdater(this, sp4, 0.01f, 1, (float)(Math.PI * 3) / 2, true);
                this.World.AddLight(sp4);
            }

            {
                SpotLightPE sp1 = new SpotLightPE(new Vector3(0, 150, 0), new Vector3(0, -1, 0), Color.Purple, 1, 600, (float)Math.Cos(Math.PI / 7), 0.5f);
                SpotLightCircularUpdater spc1 = new SpotLightCircularUpdater(this, sp1, 0.02f, 2, 0, false);
                this.World.AddLight(sp1);

                SpotLightPE sp2 = new SpotLightPE(new Vector3(0, 150, 0), new Vector3(0, -1, 0), Color.PowderBlue, 1, 600, (float)Math.Cos(Math.PI / 7), 0.5f);
                SpotLightCircularUpdater spc2 = new SpotLightCircularUpdater(this, sp2, 0.02f, 2, (float)Math.PI / 2, false);
                this.World.AddLight(sp2);

                SpotLightPE sp3 = new SpotLightPE(new Vector3(0, 150, 0), new Vector3(0, -1, 0),Color.YellowGreen, 1, 600 , (float)Math.Cos(Math.PI / 7), 0.5f);
                SpotLightCircularUpdater spc3 = new SpotLightCircularUpdater(this, sp3, 0.02f, 2, (float)Math.PI, false);
                this.World.AddLight(sp3);

                SpotLightPE sp4 = new SpotLightPE(new Vector3(0, 150, 0), new Vector3(0, -1, 0), Color.Maroon, 1, 600, (float)Math.Cos(Math.PI / 7), 0.5f);
                SpotLightCircularUpdater spc4 = new SpotLightCircularUpdater(this, sp4, 0.02f, 2, (float)(Math.PI * 3) / 2, false);
                this.World.AddLight(sp4);
            }


            {
                SpotLightPE sp1 = new SpotLightPE(new Vector3(0, 150, 0), new Vector3(0, -1, 0), Color.PapayaWhip,1, 600 , (float)Math.Cos(Math.PI / 7), 0.5f);
                SpotLightCircularUpdater spc1 = new SpotLightCircularUpdater(this, sp1, 0.03f, 3, (float)Math.PI / 4, true);
                this.World.AddLight(sp1);

                SpotLightPE sp2 = new SpotLightPE(new Vector3(0, 150, 0), new Vector3(0, -1, 0), Color.LightSeaGreen, 1, 600, (float)Math.Cos(Math.PI / 7), 0.5f);
                SpotLightCircularUpdater spc2 = new SpotLightCircularUpdater(this, sp2, 0.03f, 3, (float)Math.PI / 4 + (float)Math.PI / 2, true);
                this.World.AddLight(sp2);

                SpotLightPE sp3 = new SpotLightPE(new Vector3(0, 150, 0), new Vector3(0, -1, 0), Color.Gold, 1, 600, (float)Math.Cos(Math.PI / 7), 0.5f);
                SpotLightCircularUpdater spc3 = new SpotLightCircularUpdater(this, sp3, 0.03f, 3, (float)Math.PI / 4 + (float)Math.PI, true);
                this.World.AddLight(sp3);

                SpotLightPE sp4 = new SpotLightPE(new Vector3(0, 150, 0), new Vector3(0, -1, 0), Color.Aqua,1, 600 , (float)Math.Cos(Math.PI / 7), 0.5f);
                SpotLightCircularUpdater spc4 = new SpotLightCircularUpdater(this, sp4, 0.03f, 3, (float)Math.PI / 4 + (float)(Math.PI * 3) / 2, true);
                this.World.AddLight(sp4);
            }

            this.RenderTechnic.AddPostEffect(new AntiAliasingPostEffect());
        }
        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, 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());
        }
        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);
            
        }
Beispiel #12
0
        protected override void LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, IContentManager contentManager)
        {
            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());
            ///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);

            lt = new LightThrowBepu(this.World, factory);

            ///Create a FirstPerson Camera
            ///This is a special camera, used in the development
            ///You can move around using wasd / qz / and the mouse
            ICamera cam = new CameraFirstPerson(GraphicInfo);

            this.World.CameraManager.AddCamera(cam);

            {
                SpotLightPE sp1 = new SpotLightPE(new Vector3(0, 150, 0), new Vector3(0, -1, 0), Color.YellowGreen, 1, 600, (float)Math.Cos(Math.PI / 7), 0.5f);
                SpotLightCircularUpdater spc1 = new SpotLightCircularUpdater(this, sp1, 0.01f, 1, 0, true);
                this.World.AddLight(sp1);

                SpotLightPE sp2 = new SpotLightPE(new Vector3(0, 150, 0), new Vector3(0, -1, 0), Color.Red, 1, 600, (float)Math.Cos(Math.PI / 7), 0.5f);
                SpotLightCircularUpdater spc2 = new SpotLightCircularUpdater(this, sp2, 0.01f, 1, (float)Math.PI / 2, true);
                this.World.AddLight(sp2);

                SpotLightPE sp3 = new SpotLightPE(new Vector3(0, 150, 0), new Vector3(0, -1, 0), Color.Red, 1, 600, (float)Math.Cos(Math.PI / 7), 0.5f);
                SpotLightCircularUpdater spc3 = new SpotLightCircularUpdater(this, sp3, 0.01f, 1, (float)Math.PI, true);
                this.World.AddLight(sp3);

                SpotLightPE sp4 = new SpotLightPE(new Vector3(0, 150, 0), new Vector3(0, -1, 0), Color.Green, 1, 600, (float)Math.Cos(Math.PI / 7), 0.5f);
                SpotLightCircularUpdater spc4 = new SpotLightCircularUpdater(this, sp4, 0.01f, 1, (float)(Math.PI * 3) / 2, true);
                this.World.AddLight(sp4);
            }

            {
                SpotLightPE sp1 = new SpotLightPE(new Vector3(0, 150, 0), new Vector3(0, -1, 0), Color.Purple, 1, 600, (float)Math.Cos(Math.PI / 7), 0.5f);
                SpotLightCircularUpdater spc1 = new SpotLightCircularUpdater(this, sp1, 0.02f, 2, 0, false);
                this.World.AddLight(sp1);

                SpotLightPE sp2 = new SpotLightPE(new Vector3(0, 150, 0), new Vector3(0, -1, 0), Color.PowderBlue, 1, 600, (float)Math.Cos(Math.PI / 7), 0.5f);
                SpotLightCircularUpdater spc2 = new SpotLightCircularUpdater(this, sp2, 0.02f, 2, (float)Math.PI / 2, false);
                this.World.AddLight(sp2);

                SpotLightPE sp3 = new SpotLightPE(new Vector3(0, 150, 0), new Vector3(0, -1, 0), Color.YellowGreen, 1, 600, (float)Math.Cos(Math.PI / 7), 0.5f);
                SpotLightCircularUpdater spc3 = new SpotLightCircularUpdater(this, sp3, 0.02f, 2, (float)Math.PI, false);
                this.World.AddLight(sp3);

                SpotLightPE sp4 = new SpotLightPE(new Vector3(0, 150, 0), new Vector3(0, -1, 0), Color.Maroon, 1, 600, (float)Math.Cos(Math.PI / 7), 0.5f);
                SpotLightCircularUpdater spc4 = new SpotLightCircularUpdater(this, sp4, 0.02f, 2, (float)(Math.PI * 3) / 2, false);
                this.World.AddLight(sp4);
            }


            {
                SpotLightPE sp1 = new SpotLightPE(new Vector3(0, 150, 0), new Vector3(0, -1, 0), Color.PapayaWhip, 1, 600, (float)Math.Cos(Math.PI / 7), 0.5f);
                SpotLightCircularUpdater spc1 = new SpotLightCircularUpdater(this, sp1, 0.03f, 3, (float)Math.PI / 4, true);
                this.World.AddLight(sp1);

                SpotLightPE sp2 = new SpotLightPE(new Vector3(0, 150, 0), new Vector3(0, -1, 0), Color.LightSeaGreen, 1, 600, (float)Math.Cos(Math.PI / 7), 0.5f);
                SpotLightCircularUpdater spc2 = new SpotLightCircularUpdater(this, sp2, 0.03f, 3, (float)Math.PI / 4 + (float)Math.PI / 2, true);
                this.World.AddLight(sp2);

                SpotLightPE sp3 = new SpotLightPE(new Vector3(0, 150, 0), new Vector3(0, -1, 0), Color.Gold, 1, 600, (float)Math.Cos(Math.PI / 7), 0.5f);
                SpotLightCircularUpdater spc3 = new SpotLightCircularUpdater(this, sp3, 0.03f, 3, (float)Math.PI / 4 + (float)Math.PI, true);
                this.World.AddLight(sp3);

                SpotLightPE sp4 = new SpotLightPE(new Vector3(0, 150, 0), new Vector3(0, -1, 0), Color.Aqua, 1, 600, (float)Math.Cos(Math.PI / 7), 0.5f);
                SpotLightCircularUpdater spc4 = new SpotLightCircularUpdater(this, sp4, 0.03f, 3, (float)Math.PI / 4 + (float)(Math.PI * 3) / 2, true);
                this.World.AddLight(sp4);
            }

            this.RenderTechnic.AddPostEffect(new AntiAliasingPostEffect());
        }
        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);            

            #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

        }
        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)
        {
            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, 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);

            #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());
        }
Beispiel #19
0
        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());
        }
        /// <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);
            
            List<IObject> balls = new List<IObject>();
            Vector3 pos1,pos2;
            pos1 = new Vector3(0, 20, 0);
            pos2 = new Vector3(0,-50,0);

            IObject ball1 = CreateSphere(pos1, Matrix.Identity, Color.Red);
            ball1.PhysicObject.isMotionLess = true; // Setting the Parent object as static

            World.AddObject(ball1);

            IObject ball2 = CreateSphere(pos2,Matrix.Identity,Color.White);
            World.AddObject(ball2);
            balls.Add(ball2);

            constraint = new PointPointConstraint((pos1 + pos2) / 2, ball1.PhysicObject, ball2.PhysicObject);


            World.PhysicWorld.AddConstraint(constraint);


            ///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

            lt = new LightThrowBepu(this.World, factory);
            lt.force = 60;

            ///add a camera
            this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo));
        }
Beispiel #21
0
        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
        }