チェンジセット 1774

差分発生行の前後
無視リスト:
コミット日時:
2008/10/31 01:50:07 (2 ヶ月前)
コミッタ:
tarotarorg
ログメッセージ:

キューブ型マーカ関連クラスをsamplesに移動

ファイル:

凡例:

変更無し
追加
削除
更新
コピー
移動
  • as3/FLARToolKit/trunk/samples/org/tarotaro/flash/ar/FLARCubeMarkerDetectorSample.as

    r1755 r1774  
    1414        import org.libspark.flartoolkit.core.raster.rgb.FLARRgbRaster_BitmapData; 
    1515        import org.libspark.flartoolkit.core.raster.rgb.IFLARRgbRaster; 
    16         import org.libspark.flartoolkit.detector.CubeMarker; 
     16        import org.tarotaro.flash.ar.detector.CubeMarker; 
    1717        import org.tarotaro.flash.ar.layers.FLARCubeMarkerLayer; 
    1818        import org.tarotaro.flash.ar.layers.FLARLayer; 
     
    4444                        var param:FLARParam = new FLARParam(); 
    4545                        param.loadARParam(new CParam() as ByteArray); 
    46                          
     46                        param.changeScreenSize(320, 240); 
    4747                        //パターンの設定 
    4848                        var cTop:FLARCode = new FLARCode(16, 16); 
     
    6767                        //表示部分を設定 
    6868                        this._capture = new Bitmap(new BitmapData(320, 240, false, 0), PixelSnapping.AUTO, true); 
    69                         this._capture.scaleX = this._capture.scaleY = 2; 
     69 
    7070                        var raster:IFLARRgbRaster = new FLARRgbRaster_BitmapData(this._capture.bitmapData); 
    7171                        var webcam:Camera = Camera.getCamera(); 
     
    7777                         
    7878                        this._layer = new FLARCubeMarkerLayer(raster, param, cube); 
    79                         this._layer.scaleX = this._layer.scaleY = 2; 
    8079                         
     80                        this._arSprite = new Sprite(); 
    8181 
    82                         this.addChild(this._capture); 
    83                         this.addChild(this._layer); 
    84                          
     82                        this._arSprite.addChild(this._capture); 
     83                        this._arSprite.addChild(this._layer); 
     84                        this._arSprite.scaleX = this._arSprite.scaleY = 2; 
     85                        this.addChild(this._arSprite); 
     86 
    8587                        this.addChild(new FPSMeter()); 
    8688 
  • as3/FLARToolKit/trunk/samples/org/tarotaro/flash/ar/layers/FLARCubeMarkerLayer.as

    r1755 r1774  
    3838        import org.libspark.flartoolkit.core.raster.rgb.IFLARRgbRaster; 
    3939        import org.libspark.flartoolkit.core.transmat.FLARTransMatResult; 
    40         import org.libspark.flartoolkit.detector.CubeMarker; 
    41         import org.libspark.flartoolkit.detector.FLARCubeMarkerDetector; 
    4240        import org.libspark.flartoolkit.detector.FLARMultiMarkerDetector; 
    4341        import org.libspark.flartoolkit.detector.FLARMultiMarkerDetectorResult; 
     42        import org.libspark.flartoolkit.pv3d.FLARBaseNode; 
     43        import org.papervision3d.lights.PointLight3D; 
     44        import org.papervision3d.materials.shadematerials.FlatShadeMaterial; 
     45        import org.papervision3d.materials.utils.MaterialsList; 
     46        import org.papervision3d.materials.WireframeMaterial; 
     47        import org.papervision3d.objects.primitives.Cube; 
     48        import org.papervision3d.objects.primitives.Plane; 
     49        import org.papervision3d.view.BasicView; 
     50        import org.tarotaro.flash.ar.detector.CubeMarker; 
     51        import org.tarotaro.flash.ar.detector.CubeMarkerDetectedResult; 
     52        import org.tarotaro.flash.ar.detector.CubeMarkerDirection; 
     53        import org.tarotaro.flash.ar.detector.FLARCubeMarkerDetector; 
    4454         
    4555        /** 
     
    5262                protected var _resultMat:FLARTransMatResult; 
    5363                protected var _confidence:Number; 
     64                protected var _baseNode:FLARBaseNode; 
     65                private var _plane:Plane; 
     66                private var _cube:Cube; 
     67                private var _view:BasicView; 
    5468                 
    5569                private var colors:Object = { 
     
    6781                { 
    6882                        super(src, thresh); 
    69                         this._detector = new FLARCubeMarkerDetector(param, cube); 
    70                         this._detector.sizeCheckEnabled = false; 
     83                        this._detector = new FLARCubeMarkerDetector(param, cube,1.0); 
     84                        //this._detector.sizeCheckEnabled = false; 
    7185                        this._resultMat = new FLARTransMatResult(); 
    7286                        this._confidence = confidence; 
     87                         
     88                        this._baseNode = new FLARBaseNode(); 
     89                        var wmat:WireframeMaterial = new WireframeMaterial(0xff0000, 1, 2); 
     90                        wmat.doubleSided = true; 
     91                        this._plane = new Plane(wmat, 100, 100); 
     92                        this._baseNode.addChild(this._plane); 
     93                         
     94                        var light:PointLight3D = new PointLight3D(); 
     95                        light.x = 1000; 
     96                        light.y = 1000; 
     97                        light.z = -1000; 
     98                        var fmat:FlatShadeMaterial = new FlatShadeMaterial(light, 0xff22aa, 0x0); 
     99                        this._cube = new Cube(new MaterialsList({all: fmat}), 60,60,60); 
     100                        this._cube.z += 20; 
     101                        this._baseNode.addChild(this._cube); 
     102                         
     103                        this._view = new BasicView(320, 240); 
     104                        this._view.scene.addChild(this._baseNode); 
     105                        this.addChild(this._view); 
    73106                } 
    74107                 
     
    78111                        g.clear(); 
    79112 
    80                         //var numDetected:int = this._detector.detectMarkerLite(this._source, this._thresh); 
    81                         var r:Object = this._detector.detectMarkerLite(this._source, this._thresh); 
    82                         if (r != null) { 
    83                         //if (numDetected > 0) { 
    84                                 //trace(numDetected); 
    85                                 //for (var i:uint = 0; i < numDetected; i++) { 
    86                                         //var r:FLARMultiMarkerDetectorResult = this._detector.getResult(i); 
    87                                         trace(r.codeId,":",r.confidence); 
    88                                         //if (r.confidence <= this._confidence) { 
    89                                                 //continue; 
    90                                         //} 
     113                        var r:CubeMarkerDetectedResult = this._detector.detectMarkerLite(this._source, this._thresh); 
     114                        if (r != null && r.confidence > this._confidence) { 
     115                                        trace(r.markerDirection, r.confidence); 
     116                                        if (r.markerDirection == CubeMarkerDirection.FRONT) { 
     117                                                this._detector.getTransmationMatrix(r, this._resultMat); 
     118                                                this._baseNode.setTransformMatrix(this._resultMat); 
     119                                                this._view.startRendering(); 
     120                                        } 
    91121                                        var v:Array = r.square.sqvertex; 
    92122                                        g.lineStyle(2, colors[r.markerDirection]); 
     
    95125                                                g.lineTo(v[vi].x, v[vi].y); 
    96126                                        } 
    97                                 //} 
     127                        } else { 
     128                                this._view.stopRendering(); 
    98129                        } 
    99130                }