예제 #1
0
 /// <summary>
 /// Initiates the specified Post Effect.
 /// Called by the engine
 /// </summary>
 /// <param name="ginfo">The ginfo.</param>
 /// <param name="factory">The factory.</param>
 public override void Init(PloobsEngine.Engine.GraphicInfo ginfo, PloobsEngine.Engine.GraphicFactory factory)
 {
     this.info    = ginfo;
     this.factory = factory;
     rt           = factory.CreateRenderTarget(ginfo.BackBufferWidth, ginfo.BackBufferHeight);
     rtend        = factory.CreateRenderTarget(ginfo.BackBufferWidth, ginfo.BackBufferHeight);
     ginfo.OnGraphicInfoChange += ginfo_OnGraphicInfoChange;
     Amount = 100;
 }
    protected override void LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, IContentManager contentManager)
    {
        base.LoadContent(GraphicInfo, factory, contentManager);

        #region Models

        createobjs();

        ///Some Physic World Parameters
        ///No accuracy (speed up the simulation) and no gravity
        BepuPhysicWorld physicWorld = this.World.PhysicWorld as BepuPhysicWorld;
        physicWorld.Space.Solver.IterationLimit = 1; //Essentially no sustained contacts, so don't need to worry about accuracy.


        {
            SimpleModel sm = new SimpleModel(factory, "..\\Content\\Model\\cubo");
            sm.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Blue), TextureType.DIFFUSE);
            MaterialDescription md = MaterialDescription.DefaultBepuMaterial();
            md.Bounciness = 1;
            BoxObject pi = new BoxObject(new Vector3(0, -30, 0), 1, 1, 1, 1, new Vector3(50, 1, 50), Matrix.Identity, md);
            pi.isMotionLess          = true;
            pi.Entity.AngularDamping = 0f;
            ForwardXNABasicShader shader = new ForwardXNABasicShader();
            IMaterial             mat    = new ForwardMaterial(shader);
            IObject obj5 = new IObject(mat, sm, pi);
            this.World.AddObject(obj5);
            shader.BasicEffect.EnableDefaultLighting();
        }

        #endregion



        cam = new RotatingCamera(this);
        this.World.CameraManager.AddCamera(cam);
    }
예제 #3
0
        protected override void LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, PloobsEngine.SceneControl.IContentManager contentManager)
        {
            FarseerWorld fworld = this.World.PhysicWorld as FarseerWorld;

            ///border
            border = new Border(fworld, factory, GraphicInfo, factory.CreateTexture2DColor(1, 1, Color.Red));

            ///from texture
            //{
            //    Texture2D tex = factory.GetTexture2D("Textures//goo");
            //    IModelo2D model = new SpriteFarseer(tex);
            //    Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
            //    FarseerObject fs = new FarseerObject(fworld, tex);
            //    I2DObject o = new I2DObject(fs, mat, model);
            //    this.World.AddObject(o);
            //}

            ///from texture, scale usage sample
            //{
            //    Texture2D tex = factory.GetTexture2D("Textures//goo");
            //    tex = factory.GetScaledTexture(tex, new Vector2(2));
            //    IModelo2D model = new SpriteFarseer(tex);
            //    Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
            //    FarseerObject fs = new FarseerObject(fworld, tex);
            //    I2DObject o = new I2DObject(fs, mat, model);
            //    this.World.AddObject(o);
            //}

            ///rectangle
            Vertices verts = PolygonTools.CreateRectangle(5, 5);
            {
                IModelo2D model            = new SpriteFarseer(factory, verts, Color.Orange);
                Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
                FarseerObject          fs  = new FarseerObject(fworld, verts);
                I2DObject o = new I2DObject(fs, mat, model);
                this.World.AddObject(o);
            }

            ///circle
            CircleShape circle = new CircleShape(5, 1);

            {
                IModelo2D model            = new SpriteFarseer(factory, circle, Color.Orange);
                Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
                FarseerObject          fs  = new FarseerObject(fworld, circle);
                I2DObject o = new I2DObject(fs, mat, model);
                this.World.AddObject(o);
            }

            {
                PointLight2D l = new PointLight2D(new Vector2(-GraphicInfo.BackBufferWidth / 4, -GraphicInfo.BackBufferWidth / 4), Color.Red, 1);
                this.World.AddLight(l);
            }

            {
                SpotLight2D l = new SpotLight2D(new Vector2(+GraphicInfo.BackBufferWidth / 4, -GraphicInfo.BackBufferWidth / 4), Color.Blue, new Vector2(0, 1), MathHelper.ToRadians(45));
                this.World.AddLight(l);
            }

            ///camera
            this.World.Camera2D = new Camera2D(GraphicInfo);

            ///add a post effect =P
            //this.RenderTechnic.AddPostEffect(new WigglePostEffect());

            ///updateable
            JointUpdateable ju = new JointUpdateable(this, fworld, this.World.Camera2D);

            base.LoadContent(GraphicInfo, factory, contentManager);
        }
예제 #4
0
        protected override void LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, IContentManager contentManager)
        {
            base.LoadContent(GraphicInfo, factory, contentManager);

            ///Cenario
            SimpleModel sm = new SimpleModel(factory, "..\\Content\\Model\\cenario");

            IShader normal = new DeferredNormalShader();

            IMaterial     mat = new DeferredMaterial(normal);
            IPhysicObject pi  = new TriangleMeshObject(sm, new Vector3(0, 10, 100), Matrix.Identity, Vector3.One, MaterialDescription.DefaultBepuMaterial());

            pi.isMotionLess = true;
            IObject obj4 = new IObject(mat, sm, pi);

            this.World.AddObject(obj4);

            ///Luzes
            DirectionalLightPE ld = new DirectionalLightPE(new Vector3(4, -2, 7), Color.White);

            this.World.AddLight(ld);

            ///Camera basica
            ICamera cam = new CameraFirstPerson(GraphicInfo);

            cam.Name = "stdCam";

            this.World.CameraManager.AddCamera(cam);


            ///Associando callbacks com eventos do teclado
            {
                InputPlayableKeyBoard ipp = new SimpleConcreteKeyboardInputPlayable(StateKey.PRESS, Keys.R, Start);
                bkk0 = new BindKeyCommand(ipp, BindAction.ADD);
                CommandProcessor.getCommandProcessor().SendCommandAssyncronous(bkk0);

                InputPlayableKeyBoard ipp2 = new SimpleConcreteKeyboardInputPlayable(StateKey.PRESS, Keys.T, Stop);
                bkk1 = new BindKeyCommand(ipp2, BindAction.ADD);
                CommandProcessor.getCommandProcessor().SendCommandAssyncronous(bkk1);

                InputPlayableKeyBoard ipp3 = new SimpleConcreteKeyboardInputPlayable(StateKey.PRESS, Keys.Y, Load);
                bkk2 = new BindKeyCommand(ipp3, BindAction.ADD);
                CommandProcessor.getCommandProcessor().SendCommandAssyncronous(bkk2);
            }

            ///Camera Recorder (objeto q gravara e carregara os caminhos)
            record = new CameraRecordPath(this, cam);
            record.FinishInTheStartPosition = true;
        }
        protected override void LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, IContentManager contentManager)
        {
            base.LoadContent(GraphicInfo, factory, contentManager);

            Picking picking = new Picking(this);

            this.AddScreenUpdateable(picking);

            #region Models
            {
                SimpleModel          sm     = new SimpleModel(factory, "..\\Content\\Model\\cenario");
                IPhysicObject        pi     = new TriangleMeshObject(sm, Vector3.Zero, Matrix.Identity, Vector3.One, MaterialDescription.DefaultBepuMaterial());
                DeferredNormalShader shader = new DeferredNormalShader();
                IMaterial            mat    = new DeferredMaterial(shader);
                IObject obj3 = new IObject(mat, sm, pi);
                obj3.Name = "cenario";
                this.World.AddObject(obj3);
            }

            for (int i = 0; i < 10; i++)
            {
                for (int j = 0; j < 10; j++)
                {
                    SimpleModel sm = new SimpleModel(factory, "..\\Content\\Model\\cubo");
                    sm.SetTexture(factory.CreateTexture2DColor(1, 1, Color.White), TextureType.DIFFUSE);
                    BoxObject pi = new BoxObject(new Vector3(i * 10, 100, j * 10), 1, 1, 1, 1, new Vector3(5), Matrix.Identity, MaterialDescription.DefaultBepuMaterial());
                    pi.isMotionLess = true;
                    DeferredNormalShader shader = new DeferredNormalShader();
                    IMaterial            mat    = new DeferredMaterial(shader);
                    IObject obj4 = new IObject(mat, sm, pi);
                    obj4.Name = "Block " + i + " : " + j;
                    this.World.AddObject(obj4);
                }
            }

            #endregion

            cam          = new CameraFirstPerson(GraphicInfo);
            cam.FarPlane = 3000;

            #region NormalLight
            ///Conjunto de luzes direcionais
            DirectionalLightPE ld1 = new DirectionalLightPE(Vector3.Left, Color.White);
            DirectionalLightPE ld2 = new DirectionalLightPE(Vector3.Right, Color.White);
            DirectionalLightPE ld3 = new DirectionalLightPE(Vector3.Backward, Color.White);
            DirectionalLightPE ld4 = new DirectionalLightPE(Vector3.Forward, Color.White);
            DirectionalLightPE ld5 = new DirectionalLightPE(Vector3.Down, Color.White);
            float li = 0.2f;
            ld1.LightIntensity = li;
            ld2.LightIntensity = li;
            ld3.LightIntensity = li;
            ld4.LightIntensity = li;
            ld5.LightIntensity = li;
            this.World.AddLight(ld1);
            this.World.AddLight(ld2);
            this.World.AddLight(ld3);
            this.World.AddLight(ld4);
            this.World.AddLight(ld5);
            #endregion


            this.World.CameraManager.AddCamera(cam);
            picking.OnPickedNoneButton += new OnPicked(onPick);

            sp1 = new SpotLightPE(new Vector3(0, 150, 0), new Vector3(0, -1, 0), Color.PapayaWhip, 1, 200, (float)Math.Cos(Math.PI / 12), 2f);
            this.World.AddLight(sp1);
        }
        protected override void  LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, IContentManager contentManager)
        {
            base.LoadContent(GraphicInfo, factory, contentManager);

            for (int i = 0; i < totalDemos; i++)
            {
                screenList.SetValue(i, i);
            }

            {
                SimpleConcreteKeyboardInputPlayable ik = new SimpleConcreteKeyboardInputPlayable(StateKey.PRESS, Keys.F1, ChangeDemo);
                BindKeyCommand bk = new BindKeyCommand(ik, BindAction.ADD);
                CommandProcessor.getCommandProcessor().SendCommandAssyncronous(bk);
            }
            {
                SimpleConcreteKeyboardInputPlayable ik = new SimpleConcreteKeyboardInputPlayable(StateKey.PRESS, Keys.Escape, LeaveGame);
                BindKeyCommand bk = new BindKeyCommand(ik, BindAction.ADD);
                CommandProcessor.getCommandProcessor().SendCommandAssyncronous(bk);
            }
        }
