public static Actor CreateCogHolder(PhysicsEngine engine, out Actor holderActor) { Actor actor; actor = CreateCog(engine.Scene); actor.GlobalPose = Matrix.CreateRotationX(MathHelper.PiOver2); CapsuleShapeDescription capsuleShapeDesc = new CapsuleShapeDescription(1f, 3f); var actorDesc = new ActorDescription(capsuleShapeDesc); var bodyDesc = new BodyDescription(10000); bodyDesc.BodyFlags |= BodyFlag.Kinematic; actorDesc.GlobalPose = Matrix.CreateTranslation(Vector3.Up + new Vector3(0, 0, 0)); actorDesc.BodyDescription = bodyDesc; holderActor = engine.Scene.CreateActor(actorDesc); CylindricalJointDescription jointDesc = new CylindricalJointDescription(); jointDesc.Actor1 = actor; jointDesc.Actor2 = holderActor; jointDesc.SetGlobalAnchor(new Vector3(0, 0, 0)); jointDesc.SetGlobalAxis(Vector3.Up); var joint = engine.Scene.CreateJoint(jointDesc); joint.AddLimitPlane(new LimitPlane(new Plane(Vector3.Up, 0.0f), 0)); joint.AddLimitPlane(new LimitPlane(new Plane(Vector3.Down, 0f), 0)); return(actor); }
public PhysxCylindricalJoint(CylindricalJointDescription CylindricalJointDescription) { this.CylindricalJointDescription = CylindricalJointDescription; }
public void TestTwoCogs() { XNAGame game = new XNAGame(); game.SpectaterCamera.CameraPosition = new Vector3(0, 0, -40); game.SpectaterCamera.FarClip = 10000; PhysicsEngine engine = new PhysicsEngine(); TriangleMesh triangleMesh = null; //game.AddXNAObject(engine); Actor actor = null; Actor holderActor = null; Actor holderActor2 = null; game.InitializeEvent += delegate { engine.Initialize(); PhysicsDebugRendererXNA debugRenderer = new PhysicsDebugRendererXNA(game, engine.Scene); game.AddXNAObject(debugRenderer); actor = CogEngine.CreateCogHolder(engine, out holderActor); Joint joint; CylindricalJointDescription jointDesc; ActorDescription actorDesc; BodyDescription bodyDesc; CapsuleShapeDescription capsuleShapeDesc; Actor mobileCog = CogEngine.CreateCog(engine.Scene); mobileCog.GlobalPose = Matrix.CreateRotationX(MathHelper.PiOver2); capsuleShapeDesc = new CapsuleShapeDescription(4.7f, 3f); actorDesc = new ActorDescription(capsuleShapeDesc); bodyDesc = new BodyDescription(10000); bodyDesc.BodyFlags |= BodyFlag.Kinematic; actorDesc.GlobalPose = Matrix.CreateTranslation(Vector3.Up + new Vector3(0, 0, 0)); actorDesc.BodyDescription = bodyDesc; holderActor2 = engine.Scene.CreateActor(actorDesc); jointDesc = new CylindricalJointDescription(); jointDesc.Actor1 = mobileCog; jointDesc.Actor2 = holderActor2; jointDesc.SetGlobalAnchor(new Vector3(0, 0, 0)); jointDesc.SetGlobalAxis(Vector3.Up); joint = engine.Scene.CreateJoint(jointDesc); joint.AddLimitPlane(new LimitPlane(new Plane(Vector3.Up, 1), 0)); }; game.UpdateEvent += delegate { if (game.Keyboard.IsKeyPressed(Microsoft.Xna.Framework.Input.Keys.F)) { var bol = PhysicsHelper.CreateDynamicSphereActor(engine.Scene, 1, 1); bol.GlobalPosition = game.SpectaterCamera.CameraPosition + game.SpectaterCamera.CameraDirection * 5; bol.LinearVelocity = game.SpectaterCamera.CameraDirection * 5; } Plane p = new Plane(Vector3.Up, 0); var ray = game.GetWereldViewRay(new Vector2(game.Window.ClientBounds.Width * 0.5f, game.Window.ClientBounds.Height * 0.5f)); float?dist = ray.Intersects(p); if (dist.HasValue && game.Keyboard.IsKeyDown(Keys.C)) { //mobileCog.GlobalPosition = ray.Position + ray.Direction * dist.Value + Vector3.Up; holderActor2.MoveGlobalPositionTo(ray.Position + ray.Direction * dist.Value + Vector3.Up); } if (game.Keyboard.IsKeyDown(Keys.R)) { CogEngine.temp(game, actor); /*mobileCog.Dispose(); * mobileCog = CreateCog(triangleMesh, engine.Scene);*/ } engine.Update(game.Elapsed); }; game.Run(); engine.Dispose(); }
public PhysxCylindricalJoint(CylindricalJointDescription CylindricalJointDescription) { this.CylindricalJointDescription = CylindricalJointDescription; }