package{ import flash.events.Event; import jiglib.plugin.sandy3d.Sandy3DPhysics; import jiglib.physics.RigidBody; import sandy.materials.Appearance; import sandy.view.BasicView; /** * This is the second HelloWorld example for using JigLib together with Sandy 3D. * It shows a sphere dressed in the wire frame material, falling under the influence of gravity. * Here we add a ground plane to stop the motion * * @author petit@petitpub.com */ public class BallGround extends BasicView { private var physics:Sandy3DPhysics; /** * Initiate the physics engine, add the shpere and start rendering. */ public function BallGround() { // Initiate the BasicView super.init(400, 400); // Create an instance of the physics engine physics = new Sandy3DPhysics(scene, 2); // Create an object createScene(); // Start rendering render(); } /** * Create the sphere object and add it to the scene. * The physics engine creates the rigid sphere object and the Sandy sphere. * It also adds the Shape3D to rhe root group of the scene * The same way we add a ground plane, that will stop the motion */ private function createScene():void { var appearance:Appearance = makeColorAppearance(); var sphere:RigidBody = physics.createSphere("sphere", null, 20, 7, 5); sphere.y = 150; 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 ); } } }