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)); }
void marine_OnUpdate(IObject obj, GameTime gt, ICamera cam) { PhysxBoxCharacterObject PhysxBoxCharacterObject = obj.PhysicObject as PhysxBoxCharacterObject; KeyboardState keyboardInput = Keyboard.GetState(); if (keyboardInput.IsKeyDown(Keys.Y)) { PhysxBoxCharacterObject.Controller.Move(PhysxBoxCharacterObject.FaceVector.AsPhysX()); } if (keyboardInput.IsKeyDown(Keys.H)) { PhysxBoxCharacterObject.Controller.Move(-PhysxBoxCharacterObject.FaceVector.AsPhysX()); } if (keyboardInput.IsKeyDown(Keys.J)) { PhysxBoxCharacterObject.RotateYByAngleDegrees(-1); } if (keyboardInput.IsKeyDown(Keys.G)) { PhysxBoxCharacterObject.RotateYByAngleDegrees(1); } }