예제 #7
0
        protected override void LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, PloobsEngine.SceneControl.IContentManager contentManager)
        {
            tile = factory.GetTexture2D("Textures/tile");


            FarseerWorld fworld = this.World.PhysicWorld as FarseerWorld;

            ///border
            border = new Border(fworld, factory, GraphicInfo, factory.CreateTexture2DColor(1, 1, Color.Red));

            ///from texture
            {
                Texture2D tex              = factory.GetTexture2D("Textures//goo");
                IModelo2D model            = new SpriteFarseer(tex);
                Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
                FarseerObject          fs  = new FarseerObject(fworld, tex);
                I2DObject o = new I2DObject(fs, mat, model);
                o.OnHasMoved += new PloobsEngine.SceneControl._2DScene.OnHasMoved(o_OnHasMoved);
                this.World.AddObject(o);
            }

            ///from texture, scale usage sample
            {
                Texture2D tex = factory.GetTexture2D("Textures//goo");
                tex = factory.GetScaledTexture(tex, new Vector2(2));
                IModelo2D model            = new SpriteFarseer(tex);
                Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
                FarseerObject          fs  = new FarseerObject(fworld, tex);
                I2DObject o = new I2DObject(fs, mat, model);
                this.World.AddObject(o);
            }

            ///rectangle
            Vertices verts = PolygonTools.CreateRectangle(5, 5);
            {
                IModelo2D model            = new SpriteFarseer(factory, verts, Color.Orange);
                Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
                FarseerObject          fs  = new FarseerObject(fworld, verts);
                I2DObject o = new I2DObject(fs, mat, model);
                this.World.AddObject(o);
            }

            ///circle
            CircleShape circle = new CircleShape(5, 1);

            {
                IModelo2D model            = new SpriteFarseer(factory, circle, Color.Orange);
                Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
                FarseerObject          fs  = new FarseerObject(fworld, circle);
                I2DObject o = new I2DObject(fs, mat, model);
                this.World.AddObject(o);
            }

            ///camera
            this.World.Camera2D = new Camera2D(GraphicInfo);

            DPFSParticleSystem ps = new DPFSParticleSystem("TESTE", new SpriteParticleSystem(null));

            this.World.ParticleManager.AddAndInitializeParticleSystem(ps);

            ///add a post effect =P
            //this.RenderTechnic.AddPostEffect(new WigglePostEffect());

            ///updateable
            JointUpdateable ju = new JointUpdateable(this, fworld, this.World.Camera2D);

            base.LoadContent(GraphicInfo, factory, contentManager);
        }
 protected override void LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory)
 {
     this.GraphicInfo           = GraphicInfo;
     basicEffect                = factory.GetBasicEffect();
     basicEffect.TextureEnabled = true;
     spriteBatch                = factory.GetSpriteBatch();
     base.LoadContent(GraphicInfo, factory);
 }
        protected override void LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, IContentManager contentManager)
        {
            base.LoadContent(GraphicInfo, factory, contentManager);

            #region Models
            {
                simpleModel = new SimpleModel(factory, "..\\Content\\Model\\teapot");
                simpleModel.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Red), TextureType.DIFFUSE);

                GhostObject tmesh = new GhostObject(Vector3.Zero, Matrix.Identity, Vector3.One * 2);
                ///Environment Map Shader, there are 2 options, the first is a fully reflective surface (dont use the object texture) and the second
                ///is a mix of the object texture and the environment texture
                ///Used to fake ambient reflection, give metal appearence to an object ....
                shader = new ForwardEnvironmentShader(factory.GetTextureCube("Textures\\cubeMap"), 1, false);
                ForwardMaterial fmaterial = new ForwardMaterial(shader);
                IObject         tea       = new IObject(fmaterial, simpleModel, tmesh);

                tea.OnUpdate += new OnUpdate(tea_OnUpdate);
                this.World.AddObject(tea);
            }

            //{
            //    SimpleModel simpleModel = new SimpleModel(factory, "Model//block");
            //    simpleModel.SetTexture(factory.CreateTexture2DColor(1, 1, Color.White), TextureType.DIFFUSE);
            //    BoxObject tmesh = new BoxObject(new Vector3(0,-20,0), 1, 1, 1, 10, new Vector3(200, 1, 200), Matrix.Identity, MaterialDescription.DefaultBepuMaterial());
            //    tmesh.isMotionLess = true;
            //    DeferredNormalShader shader = new DeferredNormalShader();
            //    DeferredMaterial fmaterial = new DeferredMaterial(shader);
            //    IObject obj = new IObject(fmaterial, simpleModel, tmesh);
            //    this.World.AddObject(obj);
            //}


            #endregion

            cam = new RotatingCamera(this);
            this.World.CameraManager.AddCamera(cam);

            SkyBoxSetTextureCube stc = new SkyBoxSetTextureCube("Textures//cubeMap");
            CommandProcessor.getCommandProcessor().SendCommandAssyncronous(stc);
        }
        protected override void LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, IContentManager contentManager)
        {
            base.LoadContent(GraphicInfo, factory, contentManager);


            #region Models

            ///Cria uma textura 1x1 com a cor branca
            Texture2D white = factory.CreateTexture2DColor(1, 1, Color.White);
            {
                SimpleModel sm = new SimpleModel(factory, "..\\Content\\Model\\cubo");
                sm.SetTexture(white, TextureType.DIFFUSE);

                BoxObject            pi     = new BoxObject(new Vector3(100, 20, 0), 1, 1, 1, 5, new Vector3(100, 5, 100), Matrix.Identity, MaterialDescription.DefaultBepuMaterial());
                DeferredNormalShader shader = new DeferredNormalShader();
                ///Setando alguns parametros do material
                shader.SpecularIntensity = 0.01f;
                shader.SpecularPower     = 50;
                IMaterial mat  = new DeferredMaterial(shader);
                IObject   obj3 = new IObject(mat, sm, pi);
                this.World.AddObject(obj3);
            }

            {
                SimpleModel sm = new SimpleModel(factory, "..\\Content\\Model\\cubo");
                sm.SetTexture(white, TextureType.DIFFUSE);

                BoxObject            pi     = new BoxObject(new Vector3(90, 30, 0), 1, 1, 1, 10, new Vector3(1), Matrix.Identity, MaterialDescription.DefaultBepuMaterial());
                DeferredNormalShader shader = new DeferredNormalShader();

                IMaterial mat  = new DeferredMaterial(shader);
                IObject   obj3 = new IObject(mat, sm, pi);
                this.World.AddObject(obj3);
            }


            {
                SimpleModel          sm     = new SimpleModel(factory, "..\\Content\\Model\\cenario");
                IPhysicObject        pi     = new TriangleMeshObject(sm, Vector3.Zero, Matrix.Identity, Vector3.One, MaterialDescription.DefaultBepuMaterial());
                DeferredNormalShader shader = new DeferredNormalShader();
                IMaterial            mat    = new DeferredMaterial(shader);
                IObject obj3 = new IObject(mat, sm, pi);
                this.World.AddObject(obj3);
            }


            #endregion

            #region NormalLight
            ///Conjunto de luzes direcionais
            DirectionalLightPE ld1 = new DirectionalLightPE(Vector3.Left, Color.White);
            DirectionalLightPE ld2 = new DirectionalLightPE(Vector3.Right, Color.White);
            DirectionalLightPE ld3 = new DirectionalLightPE(Vector3.Backward, Color.White);
            DirectionalLightPE ld4 = new DirectionalLightPE(Vector3.Forward, Color.White);
            DirectionalLightPE ld5 = new DirectionalLightPE(Vector3.Down, Color.White);
            float li = 0.4f;
            ld1.LightIntensity = li;
            ld2.LightIntensity = li;
            ld3.LightIntensity = li;
            ld4.LightIntensity = li;
            ld5.LightIntensity = li;
            this.World.AddLight(ld1);
            this.World.AddLight(ld2);
            this.World.AddLight(ld3);
            this.World.AddLight(ld4);
            this.World.AddLight(ld5);
            #endregion


            ///Criando uma camera estatica
            CameraStatic camx = new CameraStatic(new Vector3(130, 100, 700), Vector3.Zero);
            ///Dando um nome a ela (para poder recupera-la depois)
            camx.Name     = "default";
            camx.FarPlane = 3000;
            ///Adiciona ao Manager (NAO ESTA SENDO ATIVADA, APENAS ADICIONADA)
            this.World.CameraManager.AddCamera(camx, camx.Name);
            ///Ativa a camera atual (AO ADICIONAR UMA CAMERA AO WORLD USANDO mundo.AddCamera(cam) A CAMERA EH AUTOMATICAMENTE ATIVADA  )
            this.World.CameraManager.SetActiveCamera(camx.Name);
            ///Adiciona na lista circular
            camerasNames.Value = camx.Name;
            camerasNames.Next();

            ///Idem para uma segunda camera (Porem esta nao eh ativada)
            CameraStatic cam2 = new CameraStatic(new Vector3(100, 100, 100), Vector3.Zero);
            cam2.Name     = "StaticCamera";
            cam2.FarPlane = 3000;
            this.World.CameraManager.AddCamera(cam2, cam2.Name);
            camerasNames.Value = cam2.Name;
            camerasNames.Next();

            ///Idem para a terceira
            CameraStatic cam3 = new CameraStatic(new Vector3(500, 300, 300), Vector3.Zero);
            cam3.Name     = "StaticCamera3";
            cam3.FarPlane = 3000;
            this.World.CameraManager.AddCamera(cam3, cam3.Name);
            camerasNames.Value = cam3.Name;
            camerasNames.Next();


            SimpleConcreteKeyboardInputPlayable ikp = new SimpleConcreteKeyboardInputPlayable(StateKey.PRESS, Keys.Space, KeyStateChange);
            bk = new BindKeyCommand(ikp, BindAction.ADD);
            CommandProcessor.getCommandProcessor().SendCommandAssyncronous(bk);
        }
