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