Example #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TriangleMeshObject"/> class.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <param name="pos">The pos.</param>
        /// <param name="rotation">The rotation.</param>
        /// <param name="scale">The scale.</param>
        /// <param name="materialDescription">The material description.</param>
        public TriangleMeshObject(IModelo model, Vector3 pos, Matrix?rotation = null, Vector3?scale = null, MaterialDescription materialDescription = null)
        {
            if (materialDescription == null)
            {
                materialDescription = MaterialDescription.DefaultBepuMaterial();
            }

            if (!rotation.HasValue)
            {
                rotation = Matrix.Identity;
            }

            if (!scale.HasValue)
            {
                scale = Vector3.One;
            }

            System.Diagnostics.Debug.Assert(model != null);
            System.Diagnostics.Debug.Assert(scale != Vector3.Zero);

            this.rotation = rotation.Value;
            this.scale    = scale.Value;
            this.position = pos;
            Vector3[] vertices = null;
            int[]     indices  = null;
            ExtractData(ref vertices, ref indices, model);
            triangleGroup          = new StaticMesh(vertices, indices, new AffineTransform(scale.Value, Quaternion.CreateFromRotationMatrix(rotation.Value), position));
            faceVector             = Vector3.Transform(Vector3.Forward, triangleGroup.WorldTransform.Matrix);
            triangleGroup.Material = new BEPUphysics.Materials.Material(materialDescription.StaticFriction, materialDescription.DynamicFriction, materialDescription.Bounciness);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="MobileMeshObject "/> class.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <param name="pos">The pos.</param>
        /// <param name="rotation">The rotation.</param>
        /// <param name="scale">The scale.</param>
        /// <param name="materialDescription">The material description.</param>
        /// <param name="MobileMeshSolidity">The mobile mesh solidity.</param>
        /// <param name="mass">The mass.</param>
        public MobileMeshObject(IModelo model, Vector3 pos, Matrix?rotation = null, Vector3?scale = null, MaterialDescription materialDescription = null, MobileMeshSolidity MobileMeshSolidity = MobileMeshSolidity.Solid, float mass = 10)
        {
            if (materialDescription == null)
            {
                materialDescription = MaterialDescription.DefaultBepuMaterial();
            }

            if (!rotation.HasValue)
            {
                rotation = Matrix.Identity;
            }

            if (!scale.HasValue)
            {
                scale = Vector3.One;
            }


            System.Diagnostics.Debug.Assert(scale != Vector3.Zero);
            System.Diagnostics.Debug.Assert(model != null);

            this.scale = scale.Value;
            Vector3[] vertices = null;
            int[]     indices  = null;
            ExtractData(ref vertices, ref indices, model);
            triangleGroup          = new MobileMesh(vertices, indices, new AffineTransform(scale.Value, Quaternion.CreateFromRotationMatrix(rotation.Value), pos), MobileMeshSolidity, mass);
            triangleGroup.Material = new BEPUphysics.Materials.Material(materialDescription.StaticFriction, materialDescription.DynamicFriction, materialDescription.Bounciness);
        }
    private void createobjs(int minus = 0)
    {
        int numColumns = 7 - minus;
        int numRows    = 7 - minus;
        int numHigh    = 7 - minus;

        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(GraphicFactory, "..\\Content\\Model\\cubo");
                    sm.SetTexture(GraphicFactory.CreateTexture2DColor(1, 1, StaticRandom.RandomColor()), TextureType.DIFFUSE);
                    MaterialDescription md = MaterialDescription.DefaultBepuMaterial();
                    md.Bounciness = 1;
                    BoxObject pi = new BoxObject(new Vector3(separation * i, k * separation, separation * j), 1, 1, 1, 1, new Vector3(1), Matrix.Identity, md);
                    pi.Entity.AngularDamping = 0f;
                    ForwardXNABasicShader shader = new ForwardXNABasicShader();
                    IMaterial             mat    = new ForwardMaterial(shader);
                    IObject obj5 = new IObject(mat, sm, pi);
                    this.World.AddObject(obj5);
                    shader.BasicEffect.EnableDefaultLighting();
                }
            }
        }
    }
Example #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GhostObject"/> class.
 /// DEfault Object in 0,0,0 identity rotation and 1,1,1 scale
 /// </summary>
 public GhostObject(BoundingBox?bb = null)
     : base(MaterialDescription.DefaultBepuMaterial(), 0)
 {
     this.pos   = Vector3.Zero;
     this.ori   = Matrix.Identity;
     this.scale = Vector3.One;
     this.bb    = bb;
 }
