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)); }
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)); }
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(); }
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, 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//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); } 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(100, 100, 100), 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 = 0.4f; emitterDesc.DimensionY = 0.4f; emitterDesc.Type = EmitterType.ConstantFlowRate; emitterDesc.Rate = 300.0f; emitterDesc.FluidVelocityMagnitude = 50.0f; emitterDesc.ParticleLifetime = 10.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 = 20000; fluidDesc.KernelRadiusMultiplier = 2.0f; fluidDesc.RestParticlesPerMeter = 7.0f; fluidDesc.MotionLimitMultiplier = 3.0f; fluidDesc.PacketSizeMultiplier = 8; fluidDesc.CollisionDistanceMultiplier = 0.1f; 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>(30000); fluidDesc.ParticleWriteData.NumberOfParticles = 30000; ///Use instanced Billboard to render the particles ! InstancedBilboardModel InstancedBilboardModel = new InstancedBilboardModel(factory, "teste", "Textures/Smoke", new BilboardInstance[] { new BilboardInstance() }, 20000); PhysxFluidObject PhysxFluidObject = new PloobsEngine.Physics.PhysxFluidObject(fluidDesc); DeferredInstancedBilboardShader DeferredInstancedBilboardShader = new PloobsEngine.Material.DeferredInstancedBilboardShader(BilboardType.Spherical); DeferredInstancedBilboardShader.AlphaTestLimit = 0.2f; FluidMaterial DeferredMaterial = new FluidMaterial(DeferredInstancedBilboardShader, 20000, new Vector2(0.2f)); IObject IObject = new IObject(DeferredMaterial, InstancedBilboardModel, 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); ///grid var grid = VertexGrid.CreateGrid(100, 100, 0.3f, 100, 100); ///model ClothModel ClothModel = new PloobsEngine.Modelo.ClothModel(factory, PhysxPhysicWorld, new ClothMeshDescription(), grid.Points, grid.TextCoords, grid.Indices, "Textures//logo_texture"); ///description ///NOW WITH WIND =P 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); ForwardXNABasicShader.BasicEffect.EnableDefaultLighting(); ///TO HOLD !!! 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); for (int i = 0; i < 3; i++) { ///Different from others examples, we use a model to provide the vertices to the cloth ///Model must be "closed" 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, ///experiment changing this =P 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); ///grid var grid = VertexGrid.CreateGrid(100, 100, 0.3f, 100, 100); ///model ClothModel ClothModel = new PloobsEngine.Modelo.ClothModel(factory, PhysxPhysicWorld, new ClothMeshDescription(), grid.Points, grid.TextCoords, grid.Indices, "Textures//logo_texture"); ///description ///NOW WITH WIND =P 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); ForwardXNABasicShader.BasicEffect.EnableDefaultLighting(); ///TO HOLD !!! 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); const int maximumParticles = 3000; ///Remember ///There are 2 math apis (XNA AND PHYSX) ///Sometimes we need to convert between then ///Use the extension methods AsPhysx() in XNA API and AsXNA in Physx APi ///emitter var fluidEmitterDesc = new FluidEmitterDescription() { DimensionX = 1.5f, DimensionY = 1.5f, Rate = 65, 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); ///fluid var fluidDesc = new FluidDescription() { Emitters = { fluidEmitterDesc }, Flags = FluidFlag.Enabled | FluidFlag.Visualization, MaximumParticles = maximumParticles, }; fluidDesc.ParticleWriteData.AllocatePositionBuffer<Vector3>(maximumParticles); fluidDesc.ParticleWriteData.NumberOfParticles = maximumParticles; ///create and add the fluid to the world fluid = PhysxPhysicWorld.Scene.CreateFluid(fluidDesc); ///Use Billboards to render the fuild particles (dummy way) Texture2D tex = factory.GetTexture2D("Textures/Smoke"); for (int i = 0; i < maximumParticles; i++) { Billboard3D Billboard3D = new Billboard3D(tex,Vector3.Zero,new Vector2(0.001f)); 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, -20, -55), Shapes = { boxShapeDesc } }; var drianActor = PhysxPhysicWorld.Scene.CreateActor(drainActorDesc); } BallThrowPhysx28 BallThrowBullet = new BallThrowPhysx28(this.World, GraphicFactory); BallThrowBullet.ballSize = 1f; BallThrowBullet.Speed = 25; this.AttachCleanUpAble(BallThrowBullet); CameraFirstPerson CameraFirstPerson = new CameraFirstPerson(GraphicInfo); CameraFirstPerson.Position = new Vector3(-35, 8, -52); CameraFirstPerson.LeftRightRot = MathHelper.ToRadians(125); 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); ///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)); }
protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager) { PhysxPhysicWorld PhysxPhysicWorld = World.PhysicWorld as PhysxPhysicWorld; base.LoadContent(GraphicInfo, factory, contentManager); const int maximumParticles = 3000; ///Remember ///There are 2 math apis (XNA AND PHYSX) ///Sometimes we need to convert between then ///Use the extension methods AsPhysx() in XNA API and AsXNA in Physx APi ///emitter var fluidEmitterDesc = new FluidEmitterDescription() { DimensionX = 1.5f, DimensionY = 1.5f, Rate = 65, 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); ///fluid var fluidDesc = new FluidDescription() { Emitters = { fluidEmitterDesc }, Flags = FluidFlag.Enabled | FluidFlag.Visualization, MaximumParticles = maximumParticles, }; fluidDesc.ParticleWriteData.AllocatePositionBuffer <Vector3>(maximumParticles); fluidDesc.ParticleWriteData.NumberOfParticles = maximumParticles; ///create and add the fluid to the world fluid = PhysxPhysicWorld.Scene.CreateFluid(fluidDesc); ///Use Billboards to render the fuild particles (dummy way) Texture2D tex = factory.GetTexture2D("Textures/Smoke"); for (int i = 0; i < maximumParticles; i++) { Billboard3D Billboard3D = new Billboard3D(tex, Vector3.Zero, new Vector2(0.001f)); 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, -20, -55), Shapes = { boxShapeDesc } }; var drianActor = PhysxPhysicWorld.Scene.CreateActor(drainActorDesc); } BallThrowPhysx28 BallThrowBullet = new BallThrowPhysx28(this.World, GraphicFactory); BallThrowBullet.ballSize = 1f; BallThrowBullet.Speed = 25; this.AttachCleanUpAble(BallThrowBullet); CameraFirstPerson CameraFirstPerson = new CameraFirstPerson(GraphicInfo); CameraFirstPerson.Position = new Vector3(-35, 8, -52); CameraFirstPerson.LeftRightRot = MathHelper.ToRadians(125); 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); ///Cosntruct a grid of vertices to make a cloth 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); ///Cloth Model (Code inside the demo) ClothModel ClothModel = new PloobsEngine.Modelo.ClothModel(factory, PhysxPhysicWorld, new ClothMeshDescription(), grid.Points, grid.TextCoords, grid.Indices, "Textures//meiofio"); ///Cloth Description var clothDesc = new ClothDescription() { Friction = 0.5f, ClothMesh = ClothModel.ClothMesh, Flags = ClothFlag.Gravity | ClothFlag.Bending | ClothFlag.CollisionTwoway | ClothFlag.Visualization, Thickness = 0.2f, }; ///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); ///Fixing the Cloth to some fixed Points // 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 }; ///To Hold for (int i = 0; i < 2; i++) { ///Create e Actor DIRECTELY without a PLOOBS Object. ///Ploobs does not know it "exists" var actorDesc = new ActorDescription() { GlobalPose = StillDesign.PhysX.MathPrimitives.Matrix.Translation(positions[i] + p.AsPhysX()), Shapes = { new BoxShapeDescription(sizes[i]) } }; ///When you create the actor, you are automagically adding it to the world var actor = PhysxPhysicWorld.Scene.CreateActor(actorDesc); ///Attach one to another PhysxClothObject.Cloth.AttachToShape(actor.Shapes.First(), (ClothAttachmentFlag)0); } BallThrowPhysx28 BallThrowBullet = new BallThrowPhysx28(this.World, GraphicFactory); BallThrowBullet.ballSize = 1; BallThrowBullet.Speed = 20; 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(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(); }
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"); ///Create A basic material StillDesign.PhysX.Material material1 = PhysxPhysicWorld.CreatePhysicMaterial( new StillDesign.PhysX.MaterialDescription() { Restitution = 0.3f, DynamicFriction = 0.5f, StaticFriction = 1, } ); ///Triangle mesh 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); ///Create some ball with random materials properties 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); ///Shape description ///REMEMBER ///YOU NEED TO APPLY THE SCALE MANUALLY TO THE SHAPE ///IN THIS CASE the physic object has a scale of 5 and the SphereShapeDescription has a ray of 5. ///The user MUST MATCH the size of the SHAPE with the Scale applied to the IModelo 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)); }
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++) { ///Different from others examples, we use a model to provide the vertices to the cloth ///Model must be "closed" 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, ///experiment changing this =P 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)); }