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));
        }
Exemplo n.º 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));
        }
Exemplo n.º 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(5f);
                PhysxGhostObject       PhysxPhysicObject = new PhysxGhostObject(new Vector3(100, 100, 100), Matrix.Identity, Vector3.One * 5f);

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

                PhysxTrigger PhysxTrigger = new PloobsEngine.Physics.PhysxTrigger(
                    SphereGeometry, Matrix.CreateTranslation(new Vector3(100, 100, 100)),
                    new PloobsEngine.Trigger.TriggerEvent("TriggerEvent", "TriggerEvent"), null, true);

                World.AddTrigger(PhysxTrigger);
            }



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

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

            ReciveMessage ReciveMessage = new ReciveMessage();
        }
Exemplo n.º 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);
            }


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

                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, Vector3.One);

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

            
            {

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

                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//block");
                simpleModel.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Blue), TextureType.DIFFUSE);

                BoxShapeDescription SphereGeometry = new BoxShapeDescription(1000, 5, 1000);
                PhysxPhysicObject PhysxPhysicObject = new PhysxPhysicObject(SphereGeometry,
                    Matrix.Identity, new Vector3(1000, 5, 1000));

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

                shader.BasicEffect.EnableDefaultLighting();
            }

            {
                ///very basic vehicle !!!
                ///no wheels also =P
                Vehicle Vehicle = new Vehicle(PhysxPhysicWorld.Scene);
                SimpleModel simpleModel = new SimpleModel(factory, "Model//block");
                simpleModel.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Green));
                PhysxPhysicObject tmesh = new PhysxPhysicObject(Vehicle.VehicleBodyActor, new Vector3(5, 3, 7));

                ForwardXNABasicShader shader = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default());
                ForwardMaterial fmaterial = new ForwardMaterial(shader);
                UserObject<Vehicle> obj = new UserObject<Vehicle>(fmaterial, simpleModel, tmesh,Vehicle);
                obj.OnUserUpdate += new Action<UserObject<StillDesign.PhysX.Samples.Vehicle>>(obj_OnUserUpdate);
                this.World.AddObject(obj);

            }

            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//block");
                simpleModel.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Blue), TextureType.DIFFUSE);

                BoxShapeDescription SphereGeometry    = new BoxShapeDescription(1000, 5, 1000);
                PhysxPhysicObject   PhysxPhysicObject = new PhysxPhysicObject(SphereGeometry,
                                                                              Matrix.Identity, new Vector3(1000, 5, 1000));

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

                shader.BasicEffect.EnableDefaultLighting();
            }

            {
                ///very basic vehicle !!!
                ///no wheels also =P
                Vehicle     Vehicle     = new Vehicle(PhysxPhysicWorld.Scene);
                SimpleModel simpleModel = new SimpleModel(factory, "Model//block");
                simpleModel.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Green));
                PhysxPhysicObject tmesh = new PhysxPhysicObject(Vehicle.VehicleBodyActor, new Vector3(5, 3, 7));

                ForwardXNABasicShader shader    = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default());
                ForwardMaterial       fmaterial = new ForwardMaterial(shader);
                UserObject <Vehicle>  obj       = new UserObject <Vehicle>(fmaterial, simpleModel, tmesh, Vehicle);
                obj.OnUserUpdate += new Action <UserObject <StillDesign.PhysX.Samples.Vehicle> >(obj_OnUserUpdate);
                this.World.AddObject(obj);
            }

            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, Vector3.One);

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

            this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo));
        }
