User Guide

368 APPENDIX E
loader.timestep = function(now)
{
if (!doorLeft.loaded) { return; }
if (!hingeLeft.loaded) { return; }
doorLeft.physicalModel = doorLeft.createConvexPhysicalModel(2);
doorLeft.physicalModel.collide = true;
doorLeft.physicalModel.acceleration = Vector(0.0, -32.0, 0.0);
hingeLeft.physicalModel = hingeLeft.createConvexPhysicalModel(0);
hingeLeft.physicalModel.fi xed = true;
constraint = this.solver.createHingeConstraint(doorLeft.physicalModel,
hingeLeft.physicalModel);
constraint.setWorldSpacePivotAndAxis(doorLeft.pivot, doorLeft.axis);
breakableConstraint = this.solver.createBreakableConstraint(constraint, 50, 50);
this.solver.addConstraint(breakableConstraint);
doorLeft.angularDashpot = this.solver.createAngularDashpot(doorLeft.physicalModel,
hingeLeft.physicalModel);
doorLeft.angularDashpot.setRotation(Rotation(‘Y’, 0.0));
doorLeft.angularDashpot.strength = .5;
this.solver.addAngularDashpot(doorLeft.angularDashpot);
removeAnimator(this);
}
addAnimator(loader);
HingeConstraint
A hinge constraint between two physical models simulates the effects of a physical hinge. The constraint includes a
pivot point and a rotation axis. The pivot point and axis are specifi ed in world space when being defi ned relative to
the initial position of the physical models. Such a constraint is created using a fast constraint solver. After that, the two
objects will be constrained to act as if there is a hinge between them.
It should be noted that for any of the physics based constraints or actions, it is necessary to assign reasonable mass
values when creating the physical models so that physics processing does not become unstable (driven out of scope).
The guidelines for mass and inertia are decribed in the method createPhysicalModel().
Properties
tau
The time constant for the constraint, similar to damping.
strength
The strength or stiffness of the constraint.