package{ import flash.events.Event; import jiglib.plugin.sandy3d.Sandy3DPhysics; import jiglib.physics.RigidBody; import sandy.materials.attributes.LightAttributes; import sandy.materials.attributes.MaterialAttributes; import sandy.materials.ColorMaterial; import sandy.materials.Appearance; import sandy.view.BasicView; /** * This application tests the hypotesis that a heavier ball falls faster than a lighter one. * We also add some nice look and feel to the balls * * @author petit@petitpub.com */ public class OnMass extends BasicView { private var physics:Sandy3DPhysics; /** * Initiate the physics engine, add the shpere and start rendering. */ public function OnMass() { // Initiate the BasicView super.init(400, 400); // Create an instance of the physics engine physics = new Sandy3DPhysics(scene, 3); // Create an object createScene(); // Start rendering render(); } /** * Create the scene */ private function createScene():void { var appearance:Appearance = makeColorAppearance(); var attributes:MaterialAttributes = new MaterialAttributes(new LightAttributes(true)); var ballMaterial1:ColorMaterial = new ColorMaterial(0xE0B42F, 1, attributes); var ballMaterial2:ColorMaterial = new ColorMaterial(0xAA1200, 1, attributes); ballMaterial1.lightingEnable = true; ballMaterial2.lightingEnable = true; var sphere:RigidBody = physics.createSphere("sphere", new Appearance( ballMaterial1 ), 20, 7, 5); sphere.y = 150; var sphere2:RigidBody = physics.createSphere("sphere", new Appearance( ballMaterial2 ), 20, 7, 5); sphere2.y = 150; sphere2.x = 60; sphere2.mass = 5; var ground:RigidBody = physics.createGround("ground", appearance, 200, -100); } /** * Overriding the simpleRender method to call the time step method of the rendering engine. * @param event The ENTER_FRAME or timer event - the heart beat of Sandy */ override public function simpleRender( event:Event = null ):void { physics.step( ); super.simpleRender( event ); } } }