예제 #11
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);
            this.gf = factory;



            ///Uncoment to Add an object
            /////Create a simple object
            /////Geomtric Info and textures (this model automaticaly loads the texture)
            //SimpleModel simpleModel = new SimpleModel(factory, "Model FILEPATH GOES HERE", "Diffuse Texture FILEPATH GOES HERE -- Use only if it is not embeded in the Model file");
            /////Physic info (position, rotation and scale are set here)
            //TriangleMeshObject tmesh = new TriangleMeshObject(simpleModel, Vector3.Zero, Matrix.Identity, Vector3.One, MaterialDescription.DefaultBepuMaterial());
            /////Shader info (must be a deferred type)
            //DeferredNormalShader shader = new DeferredNormalShader();
            /////Material info (must be a deferred type also)
            //DeferredMaterial fmaterial = new DeferredMaterial(shader);
            /////The object itself
            //IObject obj = new IObject(fmaterial, simpleModel, tmesh);
            /////Add to the world
            //this.World.AddObject(obj);

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

            pos1 = Vector3.Zero;
            pos2 = new Vector3(0, -3, 0);

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

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

            World.AddObject(ball1);

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

            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

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



            ///add a camera
            this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo));
        }
        /// <summary>
        /// Called once to load content
        /// </summary>
        /// <param name="GraphicInfo"></param>
        /// <param name="factory"></param>
        /// <param name="contentManager"></param>
        protected override void LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, PloobsEngine.SceneControl.IContentManager contentManager)
        {
            ///load background texture
            tile = factory.GetTexture2D("Textures/tile");

            ///recover the physic world reference
            FarseerWorld fworld = this.World.PhysicWorld as FarseerWorld;

            ///from vertices
            {
                ////creating objects from vertices
                Vertices Vertices = new Vertices(3);
                Vertices.Add(new Vector2(0, 0));
                Vertices.Add(new Vector2(100, 0));
                Vertices.Add(new Vector2(0, -100));


                ///creating the IModelo (graphic representation)
                SpriteFarseer SpriteFarseer = new SpriteFarseer(factory, Vertices, Color.Green);
                ///The material (how to draw)
                Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
                ///the physic object (physic representation)
                FarseerObject fs = new FarseerObject(fworld, SpriteFarseer, 1, BodyType.Static);
                ///the iobject (that comprises all)
                I2DObject o = new I2DObject(fs, mat, SpriteFarseer);
                ///adding to the world
                this.World.AddObject(o);
            }

            ///Creating from factory helper
            Vertices verts = PolygonTools.CreateRectangle(GraphicInfo.BackBufferWidth, 100);

            {
                IModelo2D model            = new SpriteFarseer(factory, verts, Color.Red);
                Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
                FarseerObject          fs  = new FarseerObject(fworld, model, 1, BodyType.Static);
                I2DObject o = new I2DObject(fs, mat, model);
                ///the origin of the created object will be in the center of it, this mean: if we draw it, the center of mass of it will be on the midle of the screen
                ///We need to translate it a bit down
                o.PhysicObject.Position = new Vector2(100, 450);
                this.World.AddObject(o);
            }

            ///Creating from factory helper
            verts = PolygonTools.CreateRectangle(GraphicInfo.BackBufferWidth, 100);
            {
                IModelo2D model            = new SpriteFarseer(factory, verts, Color.Red);
                Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
                FarseerObject          fs  = new FarseerObject(fworld, model, 1, BodyType.Static);
                I2DObject o = new I2DObject(fs, mat, model);
                ///the origin of the created object will be in the center of it, this mean: if we draw it, the center of mass of it will be on the midle of the screen
                ///We need to translate it a bit down
                o.PhysicObject.Position = new Vector2(0, 250);
                this.World.AddObject(o);
            }

            ///creating a circle =P
            CircleShape circle = new CircleShape(50, 1);

            {
                IModelo2D model            = new SpriteFarseer(factory, circle, Color.Orange);
                Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
                FarseerObject          fs  = new FarseerObject(fworld, model);
                goo = new I2DObject(fs, mat, model);
                goo.PhysicObject.Position = new Vector2(0, -150); /// a middle of the screen + 150 pixels up
                this.World.AddObject(goo);
            }

            ///the basic ortographic 2D camera
            this.World.Camera2D = new Camera2D(GraphicInfo);
            base.LoadContent(GraphicInfo, factory, contentManager);
        }
        protected override void LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, IContentManager contentManager)
        {
            base.LoadContent(GraphicInfo, factory, contentManager);

            #region Models
            ///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);
            }
        }
