ConeTwistConstraint constructor
ConeTwistConstraint(})
Implementation
ConeTwistConstraint(
Body bodyA,
Body bodyB,
{
Vec3? pivotA,
Vec3? pivotB,
Vec3? axisA,
Vec3? axisB,
this.angle = 0,
this.twistAngle = 0,
double maxForce = 1e6,
bool collideConnected = false
}
):super(bodyA, bodyB, pivotA, pivotB, maxForce){
// Set pivot point in between
this.pivotA = pivotA?.clone() ?? Vec3();
this.pivotB = pivotB?.clone() ?? Vec3();
this.axisA = axisA?.clone() ?? Vec3();
this.axisB = axisB?.clone() ?? Vec3();
coneEquation = ConeEquation(
bodyA,
bodyB,
maxForce: 0,
angle: angle,
axisA: this.axisA,
axisB: this.axisB
);
final c = coneEquation;
twistEquation = RotationalEquation(
bodyA,
bodyB,
maxAngle: twistAngle,
maxForce: 0,
axisA: this.axisA,
axisB: this.axisB
);
final t = twistEquation;
// Make the cone equation push the bodies toward the cone axis, not outward
c.minForce = -maxForce;
// Make the twist equation add torque toward the initial position
t.minForce = -maxForce;
equations.addAll([c,t]);
}