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

UV と Vertex の関係

Qキー, Eキー で メッシュを変更します
WASD Space, Z キーで移動します

UV と Vertex の関係

16番目からは両面にテクスチャが貼ってあります

次のコードでは、Planeにテクスチャを貼り付けてしまうと
意図したとおりにテクスチャが貼られない問題をUVマッピングを利用して
回避したものです。

羽ばたく蝶々のテクスチャーが上下反転する問題を回避

http://wonderfl.net/code/81ec844675f543b80dcbbae1fcd0c4e83cd644fa

意図したようにテクスチャを貼るためUV、頂点の関係は次の通り
FaceA:UV : ABC
FaceA:Vs : ABCD

FaceB:UV : DCB
FaceB:Vs : DCBA
Get Adobe Flash player
by TmskSt 19 Oct 2010
package {
	/**
	* Qキー, Eキー で メッシュを変更します
	* WASD Space, Z キーで移動します
	*/

	/**
	* UV と Vertex の関係
	* ////////////////////////
	*
	* 16番目からは両面にテクスチャが貼ってあります
	* 
	* 次のコードでは、Planeにテクスチャを貼り付けてしまうと
	* 意図したとおりにテクスチャが貼られない問題をUVマッピングを利用して
	* 回避したものです。
	*
	*
	* 羽ばたく蝶々のテクスチャーが上下反転する問題を回避
	* - forked from :   clockmaker's  [Alternativa3D] Basic Template
	* http://wonderfl.net/code/81ec844675f543b80dcbbae1fcd0c4e83cd644fa
	*
	* 意図したようにテクスチャを貼るためUV、頂点の関係は次の通り
	* FaceA:UV : ABC
	* FaceA:Vs : ABCD
	* 
	* FaceB:UV : DCB
	* FaceB:Vs : DCBA
	*/

	import alternativ5.engine3d.controllers.*;
	import alternativ5.engine3d.core.*;
	import alternativ5.engine3d.display.*;
	import alternativ5.types.*;
	import alternativ5.utils.*;
	
	import flash.events.*;
	import flash.system.*;
	import flash.text.*;
	import flash.display.*;
	import flash.net.*;
	import flash.geom.*;

	[SWF(backgroundColor="#000000", frameRate="120")]
	public class Main extends Sprite {
	    
		private var scene:Scene3D;
		private var view:View;
		private var camera:Camera3D;
		private var cameraController:CameraController;
		
		private var image:BitmapData;
		private var loader:Loader;
		
		private var tf:TextField;
		
		private var db:Vector.<XML> = new Vector.<XML>();
		private var meshes:Vector.<Mesh> = new Vector.<Mesh>();
		
		private var showingMeshKey:int = 0;
		
		public function Main() {
			this.addEventListener(Event.ADDED, init);
		}
		
		public function init(e:Event):void {
			this.removeEventListener(Event.ADDED, init);
			loader = new Loader();
			loader.load(new URLRequest("http://assets.wonderfl.net/images/related_images/3/35/35c2/35c2ea9f0b44ebde51b055163e3da4836e51d22c"), new LoaderContext(true));
			loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loaded);
		}
		
		
		private function loaded(e:Event):void{
			loader.contentLoaderInfo.removeEventListener(Event.COMPLETE,loaded);
			image = new BitmapData(loader.content.width, loader.content.height,true);
			image.draw(loader);
			
			
			stage.scaleMode = StageScaleMode.NO_SCALE;
			stage.align = StageAlign.TOP_LEFT;
			
			scene = new Scene3D();
			scene.root = new Object3D();
			
			
			
			db[0] = 
			<mesh>
				<surface materialType="TextureMaterial">
					<face>
						<UVs>
						// ABC
							<aUV x="0" y="0" />
							<bUV x="1" y="0" />
							<cUV x="1" y="1" />
						</UVs>
						// ABCD
						<vertex x="-100" y="-100" z="0" />
						<vertex x="100" y="-100" z="0" />
						<vertex x="100" y="100" z="0" />
						<vertex x="-100" y="100" z="0" />
					</face>
				</surface>
			</mesh>
			;
			
			db[1] = 
			<mesh>
				<surface materialType="TextureMaterial">
					<face>
						<UVs>
						// ABC
							<aUV x="0" y="0" />
							<bUV x="1" y="0" />
							<cUV x="1" y="1" />
						</UVs>
						// ADCB
						<vertex x="-100" y="-100" z="0" />
						<vertex x="-100" y="100" z="0" />
						<vertex x="100" y="100" z="0" />
						<vertex x="100" y="-100" z="0" />
					</face>
				</surface>
			</mesh>
			;
			
			db[2] = 
			<mesh>
				<surface materialType="TextureMaterial">
					<face>
						<UVs>
						// ABC
							<aUV x="0" y="0" />
							<bUV x="1" y="0" />
							<cUV x="1" y="1" />
						</UVs>
						// BADC
						<vertex x="100" y="-100" z="0" />
						<vertex x="-100" y="-100" z="0" />
						<vertex x="-100" y="100" z="0" />
						<vertex x="100" y="100" z="0" />
					</face>
				</surface>
			</mesh>
			;
			
			db[3] = 
			<mesh>
				<surface materialType="TextureMaterial">
					<face>
						<UVs>
						// ABC
							<aUV x="0" y="0" />
							<bUV x="1" y="0" />
							<cUV x="1" y="1" />
						</UVs>
						// BCDA
						<vertex x="100" y="-100" z="0" />
						<vertex x="100" y="100" z="0" />
						<vertex x="-100" y="100" z="0" />
						<vertex x="-100" y="-100" z="0" />
					</face>
				</surface>
			</mesh>
			;
			
			db[4] = 
			<mesh>
				<surface materialType="TextureMaterial">
					<face>
						<UVs>
						// ABC
							<aUV x="0" y="0" />
							<bUV x="1" y="0" />
							<cUV x="1" y="1" />
						</UVs>
						// CBDA
						<vertex x="100" y="100" z="0" />
						<vertex x="100" y="-100" z="0" />
						<vertex x="-100" y="100" z="0" />
						<vertex x="-100" y="-100" z="0" />
					</face>
				</surface>
			</mesh>
			;
			
			db[5] = 
			<mesh>
				<surface materialType="TextureMaterial">
					<face>
						<UVs>
						// ABC
							<aUV x="0" y="0" />
							<bUV x="1" y="0" />
							<cUV x="1" y="1" />
						</UVs>
						// CDAB
						<vertex x="100" y="100" z="0" />
						<vertex x="-100" y="100" z="0" />
						<vertex x="-100" y="-100" z="0" />
						<vertex x="100" y="-100" z="0" />
					</face>
				</surface>
			</mesh>
			;
			
			db[6] = 
			<mesh>
				<surface materialType="TextureMaterial">
					<face>
						<UVs>
						// ABC
							<aUV x="0" y="0" />
							<bUV x="1" y="0" />
							<cUV x="1" y="1" />
						</UVs>
						// DABC
						<vertex x="-100" y="100" z="0" />
						<vertex x="-100" y="-100" z="0" />
						<vertex x="100" y="-100" z="0" />
						<vertex x="100" y="100" z="0" />
					</face>
				</surface>
			</mesh>
			;
			
			db[7] = 
			<mesh>
				<surface materialType="TextureMaterial">
					<face>
						<UVs>
						// ABC
							<aUV x="0" y="0" />
							<bUV x="1" y="0" />
							<cUV x="1" y="1" />
						</UVs>
						// DCBA
						<vertex x="100" y="100" z="0" />
						<vertex x="100" y="-100" z="0" />
						<vertex x="-100" y="-100" z="0" />
						<vertex x="-100" y="100" z="0" />
					</face>
				</surface>
			</mesh>
			;
			
			// ////////////////////////////////////////
			
			db[8] = 
			<mesh>
				<surface materialType="TextureMaterial">
					<face>
						<UVs>
						// ABC
							<aUV x="0" y="0" />
							<bUV x="1" y="0" />
							<cUV x="1" y="1" />
						</UVs>
						// ABCD
						<vertex x="-100" y="-100" z="0" />
						<vertex x="100" y="-100" z="0" />
						<vertex x="100" y="100" z="0" />
						<vertex x="-100" y="100" z="0" />
					</face>
				</surface>
			</mesh>
			;
			
			db[9] = 
			<mesh>
				<surface materialType="TextureMaterial">
					<face>
						<UVs>
						// ABC
							<aUV x="0" y="0" />
							<bUV x="0" y="1" />
							<cUV x="1" y="1" />
						</UVs>
						// ABCD
						<vertex x="-100" y="-100" z="0" />
						<vertex x="100" y="-100" z="0" />
						<vertex x="100" y="100" z="0" />
						<vertex x="-100" y="100" z="0" />
					</face>
				</surface>
			</mesh>
			;
			
			db[10] = 
			<mesh>
				<surface materialType="TextureMaterial">
					<face>
						<UVs>
						// BCD
							<aUV x="1" y="0" />
							<bUV x="1" y="1" />
							<cUV x="0" y="1" />
						</UVs>
						// ABCD
						<vertex x="-100" y="-100" z="0" />
						<vertex x="100" y="-100" z="0" />
						<vertex x="100" y="100" z="0" />
						<vertex x="-100" y="100" z="0" />
					</face>
				</surface>
			</mesh>
			;
			
			db[11] = 
			<mesh>
				<surface materialType="TextureMaterial">
					<face>
						<UVs>
						// BAD
							<aUV x="0" y="1" />
							<bUV x="0" y="0" />
							<cUV x="1" y="0" />
						</UVs>
						// ABCD
						<vertex x="-100" y="-100" z="0" />
						<vertex x="100" y="-100" z="0" />
						<vertex x="100" y="100" z="0" />
						<vertex x="-100" y="100" z="0" />
					</face>
				</surface>
			</mesh>
			;
			
			db[12] = 
			<mesh>
				<surface materialType="TextureMaterial">
					<face>
						<UVs>
						// CBA
							<aUV x="1" y="1" />
							<bUV x="1" y="0" />
							<cUV x="0" y="0" />
						</UVs>
						// ABCD
						<vertex x="-100" y="-100" z="0" />
						<vertex x="100" y="-100" z="0" />
						<vertex x="100" y="100" z="0" />
						<vertex x="-100" y="100" z="0" />
					</face>
				</surface>
			</mesh>
			;
			
			db[13] = 
			<mesh>
				<surface materialType="TextureMaterial">
					<face>
						<UVs>
						// CDA
							<aUV x="1" y="1" />
							<bUV x="0" y="1" />
							<cUV x="0" y="0" />
						</UVs>
						// ABCD
						<vertex x="-100" y="-100" z="0" />
						<vertex x="100" y="-100" z="0" />
						<vertex x="100" y="100" z="0" />
						<vertex x="-100" y="100" z="0" />
					</face>
				</surface>
			</mesh>
			;
			
			db[14] = 
			<mesh>
				<surface materialType="TextureMaterial">
					<face>
						<UVs>
						// DAB
							<aUV x="0" y="1" />
							<bUV x="0" y="0" />
							<cUV x="1" y="0" />
						</UVs>
						// ABCD
						<vertex x="-100" y="-100" z="0" />
						<vertex x="100" y="-100" z="0" />
						<vertex x="100" y="100" z="0" />
						<vertex x="-100" y="100" z="0" />
					</face>
				</surface>
			</mesh>
			;
			
			db[15] = 
			<mesh>
				<surface materialType="TextureMaterial">
					<face>
						<UVs>
						// DCB
							<aUV x="0" y="1" />
							<bUV x="1" y="1" />
							<cUV x="1" y="0" />
						</UVs>
						// ABCD
						<vertex x="-100" y="-100" z="0" />
						<vertex x="100" y="-100" z="0" />
						<vertex x="100" y="100" z="0" />
						<vertex x="-100" y="100" z="0" />
					</face>
				</surface>
			</mesh>
			;
			//////////////////////////////////////
			
			//両面
			
			db[16] = 
			<mesh>
				<surface materialType="TextureMaterial">
					<face>
						<UVs>
						// ABC
							<aUV x="0" y="0" />
							<bUV x="1" y="0" />
							<cUV x="1" y="1" />
						</UVs>
						// ABCD
						<vertex x="-100" y="-100" z="0" />
						<vertex x="100" y="-100" z="0" />
						<vertex x="100" y="100" z="0" />
						<vertex x="-100" y="100" z="0" />
					</face>
					<face>
						<UVs>
						// ABC
							<aUV x="0" y="0" />
							<bUV x="1" y="0" />
							<cUV x="1" y="1" />
						</UVs>
						// DCBA
						<vertex x="-100" y="100" z="0" />
						<vertex x="100" y="100" z="0" />
						<vertex x="100" y="-100" z="0" />
						<vertex x="-100" y="-100" z="0" />
					</face>
				</surface>
			</mesh>
			;
			
			db[17] = 
			<mesh>
				<surface materialType="TextureMaterial">
					<face>
						<UVs>
						// ABC
							<aUV x="0" y="0" />
							<bUV x="1" y="0" />
							<cUV x="1" y="1" />
						</UVs>
						// ABCD
						<vertex x="-100" y="-100" z="0" />
						<vertex x="100" y="-100" z="0" />
						<vertex x="100" y="100" z="0" />
						<vertex x="-100" y="100" z="0" />
					</face>
					<face>
						<UVs>
						// ADC
							<aUV x="0" y="0" />
							<bUV x="0" y="1" />
							<cUV x="1" y="1" />
						</UVs>
						// DCBA
						<vertex x="-100" y="100" z="0" />
						<vertex x="100" y="100" z="0" />
						<vertex x="100" y="-100" z="0" />
						<vertex x="-100" y="-100" z="0" />
					</face>
				</surface>
			</mesh>
			;
			
			db[18] = 
			<mesh>
				<surface materialType="TextureMaterial">
					<face>
						<UVs>
						// ABC
							<aUV x="0" y="0" />
							<bUV x="1" y="0" />
							<cUV x="1" y="1" />
						</UVs>
						// ABCD
						<vertex x="-100" y="-100" z="0" />
						<vertex x="100" y="-100" z="0" />
						<vertex x="100" y="100" z="0" />
						<vertex x="-100" y="100" z="0" />
					</face>
					<face>
						<UVs>
						// BCD
							<aUV x="1" y="0" />
							<bUV x="1" y="1" />
							<cUV x="0" y="1" />
						</UVs>
						// DCBA
						<vertex x="-100" y="100" z="0" />
						<vertex x="100" y="100" z="0" />
						<vertex x="100" y="-100" z="0" />
						<vertex x="-100" y="-100" z="0" />
					</face>
				</surface>
			</mesh>
			;
			
			db[19] = 
			<mesh>
				<surface materialType="TextureMaterial">
					<face>
						<UVs>
						// ABC
							<aUV x="0" y="0" />
							<bUV x="1" y="0" />
							<cUV x="1" y="1" />
						</UVs>
						// ABCD
						<vertex x="-100" y="-100" z="0" />
						<vertex x="100" y="-100" z="0" />
						<vertex x="100" y="100" z="0" />
						<vertex x="-100" y="100" z="0" />
					</face>
					<face>
						<UVs>
						// BAD
							<aUV x="1" y="0" />
							<bUV x="0" y="0" />
							<cUV x="0" y="1" />
						</UVs>
						// DCBA
						<vertex x="-100" y="100" z="0" />
						<vertex x="100" y="100" z="0" />
						<vertex x="100" y="-100" z="0" />
						<vertex x="-100" y="-100" z="0" />
					</face>
				</surface>
			</mesh>
			;
			
			db[20] = 
			<mesh>
				<surface materialType="TextureMaterial">
					<face>
						<UVs>
						// ABC
							<aUV x="0" y="0" />
							<bUV x="1" y="0" />
							<cUV x="1" y="1" />
						</UVs>
						// ABCD
						<vertex x="-100" y="-100" z="0" />
						<vertex x="100" y="-100" z="0" />
						<vertex x="100" y="100" z="0" />
						<vertex x="-100" y="100" z="0" />
					</face>
					<face>
						<UVs>
						// CBA
							<aUV x="1" y="1" />
							<bUV x="1" y="0" />
							<cUV x="0" y="0" />
						</UVs>
						// DCBA
						<vertex x="-100" y="100" z="0" />
						<vertex x="100" y="100" z="0" />
						<vertex x="100" y="-100" z="0" />
						<vertex x="-100" y="-100" z="0" />
					</face>
				</surface>
			</mesh>
			;
			
			db[21] = 
			<mesh>
				<surface materialType="TextureMaterial">
					<face>
						<UVs>
						// ABC
							<aUV x="0" y="0" />
							<bUV x="1" y="0" />
							<cUV x="1" y="1" />
						</UVs>
						// ABCD
						<vertex x="-100" y="-100" z="0" />
						<vertex x="100" y="-100" z="0" />
						<vertex x="100" y="100" z="0" />
						<vertex x="-100" y="100" z="0" />
					</face>
					<face>
						<UVs>
						// CDA
							<aUV x="1" y="1" />
							<bUV x="0" y="1" />
							<cUV x="0" y="0" />
						</UVs>
						// DCBA
						<vertex x="-100" y="100" z="0" />
						<vertex x="100" y="100" z="0" />
						<vertex x="100" y="-100" z="0" />
						<vertex x="-100" y="-100" z="0" />
					</face>
				</surface>
			</mesh>
			;
			
			db[22] = 
			<mesh>
				<surface materialType="TextureMaterial">
					<face>
						<UVs>
						// ABC
							<aUV x="0" y="0" />
							<bUV x="1" y="0" />
							<cUV x="1" y="1" />
						</UVs>
						// ABCD
						<vertex x="-100" y="-100" z="0" />
						<vertex x="100" y="-100" z="0" />
						<vertex x="100" y="100" z="0" />
						<vertex x="-100" y="100" z="0" />
					</face>
					<face>
						<UVs>
						// DAB
							<aUV x="0" y="1" />
							<bUV x="0" y="0" />
							<cUV x="1" y="0" />
						</UVs>
						// DCBA
						<vertex x="-100" y="100" z="0" />
						<vertex x="100" y="100" z="0" />
						<vertex x="100" y="-100" z="0" />
						<vertex x="-100" y="-100" z="0" />
					</face>
				</surface>
			</mesh>
			;
			
			db[23] = 
			<mesh>
				<surface materialType="TextureMaterial">
					<face>
						<UVs>
						// ABC
							<aUV x="0" y="0" />
							<bUV x="1" y="0" />
							<cUV x="1" y="1" />
						</UVs>
						// ABCD
						<vertex x="-100" y="-100" z="0" />
						<vertex x="100" y="-100" z="0" />
						<vertex x="100" y="100" z="0" />
						<vertex x="-100" y="100" z="0" />
					</face>
					<face>
						<UVs>
						// DCB
							<aUV x="0" y="1" />
							<bUV x="1" y="1" />
							<cUV x="1" y="0" />
						</UVs>
						// DCBA
						<vertex x="-100" y="100" z="0" />
						<vertex x="100" y="100" z="0" />
						<vertex x="100" y="-100" z="0" />
						<vertex x="-100" y="-100" z="0" />
					</face>
				</surface>
			</mesh>
			;
			
			for ( var i:uint = 0; i < db.length; i++) {
				// 実際は このように BitmapData を渡すべきではありません
				meshes[i] = EZCreatMesh.create(db[i], (db[i].surface[0].@materialType == "TextureMaterial") ? image : null);
			}
			
			scene.root.addChild(meshes[0]);
			
			camera = new Camera3D();
			camera.x = camera.y = camera.z = 300;
			scene.root.addChild(camera);
			
			view = new View();
			addChild(view);
			view.camera = camera;
			
			cameraController = new CameraController(stage);
			cameraController.camera = camera;
			cameraController.setDefaultBindings();
			cameraController.lookAt(new Point3D);
			cameraController.checkCollisions = false;
			cameraController.speed = 200;
			cameraController.controlsEnabled = true;
			
			FPS.init(stage);
			
			tf = stage.addChild(new TextField()) as TextField;
			tf.defaultTextFormat = new TextFormat("Arial", 10, 0xFFFFFF);
			tf.x = tf.y = 15;
			tf.width = stage.stageWidth;
			tf.height = stage.stageHeight;
			tf.selectable = false;
			
			stage.addEventListener(Event.RESIZE, onResize);
			stage.addEventListener(Event.ENTER_FRAME, onEnterFrame);
			stage.addEventListener(KeyboardEvent.KEY_UP, onKeyDown);
			onResize(null);
		}
		
		private function onKeyDown(e:KeyboardEvent):void {
			switch(e.keyCode) {
				case 69 : switchMesh(true); break;
				case 81 : switchMesh(false); break;
			}
		}
		
		private function switchMesh(up:Boolean):void {
			if ((up && showingMeshKey < meshes.length - 1) || (!up && showingMeshKey !== 0)) {
				scene.root.removeChild(meshes[showingMeshKey]);
				showingMeshKey += (up) ? 1 : -1;
				tf.text = showingMeshKey + "\n-----------------------------------------------------\n" + db[showingMeshKey].toString();
				scene.root.addChild(meshes[showingMeshKey]);
			}
		}
		
		private function onResize(e:Event):void {
			view.width = stage.stageWidth;
			view.height = stage.stageHeight;
		}
		
		private function onEnterFrame(e:Event):void {
			cameraController.processInput();
			scene.calculate();
		}
	}
}



