Beispiel #1
0
        protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager)
        {
            ///cast to out world instance
            PhysxPhysicWorld PhysxPhysicWorld = World.PhysicWorld as PhysxPhysicWorld;

            base.LoadContent(GraphicInfo, factory, contentManager);
            {
                SimpleModel simpleModel = new SimpleModel(factory, "Model//cenario");

                ///Physic Triangle mesh (same as bepu)
                PhysxTriangleMesh tmesh = new PhysxTriangleMesh(PhysxPhysicWorld, simpleModel,
                                                                Matrix.Identity, Vector3.One);

                ForwardXNABasicShader shader    = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default());
                ForwardMaterial       fmaterial = new ForwardMaterial(shader);
                IObject obj = new IObject(fmaterial, simpleModel, tmesh);
                this.World.AddObject(obj);
            }

            ///Ball Throw !!!
            BallThrowPhysx28 BallThrowBullet = new BallThrowPhysx28(this.World, GraphicFactory);

            this.AttachCleanUpAble(BallThrowBullet);

            this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo));
        }
Beispiel #2
0
        protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager)
        {
            PhysxPhysicWorld PhysxPhysicWorld = World.PhysicWorld as PhysxPhysicWorld;

            base.LoadContent(GraphicInfo, factory, contentManager);
            {
                SimpleModel simpleModel = new SimpleModel(factory, "Model//cenario");

                StillDesign.PhysX.Material material1 = PhysxPhysicWorld.CreatePhysicMaterial(
                    new StillDesign.PhysX.MaterialDescription()
                {
                    Restitution     = 0.3f,
                    DynamicFriction = 0.5f,
                    StaticFriction  = 1,
                }
                    );
                PhysxTriangleMesh tmesh = new PhysxTriangleMesh(PhysxPhysicWorld, simpleModel,
                                                                Matrix.Identity, Vector3.One, 1, material1);

                ForwardXNABasicShader shader    = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default());
                ForwardMaterial       fmaterial = new ForwardMaterial(shader);
                IObject obj = new IObject(fmaterial, simpleModel, tmesh);
                this.World.AddObject(obj);
            }

            BallThrowPhysx28 BallThrowBullet = new BallThrowPhysx28(this.World, GraphicFactory);

            this.AttachCleanUpAble(BallThrowBullet);

            for (int i = 0; i < 10; i++)
            {
                StillDesign.PhysX.Material material2 = PhysxPhysicWorld.CreatePhysicMaterial(
                    new StillDesign.PhysX.MaterialDescription()
                {
                    Restitution            = PloobsEngine.Utils.StaticRandom.RandomBetween(0, 1),
                    DynamicFriction        = PloobsEngine.Utils.StaticRandom.RandomBetween(0, 1),
                    StaticFriction         = PloobsEngine.Utils.StaticRandom.RandomBetween(0, 1),
                    RestitutionCombineMode = CombineMode.Max,
                }
                    );

                ///Load a Model with a custom texture
                SimpleModel sm2 = new SimpleModel(factory, "Model\\ball");
                sm2.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Green, false), TextureType.DIFFUSE);

                ForwardXNABasicShader nd = new ForwardXNABasicShader();
                IMaterial             m  = new ForwardMaterial(nd);

                SphereShapeDescription SphereGeometry = new SphereShapeDescription(5f);
                SphereGeometry.Material = material2;

                PhysxPhysicObject PhysxPhysicObject = new PhysxPhysicObject(SphereGeometry,
                                                                            0.5f, Matrix.CreateTranslation(new Vector3(100, 100, 50 * i)), Vector3.One * 5f);

                IObject o = new IObject(m, sm2, PhysxPhysicObject);
                this.World.AddObject(o);
            }
            this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo));
        }