Example #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TerrainObject"/> class.
        /// </summary>
        /// <param name="gfactory">The gfactory.</param>
        /// <param name="heightmapTexture">The heighmap texture.</param>
        /// <param name="translation">The translation.</param>
        /// <param name="rotation">The rotation.</param>
        /// <param name="materialDesc">The material desc.</param>
        /// <param name="XSpacing">The X spacing.</param>
        /// <param name="ZSpacing">The Z spacing.</param>
        /// <param name="heightMultipler">The height multipler.</param>
        public TerrainObject(GraphicFactory gfactory, Texture2D heightmapTexture, Vector3 translation, Matrix?rotation = null, MaterialDescription materialDesc = null, float XSpacing = 1, float ZSpacing = 1, float heightMultipler = 10)
        {
            if (!rotation.HasValue)
            {
                rotation = Matrix.Identity;
            }

            if (materialDecription == null)
            {
                materialDecription = MaterialDescription.DefaultBepuMaterial();
            }

            this.heightMultipler = heightMultipler;

            //Used to calculate ther proportion of the xNormalized in the getHeightFast method
            xScale = XSpacing;
            zScale = ZSpacing;

            sourceImage = heightmapTexture;
            int xLength = sourceImage.Width;
            int yLength = sourceImage.Height;

            terrainWidth  = xLength;
            terrainHeight = yLength;

            this.rotation = rotation.Value;
            //this.scale = scale;

            Color[] colorData = new Color[xLength * yLength];
            sourceImage.GetData <Color>(colorData);

            var heightStore = new float[xLength, yLength];

            for (int i = 0; i < xLength; i++)
            {
                for (int j = 0; j < yLength; j++)
                {
                    Color color = colorData[j * xLength + i];
                    heightStore[i, j] = (color.R) / heightMultipler;

                    if (heightStore[i, j] > maxHeight)
                    {
                        maxHeight = heightStore[i, j];
                    }
                    if (heightStore[i, j] < minHeight)
                    {
                        minHeight = heightStore[i, j];
                    }
                }
            }
            //Create the terrain.
            BEPUphysics.CollisionShapes.TerrainShape shape = new BEPUphysics.CollisionShapes.TerrainShape(heightStore, BEPUphysics.CollisionShapes.QuadTriangleOrganization.BottomLeftUpperRight);

            terrain = new Terrain(shape, new BEPUphysics.MathExtensions.AffineTransform(new Vector3(XSpacing, 1, ZSpacing), Quaternion.CreateFromRotationMatrix(rotation.Value), new Vector3(-xLength * XSpacing / 2, 0, -yLength * ZSpacing / 2) + translation));
            terrain.ImproveBoundaryBehavior = true;

            SetMaterialDescription(materialDesc);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="BepuEntityObject"/> class.
 /// </summary>
 /// <param name="md">The md.</param>
 /// <param name="mass">The mass.</param>
 public BepuEntityObject(MaterialDescription md, float mass)
 {
     if (md == null)
     {
         md = MaterialDescription.DefaultBepuMaterial();
     }
     this.materialDecription = md;
     this.mass = mass;
 }
        protected IObject CreateSphereMeshModel(String fileName, Vector3 position, Matrix orientation, float raio, float scale = 1, float mass = 10)
        {
            SimpleModel simpleModel = new SimpleModel(graphicFactory, fileName);
            ///Physic info (position, rotation and scale are set here)
            SphereObject tmesh = new SphereObject(position, raio, mass, scale, 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
            return(new IObject(fmaterial, simpleModel, tmesh));
        }
Example #8
0
        private IObject CreateSphere(Vector3 pos, Matrix ori, Color Color)
        {
            ///Load a Model with a custom texture
            SimpleModel sm2 = new SimpleModel(GraphicFactory, "Model\\ball");

            sm2.SetTexture(GraphicFactory.CreateTexture2DColor(1, 1, Color, false), TextureType.DIFFUSE);
            DeferredNormalShader nd  = new DeferredNormalShader();
            IMaterial            m   = new DeferredMaterial(nd);
            SphereObject         pi2 = new SphereObject(pos, 1, 0.05f, 10, MaterialDescription.DefaultBepuMaterial());
            IObject o = new IObject(m, sm2, pi2);

            return(o);
        }
Example #9
0
        /// <summary>
        /// Create a simple Sphere object
        /// </summary>
        /// <param name="pos"></param>
        /// <param name="ori"></param>
        /// <returns></returns>
        private IObject SpawnPrimitive(Vector3 pos, Matrix ori)
        {
            ///Load a Model with a custom texture
            SimpleModel sm2 = new SimpleModel(factory, "Model\\ball");

            sm2.SetTexture(factory.CreateTexture2DColor(1, 1, Color.White, false), TextureType.DIFFUSE);
            ForwardXNABasicShader nd  = new ForwardXNABasicShader();
            IMaterial             m   = new ForwardMaterial(nd);
            SphereObject          pi2 = new SphereObject(pos, 1, 0.5f, 1, MaterialDescription.DefaultBepuMaterial());
            IObject o = new IObject(m, sm2, pi2);

            return(o);
        }
        /// <summary>
        /// Create a simple Sphere object
        /// </summary>
        /// <param name="pos"></param>
        /// <param name="ori"></param>
        /// <returns></returns>
        private ThrowParticlesObject SpawnPrimitive(DefaultSprite3DBillboardParticleSystem particleSystem, Vector3 pos, Matrix ori)
        {
            ///Load a Model with a custom texture
            SimpleModel sm2 = new SimpleModel(scene.GraphicFactory, "Model\\ball");

            sm2.SetTexture(scene.GraphicFactory.CreateTexture2DColor(1, 1, Color.White, false), TextureType.DIFFUSE);
            DeferredNormalShader nd  = new DeferredNormalShader();
            IMaterial            m   = new DeferredMaterial(nd);
            SphereObject         pi2 = new SphereObject(pos, 1, 10, 1, MaterialDescription.DefaultBepuMaterial());
            ThrowParticlesObject o   = new ThrowParticlesObject(particleSystem, m, sm2, pi2);

            return(o);
        }
        protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager)
        {
            base.LoadContent(GraphicInfo, factory, contentManager);

            RasterizerState          = new RasterizerState();
            RasterizerState.FillMode = FillMode.WireFrame;

            createterrain();


            int numColumns = 5;
            int numRows    = 5;


            float separation = 20;

            for (int i = 0; i < numRows; i++)
            {
                for (int j = 0; j < numColumns; j++)
                {
                    SimpleModel sm = new SimpleModel(GraphicFactory, "..\\Content\\Model\\cubo");
                    sm.SetTexture(GraphicFactory.CreateTexture2DColor(1, 1, StaticRandom.RandomColor()), TextureType.DIFFUSE);
                    MaterialDescription   md      = MaterialDescription.DefaultBepuMaterial();
                    BoxObject             pi      = new BoxObject(new Vector3(separation * i - 50, 50, separation * j - 50), 1, 1, 1, 1, new Vector3(5), Matrix.Identity, md);
                    ForwardXNABasicShader shader2 = new ForwardXNABasicShader();
                    IMaterial             mat     = new ForwardMaterial(shader2);
                    IObject obj5 = new IObject(mat, sm, pi);
                    this.World.AddObject(obj5);
                    shader2.BasicEffect.EnableDefaultLighting();
                    objs.Add(obj5);
                    pi.isMotionLess = true;
                }
            }

            RotatingCamera cam = new RotatingCamera(this);

            this.World.CameraManager.AddCamera(cam);

            SkyBoxSetTextureCube stc = new SkyBoxSetTextureCube("Textures//cubeMap");

            CommandProcessor.getCommandProcessor().SendCommandAssyncronous(stc);
        }
Example #12
0
        private void CreateBall(Vector3 pos)
        {
            ///Create a Simple Model
            SimpleModel model = new SimpleModel(GraphicFactory, "..\\Content\\Model\\ball");

            model.SetTexture(GraphicFactory.CreateTexture2DColor(1, 1, StaticRandom.RandomColor()), TextureType.DIFFUSE);

            ///Create a Physic Object
            IPhysicObject pobj = new SphereObject(pos, 1, 10, 1, MaterialDescription.DefaultBepuMaterial());

            pobj.isMotionLess = true;
            ///Create a shader
            IShader nd = new DeferredNormalShader();

            ///Create a Material
            IMaterial material = new DeferredMaterial(nd);
            ///Create a an Object that englobs everything and add it to the world
            IObject obj = new IObject(material, model, pobj);

            this.World.AddObject(obj);
            objects.Add(obj);
        }
Example #13
0
        private void CreateThrash(Vector3 pos)
        {
            ///Create a Simple Model
            ///thash Has a Texture Inside the .X file (not the texture itself, just the name of it)
            ///The simpleModel will find it and will attach to the Object
            IModelo model = new SimpleModel(GraphicFactory, "..\\Content\\Model\\trash");

            ///Create a Physic Object
            IPhysicObject pobj = new CapsuleObject(pos, 2, 1, 10, Matrix.Identity, MaterialDescription.DefaultBepuMaterial());

            pobj.isMotionLess = true;
            ///Create a shader
            IShader nd = new DeferredNormalShader();

            ///Create a Material
            IMaterial material = new DeferredMaterial(nd);
            ///Create a an Object that englobs everything and add it to the world
            IObject obj = new IObject(material, model, pobj);

            this.World.AddObject(obj);
            objects.Add(obj);
        }
        void key_KeyStateChange(InputPlayableKeyBoard ipk)
        {
            NetWorkClientObject no = new NetWorkClientObject("simpleball",

                                                             (mes) =>
            {
                mes.WriteSphere(new Vector3(50, 50, 10), 1, 1, 10, MaterialDescription.DefaultBepuMaterial());
                return(mes);
            },
                                                             (mes, id) =>
            {
                SimpleModel simpleModel     = new SimpleModel(this.GraphicFactory, "Model//ball");
                SphereObject sphere         = mes.ReadSphere();
                DeferredNormalShader shader = new DeferredNormalShader();
                DeferredMaterial fmaterial  = new DeferredMaterial(shader);
                IObject obj = new IObject(fmaterial, simpleModel, sphere);
                obj.SetId(id);
                return(obj);
            }
                                                             );

            client.CreateNetWorkObject(no);
        }
    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);
    }
