home *** CD-ROM | disk | FTP | other *** search
/ 600 Games / 600games.iso / Acao / germ_roundup.swf / scripts / __Packages / smashing / Viewport.as < prev    next >
Encoding:
Text File  |  2007-03-20  |  2.5 KB  |  81 lines

  1. class smashing.Viewport
  2. {
  3.    static var x;
  4.    static var halfWidth;
  5.    static var width;
  6.    static var halfHeight;
  7.    static var height;
  8.    static var centerX;
  9.    static var centerY;
  10.    static var y;
  11.    static var startX;
  12.    static var startY;
  13.    static var z = 0;
  14.    static var focal = 1300;
  15.    function Viewport()
  16.    {
  17.    }
  18.    static function init(nWidth, nHeight)
  19.    {
  20.       var _loc1_ = nWidth;
  21.       var _loc2_ = nHeight;
  22.       if(_loc1_ == undefined)
  23.       {
  24.          _loc1_ = Stage.width;
  25.       }
  26.       if(_loc2_ == undefined)
  27.       {
  28.          _loc2_ = Stage.height;
  29.       }
  30.       Stage.scaleMode = "showAll";
  31.       smashing.Viewport.x = _loc1_ / 2;
  32.       smashing.Viewport.y = _loc2_ / 2;
  33.       smashing.Viewport.halfWidth = _loc1_ / 2;
  34.       smashing.Viewport.halfHeight = _loc2_ / 2;
  35.       smashing.Viewport.width = _loc1_;
  36.       smashing.Viewport.height = _loc2_;
  37.       smashing.Viewport.centerX = smashing.Viewport.x;
  38.       smashing.Viewport.centerY = smashing.Viewport.y;
  39.       smashing.Viewport.startX = smashing.Viewport.x;
  40.       smashing.Viewport.startY = smashing.Viewport.y;
  41.       Stage.scaleMode = "noScale";
  42.    }
  43.    static function getPos(o)
  44.    {
  45.       var _loc2_ = o;
  46.       var _loc1_ = new smashing.RenderResult();
  47.       var xd = _loc2_.x - smashing.Viewport.x;
  48.       var yd = _loc2_.y - smashing.Viewport.y;
  49.       var _loc3_ = _loc2_.z - smashing.Viewport.z;
  50.       _loc1_.x = xd;
  51.       _loc2_.mpX = xd;
  52.       _loc1_.y = yd;
  53.       _loc2_.mpY = yd;
  54.       _loc1_.scale = smashing.Viewport.focal / (smashing.Viewport.focal + _loc3_);
  55.       _loc2_.mpZ = _loc3_;
  56.       return _loc1_;
  57.    }
  58.    static function localize(p)
  59.    {
  60.       var _loc1_ = p;
  61.       return new smashing.Point3D(_loc1_.x - smashing.Viewport.x,_loc1_.y - smashing.Viewport.y,_loc1_.z - smashing.Viewport.z);
  62.    }
  63.    static function getFocal(p)
  64.    {
  65.       var _loc3_ = p;
  66.       var _loc1_ = new smashing.Point3D(_loc3_.x - smashing.Viewport.x,_loc3_.y - smashing.Viewport.y,_loc3_.z - smashing.Viewport.z);
  67.       var _loc2_ = smashing.Viewport.focal / (smashing.Viewport.focal + _loc1_.z);
  68.       return new smashing.Point(_loc1_.x * _loc2_ + smashing.Viewport.centerX,_loc1_.y * _loc2_ + smashing.Viewport.centerY);
  69.    }
  70.    static function getScaleMod(zd)
  71.    {
  72.       return smashing.Viewport.focal / (smashing.Viewport.focal + zd);
  73.    }
  74.    static function reset()
  75.    {
  76.       smashing.Viewport.x = smashing.Viewport.startX;
  77.       smashing.Viewport.y = smashing.Viewport.startY;
  78.       smashing.Viewport.z = 0;
  79.    }
  80. }
  81.