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

            ///Uncoment to add your model
            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());
            ///Forward Shader (look at this shader construction for more info)
            ForwardXNABasicShader shader = new ForwardXNABasicShader();
            ///Forward material
            ForwardMaterial fmaterial = new ForwardMaterial(shader);
            ///The object itself
            IObject obj = new IObject(fmaterial, simpleModel, tmesh);

            ///Add to the world
            this.World.AddObject(obj);

            this.RenderTechnic.AddPostEffect(MotionBlurPostEffect);
            this.RenderTechnic.AddPostEffect(BloomPostEffect);

            BloomPostEffect.Enabled      = false;
            MotionBlurPostEffect.Enabled = false;

            blurdefault = MotionBlurPostEffect.Amount;

            RotatingCamera cam = new RotatingCamera(this, new Vector3(0, -100, -400));

            this.World.CameraManager.AddCamera(cam);

            RasterizerState          = new RasterizerState();
            RasterizerState.CullMode = CullMode.None;
        }
Example #2
0
        /// <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);

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

            ///Forward Shader (look at this shader construction for more info)
            TerrainMaterial material = new TerrainMaterial(factory, "Terrain//HeightMap");
            ///The object itself
            TerrainObject to  = new TerrainObject(factory, Vector3.Zero, Matrix.Identity, material.Model.GetHeights(), MaterialDescription.DefaultBepuMaterial());
            IObject       obj = new IObject(material, null, to);

            ///Add to the world
            this.World.AddObject(obj);

            ///add a camera
            RotatingCamera cam = new RotatingCamera(this, new Vector3(-200, -100, -300));

            this.World.CameraManager.AddCamera(cam);

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

            CommandProcessor.getCommandProcessor().SendCommandAssyncronous(stc);


            {
                Texture2D   t           = factory.CreateTexture2DColor(1, 1, Color.Red);
                SimpleModel simpleModel = new SimpleModel(factory, "Model/block");
                simpleModel.SetTexture(t);
                ///Forward Shader (look at this shader construction for more info)
                ForwardXNABasicShader shader = new ForwardXNABasicShader();
                ///Forward material
                ForwardMaterial fmaterial = new ForwardMaterial(shader);
                for (int i = 0; i < 10; i++)
                {
                    for (int j = 0; j < 5; j++)
                    {
                        ///Physic info (position, rotation and scale are set here)
                        BoxObject tmesh = new BoxObject(new Vector3(j * 10 + 200, 100, i * 10 + 200), 1, 1, 1, 10, Vector3.One * 2, Matrix.Identity, MaterialDescription.DefaultBepuMaterial());
                        ///The object itself
                        obj = new IObject(fmaterial, simpleModel, tmesh);
                        ///Add to the world
                        this.World.AddObject(obj);
                        objs.Add(obj);
                        tmesh.isMotionLess = true;
                    }
                }
                shader.BasicEffect.EnableDefaultLighting();
            }
        }
        protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager)
        {
            base.LoadContent(GraphicInfo, factory, contentManager);
            {
                createmarine();
            }

            RotatingCamera cam = new RotatingCamera(this);

            this.World.CameraManager.AddCamera(cam);

            RasterizerState          = new RasterizerState();
            RasterizerState.FillMode = FillMode.WireFrame;
        }
        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);
        }
        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);
        }
