home *** CD-ROM | disk | FTP | other *** search
- class smashing.Viewport
- {
- static var x;
- static var halfWidth;
- static var width;
- static var halfHeight;
- static var height;
- static var centerX;
- static var centerY;
- static var y;
- static var startX;
- static var startY;
- static var z = 0;
- static var focal = 1300;
- function Viewport()
- {
- }
- static function init(nWidth, nHeight)
- {
- var _loc1_ = nWidth;
- var _loc2_ = nHeight;
- if(_loc1_ == undefined)
- {
- _loc1_ = Stage.width;
- }
- if(_loc2_ == undefined)
- {
- _loc2_ = Stage.height;
- }
- Stage.scaleMode = "showAll";
- smashing.Viewport.x = _loc1_ / 2;
- smashing.Viewport.y = _loc2_ / 2;
- smashing.Viewport.halfWidth = _loc1_ / 2;
- smashing.Viewport.halfHeight = _loc2_ / 2;
- smashing.Viewport.width = _loc1_;
- smashing.Viewport.height = _loc2_;
- smashing.Viewport.centerX = smashing.Viewport.x;
- smashing.Viewport.centerY = smashing.Viewport.y;
- smashing.Viewport.startX = smashing.Viewport.x;
- smashing.Viewport.startY = smashing.Viewport.y;
- Stage.scaleMode = "noScale";
- }
- static function getPos(o)
- {
- var _loc2_ = o;
- var _loc1_ = new smashing.RenderResult();
- var xd = _loc2_.x - smashing.Viewport.x;
- var yd = _loc2_.y - smashing.Viewport.y;
- var _loc3_ = _loc2_.z - smashing.Viewport.z;
- _loc1_.x = xd;
- _loc2_.mpX = xd;
- _loc1_.y = yd;
- _loc2_.mpY = yd;
- _loc1_.scale = smashing.Viewport.focal / (smashing.Viewport.focal + _loc3_);
- _loc2_.mpZ = _loc3_;
- return _loc1_;
- }
- static function localize(p)
- {
- var _loc1_ = p;
- return new smashing.Point3D(_loc1_.x - smashing.Viewport.x,_loc1_.y - smashing.Viewport.y,_loc1_.z - smashing.Viewport.z);
- }
- static function getFocal(p)
- {
- var _loc3_ = p;
- var _loc1_ = new smashing.Point3D(_loc3_.x - smashing.Viewport.x,_loc3_.y - smashing.Viewport.y,_loc3_.z - smashing.Viewport.z);
- var _loc2_ = smashing.Viewport.focal / (smashing.Viewport.focal + _loc1_.z);
- return new smashing.Point(_loc1_.x * _loc2_ + smashing.Viewport.centerX,_loc1_.y * _loc2_ + smashing.Viewport.centerY);
- }
- static function getScaleMod(zd)
- {
- return smashing.Viewport.focal / (smashing.Viewport.focal + zd);
- }
- static function reset()
- {
- smashing.Viewport.x = smashing.Viewport.startX;
- smashing.Viewport.y = smashing.Viewport.startY;
- smashing.Viewport.z = 0;
- }
- }
-