protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory ,IContentManager contentManager) { base.LoadContent(GraphicInfo, factory, contentManager); { SimpleModel simpleModel = new SimpleModel(factory, "Model//cenario"); TriangleMeshObject tmesh = new TriangleMeshObject(simpleModel, Vector3.Zero, Matrix.Identity, Vector3.One, MaterialDescription.DefaultBepuMaterial()); ForwardXNABasicShader shader = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default()); ForwardMaterial fmaterial = new ForwardMaterial(shader); IObject obj = new IObject(fmaterial, simpleModel, tmesh); this.World.AddObject(obj); } ///using component Billboard3D Billboard3D = new Billboard3D(factory.GetTexture2D("Textures\\grama1"), new Vector3(100, 20, 100), Vector2.One * 0.2f); BillboardComponent.Billboards.Add(Billboard3D); ///using old mode (IObject billboard) { List<Billboard> poss = new List<Billboard>(); for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { float x, y; x = i * 10; y = j * 10; poss.Add( new Billboard() { Position = new Vector3(x, 50 , y), Scale = Vector2.One * 0.01f, Enabled = true } ); } } CPUBillboardModel bm = new CPUBillboardModel(factory, "Bilbs", "..\\Content\\Textures\\tree", poss.ToArray()); ForwardAlphaTestShader cb = new ForwardAlphaTestShader(128,CompareFunction.GreaterEqual); ForwardMaterial matfor = new ForwardMaterial(cb); matfor.RasterizerState = RasterizerState.CullNone; GhostObject go = new GhostObject(); IObject obj2 = new IObject(matfor, bm, go); this.World.AddObject(obj2); //Text Billboards TextBillboard3D TextBillboard3D = new TextBillboard3D("TEST 123 SPHERICAL", Color.Black, new Vector3(100), 0.5f); sBillboardComponent.Billboards.Add(TextBillboard3D); TextBillboard3D = new TextBillboard3D("TEST 123 Cylinder", Color.Black, new Vector3(200, 50, 200), 0.5f); cBillboardComponent.Billboards.Add(TextBillboard3D); } 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); 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); }