Example #16
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(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager)
        {
            base.LoadContent(GraphicInfo, factory, contentManager);

            SimpleModel simpleModel = new SimpleModel(factory, "Model//block");

            simpleModel.SetTexture(factory.CreateTexture2DColor(1, 1, Color.White), TextureType.DIFFUSE);
            BoxObject tmesh = new BoxObject(new Vector3(0, 10, 0), 1, 1, 1, 50, new  Vector3(5000, 1, 5000), Matrix.Identity, MaterialDescription.DefaultBepuMaterial());

            tmesh.isMotionLess = true;
            DeferredNormalShader shader    = new DeferredNormalShader();
            DeferredMaterial     fmaterial = new DeferredMaterial(shader);
            IObject obj = new IObject(fmaterial, simpleModel, tmesh);

            this.World.AddObject(obj);

            {
                List <BilboardInstance> poss = new List <BilboardInstance>();
                for (int i = -10; i < 20; i++)
                {
                    for (int j = -10; j < 20; j++)
                    {
                        float x, y;
                        x = i * 100;
                        y = j * 100;
                        BilboardInstance bi = new BilboardInstance();
                        bi.Scale    = new Vector2(100, 100);
                        bi.Position = new Vector3(x, 5, y);
                        poss.Add(bi);
                    }
                }

                ///same as before, just the name of the class change
                ///You can change the position of a individual bilboard using bm.GetBilboardInstances(), updating the structure recieved and
                ///using bm.SetBilboardInstances(). Dont do this every frame pls =P
                ///You can change lots of parameters of the DeferredInstancedBilboardShader, check it
                InstancedBilboardModel          bm = new InstancedBilboardModel(factory, "Bilbs", "..\\Content\\Textures\\tree", poss.ToArray());
                DeferredInstancedBilboardShader cb = new DeferredInstancedBilboardShader(BilboardType.Cilindric);
                DeferredMaterial matfor            = new DeferredMaterial(cb);
                GhostObject      go   = new GhostObject();
                IObject          obj2 = new IObject(matfor, bm, go);
                this.World.AddObject(obj2);
            }


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


            CameraFirstPerson cam = new CameraFirstPerson(MathHelper.ToRadians(-50), MathHelper.ToRadians(-15), new Vector3(-200, 300, 250), GraphicInfo);
            this.World.CameraManager.AddCamera(cam);

            SkyBoxSetTextureCube stc = new SkyBoxSetTextureCube("Textures//grassCube");
            CommandProcessor.getCommandProcessor().SendCommandAssyncronous(stc);
        }