예제 #14
0
        protected override void LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, IContentManager contentManager)
        {
            base.LoadContent(GraphicInfo, factory, contentManager);

            Picking picking = new Picking(this);

            this.AddScreenUpdateable(picking);

            #region Models
            {
                SimpleModel          sm     = new SimpleModel(factory, "..\\Content\\Model\\cenario");
                IPhysicObject        pi     = new TriangleMeshObject(sm, Vector3.Zero, Matrix.Identity, Vector3.One, MaterialDescription.DefaultBepuMaterial());
                DeferredNormalShader shader = new DeferredNormalShader();
                IMaterial            mat    = new DeferredMaterial(shader);
                IObject obj3 = new IObject(mat, sm, pi);
                obj3.Name = "cenario";
                this.World.AddObject(obj3);
            }

            for (int i = 0; i < 10; i++)
            {
                for (int j = 0; j < 10; j++)
                {
                    SimpleModel sm = new SimpleModel(factory, "..\\Content\\Model\\cubo");
                    sm.SetTexture(factory.CreateTexture2DColor(1, 1, Color.White), TextureType.DIFFUSE);
                    BoxObject pi = new BoxObject(new Vector3(i * 10, 100, j * 10), 1, 1, 1, 1, new Vector3(5), Matrix.Identity, MaterialDescription.DefaultBepuMaterial());
                    pi.isMotionLess = true;
                    DeferredNormalShader shader = new DeferredNormalShader();
                    IMaterial            mat    = new DeferredMaterial(shader);
                    IObject obj4 = new IObject(mat, sm, pi);
                    obj4.Name = "Block " + i + " : " + j;
                    this.World.AddObject(obj4);
                }
            }

            #endregion

            cam          = new CameraFirstPerson(GraphicInfo);
            cam.FarPlane = 3000;

            #region NormalLight
            ///Conjunto de luzes direcionais
            DirectionalLightPE ld1 = new DirectionalLightPE(Vector3.Left, Color.White);
            DirectionalLightPE ld2 = new DirectionalLightPE(Vector3.Right, Color.White);
            DirectionalLightPE ld3 = new DirectionalLightPE(Vector3.Backward, Color.White);
            DirectionalLightPE ld4 = new DirectionalLightPE(Vector3.Forward, Color.White);
            DirectionalLightPE ld5 = new DirectionalLightPE(Vector3.Down, Color.White);
            float li = 0.4f;
            ld1.LightIntensity = li;
            ld2.LightIntensity = li;
            ld3.LightIntensity = li;
            ld4.LightIntensity = li;
            ld5.LightIntensity = li;
            this.World.AddLight(ld1);
            this.World.AddLight(ld2);
            this.World.AddLight(ld3);
            this.World.AddLight(ld4);
            this.World.AddLight(ld5);
            #endregion


            this.World.CameraManager.AddCamera(cam);


            ///O PICKING FUNCIONA APENAS COM OBJETOS QUE TENHAM CORPO FISICO REAL !!!
            ///OS GHOST E OS DUMMY NUNCA SERAO SELECIONADOS
            ///Para ser informado a todo frame sobre as colisoes do raio, basta utilizar o outro construtor
            picking.OnPickedLeftButton += new OnPicked(onPick);
        }
        /// <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);

            {
                ///Create a simple object
                ///Geomtric Info and textures (this model automaticaly loads the texture)
                SimpleModel simpleModel = new SimpleModel(factory, "model/dude");
                //simpleModel.SetTexture(factory.CreateTexture2DColor(1,1,Color.Red), TextureType.DIFFUSE);
                ///Physic info (position, rotation and scale are set here)
                GhostObject pi = new GhostObject(new Vector3(200, 10, 0), Matrix.Identity, new Vector3(4));
                ///Shader info (must be a deferred type)
                DeferredNormalShader shader = new DeferredNormalShader();
                shader.ShaderId = ShaderUtils.CreateBitField(false, false, false, false, true);
                ///Material info (must be a deferred type also)
                DeferredMaterial fmaterial = new DeferredMaterial(shader);
                fmaterial.IsVisible = false;
                ///The object itself
                IObject obj = new IObject(fmaterial, simpleModel, pi);
                obj.OnUpdate += new OnUpdate(obj_OnUpdate);
                ///Add to the world
                this.World.AddObject(obj);

                StealthPostEffect StealthPostEffect = new StealthPostEffect();
                StealthPostEffect.objs.Add(obj);
                this.RenderTechnic.AddPostEffect(StealthPostEffect);
            }



            {
                ///Create a simple object
                ///Geomtric Info and textures (this model automaticaly loads the texture)
                SimpleModel simpleModel = new SimpleModel(factory, "model/cenario");
                ///Physic info (position, rotation and scale are set here)
                TriangleMeshObject tmesh = new TriangleMeshObject(simpleModel, Vector3.Zero, Matrix.Identity, Vector3.One, MaterialDescription.DefaultBepuMaterial());
                ///Shader info (must be a deferred type)
                DeferredNormalShader shader = new DeferredNormalShader();
                ///Material info (must be a deferred type also)
                DeferredMaterial fmaterial = new DeferredMaterial(shader);
                ///The object itself
                IObject obj = new IObject(fmaterial, simpleModel, tmesh);
                ///Add to the world
                this.World.AddObject(obj);
            }
            ///Add some directional lights to completely iluminate the world
            #region Lights
            DirectionalLightPE ld1 = new DirectionalLightPE(Vector3.Left, Color.White);
            DirectionalLightPE ld2 = new DirectionalLightPE(Vector3.Right, Color.White);
            DirectionalLightPE ld3 = new DirectionalLightPE(Vector3.Backward, Color.White);
            DirectionalLightPE ld4 = new DirectionalLightPE(Vector3.Forward, Color.White);
            DirectionalLightPE ld5 = new DirectionalLightPE(Vector3.Down, Color.White);
            float li = 0.4f;
            ld1.LightIntensity = li;
            ld2.LightIntensity = li;
            ld3.LightIntensity = li;
            ld4.LightIntensity = li;
            ld5.LightIntensity = li;
            this.World.AddLight(ld1);
            this.World.AddLight(ld2);
            this.World.AddLight(ld3);
            this.World.AddLight(ld4);
            this.World.AddLight(ld5);
            #endregion

            ///Add a AA post effect
            //this.RenderTechnic.AddPostEffect(new AntiAliasingPostEffect());

            ///add a camera
            this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo));

            SkyBoxSetTextureCube stc = new SkyBoxSetTextureCube("Textures//cubemap");
            CommandProcessor.getCommandProcessor().SendCommandAssyncronous(stc);
        }
        protected override void LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, PloobsEngine.SceneControl.IContentManager contentManager)
        {
            tile = factory.GetTexture2D("Textures/tile");


            FarseerWorld fworld = this.World.PhysicWorld as FarseerWorld;

            ///border
            border = new Border(fworld, factory, GraphicInfo, factory.CreateTexture2DColor(1, 1, Color.Red));

            ///from texture, scale usage sample
            {
                Texture2D tex = factory.GetTexture2D("Textures//goo");
                tex = factory.GetScaledTexture(tex, new Vector2(3));
                IModelo2D model            = new SpriteFarseer(tex);
                Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
                FarseerObject          fs  = new FarseerObject(fworld, tex);
                fs.Position         = new Vector2(0, 50);
                partobj             = new I2DObject(fs, mat, model);
                partobj.OnHasMoved += new PloobsEngine.SceneControl._2DScene.OnHasMoved(o_OnHasMoved);
                this.World.AddObject(partobj);
            }

            Vertices verts = PolygonTools.CreateRectangle(150, 150);

            {
                IModelo2D model            = new SpriteFarseer(factory, verts, Color.Green);
                Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
                FarseerObject          fs  = new FarseerObject(fworld, model, 1, BodyType.Dynamic);
                I2DObject o = new I2DObject(fs, mat, model);
                ///the origin of the created object will be in the center of it, this mean: if we draw it, the center of mass of it will be on the midle of the screen
                ///We need to translate it a bit down
                o.PhysicObject.Position = new Vector2(100, 100);
                this.World.AddObject(o);
            }

            //circle
            verts = PolygonTools.CreateCircle(150, 150);
            {
                IModelo2D model            = new SpriteFarseer(factory, verts, Color.Orange);
                Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
                FarseerObject          fs  = new FarseerObject(fworld, model, 1, BodyType.Dynamic);
                I2DObject o = new I2DObject(fs, mat, model);
                o.PhysicObject.Position = new Vector2(-100, -100);
                this.World.AddObject(o);
            }

            ///camera
            this.World.Camera2D = new Camera2D(GraphicInfo);

            DPFSParticleSystem ps = new DPFSParticleSystem("TESTE", new SpriteParticleSystem(null));

            this.World.ParticleManager.AddAndInitializeParticleSystem(ps);

            ///updateable
            ju = new JointUpdateable(this, fworld, this.World.Camera2D);

            base.LoadContent(GraphicInfo, factory, contentManager);
        }
예제 #17
0
        protected override void LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, PloobsEngine.SceneControl.IContentManager contentManager)
        {
            tile = factory.GetTexture2D("Textures/tile");

            FarseerWorld fworld = this.World.PhysicWorld as FarseerWorld;

            ///border
            border = new Border(fworld, factory, GraphicInfo, factory.CreateTexture2DColor(1, 1, Color.Red));

            ///from texture
            {
                Texture2D tex              = factory.GetTexture2D("Textures//goo");
                IModelo2D model            = new SpriteFarseer(tex);
                Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
                FarseerObject          fs  = new FarseerObject(fworld, model);
                I2DObject o = new I2DObject(fs, mat, model);
                o.PhysicObject.Position = new Vector2(200, 0);
                this.World.AddObject(o);
            }

            ///from texture, scale usage sample
            {
                Texture2D tex = factory.GetTexture2D("Textures//goo");
                tex = factory.GetScaledTexture(tex, new Vector2(2));
                IModelo2D model            = new SpriteFarseer(tex);
                Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
                FarseerObject          fs  = new FarseerObject(fworld, model);
                I2DObject o = new I2DObject(fs, mat, model);
                o.OnHasMoved += new PloobsEngine.SceneControl._2DScene.OnHasMoved(o_OnHasMoved);
                this.World.AddObject(o);
            }

            ///rectangle
            Vertices verts = PolygonTools.CreateRectangle(50, 50);
            {
                IModelo2D model            = new SpriteFarseer(factory, verts, Color.Orange);
                Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
                FarseerObject          fs  = new FarseerObject(fworld, model);
                I2DObject o = new I2DObject(fs, mat, model);
                o.PhysicObject.Position = new Vector2(-200, 0);
                this.World.AddObject(o);
            }

            ///circle
            CircleShape circle = new CircleShape(50, 1);

            {
                IModelo2D model            = new SpriteFarseer(factory, circle, Color.Orange);
                Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
                FarseerObject          fs  = new FarseerObject(fworld, model);
                I2DObject o = new I2DObject(fs, mat, model);
                o.PhysicObject.Position = new Vector2(200, -100);
                this.World.AddObject(o);
            }

            ///animated sprite
            {
                Texture2D      tex = factory.GetTexture2D("Textures//DudeSheet");
                SpriteAnimated sa  = new SpriteAnimated(tex, 8, 2);
                sa.AddAnimation("ANIM1", 1, 8, 0);
                sa.AddAnimation("ANIM2", 2, 4, MathHelper.PiOver2);

                Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
                Texture2D     frame        = factory.GetTexturePart(tex, sa.GetFrameRectangle("ANIM1", 0));
                FarseerObject fs           = new FarseerObject(fworld, frame);

                //GhostObject fs = new GhostObject(Vector2.Zero);
                sheet = new I2DObject(fs, mat, sa);
                sheet.PhysicObject.Position = new Vector2(500, 0);
                this.World.AddObject(sheet);
            }

            {
                PointLight2D l = new PointLight2D(new Vector2(-GraphicInfo.BackBufferWidth / 4, -GraphicInfo.BackBufferWidth / 4), Color.Red, 1);
                this.World.AddLight(l);
            }

            {
                SpotLight2D l = new SpotLight2D(new Vector2(+GraphicInfo.BackBufferWidth / 4, -GraphicInfo.BackBufferWidth / 4), Color.Blue, new Vector2(0, 1), MathHelper.ToRadians(45));
                this.World.AddLight(l);
            }

            {
                SimpleConcreteKeyboardInputPlayable sc = new SimpleConcreteKeyboardInputPlayable(StateKey.PRESS, Keys.Space);
                sc.KeyStateChange += new KeyStateChange(sc_KeyStateChange);
                this.BindInput(sc);
            }

            ///camera
            this.World.Camera2D = new Camera2D(GraphicInfo);

            DPFSParticleSystem ps = new DPFSParticleSystem("TESTE", new SpriteParticleSystem(null));

            this.World.ParticleManager.AddAndInitializeParticleSystem(ps);

            ///add a post effect =P
            //this.RenderTechnic.AddPostEffect(new WigglePostEffect());

            ///updateable
            JointUpdateable ju = new JointUpdateable(this, fworld, this.World.Camera2D);

            base.LoadContent(GraphicInfo, factory, contentManager);
        }