Beispiel #3
0
        protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager)
        {
            PhysxPhysicWorld PhysxPhysicWorld = World.PhysicWorld as PhysxPhysicWorld;

            base.LoadContent(GraphicInfo, factory, contentManager);
            {
                SimpleModel simpleModel = new SimpleModel(factory, "Model//cenario");

                PhysxTriangleMesh tmesh = new PhysxTriangleMesh(PhysxPhysicWorld, simpleModel,
                                                                Matrix.Identity, Vector3.One);

                ForwardXNABasicShader shader    = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default());
                ForwardMaterial       fmaterial = new ForwardMaterial(shader);
                IObject obj = new IObject(fmaterial, simpleModel, tmesh);
                this.World.AddObject(obj);
            }


            {
                ///Load a Model with a custom texture
                SimpleModel sm2 = new SimpleModel(factory, "Model\\ball");
                sm2.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Aquamarine, false), TextureType.DIFFUSE);
                ForwardXNABasicShader nd = new ForwardXNABasicShader();
                IMaterial             m  = new ForwardMaterial(nd);

                SphereShapeDescription SphereGeometry    = new SphereShapeDescription(15f);
                PhysxGhostObject       PhysxPhysicObject = new PhysxGhostObject(new Vector3(100, 100, 100), Matrix.Identity, Vector3.One * 15f);

                IObject o = new IObject(m, sm2, PhysxPhysicObject);
                this.World.AddObject(o);

                ///Physx Trigger !!!
                ///Just need to pass a shape to it
                ///WORKS THE SAME AS BEPU TRIGGER
                ///LOOK AT INTRODUCTION DEMOS
                PhysxTrigger PhysxTrigger = new PloobsEngine.Physics.PhysxTrigger(
                    SphereGeometry, Matrix.CreateTranslation(new Vector3(100, 100, 100)),
                    new PloobsEngine.Trigger.TriggerEvent("TriggerEvent", "TriggerEvent"), null, true, true, true);

                World.AddTrigger(PhysxTrigger);
            }


            BallThrowPhysx28 BallThrowBullet = new BallThrowPhysx28(this.World, GraphicFactory);

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

            ReciveMessage = new ReciveMessage();
        }
Beispiel #4
0
        protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager)
        {
            PhysxPhysicWorld PhysxPhysicWorld = World.PhysicWorld as PhysxPhysicWorld;

            base.LoadContent(GraphicInfo, factory, contentManager);
            {
                SimpleModel simpleModel = new SimpleModel(factory, "Model//cenario");

                PhysxTriangleMesh tmesh = new PhysxTriangleMesh(PhysxPhysicWorld, simpleModel,
                                                                Matrix.Identity, Vector3.One);

                ForwardXNABasicShader shader    = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default());
                ForwardMaterial       fmaterial = new ForwardMaterial(shader);
                IObject obj = new IObject(fmaterial, simpleModel, tmesh);
                this.World.AddObject(obj);
            }


            {
                ///Controller description
                ///YOu have BoxControllerDescription  and SphereControllerDescription
                BoxControllerDescription desc = new BoxControllerDescription(1, 1, 1);
                desc.UpDirection     = Axis.Y;
                desc.SlopeLimit      = 0;
                desc.SkinWidth       = 0.2f;
                desc.StepOffset      = 0.5f;
                desc.InteractionFlag = CCTInteractionFlag.Include | CCTInteractionFlag.UseFilter;

                SimpleModel sm = new SimpleModel(factory, "..\\Content\\Model\\block");
                sm.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Blue), TextureType.DIFFUSE);
                ForwardXNABasicShader shader = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default());
                ForwardMaterial       mat    = new ForwardMaterial(shader);

                ///Character Object
                PhysxBoxCharacterObject PhysxCapsuleCharacterObject = new PhysxBoxCharacterObject(desc, new Vector3(50), Matrix.Identity, Vector3.One * 5);
                IObject marine = new IObject(mat, sm, PhysxCapsuleCharacterObject);
                this.World.AddObject(marine);
                marine.OnUpdate += new OnUpdate(marine_OnUpdate);
            }

            BallThrowPhysx28 BallThrowBullet = new BallThrowPhysx28(this.World, GraphicFactory);

            this.AttachCleanUpAble(BallThrowBullet);

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

            base.LoadContent(GraphicInfo, factory, contentManager);
            {
                SimpleModel simpleModel = new SimpleModel(factory, "Model//cenario");

                PhysxTriangleMesh tmesh = new PhysxTriangleMesh(PhysxPhysicWorld, simpleModel, Matrix.Identity,
                                                                Matrix.Identity, Vector3.One, PloobsEngine.Physics.MaterialDescription.DefaultPhysxMaterial());

                ForwardXNABasicShader shader    = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default());
                ForwardMaterial       fmaterial = new ForwardMaterial(shader);
                IObject obj = new IObject(fmaterial, simpleModel, tmesh);
                this.World.AddObject(obj);
            }

            BallThrowPhysx BallThrowBullet = new BallThrowPhysx(this.World, GraphicFactory);

            this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo));
        }