Example #18
0
        protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager)
        {
            base.LoadContent(GraphicInfo, factory, contentManager);

            {
                SimpleModel           simpleModel = new SimpleModel(factory, "Model//cenario");
                TriangleMeshObject    tmesh       = new TriangleMeshObject(simpleModel, Vector3.Zero, Matrix.Identity, Vector3.One, MaterialDescription.DefaultBepuMaterial());
                ForwardXNABasicShader shader      = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default());
                ForwardMaterial       fmaterial   = new ForwardMaterial(shader);
                IObject obj = new IObject(fmaterial, simpleModel, tmesh);
                this.World.AddObject(obj);
            }

            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;
            button.Click += new TomShane.Neoforce.Controls.EventHandler(button_Click);

            // Add the window control to the manager processing queue.
            guiManager.Manager.Add(window);

            this.World.CameraManager.AddCamera(new CameraFirstPerson(false, GraphicInfo));

            SkyBoxSetTextureCube stc = new SkyBoxSetTextureCube("Textures//grassCube");

            CommandProcessor.getCommandProcessor().SendCommandAssyncronous(stc);
        }
        /// <summary>
        /// Load content for the screen.
        /// </summary>
        /// <param name="GraphicInfo"></param>
        /// <param name="factory"></param>
        /// <param name="contentManager"></param>
        protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager)
        {
            base.LoadContent(GraphicInfo, factory, contentManager);

            {
                SimpleModel simpleModel = new SimpleModel(factory, "Model//block");
                simpleModel.SetTexture(factory.CreateTexture2DColor(1, 1, Color.White), TextureType.DIFFUSE);
                ///Physic info (position, rotation and scale are set here)
                BoxObject tmesh = new BoxObject(Vector3.Zero, 1, 1, 1, 10, new Vector3(1000, 1, 1000), Matrix.Identity, MaterialDescription.DefaultBepuMaterial());
                tmesh.isMotionLess = true;
                ///Forward Shader (look at this shader construction for more info)
                ForwardXNABasicShader shader = new ForwardXNABasicShader();
                ///Deferred material
                ForwardMaterial fmaterial = new ForwardMaterial(shader);
                ///The object itself
                IObject obj = new IObject(fmaterial, simpleModel, tmesh);
                ///Add to the world
                this.World.AddObject(obj);

                ///create the fsm
                fsm = new StateMachine();
                ///atach the fsm to the object using the attachment property (there are lots of ways of doing this like extending the iobject class)
                AttachmentUpdate atachment = new AttachmentUpdate(
                    (a, b) => fsm.UpdateFSM(b)
                    );
                obj.IObjectAttachment.Add(atachment);

                ////Sample usage
                ///Press Space to go to state2 and press enter in state 2 to get back to state1 =P
                ///create state 1
                {
                    StateSample state1 = new StateSample("state1", obj);
                    state1.NextStateFunc =
                        (a) =>
                    {
                        KeyboardState kstate = Keyboard.GetState();
                        if (kstate.IsKeyDown(Keys.Space))
                        {
                            return("state2");
                        }
                        return(null);
                    };
                    fsm.AddState(state1);

                    ///SET THE CURRENT STATE
                    fsm.SetCurrentState(state1.Name);
                }



                ///create state 2
                {
                    StateSample state2 = new StateSample("state2", obj);
                    state2.NextStateFunc =
                        (a) =>
                    {
                        KeyboardState kstate = Keyboard.GetState();
                        if (kstate.IsKeyDown(Keys.Enter))
                        {
                            return("state1");
                        }
                        return(null);
                    };
                    fsm.AddState(state2);
                }
            }

            ///add a camera
            this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo));
        }