예제 #18
0
        protected override void LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, PloobsEngine.SceneControl.IContentManager contentManager)
        {
            tile = factory.GetTexture2D("Textures/tile");


            FarseerWorld fworld = this.World.PhysicWorld as FarseerWorld;

            ///border
            border = new Border(fworld, factory, GraphicInfo, factory.CreateTexture2DColor(1, 1, Color.Red));

            ///from texture
            {
                Texture2D tex              = factory.GetTexture2D("Textures//goo");
                IModelo2D model            = new SpriteFarseer(tex);
                Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
                FarseerObject          fs  = new FarseerObject(fworld, tex);

                I2DObject o = new I2DObject(fs, mat, model);
                o.Name = "Goo";
                this.World.AddObject(o);
            }

            ///rectangle
            Vertices verts = PolygonTools.CreateRectangle(5, 5);
            {
                IModelo2D model            = new SpriteFarseer(factory, verts, Color.Orange);
                Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
                FarseerObject          fs  = new FarseerObject(fworld, verts);

                I2DObject o = new I2DObject(fs, mat, model);
                o.Name = "Rectangle";
                this.World.AddObject(o);
            }

            ///circle
            CircleShape circle = new CircleShape(5, 1);

            {
                IModelo2D model            = new SpriteFarseer(factory, circle, Color.Orange);
                Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
                FarseerObject          fs  = new FarseerObject(fworld, circle);

                I2DObject o = new I2DObject(fs, mat, model);
                o.Name = "Circle";
                this.World.AddObject(o);
            }

            ///camera
            this.World.Camera2D = new Camera2D(GraphicInfo);

            base.LoadContent(GraphicInfo, factory, contentManager);

            this.BindInput(new SimpleConcreteGestureInputPlayable(Microsoft.Xna.Framework.Input.Touch.GestureType.Tap,
                                                                  (sample) =>
            {
                I2DPhysicObject obj = this.World.PhysicWorld.Picking(this.World.Camera2D.ConvertScreenToWorld(sample.Position));
                if (obj != null)
                {
                    pickedName = obj.Owner.Name + " " + sample.Position;
                }
                else
                {
                    pickedName = null;
                }
            }
                                                                  ));
        }
예제 #19
0
        protected override void LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, PloobsEngine.SceneControl.IContentManager contentManager)
        {
            tile = factory.GetTexture2D("Textures/tile");
            FarseerWorld fworld = this.World.PhysicWorld as FarseerWorld;

            ///Ground
            Vertices verts = PolygonTools.CreateRectangle(GraphicInfo.BackBufferWidth, 100);

            {
                IModelo2D model            = new SpriteFarseer(factory, verts, Color.Red);
                Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
                FarseerObject          fs  = new FarseerObject(fworld, model, 1, BodyType.Static);
                I2DObject o = new I2DObject(fs, mat, model);
                ///the origin of the created object will be in the center of it, this mean: if we draw it, the center of mass of it will be on the midle of the screen
                ///We need to translate it a bit down
                o.PhysicObject.Position = new Vector2(0, 250);
                this.World.AddObject(o);
            }

            ///animated sprite
            {
                ///loading the texture
                Texture2D tex = factory.GetTexture2D("Textures//DudeSheet");
                ///scale the texture (this is not good specially with animated texture, cause the whole texture is being scalled)
                tex = factory.GetScaledTexture(tex, new Vector2(2));
                ///Loading the Sprite and extracting the frames
                ///8 = Maximum number of frames in the horizontal
                ///2 = Number of animation
                ///See the texture DudeSheet to undertand
                SpriteAnimated sa = new SpriteAnimated(tex, 8, 2);
                ///Specify the first animation (First "line" of the texture) -- see the extra parameters in addAnimation
                sa.AddAnimation("ANIM1", 1, 8, 0);
                ///Specify the Second animation (Second "line" of the texture)
                sa.AddAnimation("ANIM2", 2, 4, 0);

                ///Create the Material
                Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
                ///To create the physic object, we extract one frame from the image and use it to be our physic body =P
                Texture2D     frame = factory.GetTexturePart(tex, sa.GetFrameRectangle("ANIM1", 0));
                FarseerObject fs    = new FarseerObject(fworld, frame);
                sheet = new I2DObject(fs, mat, sa);
                sheet.PhysicObject.Position = new Vector2(0, 0);
                this.World.AddObject(sheet);
            }

            ///camera
            this.World.Camera2D = new Camera2D(GraphicInfo);
            base.LoadContent(GraphicInfo, factory, contentManager);

            ///when double tap, perform the following action
            this.BindInput(new SimpleConcreteGestureInputPlayable(Microsoft.Xna.Framework.Input.Touch.GestureType.DoubleTap,
                                                                  (a) =>
            {
                animationIndex = (animationIndex + 1) % 2;
                (sheet.Modelo as SpriteAnimated).ChangeAnimation(animations[animationIndex]);
                ///you can play, pause, change ..... using the SpriteAnimated object.
            }
                                                                  ));
        }
