Adobe ATMOSPHERE User Manual page 309

Table of Contents

Advertisement

}
removeAnimator(this);
}
}
addAnimator(box);
applyImpulseToCenterOfMass(Vector impulse)
This function increments the linear momentum of the physical model by a specifi ed amount, and also updates
the angular momentum, in a way that is consistent with the impulse being applied to a given position within the
physical model. The direction of the impulse vector defi nes the direction of applied force, and the magnitude
of the vector determines the amount of linear momentum applied. A linear impulse may be thought of as a
large force applied for a short time, with the magnitude of the force being multiplied by the duration to get the
amount of linear momentum change.
box = SceneGroup("./resources/box.aer").add();
box.timestep = function()
{
if (this.loaded)
{
this.physicalModel = this.createPhysicalModel(10);
this.physicalModel.collide = true;
this.root = this.getSolidObject(0).rootPrimitive;
this.solidObject.onClick = function()
{
camera
= application.getView(0).getCamera(0);
direction = box.position.subtract(camera.position);
impulse
= direction.normalized.scale(10);
// Push the box directly away when it is clicked on
box.physicalModel.applyImpulseToCenterOfMass(impulse);
}
removeAnimator(this);
}
}
addAnimator(box);
disableCollisionsWith(PhysicalModel)
This function allows one physical model to avoid colliding with another physical model. This pair of objects is
kept in a list and any collisions detected between the physical models will be ignored. This feature is useful when
making mechanisms using constraints and it is necessary to avoid collisions between two objects that are joined
together.
box1 = SceneGroup("./resources/box.aer").add();
box2 = SceneGroup("./resources/box.aer").add();
297
ADOBE ATMOSPHERE
User Guide

Advertisement

Table of Contents
loading

Table of Contents