home *** CD-ROM | disk | FTP | other *** search
- class CTransform
- {
- var nearWidth;
- var nearHeight;
- var depth;
- var k;
- var nearDX;
- var nearDY;
- var nearCX = 275;
- var nearCY = 200;
- function CTransform(nearCX_, nearCY_)
- {
- this.nearCX = nearCX_;
- this.nearCY = nearCY_;
- }
- function init(nearWidth_, nearHeight_, depth_, k_)
- {
- this.nearWidth = nearWidth_;
- this.nearHeight = nearHeight_;
- this.depth = depth_;
- this.k = k_;
- this.nearDX = this.nearDY = 0;
- }
- function getScreenXY(x, y, z, point)
- {
- var _loc2_ = this.getKForZ(z);
- x = (x + this.nearDX) * _loc2_ + this.nearCX;
- y = (y + this.nearDY) * _loc2_ + this.nearCY;
- point.k = _loc2_ / (1 + 3 * z / this.depth);
- point.x = x;
- point.y = y;
- }
- function getKForZ(z)
- {
- return 1 - (1 - this.k) * z / this.depth;
- }
- function getWorldXFromScreen(x, k)
- {
- return (x - this.nearCX) / k - this.nearDX;
- }
- function getWorldYFromScreen(y, k)
- {
- return (y - this.nearCY) / k - this.nearDY;
- }
- }
-