home *** CD-ROM | disk | FTP | other *** search
/ Computer Active 2010 August / CA08.iso / Multimedija / shufflr.air / ShufflrClient.swf / scripts / org / papervision3d / objects / primitives / Plane.as next >
Encoding:
Text File  |  2010-06-23  |  4.3 KB  |  115 lines

  1. package org.papervision3d.objects.primitives
  2. {
  3.    import org.papervision3d.Papervision3D;
  4.    import org.papervision3d.core.geom.*;
  5.    import org.papervision3d.core.geom.renderables.Triangle3D;
  6.    import org.papervision3d.core.geom.renderables.Vertex3D;
  7.    import org.papervision3d.core.math.NumberUV;
  8.    import org.papervision3d.core.proto.*;
  9.    
  10.    public class Plane extends TriangleMesh3D
  11.    {
  12.       public static var DEFAULT_SIZE:Number = 500;
  13.       
  14.       public static var DEFAULT_SCALE:Number = 1;
  15.       
  16.       public static var DEFAULT_SEGMENTS:Number = 1;
  17.       
  18.       public var segmentsH:Number;
  19.       
  20.       public var segmentsW:Number;
  21.       
  22.       public function Plane(param1:MaterialObject3D = null, param2:Number = 0, param3:Number = 0, param4:Number = 0, param5:Number = 0)
  23.       {
  24.          super(param1,new Array(),new Array(),null);
  25.          this.segmentsW = param4 || DEFAULT_SEGMENTS;
  26.          this.segmentsH = param5 || this.segmentsW;
  27.          var _loc6_:Number = DEFAULT_SCALE;
  28.          if(!param3)
  29.          {
  30.             if(param2)
  31.             {
  32.                _loc6_ = param2;
  33.             }
  34.             if(Boolean(param1) && Boolean(param1.bitmap))
  35.             {
  36.                param2 = param1.bitmap.width * _loc6_;
  37.                param3 = param1.bitmap.height * _loc6_;
  38.             }
  39.             else
  40.             {
  41.                param2 = DEFAULT_SIZE * _loc6_;
  42.                param3 = DEFAULT_SIZE * _loc6_;
  43.             }
  44.          }
  45.          this.buildPlane(param2,param3);
  46.       }
  47.       
  48.       private function buildPlane(param1:Number, param2:Number) : void
  49.       {
  50.          var _loc14_:NumberUV = null;
  51.          var _loc15_:NumberUV = null;
  52.          var _loc16_:NumberUV = null;
  53.          var _loc17_:int = 0;
  54.          var _loc18_:Number = NaN;
  55.          var _loc19_:Number = NaN;
  56.          var _loc20_:Vertex3D = null;
  57.          var _loc21_:Vertex3D = null;
  58.          var _loc22_:Vertex3D = null;
  59.          var _loc3_:Number = this.segmentsW;
  60.          var _loc4_:Number = this.segmentsH;
  61.          var _loc5_:Number = _loc3_ + 1;
  62.          var _loc6_:Number = _loc4_ + 1;
  63.          var _loc7_:Array = this.geometry.vertices;
  64.          var _loc8_:Array = this.geometry.faces;
  65.          var _loc9_:Number = param1 / 2;
  66.          var _loc10_:Number = param2 / 2;
  67.          var _loc11_:Number = param1 / _loc3_;
  68.          var _loc12_:Number = param2 / _loc4_;
  69.          var _loc13_:int = 0;
  70.          while(_loc13_ < _loc3_ + 1)
  71.          {
  72.             _loc17_ = 0;
  73.             while(_loc17_ < _loc6_)
  74.             {
  75.                _loc18_ = _loc13_ * _loc11_ - _loc9_;
  76.                _loc19_ = _loc17_ * _loc12_ - _loc10_;
  77.                _loc7_.push(new Vertex3D(_loc18_,_loc19_,0));
  78.                _loc17_++;
  79.             }
  80.             _loc13_++;
  81.          }
  82.          _loc13_ = 0;
  83.          while(_loc13_ < _loc3_)
  84.          {
  85.             _loc17_ = 0;
  86.             while(_loc17_ < _loc4_)
  87.             {
  88.                _loc20_ = _loc7_[_loc13_ * _loc6_ + _loc17_];
  89.                _loc21_ = _loc7_[_loc13_ * _loc6_ + (_loc17_ + 1)];
  90.                _loc22_ = _loc7_[(_loc13_ + 1) * _loc6_ + _loc17_];
  91.                _loc14_ = new NumberUV(_loc13_ / _loc3_,_loc17_ / _loc4_);
  92.                _loc15_ = new NumberUV(_loc13_ / _loc3_,(_loc17_ + 1) / _loc4_);
  93.                _loc16_ = new NumberUV((_loc13_ + 1) / _loc3_,_loc17_ / _loc4_);
  94.                _loc8_.push(new Triangle3D(this,[_loc20_,_loc22_,_loc21_],material,[_loc14_,_loc16_,_loc15_]));
  95.                _loc20_ = _loc7_[(_loc13_ + 1) * _loc6_ + (_loc17_ + 1)];
  96.                _loc21_ = _loc7_[(_loc13_ + 1) * _loc6_ + _loc17_];
  97.                _loc22_ = _loc7_[_loc13_ * _loc6_ + (_loc17_ + 1)];
  98.                _loc14_ = new NumberUV((_loc13_ + 1) / _loc3_,(_loc17_ + 1) / _loc4_);
  99.                _loc15_ = new NumberUV((_loc13_ + 1) / _loc3_,_loc17_ / _loc4_);
  100.                _loc16_ = new NumberUV(_loc13_ / _loc3_,(_loc17_ + 1) / _loc4_);
  101.                _loc8_.push(new Triangle3D(this,[_loc20_,_loc22_,_loc21_],material,[_loc14_,_loc16_,_loc15_]));
  102.                _loc17_++;
  103.             }
  104.             _loc13_++;
  105.          }
  106.          this.geometry.ready = true;
  107.          if(Papervision3D.useRIGHTHANDED)
  108.          {
  109.             this.geometry.flipFaces();
  110.          }
  111.       }
  112.    }
  113. }
  114.  
  115.