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)); }
public override void Update(GameTime gt, PloobsEngine.SceneControl.IObject ent, IList <PloobsEngine.Light.ILight> lights) { base.Update(gt, ent, lights); PhysxFluidObject PhysxFluidObject = ent.PhysicObject as PhysxFluidObject; FluidMOdel FluidMOdel = ent.Modelo as FluidMOdel; if (!PhysxFluidObject.Fluid.ParticleWriteData.NumberOfParticles.HasValue) { return; } Phyx.Vector3[] pos = PhysxFluidObject.Fluid.ParticleWriteData.PositionBuffer.GetData <Phyx.Vector3>(); int j = 0; for (int i = 0; i < PhysxFluidObject.Fluid.ParticleWriteData.NumberOfParticles * 6; i += 6) { FluidMOdel.billboardVertices[i].Position = pos[j].AsXNA(); FluidMOdel.billboardVertices[i + 1].Position = pos[j].AsXNA(); FluidMOdel.billboardVertices[i + 2].Position = pos[j].AsXNA(); FluidMOdel.billboardVertices[i + 3].Position = pos[j].AsXNA(); FluidMOdel.billboardVertices[i + 4].Position = pos[j].AsXNA(); FluidMOdel.billboardVertices[i + 5].Position = pos[j].AsXNA(); j++; } FluidMOdel.UpdateVertices(pos.Count()); }
protected override void Draw(Microsoft.Xna.Framework.GameTime gt, PloobsEngine.SceneControl.IObject obj, PloobsEngine.SceneControl.RenderHelper render, PloobsEngine.Cameras.ICamera cam, IList <PloobsEngine.Light.ILight> lights) { Effect.CurrentTechnique = Effect.Techniques["FLUID3"]; Effect.Parameters["depth"].SetValue(r1); Effect.Parameters["normal"].SetValue(r3); Effect.Parameters["camPos"].SetValue(Vector3.Transform(cam.Position, cam.View)); Effect.Parameters["invxView"].SetValue(Matrix.Invert(cam.View)); render.RenderFullScreenQuadVertexPixel(Effect); //render.RenderTextureComplete(r3); render.SetSamplerStates(ginfo.SamplerState); }
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)); }
/// <summary> /// Initializes this instance. /// </summary> /// <param name="ginfo"></param> /// <param name="factory"></param> /// <param name="obj"></param> public override void Initialize(PloobsEngine.Engine.GraphicInfo ginfo, PloobsEngine.Engine.GraphicFactory factory, PloobsEngine.SceneControl.IObject obj) { this._shader = factory.GetEffect(effect, false, true); base.Initialize(ginfo, factory, obj); PProjection = this._shader.Parameters["Projection"]; PView = this._shader.Parameters["View"]; PuseSpecular = this._shader.Parameters["useSpecular"]; PuseBump = this._shader.Parameters["useBump"]; PuseGlow = this._shader.Parameters["useGlow"]; PCameraPos = this._shader.Parameters["CameraPos"]; Pid = this._shader.Parameters["id"]; //PTexture = this._shader.Parameters["Texture"]; PspecularPowerScale = this._shader.Parameters["specularPowerScale"]; PspecularIntensityScale = this._shader.Parameters["specularIntensityScale"]; PspecularPower = this._shader.Parameters["specularPower"]; PspecularIntensity = this._shader.Parameters["specularIntensity"]; PWorld = this._shader.Parameters["World"]; PWorldInverseTranspose = this._shader.Parameters["WorldInverseTranspose"]; //PNormalMap = this._shader.Parameters["NormalMap"]; //PSpecularMap = this._shader.Parameters["SpecularMap"]; //Pglow = this._shader.Parameters["glow"]; PreflectionIndex = this._shader.Parameters["reflectionIndex"]; //PDiffuse = this._shader.Parameters["DifTex"]; }
public override void Initialize(PloobsEngine.Engine.GraphicInfo ginfo, PloobsEngine.Engine.GraphicFactory factory, PloobsEngine.SceneControl.IObject obj) { base.Initialize(ginfo, factory, obj); #if WINDOWS_PHONE || REACH SkinnedEffect = factory.GetSkinnedEffect(); SkinnedEffect.EnableDefaultLighting(); #endif }
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); ///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); 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); 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)); }
/// <summary> /// Initializes this instance. /// </summary> /// <param name="ginfo"></param> /// <param name="factory"></param> /// <param name="obj"></param> public override void Initialize(PloobsEngine.Engine.GraphicInfo ginfo, PloobsEngine.Engine.GraphicFactory factory, PloobsEngine.SceneControl.IObject obj) { this._shader = factory.GetEffect("Effects//ShatterEffect"); base.Initialize(ginfo, factory, obj); }
public override void PreDrawPhase(GameTime gt, PloobsEngine.SceneControl.IWorld world, PloobsEngine.SceneControl.IObject obj, PloobsEngine.SceneControl.RenderHelper render, PloobsEngine.Cameras.ICamera cam) { Effect.Parameters["InvertViewProjection"].SetValue(Matrix.Invert(cam.Projection)); Effect.Parameters["halfPixel"].SetValue(ginfo.HalfPixel); Effect.Parameters["forward"].SetValue(Vector3.Normalize(cam.Target - cam.Position)); Effect.Parameters["upVector"].SetValue(cam.Up); Effect.Parameters["xView"].SetValue(cam.View); Effect.Parameters["xProjection"].SetValue(cam.Projection); Effect.Parameters["scaleX"].SetValue(3.5f); Effect.Parameters["scaleY"].SetValue(3.5f); Effect.Parameters["sphereRadius"].SetValue(3f); Effect.CurrentTechnique = Effect.Techniques["FLUID0"]; render.PushRenderTarget(r1); render.Clear(Color.Black); render.PushRasterizerState(RasterizerState); render.PushDepthStencilState(DepthStencilState.Default); render.RenderBatch(obj.Modelo.GetBatchInformation(0)[0], Effect); render.PopRasterizerState(); render.PopDepthStencilState(); render.PopRenderTarget(); //Effect.CurrentTechnique = Effect.Techniques["FLUID2"]; //render.PushRenderTarget(r2); //render.Clear(Color.Black); //Effect.Parameters["depth"].SetValue(r1); //Effect.Parameters["blurDepthFalloff"].SetValue(0); //Effect.Parameters["blurScale"].SetValue(1.5f); //Effect.Parameters["blurDir"].SetValue(new Vector2( 2 * ginfo.HalfPixel.X,0)); //render.RenderFullScreenQuadVertexPixel(Effect); //render.PopRenderTarget(); //Effect.CurrentTechnique = Effect.Techniques["FLUID2"]; //render.PushRenderTarget(r1); //render.Clear(Color.Black); //Effect.Parameters["depth"].SetValue(r2); //Effect.Parameters["blurDepthFalloff"].SetValue(0); //Effect.Parameters["blurScale"].SetValue(1.5f); //Effect.Parameters["blurDir"].SetValue(new Vector2(0, 2 * ginfo.HalfPixel.Y)); //render.RenderFullScreenQuadVertexPixel(Effect); //render.PopRenderTarget(); Effect.Parameters["blurDepthFalloff"].SetValue(20); render.PushRenderTarget(r2); render.Clear(Color.Black); PerformGaussianBLur(render, r1); render.PopRenderTarget(); render.PushRenderTarget(r1); render.Clear(Color.Black); PerformGaussianBLur(render, r2); render.PopRenderTarget(); render.PushRenderTarget(r3); render.Clear(Color.Black); Effect.CurrentTechnique = Effect.Techniques["FLUID1"]; Effect.Parameters["depth"].SetValue(r1); render.RenderFullScreenQuadVertexPixel(Effect); render.PopRenderTarget(); //render.PushRenderTarget(r3); //render.Clear(Color.Black); //GaussianBlurPostEffect.Draw(r2, render, gt, ginfo, world, false); //render.PopRenderTarget(); //render.PushRenderTarget(r2); //render.Clear(Color.Black); //GaussianBlurPostEffect.Draw(r3, render, gt, ginfo, world, false); //render.PopRenderTarget(); }
public override void Initialize(PloobsEngine.Engine.GraphicInfo ginfo, PloobsEngine.Engine.GraphicFactory factory, PloobsEngine.SceneControl.IObject obj) { this.ginfo = ginfo; Effect = factory.GetEffect("Effects/fluid"); r1 = factory.CreateRenderTarget(ginfo.BackBufferWidth, ginfo.BackBufferHeight, SurfaceFormat.Single); r2 = factory.CreateRenderTarget(ginfo.BackBufferWidth, ginfo.BackBufferHeight, SurfaceFormat.Single); r3 = factory.CreateRenderTarget(ginfo.BackBufferWidth, ginfo.BackBufferHeight, SurfaceFormat.Color); gaussian = factory.CreateRenderTarget(ginfo.BackBufferWidth, ginfo.BackBufferHeight, SurfaceFormat.Single); ComputeKernel(BLUR_RADIUS, BLUR_AMOUNT); ComputeOffsets(ginfo.BackBufferWidth, ginfo.BackBufferHeight); }
/// <summary> /// Initializes this instance. /// </summary> /// <param name="ginfo"></param> /// <param name="factory"></param> /// <param name="obj"></param> public override void Initialize(PloobsEngine.Engine.GraphicInfo ginfo, PloobsEngine.Engine.GraphicFactory factory, PloobsEngine.SceneControl.IObject obj) { this._shader = factory.GetEffect(effect, true, true); base.Initialize(ginfo, factory, obj); PProjection = this._shader.Parameters["Projection"]; PView = this._shader.Parameters["View"]; PuseSpecular = this._shader.Parameters["useSpecular"]; PuseBump = this._shader.Parameters["useBump"]; PuseGlow = this._shader.Parameters["useGlow"]; PuseParalax = this._shader.Parameters["useParalax"]; Pid = this._shader.Parameters["id"]; //PTexture = this._shader.Parameters["Texture"]; PspecularPowerScale = this._shader.Parameters["specularPowerScale"]; PspecularIntensityScale = this._shader.Parameters["specularIntensityScale"]; PspecularPower = this._shader.Parameters["specularPower"]; PspecularIntensity = this._shader.Parameters["specularIntensity"]; PWorld = this._shader.Parameters["World"]; PWorldInverseTranspose = this._shader.Parameters["WorldInverseTranspose"]; //PNormalMap = this._shader.Parameters["NormalMap"]; //PSpecularMap = this._shader.Parameters["SpecularMap"]; //Pglow = this._shader.Parameters["glow"]; //PAmbientCube = this._shader.Parameters["ambientcube"]; PAmbientCubeMapScale = this._shader.Parameters["ambientScale"]; if (useAmbientCubeMap == true) { this._shader.CurrentTechnique = this._shader.Techniques["Technique2"]; } else { this._shader.CurrentTechnique = this._shader.Techniques["Technique1"]; } }
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)); }
public override void Initialize(PloobsEngine.Engine.GraphicInfo ginfo, PloobsEngine.Engine.GraphicFactory factory, PloobsEngine.SceneControl.IObject obj) { base.Initialize(ginfo, factory, obj); this._shader = factory.GetEffect("WaterComplete", true, true); refractionRT = factory.CreateRenderTarget(WIDTH, HEIGHT); reflectionRT = factory.CreateRenderTarget(WIDTH, HEIGHT); normal0 = factory.GetTexture2D("wave0", true); normal1 = factory.GetTexture2D("wave1", true); }