Ejemplo n.º 1
0
Archivo: Level.cs Proyecto: tubitos/1
        //
        //sets world and render technic
        //
        protected override void SetWorldAndRenderTechnich(out IRenderTechnic renderTech, out IWorld world)
        {
            BepuPhysicWorld bpw = new BepuPhysicWorld(-98.0F, true, 1.0F);

            world = new IWorld(bpw, new SimpleCuller());

            DeferredRenderTechnicInitDescription desc = DeferredRenderTechnicInitDescription.Default();

            desc.UseFloatingBufferForLightMap = true;
            renderTech = new DeferredRenderTechnic(desc);
        }
Ejemplo n.º 2
0
        protected override void SetWorldAndRenderTechnich(out IRenderTechnic renderTech, out IWorld world)
        {
            BepuPhysicWorld BepuPhysicWorld = new BepuPhysicWorld(-0.97f);
            SimpleCuller    SimpleCuller    = new SimpleCuller();

            world = new IWorld(BepuPhysicWorld, SimpleCuller);

            ForwardRenderTecnichDescription desc = ForwardRenderTecnichDescription.Default();

            desc.BackGroundColor = Color.CornflowerBlue;
            renderTech           = new ForwardRenderTecnich(desc);
        }
Ejemplo n.º 3
0
        protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager)
        {
            BepuPhysicWorld.ApplyHighStabilitySettings(this.World.PhysicWorld as BepuPhysicWorld);

            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");
                simpleModel.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Green), TextureType.DIFFUSE);
                MobileMeshObject tmesh = new MobileMeshObject(simpleModel, new Vector3(100, 100, 10), Matrix.Identity, Vector3.One * 10, 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);
                shader.BasicEffect.EnableDefaultLighting();
            }

            {
                SimpleModel simpleModel = new SimpleModel(factory, "Model//uzi");
                simpleModel.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Yellow), TextureType.DIFFUSE);
                MobileMeshObject tmesh = new MobileMeshObject(simpleModel, new Vector3(150, 100, 10), Matrix.Identity, Vector3.One * 20, 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);
                shader.BasicEffect.EnableDefaultLighting();
            }

            {
                SimpleModel simpleModel = new SimpleModel(factory, "Model//uzi");
                simpleModel.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Red), TextureType.DIFFUSE);
                MobileMeshObject tmesh = new MobileMeshObject(simpleModel, new Vector3(200, 100, 10), Matrix.Identity, Vector3.One * 15, 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);
                shader.BasicEffect.EnableDefaultLighting();
            }

            this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo));
        }