import alternativ5.engine3d.core.*;
import alternativ5.engine3d.materials.*;
import alternativ5.types.*;
import alternativ5.utils.*;

import flash.geom.*;
import flash.display.*;

class EZCreatMesh {
	
	/**
	 * static const
	 */
	public static const  DEV:String = "DevMaterial";
	public static const  FILL:String = "FillMaterial";
	public static const  TEXTURE:String = "TextureMaterial";
	public static const WIRE:String = "WireMaterial";
	public static const MOVIECLIP:String = "MovieClipMaterial";
	
	/**
	 * 簡単に より早くメッシュを作成する為に
	 * 
	 * Alternativa3Dを利用したマップ(Mesh)作成時に ASでは 頂点やフェイス、サーフェス全てに id(名前)をつける必要があり、これらの作業は非常に面倒です
	 * XMLに情報を記述することによって 値 変更時にコンパイルが不要になり、誰でも簡単にマップ作成が可能です
	 * 
	 * @author br
	 */
	
	/**
	 * メッシュ作成
	 * @param	xml メッシュの情報が記載されたXML
	 * @return Mesh
	 */
	public static function create(xml:XML, bmd:BitmapData = null):Mesh {
		
		var _mesh:Mesh = new Mesh();
		var surfaces:Array = new Array();
		
		for (var a:uint = 0; a < xml.surface.length(); a++)
		{
			var surfaceName:String = String("s" + a);
			var faces:Array = new Array();
			
			for (var b:uint = 0; b < xml.surface[a].face.length(); b++)
			{
				var faceName:String = String("f" + a + b);
				var vertices:Array = new Array();
				
				for (var c:uint = 0; c < xml.surface[a].face[b].vertex.length(); c++)
				{
					var vertexName:String = String("v" + a + b + c);
					
					/**
					 * createVertex
					 */
					_mesh.createVertex(
						xml.surface[a].face[b].vertex[c].@x,
						xml.surface[a].face[b].vertex[c].@y,
						xml.surface[a].face[b].vertex[c].@z,
						vertexName
					);
					vertices.push(vertexName);
				}
				
				/**
				 * createFace
				 */
				_mesh.createFace(vertices, faceName);
				
				/**
				 * setUVsToFace
				 */
				if ("UVs" in xml.surface[a].face[b]) {
					_mesh.setUVsToFace(
						new Point(
							Number(xml.surface[a].face[b].UVs.aUV.@x),
							Number(xml.surface[a].face[b].UVs.aUV.@y)
						),
						new Point(
							Number(xml.surface[a].face[b].UVs.bUV.@x),
							Number(xml.surface[a].face[b].UVs.bUV.@y)
						),
						new Point(
							Number(xml.surface[a].face[b].UVs.cUV.@x),
							Number(xml.surface[a].face[b].UVs.cUV.@y)
						),
						faceName
					);
				}
				
				/**
				 * push Faces
				 */
				faces.push(faceName);
			}
			
			/**
			 * createSurface
			 */
			_mesh.createSurface(faces, surfaceName);
			surfaces.push(surfaceName);
			
			_mesh.setMaterialToSurface(createMaterial(xml.surface[a]), surfaceName);
		}
		
		return _mesh;
		
		
		
		/**
		 * マテリアルを作成
		 * @param	material マテリアル情報が記載されたXML
		 * @return SurfaceMaterial
		 * @exampleText XMLの例を示します
		 * <listing version="3.0">
		 * <surface materialType="FillMaterial" color="0x99ab4e" wirethickness="1" wirecolor="0x7b8d42" />
		 * <surface materialType="TextureMaterial" repeat="true" smooth="true" src="image" precision="BEST" />
		 * </listing>
		 */
		function createMaterial(material:XML):SurfaceMaterial {
			switch (true) {
				/**
				 * DEV
				 */
				case material.@materialType == DEV : 
					return new DevMaterial(
						uint(material.@parametertype) ? material.@parametertype : 0,
						uint(material.@color) ? material.@color : 0xFFFFFF,
						Number(material.@maxparametervalue) ? material.@maxparametervalue : 20,
						Boolean(material.@shownormals) ? material.@shownormals : false,
						uint(material.@normalscolor) ? material.@normalscolor : 0x00FFFF,
						int(material.@minmobility) ? material.@minmobility : 0,
						int(material.@maxmobility) ? material.@maxmobility : 255,
						Number(material.@alpha) ? material.@alpha : 1,
						String(material.@blendmode) ? material.@blendmode : "normal",
						Number(material.@wirethickness) ? material.@wirethickness : -1,
						Number(material.@wirecolor) ? material.@wirecolor : 0
					);
				break;
				
				/**
				 * FILL
				 */
				case material.@materialType == FILL : 
				
					return new FillMaterial(
						uint(material.@color)? material.@color: 0xffffff * Math.random(),
						Number(material.@alpha)? material.@alpha : 1,
						String(material.@blendmode)? material.@blendmode : "normal",
						Number(material.@wirethickness)? material.@wirethickness : -1,
						Number(material.@wirecolor)? material.@wirecolor : 0
					);
				break;
				
				/**
				 * TEXTURE
				 */
				case material.@materialType == TEXTURE :
					return new TextureMaterial(
					new Texture(bmd),
					uint(material.@alpha)? material.@alpha : 1,
					Boolean(material.@repeat == "true")? true : true,
					Boolean(material.@smooth == "true")? true : false,
					String(material.@blendmode.toString())? material.@blendmode : BlendMode.NORMAL,
					Number(material.@wirethickness)? material.@wirethickness : -1,
					uint(material.@wirecolor)? material.@wirecolor : 0,
					String(material.@precision.toString())? createTextureMaterialPrecision(material.@precision.toString()) : 10
					);
				break;
				
				/**
				 * WIRE
				 */
				case material.@materialType == WIRE : 
					return new WireMaterial(
						Number(material.@thickness) ? material.@thickness : 0,
						uint(material.@color) ? material.@color : 0xffffff * Math.random(),
						Number(material.@alpha) ? material.@alpha : 1,
						String(material.@blendmode) ? material.@blendmode : "normal"
					);
				break;
				
				default : 
				return null;
				break;
			}
		}
		
		/**
		 * createTextureMaterialPrecision
		 * @param	precision
		 * @return
		 */
		function createTextureMaterialPrecision(precision:String):Number {
			switch(true) {
				case precision == "BEST" : return TextureMaterialPrecision.BEST; break;
				case precision == "HIGH" : return TextureMaterialPrecision.HIGH; break;
				case precision == "LOW" : return TextureMaterialPrecision.LOW; break;
				case precision == "MEDIUM" : return TextureMaterialPrecision.MEDIUM; break;
				case precision == "NONE" : return TextureMaterialPrecision.NONE; break;
				case precision == "VERY_HIGH" : return TextureMaterialPrecision.VERY_HIGH; break;
				case precision == "VERY_LOW" : return TextureMaterialPrecision.VERY_LOW; break;
				default : return TextureMaterialPrecision.MEDIUM;
			}
		}
		
		
		/**
		 * XMLを元にプロパティを変更したメッシュを返します
		 * @param	mesh メッシュ
		 * @param	properties プロパティが記載されたXML
		 * @return mesh プロパティが変更されたメッシュを返します
		 * @exampleText XMLの例を示します
		 * <listing version="3.0">
		 * <mesh z="-100" scaleX="5" scaleY="5" />
		 * </listing>
		 */
		function meshPropertiesSetup(mesh:Mesh, properties:XML):Mesh {
			if(properties.hasOwnProperty("@x")) mesh.x = Number(properties.@x);
			if(properties.hasOwnProperty("@y")) mesh.y = Number(properties.@y);
			if(properties.hasOwnProperty("@z")) mesh.z = Number(properties.@z);
			if(properties.hasOwnProperty("@scaleX")) mesh.scaleX = Number(properties.@scaleX);
			if(properties.hasOwnProperty("@scaleY")) mesh.scaleY = Number(properties.@scaleY);
			if(properties.hasOwnProperty("@scaleZ")) mesh.scaleZ = Number(properties.@scaleZ);
			if(properties.hasOwnProperty("@rotationX")) mesh.rotationX = MathUtils.toRadian(Number(properties.@rotationX));
			if(properties.hasOwnProperty("@rotationY")) mesh.rotationY = MathUtils.toRadian(Number(properties.@rotationY));
			if(properties.hasOwnProperty("@rotationZ")) mesh.rotationZ = MathUtils.toRadian(Number(properties.@rotationZ));
			return mesh;
		}
	}
}