チェンジセット 1341
- コミット日時:
- 2008/09/19 17:32:51 (4 ヶ月前)
- ファイル:
凡例:
- 変更無し
- 追加
- 削除
- 更新
- コピー
- 移動
as3/FLARToolKit/trunk/samples/org/tarotaro/flash/ar/FLARAnotherWorldWindowLayer.as
r1332 r1341 16 16 package org.tarotaro.flash.ar 17 17 { 18 import flash.display.Bitmap; 19 import flash.display.BitmapData; 20 import flash.geom.Point; 21 import flash.geom.Transform; 22 import org.libspark.flartoolkit.core.FLARCode; 23 import org.libspark.flartoolkit.core.FLARParam; 24 import org.libspark.flartoolkit.core.FLARSquare; 25 import org.libspark.flartoolkit.core.FLARTransMatResult; 26 import org.libspark.flartoolkit.core.raster.FLARBitmapData; 27 import org.papervision3d.cameras.Camera3D; 28 import org.papervision3d.cameras.CameraType; 29 import org.papervision3d.core.math.Matrix3D; 30 import org.papervision3d.materials.BitmapMaterial; 31 import org.papervision3d.objects.primitives.Sphere; 18 import org.papervision3d.objects.DisplayObject3D; 32 19 import org.papervision3d.view.BasicView; 33 20 import org.tarotaro.flash.ar.layers.FLARSingleMarkerLayer; … … 39 26 public class FLARAnotherWorldWindowLayer extends FLARSingleMarkerLayer 40 27 { 41 private var _m atrix:Matrix3D;28 private var _model:DisplayObject3D; 42 29 private var _view:BasicView; 43 30 /** 31 * 32 * @param src マーカーを探す対象となる画像データ 33 * @param param カメラ用パラメータ 34 * @param code マーカーパターン 35 * @param markerWidth マーカーの幅。マーカーは正方形なので、高さもこれと同じになる。 36 * @param model 表示したいモデル。原点を中心にしたモデルであることが望ましい。 37 * @param windowWidth 表示領域の幅 38 * @param windowHeight 表示領域の高さ 39 * @param thresh マーカー検出時の閾値 40 */ 44 41 public function FLARAnotherWorldWindowLayer(src:FLARBitmapData, 45 42 param:FLARParam, 46 43 code:FLARCode, 47 44 markerWidth:Number, 48 panorama:BitmapData,45 model:DisplayObject3D, 49 46 windowWidth:Number = 640, 50 47 windowHeight:Number = 480, … … 52 49 { 53 50 super(src, param, code, markerWidth, thresh); 54 51 55 52 //Viewの作成 56 this._view = new BasicView(windowWidth, windowHeight, true, false , CameraType.FREE);53 this._view = new BasicView(windowWidth, windowHeight, true, false); 57 54 this.addChild(this._view); 55 56 //モデルの配置 57 this._model = model; 58 this._view.scene.addChild(this._model); 58 59 59 60 //カメラのセッティング 60 61 this._view.camera.focus = 300; 61 62 this._view.camera.zoom = 1; 62 63 //パノラマ球体の構築 64 //1.パノラマ用のマテリアルを作成 65 var panoramaMaterial:BitmapMaterial = new BitmapMaterial(panorama, false); 66 panoramaMaterial.opposite = true; 67 panoramaMaterial.smooth = true; 68 //2.球体を作成 69 var panoSphere:Sphere = new Sphere(panoramaMaterial, 25000, 30, 30); 70 //3.シーンに追加 71 this._view.scene.addChild(panoSphere,"panorama"); 63 this._view.camera.z = -100; 72 64 73 65 //4.レンダリング開始 74 66 this._view.startRendering(); 75 67 } 76 68 77 69 override public function update():void 78 70 { … … 90 82 var center:Point = new Point((Mx + mx)/2, (My+my)/2); 91 83 92 this._view.camera.rotationY = (center.x - this._source.getWidth()/2) * 0.6; 93 this._view.camera.rotationX = -(center.y - this._source.getHeight()/2) * 0.6; 94 trace(this._view.camera.rotationY, this._view.camera.rotationX); 95 //マーカの大きさから、ズームを判定する 96 //900-45000 97 this._view.camera.zoom = 1 + square.area / 9000; 84 this._view.camera.x = (center.x - this._source.getWidth() / 2); 85 this._view.camera.y = (center.y - this._source.getHeight() / 2); 86 this._view.camera.z = -100 - (45000 - square.area); 98 87 } else { 99 88 100 89 } 101 102 //this._view.camera.rotationY += (480 * mouseX/(this._view.width) - this._view.camera.rotationY) * .1;103 //this._view.camera.rotationX += (180 * mouseY/(this._view.height) - 90 - this._view.camera.rotationX) * .1;104 105 }106 private function setTranslationMatrix(mtx:Matrix3D):void {107 var a:Array = this._resultMat.getArray();108 mtx.n11 = a[0][1]; mtx.n12 = a[0][0]; mtx.n13 = a[0][2]; mtx.n14 = a[0][3];109 mtx.n21 = -a[1][1]; mtx.n22 = -a[1][0]; mtx.n23 = -a[1][2]; mtx.n24 = -a[1][3];110 mtx.n31 = a[2][1]; mtx.n32 = a[2][0]; mtx.n33 = a[2][2]; mtx.n34 = a[2][3];111 90 } 112 91