예제 #20
0
        /// <summary>
        /// Called once to load content
        /// </summary>
        /// <param name="GraphicInfo"></param>
        /// <param name="factory"></param>
        /// <param name="contentManager"></param>
        protected override void LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, PloobsEngine.SceneControl.IContentManager contentManager)
        {
            ///load background texture
            tile = factory.GetTexture2D("Textures/tile");

            ///recover the physic world reference
            FarseerWorld fworld = this.World.PhysicWorld as FarseerWorld;

            ///Ground 1
            Vertices verts = PolygonTools.CreateRectangle(GraphicInfo.BackBufferWidth, 100);

            {
                IModelo2D model            = new SpriteFarseer(factory, verts, Color.Red);
                Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
                FarseerObject          fs  = new FarseerObject(fworld, model, 1, BodyType.Static);
                I2DObject o = new I2DObject(fs, mat, model);
                ///the origin of the created object will be in the center of it, this mean: if we draw it, the center of mass of it will be on the midle of the screen
                ///We need to translate it a bit down
                o.PhysicObject.Position = new Vector2(0, 250);
                this.World.AddObject(o);
            }

            ///Ground 2
            verts = PolygonTools.CreateRectangle(GraphicInfo.BackBufferWidth, 100);
            {
                IModelo2D model            = new SpriteFarseer(factory, verts, Color.Green);
                Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
                FarseerObject          fs  = new FarseerObject(fworld, model, 1, BodyType.Static);
                I2DObject o = new I2DObject(fs, mat, model);
                ///the origin of the created object will be in the center of it, this mean: if we draw it, the center of mass of it will be on the midle of the screen
                ///We need to translate it a bit down
                o.PhysicObject.Position = new Vector2(GraphicInfo.BackBufferWidth, 250);
                this.World.AddObject(o);
            }

            ///Ground 3
            verts = PolygonTools.CreateRectangle(GraphicInfo.BackBufferWidth, 100);
            {
                IModelo2D model            = new SpriteFarseer(factory, verts, Color.Yellow);
                Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
                FarseerObject          fs  = new FarseerObject(fworld, model, 1, BodyType.Static);
                I2DObject o = new I2DObject(fs, mat, model);
                ///the origin of the created object will be in the center of it, this mean: if we draw it, the center of mass of it will be on the midle of the screen
                ///We need to translate it a bit down
                o.PhysicObject.Position = new Vector2(GraphicInfo.BackBufferWidth * 2, 250);
                this.World.AddObject(o);
            }

            ///Support
            verts = PolygonTools.CreateRectangle(50, 200);
            {
                IModelo2D model            = new SpriteFarseer(factory, verts, Color.Yellow);
                Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
                FarseerObject          fs  = new FarseerObject(fworld, model, 1, BodyType.Static);
                I2DObject o = new I2DObject(fs, mat, model);
                ///the origin of the created object will be in the center of it, this mean: if we draw it, the center of mass of it will be on the midle of the screen
                ///We need to translate it a bit down
                o.PhysicObject.Position = new Vector2(0, 100);
                this.World.AddObject(o);
            }

            ///target 1
            verts = PolygonTools.CreateRectangle(50, 200);
            {
                IModelo2D model            = new SpriteFarseer(factory, verts, Color.Green);
                Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
                FarseerObject          fs  = new FarseerObject(fworld, model, 1, BodyType.Dynamic);
                I2DObject o = new I2DObject(fs, mat, model);
                ///the origin of the created object will be in the center of it, this mean: if we draw it, the center of mass of it will be on the midle of the screen
                ///We need to translate it a bit down
                o.PhysicObject.Position = new Vector2(GraphicInfo.BackBufferWidth * 1.5f, 100);
                this.World.AddObject(o);
            }

            ///target 2
            verts = PolygonTools.CreateRectangle(50, 200);
            {
                IModelo2D model            = new SpriteFarseer(factory, verts, Color.Green);
                Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
                FarseerObject          fs  = new FarseerObject(fworld, model, 1, BodyType.Dynamic);
                I2DObject o = new I2DObject(fs, mat, model);
                ///the origin of the created object will be in the center of it, this mean: if we draw it, the center of mass of it will be on the midle of the screen
                ///We need to translate it a bit down
                o.PhysicObject.Position = new Vector2(GraphicInfo.BackBufferWidth * 1.6f, 100);
                this.World.AddObject(o);
            }

            ///target 3
            verts = PolygonTools.CreateRectangle(200, 50);
            {
                IModelo2D model            = new SpriteFarseer(factory, verts, Color.Green);
                Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
                FarseerObject          fs  = new FarseerObject(fworld, model, 1, BodyType.Dynamic);
                I2DObject o = new I2DObject(fs, mat, model);
                ///the origin of the created object will be in the center of it, this mean: if we draw it, the center of mass of it will be on the midle of the screen
                ///We need to translate it a bit down
                o.PhysicObject.Position = new Vector2(GraphicInfo.BackBufferWidth * 1.55f, -100);
                this.World.AddObject(o);
            }

            ///objective
            ///from texture
            {
                Texture2D tex = factory.GetTexture2D("Textures//goo");
                tex = factory.GetScaledTexture(tex, new Vector2(2));
                IModelo2D model            = new SpriteFarseer(tex);
                Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
                FarseerObject          fs  = new FarseerObject(fworld, model);
                goo = new I2DObject(fs, mat, model);
                goo.PhysicObject.Position = new Vector2(GraphicInfo.BackBufferWidth * 1.55f, -175);
                this.World.AddObject(goo);
            }

            ///Ball
            CircleShape circle = new CircleShape(50, 1);
            {
                IModelo2D model            = new SpriteFarseer(factory, circle, Color.Orange);
                Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
                FarseerObject          fs  = new FarseerObject(fworld, model);
                ball = new I2DObject(fs, mat, model);
                ball.PhysicObject.Position = new Vector2(0, -25);
                ball.OnUpdate += new PloobsEngine.SceneControl._2DScene.OnUpdate(ball_OnUpdate);
                this.World.AddObject(ball);
            }

            SimpleConcreteMouseBottomInputPlayable SimpleConcreteMouseBottomInputPlayable1 = new SimpleConcreteMouseBottomInputPlayable(StateKey.PRESS, EntityType.TOOLS, PloobsEngine.Input.MouseButtons.LeftButton,
                                                                                                                                        (sample) =>
            {
                mousepressed = true;
            }
                                                                                                                                        );

            this.BindInput(SimpleConcreteMouseBottomInputPlayable1);


            SimpleConcreteMouseBottomInputPlayable SimpleConcreteMouseBottomInputPlayable = null;

            SimpleConcreteMouseBottomInputPlayable = new SimpleConcreteMouseBottomInputPlayable(StateKey.RELEASE, EntityType.TOOLS, PloobsEngine.Input.MouseButtons.LeftButton,
                                                                                                (sample) =>
            {
                mousepressed    = false;
                lines.isEnabled = false;
                fired           = true;

                Vector2 mpos  = new Vector2(Mouse.GetState().X, Mouse.GetState().Y);
                Vector2 wpos  = this.World.Camera2D.ConvertScreenToWorld(mpos);
                Vector2 force = (ball.PhysicObject.Position - wpos) * 30;
                ball.PhysicObject.ApplyForce(force);
                this.RemoveInputBinding(SimpleConcreteMouseBottomInputPlayable);
                this.RemoveInputBinding(SimpleConcreteMouseBottomInputPlayable1);

                (this.World.Camera2D as Camera2D).TrackingBody = ball;
            }
                                                                                                );
            this.BindInput(SimpleConcreteMouseBottomInputPlayable);


            ///the basic ortographic 2D camera
            this.World.Camera2D = new Camera2D(GraphicInfo);
            base.LoadContent(GraphicInfo, factory, contentManager);

            Primitive2DDraw.Add2DPrimitive(lines);
        }
