チェンジセット 734

差分発生行の前後
無視リスト:
コミット日時:
2008/06/30 20:29:38 (2 ヶ月前)
コミッタ:
nutsu
ログメッセージ:

--

ファイル:

凡例:

変更無し
追加
削除
更新
コピー
移動
  • as3/Frocessing/trunk/src/frocessing/core/F5BitmapData.as

    r714 r734  
    7474                public override function endDraw():void 
    7575                { 
    76                         _bitmapData.draw( _shape, null, null, null, screenRect, _imageSmoothing ); 
     76                        _bitmapData.draw( _shape, null, null, null, screenRect, _bmpGc.smooth ); 
    7777                } 
    7878                 
  • as3/Frocessing/trunk/src/frocessing/core/F5BitmapData3D.as

    r714 r734  
    7373                { 
    7474                        super.endDraw(); 
    75                         _bitmapData.draw( _shape, null, null, null, screenRect, _imageSmoothing ); 
     75                        _bitmapData.draw( _shape, null, null, null, screenRect, _bmpGc.smooth ); 
    7676                } 
    7777                 
  • as3/Frocessing/trunk/src/frocessing/core/F5Graphics.as

    r714 r734  
    3434        import flash.display.BitmapData; 
    3535        import flash.display.Graphics; 
    36         import flash.geom.Matrix; 
    3736        import frocessing.color.ColorMode; 
    3837        import frocessing.color.FColorMode; 
     
    4241        import frocessing.color.FColorUtil; 
    4342        import frocessing.math.FMath; 
     43        import frocessing.geom.FMatrix2D; 
    4444         
    4545        /** 
     
    4747        *  
    4848        * @author nutsu 
    49         * @version 0.1.2 
     49        * @version 0.1.3 
    5050        */ 
    5151        public class F5Graphics extends GraphicsEx{ 
     
    9696                //Image 
    9797                protected var image_mode:int;   //@default CORNER 
    98                 protected var image_matrix:Matrix; 
    99                 protected var _imageSmoothing:Boolean; 
    10098                 
    10199                //Vertex 
     
    107105                protected var splineVertexCount:uint; 
    108106                 
     107                //Texture 
     108                protected var texture_mode:Boolean; 
     109                protected var vertexsU:Array; 
     110                protected var vertexsV:Array; 
     111                 
    109112                /** 
    110113                 * 新しい F5Graphics クラスのインスタンスを生成します. 
     
    137140                         
    138141                        image_mode     = CORNER; 
    139                         image_matrix   = new Matrix(); 
    140                         _imageSmoothing = true; 
     142                         
     143                        texture_mode   = false; 
    141144                } 
    142145                 
     
    164167                 * 描画を開始するときに実行します.このメソッドは、F5Graphics2D,F5Graphics3D など F5Graphicsの拡張クラスで意味を持ちます.  
    165168                 */ 
    166                 public function beginDraw():void { ; } 
     169                public function beginDraw():void { 
     170                        clear(); 
     171                } 
    167172                 
    168173                /** 
     
    428433                { 
    429434                        image_mode = mode; 
    430                 } 
    431                  
    432                 /** 
    433                  * 画像を描画する場合の Smoothing を設定します. 
    434                  */ 
    435                 public function imageSmoothing( smooth:Boolean ):void 
    436                 { 
    437                         _imageSmoothing = smooth; 
    438435                } 
    439436                 
     
    457454                public function image( img:BitmapData, x:Number, y:Number, w:Number = NaN, h:Number = NaN ):void 
    458455                { 
    459                         image_matrix.identity(); 
    460456                        if ( isNaN(w) || isNaN(h) ) 
    461457                        { 
     
    467463                                        y -= h * 0.5; 
    468464                                } 
    469                                 image_matrix.scale( 1, 1 ); 
    470465                        } 
    471466                        else 
     
    488483                                                break; 
    489484                                } 
    490                                 image_matrix.scale( w/img.width, h/img.height ); 
    491                         } 
    492                         image_matrix.translate( x, y ); 
    493                          
    494                         _gc.lineStyle(); 
    495                         beginBitmapFill( img, image_matrix, false, _imageSmoothing ); 
    496                         drawQuad( x, y, x + w, y, x + w, y + h, x, y + h ); 
    497                         endFill(); 
    498                         applyLineStyle(); 
     485                        } 
     486                        //_gc.lineStyle(); 
     487                        drawBitmap( img, x, y, w, h ); 
     488                        //applyLineStyle(); 
    499489                } 
    500490                 
     
    734724                        splineVertexX = []; 
    735725                        splineVertexY = []; 
     726                        vertexsU      = []; 
     727                        vertexsV      = []; 
    736728                         
    737729                        vertexCount = 0; 
     
    740732                        if ( shape_mode_polygon = (mode == POLYGON) ) 
    741733                                applyFill(); 
     734                } 
     735                 
     736                /** 
     737                 * vertex() で 描画する テクスチャ(画像) を設定します. 
     738                 * <p> 
     739                 * texture が適用されるのは、 beginShape() メソッドで以下のモードを指定した場合になります.<br/> 
     740                 * 「 TRIANGLES TRIANGLE_FAN TRIANGLE_STRIP QUADS QUAD_STRIP 」 
     741                 * </p> 
     742                 *  
     743                 * <p> 
     744                 * また、vertex() メソッドで、 u, v 値を指定する必要があります. 
     745                 * </p> 
     746                 */ 
     747                public function texture( textureData:BitmapData ):void 
     748                { 
     749                        _bmpGc.beginBitmap( textureData ); 
     750                        texture_mode = true; 
    742751                } 
    743752                 
     
    746755                 * @param       x 
    747756                 * @param       y 
    748                  */ 
    749                 public function vertex( x:Number, y:Number ):void 
     757                 * @param       u       texture を指定している場合、u 値を画像の x 座標で指定できます 
     758                 * @param       v       texture を指定している場合、v 値を画像の y 座標で指定できます 
     759                 */ 
     760                public function vertex( x:Number, y:Number, u:Number=0, v:Number=0 ):void 
    750761                { 
    751762                        vertexsX[vertexCount] = x; 
    752763                        vertexsY[vertexCount] = y; 
     764                        vertexsU[vertexCount] = u; 
     765                        vertexsV[vertexCount] = v; 
    753766                        vertexCount++; 
    754767                         
     
    776789                                                t1 = vertexCount - 2; 
    777790                                                t2 = vertexCount - 3; 
    778                                                 applyFill(); 
    779                                                 super.moveTo( vertexsX[t2], vertexsY[t2] ); 
    780                                                 super.lineTo( vertexsX[t1], vertexsY[t1] ); 
    781                                                 super.lineTo( x, y ); 
    782                                                 closePath(); 
    783                                                 applyFillEnd(); 
     791                                                if ( texture_mode ) 
     792                                                { 
     793                                                        super.moveTo( vertexsX[t2], vertexsY[t2] ); 
     794                                                        _bmpGc.drawTriangle( _startX, _startY, vertexsX[t1], vertexsY[t1], x, y, 
     795                                                                                                 vertexsU[t2], vertexsV[t2], vertexsU[t1], vertexsV[t1], u, v ); 
     796                                                } 
     797                                                else 
     798                                                { 
     799                                                        applyFill(); 
     800                                                        super.moveTo( vertexsX[t2], vertexsY[t2] ); 
     801                                                        $lineTo( vertexsX[t1], vertexsY[t1] ); 
     802                                                        $lineTo( x, y ); 
     803                                                        $closePath( _startX, _startY ); 
     804                                                        applyFillEnd(); 
     805                                                } 
    784806                                        } 
    785807                                        break; 
     
    788810                                        { 
    789811                                                t1 = vertexCount - 2; 
    790                                                 applyFill(); 
    791                                                 super.moveTo( vertexsX[0], vertexsY[0] ); 
    792                                                 super.lineTo( vertexsX[t1], vertexsY[t1] ); 
    793                                                 super.lineTo( x, y ); 
    794                                                 closePath(); 
    795                                                 applyFillEnd(); 
     812                                                if ( texture_mode ) 
     813                                                { 
     814                                                        super.moveTo( vertexsX[0], vertexsY[0] ); 
     815                                                        _bmpGc.drawTriangle( _startX, _startY, vertexsX[t1], vertexsY[t1], x, y, 
     816                                                                                                 vertexsU[0], vertexsV[0], vertexsU[t1], vertexsV[t1], u, v ); 
     817                                                } 
     818                                                else 
     819                                                { 
     820                                                        applyFill(); 
     821                                                        super.moveTo( vertexsX[0], vertexsY[0] ); 
     822                                                        $lineTo( vertexsX[t1], vertexsY[t1] ); 
     823                                                        $lineTo( x, y ); 
     824                                                        $closePath( _startX, _startY ); 
     825                                                        applyFillEnd(); 
     826                                                } 
    796827                                        } 
    797828                                        break; 
     
    801832                                                t1 = vertexCount - 2; 
    802833                                                t2 = vertexCount - 3; 
    803                                                 applyFill(); 
    804                                                 super.moveTo( vertexsX[t2], vertexsY[t2] ); 
    805                                                 super.lineTo( vertexsX[t1], vertexsY[t1] ); 
    806                                                 super.lineTo( x, y ); 
    807                                                 closePath(); 
    808                                                 applyFillEnd(); 
     834                                                if ( texture_mode ) 
     835                                                { 
     836                                                        super.moveTo( vertexsX[t2], vertexsY[t2] ); 
     837                                                        _bmpGc.drawTriangle( _startX, _startY, x, y, vertexsX[t1], vertexsY[t1], 
     838                                                                                                 vertexsU[t2], vertexsV[t2], u, v, vertexsU[t1], vertexsV[t1] ); 
     839                                                } 
     840                                                else 
     841                                                { 
     842                                                        applyFill(); 
     843                                                        super.moveTo( vertexsX[t2], vertexsY[t2] ); 
     844                                                        $lineTo( x, y ); 
     845                                                        $lineTo( vertexsX[t1], vertexsY[t1] ); 
     846                                                        $closePath( _startX, _startY ); 
     847                                                        applyFillEnd(); 
     848                                                } 
    809849                                        } 
    810850                                        break; 
     
    815855                                                t2 = vertexCount - 3; 
    816856                                                t3 = vertexCount - 4; 
    817                                                 applyFill(); 
    818                                                 super.moveTo( vertexsX[t3], vertexsY[t3] ); 
    819                                                 super.lineTo( vertexsX[t2], vertexsY[t2] ); 
    820                                                 super.lineTo( vertexsX[t1], vertexsY[t1] ); 
    821                                                 super.lineTo( x, y ); 
    822                                                 closePath(); 
    823                                                 applyFillEnd(); 
     857                                                if ( texture_mode ) 
     858                                                { 
     859                                                        _gc.lineStyle(); 
     860                                                        super.moveTo( vertexsX[t3], vertexsY[t3] ); 
     861                                                        _bmpGc.drawQuad( _startX, _startY, vertexsX[t2], vertexsY[t2], vertexsX[t1], vertexsY[t1], x, y, 
     862                                                                                         vertexsU[t3], vertexsV[t3], vertexsU[t2], vertexsV[t2], vertexsU[t1], vertexsV[t1], u, v ); 
     863                                                        if ( _stroke_do ) 
     864                                                        { 
     865                                                                applyLineStyle(); 
     866                                                                super.moveTo( vertexsX[t3], vertexsY[t3] ); 
     867                                                                $lineTo( vertexsX[t2], vertexsY[t2] ); 
     868                                                                $lineTo( vertexsX[t1], vertexsY[t1] ); 
     869                                                                $lineTo( x, y ); 
     870                                                                $closePath( _startX, _startY ); 
     871                                                        } 
     872                                                } 
     873                                                else 
     874                                                { 
     875                                                        applyFill(); 
     876                                                        super.moveTo( vertexsX[t3], vertexsY[t3] ); 
     877                                                        $lineTo( vertexsX[t2], vertexsY[t2] ); 
     878                                                        $lineTo( vertexsX[t1], vertexsY[t1] ); 
     879                                                        $lineTo( x, y ); 
     880                                                        $closePath( _startX, _startY ); 
     881                                                        applyFillEnd(); 
     882                                                } 
    824883                                        } 
    825884                                        break; 
     
    830889                                                t2 = vertexCount - 3; 
    831890                                                t3 = vertexCount - 4; 
    832                                                 applyFill(); 
    833                                                 super.moveTo( vertexsX[t3], vertexsY[t3] ); 
    834                                                 super.lineTo( vertexsX[t2], vertexsY[t2] ); 
    835                                                 super.lineTo( x, y ); 
    836                                                 super.lineTo( vertexsX[t1], vertexsY[t1] ); 
    837                                                 closePath(); 
    838                                                 applyFillEnd(); 
     891                                                if ( texture_mode ) 
     892                                                { 
     893                                                        _gc.lineStyle(); 
     894                                                        super.moveTo( vertexsX[t3], vertexsY[t3] ); 
     895                                                        _bmpGc.drawQuad( _startX, _startY, vertexsX[t2], vertexsY[t2], x, y, vertexsX[t1], vertexsY[t1], 
     896                                                                                         vertexsU[t3], vertexsV[t3], vertexsU[t2], vertexsV[t2], u, v, vertexsU[t1], vertexsV[t1] ); 
     897                                                        if ( _stroke_do ) 
     898                                                        { 
     899                                                                super.moveTo( vertexsX[t3], vertexsY[t3] ); 
     900                                                                $lineTo( vertexsX[t2], vertexsY[t2] ); 
     901                                                                $lineTo( x, y ); 
     902                                                                $lineTo( vertexsX[t1], vertexsY[t1] ); 
     903                                                                $closePath( _startX, _startY ); 
     904                                                        } 
     905                                                } 
     906                                                else 
     907                                                { 
     908                                                        applyFill(); 
     909                                                        super.moveTo( vertexsX[t3], vertexsY[t3] ); 
     910                                                        $lineTo( vertexsX[t2], vertexsY[t2] ); 
     911                                                        $lineTo( x, y ); 
     912                                                        $lineTo( vertexsX[t1], vertexsY[t1] ); 
     913                                                        $closePath( _startX, _startY ); 
     914                                                        applyFillEnd(); 
     915                                                } 
    839916                                        } 
    840917                                        break; 
     
    9231000                        shape_mode        = NONE_SHAPE; 
    9241001                        shape_mode_polygon = false; 
     1002                         
     1003                        if ( texture_mode ) 
     1004                        { 
     1005                                texture_mode = false; 
     1006                                _bmpGc.endBitmap(); 
     1007                        } 
    9251008                } 
    9261009                 
  • as3/Frocessing/trunk/src/frocessing/core/F5Graphics2D.as

    r714 r734  
    4242        *  
    4343        * @author nutsu 
    44         * @version 0.1.2 
     44        * @version 0.1.3 
    4545        */ 
    4646        public class F5Graphics2D extends F5Graphics { 
     
    254254                } 
    255255                 
    256                 //--------------------------------------------------------------------------------------------------- IMAGE 
    257                  
    258                 /** 
    259                  * @inheritDoc 
    260                  */ 
    261                 public override function beginBitmapFill(bitmap:BitmapData,matrix_:Matrix=null,repeat:Boolean=true,smooth:Boolean=false):void 
    262                 { 
    263                         matrix_.concat( _matrix ); 
    264                         _gc.beginBitmapFill( bitmap, matrix_, repeat, smooth ); 
    265                 } 
    266                  
    267256                //--------------------------------------------------------------------------------------------------- VERTEX 
    268257                 
     
    270259                 * @inheritDoc 
    271260                 */ 
    272                 public override function vertex( x:Number, y:Number ):void 
     261                public override function vertex( x:Number, y:Number, u:Number=0, v:Number=0 ):void 
    273262                { 
    274263                        super.vertex( x * a + y * c + tx, 
    275                                                   x * b + y * d + ty ); 
     264                                                  x * b + y * d + ty, 
     265                                                  u, v ); 
    276266                } 
    277267                 
     
    391381                                                   x * a + y * c + tx, 
    392382                                                   x * b + y * d + ty ); 
     383                } 
     384                 
     385                //--------------------------------------------------------------------------------------------------- BITMAP 
     386                 
     387                /** 
     388                 * @inheritDoc 
     389                 */ 
     390                public override function drawBitmap( bitmapdata:BitmapData, x:Number, y:Number, w:Number, h:Number ):void 
     391                { 
     392                        moveTo( x, y ); 
     393                        _bmpGc.beginBitmap( bitmapdata ); 
     394                        _bmpGc.drawBitmap( x, y, w, h, _matrix ); 
     395                        _bmpGc.endBitmap(); 
     396                } 
     397                 
     398                /** 
     399                 * @inheritDoc 
     400                 */ 
     401                public override function drawBitmapTriangle( bitmapdata:BitmapData, 
     402                                                                                        x0:Number, y0:Number, x1:Number, y1:Number, x2:Number, y2:Number, 
     403                                                                                        u0:Number, v0:Number, u1:Number, v1:Number, u2:Number, v2:Number ):void 
     404                { 
     405                        super.drawBitmapTriangle( bitmapdata, 
     406                                                                          screenX( x0, y0 ), screenY( x0, y0 ), 
     407                                                                          screenX( x1, y1 ), screenY( x1, y1 ), 
     408                                                                          screenX( x2, y2 ), screenY( x2, y2 ), 
     409                                                                          u0, v0, u1, v1, u2, v2 ); 
     410                } 
     411                 
     412                /** 
     413                 * @@inheritDoc 
     414                 */ 
     415                public override function drawBitmapQuad( bitmapdata:BitmapData, 
     416                                                                                x0:Number, y0:Number, x1:Number, y1:Number, x2:Number, y2:Number, x3:Number, y3:Number, 
     417                                                                                u0:Number=0, v0:Number=0, u1:Number=1, v1:Number=0, u2:Number=1, v2:Number=1, u3:Number=0, v3:Number=1 ):void 
     418                { 
     419                        super.drawBitmapQuad( bitmapdata, 
     420                                                                  screenX( x0, y0 ), screenY( x0, y0 ), 
     421                                                                  screenX( x1, y1 ), screenY( x1, y1 ), 
     422                                                                  screenX( x2, y2 ), screenY( x2, y2 ), 
     423                                                                  screenX( x3, y3 ), screenY( x3, y3 ), 
     424                                                                  u0, v0, u1, v1, u2, v2, u3, v3 ); 
     425                } 
     426                 
     427                //--------------------------------------------------------------------------------------------------- FILL STYLE 
     428                 
     429                /** 
     430                 * @inheritDoc 
     431                 */ 
     432                public override function beginBitmapFill(bitmap:BitmapData,matrix_:Matrix=null,repeat:Boolean=true,smooth:Boolean=false):void 
     433                { 
     434                        // apply transfrom 
     435                        if ( matrix_ ) 
     436                        { 
     437                                matrix_.concat( _matrix ); 
     438                                _gc.beginBitmapFill( bitmap, matrix_, repeat, smooth ); 
     439                        } 
     440                        else 
     441                        { 
     442                                _gc.beginBitmapFill( bitmap, _matrix, repeat, smooth ); 
     443                        } 
     444                } 
     445                 
     446                /** 
     447                 * @inheritDoc 
     448                 */ 
     449                public override function beginGradientFill(type:String, color:Array, alphas:Array, ratios:Array, matrix_:Matrix=null, spreadMethod:String="pad", interpolationMethod:String="rgb",focalPointRation:Number=0.0):void 
     450                { 
     451                        // apply transfrom 
     452                        if ( matrix_ ) 
     453                        { 
     454                                matrix_.concat( _matrix ); 
     455                                _gc.beginGradientFill( type, color, alphas, ratios, matrix_, spreadMethod, interpolationMethod, focalPointRation ); 
     456                        } 
     457                        else 
     458                        { 
     459                                _gc.beginGradientFill( type, color, alphas, ratios, _matrix, spreadMethod, interpolationMethod, focalPointRation ); 
     460                        } 
    393461                } 
    394462        } 
  • as3/Frocessing/trunk/src/frocessing/core/F5Graphics3D.as

    r714 r734  
    3434        import flash.display.BitmapData; 
    3535        import flash.display.Graphics; 
     36        import frocessing.f3d.F3DCamera; 
    3637        import frocessing.f3d.F3DRender; 
    3738        import frocessing.geom.FMatrix3D; 
    38         import frocessing.geom.Vector3D; 
    3939        import frocessing.math.FMath; 
     40        import frocessing.f3d.model.F3DModel; 
     41        import frocessing.f3d.model.F3DSphere; 
    4042         
    4143        /** 
     
    4345        *  
    4446        * @author nutsu 
    45         * @version 0.1.2 
     47        * @version 0.1.3 
    4648        */ 
    4749        public class F5Graphics3D extends F5Graphics { 
     
    6870                 
    6971                //Camera , Projection 
    70                 private var _cameraX:Number; 
    71                 private var _cameraY:Number; 
    72                 private var _cameraZ:Number; 
    73                 private var field_of_view:Number; 
    74                 private var camera_aspect:Number; 
    75                 private var p_left:Number; 
    76                 private var p_right:Number; 
    77                 private var p_bottom:Number; 
    78                 private var p_top:Number; 
    79                 private var z_near:Number; 
    80                 private var z_far:Number; 
     72                private var f_camera:F3DCamera; 
     73                private var camera_setting:Boolean; 
    8174                private var ortho_projection:Boolean; 
    82                  
    83                 private var camera_setting:Boolean; 
    84                 private var _cameraMatrix:FMatrix3D; 
    85                 private var _camera_tmp_matrix:FMatrix3D; 
    86                 private var _projMatrix:FMatrix3D; 
    8775                 
    8876                //Z Coordinates 
     
    10997                private var sprite2d_pers_height:Number; 
    11098                 
    111                  
    112                 /** 
    113                  *  
    114                  * @param       gc 
    115                  * @param       width_ 
    116                  * @param       height_ 
     99                /** 
     100                * 新しく F5Graphics3D のインスタンスを生成します. 
     101                 *  
     102                 * @param       gc             描画対象の Graphics 
     103                 * @param       width_ スクリーンの幅 
     104                 * @param       height_        スクリーンの高さ 
    117105                 */ 
    118106                public function F5Graphics3D( gc:Graphics, width_:Number, height_:Number ) 
     
    122110                        _background_do = false; 
    123111                         
     112                        // size 
     113                        _width      = width_; 
     114                        _height     = height_; 
     115                        half_width  = _width*0.5; 
     116                        half_height = _height * 0.5; 
     117                         
    124118                        // camrea and projection 
    125                         camera_setting  = false; 
    126                         _cameraMatrix   = new FMatrix3D(); 
    127                         _projMatrix     = new FMatrix3D(); 
     119                        camera_setting = false; 
     120                        f_camera       = new F3DCamera( _width, _height ); 
     121                         
     122                        // 3d rendrer 
     123                        render = new F3DRender( gc, half_width, half_height ); 
     124                        render.init(); 
    128125                         
    129126                        // transfrom init 
     
    131128                        _matrix_tmp  = []; 
    132129                         
    133                         // 
    134                         size( width_, height_ ); 
    135                          
    136                         // 3d rendrer 
    137                         render = new F3DRender( gc, width_*0.5, height_*0.5 ); 
    138                         render.init(); 
    139                          
    140130                        // init sphere 
    141131                        sphereDetail(12); 
    142132                } 
    143133                 
    144                 //--------------------------------------------------------------------------------------------------- OUT 
    145                  
    146                 /** 
    147                  *  
     134                /** 
     135                 * @inheritDoc 
     136                 */ 
     137                public override function size(width_:uint, height_:uint):void  
     138                { 
     139                        // init canvas size 
     140                        _width      = width_; 
     141                        _height     = height_; 
     142                        half_width  = _width*0.5; 
     143                        half_height = _height * 0.5; 
     144                         
     145                        // init camera and projection 
     146                        f_camera.setScreenSize( width_, height_ ); 
     147                         
     148                        // set render center coordinate 
     149                        render.setCenter( half_width, half_height ); 
     150                         
     151                        // reset transform 
     152                        resetMatrix(); 
     153                } 
     154                 
     155                //--------------------------------------------------------------------------------------------------- OUT TO RENDER 
     156                 
     157                /** 
     158                 * render clear and init 
    148159                 */ 
    149160                protected override function $clear():void 
     
    153164                 
    154165                /** 
    155                  *  
     166                 * render moveTo. start shape. 
    156167                 */ 
    157168                protected function $moveTo3d( x:Number, y:Number, z:Number ):void 
     
    162173                 
    163174                /** 
    164                  *  
     175                 * render lineTo 
    165176                 */ 
    166177                protected function $lineTo3d( x:Number, y:Number, z:Number ):void 
     
    170181                 
    171182                /** 
    172                  *  
     183                 * render curveTo 
    173184                 */ 
    174185                protected function $curveTo3d( cx:Number, cy:Number, cz:Number, x:Number, y:Number, z:Number ):void 
     
    178189                 
    179190                /**