Exemplo n.º 9
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);
            }

            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, 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(5f);
                 PhysxGhostObject PhysxPhysicObject = new PhysxGhostObject(new Vector3(100,100,100),Matrix.Identity, Vector3.One * 5f);
                 
                 IObject o = new IObject(m, sm2, PhysxPhysicObject);
                 this.World.AddObject(o);

                 PhysxTrigger PhysxTrigger = new PloobsEngine.Physics.PhysxTrigger(
                     SphereGeometry, Matrix.CreateTranslation(new Vector3(100, 100, 100)),
                     new PloobsEngine.Trigger.TriggerEvent("TriggerEvent", "TriggerEvent"), null, true);

                 World.AddTrigger(PhysxTrigger);

            }

            

            BallThrowPhysx28 BallThrowBullet = new BallThrowPhysx28(this.World, GraphicFactory);
            this.AttachCleanUpAble(BallThrowBullet);
            this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo));

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

            base.LoadContent(GraphicInfo, factory, contentManager);

            const int maximumParticles = 1000;
            var       fluidEmitterDesc = new FluidEmitterDescription()
            {
                DimensionX   = 0.5f,
                DimensionY   = 0.5f,
                Rate         = 15,
                RelativePose =
                    Phyx.Matrix.RotationAxis(new Phyx.Vector3(0, 1, 0), (float)Math.PI) *
                    Phyx.Matrix.Translation(-40, 10, -50),
                Shape       = EmitterShape.Rectangular,
                Type        = EmitterType.ConstantFlowRate,
                RandomAngle = 0.5f
            };

            fluidEmitterDesc.Flags |= (FluidEmitterFlag.Enabled | FluidEmitterFlag.Visualization);

            var fluidDesc = new FluidDescription()
            {
                Emitters         = { fluidEmitterDesc },
                Flags            = FluidFlag.Enabled | FluidFlag.Visualization | FluidFlag.Enabled,
                MaximumParticles = maximumParticles,
            };

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

            fluid = PhysxPhysicWorld.Scene.CreateFluid(fluidDesc);


            Texture2D tex = factory.GetTexture2D("Textures/Smoke");

            for (int i = 0; i < maximumParticles; i++)
            {
                Billboard3D Billboard3D = new Billboard3D(tex, Vector3.Zero, new Vector2(0.002f));
                Billboard3D.Enabled = false;
                CPUSphericalBillboardComponent.Billboards.Add(Billboard3D);
            }


            // Ledge
            {
                var         boxShapeDesc = new BoxShapeDescription(5, 0.1f, 5);
                SimpleModel SimpleModel  = new PloobsEngine.Modelo.SimpleModel(factory, "Model/block");
                SimpleModel.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Red), TextureType.DIFFUSE);
                PhysxPhysicObject PhysxPhysicObject = new PloobsEngine.Physics.PhysxPhysicObject(boxShapeDesc,
                                                                                                 (Phyx.Matrix.RotationX(-0.5f) * Phyx.Matrix.Translation(-40, 5, -52)).AsXNA(), new Vector3(5, 0.1f, 5));
                ForwardXNABasicShader shader    = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default());
                ForwardMaterial       fmaterial = new ForwardMaterial(shader);
                IObject obj = new IObject(fmaterial, SimpleModel, PhysxPhysicObject);
                this.World.AddObject(obj);
            }

            // Drain
            {
                var boxShapeDesc = new BoxShapeDescription(5, 0.1f, 5);
                boxShapeDesc.Flags |= ShapeFlag.FluidDrain;

                var drainActorDesc = new ActorDescription()
                {
                    GlobalPose = Phyx.Matrix.Translation(-40, 0, -55),
                    Shapes     = { boxShapeDesc }
                };

                var drianActor = PhysxPhysicWorld.Scene.CreateActor(drainActorDesc);
            }

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

            Texture2D   tMap = factory.GetTexture2D("Textures//hmap_10243");
            QuadTerrain q    = new PloobsEngine.Material.QuadTerrain(factory, tMap, 33, 513, 10, 3f);

            ForwardTerrainMaterial mat = new ForwardTerrainMaterial(q);

            //Set various terrain stats.
            mat.diffuseScale      = q.flatScale / 4;
            mat.detailScale       = q.flatScale / 100;
            mat.detailMapStrength = 2;
            mat.textureBlend      = factory.GetTexture2D("Textures//hmap_256blend");
            mat.textureDetail     = factory.GetTexture2D("Textures//coolgrass2DOT3");
            mat.textureRed        = factory.GetTexture2D("Textures//TexR");
            mat.textureGreen      = factory.GetTexture2D("Textures//TexG");
            mat.textureBlue       = factory.GetTexture2D("Textures//TexB");
            mat.textureBlack      = factory.GetTexture2D("Textures//TexBase");

            mat.sunlightVector = Vector3.Normalize(new Vector3(.5f, .5f, .8f));
            mat.sunlightColour = new Vector3(2.3f, 2f, 1.8f);
            float[,] f         = q.getHeightMap();
            int v       = 513;
            var samples = new HeightFieldSample[v * v];

            for (int r = 0; r < v; r++)
            {
                for (int c = 0; c < v; c++)
                {
                    var sample = new HeightFieldSample()
                    {
                        Height = (short)f[r, c],
                        //Height = 5,
                        TessellationFlag = 1,
                        MaterialIndex0   = 1,
                        MaterialIndex1   = 0
                    };

                    samples[r * v + c] = sample;
                }
            }

            var heightFieldDesc = new HeightFieldDescription()
            {
                NumberOfRows        = v,
                NumberOfColumns     = v,
                ConvexEdgeThreshold = 0f,
            };

            heightFieldDesc.SetSamples(samples);

            var heightField = PhysxPhysicWorld.Core.CreateHeightField(heightFieldDesc);

            heightFieldDesc.Dispose();

            var heightFieldShapeDesc = new HeightFieldShapeDescription()
            {
                HeightField = heightField,
                HeightScale = 1.0f,
                RowScale    = 1,
                ColumnScale = 1,
            };

            heightFieldShapeDesc.LocalPose = StillDesign.PhysX.MathPrimitives.Matrix.Identity;

            var actorDesc = new ActorDescription()
            {
                GlobalPose = Matrix.Identity.AsPhysX(),
                Shapes     = { heightFieldShapeDesc },
            };

            actor = PhysxPhysicWorld.Scene.CreateActor(actorDesc);

            IObject obj3 = new IObject(mat, null, new PhysxGhostObject());

            this.World.AddObject(obj3);

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

            this.AttachCleanUpAble(BallThrowBullet);

            CameraFirstPerson CameraFirstPerson = new CameraFirstPerson(GraphicInfo);

            CameraFirstPerson.FarPlane = 20000;
            this.World.CameraManager.AddCamera(CameraFirstPerson);
        }
        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));
        }
        protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager)
        {
            PhysxPhysicWorld PhysxPhysicWorld = World.PhysicWorld as PhysxPhysicWorld;

            base.LoadContent(GraphicInfo, factory, contentManager);

            int w = 25;
            int h = 25;

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

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


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

            ClothModel ClothModel = new PloobsEngine.Modelo.ClothModel(factory, PhysxPhysicWorld,
                                                                       new ClothMeshDescription(), grid.Points, grid.TextCoords, grid.Indices, "Textures//meiofio");

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

            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;

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



            // Four corner boxes to hold it in place
            var positions = new[]
            {
                new StillDesign.PhysX.MathPrimitives.Vector3(0, 0, -hh),                // Back
                new StillDesign.PhysX.MathPrimitives.Vector3(0, 0, hh),                 // Front
                new StillDesign.PhysX.MathPrimitives.Vector3(-hw, 0, 0),                // Left
                new StillDesign.PhysX.MathPrimitives.Vector3(hw, 0, 0),                 // Right
            };

            var sizes = new[]
            {
                new StillDesign.PhysX.MathPrimitives.Vector3(w, 1, 1),                 // Back
                new StillDesign.PhysX.MathPrimitives.Vector3(w, 1, 1),                 // Front
                new StillDesign.PhysX.MathPrimitives.Vector3(1, 1, h),                 // Left
                new StillDesign.PhysX.MathPrimitives.Vector3(1, 1, h),                 //Right
            };

            ///pra preender
            for (int i = 0; i < 2; i++)
            {
                var actorDesc = new ActorDescription()
                {
                    GlobalPose = StillDesign.PhysX.MathPrimitives.Matrix.Translation(positions[i] + p.AsPhysX()),
                    Shapes     = { new BoxShapeDescription(sizes[i]) }
                };

                var actor = PhysxPhysicWorld.Scene.CreateActor(actorDesc);


                PhysxClothObject.Cloth.AttachToShape(actor.Shapes.First(), (ClothAttachmentFlag)0);
            }

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

            this.AttachCleanUpAble(BallThrowBullet);
            this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo));
        }