예제 #21
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));
        }
        protected override void AfterLoadContent(IContentManager manager, PloobsEngine.Engine.GraphicInfo ginfo, PloobsEngine.Engine.GraphicFactory factory)
        {
            base.AfterLoadContent(manager, ginfo, factory);
            this.ginfo = ginfo;

            pointLightEffect = factory.GetEffect("PrePass/plight");
            _clearGBuffer    = factory.GetEffect("PrePass/ClearGBuffer");
            _lighting        = factory.GetEffect("PrePass/LightingLpp");

            sphereModel = new SimpleModel(factory, "Model/Dsphere");
            ForwardPass = new ForwardPass(ForwardPassDescription.Default());
            _width      = ginfo.BackBufferWidth;
            _height     = ginfo.BackBufferHeight;

            _cwDepthState = new DepthStencilState();
            _cwDepthState.DepthBufferWriteEnable = false;
            _cwDepthState.DepthBufferFunction    = CompareFunction.LessEqual;

            _ccwDepthState = new DepthStencilState();
            _ccwDepthState.DepthBufferWriteEnable = false;
            _ccwDepthState.DepthBufferFunction    = CompareFunction.GreaterEqual;

            _directionalDepthState = new DepthStencilState();;
            _directionalDepthState.DepthBufferWriteEnable = false;
            _directionalDepthState.DepthBufferFunction    = CompareFunction.Greater;


            _depthStateDrawLights = new DepthStencilState();

            //we draw our volumes with front-face culling, so we have to use GreaterEqual here
            _depthStateDrawLights.DepthBufferFunction = CompareFunction.GreaterEqual;
            //with our z-buffer reconstructed we only need to read it
            _depthStateDrawLights.DepthBufferWriteEnable = false;

            _depthStateReconstructZ = new DepthStencilState
            {
                DepthBufferEnable      = true,
                DepthBufferWriteEnable = true,
                DepthBufferFunction    = CompareFunction.Always
            };

            _lightAddBlendState = new BlendState()
            {
                AlphaSourceBlend      = Blend.One,
                ColorSourceBlend      = Blend.One,
                AlphaDestinationBlend = Blend.One,
                ColorDestinationBlend = Blend.One,
            };

            CreateGBuffer(factory);
        }
        /// <summary>
        /// Called once to load content
        /// </summary>
        /// <param name="GraphicInfo"></param>
        /// <param name="factory"></param>
        /// <param name="contentManager"></param>
        protected override void LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, PloobsEngine.SceneControl.IContentManager contentManager)
        {
            ///load background texture
            tile = factory.GetTexture2D("Textures/tile");

            ///recover the physic world reference
            FarseerWorld fworld = this.World.PhysicWorld as FarseerWorld;

            ///from vertices
            {
                ////creating objects from vertices
                Vertices Vertices = new Vertices(3);
                Vertices.Add(new Vector2(0, 0));
                Vertices.Add(new Vector2(100, 0));
                Vertices.Add(new Vector2(0, -100));


                ///creating the IModelo (graphic representation)
                SpriteFarseer SpriteFarseer = new SpriteFarseer(factory, Vertices, Color.Green);
                ///The material (how to draw)
                Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
                ///the physic object (physic representation)
                FarseerObject fs = new FarseerObject(fworld, SpriteFarseer, 1, BodyType.Static);
                ///the iobject (that comprises all)
                I2DObject o = new I2DObject(fs, mat, SpriteFarseer);
                ///adding to the world
                this.World.AddObject(o);
            }

            ///Creating from factory helper
            Vertices verts = PolygonTools.CreateRectangle(GraphicInfo.BackBufferWidth, 100);

            {
                IModelo2D model            = new SpriteFarseer(factory, verts, Color.Red);
                Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
                FarseerObject          fs  = new FarseerObject(fworld, model, 1, BodyType.Static);
                I2DObject o = new I2DObject(fs, mat, model);
                ///the origin of the created object will be in the center of it, this mean: if we draw it, the center of mass of it will be on the midle of the screen
                ///We need to translate it a bit down
                o.PhysicObject.Position = new Vector2(0, 250);
                this.World.AddObject(o);
            }

            ///Creating from factory helper
            verts = PolygonTools.CreateRectangle(GraphicInfo.BackBufferWidth, 100);
            {
                IModelo2D model            = new SpriteFarseer(factory, verts, Color.Red);
                Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
                FarseerObject          fs  = new FarseerObject(fworld, model, 1, BodyType.Static);
                I2DObject o = new I2DObject(fs, mat, model);
                ///the origin of the created object will be in the center of it, this mean: if we draw it, the center of mass of it will be on the midle of the screen
                ///We need to translate it a bit down
                o.PhysicObject.Position = new Vector2(GraphicInfo.BackBufferWidth, 450);
                this.World.AddObject(o);
            }

            ///creating a circle =P
            CircleShape circle = new CircleShape(50, 1);

            {
                IModelo2D model            = new SpriteFarseer(factory, circle, Color.Orange);
                Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
                FarseerObject          fs  = new FarseerObject(fworld, model);
                Tracked = new I2DObject(fs, mat, model);
                Tracked.PhysicObject.Position = new Vector2(0, -250); /// a middle of the screen + 250 pixels up
                this.World.AddObject(Tracked);
            }

            ///when space is pressed, perform the following action
            this.BindInput(new SimpleConcreteKeyboardInputPlayable(StateKey.PRESS, Keys.Space,
                                                                   (a) =>
            {
                if (tracking == false)
                {
                    ///enable camera tracking
                    (this.World.Camera2D as Camera2D).TrackingBody           = Tracked;
                    (this.World.Camera2D as Camera2D).EnablePositionTracking = true;
                }
                else
                {
                    ///reset the camera (recreating =P)
                    this.World.Camera2D = new Camera2D(GraphicInfo);
                }
                tracking = !tracking;
            }
                                                                   ));

            ///the basic ortographic 2D camera
            this.World.Camera2D = new Camera2D(GraphicInfo);
            base.LoadContent(GraphicInfo, factory, contentManager);
        }
        protected override void LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, PloobsEngine.SceneControl.IContentManager contentManager)
        {
            tile = factory.GetTexture2D("Textures/tile");

            FarseerWorld fworld = this.World.PhysicWorld as FarseerWorld;

            ///border
            border = new Border(fworld, factory, GraphicInfo, factory.CreateTexture2DColor(1, 1, Color.Red));

            ///from texture
            {
                Texture2D tex              = factory.GetTexture2D("Textures//goo");
                IModelo2D model            = new SpriteFarseer(tex);
                Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
                FarseerObject          fs  = new FarseerObject(fworld, model);
                I2DObject o = new I2DObject(fs, mat, model);
                o.PhysicObject.Position = new Vector2(200, 0);
                this.World.AddObject(o);
            }

            ///from texture, scale usage sample
            {
                Texture2D tex = factory.GetTexture2D("Textures//goo");
                tex = factory.GetScaledTexture(tex, new Vector2(2));
                IModelo2D model            = new SpriteFarseer(tex);
                Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
                FarseerObject          fs  = new FarseerObject(fworld, model);
                I2DObject o = new I2DObject(fs, mat, model);
                o.OnHasMoved += new PloobsEngine.SceneControl._2DScene.OnHasMoved(o_OnHasMoved);
                this.World.AddObject(o);
            }

            ///rectangle
            Vertices verts = PolygonTools.CreateRectangle(50, 50);
            {
                IModelo2D model            = new SpriteFarseer(factory, verts, Color.Orange);
                Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
                FarseerObject          fs  = new FarseerObject(fworld, model);
                I2DObject o = new I2DObject(fs, mat, model);
                o.PhysicObject.Position = new Vector2(-200, 0);
                this.World.AddObject(o);
            }

            ///circle
            CircleShape circle = new CircleShape(50, 1);

            {
                IModelo2D model            = new SpriteFarseer(factory, circle, Color.Orange);
                Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
                FarseerObject          fs  = new FarseerObject(fworld, model);
                I2DObject o = new I2DObject(fs, mat, model);
                o.PhysicObject.Position = new Vector2(200, -100);
                this.World.AddObject(o);
            }

            ///animated sprite
            {
                Texture2D      tex = factory.GetTexture2D("Textures//DudeSheet");
                SpriteAnimated sa  = new SpriteAnimated(tex, 8, 2);
                sa.AddAnimation("ANIM1", 1, 8, 0);
                sa.AddAnimation("ANIM2", 2, 4, MathHelper.PiOver2);

                Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
                Texture2D     frame        = factory.GetTexturePart(tex, sa.GetFrameRectangle("ANIM1", 0));
                FarseerObject fs           = new FarseerObject(fworld, frame);

                //GhostObject fs = new GhostObject(Vector2.Zero);
                sheet = new I2DObject(fs, mat, sa);
                sheet.PhysicObject.Position = new Vector2(500, 0);
                this.World.AddObject(sheet);
            }

            {
                PointLight2D l = new PointLight2D(new Vector2(-GraphicInfo.BackBufferWidth / 4, -GraphicInfo.BackBufferWidth / 4), Color.Red, 1);
                this.World.AddLight(l);
            }

            {
                SpotLight2D l = new SpotLight2D(new Vector2(+GraphicInfo.BackBufferWidth / 4, -GraphicInfo.BackBufferWidth / 4), Color.Blue, new Vector2(0, 1), MathHelper.ToRadians(45));
                this.World.AddLight(l);
            }

            {
                SimpleConcreteKeyboardInputPlayable sc = new SimpleConcreteKeyboardInputPlayable(StateKey.PRESS, Keys.Space);
                sc.KeyStateChange += new KeyStateChange(sc_KeyStateChange);
                this.BindInput(sc);
            }

            ///camera
            this.World.Camera2D = new Camera2D(GraphicInfo);

            DPFSParticleSystem ps = new DPFSParticleSystem("TESTE", new SpriteParticleSystem(null));

            this.World.ParticleManager.AddAndInitializeParticleSystem(ps);

            ///add a post effect =P
            //this.RenderTechnic.AddPostEffect(new WigglePostEffect());

            ///updateable
            JointUpdateable ju = new JointUpdateable(this, fworld, this.World.Camera2D);

            base.LoadContent(GraphicInfo, factory, contentManager);

            {
                NeoforceGui guiManager = this.Gui as NeoforceGui;
                System.Diagnostics.Debug.Assert(guiManager != null);

                // Create and setup Window control.
                Window window = new Window(guiManager.Manager);
                window.Init();
                window.Text   = "Getting Started";
                window.Width  = 480;
                window.Height = 200;
                window.Center();
                window.Visible = true;

                // Create Button control and set the previous window as its parent.
                Button button = new Button(guiManager.Manager);
                button.Init();
                button.Text   = "OK";
                button.Width  = 72;
                button.Height = 24;
                button.Left   = (window.ClientWidth / 2) - (button.Width / 2);
                button.Top    = window.ClientHeight - button.Height - 8;
                button.Anchor = Anchors.Bottom;
                button.Parent = window;

                // Add the window control to the manager processing queue.
                guiManager.Manager.Add(window);
            }
        }
        protected override void LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, IContentManager contentManager)
        {
            base.LoadContent(GraphicInfo, factory, contentManager);

            #region Models
            ///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);
        }
        /// <summary>
        /// Called once to load content
        /// </summary>
        /// <param name="GraphicInfo"></param>
        /// <param name="factory"></param>
        /// <param name="contentManager"></param>
        protected override void LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, PloobsEngine.SceneControl.IContentManager contentManager)
        {
            ///load background texture
            tile = factory.GetTexture2D("Textures/tile");

            ///recover the physic world reference
            FarseerWorld fworld = this.World.PhysicWorld as FarseerWorld;

            ///from vertices
            {
                ////creating objects from vertices
                Vertices Vertices = new Vertices(3);
                Vertices.Add(new Vector2(0, 0));
                Vertices.Add(new Vector2(100, 0));
                Vertices.Add(new Vector2(0, -100));


                ///creating the IModelo (graphic representation)
                SpriteFarseer SpriteFarseer = new SpriteFarseer(factory, Vertices, Color.Green);
                ///The material (how to draw)
                Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
                ///the physic object (physic representation)
                FarseerObject fs = new FarseerObject(fworld, SpriteFarseer, 1, BodyType.Static);
                ///the iobject (that comprises all)
                I2DObject o = new I2DObject(fs, mat, SpriteFarseer);
                ///adding to the world
                this.World.AddObject(o);
            }

            ///Creating from factory helper
            Vertices verts = PolygonTools.CreateRectangle(GraphicInfo.BackBufferWidth, 100);

            {
                IModelo2D model            = new SpriteFarseer(factory, verts, Color.Red);
                Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
                FarseerObject          fs  = new FarseerObject(fworld, model, 1, BodyType.Static);
                I2DObject o = new I2DObject(fs, mat, model);
                ///the origin of the created object will be in the center of it, this mean: if we draw it, the center of mass of it will be on the midle of the screen
                ///We need to translate it a bit down
                o.PhysicObject.Position = new Vector2(0, 250);
                this.World.AddObject(o);
            }

            ///Creating from factory helper
            verts = PolygonTools.CreateRectangle(GraphicInfo.BackBufferWidth, 100);
            {
                IModelo2D model            = new SpriteFarseer(factory, verts, Color.Red);
                Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
                FarseerObject          fs  = new FarseerObject(fworld, model, 1, BodyType.Static);
                I2DObject o = new I2DObject(fs, mat, model);
                ///the origin of the created object will be in the center of it, this mean: if we draw it, the center of mass of it will be on the midle of the screen
                ///We need to translate it a bit down
                o.PhysicObject.Position = new Vector2(GraphicInfo.BackBufferWidth, 450);
                this.World.AddObject(o);
            }

            ///Creating from factory helper
            verts = PolygonTools.CreateRectangle(100, GraphicInfo.BackBufferHeight);
            {
                IModelo2D model            = new SpriteFarseer(factory, verts, Color.Red);
                Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
                FarseerObject          fs  = new FarseerObject(fworld, model, 1, BodyType.Static);
                I2DObject o = new I2DObject(fs, mat, model);
                ///the origin of the created object will be in the center of it, this mean: if we draw it, the center of mass of it will be on the midle of the screen
                ///We need to translate it a bit down
                o.PhysicObject.Position = new Vector2(GraphicInfo.BackBufferWidth * 1.5f, 450);
                this.World.AddObject(o);
            }

            ///Creating from factory helper
            verts = PolygonTools.CreateRectangle(100, GraphicInfo.BackBufferHeight);
            {
                IModelo2D model            = new SpriteFarseer(factory, verts, Color.Red);
                Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
                FarseerObject          fs  = new FarseerObject(fworld, model, 1, BodyType.Static);
                I2DObject o = new I2DObject(fs, mat, model);
                ///the origin of the created object will be in the center of it, this mean: if we draw it, the center of mass of it will be on the midle of the screen
                ///We need to translate it a bit down
                o.PhysicObject.Position = new Vector2(-GraphicInfo.BackBufferWidth / 2, 150);
                this.World.AddObject(o);
            }

            ///creating a circle =P
            CircleShape circle = new CircleShape(50, 1);

            {
                IModelo2D model            = new SpriteFarseer(factory, circle, Color.Orange);
                Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
                FarseerObject          fs  = new FarseerObject(fworld, model);
                fs.Body.Restitution           = 0.95f;
                Tracked                       = new I2DObject(fs, mat, model);
                Tracked.PhysicObject.Position = new Vector2(0, -250); /// a middle of the screen + 250 pixels up
                this.World.AddObject(Tracked);
            }

            ///when space is pressed, perform the following action
            this.BindInput(new SimpleConcreteGestureInputPlayable(Microsoft.Xna.Framework.Input.Touch.GestureType.Hold,
                                                                  (a) =>
            {
                if (tracking == false)
                {
                    ///enable camera tracking
                    (this.World.Camera2D as Camera2D).TrackingBody           = Tracked;
                    (this.World.Camera2D as Camera2D).EnablePositionTracking = true;
                }
                else
                {
                    Vector2 pos = (this.World.Camera2D as Camera2D).Position;
                    ///reset the camera (recreating =P)
                    this.World.Camera2D          = new Camera2D(GraphicInfo);
                    this.World.Camera2D.Position = pos;
                }
                tracking = !tracking;
            }
                                                                  ));


            this.BindInput(new SimpleConcreteGestureInputPlayable(Microsoft.Xna.Framework.Input.Touch.GestureType.FreeDrag,
                                                                  (a) =>
            {
                ///tune this, make proportinal to elapsed time ..... =P
                this.World.Camera2D.MoveCamera(0.1f * a.Delta);
            }
                                                                  ));

            this.BindInput(new SimpleConcreteGestureInputPlayable(Microsoft.Xna.Framework.Input.Touch.GestureType.Pinch,
                                                                  (sample) =>
            {
                // if (lastDistance != 0)
                {
                    // get the current and previous locations of the two fingers
                    Vector2 a    = sample.Position;
                    Vector2 aOld = sample.Position - sample.Delta;
                    Vector2 b    = sample.Position2;
                    Vector2 bOld = sample.Position2 - sample.Delta2;

                    // figure out the distance between the current and previous locations
                    float d    = Vector2.Distance(a, b);
                    float dOld = Vector2.Distance(aOld, bOld);

                    // calculate the difference between the two and use that to alter the scale
                    float scaleChange         = (d - dOld) * .5f;
                    this.World.Camera2D.Zoom -= scaleChange;
                }
            }
                                                                  ));

            ///the basic ortographic 2D camera
            this.World.Camera2D = new Camera2D(GraphicInfo);
            base.LoadContent(GraphicInfo, factory, contentManager);
        }