Ejemplo n.º 4
0
        protected override void SetWorldAndRenderTechnich(out IRenderTechnic renderTech, out IWorld world)
        {
            BepuPhysicWorld bepuWorld = new BepuPhysicWorld(-0.98f, true, 1, true);

            world = new IWorld(bepuWorld, new SimpleCuller());

            BepuPhysicWorld.ApplyHighStabilitySettings(bepuWorld);

            DeferredRenderTechnicInitDescription desc = DeferredRenderTechnicInitDescription.Default();

            desc.UseFloatingBufferForLightMap = true;
            desc.BackGroundColor = Color.CornflowerBlue;
            renderTech           = new DeferredRenderTechnic(desc);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Trigger creation
        /// </summary>
        /// <param name="physicWorld">The physic world.</param>
        /// <param name="triangleMesh">Triangle mesh representing the Volume of the Trigger</param>
        /// <param name="evt">Event to be fired</param>
        /// <param name="fireBeginsTouching">if set to <c>true</c> [fire begins touching].</param>
        /// <param name="fireEndsTouching">if set to <c>true</c> [fire ends touching].</param>
        /// <param name="fireBeginsContaining">if set to <c>true</c> [fire begins containing].</param>
        /// <param name="fireEndsContaining">if set to <c>true</c> [fire ends containing].</param>
        public BepuTrigger(BepuPhysicWorld physicWorld, TriangleMeshObject triangleMesh, TriggerEvent evt, bool fireBeginsTouching, bool fireEndsTouching, bool fireBeginsContaining, bool fireEndsContaining)
        {
            this.volumeobject = new DetectorVolumeObject(physicWorld, triangleMesh);
            DetectorVolume detectorVolume = this.volumeobject.DetectorVolume;

            if (fireBeginsTouching)
            {
                detectorVolume.EntityBeginsTouching += new EntityBeginsTouchingVolumeEventHandler(detectorVolume_EntityBeginsTouching);
            }
            if (fireEndsTouching)
            {
                detectorVolume.EntityStopsTouching += new EntityStopsTouchingVolumeEventHandler(detectorVolume_EntityStopsTouching);
            }
            if (fireBeginsContaining)
            {
                detectorVolume.VolumeBeginsContainingEntity += new VolumeBeginsContainingEntityEventHandler(detectorVolume_VolumeBeginsContainingEntity);
            }
            if (fireEndsContaining)
            {
                detectorVolume.VolumeStopsContainingEntity += new VolumeStopsContainingEntityEventHandler(detectorVolume_VolumeStopsContainingEntity);
            }
            this.evt = evt;
        }
Ejemplo n.º 6
0
    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);
    }
 public static void Update(this BepuPhysicWorld BepuPhysicWorld, GameTime gt)
 {
     BepuPhysicWorld.iUpdate(gt);
 }
 /// <summary>
 /// Creates a gravitational field.
 /// </summary>
 /// <param name="shape">Shape representing the volume of the force field.</param>
 /// <param name="origin">Location that entities will be pushed toward.</param>
 /// <param name="multiplier">Represents the gravitational constant of the field times the effective mass at the center of the field.</param>
 /// <param name="maxForce">Maximum force the field can apply.</param>
 /// <param name="physicWorld">The physic world.</param>
 public GravitationalFieldObject(ForceFieldShape shape, Vector3 origin, float multiplier, float maxForce, BepuPhysicWorld physicWorld)
     : base(shape, physicWorld.Space.BroadPhase.QueryAccelerator)
 {
     this.Multiplier = multiplier;
     this.Origin     = origin;
     this.MaxForce   = maxForce;
 }
 public DetectorVolumeObject(BepuPhysicWorld bepuPhysicWorld, TriangleMeshObject mesh)
 {
     this.mesh      = mesh;
     detectorVolume = new DetectorVolume(mesh.StaticMesh.Mesh.Data, bepuPhysicWorld.Space.BroadPhase.QueryAccelerator);
 }
        protected override void LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, IContentManager contentManager)
        {
            base.LoadContent(GraphicInfo, factory, contentManager);

            #region Trigger
            ///Criacao de um Trigger
            ///Create a trigger
            {
                ///Modelo cujo formato sera utilizado para disparar o trigger
                ///Model used as base the for the trigger
                SimpleModel sm = new SimpleModel(factory, "..\\Content\\Model\\cubo");
                sm.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Red), TextureType.DIFFUSE); ///VERMELHO

                ///Criacao do Triangle Mesh
                ///Create the triangle mesh from the model
                TriangleMeshObject tm = new TriangleMeshObject(sm, new Vector3(200, 5, 0), Matrix.Identity, Vector3.One * 10, MaterialDescription.DefaultBepuMaterial());
                ///Criacao do Evento q sera disparado qd o trigger for acionado
                ///Pode-se criar outros tipos de eventos, basta extender a classe  IEvent
                ///O parametro passado eh o canal em que o trigger enviara suas mensagens
                ///Qualquer Entidade que extende IRecieveMessageEntity pode receber mensagens
                ///Create the eventr that the trigger will fire
                ///TriggerEvent is the name of the CHANNEL (SEE CHANGINGMESSAGESSCREEN.CS) where the trigger will send the messages. (you can change the name at your will, change also the channel that the other objects are listening)
                TriggerEvent te = new TriggerEvent("TriggerEvent", "TriggerTest1");
                ///Criacao do Trigger
                ///Creating and adding the trigger to the physic world
                BepuPhysicWorld physicWorld = this.World.PhysicWorld as BepuPhysicWorld;
                System.Diagnostics.Debug.Assert(physicWorld != null);
                ///Setting triggers configuration, IT RECIEVES A TRIANGLE MESH
                ///TRIGGERS ARE ALWAYS TRIANGLE MESHES !!!!
                BepuTrigger bt = new BepuTrigger(physicWorld, tm, te, true, true, true, true);
                ///Adiciona o trigger ao mundo
                this.World.AddTrigger(bt);

                ///Adicona um objeto na posicao do trigger (Objeto FANTASMA, nao sera detectado pelo trigger)
                ///Facilita na localizacao do Trigger
                ///CREATE A VISUAL OBJECT FOR THE TRIGGER (SO WE CAN SEE IT)
                ///GHOST OBJECT (NO COLLISION)
                GhostObject ghost = new GhostObject(new Vector3(200, 5, 0), Matrix.Identity, Vector3.One * 10);
                ///material and shader
                DeferredNormalShader shader = new DeferredNormalShader();
                IMaterial            mat    = new DeferredMaterial(shader);
                /// add the visual object (DONT NEED, WE ADDED JUST TO SEE THE TRIGGER)
                IObject obj3 = new IObject(mat, sm, ghost);
                this.World.AddObject(obj3);
            }


            #endregion

            ///Criacao de um Objeto q recebera mensagens do trigger
            ///THIS OBJECT THAT WILL RECIEVE MESSAGE FROM the trigger
            #region Models
            {
                SimpleModel sm = new SimpleModel(factory, "..\\Content\\Model\\cubo");
                sm.SetTexture(factory.CreateTexture2DColor(1, 1, Color.White), TextureType.DIFFUSE); ///BRANCO
                IPhysicObject        pi     = new TriangleMeshObject(sm, new Vector3(20, 50, 50), Matrix.Identity, Vector3.One * 10, MaterialDescription.DefaultBepuMaterial());
                DeferredNormalShader shader = new DeferredNormalShader();
                IMaterial            mat    = new DeferredMaterial(shader);
                IObject obj3 = new IObject(mat, sm, pi);
                ///Cadastra uma funcao para tratar das mensagens recebidas
                ///existem outras maneiras de fazer isso, como Extender a classe IObject e sobrescrever o metodo HandleMessage
                ///MESSAGE HANDLER
                obj3.OnRecieveMessage += new OnRecieveMessage(obj3_OnRecieveMessage);
                this.World.AddObject(obj3);
                ///Adiciona o Objeto criado ao grupo "TriggerEvent" que recebera as mensagens do trigger
                ///Register to recieve TriggerEvent Messages (registering to the channel)
                EntityMapper.getInstance().AddgrouptagRecieveEntity("TriggerEvent", obj3);
            }


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


            #endregion

            ///Demonstracao de que qualquer entidade pode receber mensagens
            ///Olhar a implementacao desta classe, esta no fim deste arquivo
            ///Creating an entity to recieve the trigger message also
            ///JUST to show that everyone can recieve messages
            rmessage = new ReciveMessage();

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

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

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

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

            #region Models

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

            int numColumns = 10;
            int numRows    = 10;
            int numHigh    = 15;

            ///1500 box
            ///1500 luzes

            ///CREATE LOOOOTS OF OBJECTS AND LIGHTS
            float separation = 3;
            for (int i = 0; i < numRows; i++)
            {
                for (int j = 0; j < numColumns; j++)
                {
                    for (int k = 0; k < numHigh; k++)
                    {
                        SimpleModel sm = new SimpleModel(factory, "..\\Content\\Model\\cubo");
                        sm.SetTexture(factory.CreateTexture2DColor(1, 1, StaticRandom.RandomColor()), TextureType.DIFFUSE);
                        MaterialDescription md = MaterialDescription.DefaultBepuMaterial();
                        md.Bounciness = 1;
                        BoxObject pi = new BoxObject(new Vector3(separation * i, k * separation, separation * j), 1, 1, 1, 1, new Vector3(1), Matrix.Identity, md);
                        pi.Entity.AngularDamping = 0f; //It looks cooler if boxes don't slowly stop spinning!
                        IShader   shader = new DeferredNormalShader();
                        IMaterial mat    = new DeferredMaterial(shader);
                        IObject   obj5   = new IObject(mat, sm, pi);
                        this.World.AddObject(obj5);

                        ///Light is atached to the blocks
                        MoveablePointLight pl = new MoveablePointLight(pi, StaticRandom.RandomColor(), 5, 1);
                        this.World.AddLight(pl);
                    }
                }
            }

            #endregion

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


            ///THROW THE BALLS IN THE BLOCKS !!!!!!
            lt = new LightThrowBepu(this.World, factory);

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