Dynamica Maya plugin changes to take into account scale and pivot point offset

when converting existing objects to convex hull or mesh
One more method added to set spring equilibrium point directly for btGeneric6DofSpringConstraint
This commit is contained in:
rponom
2010-03-03 20:50:38 +00:00
parent 658979c3ac
commit af754373b2
3 changed files with 21 additions and 1 deletions

View File

@@ -458,8 +458,19 @@ proc dynamicaUI_createRigidBody(int $activebody, int $collisionShapeType)
setAttr ($rigidBodyNode + ".mass" ) $mass;
setAttr ($collisionShapeNode + ".type" ) $collisionShapeType;
float $pos[]= `getAttr ($shapeTransforms[0] + ".translate")`;
float $rot[]= `getAttr ($shapeTransforms[0] + ".rotate")`;
float $wmatr[]= `getAttr ($shapeTransforms[0] + ".worldMatrix")`;
// float $pos[]= `getAttr ($shapeTransforms[0] + ".translate")`;
// We need to take into account offset of the pivot point
// so get the final translation directly from world matrix
// also get existing scale
// note that this may not work if scaling coordinate system differs from object's coordinate system
// Bullet does not support that yet
float $pos[];
$pos[0] = $wmatr[12];
$pos[1] = $wmatr[13];
$pos[2] = $wmatr[14];
float $scale[] = `getAttr ($shapeTransforms[0] + ".scale")`;
setAttr ($rigidBodyTransforms[0] + ".translate") -type double3 $pos[0] $pos[1] $pos[2];
setAttr ($rigidBodyNode + ".initialPosition") -type double3 $pos[0] $pos[1] $pos[2];
@@ -467,6 +478,9 @@ proc dynamicaUI_createRigidBody(int $activebody, int $collisionShapeType)
setAttr ($rigidBodyTransforms[0] + ".rotate") -type double3 $rot[0] $rot[1] $rot[2];
setAttr ($rigidBodyNode + ".initialRotation") -type double3 $rot[0] $rot[1] $rot[2];
setAttr ($rigidBodyTransforms[0] + ".scale") -type double3 $scale[0] $scale[1] $scale[2];
setAttr ($collisionShapeNode + ".scale" ) -type double3 $scale[0] $scale[1] $scale[2];
$newBodies[$i] = $rigidBodyTransforms[0];
}
else

View File

@@ -92,6 +92,11 @@ void btGeneric6DofSpringConstraint::setEquilibriumPoint(int index)
}
}
void btGeneric6DofSpringConstraint::setEquilibriumPoint(int index, btScalar val)
{
btAssert((index >= 0) && (index < 6));
m_equilibriumPoint[index] = val;
}
void btGeneric6DofSpringConstraint::internalUpdateSprings(btConstraintInfo2* info)

View File

@@ -47,6 +47,7 @@ public:
void setDamping(int index, btScalar damping);
void setEquilibriumPoint(); // set the current constraint position/orientation as an equilibrium point for all DOF
void setEquilibriumPoint(int index); // set the current constraint position/orientation as an equilibrium point for given DOF
void setEquilibriumPoint(int index, btScalar val);
virtual void getInfo2 (btConstraintInfo2* info);
};