예제 #27
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());
        }
예제 #28
0
        protected override void LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, PloobsEngine.SceneControl.IContentManager contentManager)
        {
            tile = factory.GetTexture2D("Textures/tile");
            FarseerWorld fworld = this.World.PhysicWorld as FarseerWorld;

            //ground
            {
                Vertices Vertices = new Vertices(3);
                Vertices.Add(new Vector2(-200, 0));
                Vertices.Add(new Vector2(0, 200));
                Vertices.Add(new Vector2(200, 0));

                SpriteFarseer          SpriteFarseer = new SpriteFarseer(factory, Vertices, Color.Red);
                Basic2DTextureMaterial mat           = new Basic2DTextureMaterial();
                FarseerObject          fs            = new FarseerObject(fworld, SpriteFarseer, 1, BodyType.Static);
                I2DObject o = new I2DObject(fs, mat, SpriteFarseer);
                this.World.AddObject(o);
            }

            ///from texture
            {
                Texture2D tex              = factory.GetTexture2D("Textures//goo");
                IModelo2D model            = new SpriteFarseer(tex);
                Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
                FarseerObject          fs  = new FarseerObject(fworld, tex);
                I2DObject o = new I2DObject(fs, mat, model);
                this.World.AddObject(o);
            }

            ///rectangle
            Vertices verts = PolygonTools.CreateRectangle(50, 50);

            {
                IModelo2D model = new SpriteFarseer(factory, verts, Color.Red);
                model.LayerDepth = 0;
                Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
                FarseerObject          fs  = new FarseerObject(fworld, model, 1, BodyType.Static);
                I2DObject o = new I2DObject(fs, mat, model);
                this.World.AddObject(o);
            }

            //rectangle
            //cria em Display
            verts = PolygonTools.CreateRectangle(50, 50);

            {
                IModelo2D model = new SpriteFarseer(factory, verts, Color.Green);
                model.LayerDepth = 1;
                Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
                FarseerObject          fs  = new FarseerObject(fworld, model, 1, BodyType.Static);
                I2DObject o = new I2DObject(fs, mat, model);

                o.PhysicObject.Position = new Vector2(50, 50);
                this.World.AddObject(o);
            }


            ///rectangle
            verts = PolygonTools.CreateRectangle(50, 50);
            {
                IModelo2D model = new SpriteFarseer(factory, verts, Color.Orange);
                model.LayerDepth = 0;
                Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
                FarseerObject          fs  = new FarseerObject(fworld, model, 1, BodyType.Static);
                I2DObject o = new I2DObject(fs, mat, model);
                o.PhysicObject.Position = new Vector2(-GraphicInfo.BackBufferWidth / 2, 0);
                this.World.AddObject(o);
            }

            ///circle
            CircleShape circle = new CircleShape(50, 1);

            {
                IModelo2D model            = new SpriteFarseer(factory, circle, Color.Yellow);
                Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
                FarseerObject          fs  = new FarseerObject(fworld, model);
                I2DObject o = new I2DObject(fs, mat, model);
                o.PhysicObject.Position = new Vector2(0, -GraphicInfo.BackBufferHeight / 2);
                this.World.AddObject(o);
            }

            ///animated sprite
            {
                Texture2D      tex = factory.GetTexture2D("Textures//DudeSheet");
                SpriteAnimated sa  = new SpriteAnimated(tex, 8, 2);
                sa.AddAnimation("ANIM1", 1, 8, 0);
                sa.AddAnimation("ANIM2", 2, 4, MathHelper.PiOver2);

                Basic2DTextureMaterial mat = new Basic2DTextureMaterial();
                Texture2D     frame        = factory.GetTexturePart(tex, sa.GetFrameRectangle("ANIM1", 0));
                FarseerObject fs           = new FarseerObject(fworld, frame);

                I2DObject sheet = new I2DObject(fs, mat, sa);
                sheet.PhysicObject.Position = new Vector2(100, 100);
                this.World.AddObject(sheet);
            }

            ///camera
            this.World.Camera2D = new Camera2D(GraphicInfo);
            base.LoadContent(GraphicInfo, factory, contentManager);
        }
예제 #29
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 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);
        }