Beispiel #6
0
        protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager)
        {
            PhysxPhysicWorld PhysxPhysicWorld = World.PhysicWorld as PhysxPhysicWorld;

            base.LoadContent(GraphicInfo, factory, contentManager);

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

                PhysxTriangleMesh tmesh = new PhysxTriangleMesh(PhysxPhysicWorld, simpleModel,
                                                                Matrix.Identity, Vector3.One);

                DeferredNormalShader shader    = new DeferredNormalShader();
                DeferredMaterial     fmaterial = new DeferredMaterial(shader);
                IObject obj = new IObject(fmaterial, simpleModel, tmesh);
                this.World.AddObject(obj);
            }

            PhysxPhysicObject frame;
            {
                var         boxShapeDesc = new BoxShapeDescription(3, 10, 3);
                SimpleModel SimpleModel  = new PloobsEngine.Modelo.SimpleModel(factory, "Model/block");
                SimpleModel.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Red), TextureType.DIFFUSE);

                frame = new PloobsEngine.Physics.PhysxPhysicObject(boxShapeDesc, Matrix.CreateTranslation(50, 5, 50), new Vector3(3, 10, 3));
                DeferredNormalShader shader    = new DeferredNormalShader();
                DeferredMaterial     fmaterial = new DeferredMaterial(shader);
                IObject obj = new IObject(fmaterial, SimpleModel, frame);
                this.World.AddObject(obj);
            }

            //Create an attached emitter
            FluidEmitterDescription emitterDesc = new FluidEmitterDescription();

            emitterDesc.MaximumParticles       = 0;
            emitterDesc.DimensionX             = 8f;
            emitterDesc.DimensionY             = 8f;
            emitterDesc.Type                   = EmitterType.ConstantFlowRate;
            emitterDesc.Rate                   = 150.0f;
            emitterDesc.FluidVelocityMagnitude = 60.0f;
            emitterDesc.ParticleLifetime       = 8.0f;
            emitterDesc.Shape                  = EmitterShape.Rectangular;

            //attach to actor
            emitterDesc.Flags = FluidEmitterFlag.AddBodyVelocity | FluidEmitterFlag.Enabled | FluidEmitterFlag.Visualization;
            emitterDesc.RepulsionCoefficient = 0.02f;

            //emitterDesc.RelativePose = Phyx.Matrix.RotationX((float)Math.PI / 2);
            emitterDesc.RelativePose *= Phyx.Matrix.Translation(0, 20f, 0);

            emitterDesc.FrameShape = frame.Actor.Shapes[0];

            FluidDescription fluidDesc = new FluidDescription();

            fluidDesc.MaximumParticles            = 2500;
            fluidDesc.KernelRadiusMultiplier      = 5.0f;
            fluidDesc.RestParticlesPerMeter       = 5.0f;
            fluidDesc.MotionLimitMultiplier       = 0.9f;
            fluidDesc.PacketSizeMultiplier        = 16;
            fluidDesc.CollisionDistanceMultiplier = 0.12f;
            fluidDesc.Stiffness   = 50.0f;
            fluidDesc.Viscosity   = 40.0f;
            fluidDesc.RestDensity = 1000.0f;
            fluidDesc.Damping     = 0.0f;
            fluidDesc.RestitutionForStaticShapes     = 0.2f;
            fluidDesc.DynamicFrictionForStaticShapes = 0.05f;
            fluidDesc.Flags            = FluidFlag.Enabled | FluidFlag.Visualization;
            fluidDesc.SimulationMethod = FluidSimulationMethod.SmoothedParticleHydrodynamics;

            fluidDesc.ParticleWriteData.AllocatePositionBuffer <Phyx.Vector3>(fluidDesc.MaximumParticles);
            fluidDesc.ParticleWriteData.NumberOfParticles = fluidDesc.MaximumParticles;

            FluidMOdel       FluidMOdel       = new PloobsEngine.Modelo.FluidMOdel(factory, "teste", null, fluidDesc.MaximumParticles);
            PhysxFluidObject PhysxFluidObject = new PloobsEngine.Physics.PhysxFluidObject(fluidDesc);
            FluidShader      FluidShader      = new FluidShader();
            DeferredMaterial ForwardMaterial  = new DeferredMaterial(FluidShader);
            IObject          IObject          = new IObject(ForwardMaterial, FluidMOdel, PhysxFluidObject);

            this.World.AddObject(IObject);

            PhysxFluidObject.Fluid.CreateFluidEmitter(emitterDesc);

            #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


            BallThrowPhysx28 BallThrowBullet = new BallThrowPhysx28(this.World, GraphicFactory, false);
            this.AttachCleanUpAble(BallThrowBullet);

            this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo));
        }