Example #6
0
        /// <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);

            ///Uncoment to add your model
            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());
            ///Forward Shader (look at this shader construction for more info)
            ForwardXNABasicShader shader = new ForwardXNABasicShader();
            ///Forward material
            ForwardMaterial fmaterial = new ForwardMaterial(shader);
            ///The object itself
            IObject obj = new IObject(fmaterial, simpleModel, tmesh);

            ///Add to the world
            this.World.AddObject(obj);

            ///add a camera
            RotatingCamera cam = new RotatingCamera(this);

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

        #region Models

        createobjs();

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


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

        #endregion



        cam = new RotatingCamera(this);
        this.World.CameraManager.AddCamera(cam);
    }
        protected override void LoadContent(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 sm = new SimpleModel(factory, "Model//block");
                sm.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Blue), TextureType.DIFFUSE);
                ForwardXNABasicShader shader    = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default());
                ForwardMaterial       fmaterial = new ForwardMaterial(shader);
                //CharacterControllerInput character = new CharacterControllerInput(this, new Vector3(100, 150, 1), 1, 1, 50, Vector3.One * 10, 0.5f);
                BoxObject  bb     = new BoxObject(new Vector3(100, 0, 1), 1, 1, 1, 10, Vector3.One * 10, Matrix.Identity, MaterialDescription.DefaultBepuMaterial());
                BaseObject marine = new BaseObject(fmaterial, bb, sm);
                this.World.AddObject(marine);

                /////ever !!!
                //marine.Behavior = new Repeater<BaseObject>(

                //new Watch<BaseObject>(
                //    (a,b)=>
                //        {

                //            ///condition
                //            if(a.PhysicObject.Position.Length() < 100)
                //            {
                //                return TaskResult.Failure;
                //            }
                //            return TaskResult.Success;
                //        }
                //    ,

                //        ///chnage its color =P
                //        new BehaviorTrees.Action<BaseObject>(
                //            (a,b)=>
                //            {
                //                a.Modelo.SetTexture(factory.CreateTexture2DColor(1,1,StaticRandom.RandomColor()),TextureType.DIFFUSE);
                //                return TaskResult.Success;
                //            }
                //            )
                //)
                //);



                marine.Behavior = new Repeater <BaseObject>
                                  (
                    new Sequence <BaseObject>()
                {
                    new Wait <BaseObject>(0.5f,
                                          new BehaviorTrees.Action <BaseObject>(
                                              (a, b) =>
                    {
                        return(TaskResult.Success);
                    }
                                              )
                                          )
                    ,

                    new RepeaterUntil <BaseObject>(
                        (a, b) =>
                    {
                        if ((a.PhysicObject.Position - waytogo).Length() > 50)
                        {
                            return(TaskResult.Running);
                        }
                        else
                        {
                            return(TaskResult.Success);
                        }
                    }
                        ,
                        new BehaviorTrees.Action <BaseObject>(
                            (a, b) =>
                    {
                        Vector3 direction = waytogo - a.PhysicObject.Position;
                        direction.Y       = 0;
                        direction.Normalize();
                        a.PhysicObject.Velocity = direction * 10;
                        // a.PhysicObject.Velocity += direction;


                        return(TaskResult.Success);
                    }
                            )
                        ),
                    ///chnage its color =P
                    new BehaviorTrees.Action <BaseObject>(
                        (a, b) =>
                    {
                        a.Modelo.SetTexture(factory.CreateTexture2DColor(1, 1, StaticRandom.RandomColor()), TextureType.DIFFUSE);
                        return(TaskResult.Success);
                    }
                        )
                }
                                  );
            }
            //this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo));
            RotatingCamera cam = new RotatingCamera(this, new Vector3(0, -100, -200));

            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.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;
                ForwardXNABasicShader shader    = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default());
                ForwardMaterial       fmaterial = new ForwardMaterial(shader);
                IObject obj = new IObject(fmaterial, simpleModel, tmesh);
                this.World.AddObject(obj);
            }

            Simulator.setTimeStep(0.25f);
            Simulator.setAgentDefaults(5.0f, 25, 10.0f, 25.0f, 2.0f, 4.0f, new Vector2());

            {
                ///reuse parts of the object that are constant for all instances
                SimpleModel simpleModel = new SimpleModel(factory, "Model//block");
                simpleModel.SetTexture(factory.CreateTexture2DColor(1, 1, Color.White), TextureType.DIFFUSE);
                ForwardXNABasicShader shader    = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default());
                ForwardMaterial       fmaterial = new ForwardMaterial(shader);

                for (int i = 0; i < 10; i++)
                {
                    for (int j = 0; j < 10; j++)
                    {
                        BoxObject tmesh = new BoxObject(new Vector3(100 + j * 5, 5, i * 5), 1, 1, 1, 10, new Vector3(1, 1, 1), Matrix.Identity, MaterialDescription.DefaultBepuMaterial());
                        int       id    = Simulator.addAgent(new Vector2(tmesh.Position.X, tmesh.Position.Z));
                        RVOObject obj   = new RVOObject(id, fmaterial, simpleModel, tmesh);
                        obj.OnUpdate += new OnUpdate(obj_OnUpdate); /// dummy position update way =p
                        this.World.AddObject(obj);
                    }
                }
            }

            ///counterclockwise vertices
            Simulator.addObstacle(
                new List <Vector2>()
            {
                new Vector2(20, 20),
                new Vector2(40, 20),
                new Vector2(40, 40),
                new Vector2(40, 40),
                new Vector2(20, 40),
                new Vector2(20, 20),
            }
                );

            Simulator.processObstacles();

            ///obstacle
            {
                SimpleModel simpleModel = new SimpleModel(factory, "Model//block");
                simpleModel.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Yellow), TextureType.DIFFUSE);
                GhostObject           tmesh     = new GhostObject(new Vector3(30, 0, 30), Matrix.Identity, new Vector3(10));
                ForwardXNABasicShader shader    = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default());
                ForwardMaterial       fmaterial = new ForwardMaterial(shader);
                IObject obj = new IObject(fmaterial, simpleModel, tmesh);
                this.World.AddObject(obj);
            }

            ///add a camera
            RotatingCamera cam = new RotatingCamera(this, new Vector3(-50, -30, -150));

            this.World.CameraManager.AddCamera(cam);

            Picking p = new Picking(this, Microsoft.Xna.Framework.Input.Touch.GestureType.DoubleTap, 10000);

            p.OnPickedGesture += new OnPicked(p_OnPickedGesture);
        }
    protected override void LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, IContentManager contentManager)
    {
        base.LoadContent(GraphicInfo, factory, contentManager);

        #region Models

        createobjs();

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


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

        #endregion

   

        cam = new RotatingCamera(this);        
        this.World.CameraManager.AddCamera(cam);
        
    }
        protected override void LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, IContentManager contentManager)
        {
            base.LoadContent(GraphicInfo, factory, contentManager);

            {
                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;
                ForwardXNABasicShader shader = new ForwardXNABasicShader();
                IMaterial             mat    = new ForwardMaterial(shader);
                IObject obj3 = new IObject(mat, sm, pi);
                this.World.AddObject(obj3);
                shader.BasicEffect.EnableDefaultLighting();

                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;

            {
                ///reuse instances that does not change
                SimpleModel sm = new SimpleModel(factory, "..\\Content\\Model\\cubo");
                sm.SetTexture(factory.CreateTexture2DColor(1, 1, Color.White), TextureType.DIFFUSE);
                ForwardXNABasicShader shader = new ForwardXNABasicShader();
                IMaterial             mat    = new ForwardMaterial(shader);

                for (int i = 0; i < numRows; i++)
                {
                    for (int j = 0; j < numColumns; j++)
                    {
                        for (int k = 0; k < numHigh; k++)
                        {
                            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;
                            IObject obj3 = new IObject(mat, sm, pi);
                            this.World.AddObject(obj3);
                            pi.Entity.LinearVelocity = new Vector3(30, 0, 0);
                        }
                    }
                }

                shader.BasicEffect.EnableDefaultLighting();
            }

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

            #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

            RotatingCamera cam = new RotatingCamera(this, new Vector3(0, 0, -300));
            this.World.CameraManager.AddCamera(cam);
        }