Example #20
0
        IObject[] wl_OnCreateIObject(IWorld world, GraphicFactory factory, GraphicInfo ginfo, ObjectInformation[] mi)
        {
            IModelo         model  = new CustomModel(factory, mi);
            IPhysicObject   po     = new TriangleMeshObject(model, Vector3.Zero, Matrix.Identity, Vector3.One, MaterialDescription.DefaultBepuMaterial());
            IShader         shader = new ForwardXNABasicShader();
            ForwardMaterial dm     = new ForwardMaterial(shader);

            return(new IObject[] { new IObject(dm, model, po) });
        }
Example #21
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);
        }
Example #23
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);

            RegisterDebugDrawCommand rc = new RegisterDebugDrawCommand(ddrawer);

            CommandProcessor.getCommandProcessor().SendCommandAssyncronous(rc);

            ddrawer.AddShape(new DebugBox(new BoundingBox(new Vector3(-50), new Vector3(50)), Color.Red));

            DebugLine dl = new DebugLine(Vector3.Zero, new Vector3(1000, 1000, 1000), Color.Red);

            ddrawer.AddShape(dl);

            DebugLines dls = new DebugLines();

            ddrawer.AddShape(dls);

            dls.AddLine(Vector3.Zero, new Vector3(-1000, 1000, -1000), Color.Green);
            dls.AddLine(Vector3.Zero, new Vector3(-1000, 1000, 1000), Color.Pink);

            SimpleModel          simpleModel = new SimpleModel(factory, "Model//cenario");
            TriangleMeshObject   tmesh       = new TriangleMeshObject(simpleModel, Vector3.Zero, Matrix.Identity, Vector3.One, MaterialDescription.DefaultBepuMaterial());
            DeferredNormalShader shader      = new DeferredNormalShader();
            DeferredMaterial     fmaterial   = new DeferredMaterial(shader);
            IObject obj = new IObject(fmaterial, simpleModel, tmesh);

            this.World.AddObject(obj);

            ///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));
        }
        protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager)
        {
            base.LoadContent(GraphicInfo, factory, contentManager);

            {
                SimpleModel           simpleModel = new SimpleModel(factory, "Model//cenario");
                TriangleMeshObject    tmesh       = new TriangleMeshObject(simpleModel, Vector3.Zero, Matrix.Identity, Vector3.One, MaterialDescription.DefaultBepuMaterial());
                ForwardXNABasicShader shader      = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default());
                ForwardMaterial       fmaterial   = new ForwardMaterial(shader);
                IObject obj = new IObject(fmaterial, simpleModel, tmesh);
                this.World.AddObject(obj);
            }
            {
                SimpleModel      simpleModel = new SimpleModel(factory, "Model//uzi");
                MobileMeshObject tmesh       = new MobileMeshObject(simpleModel, new Vector3(100, 100, 10), Matrix.Identity, Vector3.One * 50, MaterialDescription.DefaultBepuMaterial(), BEPUphysics.CollisionShapes.MobileMeshSolidity.DoubleSided, 10);
                //TriangleMeshObject tmesh = new TriangleMeshObject(simpleModel, new Vector3(100, 100, 10), Matrix.Identity, Vector3.One * 50, MaterialDescription.DefaultBepuMaterial());
                ForwardXNABasicShader shader    = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default());
                ForwardMaterial       fmaterial = new ForwardMaterial(shader);
                IObject obj = new IObject(fmaterial, simpleModel, tmesh);
                this.World.AddObject(obj);
            }

            new LightThrowBepu(this.World, factory);
            this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo));
        }