Exemplo n.º 15
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));
        }
Exemplo n.º 16
0
        protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager)
        {
            PhysxPhysicWorld PhysxPhysicWorld = World.PhysicWorld as PhysxPhysicWorld;

            base.LoadContent(GraphicInfo, factory, contentManager);

            for (int i = 0; i < 3; i++)
            {
                ClothMeshDescription ClothMeshDescription = new ClothMeshDescription();
                ClothMeshDescription.WeldingDistance = 0.0001f;
                ClothMeshDescription.Flags           = (MeshFlag)(int)ClothMeshFlag.WeldVertices;


                ClothModel ClothModel = new PloobsEngine.Modelo.ClothModel(factory, PhysxPhysicWorld,
                                                                           ClothMeshDescription, "Model//ball", Vector3.One * 25, "Textures//meiofio");

                var clothDesc = new ClothDescription()
                {
                    Friction  = 0.5f,
                    ClothMesh = ClothModel.ClothMesh,
                    Pressure  = 0.9f,
                    Flags     = ClothFlag.Bending | ClothFlag.CollisionTwoway | ClothFlag.Visualization | ClothFlag.Pressure | ClothFlag.Gravity | ClothFlag.SelfCollision | ClothFlag.TriangleCollision,
                    Thickness = 0.4f,
                };


                clothDesc.MeshData.AllocatePositions <Vector3>(ClothModel.VerticesNum);
                clothDesc.MeshData.AllocateIndices <int>(ClothModel.IndicesNum);
                clothDesc.MeshData.AllocateNormals <Vector3>(ClothModel.VerticesNum);

                clothDesc.MeshData.MaximumVertices = ClothModel.VerticesNum;
                clothDesc.MeshData.MaximumIndices  = ClothModel.IndicesNum;

                clothDesc.MeshData.NumberOfVertices = ClothModel.VerticesNum;
                clothDesc.MeshData.NumberOfIndices  = ClothModel.IndicesNum;

                PhysxClothObject PhysxClothObject = new PloobsEngine.Physics.PhysxClothObject(clothDesc,
                                                                                              Matrix.CreateTranslation(100, 50, i * 100));


                ForwardXNABasicShader ForwardXNABasicShader = new PloobsEngine.Material.ForwardXNABasicShader();
                ClothMaterial         ClothMaterial         = new ClothMaterial(ForwardXNABasicShader);
                //ClothMaterial.RasterizerState.FillMode = FillMode.WireFrame;
                IObject IObject = new PloobsEngine.SceneControl.IObject(ClothMaterial, ClothModel, PhysxClothObject);
                World.AddObject(IObject);

                ForwardXNABasicShader.BasicEffect.EnableDefaultLighting();
            }

            {
                SimpleModel simpleModel = new SimpleModel(factory, "Model//block");
                simpleModel.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Blue), TextureType.DIFFUSE);

                BoxShapeDescription SphereGeometry    = new BoxShapeDescription(1000, 5, 1000);
                PhysxPhysicObject   PhysxPhysicObject = new PhysxPhysicObject(SphereGeometry,
                                                                              Matrix.Identity, new Vector3(1000, 5, 1000));

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

                shader.BasicEffect.EnableDefaultLighting();
            }


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

            Texture2D tMap = factory.GetTexture2D("Textures//hmap_10243");
            QuadTerrain q = new PloobsEngine.Material.QuadTerrain(factory, tMap, 33, 513, 10, 3f);

            ForwardTerrainMaterial mat = new ForwardTerrainMaterial(q);

            //Set various terrain stats.
            mat.diffuseScale = q.flatScale / 4;
            mat.detailScale = q.flatScale / 100;
            mat.detailMapStrength = 2;
            mat.textureBlend = factory.GetTexture2D("Textures//hmap_256blend");
            mat.textureDetail = factory.GetTexture2D("Textures//coolgrass2DOT3");
            mat.textureRed = factory.GetTexture2D("Textures//TexR");
            mat.textureGreen = factory.GetTexture2D("Textures//TexG");
            mat.textureBlue = factory.GetTexture2D("Textures//TexB");
            mat.textureBlack = factory.GetTexture2D("Textures//TexBase");

            mat.sunlightVector = Vector3.Normalize(new Vector3(.5f, .5f, .8f));
            mat.sunlightColour = new Vector3(2.3f, 2f, 1.8f);
            float[,] f = q.getHeightMap();
            int v = 513;
            var samples = new HeightFieldSample[v * v];

            for (int r = 0; r < v; r++)
            {
                for (int c = 0; c < v ; c++)
                {
                    var sample = new HeightFieldSample()
                    {
                        Height = (short)f[r, c],                        
                        //Height = 5,                        
                        TessellationFlag = 1,
                        MaterialIndex0 = 1,
                        MaterialIndex1 = 0
                    };

                    samples[r * v + c] = sample;
                }
            }

            var heightFieldDesc = new HeightFieldDescription()
            {
                NumberOfRows = v,
                NumberOfColumns = v,                                
                ConvexEdgeThreshold = 0f,

            };
            heightFieldDesc.SetSamples(samples);
            
            var heightField = PhysxPhysicWorld.Core.CreateHeightField(heightFieldDesc);
            
            heightFieldDesc.Dispose();

            var heightFieldShapeDesc = new HeightFieldShapeDescription()
            {
                HeightField = heightField,
                HeightScale = 1.0f,
                RowScale = 1,
                ColumnScale = 1,
            };
            heightFieldShapeDesc.LocalPose = StillDesign.PhysX.MathPrimitives.Matrix.Identity;

            var actorDesc = new ActorDescription()
            {
                GlobalPose = Matrix.Identity.AsPhysX(),
                Shapes = { heightFieldShapeDesc },                
            };

            actor = PhysxPhysicWorld.Scene.CreateActor(actorDesc);

            IObject obj3 = new IObject(mat, null, new PhysxGhostObject());
            this.World.AddObject(obj3);            
            
            BallThrowPhysx28 BallThrowBullet = new BallThrowPhysx28(this.World, GraphicFactory);
            this.AttachCleanUpAble(BallThrowBullet);

            CameraFirstPerson CameraFirstPerson = new CameraFirstPerson(GraphicInfo);
            CameraFirstPerson.FarPlane = 20000;
            this.World.CameraManager.AddCamera(CameraFirstPerson);
        }
