home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
404 Jogos
/
CLJG.iso
/
Esportes
/
CrossingCup.swf
/
scripts
/
__Packages
/
sandy
/
skin
/
TextureSkin.as
< prev
Wrap
Text File
|
2007-12-11
|
3KB
|
104 lines
class sandy.skin.TextureSkin extends sandy.skin.BasicSkin implements sandy.skin.Skin
{
function TextureSkin(t)
{
super();
this.__set__texture(t);
this._p = new flash.geom.Point(0,0);
this._cmf = new flash.filters.ColorMatrixFilter();
}
function set texture(b)
{
this._texture = b;
this._w = b.width;
this._h = b.height;
this.broadcastEvent(this._eOnUpdate);
}
function get texture()
{
return this._texture;
}
function getType(Void)
{
return sandy.skin.SkinType.__get__TEXTURE();
}
function begin(f, mc)
{
var _loc5_ = f._va.sx;
var _loc4_ = f._va.sy;
var _loc16_ = f._vb.sx;
var _loc14_ = f._vb.sy;
var _loc15_ = f._vc.sx;
var _loc12_ = f._vc.sy;
if(!(this._w > 0 && this._h > 0))
{
return undefined;
}
var _loc18_ = {a:(_loc16_ - _loc5_) / this._w,b:(_loc14_ - _loc4_) / this._w,c:(_loc15_ - _loc5_) / this._h,d:(_loc12_ - _loc4_) / this._h,tx:_loc5_,ty:_loc4_};
if(undefined == f.tMat)
{
var _loc3_ = f.aUv;
var _loc7_ = _loc3_[0].u * this._w;
var _loc6_ = _loc3_[0].v * this._h;
var _loc23_ = _loc3_[1].u * this._w;
var _loc21_ = _loc3_[1].v * this._h;
var _loc22_ = _loc3_[2].u * this._w;
var _loc20_ = _loc3_[2].v * this._h;
var _loc11_ = new flash.geom.Matrix((_loc23_ - _loc7_) / this._w,(_loc21_ - _loc6_) / this._w,(_loc22_ - _loc7_) / this._h,(_loc20_ - _loc6_) / this._h,_loc7_,_loc6_);
_loc11_.invert();
f.tMat = _loc11_;
}
var _loc13_ = f.tMat;
var _loc9_ = this.__concat(_loc13_,_loc18_);
if(this._useLight == true)
{
this._tmp = this._texture.clone();
var _loc10_ = sandy.core.World3D.getInstance().getLight();
var _loc17_ = 0.01 * _loc10_.getPower();
var _loc19_ = _loc17_ - sandy.math.VectorMath.dot(_loc10_.dir,f.createNormale());
this._cmf.matrix = this.__getBrightnessTransform(_loc19_);
this._tmp.applyFilter(this._tmp,this._tmp.rectangle,this._p,this._cmf);
mc.filters = this._filters;
mc.beginBitmapFill(this._tmp,_loc9_,false,false);
}
else
{
mc.filters = this._filters;
mc.beginBitmapFill(this._texture,_loc9_,false,false);
}
}
function __getBrightnessTransform(scale)
{
var _loc2_ = scale;
var _loc1_ = 0;
return new Array(_loc2_,0,0,0,_loc1_,0,_loc2_,0,0,_loc1_,0,0,_loc2_,0,_loc1_,0,0,0,1,_loc1_);
}
function end(f, mc)
{
mc.endFill();
}
function toString(Void)
{
return "sandy.skin.TextureSkin";
}
function __concat(m1, m2)
{
var _loc2_ = {};
_loc2_.a = m1.a * m2.a;
_loc2_.d = m1.d * m2.d;
_loc2_.b = _loc2_.c = 0;
_loc2_.ty = m1.ty * m2.d + m2.ty;
_loc2_.tx = m1.tx * m2.a + m2.tx;
if(m1.b != 0 || m1.c != 0 || m2.b != 0 || m2.c != 0)
{
_loc2_.a += m1.b * m2.c;
_loc2_.d += m1.c * m2.b;
_loc2_.b += m1.a * m2.b + m1.b * m2.d;
_loc2_.c += m1.c * m2.a + m1.d * m2.c;
_loc2_.tx += m1.ty * m2.c;
_loc2_.ty += m1.tx * m2.b;
}
return _loc2_;
}
}