Example #25
0
        protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager)
        {
            base.LoadContent(GraphicInfo, factory, contentManager);

            {
                SimpleModel           simpleModel = new SimpleModel(factory, "Model//cenario");
                TriangleMeshObject    tmesh       = new TriangleMeshObject(simpleModel, Vector3.Zero, Matrix.Identity, Vector3.One, MaterialDescription.DefaultBepuMaterial());
                ForwardXNABasicShader shader      = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default());
                ForwardMaterial       fmaterial   = new ForwardMaterial(shader);
                IObject obj = new IObject(fmaterial, simpleModel, tmesh);
                this.World.AddObject(obj);
            }

            {
                TModelo <VertexPositionColor> simpleModel = new TModelo <VertexPositionColor>(factory,
                                                                                              new VertexPositionColor[]
                {
                    new VertexPositionColor(new Vector3(50, 10, 0), Color.Green),
                    new VertexPositionColor(new Vector3(10, 10, 0), Color.Green),
                    new VertexPositionColor(new Vector3(0, 100, 0), Color.Green)
                }
                                                                                              , null,
                                                                                              Matrix.Identity, null, -1, false, 1, BufferUsage.None);

                TriangleMeshObject    tmesh     = new TriangleMeshObject(simpleModel, new Vector3(100, 10, 10), Matrix.Identity, Vector3.One * 2, MaterialDescription.DefaultBepuMaterial());
                ForwardXNABasicShader shader    = new ForwardXNABasicShader();
                ForwardMaterial       fmaterial = new ForwardMaterial(shader);
                IObject obj = new IObject(fmaterial, simpleModel, tmesh);
                this.World.AddObject(obj);

                shader.BasicEffect.TextureEnabled     = false;
                shader.BasicEffect.VertexColorEnabled = true;
            }

            {
                TConstructiveModelo <VertexPositionColor> simpleModel = new TConstructiveModelo <VertexPositionColor>(factory, Matrix.CreateTranslation(new Vector3(100)), null, -1, false, BufferUsage.None);
                simpleModel.AddVertex(new VertexPositionColor(new Vector3(50, 10, 0), Color.Red));
                simpleModel.AddVertex(new VertexPositionColor(new Vector3(100, 10, 0), Color.Red));
                simpleModel.AddVertex(new VertexPositionColor(new Vector3(0, 100, 0), Color.Red));
                simpleModel.BuildModel();

                TriangleMeshObject    tmesh     = new TriangleMeshObject(simpleModel, new Vector3(100, 10, 10), Matrix.Identity, Vector3.One * 2, MaterialDescription.DefaultBepuMaterial());
                ForwardXNABasicShader shader    = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default());
                ForwardMaterial       fmaterial = new ForwardMaterial(shader);
                IObject obj = new IObject(fmaterial, simpleModel, tmesh);
                this.World.AddObject(obj);

                shader.BasicEffect.TextureEnabled     = false;
                shader.BasicEffect.VertexColorEnabled = true;
            }


            this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo));

            this.RenderTechnic.AddPostEffect(new BlackWhitePostEffect());
        }
        protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager)
        {
            base.LoadContent(GraphicInfo, factory, contentManager);
            {
                //supose you have these: (just an idiot sample -- dummy values)
                int[]     indices = new int[] { 0, 1, 2, 1, 2, 3 };
                Vector3[] vecs    = new Vector3[] { new Vector3(0), new Vector3(4), new Vector3(2), new Vector3(1) };

                ///This is not good, cause it is very cpu intensive
                ///try to update the vertices array instead of creating one every time
                VertexPositionTexture[] vertices = new VertexPositionTexture[vecs.Length];
                for (int i = 0; i < vecs.Length; i++)
                {
                    VertexPositionTexture v = new VertexPositionTexture(vecs[i], Vector2.Zero);
                    vertices[i] = v;
                }


                //TO CONSTRUCT
                ////Creating the terrain
                VoxelTerrainModel    VoxelTerrainModel = new PloobsProjectTemplate.VoxelTerrainModel(factory, "ANY_NAME", "Textures//goo", indices, vertices);
                TriangleMeshObject   tm      = new TriangleMeshObject(VoxelTerrainModel, Vector3.Zero, Matrix.Identity, Vector3.One, MaterialDescription.DefaultBepuMaterial());
                DeferredNormalShader shader2 = new DeferredNormalShader();
                IMaterial            mat     = new DeferredMaterial(shader2);
                IObject obj2 = new IObject(mat, VoxelTerrainModel, tm);


                ///TO UPDATE
                ///PHYSIC
                ///to update the triangle mesh date (updated version of indices/vertices ....)
                tm.StaticMesh.Mesh.Data.Indices  = indices;
                tm.StaticMesh.Mesh.Data.Vertices = vecs;

                //if you NOT changed the indices (slower)
                tm.StaticMesh.Mesh.Tree.Reconstruct();
                //if you changed the indices (faster)
                tm.StaticMesh.Mesh.Tree.Refit();



                ///MODEL (see the VoxelTerrainModel  ) implementation
                VoxelTerrainModel.Vertices = vertices;
                VoxelTerrainModel.Indices  = indices;
            }

            {
                SimpleModel           simpleModel = new SimpleModel(factory, "Model//cenario");
                TriangleMeshObject    tmesh       = new TriangleMeshObject(simpleModel, Vector3.Zero, Matrix.Identity, Vector3.One, MaterialDescription.DefaultBepuMaterial());
                ForwardXNABasicShader shader      = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default());
                ForwardMaterial       fmaterial   = new ForwardMaterial(shader);
                IObject obj = new IObject(fmaterial, simpleModel, tmesh);
                this.World.AddObject(obj);
            }
            {
                SimpleModel           simpleModel = new SimpleModel(factory, "Model//uzi");
                TriangleMeshObject    tmesh       = new TriangleMeshObject(simpleModel, new Vector3(100, 10, 10), Matrix.Identity, Vector3.One * 10, MaterialDescription.DefaultBepuMaterial());
                ForwardXNABasicShader shader      = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default());
                ForwardMaterial       fmaterial   = new ForwardMaterial(shader);
                IObject obj = new IObject(fmaterial, simpleModel, tmesh);
                this.World.AddObject(obj);
            }

            this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo));

            this.RenderTechnic.AddPostEffect(new BlackWhitePostEffect());
        }
