aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin/BSAPIXNA.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSAPIXNA.cs')
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSAPIXNA.cs231
1 files changed, 188 insertions, 43 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSAPIXNA.cs b/OpenSim/Region/Physics/BulletSPlugin/BSAPIXNA.cs
index 39e62dd..6fc10e9 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSAPIXNA.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSAPIXNA.cs
@@ -559,8 +559,9 @@ private sealed class BulletConstraintXNA : BulletConstraint
559 } 559 }
560 560
561 561
562 //BulletSimAPI.Create6DofConstraint(m_world.ptr, m_body1.ptr, m_body2.ptr,frame1, frame1rot,frame2, frame2rot,useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies)); 562 public override BulletConstraint Create6DofConstraint(BulletWorld pWorld, BulletBody pBody1, BulletBody pBody2,
563 public override BulletConstraint Create6DofConstraint(BulletWorld pWorld, BulletBody pBody1, BulletBody pBody2, Vector3 pframe1, Quaternion pframe1rot, Vector3 pframe2, Quaternion pframe2rot, bool puseLinearReferenceFrameA, bool pdisableCollisionsBetweenLinkedBodies) 563 Vector3 pframe1, Quaternion pframe1rot, Vector3 pframe2, Quaternion pframe2rot,
564 bool puseLinearReferenceFrameA, bool pdisableCollisionsBetweenLinkedBodies)
564 565
565 { 566 {
566 DiscreteDynamicsWorld world = (pWorld as BulletWorldXNA).world; 567 DiscreteDynamicsWorld world = (pWorld as BulletWorldXNA).world;
@@ -584,7 +585,24 @@ private sealed class BulletConstraintXNA : BulletConstraint
584 return new BulletConstraintXNA(consttr); 585 return new BulletConstraintXNA(consttr);
585 } 586 }
586 587
587 588 public override BulletConstraint Create6DofConstraintFixed(BulletWorld pWorld, BulletBody pBody1,
589 Vector3 pframe1, Quaternion pframe1rot,
590 bool pUseLinearReferenceFrameB, bool pdisableCollisionsBetweenLinkedBodies)
591 {
592 DiscreteDynamicsWorld world = (pWorld as BulletWorldXNA).world;
593 RigidBody body1 = (pBody1 as BulletBodyXNA).rigidBody;
594 IndexedVector3 frame1v = new IndexedVector3(pframe1.X, pframe1.Y, pframe1.Z);
595 IndexedQuaternion frame1rot = new IndexedQuaternion(pframe1rot.X, pframe1rot.Y, pframe1rot.Z, pframe1rot.W);
596 IndexedMatrix frame1 = IndexedMatrix.CreateFromQuaternion(frame1rot);
597 frame1._origin = frame1v;
598
599 Generic6DofConstraint consttr = new Generic6DofConstraint(body1, ref frame1, pUseLinearReferenceFrameB);
600 consttr.CalculateTransforms();
601 world.AddConstraint(consttr,pdisableCollisionsBetweenLinkedBodies);
602
603 return new BulletConstraintXNA(consttr);
604 }
605
588 /// <summary> 606 /// <summary>
589 /// 607 ///
590 /// </summary> 608 /// </summary>
@@ -1133,8 +1151,8 @@ private sealed class BulletConstraintXNA : BulletConstraint
1133 p.numberOfSolverIterations = o[0].numberOfSolverIterations; 1151 p.numberOfSolverIterations = o[0].numberOfSolverIterations;
1134 1152
1135 p.linksetImplementation = BSParam.LinksetImplementation; 1153 p.linksetImplementation = BSParam.LinksetImplementation;
1136 p.linkConstraintUseFrameOffset = BSParam.LinkConstraintUseFrameOffset; 1154 p.linkConstraintUseFrameOffset = BSParam.NumericBool(BSParam.LinkConstraintUseFrameOffset);
1137 p.linkConstraintEnableTransMotor = BSParam.LinkConstraintEnableTransMotor; 1155 p.linkConstraintEnableTransMotor = BSParam.NumericBool(BSParam.LinkConstraintEnableTransMotor);
1138 p.linkConstraintTransMotorMaxVel = BSParam.LinkConstraintTransMotorMaxVel; 1156 p.linkConstraintTransMotorMaxVel = BSParam.LinkConstraintTransMotorMaxVel;
1139 p.linkConstraintTransMotorMaxForce = BSParam.LinkConstraintTransMotorMaxForce; 1157 p.linkConstraintTransMotorMaxForce = BSParam.LinkConstraintTransMotorMaxForce;
1140 p.linkConstraintERP = BSParam.LinkConstraintERP; 1158 p.linkConstraintERP = BSParam.LinkConstraintERP;
@@ -1443,129 +1461,130 @@ private sealed class BulletConstraintXNA : BulletConstraint
1443 1461
1444 public BSPhysicsShapeType BSShapeTypeFromBroadPhaseNativeType(BroadphaseNativeTypes pin) 1462 public BSPhysicsShapeType BSShapeTypeFromBroadPhaseNativeType(BroadphaseNativeTypes pin)
1445 { 1463 {
1464 BSPhysicsShapeType ret = BSPhysicsShapeType.SHAPE_UNKNOWN;
1446 switch (pin) 1465 switch (pin)
1447 { 1466 {
1448 case BroadphaseNativeTypes.BOX_SHAPE_PROXYTYPE: 1467 case BroadphaseNativeTypes.BOX_SHAPE_PROXYTYPE:
1449 return BSPhysicsShapeType.SHAPE_BOX; 1468 ret = BSPhysicsShapeType.SHAPE_BOX;
1450 break; 1469 break;
1451 case BroadphaseNativeTypes.TRIANGLE_SHAPE_PROXYTYPE: 1470 case BroadphaseNativeTypes.TRIANGLE_SHAPE_PROXYTYPE:
1452 return BSPhysicsShapeType.SHAPE_UNKNOWN; 1471 ret = BSPhysicsShapeType.SHAPE_UNKNOWN;
1453 break; 1472 break;
1454 1473
1455 case BroadphaseNativeTypes.TETRAHEDRAL_SHAPE_PROXYTYPE: 1474 case BroadphaseNativeTypes.TETRAHEDRAL_SHAPE_PROXYTYPE:
1456 return BSPhysicsShapeType.SHAPE_UNKNOWN; 1475 ret = BSPhysicsShapeType.SHAPE_UNKNOWN;
1457 break; 1476 break;
1458 case BroadphaseNativeTypes.CONVEX_TRIANGLEMESH_SHAPE_PROXYTYPE: 1477 case BroadphaseNativeTypes.CONVEX_TRIANGLEMESH_SHAPE_PROXYTYPE:
1459 return BSPhysicsShapeType.SHAPE_MESH; 1478 ret = BSPhysicsShapeType.SHAPE_MESH;
1460 break; 1479 break;
1461 case BroadphaseNativeTypes.CONVEX_HULL_SHAPE_PROXYTYPE: 1480 case BroadphaseNativeTypes.CONVEX_HULL_SHAPE_PROXYTYPE:
1462 return BSPhysicsShapeType.SHAPE_HULL; 1481 ret = BSPhysicsShapeType.SHAPE_HULL;
1463 break; 1482 break;
1464 case BroadphaseNativeTypes.CONVEX_POINT_CLOUD_SHAPE_PROXYTYPE: 1483 case BroadphaseNativeTypes.CONVEX_POINT_CLOUD_SHAPE_PROXYTYPE:
1465 return BSPhysicsShapeType.SHAPE_UNKNOWN; 1484 ret = BSPhysicsShapeType.SHAPE_UNKNOWN;
1466 break; 1485 break;
1467 case BroadphaseNativeTypes.CUSTOM_POLYHEDRAL_SHAPE_TYPE: 1486 case BroadphaseNativeTypes.CUSTOM_POLYHEDRAL_SHAPE_TYPE:
1468 return BSPhysicsShapeType.SHAPE_UNKNOWN; 1487 ret = BSPhysicsShapeType.SHAPE_UNKNOWN;
1469 break; 1488 break;
1470 //implicit convex shapes 1489 //implicit convex shapes
1471 case BroadphaseNativeTypes.IMPLICIT_CONVEX_SHAPES_START_HERE: 1490 case BroadphaseNativeTypes.IMPLICIT_CONVEX_SHAPES_START_HERE:
1472 return BSPhysicsShapeType.SHAPE_UNKNOWN; 1491 ret = BSPhysicsShapeType.SHAPE_UNKNOWN;
1473 break; 1492 break;
1474 case BroadphaseNativeTypes.SPHERE_SHAPE_PROXYTYPE: 1493 case BroadphaseNativeTypes.SPHERE_SHAPE_PROXYTYPE:
1475 return BSPhysicsShapeType.SHAPE_SPHERE; 1494 ret = BSPhysicsShapeType.SHAPE_SPHERE;
1476 break; 1495 break;
1477 case BroadphaseNativeTypes.MULTI_SPHERE_SHAPE_PROXYTYPE: 1496 case BroadphaseNativeTypes.MULTI_SPHERE_SHAPE_PROXYTYPE:
1478 return BSPhysicsShapeType.SHAPE_UNKNOWN; 1497 ret = BSPhysicsShapeType.SHAPE_UNKNOWN;
1479 break; 1498 break;
1480 case BroadphaseNativeTypes.CAPSULE_SHAPE_PROXYTYPE: 1499 case BroadphaseNativeTypes.CAPSULE_SHAPE_PROXYTYPE:
1481 return BSPhysicsShapeType.SHAPE_CAPSULE; 1500 ret = BSPhysicsShapeType.SHAPE_CAPSULE;
1482 break; 1501 break;
1483 case BroadphaseNativeTypes.CONE_SHAPE_PROXYTYPE: 1502 case BroadphaseNativeTypes.CONE_SHAPE_PROXYTYPE:
1484 return BSPhysicsShapeType.SHAPE_CONE; 1503 ret = BSPhysicsShapeType.SHAPE_CONE;
1485 break; 1504 break;
1486 case BroadphaseNativeTypes.CONVEX_SHAPE_PROXYTYPE: 1505 case BroadphaseNativeTypes.CONVEX_SHAPE_PROXYTYPE:
1487 return BSPhysicsShapeType.SHAPE_UNKNOWN; 1506 ret = BSPhysicsShapeType.SHAPE_UNKNOWN;
1488 break; 1507 break;
1489 case BroadphaseNativeTypes.CYLINDER_SHAPE_PROXYTYPE: 1508 case BroadphaseNativeTypes.CYLINDER_SHAPE_PROXYTYPE:
1490 return BSPhysicsShapeType.SHAPE_CYLINDER; 1509 ret = BSPhysicsShapeType.SHAPE_CYLINDER;
1491 break; 1510 break;
1492 case BroadphaseNativeTypes.UNIFORM_SCALING_SHAPE_PROXYTYPE: 1511 case BroadphaseNativeTypes.UNIFORM_SCALING_SHAPE_PROXYTYPE:
1493 return BSPhysicsShapeType.SHAPE_UNKNOWN; 1512 ret = BSPhysicsShapeType.SHAPE_UNKNOWN;
1494 break; 1513 break;
1495 case BroadphaseNativeTypes.MINKOWSKI_SUM_SHAPE_PROXYTYPE: 1514 case BroadphaseNativeTypes.MINKOWSKI_SUM_SHAPE_PROXYTYPE:
1496 return BSPhysicsShapeType.SHAPE_UNKNOWN; 1515 ret = BSPhysicsShapeType.SHAPE_UNKNOWN;
1497 break; 1516 break;
1498 case BroadphaseNativeTypes.MINKOWSKI_DIFFERENCE_SHAPE_PROXYTYPE: 1517 case BroadphaseNativeTypes.MINKOWSKI_DIFFERENCE_SHAPE_PROXYTYPE:
1499 return BSPhysicsShapeType.SHAPE_UNKNOWN; 1518 ret = BSPhysicsShapeType.SHAPE_UNKNOWN;
1500 break; 1519 break;
1501 case BroadphaseNativeTypes.BOX_2D_SHAPE_PROXYTYPE: 1520 case BroadphaseNativeTypes.BOX_2D_SHAPE_PROXYTYPE:
1502 return BSPhysicsShapeType.SHAPE_UNKNOWN; 1521 ret = BSPhysicsShapeType.SHAPE_UNKNOWN;
1503 break; 1522 break;
1504 case BroadphaseNativeTypes.CONVEX_2D_SHAPE_PROXYTYPE: 1523 case BroadphaseNativeTypes.CONVEX_2D_SHAPE_PROXYTYPE:
1505 return BSPhysicsShapeType.SHAPE_UNKNOWN; 1524 ret = BSPhysicsShapeType.SHAPE_UNKNOWN;
1506 break; 1525 break;
1507 case BroadphaseNativeTypes.CUSTOM_CONVEX_SHAPE_TYPE: 1526 case BroadphaseNativeTypes.CUSTOM_CONVEX_SHAPE_TYPE:
1508 return BSPhysicsShapeType.SHAPE_UNKNOWN; 1527 ret = BSPhysicsShapeType.SHAPE_UNKNOWN;
1509 break; 1528 break;
1510 //concave shape 1529 //concave shape
1511 case BroadphaseNativeTypes.CONCAVE_SHAPES_START_HERE: 1530 case BroadphaseNativeTypes.CONCAVE_SHAPES_START_HERE:
1512 return BSPhysicsShapeType.SHAPE_UNKNOWN; 1531 ret = BSPhysicsShapeType.SHAPE_UNKNOWN;
1513 break; 1532 break;
1514 //keep all the convex shapetype below here, for the check IsConvexShape in broadphase proxy! 1533 //keep all the convex shapetype below here, for the check IsConvexShape in broadphase proxy!
1515 case BroadphaseNativeTypes.TRIANGLE_MESH_SHAPE_PROXYTYPE: 1534 case BroadphaseNativeTypes.TRIANGLE_MESH_SHAPE_PROXYTYPE:
1516 return BSPhysicsShapeType.SHAPE_MESH; 1535 ret = BSPhysicsShapeType.SHAPE_MESH;
1517 break; 1536 break;
1518 case BroadphaseNativeTypes.SCALED_TRIANGLE_MESH_SHAPE_PROXYTYPE: 1537 case BroadphaseNativeTypes.SCALED_TRIANGLE_MESH_SHAPE_PROXYTYPE:
1519 return BSPhysicsShapeType.SHAPE_MESH; 1538 ret = BSPhysicsShapeType.SHAPE_MESH;
1520 break; 1539 break;
1521 ///used for demo integration FAST/Swift collision library and Bullet 1540 ///used for demo integration FAST/Swift collision library and Bullet
1522 case BroadphaseNativeTypes.FAST_CONCAVE_MESH_PROXYTYPE: 1541 case BroadphaseNativeTypes.FAST_CONCAVE_MESH_PROXYTYPE:
1523 return BSPhysicsShapeType.SHAPE_MESH; 1542 ret = BSPhysicsShapeType.SHAPE_MESH;
1524 break; 1543 break;
1525 //terrain 1544 //terrain
1526 case BroadphaseNativeTypes.TERRAIN_SHAPE_PROXYTYPE: 1545 case BroadphaseNativeTypes.TERRAIN_SHAPE_PROXYTYPE:
1527 return BSPhysicsShapeType.SHAPE_HEIGHTMAP; 1546 ret = BSPhysicsShapeType.SHAPE_HEIGHTMAP;
1528 break; 1547 break;
1529 ///Used for GIMPACT Trimesh integration 1548 ///Used for GIMPACT Trimesh integration
1530 case BroadphaseNativeTypes.GIMPACT_SHAPE_PROXYTYPE: 1549 case BroadphaseNativeTypes.GIMPACT_SHAPE_PROXYTYPE:
1531 return BSPhysicsShapeType.SHAPE_MESH; 1550 ret = BSPhysicsShapeType.SHAPE_MESH;
1532 break; 1551 break;
1533 ///Multimaterial mesh 1552 ///Multimaterial mesh
1534 case BroadphaseNativeTypes.MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE: 1553 case BroadphaseNativeTypes.MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE:
1535 return BSPhysicsShapeType.SHAPE_MESH; 1554 ret = BSPhysicsShapeType.SHAPE_MESH;
1536 break; 1555 break;
1537 1556
1538 case BroadphaseNativeTypes.EMPTY_SHAPE_PROXYTYPE: 1557 case BroadphaseNativeTypes.EMPTY_SHAPE_PROXYTYPE:
1539 return BSPhysicsShapeType.SHAPE_UNKNOWN; 1558 ret = BSPhysicsShapeType.SHAPE_UNKNOWN;
1540 break; 1559 break;
1541 case BroadphaseNativeTypes.STATIC_PLANE_PROXYTYPE: 1560 case BroadphaseNativeTypes.STATIC_PLANE_PROXYTYPE:
1542 return BSPhysicsShapeType.SHAPE_GROUNDPLANE; 1561 ret = BSPhysicsShapeType.SHAPE_GROUNDPLANE;
1543 break; 1562 break;
1544 case BroadphaseNativeTypes.CUSTOM_CONCAVE_SHAPE_TYPE: 1563 case BroadphaseNativeTypes.CUSTOM_CONCAVE_SHAPE_TYPE:
1545 return BSPhysicsShapeType.SHAPE_UNKNOWN; 1564 ret = BSPhysicsShapeType.SHAPE_UNKNOWN;
1546 break; 1565 break;
1547 case BroadphaseNativeTypes.CONCAVE_SHAPES_END_HERE: 1566 case BroadphaseNativeTypes.CONCAVE_SHAPES_END_HERE:
1548 return BSPhysicsShapeType.SHAPE_UNKNOWN; 1567 ret = BSPhysicsShapeType.SHAPE_UNKNOWN;
1549 break; 1568 break;
1550 1569
1551 case BroadphaseNativeTypes.COMPOUND_SHAPE_PROXYTYPE: 1570 case BroadphaseNativeTypes.COMPOUND_SHAPE_PROXYTYPE:
1552 return BSPhysicsShapeType.SHAPE_COMPOUND; 1571 ret = BSPhysicsShapeType.SHAPE_COMPOUND;
1553 break; 1572 break;
1554 1573
1555 case BroadphaseNativeTypes.SOFTBODY_SHAPE_PROXYTYPE: 1574 case BroadphaseNativeTypes.SOFTBODY_SHAPE_PROXYTYPE:
1556 return BSPhysicsShapeType.SHAPE_MESH; 1575 ret = BSPhysicsShapeType.SHAPE_MESH;
1557 break; 1576 break;
1558 case BroadphaseNativeTypes.HFFLUID_SHAPE_PROXYTYPE: 1577 case BroadphaseNativeTypes.HFFLUID_SHAPE_PROXYTYPE:
1559 return BSPhysicsShapeType.SHAPE_UNKNOWN; 1578 ret = BSPhysicsShapeType.SHAPE_UNKNOWN;
1560 break; 1579 break;
1561 case BroadphaseNativeTypes.HFFLUID_BUOYANT_CONVEX_SHAPE_PROXYTYPE: 1580 case BroadphaseNativeTypes.HFFLUID_BUOYANT_CONVEX_SHAPE_PROXYTYPE:
1562 return BSPhysicsShapeType.SHAPE_UNKNOWN; 1581 ret = BSPhysicsShapeType.SHAPE_UNKNOWN;
1563 break; 1582 break;
1564 case BroadphaseNativeTypes.INVALID_SHAPE_PROXYTYPE: 1583 case BroadphaseNativeTypes.INVALID_SHAPE_PROXYTYPE:
1565 return BSPhysicsShapeType.SHAPE_UNKNOWN; 1584 ret = BSPhysicsShapeType.SHAPE_UNKNOWN;
1566 break; 1585 break;
1567 } 1586 }
1568 return BSPhysicsShapeType.SHAPE_UNKNOWN; 1587 return ret;
1569 } 1588 }
1570 1589
1571 public override void RemoveChildShapeFromCompoundShape(BulletShape cShape, BulletShape removeShape) { /* TODO */ } 1590 public override void RemoveChildShapeFromCompoundShape(BulletShape cShape, BulletShape removeShape) { /* TODO */ }
@@ -1579,7 +1598,39 @@ private sealed class BulletConstraintXNA : BulletConstraint
1579 return new BulletShapeXNA(m_planeshape, BSPhysicsShapeType.SHAPE_GROUNDPLANE); 1598 return new BulletShapeXNA(m_planeshape, BSPhysicsShapeType.SHAPE_GROUNDPLANE);
1580 } 1599 }
1581 1600
1582 public override BulletConstraint CreateHingeConstraint(BulletWorld pWorld, BulletBody pBody1, BulletBody pBody2, Vector3 ppivotInA, Vector3 ppivotInB, Vector3 paxisInA, Vector3 paxisInB, bool puseLinearReferenceFrameA, bool pdisableCollisionsBetweenLinkedBodies) 1601 public override BulletConstraint Create6DofSpringConstraint(BulletWorld pWorld, BulletBody pBody1, BulletBody pBody2,
1602 Vector3 pframe1, Quaternion pframe1rot, Vector3 pframe2, Quaternion pframe2rot,
1603 bool puseLinearReferenceFrameA, bool pdisableCollisionsBetweenLinkedBodies)
1604
1605 {
1606 Generic6DofSpringConstraint constrain = null;
1607 DiscreteDynamicsWorld world = (pWorld as BulletWorldXNA).world;
1608 RigidBody body1 = (pBody1 as BulletBodyXNA).rigidBody;
1609 RigidBody body2 = (pBody2 as BulletBodyXNA).rigidBody;
1610 if (body1 != null && body2 != null)
1611 {
1612 IndexedVector3 frame1v = new IndexedVector3(pframe1.X, pframe1.Y, pframe1.Z);
1613 IndexedQuaternion frame1rot = new IndexedQuaternion(pframe1rot.X, pframe1rot.Y, pframe1rot.Z, pframe1rot.W);
1614 IndexedMatrix frame1 = IndexedMatrix.CreateFromQuaternion(frame1rot);
1615 frame1._origin = frame1v;
1616
1617 IndexedVector3 frame2v = new IndexedVector3(pframe2.X, pframe2.Y, pframe2.Z);
1618 IndexedQuaternion frame2rot = new IndexedQuaternion(pframe2rot.X, pframe2rot.Y, pframe2rot.Z, pframe2rot.W);
1619 IndexedMatrix frame2 = IndexedMatrix.CreateFromQuaternion(frame2rot);
1620 frame2._origin = frame1v;
1621
1622 constrain = new Generic6DofSpringConstraint(body1, body2, ref frame1, ref frame2, puseLinearReferenceFrameA);
1623 world.AddConstraint(constrain, pdisableCollisionsBetweenLinkedBodies);
1624
1625 constrain.CalculateTransforms();
1626 }
1627
1628 return new BulletConstraintXNA(constrain);
1629 }
1630
1631 public override BulletConstraint CreateHingeConstraint(BulletWorld pWorld, BulletBody pBody1, BulletBody pBody2,
1632 Vector3 ppivotInA, Vector3 ppivotInB, Vector3 paxisInA, Vector3 paxisInB,
1633 bool puseLinearReferenceFrameA, bool pdisableCollisionsBetweenLinkedBodies)
1583 { 1634 {
1584 HingeConstraint constrain = null; 1635 HingeConstraint constrain = null;
1585 DiscreteDynamicsWorld world = (pWorld as BulletWorldXNA).world; 1636 DiscreteDynamicsWorld world = (pWorld as BulletWorldXNA).world;
@@ -1591,6 +1642,100 @@ private sealed class BulletConstraintXNA : BulletConstraint
1591 IndexedVector3 pivotInB = new IndexedVector3(ppivotInB.X, ppivotInB.Y, ppivotInB.Z); 1642 IndexedVector3 pivotInB = new IndexedVector3(ppivotInB.X, ppivotInB.Y, ppivotInB.Z);
1592 IndexedVector3 axisInA = new IndexedVector3(paxisInA.X, paxisInA.Y, paxisInA.Z); 1643 IndexedVector3 axisInA = new IndexedVector3(paxisInA.X, paxisInA.Y, paxisInA.Z);
1593 IndexedVector3 axisInB = new IndexedVector3(paxisInB.X, paxisInB.Y, paxisInB.Z); 1644 IndexedVector3 axisInB = new IndexedVector3(paxisInB.X, paxisInB.Y, paxisInB.Z);
1645 constrain = new HingeConstraint(rb1, rb2, ref pivotInA, ref pivotInB, ref axisInA, ref axisInB, puseLinearReferenceFrameA);
1646 world.AddConstraint(constrain, pdisableCollisionsBetweenLinkedBodies);
1647 }
1648 return new BulletConstraintXNA(constrain);
1649 }
1650
1651 public override BulletConstraint CreateSliderConstraint(BulletWorld pWorld, BulletBody pBody1, BulletBody pBody2,
1652 Vector3 pframe1, Quaternion pframe1rot,
1653 Vector3 pframe2, Quaternion pframe2rot,
1654 bool puseLinearReferenceFrameA, bool pdisableCollisionsBetweenLinkedBodies)
1655 {
1656 SliderConstraint constrain = null;
1657 DiscreteDynamicsWorld world = (pWorld as BulletWorldXNA).world;
1658 RigidBody rb1 = (pBody1 as BulletBodyXNA).rigidBody;
1659 RigidBody rb2 = (pBody2 as BulletBodyXNA).rigidBody;
1660 if (rb1 != null && rb2 != null)
1661 {
1662 IndexedVector3 frame1v = new IndexedVector3(pframe1.X, pframe1.Y, pframe1.Z);
1663 IndexedQuaternion frame1rot = new IndexedQuaternion(pframe1rot.X, pframe1rot.Y, pframe1rot.Z, pframe1rot.W);
1664 IndexedMatrix frame1 = IndexedMatrix.CreateFromQuaternion(frame1rot);
1665 frame1._origin = frame1v;
1666
1667 IndexedVector3 frame2v = new IndexedVector3(pframe2.X, pframe2.Y, pframe2.Z);
1668 IndexedQuaternion frame2rot = new IndexedQuaternion(pframe2rot.X, pframe2rot.Y, pframe2rot.Z, pframe2rot.W);
1669 IndexedMatrix frame2 = IndexedMatrix.CreateFromQuaternion(frame2rot);
1670 frame2._origin = frame1v;
1671
1672 constrain = new SliderConstraint(rb1, rb2, ref frame1, ref frame2, puseLinearReferenceFrameA);
1673 world.AddConstraint(constrain, pdisableCollisionsBetweenLinkedBodies);
1674 }
1675 return new BulletConstraintXNA(constrain);
1676 }
1677
1678 public override BulletConstraint CreateConeTwistConstraint(BulletWorld pWorld, BulletBody pBody1, BulletBody pBody2,
1679 Vector3 pframe1, Quaternion pframe1rot,
1680 Vector3 pframe2, Quaternion pframe2rot,
1681 bool pdisableCollisionsBetweenLinkedBodies)
1682 {
1683 ConeTwistConstraint constrain = null;
1684 DiscreteDynamicsWorld world = (pWorld as BulletWorldXNA).world;
1685 RigidBody rb1 = (pBody1 as BulletBodyXNA).rigidBody;
1686 RigidBody rb2 = (pBody2 as BulletBodyXNA).rigidBody;
1687 if (rb1 != null && rb2 != null)
1688 {
1689 IndexedVector3 frame1v = new IndexedVector3(pframe1.X, pframe1.Y, pframe1.Z);
1690 IndexedQuaternion frame1rot = new IndexedQuaternion(pframe1rot.X, pframe1rot.Y, pframe1rot.Z, pframe1rot.W);
1691 IndexedMatrix frame1 = IndexedMatrix.CreateFromQuaternion(frame1rot);
1692 frame1._origin = frame1v;
1693
1694 IndexedVector3 frame2v = new IndexedVector3(pframe2.X, pframe2.Y, pframe2.Z);
1695 IndexedQuaternion frame2rot = new IndexedQuaternion(pframe2rot.X, pframe2rot.Y, pframe2rot.Z, pframe2rot.W);
1696 IndexedMatrix frame2 = IndexedMatrix.CreateFromQuaternion(frame2rot);
1697 frame2._origin = frame1v;
1698
1699 constrain = new ConeTwistConstraint(rb1, rb2, ref frame1, ref frame2);
1700 world.AddConstraint(constrain, pdisableCollisionsBetweenLinkedBodies);
1701 }
1702 return new BulletConstraintXNA(constrain);
1703 }
1704
1705 public override BulletConstraint CreateGearConstraint(BulletWorld pWorld, BulletBody pBody1, BulletBody pBody2,
1706 Vector3 paxisInA, Vector3 paxisInB,
1707 float pratio, bool pdisableCollisionsBetweenLinkedBodies)
1708 {
1709 Generic6DofConstraint constrain = null;
1710 /* BulletXNA does not have a gear constraint
1711 GearConstraint constrain = null;
1712 DiscreteDynamicsWorld world = (pWorld as BulletWorldXNA).world;
1713 RigidBody rb1 = (pBody1 as BulletBodyXNA).rigidBody;
1714 RigidBody rb2 = (pBody2 as BulletBodyXNA).rigidBody;
1715 if (rb1 != null && rb2 != null)
1716 {
1717 IndexedVector3 axis1 = new IndexedVector3(paxisInA.X, paxisInA.Y, paxisInA.Z);
1718 IndexedVector3 axis2 = new IndexedVector3(paxisInB.X, paxisInB.Y, paxisInB.Z);
1719 constrain = new GearConstraint(rb1, rb2, ref axis1, ref axis2, pratio);
1720 world.AddConstraint(constrain, pdisableCollisionsBetweenLinkedBodies);
1721 }
1722 */
1723 return new BulletConstraintXNA(constrain);
1724 }
1725
1726 public override BulletConstraint CreatePoint2PointConstraint(BulletWorld pWorld, BulletBody pBody1, BulletBody pBody2,
1727 Vector3 ppivotInA, Vector3 ppivotInB,
1728 bool pdisableCollisionsBetweenLinkedBodies)
1729 {
1730 Point2PointConstraint constrain = null;
1731 DiscreteDynamicsWorld world = (pWorld as BulletWorldXNA).world;
1732 RigidBody rb1 = (pBody1 as BulletBodyXNA).rigidBody;
1733 RigidBody rb2 = (pBody2 as BulletBodyXNA).rigidBody;
1734 if (rb1 != null && rb2 != null)
1735 {
1736 IndexedVector3 pivotInA = new IndexedVector3(ppivotInA.X, ppivotInA.Y, ppivotInA.Z);
1737 IndexedVector3 pivotInB = new IndexedVector3(ppivotInB.X, ppivotInB.Y, ppivotInB.Z);
1738 constrain = new Point2PointConstraint(rb1, rb2, ref pivotInA, ref pivotInB);
1594 world.AddConstraint(constrain, pdisableCollisionsBetweenLinkedBodies); 1739 world.AddConstraint(constrain, pdisableCollisionsBetweenLinkedBodies);
1595 } 1740 }
1596 return new BulletConstraintXNA(constrain); 1741 return new BulletConstraintXNA(constrain);