Beautifl - Flash Gallery

Thumbnail : Another Alternativa3D maze (bent :)
Another Alternativa3D maze (bent :)
makc3d 2010-03-04 see code comments

再生するにはFlash Playerが必要です。デスクトップのブラウザでご覧ください。

// forked from makc3d's Another Alternativa3D maze (textured :)
// Another Alternativa3D maze (textured :)
// use WASD + mouse to fly around
package
{
	import flash.display.*;
	import flash.events.*;
	import flash.filters.ShaderFilter;
	import flash.geom.*;

	import alternativ5.engine3d.controllers.*
	import alternativ5.engine3d.core.*
	import alternativ5.engine3d.display.*
	import alternativ5.engine3d.materials.*
	import alternativ5.engine3d.primitives.*
	import alternativ5.types.*

	[SWF(backgroundColor="0")]	
	public class Maze extends Sprite
	{
		private var maze:Array;
		private var SIZE:int = 11;
		private var N:int = 3; // don't go crazy :)

		private var q:int;

		private var texture2:BitmapData;
		private var texture3:BitmapData;

		public function Maze()
		{
			var image2:String = "";
			image2 += "/9j/4AAQSkZJRgABAgAAZABkAAD/7AARRHVja3kAAQAEAAAAQwAA/+4ADkFkb2JlAGTAAAAAAf/bAIQABQMDAwMDBQMDBQcEBAQHCAYFBQYICQcHCAcHCQsJCgoKCgkLCwwMDAwMCw4ODg4ODhQUFBQUFhYWFhYWFhYWFgEFBQUJCAkRCwsRFA8ODxQWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYW/8AAEQgAZABkAwERAAIRAQMRAf/EAKcAAAIDAQEBAAAAAAAAAAAA";
			image2 += "AAQFAQMGAgAIAQADAQEBAAAAAAAAAAAAAAACAwQBAAUQAAIBAgQEAwMHCQQLAAAAAAIDEgEEABEiEyEyFAUxQiNSMxVBUWGBcoIW8HFiokMkNAYXksJTJZGhwbLi8sNEZDVFEQACAgEDAgIHCAEFAAAAAAAAARECEiExAyIT8BRBUYHB8TIEYXGRoUJigiPC4VLyQxX/2gAMAwEAAhEDEQA/APl/t+zcLBlwJbSTyOO0sqCMaVOnokVdVdUvs+XEthsB5W4bzRJ1ZrESC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g59nHp+X2/EFuNqRfib8Ubuye/1ee1txrvb/Vep7qfjonng1nDjHL7Pv/D3mvCV/s8e0U/9/wD/AGviG7+h8Xluf2tiH3Nz6MUaz6Mfy+P5+0T+g//Z";

			var loader:Loader = new Loader;
			loader.contentLoaderInfo.addEventListener ("complete", onImage2);
			loader.loadBytes (new Base64 (image2));
		}

		private function onImage2 (e:Event):void {
			texture2 = Bitmap (LoaderInfo(e.target).content).bitmapData;

			var image3:String = "";
			image3 += "/9j/4AAQSkZJRgABAgAAZABkAAD/7AARRHVja3kAAQAEAAAAFAAA/+4ADkFkb2JlAGTAAAAAAf/bAIQAEg4ODhAOFRAQFR4TERMeIxoVFRojIhgYGhgYIiceIiEhIh4nJy4wMzAuJz4+QUE+PkFBQUFBQUFBQUFBQUFBQQEUExMWGRYbFxcbGhYaFhohGh0dGiExISEkISExPi0nJycnLT44OzMzMzs4QUE+PkFBQUFBQUFBQUFBQUFBQUFB/8AAEQgAgACAAwEiAAIRAQMRAf/EAJUAAAIDAQEAAAAAAAAAAAAA";
			image3 += "AAQFAgMGAQABAQEBAQEAAAAAAAAAAAAAAAABAgMEEAACAQMDAQUECAYBBQEAAAABAgMAEQQhEgUxQVFhIhNxkTIUgaGxwdFCUiNicoIkFQaS8DNTNERFEQACAQMEAQIFAgcAAAAAAAAAAREhMQJBcYGRUWES8CJSgpJCE6GxwdHhYuL/2gAMAwEAAhEDEQA/AEMvkTcR0FyQPGqxlYYuCSbdARR0y+Uyyi8cY89vzAadKXGbirm0LC4/U2lc0qHoeTTpHJaudigdhtbqNbVcudhF7oo1/LagvU43T9trjxarY24s";
			image3 += "uo9Nr+BNWNzPuf8AqGzy4UIUuh82tUHMwCNBsJ7dWorkflV9IzKShHlHQ+8UuaTjb+VWUdouaEt45Lhm4Wwg6t2HpVkU2PPIqxi19DcXoRJePB8yll7rkURA+CzXhDIw6a3FKCXN+icmTjRMytr2XIFQTkMFCCVDeFeyDho+2cXk6mxNrH2VQZeLvcRm36bt9tRLc02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AB3YhNurXb7KYcZNxssyenimMhgBJuJ8xOmhoyUf6+AfSgdidASWFqvxZeAh2yLG6yr2kMwBqyrST25RPtgB/2DNwoM5o3xhLKFF5Ne2lB5XFIIGEuvQ2NxTjk2w8uYzJGT2b2vuP0VDEh4vY3zEW4jpYG9Fkg8MkhKudirJvOLvX9LA2+qmvHNh5EbExmAoNx2/n";
			image3 += "16WbpU2i4vUJCw10Yi+nsqaDGjJ9IMqm1xttceyo8kaxwyu6CyXkcBtPkVU9dy7rm/frVAy8HaQYLkj4rHStLFicRLMXK7YrXO5GGvd1q7J4zgZlb0SsTgfEA20e0VZmplpqn9DKrlYG4XhLDptsRWnxFhfjZZ409MensC9RdWtelb4OMCQqqyg2DC+tu2mMORjJgyQ3KtbyADS+mlZk28Xfa1D/2Q==";

			var loader:Loader = new Loader;
			loader.contentLoaderInfo.addEventListener ("complete", onImage3);
			loader.loadBytes (new Base64 (image3));
		}

		private function onImage3 (e:Event):void {
			texture3 = Bitmap (LoaderInfo(e.target).content).bitmapData;

			// ready
			stage.quality = "low";
	
			scene = new Scene3D; scene.root = new Object3D; 
			view = new View; view.camera = new Camera3D; scene.root.addChild (view.camera); 
			view.width = view.height = 465; view.camera.z = -500; addChild (view); 
			wasd = new CameraController (stage); wasd.camera = view.camera; 
			wasd.setDefaultBindings ();
			wasd.checkCollisions = true; 
			wasd.collisionRadius = 3; 
			wasd.controlsEnabled = true; 
			wasd.mouseSensitivity *= 0.4; 
			wasd.speed = 20;
			wasd.fovStep = 0;

			var p:Plane = new Plane (SIZE * 10, SIZE * 10);
			for each (var f:Face in p.faces) {   
				var uv:Point;   
				uv = f.aUV; uv.x *= SIZE; uv.y *= SIZE; f.aUV = uv;   
				uv = f.bUV; uv.x *= SIZE; uv.y *= SIZE; f.bUV = uv;   
				uv = f.cUV; uv.x *= SIZE; uv.y *= SIZE; f.cUV = uv;   
			} 
			p.cloneMaterialToAllSurfaces (new TextureMaterial (new Texture (texture3),
				1, true, false, "normal", -1, 0, TextureMaterialPrecision.VERY_HIGH));
			p.x = (SIZE - 1) * 5; p.y = (SIZE - 1) * 5; p.z = -5;
			scene.root.addChild (p);

			p = p.clone () as Plane;
			p.x = (SIZE - 1) * 5; p.y = (SIZE - 1) * 5; p.z = N*10 -5;
			scene.root.addChild (p);

			// the reason for this fork is great idea by paq,
			// http://wonderfl.kayac.com/code/7cbc840af08054aa087e2fdf8b8f1b01b222f752
			for (q = 0; q < N; q++) {
				initialize(); 
				boutaoshi(); 
				draw(); 
			}

		}
		
		private function boutaoshi():void
		{
			for (var y:int = 2; y < SIZE - 1; y += 2)
			{
				var dx:int = 2;
				var dy:int = y;
				
				switch (Math.floor(Math.random() * 4))
				{
					case 0:
						dx++;
						break;
					case 1:
						dx--;
						break;
					case 2:
						dy++;
						break;
					case 3:
						dy--;
						break;
				}
				
				if (!maze[dx][dy])
				{
					maze[dx][dy] = true;
				}
				else
				{
					y -= 2;
				}
			}
			
			for (var x:int = 4; x < SIZE - 1; x += 2)
			{
				for (y = 2; y < SIZE - 1; y += 2)
				{
					dx = x;
					dy = y;
					
					switch (Math.floor(Math.random() * 3))
					{
						case 0:
							dy++;
							break;
						case 1:
							dy--;
							break;
						case 2:
							dx++;
							break;
					}
					
					if (!maze[dx][dy])
					{
						maze[dx][dy] = true;
					}
					else
					{
						y -= 2;
					}
				}
			}
		}
		
		private var scene:Scene3D;
		private var view:View;
		private var wasd:CameraController;
		private var sf:ShaderFilter;

		private function draw():void
		{
			var i0:int = 1, j0:int = 1;
			for (var i:int = 0; i < SIZE; i++)
			{
				for (var j:int = 0; j < SIZE; j++)
				{
					if (maze[i][j])
					{
						var box:Box = new Box (10, 10, 10);
						box.mobility = 1;
						box.x = i * 10; box.y = j * 10; box.z = q * 10; 
						for each (var s:Surface in box.surfaces) s.material =
							new TextureMaterial (new Texture (texture2));
						box.setMaterialToSurface (new TextureMaterial (new Texture (texture3)), "top");
						box.setMaterialToSurface (new TextureMaterial (new Texture (texture3)), "bottom");
						scene.root.addChild (box); 
					}
					else
					{
						i0 = i; j0 = j;
					}
				}
			}

			view.camera.x = i0 * 10; 
			view.camera.y = j0 * 10;
			view.camera.z = q * 10; 
			view.camera.rotationX = -Math.PI / 2; 
			view.camera.rotationZ = -3;
			view.camera.fov = 2.9;

			var sh:Shader = new Shader (new Base64 ("pQEAAACkCQBOZXdGaWx0ZXKgDG5hbWVzcGFjZQBleHBlcmltZW50YWwAoAx2ZW5kb3IAbWFrYwCgCHZlcnNpb24AAQCgDGRlc2NyaXB0aW9uAHNwaGVyaXplAKEBAgAADF9PdXRDb29yZACjAARzcmMAoQIEAQAPZHN0AKEBAgAAA2NlbnRlcgCiAm1pblZhbHVlAAAAAAAAAAAAogJtYXhWYWx1ZQBEgAAARIAAAKICZGVmYXVsdFZhbHVlAENogABDaIAAoQEBAgAIem9vbQCiAW1pblZhbHVlAAAAAACiAW1heFZhbHVlAEEgAACiAWRlZmF1bHRWYWx1ZQBAAAAAoQEBAgAEcmFkaXVzAKIBbWluVmFsdWUAQSAAAKIBbWF4VmFsdWUARHoAAKIBZGVmYXVsdFZhbHVlAEOkgAAdAgAxAAAQADIDAIA/gAAAMgMAQEAAAAAEAwAgAwBAAAMDACACAMAAMgMAQEAAAAAdAwAQAwCAAAgDABADAEAAHQMAQAMAAAABAwBAAwDAADIDAIA/AAAAHQMAIAMAQAADAwAgAwAAAB0DAIADAIAAHQMAYQIAsAACAwBhAACwAB0EAMEDAGAAHQMAQAQAAAADAwBABAAAAB0DACAEAEAAAwMAIAQAQAAdAwAQAwBAAAEDABADAIAAFgMAQAMAwAAdAwAgAwBAACoDACACAEAAHQGAgACAAAA0AAAAAYAAADIDAEA9zMzNHQMAEAMAgAABAwAQAwBAAAQDAEADAMAAAwMAQAIAQAAEAwAQAgBAAAMDABADAIAADwQAIAMAwAAdAwAQAwBAAAMDABAEAIAAMgMAQD/I9cMEBAAgAwBAAAMEACADAMAAHQMAQAQAgAAHAwBAAgAAAAMEAMEDAFAAHQQAMQAAsAABBAAxBAAQAB0CADEEALAANgAAAAAAAAAxBQDxAgCwAB0BAPMFABsAAwEAQAMAAAA="));
			sh.data ["zoom"] ["value"] = [3.0]; sf = new ShaderFilter (sh); view.filters = [sf];

			addEventListener (Event.ENTER_FRAME, function (e:Event):void {
				wasd.processInput (); scene.calculate ();
			});
		}
		
		private function initialize():void
		{
			maze = new Array(SIZE);
			for (var i:int = 0; i < SIZE; i++)
			{
				maze[i] = new Array(SIZE);
			}
			
			for (i = 0; i < SIZE; i++)
			{
				for (var j:int = 0; j < SIZE; j++)
				{
					if (i == 0 || j == 0 || i == SIZE - 1 || j == SIZE - 1 || i % 2 == 0 && j % 2 == 0)
					{
						maze[i][j] = true;
					}
					else
					{
						maze[i][j] = false;
					}
				}
			}
		}
	}
}


// base64 code by 2ndyofyyx,
// http://wonderfl.kayac.com/code/b3a19884080f5ed34137e52e7c3032f3510ef861
import flash.utils.ByteArray; 
class Base64 extends ByteArray { 
    private static const BASE64:Array = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,62,0,0,0,63,52,53,54,55,56,57,58,59,60,61,0,0,0,0,0,0,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,0,0,0,0,0,0,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,0,0,0,0,0]; 
    public function Base64(str:String) { 
        var n:int, j:int; 
        for(var i:int = 0; i < str.length && str.charAt(i) != "="; i++) { 
            j = (j << 6) | BASE64[str.charCodeAt(i)]; 
            n += 6; 
            while(n >= 8) { 
                writeByte((j >> (n -= 8)) & 0xFF); 
            } 
        } 
        position = 0; 
    } 
}