home *** CD-ROM | disk | FTP | other *** search
/ 404 Jogos / CLJG.iso / Esportes / CrossingCup.swf / scripts / __Packages / sandy / primitive / Plane3D.as < prev    next >
Encoding:
Text File  |  2007-12-11  |  3.7 KB  |  95 lines

  1. class sandy.primitive.Plane3D extends sandy.core.Object3D implements sandy.primitive.Primitive3D
  2. {
  3.    var _h;
  4.    var _lg;
  5.    var _q;
  6.    var _mode;
  7.    var aPoints;
  8.    var _aUv;
  9.    var aNormals;
  10.    function Plane3D(h, lg, q, mode)
  11.    {
  12.       super();
  13.       this._h = undefined != h ? Number(h) : 6;
  14.       this._lg = undefined != lg ? Number(lg) : 6;
  15.       this._q = !(undefined == q || q <= 0 || q > 10) ? Number(q) : 1;
  16.       this._mode = !(undefined == mode || mode != "tri" && mode != "quad") ? mode : "tri";
  17.       this.generate();
  18.    }
  19.    function generate(Void)
  20.    {
  21.       var _loc13_ = this._h / 2;
  22.       var _loc9_ = this._lg / 2;
  23.       var _loc14_ = this._h / this._q;
  24.       var _loc10_ = this._lg / this._q;
  25.       var _loc5_ = undefined;
  26.       var _loc12_ = undefined;
  27.       var _loc8_ = undefined;
  28.       var _loc11_ = undefined;
  29.       var _loc7_ = undefined;
  30.       var _loc2_ = undefined;
  31.       var _loc4_ = - _loc13_;
  32.       var _loc15_ = false;
  33.       var _loc6_ = undefined;
  34.       do
  35.       {
  36.          var _loc3_ = - _loc9_;
  37.          do
  38.          {
  39.             _loc5_ = new sandy.core.data.Vertex(_loc3_,0,_loc4_);
  40.             _loc12_ = this.aPoints.push(_loc5_) - 1;
  41.             _loc5_ = new sandy.core.data.Vertex(_loc3_ + _loc10_,0,_loc4_);
  42.             _loc8_ = this.aPoints.push(_loc5_) - 1;
  43.             _loc5_ = new sandy.core.data.Vertex(_loc3_ + _loc10_,0,_loc4_ + _loc14_);
  44.             _loc11_ = this.aPoints.push(_loc5_) - 1;
  45.             _loc5_ = new sandy.core.data.Vertex(_loc3_,0,_loc4_ + _loc14_);
  46.             _loc7_ = this.aPoints.push(_loc5_) - 1;
  47.             this.addUVCoordinate((_loc3_ + _loc9_) / this._lg,(_loc4_ + _loc13_) / this._h);
  48.             this.addUVCoordinate((_loc3_ + _loc9_ + _loc10_) / this._lg,(_loc4_ + _loc13_) / this._h);
  49.             this.addUVCoordinate((_loc3_ + _loc9_ + _loc10_) / this._lg,(_loc4_ + _loc13_ + _loc14_) / this._h);
  50.             this.addUVCoordinate((_loc3_ + _loc9_) / this._lg,(_loc4_ + _loc13_ + _loc14_) / this._h);
  51.             if(this._mode == "tri")
  52.             {
  53.                _loc2_ = new sandy.core.face.TriFace3D(this,this.aPoints[_loc12_],this.aPoints[_loc7_],this.aPoints[_loc8_]);
  54.                _loc2_.setUVCoordinates(this._aUv[_loc12_],this._aUv[_loc7_],this._aUv[_loc8_]);
  55.                this.addFace(_loc2_);
  56.                if(!_loc15_)
  57.                {
  58.                   _loc6_ = _loc2_.createNormale();
  59.                   this.aNormals.push(_loc6_);
  60.                   _loc15_ = true;
  61.                }
  62.                else
  63.                {
  64.                   _loc2_.setNormale(_loc6_);
  65.                }
  66.                _loc2_ = new sandy.core.face.TriFace3D(this,this.aPoints[_loc7_],this.aPoints[_loc11_],this.aPoints[_loc8_]);
  67.                _loc2_.setUVCoordinates(this._aUv[_loc7_],this._aUv[_loc11_],this._aUv[_loc8_]);
  68.                this.addFace(_loc2_);
  69.                _loc2_.setNormale(_loc6_);
  70.             }
  71.             else if(this._mode == "quad")
  72.             {
  73.                _loc2_ = new sandy.core.face.QuadFace3D(this,this.aPoints[_loc12_],this.aPoints[_loc7_],this.aPoints[_loc11_],this.aPoints[_loc8_]);
  74.                _loc2_.setUVCoordinates(this._aUv[_loc12_],this._aUv[_loc7_],this._aUv[_loc11_],this._aUv[_loc8_]);
  75.                this.addFace(_loc2_);
  76.                if(!_loc15_)
  77.                {
  78.                   _loc6_ = _loc2_.createNormale();
  79.                   this.aNormals.push(_loc6_);
  80.                   _loc15_ = true;
  81.                }
  82.                else
  83.                {
  84.                   _loc2_.setNormale(_loc6_);
  85.                }
  86.             }
  87.          }
  88.          while((_loc3_ += _loc10_) < _loc9_ - 1);
  89.          
  90.       }
  91.       while((_loc4_ += _loc14_) < _loc13_ - 1);
  92.       
  93.    }
  94. }
  95.