In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

jiglibflash sample

tutorial of jiglibflash by miguelMoraleda at:
http://as3.miguelmoraleda.com/2009/04/24/flash/jiglibflash/tutorial-jiglibflash-how-to-create-basic-physics-3d-scenetutorial-jiglibflash-como-crear-una-scena-en-3d-con-fisica/
Get Adobe Flash player
by mash 08 May 2009
// tutorial of jiglibflash by miguelMoraleda at:
// http://as3.miguelmoraleda.com/2009/04/24/flash/jiglibflash/tutorial-jiglibflash-how-to-create-basic-physics-3d-scenetutorial-jiglibflash-como-crear-una-scena-en-3d-con-fisica/
package  
{
	import flash.display.StageAlign;
	import flash.display.StageQuality;
	import flash.display.StageScaleMode;
	import flash.events.Event;
	import jiglib.physics.RigidBody;
	import jiglib.plugin.papervision3d.Papervision3DPhysics;
	import org.papervision3d.materials.utils.MaterialsList;
	import org.papervision3d.materials.WireframeMaterial;
	import org.papervision3d.objects.DisplayObject3D;
	import org.papervision3d.view.BasicView;
	
	/**
	 * ...
	 * @author http://www.miguelmoraleda.com
	 */
	public class Main extends BasicView
	{
		private var _physics:Papervision3DPhysics;
		private var _cameraTarget:DisplayObject3D;
		
		public function Main() 
		{
			super(0, 0, true);
			
			configStage();
			configScene();
			initPhysics();
			createGround();
			createBox();
			createSphere();
			startRendering();
		}
		
		private function configStage():void
		{
			stage.scaleMode = StageScaleMode.NO_SCALE;
			stage.align = StageAlign.TOP_LEFT;
			stage.quality = StageQuality.MEDIUM;
		}
		
		private function configScene():void
		{
			_cameraTarget = new DisplayObject3D();
			
			camera.x = 400
			camera.y = 400;
			camera.z = 0;
			camera.lookAt(_cameraTarget);
		}
		
		private function initPhysics():void
		{
			_physics = new Papervision3DPhysics(scene, 7);
		}
		
		private function createGround():void
		{
			var mat:WireframeMaterial = new WireframeMaterial(0xCCCCCC);
			var ground:RigidBody = _physics.createGround(mat, 1000, 0);
		}
		
		private function createBox():void
		{
			var materials:MaterialsList = new MaterialsList();
			materials.addMaterial(new WireframeMaterial(0xFF4444), "all");
			var box:RigidBody;
			for (var i:int = 1; i < 5; i++) {
				box = _physics.createCube(materials, 100, 100, 100, 3, 3, 3);
				box.y = 300 * i;
			}
		}
		
		private function createSphere():void
		{
			var ball:RigidBody;
			for (var i:int = 1; i < 4; i++) {
				ball = _physics.createSphere(new WireframeMaterial(0xFF44FF), 50);
				ball.z = -200;
				ball.y = 300 * i;
			}
		}
		
		override protected function onRenderTick(event:Event = null):void 
		{
			_physics.step();
			super.onRenderTick(event);
		}
		
	}
	
}