//BuildCapsuleShape2(physicsScene.World.ptr, 1f, 1f, prim.Scale); internal static object BuildCapsuleShape2(object pWorld, float pRadius, float pHeight, Vector3 pScale) { DiscreteDynamicsWorld world = pWorld as DiscreteDynamicsWorld; IndexedVector3 scale = new IndexedVector3(pScale.X, pScale.Y, pScale.Z); CapsuleShapeZ capsuleShapeZ = new CapsuleShapeZ(pRadius, pHeight); capsuleShapeZ.SetMargin(world.WorldSettings.Params.collisionMargin); capsuleShapeZ.SetLocalScaling(ref scale); return capsuleShapeZ; }
//BuildCapsuleShape(physicsScene.World.ptr, 1f, 1f, prim.Scale); public override BulletShape BuildCapsuleShape(BulletWorld pWorld, float pRadius, float pHeight, Vector3 pScale) { DiscreteDynamicsWorld world = (pWorld as BulletWorldXNA).world; IndexedVector3 scale = new IndexedVector3(pScale.X, pScale.Y, pScale.Z); CapsuleShapeZ capsuleShapeZ = new CapsuleShapeZ(pRadius, pHeight); capsuleShapeZ.SetMargin(world.WorldSettings.Params.collisionMargin); capsuleShapeZ.SetLocalScaling(ref scale); return new BulletShapeXNA(capsuleShapeZ, BSPhysicsShapeType.SHAPE_CAPSULE); ; }
private void BuildBoard() { float width = 40; float height = 40; IndexedVector3 boardBackExtents = new IndexedVector3(width,height,2) /2f; IndexedVector3 boardSideExtents = new IndexedVector3(1,height,2) /2f; IndexedVector3 boardBarExtents = new IndexedVector3(width,1,2)/2f; IndexedVector3 pinExtent = new IndexedVector3(0.5f,1f,2f); IndexedVector3 boardCenter = new IndexedVector3(0,0,0); // build frame.objects BoxShape boardBack = new BoxShape(boardBackExtents); BoxShape boardSide = new BoxShape(boardSideExtents); BoxShape boardBar = new BoxShape(boardBarExtents); StaticPlaneShape boardFront = new StaticPlaneShape(new IndexedVector3(0,0,-1),-(boardBackExtents.Z+boardSideExtents.Z)); CollisionShape pinShape = new CapsuleShapeZ(pinExtent.Y,pinExtent.Z); //pinShape = new BoxShape(pinExtent); //pinShape = new SphereShape(pinExtent.Y); m_cameraUp = Vector3.Up; // now RB's Matrix m = Matrix.Identity; IndexedMatrix trans = m; trans._origin = boardCenter; float mass = 0f; //LocalCreateRigidBody(mass,trans,boardBack); //LocalCreateRigidBody(mass, trans, boardFront); IndexedVector3 leftSide = new IndexedVector3(boardCenter.X - boardBackExtents.X + boardSideExtents.X, boardCenter.Y, boardCenter.Z + boardSideExtents.Z); IndexedVector3 rightSide = new IndexedVector3(boardCenter.X + boardBackExtents.X - boardSideExtents.X, boardCenter.Y, boardCenter.Z + boardSideExtents.Z); IndexedVector3 topBar = new IndexedVector3(boardCenter.X, boardCenter.Y + boardBackExtents.Y - boardBarExtents.Y, boardCenter.Z + boardSideExtents.Z); IndexedVector3 bottomBar = new IndexedVector3(boardCenter.X, boardCenter.Y - boardBackExtents.Y + boardBarExtents.Y, boardCenter.Z + boardSideExtents.Z); trans._origin = leftSide; LocalCreateRigidBody(mass, trans, boardSide); trans._origin = rightSide; LocalCreateRigidBody(mass, trans, boardSide); trans._origin = topBar; LocalCreateRigidBody(mass, trans, boardBar); trans._origin = bottomBar; LocalCreateRigidBody(mass, trans, boardBar); // now place the pins? (simple offset grid to start) int numPinsX = 8; int numPinsY = 8; // fixme IndexedVector3 pinTopLeft = new IndexedVector3(-boardBackExtents.X + 4, boardBackExtents.Y - 5, boardCenter.Z + boardSideExtents.Z); IndexedVector3 pinSpacer = new IndexedVector3(pinExtent.Y * 4f, -pinExtent.Y * 4f, 0); float ballRadius = 0.9f; float fudge = 3f; m_dropSphereShape = new SphereShape(ballRadius); m_ballDropSpot = new Vector3(1f, pinTopLeft.Y + 1, boardCenter.Z + boardBackExtents.Z+ballRadius); //new SphereShape(0.95f); m_debugDraw.SetDebugMode(m_debugDraw.GetDebugMode() | DebugDrawModes.DBG_DrawAabb); trans._origin = pinTopLeft; LocalCreateRigidBody(mass, trans, pinShape); for (int i = 0; i < numPinsX; ++i) { for (int j = 0; j < numPinsY; ++j) { IndexedVector3 pos = new IndexedVector3(pinSpacer.X * i, (pinSpacer.Y * j), pinSpacer.Z); // stagger rows. if (j % 2 == 1) { pos.X += pinSpacer.X/2f; } trans._origin = pinTopLeft + pos; LocalCreateRigidBody(mass, trans, pinShape); } } }