チェンジセット 4463

差分発生行の前後
無視リスト:
コミット日時:
2011/01/31 10:56:11 (1 年前)
コミッタ:
ericsoco
ログメッセージ:

updated NyARParam.changeScreenSize to work correctly with non-4:3 sources.

ファイル:

凡例:

変更無し
追加
削除
更新
コピー
移動
  • as3/FLARToolKit/trunk/libs/NyARToolKitAS3/src/jp/nyatla/nyartoolkit/as3/core/param/NyARParam.as

    r3322 r4463  
    11package jp.nyatla.nyartoolkit.as3.core.param 
    22{ 
    3         import jp.nyatla.nyartoolkit.as3.core.types.*; 
     3        import flash.utils.ByteArray; 
     4        import flash.utils.Endian; 
    45         
    5         import flash.utils.ByteArray; 
    6         import flash.utils.Endian;       
     6        import jp.nyatla.nyartoolkit.as3.core.types.*;   
    77         
    88        /** 
     
    5252                 * @return 
    5353                 *  
     54                 * ERICSOCO edit: 
     55                 * now responds to changes in both width and height (instead of just width). 
    5456                 */ 
    5557                public function changeScreenSize(i_xsize:int,i_ysize:int):void 
    5658                { 
    57                         var scale:Number = Number(i_xsize) / Number(this._screen_size.w);// scale = (double)xsize / (double)(source->xsize); 
    5859                        //スケールを変更 
    59                         this._dist.changeScale(scale); 
    60                         this._projection_matrix.changeScale(scale); 
     60                        var scaleX:Number = (i_xsize / this._screen_size.w); 
     61                        var scaleY:Number = (i_ysize / this._screen_size.h); 
     62                        var scaleXY:Number = (Math.sqrt(i_xsize*i_xsize+i_ysize*i_ysize) / 
     63                                                                        Math.sqrt(this._screen_size.w*this._screen_size.w + this._screen_size.h*this._screen_size.h)); 
     64                         
     65                        var distVector:Vector.<Number> = new Vector.<Number>(4, true); 
     66                        this._dist.getValue(distVector); 
     67                        distVector[0] *= scaleX; 
     68                        distVector[1] *= scaleY; 
     69                        distVector[2] /= (i_xsize * i_ysize); 
     70                        this._dist.setValue(distVector); 
     71                         
     72                        var projVector:Vector.<Number> = new Vector.<Number>(12, true); 
     73                        this._projection_matrix.getValue(projVector); 
     74                        projVector[0] *= scaleXY; 
     75                        projVector[1] *= scaleXY; 
     76                        projVector[2] *= scaleX; 
     77                        projVector[3] *= scaleXY; 
     78                        projVector[4] *= scaleXY; 
     79                        projVector[5] *= scaleXY; 
     80                        projVector[6] *= scaleY; 
     81                        projVector[7] *= scaleXY; 
     82                        this._projection_matrix.setValue(projVector); 
     83                         
    6184                        this._screen_size.w = i_xsize;// newparam->xsize = xsize; 
    6285                        this._screen_size.h = i_ysize;// newparam->ysize = ysize;