Example #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());
        }
        protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager)
        {
            base.LoadContent(GraphicInfo, factory, contentManager);

            {
                SimpleModel           simpleModel = new SimpleModel(factory, "Model//cenario");
                TriangleMeshObject    tmesh       = new TriangleMeshObject(simpleModel, Vector3.Zero, Matrix.Identity, Vector3.One, MaterialDescription.DefaultBepuMaterial());
                ForwardXNABasicShader shader      = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default());
                ForwardMaterial       fmaterial   = new ForwardMaterial(shader);
                IObject obj = new IObject(fmaterial, simpleModel, tmesh);
                this.World.AddObject(obj);
            }

            for (int i = 0; i < 10; i++)
            {
                for (int j = 0; j < 10; j++)
                {
                    SimpleModel           simpleModel = new SimpleModel(factory, "Model//uzi");
                    TriangleMeshObject    tmesh       = new TriangleMeshObject(simpleModel, new Vector3(25 * j, 30, 15 * i), Matrix.Identity, Vector3.One * 10, MaterialDescription.DefaultBepuMaterial());
                    ForwardXNABasicShader shader      = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default());
                    ForwardMaterial       fmaterial   = new ForwardMaterial(shader);
                    IObject obj = new IObject(fmaterial, simpleModel, tmesh);
                    obj.OnUpdate += new OnUpdate(obj_OnUpdate);
                    this.World.AddObject(obj);
                }
            }

            this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo));
        }
        protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager)
        {
            base.LoadContent(GraphicInfo, factory, contentManager);

            {
                SimpleModel simpleModel = new SimpleModel(factory, "Model//block");
                simpleModel.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Red), TextureType.DIFFUSE);
                BoxObject tmesh = new BoxObject(new Vector3(0), 1, 1, 1, 10, new Vector3(1000, 1, 1000), Matrix.Identity, MaterialDescription.DefaultBepuMaterial());
                tmesh.isMotionLess = true;
                ForwardTransparenteShader shader = new ForwardTransparenteShader();
                shader.TransparencyLevel = 0.2f;
                ForwardMaterial fmaterial = new ForwardMaterial(shader);
                IObject         obj       = new IObject(fmaterial, simpleModel, tmesh);
                this.World.AddObject(obj);
            }


            Simulator.setTimeStep(0.10f);
            Simulator.setAgentDefaults(15.0f, 25, 5.0f, 5.0f, 2.0f, new Vector3());

            for (int i = 0; i < 20; i++)
            {
                for (int j = 0; j < 20; j++)
                {
                    SimpleModel simpleModel = new SimpleModel(factory, "Model//block");
                    simpleModel.SetTexture(factory.CreateTexture2DColor(1, 1, Color.White), TextureType.DIFFUSE);
                    GhostObject           tmesh     = new GhostObject(new Vector3(100 + j * 15, 5, i * 15), Matrix.Identity, new Vector3(1, 1, 1));
                    ForwardXNABasicShader shader    = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default());
                    ForwardMaterial       fmaterial = new ForwardMaterial(shader);
                    int       id  = Simulator.addAgent(tmesh.Position);
                    RVOObject obj = new RVOObject(id, fmaterial, simpleModel, tmesh);
                    obj.OnUpdate += new OnUpdate(obj_OnUpdate); /// dummy position update way =p
                    this.World.AddObject(obj);
                }
            }

            this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo));

            Picking p = new Picking(this, 1000);

            p.OnPickedLeftButton += new OnPicked(p_OnPickedLeftButton);
        }
        protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager)
        {
            base.LoadContent(GraphicInfo, factory, contentManager);
            {
                SimpleModel          simpleModel = new SimpleModel(factory, "Model//cenario");
                TriangleMeshObject   tmesh       = new TriangleMeshObject(simpleModel, Vector3.Zero, Matrix.Identity, Vector3.One, MaterialDescription.DefaultBepuMaterial());
                DeferredNormalShader shader      = new DeferredNormalShader();
                DeferredMaterial     fmaterial   = new DeferredMaterial(shader);
                IObject obj = new IObject(fmaterial, simpleModel, tmesh);
                this.World.AddObject(obj);
            }


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

            CameraFirstPerson cam = new CameraFirstPerson(GraphicInfo);
            //cam.FarPlane = 100;
            this.World.CameraManager.AddCamera(cam);

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


            {
                ///Add Decal To the Decal Component
                ///Texture
                Texture2D texture = factory.GetTexture2D("Textures//goo");
                ///The projection Matrix
                var projection = Matrix.CreatePerspectiveFieldOfView(cam.FieldOfView / 20, cam.AspectRatio, 1, 2000);

                ///The view Matrix
                var view = Matrix.CreateLookAt(
                    new Vector3(500, 300, 200),
                    new Vector3(0, 0, 0),
                    Vector3.Up
                    );
                Decal decal = new Decal(texture, view, projection);
                DecalComponent.Decals.Add(decal);
            }
            {
                ///Add Decal To the Decal Component
                ///Texture
                Texture2D texture = factory.GetTexture2D("Textures//goo");
                ///The projection Matrix
                var projection = Matrix.CreatePerspectiveFieldOfView(cam.FieldOfView / 10, cam.AspectRatio, 1, 2000);

                ///The view Matrix
                var view = Matrix.CreateLookAt(
                    new Vector3(500, 500, 700),
                    new Vector3(-200, 50, -10),
                    Vector3.Up
                    );
                Decal decal = new Decal(texture, view, projection);
                DecalComponent.Decals.Add(decal);
            }

            SkyBoxSetTextureCube stc = new SkyBoxSetTextureCube("Textures//grasscube");
            CommandProcessor.getCommandProcessor().SendCommandAssyncronous(stc);
        }