Exemplo n.º 18
0
        protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager)
        {
            PhysxPhysicWorld PhysxPhysicWorld = World.PhysicWorld as PhysxPhysicWorld;

            base.LoadContent(GraphicInfo, factory, contentManager);

            // Create a simple fluid description with fluids and visualization enabled
            FluidDescription fluidDesc = new FluidDescription()
            {
                Flags = FluidFlag.Enabled | FluidFlag.Visualization,
            };

            // Store our particle positions somewhere (as our particle generation function below generates and unknown number of particles at runtime we need a list instead of an array)
            var particlePositions = new List <Phyx.Vector3>();

            // Move all the particles by this offset
            Phyx.Vector3 position = new Phyx.Vector3(0, 20, 0);

            // Number of particles in the x, y and z directions
            int   sideNum  = 10;
            float distance = 1f;

            float radius = sideNum * distance * 0.5f;

            for (int i = 0; i < sideNum; i++)
            {
                for (int j = 0; j < sideNum; j++)
                {
                    for (int k = 0; k < sideNum; k++)
                    {
                        Phyx.Vector3 p = new Phyx.Vector3(i * distance, j * distance, k * distance);

                        if ((p - new Phyx.Vector3(radius, radius, radius)).Length() < radius)
                        {
                            p += position - new Phyx.Vector3(radius, radius, radius);

                            particlePositions.Add(p);
                        }
                    }
                }
            }

            // Allocate memory for the initial particle positions to be stored in
            // And then set the position buffer
            fluidDesc.InitialParticleData.AllocatePositionBuffer <Phyx.Vector3>(particlePositions.Count);
            fluidDesc.InitialParticleData.NumberOfParticles = particlePositions.Count;
            fluidDesc.InitialParticleData.PositionBuffer.SetData(particlePositions.ToArray());

            // Allocate memory for PhysX to store the position of each particle
            fluidDesc.ParticleWriteData.AllocatePositionBuffer <Phyx.Vector3>(particlePositions.Count);
            fluidDesc.ParticleWriteData.NumberOfParticles = particlePositions.Count;

            InstancedBilboardModel          InstancedBilboardModel          = new InstancedBilboardModel(factory, "teste", "Textures/Smoke", new BilboardInstance[] { new BilboardInstance() }, particlePositions.Count);
            PhysxFluidObject                PhysxFluidObject                = new PloobsEngine.Physics.PhysxFluidObject(fluidDesc);
            DeferredInstancedBilboardShader DeferredInstancedBilboardShader = new PloobsEngine.Material.DeferredInstancedBilboardShader(BilboardType.Spherical);

            DeferredInstancedBilboardShader.AlphaTestLimit = 0.2f;
            FluidMaterial DeferredMaterial = new FluidMaterial(DeferredInstancedBilboardShader, particlePositions.Count, new Vector2(0.2f));
            IObject       IObject          = new IObject(DeferredMaterial, InstancedBilboardModel, PhysxFluidObject);

            this.World.AddObject(IObject);


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

                PhysxPhysicObject PhysxPhysicObject = new PloobsEngine.Physics.PhysxPhysicObject(boxShapeDesc,
                                                                                                 (Phyx.Matrix.RotationZ(0.3f) *
                                                                                                  Phyx.Matrix.Translation(0, 5, 0)).AsXNA(), new Vector3(10, 0.2f, 10));
                DeferredNormalShader shader    = new DeferredNormalShader();
                DeferredMaterial     fmaterial = new DeferredMaterial(shader);
                IObject obj = new IObject(fmaterial, SimpleModel, PhysxPhysicObject);
                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


            BallThrowPhysx28 BallThrowBullet = new BallThrowPhysx28(this.World, GraphicFactory, false);
            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);            

            var grid = VertexGrid.CreateGrid(100, 100, 0.3f, 100, 100);
            
            ClothModel ClothModel = new PloobsEngine.Modelo.ClothModel(factory, PhysxPhysicWorld,
                new ClothMeshDescription(), grid.Points,grid.TextCoords,grid.Indices, "Textures//meiofio");

            var clothDesc = new ClothDescription()
            {
                Friction = 0.5f,
                ClothMesh = ClothModel.ClothMesh,
                Flags = ClothFlag.Bending | ClothFlag.CollisionTwoway | ClothFlag.Visualization ,
                Thickness = 0.2f,                
                WindAcceleration = new StillDesign.PhysX.MathPrimitives.Vector3(10,0,10)
            };            
                        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 ;            
            
            PhysxClothObject PhysxClothObject = new PloobsEngine.Physics.PhysxClothObject(clothDesc,
                                                Matrix.CreateRotationX((float)Math.PI / 2f) * Matrix.CreateTranslation(0,10,0));

            
            ForwardXNABasicShader ForwardXNABasicShader = new PloobsEngine.Material.ForwardXNABasicShader();
            ClothMaterial ClothMaterial = new ClothMaterial(ForwardXNABasicShader);
            IObject IObject = new PloobsEngine.SceneControl.IObject(ClothMaterial, ClothModel, PhysxClothObject);
            
            World.AddObject(IObject);
            
                ///pra preender            
                CapsuleShapeDescription CapsuleShapeDescription = new StillDesign.PhysX.CapsuleShapeDescription();
                CapsuleShapeDescription.Height = 100;
                CapsuleShapeDescription.Radius = 0.15f;
                CapsuleShapeDescription.LocalPosition = new StillDesign.PhysX.MathPrimitives.Vector3(0, 0.15f + 0.5f * 10, 0);
                
                var actorDesc = new ActorDescription()
                {
                    GlobalPose = StillDesign.PhysX.MathPrimitives.Matrix.Translation(0,-0.2f,0),
                    Shapes = { CapsuleShapeDescription }
                };

                var actor = PhysxPhysicWorld.Scene.CreateActor(actorDesc);

                PhysxClothObject.Cloth.AttachToShape(actor.Shapes.First(), (ClothAttachmentFlag)0);                
            
                        
            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);

            // Create a simple fluid description with fluids and visualization enabled
            FluidDescription fluidDesc = new FluidDescription()
            {
                Flags = FluidFlag.Enabled | FluidFlag.Visualization,
            };

            // Store our particle positions somewhere (as our particle generation function below generates and unknown number of particles at runtime we need a list instead of an array)
            var particlePositions = new List<Phyx.Vector3>();

            // Move all the particles by this offset
            Phyx.Vector3 position = new Phyx.Vector3(0, 20, 0);

            // Number of particles in the x, y and z directions
            int sideNum = 10;
            float distance = 1f;

            float radius = sideNum * distance * 0.5f;

            for (int i = 0; i < sideNum; i++)
            {
                for (int j = 0; j < sideNum; j++)
                {
                    for (int k = 0; k < sideNum; k++)
                    {
                        Phyx.Vector3 p = new Phyx.Vector3(i * distance, j * distance, k * distance);

                        if ((p - new Phyx.Vector3(radius, radius, radius)).Length() < radius)
                        {
                            p += position - new Phyx.Vector3(radius, radius, radius);

                            particlePositions.Add(p);
                        }
                    }
                }
            }

            // Allocate memory for the initial particle positions to be stored in
            // And then set the position buffer
            fluidDesc.InitialParticleData.AllocatePositionBuffer<Phyx.Vector3>(particlePositions.Count);
            fluidDesc.InitialParticleData.NumberOfParticles = particlePositions.Count;
            fluidDesc.InitialParticleData.PositionBuffer.SetData(particlePositions.ToArray());

            // Allocate memory for PhysX to store the position of each particle
            fluidDesc.ParticleWriteData.AllocatePositionBuffer<Phyx.Vector3>(particlePositions.Count);
            fluidDesc.ParticleWriteData.NumberOfParticles = particlePositions.Count;

            InstancedBilboardModel InstancedBilboardModel = new InstancedBilboardModel(factory, "teste", "Textures/Smoke", new BilboardInstance[] { new BilboardInstance() }, particlePositions.Count);
            PhysxFluidObject PhysxFluidObject = new PloobsEngine.Physics.PhysxFluidObject(fluidDesc);
            DeferredInstancedBilboardShader DeferredInstancedBilboardShader = new PloobsEngine.Material.DeferredInstancedBilboardShader(BilboardType.Spherical);
            DeferredInstancedBilboardShader.AlphaTestLimit = 0.2f;
            FluidMaterial DeferredMaterial = new FluidMaterial(DeferredInstancedBilboardShader, particlePositions.Count, new Vector2(0.2f));
            IObject IObject = new IObject(DeferredMaterial, InstancedBilboardModel, PhysxFluidObject);
            this.World.AddObject(IObject);


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

                PhysxPhysicObject PhysxPhysicObject = new PloobsEngine.Physics.PhysxPhysicObject(boxShapeDesc,
                    (Phyx.Matrix.RotationZ(0.3f) *
                        Phyx.Matrix.Translation(0, 5, 0)).AsXNA(), new Vector3(10, 0.2f, 10));
                DeferredNormalShader shader = new DeferredNormalShader();
                DeferredMaterial fmaterial = new DeferredMaterial(shader);
                IObject obj = new IObject(fmaterial, SimpleModel, PhysxPhysicObject);
                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


            BallThrowPhysx28 BallThrowBullet = new BallThrowPhysx28(this.World, GraphicFactory,false);
            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);

            const int maximumParticles = 1000;
            var       fluidEmitterDesc = new FluidEmitterDescription()
            {
                DimensionX   = 0.5f,
                DimensionY   = 0.5f,
                Rate         = 15,
                RelativePose =
                    Phyx.Matrix.RotationAxis(new Phyx.Vector3(0, 1, 0), (float)Math.PI) *
                    Phyx.Matrix.Translation(-40, 10, -50),
                Shape       = EmitterShape.Rectangular,
                Type        = EmitterType.ConstantFlowRate,
                RandomAngle = 0.5f
            };

            fluidEmitterDesc.Flags |= (FluidEmitterFlag.Enabled | FluidEmitterFlag.Visualization);

            var fluidDesc = new FluidDescription()
            {
                Emitters         = { fluidEmitterDesc },
                Flags            = FluidFlag.Enabled | FluidFlag.Visualization | FluidFlag.Enabled,
                MaximumParticles = maximumParticles,
            };

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

            InstancedBilboardModel          InstancedBilboardModel          = new InstancedBilboardModel(factory, "teste", "Textures/Smoke", new BilboardInstance[] { new BilboardInstance() }, maximumParticles);
            PhysxFluidObject                PhysxFluidObject                = new PloobsEngine.Physics.PhysxFluidObject(fluidDesc);
            DeferredInstancedBilboardShader DeferredInstancedBilboardShader = new PloobsEngine.Material.DeferredInstancedBilboardShader(BilboardType.Spherical);

            DeferredInstancedBilboardShader.AlphaTestLimit = 0.2f;
            FluidMaterial DeferredMaterial = new FluidMaterial(DeferredInstancedBilboardShader, maximumParticles, new Vector2(0.2f));
            IObject       IObject          = new IObject(DeferredMaterial, InstancedBilboardModel, PhysxFluidObject);

            this.World.AddObject(IObject);


            // Ledge
            {
                var         boxShapeDesc = new BoxShapeDescription(5, 0.1f, 5);
                SimpleModel SimpleModel  = new PloobsEngine.Modelo.SimpleModel(factory, "Model/block");
                SimpleModel.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Red), TextureType.DIFFUSE);

                PhysxPhysicObject PhysxPhysicObject = new PloobsEngine.Physics.PhysxPhysicObject(boxShapeDesc,
                                                                                                 (Phyx.Matrix.RotationX(-0.5f) * Phyx.Matrix.Translation(-40, 5, -52)).AsXNA(), new Vector3(5, 0.1f, 5));
                DeferredNormalShader shader    = new DeferredNormalShader();
                DeferredMaterial     fmaterial = new DeferredMaterial(shader);
                IObject obj = new IObject(fmaterial, SimpleModel, PhysxPhysicObject);
                this.World.AddObject(obj);
            }

            // Drain
            {
                var boxShapeDesc = new BoxShapeDescription(5, 0.1f, 5);
                boxShapeDesc.Flags |= ShapeFlag.FluidDrain;

                var drainActorDesc = new ActorDescription()
                {
                    GlobalPose = Phyx.Matrix.Translation(-40, 0, -55),
                    Shapes     = { boxShapeDesc }
                };

                var drianActor = PhysxPhysicWorld.Scene.CreateActor(drainActorDesc);
            }

            #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));
        }
        protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory ,IContentManager contentManager)
        {
            PhysxPhysicWorld PhysxPhysicWorld = World.PhysicWorld as PhysxPhysicWorld;

            base.LoadContent(GraphicInfo, factory, contentManager);            

            int w = 25;
            int h = 25;

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

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

            var grid = VertexGrid.CreateGrid(w, h);
            
            ClothModel ClothModel = new PloobsEngine.Modelo.ClothModel(factory, PhysxPhysicWorld,
                new ClothMeshDescription(), grid.Points,grid.TextCoords,grid.Indices, "Textures//meiofio");

            var clothDesc = new ClothDescription()
            {
                Friction = 0.5f,
                ClothMesh = ClothModel.ClothMesh,
                Flags = ClothFlag.Gravity | ClothFlag.Bending | ClothFlag.CollisionTwoway | ClothFlag.Visualization ,
                Thickness = 0.2f,                
            };            
            
            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 ;            
            
            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);



            // Four corner boxes to hold it in place
            var positions = new[]
			{
				new StillDesign.PhysX.MathPrimitives.Vector3(0, 0, -hh), // Back
				new StillDesign.PhysX.MathPrimitives.Vector3(0, 0, hh), // Front
				new StillDesign.PhysX.MathPrimitives.Vector3(-hw, 0, 0), // Left
				new StillDesign.PhysX.MathPrimitives.Vector3(hw, 0, 0), // Right
			};

            var sizes = new[]
			{
				new StillDesign.PhysX.MathPrimitives.Vector3(w, 1, 1), // Back
				new StillDesign.PhysX.MathPrimitives.Vector3(w, 1, 1), // Front
				new StillDesign.PhysX.MathPrimitives.Vector3(1, 1, h), // Left
				new StillDesign.PhysX.MathPrimitives.Vector3(1, 1, h), //Right
			};

            ///pra preender
            for (int i = 0; i < 2; i++)
            {
                var actorDesc = new ActorDescription()
                {
                    GlobalPose = StillDesign.PhysX.MathPrimitives.Matrix.Translation(positions[i] + p.AsPhysX()),
                    Shapes = { new BoxShapeDescription(sizes[i]) }
                };

                var actor = PhysxPhysicWorld.Scene.CreateActor(actorDesc);


                PhysxClothObject.Cloth.AttachToShape(actor.Shapes.First(), (ClothAttachmentFlag)0);                
            }
                        
            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);

            for (int i = 0; i < 3; i++)
            {
                ClothMeshDescription ClothMeshDescription = new ClothMeshDescription();
                ClothMeshDescription.WeldingDistance = 0.0001f;
                ClothMeshDescription.Flags = (MeshFlag)(int)ClothMeshFlag.WeldVertices;


                ClothModel ClothModel = new PloobsEngine.Modelo.ClothModel(factory, PhysxPhysicWorld,
                    ClothMeshDescription, "Model//ball", Vector3.One * 25, "Textures//meiofio");

                var clothDesc = new ClothDescription()
                {
                    Friction = 0.5f,
                    ClothMesh = ClothModel.ClothMesh,
                    Pressure = 0.9f,
                    Flags = ClothFlag.Bending | ClothFlag.CollisionTwoway | ClothFlag.Visualization | ClothFlag.Pressure | ClothFlag.Gravity | ClothFlag.SelfCollision | ClothFlag.TriangleCollision,
                    Thickness = 0.4f,
                };


                clothDesc.MeshData.AllocatePositions<Vector3>(ClothModel.VerticesNum);
                clothDesc.MeshData.AllocateIndices<int>(ClothModel.IndicesNum);
                clothDesc.MeshData.AllocateNormals<Vector3>(ClothModel.VerticesNum);

                clothDesc.MeshData.MaximumVertices = ClothModel.VerticesNum;
                clothDesc.MeshData.MaximumIndices = ClothModel.IndicesNum;

                clothDesc.MeshData.NumberOfVertices = ClothModel.VerticesNum;
                clothDesc.MeshData.NumberOfIndices = ClothModel.IndicesNum;

                PhysxClothObject PhysxClothObject = new PloobsEngine.Physics.PhysxClothObject(clothDesc,
                                                    Matrix.CreateTranslation(100, 50, i * 100));


                ForwardXNABasicShader ForwardXNABasicShader = new PloobsEngine.Material.ForwardXNABasicShader();
                ClothMaterial ClothMaterial = new ClothMaterial(ForwardXNABasicShader);
                //ClothMaterial.RasterizerState.FillMode = FillMode.WireFrame;
                IObject IObject = new PloobsEngine.SceneControl.IObject(ClothMaterial, ClothModel, PhysxClothObject);
                World.AddObject(IObject);

                ForwardXNABasicShader.BasicEffect.EnableDefaultLighting();
            }

            {
                SimpleModel simpleModel = new SimpleModel(factory, "Model//block");
                simpleModel.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Blue), TextureType.DIFFUSE);

                BoxShapeDescription SphereGeometry = new BoxShapeDescription(1000, 5, 1000);
                PhysxPhysicObject PhysxPhysicObject = new PhysxPhysicObject(SphereGeometry,
                    Matrix.Identity, new Vector3(1000, 5, 1000));

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

                shader.BasicEffect.EnableDefaultLighting();
            }


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

            const int maximumParticles = 1000;
            var fluidEmitterDesc = new FluidEmitterDescription()
            {
                DimensionX = 0.5f,
                DimensionY = 0.5f,
                Rate = 15,
                RelativePose =
                    Phyx.Matrix.RotationAxis(new Phyx.Vector3(0, 1, 0), (float)Math.PI) *
                    Phyx.Matrix.Translation(-40, 10, -50),
                Shape = EmitterShape.Rectangular,
                Type = EmitterType.ConstantFlowRate,
                RandomAngle = 0.5f
            };
            fluidEmitterDesc.Flags |= (FluidEmitterFlag.Enabled | FluidEmitterFlag.Visualization);

            var fluidDesc = new FluidDescription()
            {
                Emitters = { fluidEmitterDesc },
                Flags = FluidFlag.Enabled | FluidFlag.Visualization | FluidFlag.Enabled,
                MaximumParticles = maximumParticles,
                
            };
            fluidDesc.ParticleWriteData.AllocatePositionBuffer<Vector3>(maximumParticles);
            fluidDesc.ParticleWriteData.NumberOfParticles = maximumParticles;

            InstancedBilboardModel InstancedBilboardModel = new InstancedBilboardModel(factory, "teste", "Textures/Smoke", new BilboardInstance[] {new BilboardInstance() }, maximumParticles);
            PhysxFluidObject PhysxFluidObject = new PloobsEngine.Physics.PhysxFluidObject(fluidDesc);
            DeferredInstancedBilboardShader DeferredInstancedBilboardShader = new PloobsEngine.Material.DeferredInstancedBilboardShader(BilboardType.Spherical);
            DeferredInstancedBilboardShader.AlphaTestLimit = 0.2f;
            FluidMaterial DeferredMaterial = new FluidMaterial(DeferredInstancedBilboardShader,maximumParticles,new Vector2(0.2f));
            IObject IObject = new IObject(DeferredMaterial, InstancedBilboardModel, PhysxFluidObject);
            this.World.AddObject(IObject);


            // Ledge
            {
                var boxShapeDesc = new BoxShapeDescription(5, 0.1f, 5);
                SimpleModel SimpleModel = new PloobsEngine.Modelo.SimpleModel(factory, "Model/block");
                SimpleModel.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Red), TextureType.DIFFUSE);

                PhysxPhysicObject PhysxPhysicObject = new PloobsEngine.Physics.PhysxPhysicObject(boxShapeDesc,
                    (Phyx.Matrix.RotationX(-0.5f) * Phyx.Matrix.Translation(-40, 5, -52)).AsXNA(),new Vector3(5,0.1f,5));
                DeferredNormalShader shader = new DeferredNormalShader();
                DeferredMaterial fmaterial = new DeferredMaterial(shader);
                IObject obj = new IObject(fmaterial, SimpleModel, PhysxPhysicObject);
                this.World.AddObject(obj);
            }

            // Drain
            {
                var boxShapeDesc = new BoxShapeDescription(5, 0.1f, 5);
                boxShapeDesc.Flags |= ShapeFlag.FluidDrain;

                var drainActorDesc = new ActorDescription()
                {
                    GlobalPose = Phyx.Matrix.Translation(-40, 0, -55),
                    Shapes = { boxShapeDesc }
                };

                var drianActor = PhysxPhysicWorld.Scene.CreateActor(drainActorDesc);
            }

            #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));
        }
        protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory ,IContentManager contentManager)
        {
            PhysxPhysicWorld PhysxPhysicWorld = World.PhysicWorld as PhysxPhysicWorld;
            
            base.LoadContent(GraphicInfo, factory, contentManager);

            const int maximumParticles = 1000;
            var fluidEmitterDesc = new FluidEmitterDescription()
            {
                DimensionX = 0.5f,
                DimensionY = 0.5f,
                Rate = 15,
                RelativePose =
                    Phyx.Matrix.RotationAxis(new Phyx.Vector3(0, 1, 0), (float)Math.PI) *
                    Phyx.Matrix.Translation(-40, 10, -50),
                Shape = EmitterShape.Rectangular,
                Type = EmitterType.ConstantFlowRate,
                RandomAngle = 0.5f
            };
            fluidEmitterDesc.Flags |= (FluidEmitterFlag.Enabled | FluidEmitterFlag.Visualization);

            var fluidDesc = new FluidDescription()
            {
                Emitters = { fluidEmitterDesc },
                Flags = FluidFlag.Enabled | FluidFlag.Visualization | FluidFlag.Enabled,
                MaximumParticles = maximumParticles,
                
            };
            fluidDesc.ParticleWriteData.AllocatePositionBuffer<Vector3>(maximumParticles);
            fluidDesc.ParticleWriteData.NumberOfParticles = maximumParticles;
            
            fluid = PhysxPhysicWorld.Scene.CreateFluid(fluidDesc);

                       
            Texture2D tex = factory.GetTexture2D("Textures/Smoke");
            for (int i = 0; i < maximumParticles; i++)
            {
                Billboard3D Billboard3D = new Billboard3D(tex,Vector3.Zero,new Vector2(0.002f));
                Billboard3D.Enabled = false;
                CPUSphericalBillboardComponent.Billboards.Add(Billboard3D);
            }


            // Ledge
            {
                var boxShapeDesc = new BoxShapeDescription(5, 0.1f, 5);
                SimpleModel SimpleModel = new PloobsEngine.Modelo.SimpleModel(factory, "Model/block");
                SimpleModel.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Red), TextureType.DIFFUSE);
                PhysxPhysicObject PhysxPhysicObject = new PloobsEngine.Physics.PhysxPhysicObject(boxShapeDesc,
                    (Phyx.Matrix.RotationX(-0.5f) * Phyx.Matrix.Translation(-40, 5, -52)).AsXNA(),new Vector3(5,0.1f,5));
                ForwardXNABasicShader shader = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default());
                ForwardMaterial fmaterial = new ForwardMaterial(shader);
                IObject obj = new IObject(fmaterial, SimpleModel, PhysxPhysicObject);
                this.World.AddObject(obj);
            }

            // Drain
            {
                var boxShapeDesc = new BoxShapeDescription(5, 0.1f, 5);
                boxShapeDesc.Flags |= ShapeFlag.FluidDrain;

                var drainActorDesc = new ActorDescription()
                {
                    GlobalPose = Phyx.Matrix.Translation(-40, 0, -55),
                    Shapes = { boxShapeDesc }
                };

                var drianActor = PhysxPhysicWorld.Scene.CreateActor(drainActorDesc);
            }            

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

            var grid = VertexGrid.CreateGrid(100, 100, 0.3f, 100, 100);

            ClothModel ClothModel = new PloobsEngine.Modelo.ClothModel(factory, PhysxPhysicWorld,
                                                                       new ClothMeshDescription(), grid.Points, grid.TextCoords, grid.Indices, "Textures//meiofio");

            var clothDesc = new ClothDescription()
            {
                Friction         = 0.5f,
                ClothMesh        = ClothModel.ClothMesh,
                Flags            = ClothFlag.Bending | ClothFlag.CollisionTwoway | ClothFlag.Visualization,
                Thickness        = 0.2f,
                WindAcceleration = new StillDesign.PhysX.MathPrimitives.Vector3(10, 0, 10)
            };

            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;

            PhysxClothObject PhysxClothObject = new PloobsEngine.Physics.PhysxClothObject(clothDesc,
                                                                                          Matrix.CreateRotationX((float)Math.PI / 2f) * Matrix.CreateTranslation(0, 10, 0));


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

            World.AddObject(IObject);

            ///pra preender
            CapsuleShapeDescription CapsuleShapeDescription = new StillDesign.PhysX.CapsuleShapeDescription();

            CapsuleShapeDescription.Height        = 100;
            CapsuleShapeDescription.Radius        = 0.15f;
            CapsuleShapeDescription.LocalPosition = new StillDesign.PhysX.MathPrimitives.Vector3(0, 0.15f + 0.5f * 10, 0);

            var actorDesc = new ActorDescription()
            {
                GlobalPose = StillDesign.PhysX.MathPrimitives.Matrix.Translation(0, -0.2f, 0),
                Shapes     = { CapsuleShapeDescription }
            };

            var actor = PhysxPhysicWorld.Scene.CreateActor(actorDesc);

            PhysxClothObject.Cloth.AttachToShape(actor.Shapes.First(), (ClothAttachmentFlag)0);


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

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