Beispiel #7
0
        protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager)
        {
            PhysxPhysicWorld PhysxPhysicWorld = World.PhysicWorld as PhysxPhysicWorld;

            base.LoadContent(GraphicInfo, factory, contentManager);


            ///Cosntruct a grid of vertices to make a cloth
            int w = 50;
            int h = 50;

            float hw = w / 2.0f;
            float hh = h / 2.0f;

            Vector3 p = new Vector3(0, 70, 0);

            var grid = VertexGrid.CreateGrid(w, h);

            ///Cloth Model (Code inside the demo)
            ClothModel ClothModel = new PloobsEngine.Modelo.ClothModel(factory, PhysxPhysicWorld,
                                                                       new ClothMeshDescription(), grid.Points, grid.TextCoords, grid.Indices, "Textures//fabric");

            ///Cloth Description
            var clothDesc = new ClothDescription()
            {
                Friction  = 0.5f,
                ClothMesh = ClothModel.ClothMesh,
                Flags     = ClothFlag.Gravity | ClothFlag.Bending | ClothFlag.CollisionTwoway | ClothFlag.Visualization | ClothFlag.SelfCollision,
                Thickness = 0.5f,
            };

            ///Adding Cloth Vertices
            clothDesc.MeshData.AllocatePositions <Vector3>(grid.Points.Length);
            clothDesc.MeshData.AllocateIndices <int>(grid.Indices.Length);
            clothDesc.MeshData.AllocateNormals <Vector3>(grid.Points.Length);

            clothDesc.MeshData.MaximumVertices = grid.Points.Length;
            clothDesc.MeshData.MaximumIndices  = grid.Indices.Length;

            clothDesc.MeshData.NumberOfVertices = grid.Points.Length;
            clothDesc.MeshData.NumberOfIndices  = grid.Indices.Length;



            ///Cloth Physic Model
            PhysxClothObject PhysxClothObject = new PloobsEngine.Physics.PhysxClothObject(clothDesc,
                                                                                          Matrix.CreateTranslation(-hw, 0, -hh) * Matrix.CreateTranslation(p));



            ForwardXNABasicShader ForwardXNABasicShader = new PloobsEngine.Material.ForwardXNABasicShader();
            ClothMaterial         ClothMaterial         = new ClothMaterial(ForwardXNABasicShader);
            IObject IObject = new PloobsEngine.SceneControl.IObject(ClothMaterial, ClothModel, PhysxClothObject);

            World.AddObject(IObject);


            {
                SimpleModel simpleModel = new SimpleModel(factory, "Model//table", "Textures//wood_dark");

                StillDesign.PhysX.Material material1 = PhysxPhysicWorld.CreatePhysicMaterial(
                    new StillDesign.PhysX.MaterialDescription()
                {
                    Restitution     = 0.3f,
                    DynamicFriction = 0.5f,
                    StaticFriction  = 1,
                }
                    );
                PhysxTriangleMesh tmesh = new PhysxTriangleMesh(PhysxPhysicWorld, simpleModel,
                                                                Matrix.Identity, Vector3.One, 1, material1);

                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();
            }
            {
                StillDesign.PhysX.Material material2 = PhysxPhysicWorld.CreatePhysicMaterial(
                    new StillDesign.PhysX.MaterialDescription()
                {
                    Restitution            = PloobsEngine.Utils.StaticRandom.RandomBetween(0, 1),
                    DynamicFriction        = PloobsEngine.Utils.StaticRandom.RandomBetween(0, 1),
                    StaticFriction         = PloobsEngine.Utils.StaticRandom.RandomBetween(0, 1),
                    RestitutionCombineMode = CombineMode.Max,
                }
                    );
                {
                    SimpleModel sm2 = new SimpleModel(factory, "Model\\ball");
                    sm2.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Green, false), TextureType.DIFFUSE);

                    ForwardXNABasicShader nd = new ForwardXNABasicShader();
                    IMaterial             m  = new ForwardMaterial(nd);

                    SphereShapeDescription SphereGeometry = new SphereShapeDescription(5);
                    SphereGeometry.Material = material2;

                    PhysxPhysicObject PhysxPhysicObject = new PhysxPhysicObject(SphereGeometry,
                                                                                0.5f, Matrix.CreateTranslation(new Vector3(0, 50, 0)), Vector3.One * 5f);

                    IObject o = new IObject(m, sm2, PhysxPhysicObject);
                    this.World.AddObject(o);
                    nd.BasicEffect.EnableDefaultLighting();
                    PhysxPhysicObject.isMotionLess = true;
                }
            }



            BallThrowPhysx28 BallThrowBullet = new BallThrowPhysx28(this.World, GraphicFactory);

            BallThrowBullet.ballSize = 1;
            BallThrowBullet.Speed    = 20;
            this.AttachCleanUpAble(BallThrowBullet);
            this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo));
        }