Section 1
//AuxFunctions (caurina.transitions.AuxFunctions)
package caurina.transitions {
public class AuxFunctions {
public static function getObjectLength(_arg1:Object):uint{
var _local2:uint;
var _local3:String;
_local2 = 0;
for (_local3 in _arg1) {
_local2++;
};
return (_local2);
}
public static function numberToG(_arg1:Number):Number{
return (((_arg1 & 0xFF00) >> 8));
}
public static function numberToB(_arg1:Number):Number{
return ((_arg1 & 0xFF));
}
public static function numberToR(_arg1:Number):Number{
return (((_arg1 & 0xFF0000) >> 16));
}
public static function concatObjects(... _args):Object{
var _local2:Object;
var _local3:Object;
var _local4:int;
var _local5:String;
_local2 = {};
_local4 = 0;
while (_local4 < _args.length) {
_local3 = _args[_local4];
for (_local5 in _local3) {
if (_local3[_local5] == null){
delete _local2[_local5];
} else {
_local2[_local5] = _local3[_local5];
};
};
_local4++;
};
return (_local2);
}
}
}//package caurina.transitions
Section 2
//Equations (caurina.transitions.Equations)
package caurina.transitions {
public class Equations {
public function Equations(){
trace("Equations is a static class and should not be instantiated.");
}
public static function easeOutBounce(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
_arg1 = (_arg1 / _arg4);
if (_arg1 < (1 / 2.75)){
return (((_arg3 * ((7.5625 * _arg1) * _arg1)) + _arg2));
};
if (_arg1 < (2 / 2.75)){
_arg1 = (_arg1 - (1.5 / 2.75));
return (((_arg3 * (((7.5625 * _arg1) * _arg1) + 0.75)) + _arg2));
};
if (_arg1 < (2.5 / 2.75)){
_arg1 = (_arg1 - (2.25 / 2.75));
return (((_arg3 * (((7.5625 * _arg1) * _arg1) + 0.9375)) + _arg2));
};
_arg1 = (_arg1 - (2.625 / 2.75));
return (((_arg3 * (((7.5625 * _arg1) * _arg1) + 0.984375)) + _arg2));
}
public static function easeInOutElastic(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
var _local6:Number;
var _local7:Number;
var _local8:Number;
if (_arg1 == 0){
return (_arg2);
};
_arg1 = (_arg1 / (_arg4 / 2));
if (_arg1 == 2){
return ((_arg2 + _arg3));
};
_local6 = (((!(Boolean(_arg5))) || (isNaN(_arg5.period)))) ? (_arg4 * (0.3 * 1.5)) : _arg5.period;
_local8 = (((!(Boolean(_arg5))) || (isNaN(_arg5.amplitude)))) ? 0 : _arg5.amplitude;
if (((!(Boolean(_local8))) || ((_local8 < Math.abs(_arg3))))){
_local8 = _arg3;
_local7 = (_local6 / 4);
} else {
_local7 = ((_local6 / (2 * Math.PI)) * Math.asin((_arg3 / _local8)));
};
if (_arg1 < 1){
--_arg1;
return (((-0.5 * ((_local8 * Math.pow(2, (10 * _arg1))) * Math.sin(((((_arg1 * _arg4) - _local7) * (2 * Math.PI)) / _local6)))) + _arg2));
};
--_arg1;
return ((((((_local8 * Math.pow(2, (-10 * _arg1))) * Math.sin(((((_arg1 * _arg4) - _local7) * (2 * Math.PI)) / _local6))) * 0.5) + _arg3) + _arg2));
}
public static function easeInOutQuad(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
_arg1 = (_arg1 / (_arg4 / 2));
if (_arg1 < 1){
return (((((_arg3 / 2) * _arg1) * _arg1) + _arg2));
};
--_arg1;
return ((((-(_arg3) / 2) * ((_arg1 * (_arg1 - 2)) - 1)) + _arg2));
}
public static function easeInOutBounce(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
if (_arg1 < (_arg4 / 2)){
return (((easeInBounce((_arg1 * 2), 0, _arg3, _arg4) * 0.5) + _arg2));
};
return ((((easeOutBounce(((_arg1 * 2) - _arg4), 0, _arg3, _arg4) * 0.5) + (_arg3 * 0.5)) + _arg2));
}
public static function easeInOutBack(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
var _local6:Number;
_local6 = (((!(Boolean(_arg5))) || (isNaN(_arg5.overshoot)))) ? 1.70158 : _arg5.overshoot;
_arg1 = (_arg1 / (_arg4 / 2));
if (_arg1 < 1){
_local6 = (_local6 * 1.525);
return ((((_arg3 / 2) * ((_arg1 * _arg1) * (((_local6 + 1) * _arg1) - _local6))) + _arg2));
};
_arg1 = (_arg1 - 2);
_local6 = (_local6 * 1.525);
return ((((_arg3 / 2) * (((_arg1 * _arg1) * (((_local6 + 1) * _arg1) + _local6)) + 2)) + _arg2));
}
public static function easeOutInCubic(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
if (_arg1 < (_arg4 / 2)){
return (easeOutCubic((_arg1 * 2), _arg2, (_arg3 / 2), _arg4, _arg5));
};
return (easeInCubic(((_arg1 * 2) - _arg4), (_arg2 + (_arg3 / 2)), (_arg3 / 2), _arg4, _arg5));
}
public static function easeNone(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
return ((((_arg3 * _arg1) / _arg4) + _arg2));
}
public static function easeOutBack(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
var _local6:Number;
_local6 = (((!(Boolean(_arg5))) || (isNaN(_arg5.overshoot)))) ? 1.70158 : _arg5.overshoot;
_arg1 = ((_arg1 / _arg4) - 1);
return (((_arg3 * (((_arg1 * _arg1) * (((_local6 + 1) * _arg1) + _local6)) + 1)) + _arg2));
}
public static function easeInOutSine(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
return ((((-(_arg3) / 2) * (Math.cos(((Math.PI * _arg1) / _arg4)) - 1)) + _arg2));
}
public static function easeInBack(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
var _local6:Number;
_local6 = (((!(Boolean(_arg5))) || (isNaN(_arg5.overshoot)))) ? 1.70158 : _arg5.overshoot;
_arg1 = (_arg1 / _arg4);
return (((((_arg3 * _arg1) * _arg1) * (((_local6 + 1) * _arg1) - _local6)) + _arg2));
}
public static function easeInQuart(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
_arg1 = (_arg1 / _arg4);
return ((((((_arg3 * _arg1) * _arg1) * _arg1) * _arg1) + _arg2));
}
public static function easeOutInQuint(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
if (_arg1 < (_arg4 / 2)){
return (easeOutQuint((_arg1 * 2), _arg2, (_arg3 / 2), _arg4, _arg5));
};
return (easeInQuint(((_arg1 * 2) - _arg4), (_arg2 + (_arg3 / 2)), (_arg3 / 2), _arg4, _arg5));
}
public static function easeOutInBounce(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
if (_arg1 < (_arg4 / 2)){
return (easeOutBounce((_arg1 * 2), _arg2, (_arg3 / 2), _arg4, _arg5));
};
return (easeInBounce(((_arg1 * 2) - _arg4), (_arg2 + (_arg3 / 2)), (_arg3 / 2), _arg4, _arg5));
}
public static function init():void{
Tweener.registerTransition("easenone", easeNone);
Tweener.registerTransition("linear", easeNone);
Tweener.registerTransition("easeinquad", easeInQuad);
Tweener.registerTransition("easeoutquad", easeOutQuad);
Tweener.registerTransition("easeinoutquad", easeInOutQuad);
Tweener.registerTransition("easeoutinquad", easeOutInQuad);
Tweener.registerTransition("easeincubic", easeInCubic);
Tweener.registerTransition("easeoutcubic", easeOutCubic);
Tweener.registerTransition("easeinoutcubic", easeInOutCubic);
Tweener.registerTransition("easeoutincubic", easeOutInCubic);
Tweener.registerTransition("easeinquart", easeInQuart);
Tweener.registerTransition("easeoutquart", easeOutQuart);
Tweener.registerTransition("easeinoutquart", easeInOutQuart);
Tweener.registerTransition("easeoutinquart", easeOutInQuart);
Tweener.registerTransition("easeinquint", easeInQuint);
Tweener.registerTransition("easeoutquint", easeOutQuint);
Tweener.registerTransition("easeinoutquint", easeInOutQuint);
Tweener.registerTransition("easeoutinquint", easeOutInQuint);
Tweener.registerTransition("easeinsine", easeInSine);
Tweener.registerTransition("easeoutsine", easeOutSine);
Tweener.registerTransition("easeinoutsine", easeInOutSine);
Tweener.registerTransition("easeoutinsine", easeOutInSine);
Tweener.registerTransition("easeincirc", easeInCirc);
Tweener.registerTransition("easeoutcirc", easeOutCirc);
Tweener.registerTransition("easeinoutcirc", easeInOutCirc);
Tweener.registerTransition("easeoutincirc", easeOutInCirc);
Tweener.registerTransition("easeinexpo", easeInExpo);
Tweener.registerTransition("easeoutexpo", easeOutExpo);
Tweener.registerTransition("easeinoutexpo", easeInOutExpo);
Tweener.registerTransition("easeoutinexpo", easeOutInExpo);
Tweener.registerTransition("easeinelastic", easeInElastic);
Tweener.registerTransition("easeoutelastic", easeOutElastic);
Tweener.registerTransition("easeinoutelastic", easeInOutElastic);
Tweener.registerTransition("easeoutinelastic", easeOutInElastic);
Tweener.registerTransition("easeinback", easeInBack);
Tweener.registerTransition("easeoutback", easeOutBack);
Tweener.registerTransition("easeinoutback", easeInOutBack);
Tweener.registerTransition("easeoutinback", easeOutInBack);
Tweener.registerTransition("easeinbounce", easeInBounce);
Tweener.registerTransition("easeoutbounce", easeOutBounce);
Tweener.registerTransition("easeinoutbounce", easeInOutBounce);
Tweener.registerTransition("easeoutinbounce", easeOutInBounce);
}
public static function easeOutExpo(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
return (((_arg1)==_arg4) ? (_arg2 + _arg3) : (((_arg3 * 1.001) * (-(Math.pow(2, ((-10 * _arg1) / _arg4))) + 1)) + _arg2));
}
public static function easeOutInBack(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
if (_arg1 < (_arg4 / 2)){
return (easeOutBack((_arg1 * 2), _arg2, (_arg3 / 2), _arg4, _arg5));
};
return (easeInBack(((_arg1 * 2) - _arg4), (_arg2 + (_arg3 / 2)), (_arg3 / 2), _arg4, _arg5));
}
public static function easeInExpo(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
return (((_arg1)==0) ? _arg2 : (((_arg3 * Math.pow(2, (10 * ((_arg1 / _arg4) - 1)))) + _arg2) - (_arg3 * 0.001)));
}
public static function easeInCubic(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
_arg1 = (_arg1 / _arg4);
return (((((_arg3 * _arg1) * _arg1) * _arg1) + _arg2));
}
public static function easeInQuint(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
_arg1 = (_arg1 / _arg4);
return (((((((_arg3 * _arg1) * _arg1) * _arg1) * _arg1) * _arg1) + _arg2));
}
public static function easeInOutCirc(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
_arg1 = (_arg1 / (_arg4 / 2));
if (_arg1 < 1){
return ((((-(_arg3) / 2) * (Math.sqrt((1 - (_arg1 * _arg1))) - 1)) + _arg2));
};
_arg1 = (_arg1 - 2);
return ((((_arg3 / 2) * (Math.sqrt((1 - (_arg1 * _arg1))) + 1)) + _arg2));
}
public static function easeInQuad(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
_arg1 = (_arg1 / _arg4);
return ((((_arg3 * _arg1) * _arg1) + _arg2));
}
public static function easeInBounce(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
return (((_arg3 - easeOutBounce((_arg4 - _arg1), 0, _arg3, _arg4)) + _arg2));
}
public static function easeOutInExpo(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
if (_arg1 < (_arg4 / 2)){
return (easeOutExpo((_arg1 * 2), _arg2, (_arg3 / 2), _arg4, _arg5));
};
return (easeInExpo(((_arg1 * 2) - _arg4), (_arg2 + (_arg3 / 2)), (_arg3 / 2), _arg4, _arg5));
}
public static function easeOutQuart(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
_arg1 = ((_arg1 / _arg4) - 1);
return (((-(_arg3) * ((((_arg1 * _arg1) * _arg1) * _arg1) - 1)) + _arg2));
}
public static function easeInSine(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
return ((((-(_arg3) * Math.cos(((_arg1 / _arg4) * (Math.PI / 2)))) + _arg3) + _arg2));
}
public static function easeInOutQuart(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
_arg1 = (_arg1 / (_arg4 / 2));
if (_arg1 < 1){
return (((((((_arg3 / 2) * _arg1) * _arg1) * _arg1) * _arg1) + _arg2));
};
_arg1 = (_arg1 - 2);
return ((((-(_arg3) / 2) * ((((_arg1 * _arg1) * _arg1) * _arg1) - 2)) + _arg2));
}
public static function easeOutQuad(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
_arg1 = (_arg1 / _arg4);
return ((((-(_arg3) * _arg1) * (_arg1 - 2)) + _arg2));
}
public static function easeOutInElastic(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
if (_arg1 < (_arg4 / 2)){
return (easeOutElastic((_arg1 * 2), _arg2, (_arg3 / 2), _arg4, _arg5));
};
return (easeInElastic(((_arg1 * 2) - _arg4), (_arg2 + (_arg3 / 2)), (_arg3 / 2), _arg4, _arg5));
}
public static function easeInElastic(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
var _local6:Number;
var _local7:Number;
var _local8:Number;
if (_arg1 == 0){
return (_arg2);
};
_arg1 = (_arg1 / _arg4);
if (_arg1 == 1){
return ((_arg2 + _arg3));
};
_local6 = (((!(Boolean(_arg5))) || (isNaN(_arg5.period)))) ? (_arg4 * 0.3) : _arg5.period;
_local8 = (((!(Boolean(_arg5))) || (isNaN(_arg5.amplitude)))) ? 0 : _arg5.amplitude;
if (((!(Boolean(_local8))) || ((_local8 < Math.abs(_arg3))))){
_local8 = _arg3;
_local7 = (_local6 / 4);
} else {
_local7 = ((_local6 / (2 * Math.PI)) * Math.asin((_arg3 / _local8)));
};
--_arg1;
return ((-(((_local8 * Math.pow(2, (10 * _arg1))) * Math.sin(((((_arg1 * _arg4) - _local7) * (2 * Math.PI)) / _local6)))) + _arg2));
}
public static function easeOutCubic(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
_arg1 = ((_arg1 / _arg4) - 1);
return (((_arg3 * (((_arg1 * _arg1) * _arg1) + 1)) + _arg2));
}
public static function easeOutQuint(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
_arg1 = ((_arg1 / _arg4) - 1);
return (((_arg3 * (((((_arg1 * _arg1) * _arg1) * _arg1) * _arg1) + 1)) + _arg2));
}
public static function easeOutInQuad(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
if (_arg1 < (_arg4 / 2)){
return (easeOutQuad((_arg1 * 2), _arg2, (_arg3 / 2), _arg4, _arg5));
};
return (easeInQuad(((_arg1 * 2) - _arg4), (_arg2 + (_arg3 / 2)), (_arg3 / 2), _arg4, _arg5));
}
public static function easeOutSine(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
return (((_arg3 * Math.sin(((_arg1 / _arg4) * (Math.PI / 2)))) + _arg2));
}
public static function easeInOutCubic(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
_arg1 = (_arg1 / (_arg4 / 2));
if (_arg1 < 1){
return ((((((_arg3 / 2) * _arg1) * _arg1) * _arg1) + _arg2));
};
_arg1 = (_arg1 - 2);
return ((((_arg3 / 2) * (((_arg1 * _arg1) * _arg1) + 2)) + _arg2));
}
public static function easeInOutQuint(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
_arg1 = (_arg1 / (_arg4 / 2));
if (_arg1 < 1){
return ((((((((_arg3 / 2) * _arg1) * _arg1) * _arg1) * _arg1) * _arg1) + _arg2));
};
_arg1 = (_arg1 - 2);
return ((((_arg3 / 2) * (((((_arg1 * _arg1) * _arg1) * _arg1) * _arg1) + 2)) + _arg2));
}
public static function easeInCirc(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
_arg1 = (_arg1 / _arg4);
return (((-(_arg3) * (Math.sqrt((1 - (_arg1 * _arg1))) - 1)) + _arg2));
}
public static function easeOutInSine(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
if (_arg1 < (_arg4 / 2)){
return (easeOutSine((_arg1 * 2), _arg2, (_arg3 / 2), _arg4, _arg5));
};
return (easeInSine(((_arg1 * 2) - _arg4), (_arg2 + (_arg3 / 2)), (_arg3 / 2), _arg4, _arg5));
}
public static function easeInOutExpo(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
if (_arg1 == 0){
return (_arg2);
};
if (_arg1 == _arg4){
return ((_arg2 + _arg3));
};
_arg1 = (_arg1 / (_arg4 / 2));
if (_arg1 < 1){
return (((((_arg3 / 2) * Math.pow(2, (10 * (_arg1 - 1)))) + _arg2) - (_arg3 * 0.0005)));
};
--_arg1;
return (((((_arg3 / 2) * 1.0005) * (-(Math.pow(2, (-10 * _arg1))) + 2)) + _arg2));
}
public static function easeOutElastic(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
var _local6:Number;
var _local7:Number;
var _local8:Number;
if (_arg1 == 0){
return (_arg2);
};
_arg1 = (_arg1 / _arg4);
if (_arg1 == 1){
return ((_arg2 + _arg3));
};
_local6 = (((!(Boolean(_arg5))) || (isNaN(_arg5.period)))) ? (_arg4 * 0.3) : _arg5.period;
_local8 = (((!(Boolean(_arg5))) || (isNaN(_arg5.amplitude)))) ? 0 : _arg5.amplitude;
if (((!(Boolean(_local8))) || ((_local8 < Math.abs(_arg3))))){
_local8 = _arg3;
_local7 = (_local6 / 4);
} else {
_local7 = ((_local6 / (2 * Math.PI)) * Math.asin((_arg3 / _local8)));
};
return (((((_local8 * Math.pow(2, (-10 * _arg1))) * Math.sin(((((_arg1 * _arg4) - _local7) * (2 * Math.PI)) / _local6))) + _arg3) + _arg2));
}
public static function easeOutCirc(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
_arg1 = ((_arg1 / _arg4) - 1);
return (((_arg3 * Math.sqrt((1 - (_arg1 * _arg1)))) + _arg2));
}
public static function easeOutInQuart(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
if (_arg1 < (_arg4 / 2)){
return (easeOutQuart((_arg1 * 2), _arg2, (_arg3 / 2), _arg4, _arg5));
};
return (easeInQuart(((_arg1 * 2) - _arg4), (_arg2 + (_arg3 / 2)), (_arg3 / 2), _arg4, _arg5));
}
public static function easeOutInCirc(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Object=null):Number{
if (_arg1 < (_arg4 / 2)){
return (easeOutCirc((_arg1 * 2), _arg2, (_arg3 / 2), _arg4, _arg5));
};
return (easeInCirc(((_arg1 * 2) - _arg4), (_arg2 + (_arg3 / 2)), (_arg3 / 2), _arg4, _arg5));
}
}
}//package caurina.transitions
Section 3
//PropertyInfoObj (caurina.transitions.PropertyInfoObj)
package caurina.transitions {
public class PropertyInfoObj {
public var originalValueComplete:Object;
public var modifierParameters:Array;
public var isSpecialProperty:Boolean;
public var hasModifier:Boolean;
public var valueComplete:Number;
public var extra:Object;
public var valueStart:Number;
public var modifierFunction:Function;
public var arrayIndex:Number;
public function PropertyInfoObj(_arg1:Number, _arg2:Number, _arg3:Object, _arg4:Number, _arg5:Object, _arg6:Boolean, _arg7:Function, _arg8:Array){
valueStart = _arg1;
valueComplete = _arg2;
originalValueComplete = _arg3;
arrayIndex = _arg4;
extra = _arg5;
isSpecialProperty = _arg6;
hasModifier = Boolean(_arg7);
modifierFunction = _arg7;
modifierParameters = _arg8;
}
public function toString():String{
var _local1:String;
_local1 = "\n[PropertyInfoObj ";
_local1 = (_local1 + ("valueStart:" + String(valueStart)));
_local1 = (_local1 + ", ");
_local1 = (_local1 + ("valueComplete:" + String(valueComplete)));
_local1 = (_local1 + ", ");
_local1 = (_local1 + ("originalValueComplete:" + String(originalValueComplete)));
_local1 = (_local1 + ", ");
_local1 = (_local1 + ("arrayIndex:" + String(arrayIndex)));
_local1 = (_local1 + ", ");
_local1 = (_local1 + ("extra:" + String(extra)));
_local1 = (_local1 + ", ");
_local1 = (_local1 + ("isSpecialProperty:" + String(isSpecialProperty)));
_local1 = (_local1 + ", ");
_local1 = (_local1 + ("hasModifier:" + String(hasModifier)));
_local1 = (_local1 + ", ");
_local1 = (_local1 + ("modifierFunction:" + String(modifierFunction)));
_local1 = (_local1 + ", ");
_local1 = (_local1 + ("modifierParameters:" + String(modifierParameters)));
_local1 = (_local1 + "]\n");
return (_local1);
}
public function clone():PropertyInfoObj{
var _local1:PropertyInfoObj;
_local1 = new PropertyInfoObj(valueStart, valueComplete, originalValueComplete, arrayIndex, extra, isSpecialProperty, modifierFunction, modifierParameters);
return (_local1);
}
}
}//package caurina.transitions
Section 4
//SpecialProperty (caurina.transitions.SpecialProperty)
package caurina.transitions {
public class SpecialProperty {
public var parameters:Array;
public var preProcess:Function;
public var setValue:Function;
public var getValue:Function;
public function SpecialProperty(_arg1:Function, _arg2:Function, _arg3:Array=null, _arg4:Function=null){
getValue = _arg1;
setValue = _arg2;
parameters = _arg3;
preProcess = _arg4;
}
public function toString():String{
var _local1:String;
_local1 = "";
_local1 = (_local1 + "[SpecialProperty ");
_local1 = (_local1 + ("getValue:" + String(getValue)));
_local1 = (_local1 + ", ");
_local1 = (_local1 + ("setValue:" + String(setValue)));
_local1 = (_local1 + ", ");
_local1 = (_local1 + ("parameters:" + String(parameters)));
_local1 = (_local1 + ", ");
_local1 = (_local1 + ("preProcess:" + String(preProcess)));
_local1 = (_local1 + "]");
return (_local1);
}
}
}//package caurina.transitions
Section 5
//SpecialPropertyModifier (caurina.transitions.SpecialPropertyModifier)
package caurina.transitions {
public class SpecialPropertyModifier {
public var getValue:Function;
public var modifyValues:Function;
public function SpecialPropertyModifier(_arg1:Function, _arg2:Function){
modifyValues = _arg1;
getValue = _arg2;
}
public function toString():String{
var _local1:String;
_local1 = "";
_local1 = (_local1 + "[SpecialPropertyModifier ");
_local1 = (_local1 + ("modifyValues:" + String(modifyValues)));
_local1 = (_local1 + ", ");
_local1 = (_local1 + ("getValue:" + String(getValue)));
_local1 = (_local1 + "]");
return (_local1);
}
}
}//package caurina.transitions
Section 6
//SpecialPropertySplitter (caurina.transitions.SpecialPropertySplitter)
package caurina.transitions {
public class SpecialPropertySplitter {
public var parameters:Array;
public var splitValues:Function;
public function SpecialPropertySplitter(_arg1:Function, _arg2:Array){
splitValues = _arg1;
parameters = _arg2;
}
public function toString():String{
var _local1:String;
_local1 = "";
_local1 = (_local1 + "[SpecialPropertySplitter ");
_local1 = (_local1 + ("splitValues:" + String(splitValues)));
_local1 = (_local1 + ", ");
_local1 = (_local1 + ("parameters:" + String(parameters)));
_local1 = (_local1 + "]");
return (_local1);
}
}
}//package caurina.transitions
Section 7
//Tweener (caurina.transitions.Tweener)
package caurina.transitions {
import flash.display.*;
import flash.events.*;
import flash.utils.*;
public class Tweener {
private static var _timeScale:Number = 1;
private static var _currentTimeFrame:Number;
private static var _specialPropertySplitterList:Object;
private static var _engineExists:Boolean = false;
private static var _specialPropertyModifierList:Object;
private static var _currentTime:Number;
private static var _tweenList:Array;
private static var _specialPropertyList:Object;
private static var _transitionList:Object;
private static var _inited:Boolean = false;
private static var __tweener_controller__:MovieClip;
public function Tweener(){
trace("Tweener is a static class and should not be instantiated.");
}
public static function registerSpecialPropertyModifier(_arg1:String, _arg2:Function, _arg3:Function):void{
var _local4:SpecialPropertyModifier;
if (!_inited){
init();
};
_local4 = new SpecialPropertyModifier(_arg2, _arg3);
_specialPropertyModifierList[_arg1] = _local4;
}
public static function registerSpecialProperty(_arg1:String, _arg2:Function, _arg3:Function, _arg4:Array=null, _arg5:Function=null):void{
var _local6:SpecialProperty;
if (!_inited){
init();
};
_local6 = new SpecialProperty(_arg2, _arg3, _arg4, _arg5);
_specialPropertyList[_arg1] = _local6;
}
public static function init(... _args):void{
_inited = true;
_transitionList = new Object();
Equations.init();
_specialPropertyList = new Object();
_specialPropertyModifierList = new Object();
_specialPropertySplitterList = new Object();
}
private static function updateTweens():Boolean{
var _local1:int;
if (_tweenList.length == 0){
return (false);
};
_local1 = 0;
while (_local1 < _tweenList.length) {
if ((((_tweenList[_local1] == undefined)) || (!(_tweenList[_local1].isPaused)))){
if (!updateTweenByIndex(_local1)){
removeTweenByIndex(_local1);
};
if (_tweenList[_local1] == null){
removeTweenByIndex(_local1, true);
_local1--;
};
};
_local1++;
};
return (true);
}
public static function addCaller(_arg1:Object=null, _arg2:Object=null):Boolean{
var _local3:Number;
var _local4:Array;
var _local5:Object;
var _local6:Number;
var _local7:Number;
var _local8:Function;
var _local9:TweenListObj;
var _local10:Number;
var _local11:String;
if (!Boolean(_arg1)){
return (false);
};
if ((_arg1 is Array)){
_local4 = _arg1.concat();
} else {
_local4 = [_arg1];
};
_local5 = _arg2;
if (!_inited){
init();
};
if (((!(_engineExists)) || (!(Boolean(__tweener_controller__))))){
startEngine();
};
_local6 = (isNaN(_local5.time)) ? 0 : _local5.time;
_local7 = (isNaN(_local5.delay)) ? 0 : _local5.delay;
if (typeof(_local5.transition) == "string"){
_local11 = _local5.transition.toLowerCase();
_local8 = _transitionList[_local11];
} else {
_local8 = _local5.transition;
};
if (!Boolean(_local8)){
_local8 = _transitionList["easeoutexpo"];
};
_local3 = 0;
while (_local3 < _local4.length) {
if (_local5.useFrames == true){
_local9 = new TweenListObj(_local4[_local3], (_currentTimeFrame + (_local7 / _timeScale)), (_currentTimeFrame + ((_local7 + _local6) / _timeScale)), true, _local8, _local5.transitionParams);
} else {
_local9 = new TweenListObj(_local4[_local3], (_currentTime + ((_local7 * 1000) / _timeScale)), (_currentTime + (((_local7 * 1000) + (_local6 * 1000)) / _timeScale)), false, _local8, _local5.transitionParams);
};
_local9.properties = null;
_local9.onStart = _local5.onStart;
_local9.onUpdate = _local5.onUpdate;
_local9.onComplete = _local5.onComplete;
_local9.onOverwrite = _local5.onOverwrite;
_local9.onStartParams = _local5.onStartParams;
_local9.onUpdateParams = _local5.onUpdateParams;
_local9.onCompleteParams = _local5.onCompleteParams;
_local9.onOverwriteParams = _local5.onOverwriteParams;
_local9.onStartScope = _local5.onStartScope;
_local9.onUpdateScope = _local5.onUpdateScope;
_local9.onCompleteScope = _local5.onCompleteScope;
_local9.onOverwriteScope = _local5.onOverwriteScope;
_local9.onErrorScope = _local5.onErrorScope;
_local9.isCaller = true;
_local9.count = _local5.count;
_local9.waitFrames = _local5.waitFrames;
_tweenList.push(_local9);
if ((((_local6 == 0)) && ((_local7 == 0)))){
_local10 = (_tweenList.length - 1);
updateTweenByIndex(_local10);
removeTweenByIndex(_local10);
};
_local3++;
};
return (true);
}
public static function pauseAllTweens():Boolean{
var _local1:Boolean;
var _local2:uint;
if (!Boolean(_tweenList)){
return (false);
};
_local1 = false;
_local2 = 0;
while (_local2 < _tweenList.length) {
pauseTweenByIndex(_local2);
_local1 = true;
_local2++;
};
return (_local1);
}
public static function removeTweens(_arg1:Object, ... _args):Boolean{
var _local3:Array;
var _local4:uint;
var _local5:SpecialPropertySplitter;
var _local6:Array;
var _local7:uint;
_local3 = new Array();
_local4 = 0;
while (_local4 < _args.length) {
if ((((typeof(_args[_local4]) == "string")) && ((_local3.indexOf(_args[_local4]) == -1)))){
if (_specialPropertySplitterList[_args[_local4]]){
_local5 = _specialPropertySplitterList[_args[_local4]];
_local6 = _local5.splitValues(_arg1, null);
_local7 = 0;
while (_local7 < _local6.length) {
_local3.push(_local6[_local7].name);
_local7++;
};
} else {
_local3.push(_args[_local4]);
};
};
_local4++;
};
return (affectTweens(removeTweenByIndex, _arg1, _local3));
}
public static function splitTweens(_arg1:Number, _arg2:Array):uint{
var _local3:TweenListObj;
var _local4:TweenListObj;
var _local5:uint;
var _local6:String;
var _local7:Boolean;
_local3 = _tweenList[_arg1];
_local4 = _local3.clone(false);
_local5 = 0;
while (_local5 < _arg2.length) {
_local6 = _arg2[_local5];
if (Boolean(_local3.properties[_local6])){
_local3.properties[_local6] = undefined;
delete _local3.properties[_local6];
};
_local5++;
};
for (_local6 in _local4.properties) {
_local7 = false;
_local5 = 0;
while (_local5 < _arg2.length) {
if (_arg2[_local5] == _local6){
_local7 = true;
break;
};
_local5++;
};
if (!_local7){
_local4.properties[_local6] = undefined;
delete _local4.properties[_local6];
};
};
_tweenList.push(_local4);
return ((_tweenList.length - 1));
}
public static function updateFrame():void{
_currentTimeFrame++;
}
public static function resumeTweenByIndex(_arg1:Number):Boolean{
var _local2:TweenListObj;
var _local3:Number;
_local2 = _tweenList[_arg1];
if ((((_local2 == null)) || (!(_local2.isPaused)))){
return (false);
};
_local3 = getCurrentTweeningTime(_local2);
_local2.timeStart = (_local2.timeStart + (_local3 - _local2.timePaused));
_local2.timeComplete = (_local2.timeComplete + (_local3 - _local2.timePaused));
_local2.timePaused = undefined;
_local2.isPaused = false;
return (true);
}
public static function getVersion():String{
return ("AS3 1.31.74");
}
public static function onEnterFrame(_arg1:Event):void{
var _local2:Boolean;
updateTime();
updateFrame();
_local2 = false;
_local2 = updateTweens();
if (!_local2){
stopEngine();
};
}
public static function updateTime():void{
_currentTime = getTimer();
}
private static function updateTweenByIndex(_arg1:Number):Boolean{
var tTweening:TweenListObj;
var isOver:Boolean;
var mustUpdate:Boolean;
var nv:Number;
var t:Number;
var b:Number;
var c:Number;
var d:Number;
var pName:String;
var eventScope:Object;
var tScope:Object;
var cTime:Number;
var tProperty:Object;
var pv:Number;
var i = _arg1;
tTweening = _tweenList[i];
if ((((tTweening == null)) || (!(Boolean(tTweening.scope))))){
return (false);
};
isOver = false;
cTime = getCurrentTweeningTime(tTweening);
if (cTime >= tTweening.timeStart){
tScope = tTweening.scope;
if (tTweening.isCaller){
do {
t = (((tTweening.timeComplete - tTweening.timeStart) / tTweening.count) * (tTweening.timesCalled + 1));
b = tTweening.timeStart;
c = (tTweening.timeComplete - tTweening.timeStart);
d = (tTweening.timeComplete - tTweening.timeStart);
nv = tTweening.transition(t, b, c, d);
} while (!(cTime >= nv));
} else {
mustUpdate = (((((tTweening.skipUpdates < 1)) || (!(tTweening.skipUpdates)))) || ((tTweening.updatesSkipped >= tTweening.skipUpdates)));
if (cTime >= tTweening.timeComplete){
isOver = true;
mustUpdate = true;
};
if (!tTweening.hasStarted){
if (Boolean(tTweening.onStart)){
eventScope = (Boolean(tTweening.onStartScope)) ? tTweening.onStartScope : tScope;
try {
tTweening.onStart.apply(eventScope, tTweening.onStartParams);
} catch(e2:Error) {
handleError(tTweening, e2, "onStart");
};
};
for (pName in tTweening.properties) {
if (tTweening.properties[pName].isSpecialProperty){
if (Boolean(_specialPropertyList[pName].preProcess)){
tTweening.properties[pName].valueComplete = _specialPropertyList[pName].preProcess(tScope, _specialPropertyList[pName].parameters, tTweening.properties[pName].originalValueComplete, tTweening.properties[pName].extra);
};
pv = _specialPropertyList[pName].getValue(tScope, _specialPropertyList[pName].parameters, tTweening.properties[pName].extra);
} else {
pv = tScope[pName];
};
tTweening.properties[pName].valueStart = (isNaN(pv)) ? tTweening.properties[pName].valueComplete : pv;
};
mustUpdate = true;
tTweening.hasStarted = true;
};
if (mustUpdate){
for (pName in tTweening.properties) {
tProperty = tTweening.properties[pName];
if (isOver){
nv = tProperty.valueComplete;
} else {
if (tProperty.hasModifier){
t = (cTime - tTweening.timeStart);
d = (tTweening.timeComplete - tTweening.timeStart);
nv = tTweening.transition(t, 0, 1, d, tTweening.transitionParams);
nv = tProperty.modifierFunction(tProperty.valueStart, tProperty.valueComplete, nv, tProperty.modifierParameters);
} else {
t = (cTime - tTweening.timeStart);
b = tProperty.valueStart;
c = (tProperty.valueComplete - tProperty.valueStart);
d = (tTweening.timeComplete - tTweening.timeStart);
nv = tTweening.transition(t, b, c, d, tTweening.transitionParams);
};
};
if (tTweening.rounded){
nv = Math.round(nv);
};
if (tProperty.isSpecialProperty){
_specialPropertyList[pName].setValue(tScope, nv, _specialPropertyList[pName].parameters, tTweening.properties[pName].extra);
} else {
tScope[pName] = nv;
};
};
tTweening.updatesSkipped = 0;
if (Boolean(tTweening.onUpdate)){
eventScope = (Boolean(tTweening.onUpdateScope)) ? tTweening.onUpdateScope : tScope;
try {
tTweening.onUpdate.apply(eventScope, tTweening.onUpdateParams);
} catch(e3:Error) {
handleError(tTweening, e3, "onUpdate");
};
};
} else {
tTweening.updatesSkipped++;
};
};
if (((isOver) && (Boolean(tTweening.onComplete)))){
eventScope = (Boolean(tTweening.onCompleteScope)) ? tTweening.onCompleteScope : tScope;
try {
tTweening.onComplete.apply(eventScope, tTweening.onCompleteParams);
} catch(e4:Error) {
handleError(tTweening, e4, "onComplete");
};
};
return (!(isOver));
};
return (true);
}
public static function setTimeScale(_arg1:Number):void{
var _local2:Number;
var _local3:Number;
if (isNaN(_arg1)){
_arg1 = 1;
};
if (_arg1 < 1E-5){
_arg1 = 1E-5;
};
if (_arg1 != _timeScale){
if (_tweenList != null){
_local2 = 0;
while (_local2 < _tweenList.length) {
_local3 = getCurrentTweeningTime(_tweenList[_local2]);
_tweenList[_local2].timeStart = (_local3 - (((_local3 - _tweenList[_local2].timeStart) * _timeScale) / _arg1));
_tweenList[_local2].timeComplete = (_local3 - (((_local3 - _tweenList[_local2].timeComplete) * _timeScale) / _arg1));
if (_tweenList[_local2].timePaused != undefined){
_tweenList[_local2].timePaused = (_local3 - (((_local3 - _tweenList[_local2].timePaused) * _timeScale) / _arg1));
};
_local2++;
};
};
_timeScale = _arg1;
};
}
public static function resumeAllTweens():Boolean{
var _local1:Boolean;
var _local2:uint;
if (!Boolean(_tweenList)){
return (false);
};
_local1 = false;
_local2 = 0;
while (_local2 < _tweenList.length) {
resumeTweenByIndex(_local2);
_local1 = true;
_local2++;
};
return (_local1);
}
private static function handleError(_arg1:TweenListObj, _arg2:Error, _arg3:String):void{
var eventScope:Object;
var pTweening = _arg1;
var pError = _arg2;
var pCallBackName = _arg3;
if (((Boolean(pTweening.onError)) && ((pTweening.onError is Function)))){
eventScope = (Boolean(pTweening.onErrorScope)) ? pTweening.onErrorScope : pTweening.scope;
try {
pTweening.onError.apply(eventScope, [pTweening.scope, pError]);
} catch(metaError:Error) {
printError(((((String(pTweening.scope) + " raised an error while executing the 'onError' handler. Original error:\n ") + pError.getStackTrace()) + "\nonError error: ") + metaError.getStackTrace()));
};
} else {
if (!Boolean(pTweening.onError)){
printError(((((String(pTweening.scope) + " raised an error while executing the '") + pCallBackName) + "'handler. \n") + pError.getStackTrace()));
};
};
}
private static function startEngine():void{
_engineExists = true;
_tweenList = new Array();
__tweener_controller__ = new MovieClip();
__tweener_controller__.addEventListener(Event.ENTER_FRAME, Tweener.onEnterFrame);
_currentTimeFrame = 0;
updateTime();
}
public static function removeAllTweens():Boolean{
var _local1:Boolean;
var _local2:uint;
if (!Boolean(_tweenList)){
return (false);
};
_local1 = false;
_local2 = 0;
while (_local2 < _tweenList.length) {
removeTweenByIndex(_local2);
_local1 = true;
_local2++;
};
return (_local1);
}
public static function addTween(_arg1:Object=null, _arg2:Object=null):Boolean{
var _local3:Number;
var _local4:Number;
var _local5:String;
var _local6:Array;
var _local7:Object;
var _local8:Number;
var _local9:Number;
var _local10:Array;
var _local11:Object;
var _local12:Object;
var _local13:Function;
var _local14:Object;
var _local15:TweenListObj;
var _local16:Number;
var _local17:Array;
var _local18:Array;
var _local19:Array;
var _local20:String;
if (!Boolean(_arg1)){
return (false);
};
if ((_arg1 is Array)){
_local6 = _arg1.concat();
} else {
_local6 = [_arg1];
};
_local7 = TweenListObj.makePropertiesChain(_arg2);
if (!_inited){
init();
};
if (((!(_engineExists)) || (!(Boolean(__tweener_controller__))))){
startEngine();
};
_local8 = (isNaN(_local7.time)) ? 0 : _local7.time;
_local9 = (isNaN(_local7.delay)) ? 0 : _local7.delay;
_local10 = new Array();
_local11 = {time:true, delay:true, useFrames:true, skipUpdates:true, transition:true, transitionParams:true, onStart:true, onUpdate:true, onComplete:true, onOverwrite:true, onError:true, rounded:true, onStartParams:true, onUpdateParams:true, onCompleteParams:true, onOverwriteParams:true, onStartScope:true, onUpdateScope:true, onCompleteScope:true, onOverwriteScope:true, onErrorScope:true};
_local12 = new Object();
for (_local5 in _local7) {
if (!_local11[_local5]){
if (_specialPropertySplitterList[_local5]){
_local17 = _specialPropertySplitterList[_local5].splitValues(_local7[_local5], _specialPropertySplitterList[_local5].parameters);
_local3 = 0;
while (_local3 < _local17.length) {
if (_specialPropertySplitterList[_local17[_local3].name]){
_local18 = _specialPropertySplitterList[_local17[_local3].name].splitValues(_local17[_local3].value, _specialPropertySplitterList[_local17[_local3].name].parameters);
_local4 = 0;
while (_local4 < _local18.length) {
_local10[_local18[_local4].name] = {valueStart:undefined, valueComplete:_local18[_local4].value, arrayIndex:_local18[_local4].arrayIndex, isSpecialProperty:false};
_local4++;
};
} else {
_local10[_local17[_local3].name] = {valueStart:undefined, valueComplete:_local17[_local3].value, arrayIndex:_local17[_local3].arrayIndex, isSpecialProperty:false};
};
_local3++;
};
} else {
if (_specialPropertyModifierList[_local5] != undefined){
_local19 = _specialPropertyModifierList[_local5].modifyValues(_local7[_local5]);
_local3 = 0;
while (_local3 < _local19.length) {
_local12[_local19[_local3].name] = {modifierParameters:_local19[_local3].parameters, modifierFunction:_specialPropertyModifierList[_local5].getValue};
_local3++;
};
} else {
_local10[_local5] = {valueStart:undefined, valueComplete:_local7[_local5]};
};
};
};
};
for (_local5 in _local10) {
if (_specialPropertyList[_local5] != undefined){
_local10[_local5].isSpecialProperty = true;
} else {
if (_local6[0][_local5] == undefined){
printError((((("The property '" + _local5) + "' doesn't seem to be a normal object property of ") + String(_local6[0])) + " or a registered special property."));
};
};
};
for (_local5 in _local12) {
if (_local10[_local5] != undefined){
_local10[_local5].modifierParameters = _local12[_local5].modifierParameters;
_local10[_local5].modifierFunction = _local12[_local5].modifierFunction;
};
};
if (typeof(_local7.transition) == "string"){
_local20 = _local7.transition.toLowerCase();
_local13 = _transitionList[_local20];
} else {
_local13 = _local7.transition;
};
if (!Boolean(_local13)){
_local13 = _transitionList["easeoutexpo"];
};
_local3 = 0;
while (_local3 < _local6.length) {
_local14 = new Object();
for (_local5 in _local10) {
_local14[_local5] = new PropertyInfoObj(_local10[_local5].valueStart, _local10[_local5].valueComplete, _local10[_local5].valueComplete, _local10[_local5].arrayIndex, {}, _local10[_local5].isSpecialProperty, _local10[_local5].modifierFunction, _local10[_local5].modifierParameters);
};
if (_local7.useFrames == true){
_local15 = new TweenListObj(_local6[_local3], (_currentTimeFrame + (_local9 / _timeScale)), (_currentTimeFrame + ((_local9 + _local8) / _timeScale)), true, _local13, _local7.transitionParams);
} else {
_local15 = new TweenListObj(_local6[_local3], (_currentTime + ((_local9 * 1000) / _timeScale)), (_currentTime + (((_local9 * 1000) + (_local8 * 1000)) / _timeScale)), false, _local13, _local7.transitionParams);
};
_local15.properties = _local14;
_local15.onStart = _local7.onStart;
_local15.onUpdate = _local7.onUpdate;
_local15.onComplete = _local7.onComplete;
_local15.onOverwrite = _local7.onOverwrite;
_local15.onError = _local7.onError;
_local15.onStartParams = _local7.onStartParams;
_local15.onUpdateParams = _local7.onUpdateParams;
_local15.onCompleteParams = _local7.onCompleteParams;
_local15.onOverwriteParams = _local7.onOverwriteParams;
_local15.onStartScope = _local7.onStartScope;
_local15.onUpdateScope = _local7.onUpdateScope;
_local15.onCompleteScope = _local7.onCompleteScope;
_local15.onOverwriteScope = _local7.onOverwriteScope;
_local15.onErrorScope = _local7.onErrorScope;
_local15.rounded = _local7.rounded;
_local15.skipUpdates = _local7.skipUpdates;
removeTweensByTime(_local15.scope, _local15.properties, _local15.timeStart, _local15.timeComplete);
_tweenList.push(_local15);
if ((((_local8 == 0)) && ((_local9 == 0)))){
_local16 = (_tweenList.length - 1);
updateTweenByIndex(_local16);
removeTweenByIndex(_local16);
};
_local3++;
};
return (true);
}
public static function registerTransition(_arg1:String, _arg2:Function):void{
if (!_inited){
init();
};
_transitionList[_arg1] = _arg2;
}
public static function printError(_arg1:String):void{
trace(("## [Tweener] Error: " + _arg1));
}
private static function affectTweens(_arg1:Function, _arg2:Object, _arg3:Array):Boolean{
var _local4:Boolean;
var _local5:uint;
var _local6:Array;
var _local7:uint;
var _local8:uint;
var _local9:uint;
_local4 = false;
if (!Boolean(_tweenList)){
return (false);
};
_local5 = 0;
while (_local5 < _tweenList.length) {
if (((_tweenList[_local5]) && ((_tweenList[_local5].scope == _arg2)))){
if (_arg3.length == 0){
_arg1(_local5);
_local4 = true;
} else {
_local6 = new Array();
_local7 = 0;
while (_local7 < _arg3.length) {
if (Boolean(_tweenList[_local5].properties[_arg3[_local7]])){
_local6.push(_arg3[_local7]);
};
_local7++;
};
if (_local6.length > 0){
_local8 = AuxFunctions.getObjectLength(_tweenList[_local5].properties);
if (_local8 == _local6.length){
_arg1(_local5);
_local4 = true;
} else {
_local9 = splitTweens(_local5, _local6);
_arg1(_local9);
_local4 = true;
};
};
};
};
_local5++;
};
return (_local4);
}
public static function getTweens(_arg1:Object):Array{
var _local2:uint;
var _local3:String;
var _local4:Array;
if (!Boolean(_tweenList)){
return ([]);
};
_local4 = new Array();
_local2 = 0;
while (_local2 < _tweenList.length) {
if (((Boolean(_tweenList[_local2])) && ((_tweenList[_local2].scope == _arg1)))){
for (_local3 in _tweenList[_local2].properties) {
_local4.push(_local3);
};
};
_local2++;
};
return (_local4);
}
public static function isTweening(_arg1:Object):Boolean{
var _local2:uint;
if (!Boolean(_tweenList)){
return (false);
};
_local2 = 0;
while (_local2 < _tweenList.length) {
if (((Boolean(_tweenList[_local2])) && ((_tweenList[_local2].scope == _arg1)))){
return (true);
};
_local2++;
};
return (false);
}
public static function pauseTweenByIndex(_arg1:Number):Boolean{
var _local2:TweenListObj;
_local2 = _tweenList[_arg1];
if ((((_local2 == null)) || (_local2.isPaused))){
return (false);
};
_local2.timePaused = getCurrentTweeningTime(_local2);
_local2.isPaused = true;
return (true);
}
public static function getCurrentTweeningTime(_arg1:Object):Number{
return ((_arg1.useFrames) ? _currentTimeFrame : _currentTime);
}
public static function getTweenCount(_arg1:Object):Number{
var _local2:uint;
var _local3:Number;
if (!Boolean(_tweenList)){
return (0);
};
_local3 = 0;
_local2 = 0;
while (_local2 < _tweenList.length) {
if (((Boolean(_tweenList[_local2])) && ((_tweenList[_local2].scope == _arg1)))){
_local3 = (_local3 + AuxFunctions.getObjectLength(_tweenList[_local2].properties));
};
_local2++;
};
return (_local3);
}
private static function stopEngine():void{
_engineExists = false;
_tweenList = null;
_currentTime = 0;
_currentTimeFrame = 0;
__tweener_controller__.removeEventListener(Event.ENTER_FRAME, Tweener.onEnterFrame);
__tweener_controller__ = null;
}
public static function removeTweensByTime(_arg1:Object, _arg2:Object, _arg3:Number, _arg4:Number):Boolean{
var removed:Boolean;
var removedLocally:Boolean;
var i:uint;
var tl:uint;
var pName:String;
var eventScope:Object;
var p_scope = _arg1;
var p_properties = _arg2;
var p_timeStart = _arg3;
var p_timeComplete = _arg4;
removed = false;
tl = _tweenList.length;
i = 0;
while (i < tl) {
if (((Boolean(_tweenList[i])) && ((p_scope == _tweenList[i].scope)))){
if ((((p_timeComplete > _tweenList[i].timeStart)) && ((p_timeStart < _tweenList[i].timeComplete)))){
removedLocally = false;
for (pName in _tweenList[i].properties) {
if (Boolean(p_properties[pName])){
if (Boolean(_tweenList[i].onOverwrite)){
eventScope = (Boolean(_tweenList[i].onOverwriteScope)) ? _tweenList[i].onOverwriteScope : _tweenList[i].scope;
try {
_tweenList[i].onOverwrite.apply(eventScope, _tweenList[i].onOverwriteParams);
} catch(e:Error) {
handleError(_tweenList[i], e, "onOverwrite");
};
};
_tweenList[i].properties[pName] = undefined;
delete _tweenList[i].properties[pName];
removedLocally = true;
removed = true;
};
};
if (removedLocally){
if (AuxFunctions.getObjectLength(_tweenList[i].properties) == 0){
removeTweenByIndex(i);
};
};
};
};
i = (i + 1);
};
return (removed);
}
public static function registerSpecialPropertySplitter(_arg1:String, _arg2:Function, _arg3:Array=null):void{
var _local4:SpecialPropertySplitter;
if (!_inited){
init();
};
_local4 = new SpecialPropertySplitter(_arg2, _arg3);
_specialPropertySplitterList[_arg1] = _local4;
}
public static function removeTweenByIndex(_arg1:Number, _arg2:Boolean=false):Boolean{
_tweenList[_arg1] = null;
if (_arg2){
_tweenList.splice(_arg1, 1);
};
return (true);
}
public static function resumeTweens(_arg1:Object, ... _args):Boolean{
var _local3:Array;
var _local4:uint;
_local3 = new Array();
_local4 = 0;
while (_local4 < _args.length) {
if ((((typeof(_args[_local4]) == "string")) && ((_local3.indexOf(_args[_local4]) == -1)))){
_local3.push(_args[_local4]);
};
_local4++;
};
return (affectTweens(resumeTweenByIndex, _arg1, _local3));
}
public static function pauseTweens(_arg1:Object, ... _args):Boolean{
var _local3:Array;
var _local4:uint;
_local3 = new Array();
_local4 = 0;
while (_local4 < _args.length) {
if ((((typeof(_args[_local4]) == "string")) && ((_local3.indexOf(_args[_local4]) == -1)))){
_local3.push(_args[_local4]);
};
_local4++;
};
return (affectTweens(pauseTweenByIndex, _arg1, _local3));
}
}
}//package caurina.transitions
Section 8
//TweenListObj (caurina.transitions.TweenListObj)
package caurina.transitions {
public class TweenListObj {
public var onUpdate:Function;
public var useFrames:Boolean;
public var hasStarted:Boolean;
public var onOverwriteParams:Array;
public var timeStart:Number;
public var count:Number;
public var timeComplete:Number;
public var onStartParams:Array;
public var onUpdateScope:Object;
public var rounded:Boolean;
public var onUpdateParams:Array;
public var properties:Object;
public var onComplete:Function;
public var transitionParams:Object;
public var updatesSkipped:Number;
public var onStart:Function;
public var onOverwriteScope:Object;
public var skipUpdates:Number;
public var onStartScope:Object;
public var scope:Object;
public var transition:Function;
public var timePaused:Number;
public var onCompleteParams:Array;
public var timesCalled:Number;
public var isCaller:Boolean;
public var onError:Function;
public var onErrorScope:Object;
public var onOverwrite:Function;
public var isPaused:Boolean;
public var waitFrames:Boolean;
public var onCompleteScope:Object;
public function TweenListObj(_arg1:Object, _arg2:Number, _arg3:Number, _arg4:Boolean, _arg5:Function, _arg6:Object){
scope = _arg1;
timeStart = _arg2;
timeComplete = _arg3;
useFrames = _arg4;
transition = _arg5;
transitionParams = _arg6;
properties = new Object();
isPaused = false;
timePaused = undefined;
isCaller = false;
updatesSkipped = 0;
timesCalled = 0;
skipUpdates = 0;
hasStarted = false;
}
public function clone(_arg1:Boolean):TweenListObj{
var _local2:TweenListObj;
var _local3:String;
_local2 = new TweenListObj(scope, timeStart, timeComplete, useFrames, transition, transitionParams);
_local2.properties = new Array();
for (_local3 in properties) {
_local2.properties[_local3] = properties[_local3].clone();
};
_local2.skipUpdates = skipUpdates;
_local2.updatesSkipped = updatesSkipped;
if (!_arg1){
_local2.onStart = onStart;
_local2.onUpdate = onUpdate;
_local2.onComplete = onComplete;
_local2.onOverwrite = onOverwrite;
_local2.onError = onError;
_local2.onStartParams = onStartParams;
_local2.onUpdateParams = onUpdateParams;
_local2.onCompleteParams = onCompleteParams;
_local2.onOverwriteParams = onOverwriteParams;
_local2.onStartScope = onStartScope;
_local2.onUpdateScope = onUpdateScope;
_local2.onCompleteScope = onCompleteScope;
_local2.onOverwriteScope = onOverwriteScope;
_local2.onErrorScope = onErrorScope;
};
_local2.rounded = rounded;
_local2.isPaused = isPaused;
_local2.timePaused = timePaused;
_local2.isCaller = isCaller;
_local2.count = count;
_local2.timesCalled = timesCalled;
_local2.waitFrames = waitFrames;
_local2.hasStarted = hasStarted;
return (_local2);
}
public function toString():String{
var _local1:String;
var _local2:Boolean;
var _local3:String;
_local1 = "\n[TweenListObj ";
_local1 = (_local1 + ("scope:" + String(scope)));
_local1 = (_local1 + ", properties:");
_local2 = true;
for (_local3 in properties) {
if (!_local2){
_local1 = (_local1 + ",");
};
_local1 = (_local1 + ("[name:" + properties[_local3].name));
_local1 = (_local1 + (",valueStart:" + properties[_local3].valueStart));
_local1 = (_local1 + (",valueComplete:" + properties[_local3].valueComplete));
_local1 = (_local1 + "]");
_local2 = false;
};
_local1 = (_local1 + (", timeStart:" + String(timeStart)));
_local1 = (_local1 + (", timeComplete:" + String(timeComplete)));
_local1 = (_local1 + (", useFrames:" + String(useFrames)));
_local1 = (_local1 + (", transition:" + String(transition)));
_local1 = (_local1 + (", transitionParams:" + String(transitionParams)));
if (skipUpdates){
_local1 = (_local1 + (", skipUpdates:" + String(skipUpdates)));
};
if (updatesSkipped){
_local1 = (_local1 + (", updatesSkipped:" + String(updatesSkipped)));
};
if (Boolean(onStart)){
_local1 = (_local1 + (", onStart:" + String(onStart)));
};
if (Boolean(onUpdate)){
_local1 = (_local1 + (", onUpdate:" + String(onUpdate)));
};
if (Boolean(onComplete)){
_local1 = (_local1 + (", onComplete:" + String(onComplete)));
};
if (Boolean(onOverwrite)){
_local1 = (_local1 + (", onOverwrite:" + String(onOverwrite)));
};
if (Boolean(onError)){
_local1 = (_local1 + (", onError:" + String(onError)));
};
if (onStartParams){
_local1 = (_local1 + (", onStartParams:" + String(onStartParams)));
};
if (onUpdateParams){
_local1 = (_local1 + (", onUpdateParams:" + String(onUpdateParams)));
};
if (onCompleteParams){
_local1 = (_local1 + (", onCompleteParams:" + String(onCompleteParams)));
};
if (onOverwriteParams){
_local1 = (_local1 + (", onOverwriteParams:" + String(onOverwriteParams)));
};
if (onStartScope){
_local1 = (_local1 + (", onStartScope:" + String(onStartScope)));
};
if (onUpdateScope){
_local1 = (_local1 + (", onUpdateScope:" + String(onUpdateScope)));
};
if (onCompleteScope){
_local1 = (_local1 + (", onCompleteScope:" + String(onCompleteScope)));
};
if (onOverwriteScope){
_local1 = (_local1 + (", onOverwriteScope:" + String(onOverwriteScope)));
};
if (onErrorScope){
_local1 = (_local1 + (", onErrorScope:" + String(onErrorScope)));
};
if (rounded){
_local1 = (_local1 + (", rounded:" + String(rounded)));
};
if (isPaused){
_local1 = (_local1 + (", isPaused:" + String(isPaused)));
};
if (timePaused){
_local1 = (_local1 + (", timePaused:" + String(timePaused)));
};
if (isCaller){
_local1 = (_local1 + (", isCaller:" + String(isCaller)));
};
if (count){
_local1 = (_local1 + (", count:" + String(count)));
};
if (timesCalled){
_local1 = (_local1 + (", timesCalled:" + String(timesCalled)));
};
if (waitFrames){
_local1 = (_local1 + (", waitFrames:" + String(waitFrames)));
};
if (hasStarted){
_local1 = (_local1 + (", hasStarted:" + String(hasStarted)));
};
_local1 = (_local1 + "]\n");
return (_local1);
}
public static function makePropertiesChain(_arg1:Object):Object{
var _local2:Object;
var _local3:Object;
var _local4:Object;
var _local5:Object;
var _local6:Number;
var _local7:Number;
var _local8:Number;
_local2 = _arg1.base;
if (_local2){
_local3 = {};
if ((_local2 is Array)){
_local4 = [];
_local8 = 0;
while (_local8 < _local2.length) {
_local4.push(_local2[_local8]);
_local8++;
};
} else {
_local4 = [_local2];
};
_local4.push(_arg1);
_local6 = _local4.length;
_local7 = 0;
while (_local7 < _local6) {
if (_local4[_local7]["base"]){
_local5 = AuxFunctions.concatObjects(makePropertiesChain(_local4[_local7]["base"]), _local4[_local7]);
} else {
_local5 = _local4[_local7];
};
_local3 = AuxFunctions.concatObjects(_local3, _local5);
_local7++;
};
if (_local3["base"]){
delete _local3["base"];
};
return (_local3);
//unresolved jump
};
return (_arg1);
}
}
}//package caurina.transitions
Section 9
//AdLoader (CPMStar.AdLoader)
package CPMStar {
import flash.display.*;
import flash.events.*;
import flash.net.*;
import flash.system.*;
public class AdLoader extends Sprite {
private var contentspotid:String;
private var cpmstarLoader:Loader;
public function AdLoader(_arg1:String){
this.contentspotid = _arg1;
addEventListener(Event.ADDED, addedHandler);
}
private function addedHandler(_arg1:Event):void{
var _local2:String;
var _local3:DisplayObjectContainer;
removeEventListener(Event.ADDED, addedHandler);
Security.allowDomain("server.cpmstar.com");
_local2 = "http://server.cpmstar.com/adviewas3.swf";
_local3 = parent;
cpmstarLoader = new Loader();
cpmstarLoader.contentLoaderInfo.addEventListener(Event.INIT, dispatchHandler);
cpmstarLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, dispatchHandler);
cpmstarLoader.load(new URLRequest(((_local2 + "?contentspotid=") + contentspotid)));
addChild(cpmstarLoader);
}
private function dispatchHandler(_arg1:Event):void{
dispatchEvent(_arg1);
}
}
}//package CPMStar
Section 10
//JConfig (jiglib.cof.JConfig)
package jiglib.cof {
public class JConfig {
public static var damping:Number = 0.995;
public static var allowedPenetration:Number = 0.0001;
public static var boxCollisionsType:String = "EDGEBASE";
public static var collToll:Number = 0.005;
public static var angVelThreshold:Number = 10;
public static var deactivationTime:Number = 100;
public static var velThreshold:Number = 0.4;
public static var limitVelocities:Boolean = false;
public static var numContactIterations:Number = 4;
public static var rotationType:String = "DEGREES";
public static var orientThreshold:Number = 0.2;
public static var numCollisionIterations:Number = 4;
public static var solverType:String = "FAST";
public static var posThreshold:Number = 0.1;
public static var numPenetrationRelaxationTimesteps:Number = 7;
}
}//package jiglib.cof
Section 11
//CollDetectBoxBox (jiglib.collision.CollDetectBoxBox)
package jiglib.collision {
import jiglib.math.*;
import jiglib.physics.*;
import jiglib.geometry.*;
import jiglib.cof.*;
public class CollDetectBoxBox extends CollDetectFunctor {
private const MAX_SUPPORT_VERTS:Number = 10;
private var combinationDist:Number;
public function CollDetectBoxBox(){
name = "BoxBox";
type0 = "BOX";
type1 = "BOX";
}
private function getEdgeEdgeContacts(_arg1:JNumber3D, _arg2:JNumber3D, _arg3:JNumber3D, _arg4:JNumber3D, _arg5:Array, _arg6:Array):void{
var _local7:JNumber3D;
var _local8:JNumber3D;
var _local9:JNumber3D;
var _local10:JNumber3D;
var _local11:Number;
var _local12:Number;
_local7 = JNumber3D.sub(_arg2, _arg1);
_local8 = JNumber3D.sub(_arg4, _arg3);
_local9 = JNumber3D.cross(_local8, _local7);
_local10 = JNumber3D.cross(_local8, _local9);
_local11 = JNumber3D.dot(_local10, _arg3);
_local12 = ((_local11 - JNumber3D.dot(_arg1, _local10)) / JNumber3D.dot(_local7, _local10));
if (_local12 < 0){
_local12 = 0;
} else {
if (_local12 > 1){
_local12 = 1;
};
};
getPointEdgeContacts(JNumber3D.add(_arg1, JNumber3D.multiply(_local7, _local12)), _arg3, _arg4, _arg5, _arg6);
}
private function getPointPointContacts(_arg1:JNumber3D, _arg2:JNumber3D, _arg3:Array, _arg4:Array):void{
_arg3.push(_arg1.clone());
_arg4.push(_arg2.clone());
}
private function getPointFaceContacts(_arg1:JNumber3D, _arg2:JNumber3D, _arg3:Number, _arg4:Array, _arg5:Array):void{
var _local6:Number;
_local6 = (JNumber3D.dot(_arg1, _arg2) - _arg3);
addPoint(_arg4, _arg1.clone(), combinationDist);
addPoint(_arg5, JNumber3D.sub(_arg1, JNumber3D.multiply(_arg2, _local6)), combinationDist);
}
private function planeClip(_arg1:Array, _arg2:Array, _arg3:JNumber3D, _arg4:Number):Boolean{
var _local5:Array;
var _local6:Boolean;
var _local7:Boolean;
var _local8:Number;
var _local9:String;
var _local10:int;
var _local11:int;
var _local12:int;
var _local13:int;
var _local14:JNumber3D;
var _local15:Number;
_local5 = [];
_local6 = false;
_local7 = false;
for (_local9 in _arg1) {
_local8 = (JNumber3D.dot(_arg1[_local9], _arg3) - _arg4);
_local5[_local9] = ((_local8)<0) ? true : false;
_local6 = ((_local6) || (_local5[_local9]));
_local7 = ((_local6) || (!(_local5[_local9])));
};
if (!_local6){
return (false);
};
if (!_local7){
for (_local9 in _arg1) {
_arg2[_local9] = _arg1[_local9].clone();
};
return (true);
};
_local10 = 0;
_local11 = (_arg1.length - 1);
_local12 = ((_arg1.length)>2) ? _arg1.length : 1;
_local13 = 0;
while (_local13 < _local12) {
if (_local5[_local11]){
if (_local10 >= MAX_SUPPORT_VERTS){
return (true);
};
var _temp1 = _local10;
_local10 = (_local10 + 1);
var _local16 = _temp1;
_arg2[_local16] = _arg1[_local11].clone();
};
if ((_local5[_local13] ^ _local5[_local11])){
if (_local10 >= MAX_SUPPORT_VERTS){
return (true);
};
_local14 = JNumber3D.sub(_arg1[_local13], _arg1[_local11]);
_local15 = ((_arg4 - JNumber3D.dot(_arg1[_local11], _arg3)) / JNumber3D.dot(_local14, _arg3));
var _temp2 = _local10;
_local10 = (_local10 + 1);
_local16 = _temp2;
_arg2[_local16] = JNumber3D.add(_arg1[_local11], JNumber3D.multiply(_local14, _local15));
};
_local11 = _local13;
_local13++;
};
return (true);
}
private function getBox2BoxEdgesIntersectionPoints(_arg1:Array, _arg2:JBox, _arg3:JBox, _arg4:Boolean):Number{
var _local5:Number;
var _local6:JSegment;
var _local7:PhysicsState;
var _local8:PhysicsState;
var _local9:Array;
var _local10:Array;
var _local11:Object;
var _local12:String;
_local5 = 0;
_local7 = (_arg4) ? _arg2.currentState : _arg2.oldState;
_local8 = (_arg4) ? _arg3.currentState : _arg3.oldState;
_local9 = _arg3.getCornerPoints(_local8);
_local10 = _arg3.edges;
for (_local12 in _local10) {
_local11 = new Object();
_local6 = new JSegment(_local9[_local10[_local12].ind0], JNumber3D.sub(_local9[_local10[_local12].ind1], _local9[_local10[_local12].ind0]));
if (_arg2.segmentIntersect(_local11, _local6, _local7)){
if (addPoint(_arg1, _local11.posOut, combinationDist)){
_local5 = (_local5 + 1);
};
};
};
return (_local5);
}
private function boxSortCollDetect(_arg1:CollDetectInfo, _arg2:Array, _arg3:JBox, _arg4:JBox, _arg5:JNumber3D, _arg6:Number):void{
var _local7:Array;
var _local8:Array;
var _local9:Array;
var _local10:Array;
var _local11:int;
var _local12:int;
var _local13:CollPointInfo;
var _local14:Array;
var _local15:CollisionInfo;
var _local16:MaterialProperties;
var _local17:JNumber3D;
var _local18:Number;
var _local19:int;
var _local20:int;
_local7 = [];
_local8 = [];
_local9 = _arg3.getSupportVertices(_arg5);
_local10 = _arg4.getSupportVertices(JNumber3D.multiply(_arg5, -1));
_local11 = _local9.length;
_local12 = _local10.length;
combinationDist = (0.2 * Math.min(Math.min(_arg3.sideLengths.x, _arg3.sideLengths.y, _arg3.sideLengths.z), Math.min(_arg4.sideLengths.x, _arg4.sideLengths.y, _arg4.sideLengths.z)));
combinationDist = (combinationDist * combinationDist);
if (_local11 == 1){
if (_local12 == 1){
getPointPointContacts(_local9[0], _local10[0], _local7, _local8);
} else {
if (_local12 == 2){
getPointEdgeContacts(_local9[0], _local10[0], _local10[1], _local7, _local8);
} else {
_local17 = JNumber3D.getNormal(_local10[0], _local10[1], _local10[2]);
_local18 = JNumber3D.dot(_local17, _local10[0]);
getPointFaceContacts(_local9[0], _local17, _local18, _local7, _local8);
};
};
} else {
if (_local11 == 2){
if (_local12 == 1){
getPointEdgeContacts(_local10[0], _local9[0], _local9[1], _local8, _local7);
} else {
if (_local12 == 2){
getEdgeEdgeContacts(_local9[0], _local9[1], _local10[0], _local10[1], _local7, _local8);
} else {
getPolygonContacts(_local10, _local9, _local8, _local7);
};
};
} else {
if (_local12 == 1){
_local17 = JNumber3D.getNormal(_local9[0], _local9[1], _local9[2]);
_local18 = JNumber3D.dot(_local17, _local9[0]);
getPointFaceContacts(_local10[0], _local17, _local18, _local8, _local7);
} else {
getPolygonContacts(_local9, _local10, _local7, _local8);
};
};
};
if (_local8.length > _local7.length){
_local7 = _local8;
};
if (_local7.length > _local8.length){
_local8 = _local7;
};
_local14 = [];
if ((((_local7.length > 0)) && ((_local8.length > 0)))){
_local19 = ((_local7.length)>_local8.length) ? _local8.length : _local7.length;
_local20 = 0;
while (_local20 < _local19) {
_local13 = new CollPointInfo();
_local13.r0 = JNumber3D.sub(_local7[_local20], _arg3.currentState.position);
_local13.r1 = JNumber3D.sub(_local8[_local20], _arg4.currentState.position);
_local13.initialPenetration = _arg6;
_local14.push(_local13);
_local20++;
};
} else {
_local13 = new CollPointInfo();
_local13.r0 = new JNumber3D();
_local13.r1 = new JNumber3D();
_local13.initialPenetration = _arg6;
_local14.push(_local13);
};
_local15 = new CollisionInfo();
_local15.objInfo = _arg1;
_local15.dirToBody = _arg5;
_local15.pointInfo = _local14;
_local16 = new MaterialProperties();
_local16.restitution = Math.sqrt((_arg3.material.restitution * _arg4.material.restitution));
_local16.friction = Math.sqrt((_arg3.material.friction * _arg4.material.friction));
_local15.mat = _local16;
_arg2.push(_local15);
_arg1.body0.collisions.push(_local15);
_arg1.body1.collisions.push(_local15);
}
private function boxEdgesCollDetect(_arg1:CollDetectInfo, _arg2:Array, _arg3:JBox, _arg4:JBox, _arg5:JNumber3D, _arg6:Number, _arg7:int):void{
var _local8:Boolean;
var _local9:Array;
var _local10:JNumber3D;
var _local11:Number;
var _local12:Number;
var _local13:Array;
var _local14:CollPointInfo;
var _local15:String;
var _local16:CollisionInfo;
var _local17:MaterialProperties;
_local8 = true;
_local9 = [];
combinationDist = (0.5 * Math.min(Math.min(_arg3.sideLengths.x, _arg3.sideLengths.y, _arg3.sideLengths.z), Math.min(_arg4.sideLengths.x, _arg4.sideLengths.y, _arg4.sideLengths.z)));
combinationDist = (combinationDist * combinationDist);
if (_arg6 > -(JNumber3D.NUM_TINY)){
getBoxBoxIntersectionPoints(_local9, _arg3, _arg4, false);
};
if (_local9.length == 0){
_local8 = false;
getBoxBoxIntersectionPoints(_local9, _arg3, _arg4, true);
};
_local10 = JNumber3D.sub(JNumber3D.sub(_arg3.currentState.position, _arg3.oldState.position), JNumber3D.sub(_arg4.currentState.position, _arg4.oldState.position));
_local11 = JNumber3D.dot(_local10, _arg5);
_local12 = (_arg6 + _local11);
_local13 = [];
if (_local9.length > 0){
for (_local15 in _local9) {
if (_local8){
_local14 = new CollPointInfo();
_local14.r0 = JNumber3D.sub(_local9[_local15], _arg3.oldState.position);
_local14.r1 = JNumber3D.sub(_local9[_local15], _arg4.oldState.position);
_local14.initialPenetration = _local12;
_local13.push(_local14);
} else {
_local14 = new CollPointInfo();
_local14.r0 = JNumber3D.sub(_local9[_local15], _arg3.currentState.position);
_local14.r1 = JNumber3D.sub(_local9[_local15], _arg4.currentState.position);
_local14.initialPenetration = _local12;
_local13.push(_local14);
};
};
_local16 = new CollisionInfo();
_local16.objInfo = _arg1;
_local16.dirToBody = _arg5;
_local16.pointInfo = _local13;
_local17 = new MaterialProperties();
_local17.restitution = Math.sqrt((_arg3.material.restitution * _arg4.material.restitution));
_local17.friction = Math.sqrt((_arg3.material.friction * _arg4.material.friction));
_local16.mat = _local17;
_arg2.push(_local16);
_arg1.body0.collisions.push(_local16);
_arg1.body1.collisions.push(_local16);
};
}
private function getBoxBoxIntersectionPoints(_arg1:Array, _arg2:JBox, _arg3:JBox, _arg4:Boolean):uint{
getBox2BoxEdgesIntersectionPoints(_arg1, _arg2, _arg3, _arg4);
getBox2BoxEdgesIntersectionPoints(_arg1, _arg3, _arg2, _arg4);
return (_arg1.length);
}
private function addPoint(_arg1:Array, _arg2:JNumber3D, _arg3:Number):Boolean{
var _local4:String;
for (_local4 in _arg1) {
if (JNumber3D.sub(_arg1[_local4], _arg2).modulo2 < _arg3){
_arg1[_local4] = JNumber3D.divide(JNumber3D.add(_arg1[_local4], _arg2), 2);
return (false);
};
};
_arg1.push(_arg2);
return (true);
}
private function polygonClip(_arg1:Array, _arg2:Array, _arg3:Array):Boolean{
var _local4:JNumber3D;
var _local5:int;
var _local6:JNumber3D;
var _local7:JNumber3D;
var _local8:Array;
var _local9:int;
var _local10:int;
var _local11:Number;
if (_arg1.length <= 2){
return (false);
};
_local4 = JNumber3D.getNormal(_arg1[0], _arg1[1], _arg1[2]);
_local5 = (_arg1.length - 1);
_local8 = _arg2.concat();
_local9 = _arg1.length;
_local10 = 0;
while (_local10 < _local9) {
_local7 = JNumber3D.sub(_arg1[_local10], _arg1[_local5]);
_local6 = JNumber3D.cross(_local4, _local7);
_local11 = JNumber3D.dot(_arg1[_local5], _local6);
if (!planeClip(_local8, _arg3, _local6, _local11)){
return (false);
};
_local8 = _arg3.concat();
_local5 = _local10;
_local10++;
};
return (true);
}
override public function collDetect(_arg1:CollDetectInfo, _arg2:Array):void{
var _local3:JBox;
var _local4:JBox;
var _local5:Array;
var _local6:Array;
var _local7:Array;
var _local8:Number;
var _local9:Array;
var _local10:String;
var _local11:Number;
var _local12:int;
var _local13:JNumber3D;
var _local14:JNumber3D;
_local3 = (_arg1.body0 as JBox);
_local4 = (_arg1.body1 as JBox);
if (!_local3.hitTestObject3D(_local4)){
return;
};
_local5 = _local3.currentState.orientation.getCols();
_local6 = _local4.currentState.orientation.getCols();
_local7 = [_local5[0], _local5[1], _local5[2], _local6[0], _local6[1], _local6[2], JNumber3D.cross(_local6[0], _local5[0]), JNumber3D.cross(_local6[0], _local5[1]), JNumber3D.cross(_local6[0], _local5[2]), JNumber3D.cross(_local6[1], _local5[0]), JNumber3D.cross(_local6[1], _local5[1]), JNumber3D.cross(_local6[1], _local5[2]), JNumber3D.cross(_local6[2], _local5[0]), JNumber3D.cross(_local6[2], _local5[1]), JNumber3D.cross(_local6[2], _local5[2])];
_local9 = [];
for (_local10 in _local7) {
_local9[_local10] = new Object();
_local9[_local10].flag = false;
_local9[_local10].depth = JNumber3D.NUM_HUGE;
_local8 = _local7[_local10].modulo2;
if (_local8 < JNumber3D.NUM_TINY){
} else {
_local14 = _local7[_local10].clone();
_local14.normalize();
if (disjoint(_local9[_local10], _local14, _local3, _local4)){
return;
};
};
};
_local11 = JNumber3D.NUM_HUGE;
_local12 = -1;
for (_local10 in _local7) {
_local8 = _local7[_local10].modulo2;
if (_local8 < JNumber3D.NUM_TINY){
} else {
if (_local9[_local10].depth < _local11){
_local11 = _local9[_local10].depth;
_local12 = int(_local10);
};
};
};
if (_local12 == -1){
return;
};
_local13 = _local7[_local12].clone();
if (JNumber3D.dot(JNumber3D.sub(_local4.currentState.position, _local3.currentState.position), _local13) > 0){
_local13 = JNumber3D.multiply(_local13, -1);
};
_local13.normalize();
if (JConfig.boxCollisionsType == "EDGEBASE"){
boxEdgesCollDetect(_arg1, _arg2, _local3, _local4, _local13, _local11, _local12);
} else {
boxSortCollDetect(_arg1, _arg2, _local3, _local4, _local13, _local11);
};
}
private function getPolygonContacts(_arg1:Array, _arg2:Array, _arg3:Array, _arg4:Array):void{
var _local5:JNumber3D;
var _local6:Number;
var _local7:Array;
var _local8:String;
if (!polygonClip(_arg1, _arg2, _arg4)){
return;
};
_local5 = JNumber3D.getNormal(_arg1[0], _arg1[1], _arg1[2]);
_local6 = JNumber3D.dot(_arg1[0], _local5);
_local7 = [];
for (_local8 in _arg4) {
getPointFaceContacts(_arg4[_local8], _local5, _local6, _local7, _arg3);
};
}
private function getPointEdgeContacts(_arg1:JNumber3D, _arg2:JNumber3D, _arg3:JNumber3D, _arg4:Array, _arg5:Array):void{
var _local6:JNumber3D;
var _local7:JNumber3D;
var _local8:Number;
_local6 = JNumber3D.sub(_arg1, _arg2);
_local7 = JNumber3D.sub(_arg3, _arg2);
_local8 = (JNumber3D.dot(_local6, _local7) / JNumber3D.dot(_local7, _local7));
if (_local8 < 0){
_local8 = 0;
} else {
if (_local8 > 1){
_local8 = 1;
};
};
_arg4.push(_arg1.clone());
_arg5.push(JNumber3D.add(_arg2, JNumber3D.multiply(_local7, _local8)));
}
private function disjoint(_arg1:Object, _arg2:JNumber3D, _arg3:JBox, _arg4:JBox):Boolean{
var _local5:Object;
var _local6:Object;
_local5 = _arg3.getSpan(_arg2);
_local6 = _arg4.getSpan(_arg2);
if ((((_local5.min > ((_local6.max + JConfig.collToll) + JNumber3D.NUM_TINY))) || ((_local6.min > ((_local5.max + JConfig.collToll) + JNumber3D.NUM_TINY))))){
_arg1.flag = true;
return (true);
};
if ((((_local5.max > _local6.max)) && ((_local6.min > _local5.min)))){
_arg1.depth = Math.min((_local5.max - _local6.min), (_local6.max - _local5.min));
} else {
if ((((_local6.max > _local5.max)) && ((_local5.min > _local6.min)))){
_arg1.depth = Math.min((_local6.max - _local5.min), (_local5.max - _local6.min));
} else {
_arg1.depth = Math.min(_local5.max, _local6.max);
_arg1.depth = (_arg1.depth - Math.max(_local5.min, _local6.min));
};
};
_arg1.flag = false;
return (false);
}
}
}//package jiglib.collision
Section 12
//CollDetectBoxPlane (jiglib.collision.CollDetectBoxPlane)
package jiglib.collision {
import jiglib.math.*;
import jiglib.physics.*;
import jiglib.geometry.*;
import jiglib.cof.*;
public class CollDetectBoxPlane extends CollDetectFunctor {
public function CollDetectBoxPlane(){
name = "BoxPlane";
type0 = "BOX";
type1 = "PLANE";
}
override public function collDetect(_arg1:CollDetectInfo, _arg2:Array):void{
var _local3:RigidBody;
var _local4:JBox;
var _local5:JPlane;
var _local6:Number;
var _local7:Array;
var _local8:Array;
var _local9:Array;
var _local10:CollPointInfo;
var _local11:JNumber3D;
var _local12:JNumber3D;
var _local13:Number;
var _local14:Number;
var _local15:String;
var _local16:CollisionInfo;
var _local17:MaterialProperties;
if (_arg1.body0.type == "PLANE"){
_local3 = _arg1.body0;
_arg1.body0 = _arg1.body1;
_arg1.body1 = _local3;
};
_local4 = (_arg1.body0 as JBox);
_local5 = (_arg1.body1 as JPlane);
_local6 = _local5.pointPlaneDistance(_local4.currentState.position);
if (_local6 > (_local4.boundingSphere + JConfig.collToll)){
return;
};
_local7 = _local4.getCornerPoints(_local4.currentState);
_local8 = _local4.getCornerPoints(_local4.oldState);
_local9 = [];
for (_local15 in _local7) {
_local11 = _local7[_local15];
_local12 = _local8[_local15];
_local13 = (-1 * _local5.pointPlaneDistance(_local11));
_local14 = (-1 * _local5.pointPlaneDistance(_local12));
if (Math.max(_local13, _local14) > -(JConfig.collToll)){
_local10 = new CollPointInfo();
_local10.r0 = JNumber3D.sub(_local12, _local4.oldState.position);
_local10.r1 = JNumber3D.sub(_local12, _local5.oldState.position);
_local10.initialPenetration = _local14;
_local9.push(_local10);
};
};
if (_local9.length > 0){
_local16 = new CollisionInfo();
_local16.objInfo = _arg1;
_local16.dirToBody = _local5.normal;
_local16.pointInfo = _local9;
_local17 = new MaterialProperties();
_local17.restitution = Math.sqrt((_local4.material.restitution * _local5.material.restitution));
_local17.friction = Math.sqrt((_local4.material.friction * _local5.material.friction));
_local16.mat = _local17;
_arg2.push(_local16);
_arg1.body0.collisions.push(_local16);
_arg1.body1.collisions.push(_local16);
};
}
}
}//package jiglib.collision
Section 13
//CollDetectCapsuleBox (jiglib.collision.CollDetectCapsuleBox)
package jiglib.collision {
import jiglib.math.*;
import jiglib.physics.*;
import jiglib.geometry.*;
import jiglib.cof.*;
public class CollDetectCapsuleBox extends CollDetectFunctor {
public function CollDetectCapsuleBox(){
name = "CapsuleBox";
type0 = "CAPSULE";
type1 = "BOX";
}
override public function collDetect(_arg1:CollDetectInfo, _arg2:Array):void{
var _local3:RigidBody;
var _local4:JCapsule;
var _local5:JBox;
var _local6:Array;
var _local7:CollPointInfo;
var _local8:JSegment;
var _local9:JSegment;
var _local10:Number;
var _local11:Object;
var _local12:Number;
var _local13:Object;
var _local14:Number;
var _local15:Array;
var _local16:JNumber3D;
var _local17:JNumber3D;
var _local18:Number;
var _local19:Number;
var _local20:JNumber3D;
var _local21:CollisionInfo;
var _local22:MaterialProperties;
if (_arg1.body0.type == "BOX"){
_local3 = _arg1.body0;
_arg1.body0 = _arg1.body1;
_arg1.body1 = _local3;
};
_local4 = (_arg1.body0 as JCapsule);
_local5 = (_arg1.body1 as JBox);
if (!_local4.hitTestObject3D(_local5)){
return;
};
_local6 = [];
_local8 = new JSegment(_local4.getBottomPos(_local4.oldState), JNumber3D.multiply(_local4.oldState.orientation.getCols()[1], _local4.length));
_local9 = new JSegment(_local4.getBottomPos(_local4.currentState), JNumber3D.multiply(_local4.currentState.orientation.getCols()[1], _local4.length));
_local10 = _local4.radius;
_local11 = new Object();
_local12 = _local8.segmentBoxDistanceSq(_local11, _local5, _local5.oldState);
_local13 = new Object();
_local14 = _local9.segmentBoxDistanceSq(_local13, _local5, _local5.currentState);
_local15 = _local5.oldState.orientation.getCols();
if (Math.min(_local12, _local14) < Math.pow((_local10 + JConfig.collToll), 2)){
_local16 = _local8.getPoint(Number(_local11.pfLParam));
_local17 = _local5.oldState.position.clone();
_local17 = JNumber3D.add(_local17, JNumber3D.multiply(_local15[0], _local11.pfLParam0));
_local17 = JNumber3D.add(_local17, JNumber3D.multiply(_local15[1], _local11.pfLParam1));
_local17 = JNumber3D.add(_local17, JNumber3D.multiply(_local15[2], _local11.pfLParam2));
_local18 = Math.sqrt(_local12);
_local19 = (_local10 - _local18);
if (_local18 > JNumber3D.NUM_TINY){
_local20 = JNumber3D.sub(_local16, _local17);
_local20.normalize();
} else {
if (JNumber3D.sub(_local16, _local5.oldState.position).modulo > JNumber3D.NUM_TINY){
_local20 = JNumber3D.sub(_local16, _local5.oldState.position);
_local20.normalize();
} else {
_local20 = JNumber3D.UP;
JMatrix3D.multiplyVector(JMatrix3D.rotationMatrix(0, 0, 1, (360 * Math.random())), _local20);
};
};
_local7 = new CollPointInfo();
_local7.r0 = JNumber3D.sub(_local17, _local4.oldState.position);
_local7.r1 = JNumber3D.sub(_local17, _local5.oldState.position);
_local7.initialPenetration = _local19;
_local6.push(_local7);
};
_local8 = new JSegment(_local4.getEndPos(_local4.oldState), JNumber3D.multiply(_local4.oldState.orientation.getCols()[1], _local4.length));
_local9 = new JSegment(_local4.getEndPos(_local4.currentState), JNumber3D.multiply(_local4.currentState.orientation.getCols()[1], _local4.length));
_local11 = new Object();
_local12 = _local8.segmentBoxDistanceSq(_local11, _local5, _local5.oldState);
_local13 = new Object();
_local14 = _local9.segmentBoxDistanceSq(_local13, _local5, _local5.currentState);
if (Math.min(_local12, _local14) < Math.pow((_local10 + JConfig.collToll), 2)){
_local16 = _local8.getPoint(Number(_local11.pfLParam));
_local17 = _local5.oldState.position.clone();
_local17 = JNumber3D.add(_local17, JNumber3D.multiply(_local15[0], _local11.pfLParam0));
_local17 = JNumber3D.add(_local17, JNumber3D.multiply(_local15[1], _local11.pfLParam1));
_local17 = JNumber3D.add(_local17, JNumber3D.multiply(_local15[2], _local11.pfLParam2));
_local18 = Math.sqrt(_local12);
_local19 = (_local10 - _local18);
if (_local18 > JNumber3D.NUM_TINY){
_local20 = JNumber3D.sub(_local16, _local17);
_local20.normalize();
} else {
if (JNumber3D.sub(_local16, _local5.oldState.position).modulo > JNumber3D.NUM_TINY){
_local20 = JNumber3D.sub(_local16, _local5.oldState.position);
_local20.normalize();
} else {
_local20 = JNumber3D.UP;
JMatrix3D.multiplyVector(JMatrix3D.rotationMatrix(0, 0, 1, (360 * Math.random())), _local20);
};
};
_local7 = new CollPointInfo();
_local7.r0 = JNumber3D.sub(_local17, _local4.oldState.position);
_local7.r1 = JNumber3D.sub(_local17, _local5.oldState.position);
_local7.initialPenetration = _local19;
_local6.push(_local7);
};
if (_local6.length > 0){
_local21 = new CollisionInfo();
_local21.objInfo = _arg1;
_local21.dirToBody = _local20;
_local21.pointInfo = _local6;
_local22 = new MaterialProperties();
_local22.restitution = Math.sqrt((_local4.material.restitution * _local5.material.restitution));
_local22.friction = Math.sqrt((_local4.material.friction * _local5.material.friction));
_local21.mat = _local22;
_arg2.push(_local21);
_arg1.body0.collisions.push(_local21);
_arg1.body1.collisions.push(_local21);
};
}
}
}//package jiglib.collision
Section 14
//CollDetectCapsuleCapsule (jiglib.collision.CollDetectCapsuleCapsule)
package jiglib.collision {
import jiglib.math.*;
import jiglib.physics.*;
import jiglib.geometry.*;
import jiglib.cof.*;
public class CollDetectCapsuleCapsule extends CollDetectFunctor {
public function CollDetectCapsuleCapsule(){
name = "CapsuleCapsule";
type0 = "CAPSULE";
type1 = "CAPSULE";
}
override public function collDetect(_arg1:CollDetectInfo, _arg2:Array):void{
var _local3:JCapsule;
var _local4:JCapsule;
var _local5:Array;
var _local6:CollPointInfo;
var _local7:JSegment;
var _local8:JSegment;
var _local9:JSegment;
var _local10:JSegment;
var _local11:Number;
var _local12:Object;
var _local13:Number;
var _local14:Object;
var _local15:Number;
var _local16:JNumber3D;
var _local17:JNumber3D;
var _local18:JNumber3D;
var _local19:Number;
var _local20:Number;
var _local21:JNumber3D;
var _local22:CollisionInfo;
var _local23:MaterialProperties;
_local3 = (_arg1.body0 as JCapsule);
_local4 = (_arg1.body1 as JCapsule);
if (!_local3.hitTestObject3D(_local4)){
return;
};
_local5 = [];
_local7 = new JSegment(_local3.getBottomPos(_local3.oldState), JNumber3D.multiply(_local3.oldState.orientation.getCols()[1], _local3.length));
_local8 = new JSegment(_local3.getBottomPos(_local3.currentState), JNumber3D.multiply(_local3.currentState.orientation.getCols()[1], _local3.length));
_local9 = new JSegment(_local4.getBottomPos(_local4.oldState), JNumber3D.multiply(_local4.oldState.orientation.getCols()[1], _local4.length));
_local10 = new JSegment(_local4.getBottomPos(_local4.currentState), JNumber3D.multiply(_local4.currentState.orientation.getCols()[1], _local4.length));
_local11 = (_local3.radius + _local4.radius);
_local12 = new Object();
_local13 = _local7.segmentSegmentDistanceSq(_local12, _local9);
_local14 = new Object();
_local15 = _local8.segmentSegmentDistanceSq(_local12, _local10);
if (Math.min(_local13, _local15) < Math.pow((_local11 + JConfig.collToll), 2)){
_local16 = _local7.getPoint(_local12.t0);
_local17 = _local9.getPoint(_local12.t1);
_local18 = JNumber3D.sub(_local16, _local17);
_local19 = Math.sqrt(_local13);
_local20 = (_local11 - _local19);
if (_local19 > JNumber3D.NUM_TINY){
_local18 = JNumber3D.divide(_local18, _local19);
} else {
_local18 = JNumber3D.UP;
JMatrix3D.multiplyVector(JMatrix3D.rotationMatrix(0, 0, 1, (360 * Math.random())), _local18);
};
_local21 = JNumber3D.add(_local17, JNumber3D.multiply(_local18, (_local4.radius - (0.5 * _local20))));
_local6 = new CollPointInfo();
_local6.r0 = JNumber3D.sub(_local21, _local3.oldState.position);
_local6.r1 = JNumber3D.sub(_local21, _local4.oldState.position);
_local6.initialPenetration = _local20;
_local5.push(_local6);
};
_local7 = new JSegment(_local3.getEndPos(_local3.oldState), JNumber3D.multiply(_local3.oldState.orientation.getCols()[1], _local3.length));
_local8 = new JSegment(_local3.getEndPos(_local3.currentState), JNumber3D.multiply(_local3.currentState.orientation.getCols()[1], _local3.length));
_local9 = new JSegment(_local4.getEndPos(_local4.oldState), JNumber3D.multiply(_local4.oldState.orientation.getCols()[1], _local4.length));
_local10 = new JSegment(_local4.getEndPos(_local4.currentState), JNumber3D.multiply(_local4.currentState.orientation.getCols()[1], _local4.length));
_local12 = new Object();
_local13 = _local7.segmentSegmentDistanceSq(_local12, _local9);
_local14 = new Object();
_local15 = _local8.segmentSegmentDistanceSq(_local12, _local10);
if (Math.min(_local13, _local15) < Math.pow((_local11 + JConfig.collToll), 2)){
_local16 = _local7.getPoint(_local12.t0);
_local17 = _local9.getPoint(_local12.t1);
_local18 = JNumber3D.sub(_local16, _local17);
_local19 = Math.sqrt(_local13);
_local20 = (_local11 - _local19);
if (_local19 > JNumber3D.NUM_TINY){
_local18 = JNumber3D.divide(_local18, _local19);
} else {
_local18 = JNumber3D.UP;
JMatrix3D.multiplyVector(JMatrix3D.rotationMatrix(0, 0, 1, (360 * Math.random())), _local18);
};
_local21 = JNumber3D.add(_local17, JNumber3D.multiply(_local18, (_local4.radius - (0.5 * _local20))));
_local6 = new CollPointInfo();
_local6.r0 = JNumber3D.sub(_local21, _local3.oldState.position);
_local6.r1 = JNumber3D.sub(_local21, _local4.oldState.position);
_local6.initialPenetration = _local20;
_local5.push(_local6);
};
if (_local5.length > 0){
_local22 = new CollisionInfo();
_local22.objInfo = _arg1;
_local22.dirToBody = _local18;
_local22.pointInfo = _local5;
_local23 = new MaterialProperties();
_local23.restitution = Math.sqrt((_local3.material.restitution * _local4.material.restitution));
_local23.friction = Math.sqrt((_local3.material.friction * _local4.material.friction));
_local22.mat = _local23;
_arg2.push(_local22);
_arg1.body0.collisions.push(_local22);
_arg1.body1.collisions.push(_local22);
};
}
}
}//package jiglib.collision
Section 15
//CollDetectCapsulePlane (jiglib.collision.CollDetectCapsulePlane)
package jiglib.collision {
import jiglib.math.*;
import jiglib.physics.*;
import jiglib.geometry.*;
import jiglib.cof.*;
public class CollDetectCapsulePlane extends CollDetectFunctor {
public function CollDetectCapsulePlane(){
name = "CapsulePlane";
type0 = "CAPSULE";
type1 = "PLANE";
}
override public function collDetect(_arg1:CollDetectInfo, _arg2:Array):void{
var _local3:RigidBody;
var _local4:JCapsule;
var _local5:JPlane;
var _local6:Array;
var _local7:CollPointInfo;
var _local8:JNumber3D;
var _local9:Number;
var _local10:JNumber3D;
var _local11:Number;
var _local12:Number;
var _local13:JNumber3D;
var _local14:CollisionInfo;
var _local15:MaterialProperties;
if (_arg1.body0.type == "PLANE"){
_local3 = _arg1.body0;
_arg1.body0 = _arg1.body1;
_arg1.body1 = _local3;
};
_local4 = (_arg1.body0 as JCapsule);
_local5 = (_arg1.body1 as JPlane);
_local6 = [];
_local8 = _local4.getBottomPos(_local4.oldState);
_local9 = _local5.pointPlaneDistance(_local8);
_local10 = _local4.getBottomPos(_local4.currentState);
_local11 = _local5.pointPlaneDistance(_local10);
if (Math.min(_local9, _local11) < (_local4.radius + JConfig.collToll)){
_local12 = (_local4.radius - _local9);
_local13 = JNumber3D.sub(_local8, JNumber3D.multiply(_local5.normal, _local4.radius));
_local7 = new CollPointInfo();
_local7.r0 = JNumber3D.sub(_local13, _local4.oldState.position);
_local7.r1 = JNumber3D.sub(_local13, _local5.oldState.position);
_local7.initialPenetration = _local12;
_local6.push(_local7);
};
_local8 = _local4.getEndPos(_local4.oldState);
_local10 = _local4.getEndPos(_local4.currentState);
_local9 = _local5.pointPlaneDistance(_local8);
_local11 = _local5.pointPlaneDistance(_local10);
if (Math.min(_local9, _local11) < (_local4.radius + JConfig.collToll)){
_local12 = (_local4.radius - _local9);
_local13 = JNumber3D.sub(_local8, JNumber3D.multiply(_local5.normal, _local4.radius));
_local7 = new CollPointInfo();
_local7.r0 = JNumber3D.sub(_local13, _local4.oldState.position);
_local7.r1 = JNumber3D.sub(_local13, _local5.oldState.position);
_local7.initialPenetration = _local12;
_local6.push(_local7);
};
if (_local6.length > 0){
_local14 = new CollisionInfo();
_local14.objInfo = _arg1;
_local14.dirToBody = _local5.normal;
_local14.pointInfo = _local6;
_local15 = new MaterialProperties();
_local15.restitution = Math.sqrt((_local4.material.restitution * _local5.material.restitution));
_local15.friction = Math.sqrt((_local4.material.friction * _local5.material.friction));
_local14.mat = _local15;
_arg2.push(_local14);
_arg1.body0.collisions.push(_local14);
_arg1.body1.collisions.push(_local14);
};
}
}
}//package jiglib.collision
Section 16
//CollDetectFunctor (jiglib.collision.CollDetectFunctor)
package jiglib.collision {
public class CollDetectFunctor {
public var type0:String;
public var name:String;
public var type1:String;
public function collDetect(_arg1:CollDetectInfo, _arg2:Array):void{
}
}
}//package jiglib.collision
Section 17
//CollDetectInfo (jiglib.collision.CollDetectInfo)
package jiglib.collision {
import jiglib.physics.*;
public class CollDetectInfo {
public var body0:RigidBody;
public var body1:RigidBody;
}
}//package jiglib.collision
Section 18
//CollDetectSphereBox (jiglib.collision.CollDetectSphereBox)
package jiglib.collision {
import jiglib.math.*;
import jiglib.physics.*;
import jiglib.geometry.*;
import jiglib.cof.*;
public class CollDetectSphereBox extends CollDetectFunctor {
public function CollDetectSphereBox(){
name = "SphereBox";
type0 = "SPHERE";
type1 = "BOX";
}
override public function collDetect(_arg1:CollDetectInfo, _arg2:Array):void{
var _local3:RigidBody;
var _local4:JSphere;
var _local5:JBox;
var _local6:JNumber3D;
var _local7:JNumber3D;
var _local8:Object;
var _local9:Object;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:JNumber3D;
var _local15:Array;
var _local16:CollPointInfo;
var _local17:CollisionInfo;
var _local18:MaterialProperties;
if (_arg1.body0.type == "BOX"){
_local3 = _arg1.body0;
_arg1.body0 = _arg1.body1;
_arg1.body1 = _local3;
};
_local4 = (_arg1.body0 as JSphere);
_local5 = (_arg1.body1 as JBox);
if (!_local4.hitTestObject3D(_local5)){
return;
};
_local6 = _local4.oldState.position;
_local7 = _local5.oldState.position;
_local8 = new Object();
_local9 = new Object();
_local10 = _local5.getDistanceToPoint(_local5.oldState, _local8, _local4.oldState.position);
_local11 = _local5.getDistanceToPoint(_local5.currentState, _local9, _local4.currentState.position);
_local12 = (_local4.radius - _local10);
_local13 = (_local4.radius - _local11);
if (Math.max(_local12, _local13) > -(JConfig.collToll)){
_local15 = [];
if (_local10 < -(JNumber3D.NUM_TINY)){
_local14 = JNumber3D.sub(JNumber3D.sub(_local8.pos, _local4.oldState.position), _local8.pos);
_local14.normalize();
} else {
if (_local10 > JNumber3D.NUM_TINY){
_local14 = JNumber3D.sub(_local4.oldState.position, _local8.pos);
_local14.normalize();
} else {
_local14 = JNumber3D.sub(_local4.oldState.position, _local5.oldState.position);
_local14.normalize();
};
};
_local16 = new CollPointInfo();
_local16.r0 = JNumber3D.sub(_local8.pos, _local4.oldState.position);
_local16.r1 = JNumber3D.sub(_local8.pos, _local5.oldState.position);
_local16.initialPenetration = _local12;
_local15.push(_local16);
_local17 = new CollisionInfo();
_local17.objInfo = _arg1;
_local17.dirToBody = _local14;
_local17.pointInfo = _local15;
_local18 = new MaterialProperties();
_local18.restitution = Math.sqrt((_local4.material.restitution * _local5.material.restitution));
_local18.friction = Math.sqrt((_local4.material.friction * _local5.material.friction));
_local17.mat = _local18;
_arg2.push(_local17);
_arg1.body0.collisions.push(_local17);
_arg1.body1.collisions.push(_local17);
};
}
}
}//package jiglib.collision
Section 19
//CollDetectSphereCapsule (jiglib.collision.CollDetectSphereCapsule)
package jiglib.collision {
import jiglib.math.*;
import jiglib.physics.*;
import jiglib.geometry.*;
import jiglib.cof.*;
public class CollDetectSphereCapsule extends CollDetectFunctor {
public function CollDetectSphereCapsule(){
name = "SphereCapsule";
type0 = "SPHERE";
type1 = "CAPSULE";
}
override public function collDetect(_arg1:CollDetectInfo, _arg2:Array):void{
var _local3:RigidBody;
var _local4:JSphere;
var _local5:JCapsule;
var _local6:JSegment;
var _local7:JSegment;
var _local8:Number;
var _local9:Object;
var _local10:Number;
var _local11:Object;
var _local12:Number;
var _local13:JNumber3D;
var _local14:JNumber3D;
var _local15:Number;
var _local16:Number;
var _local17:JNumber3D;
var _local18:Array;
var _local19:CollPointInfo;
var _local20:CollisionInfo;
var _local21:MaterialProperties;
if (_arg1.body0.type == "CAPSULE"){
_local3 = _arg1.body0;
_arg1.body0 = _arg1.body1;
_arg1.body1 = _local3;
};
_local4 = (_arg1.body0 as JSphere);
_local5 = (_arg1.body1 as JCapsule);
if (!_local4.hitTestObject3D(_local5)){
return;
};
_local6 = new JSegment(_local5.getBottomPos(_local5.oldState), JNumber3D.multiply(_local5.oldState.orientation.getCols()[1], _local5.length));
_local7 = new JSegment(_local5.getBottomPos(_local5.currentState), JNumber3D.multiply(_local5.currentState.orientation.getCols()[1], _local5.length));
_local8 = (_local4.radius + _local5.radius);
_local9 = new Object();
_local10 = _local6.pointSegmentDistanceSq(_local9, _local4.oldState.position);
_local11 = new Object();
_local12 = _local7.pointSegmentDistanceSq(_local11, _local4.currentState.position);
if (Math.min(_local10, _local12) < Math.pow((_local8 + JConfig.collToll), 2)){
_local13 = _local6.getPoint(_local9.t);
_local14 = JNumber3D.sub(_local4.oldState.position, _local13);
_local15 = Math.sqrt(_local10);
_local16 = (_local8 - _local15);
if (_local15 > JNumber3D.NUM_TINY){
_local14 = JNumber3D.divide(_local14, _local15);
} else {
_local14 = JNumber3D.UP;
JMatrix3D.multiplyVector(JMatrix3D.rotationMatrix(0, 0, 1, (360 * Math.random())), _local14);
};
_local17 = JNumber3D.add(_local13, JNumber3D.multiply(_local14, (_local5.radius - (0.5 * _local16))));
_local18 = [];
_local19 = new CollPointInfo();
_local19.r0 = JNumber3D.sub(_local17, _local4.oldState.position);
_local19.r1 = JNumber3D.sub(_local17, _local5.oldState.position);
_local19.initialPenetration = _local16;
_local18.push(_local19);
_local20 = new CollisionInfo();
_local20.objInfo = _arg1;
_local20.dirToBody = _local14;
_local20.pointInfo = _local18;
_local21 = new MaterialProperties();
_local21.restitution = Math.sqrt((_local4.material.restitution * _local5.material.restitution));
_local21.friction = Math.sqrt((_local4.material.friction * _local5.material.friction));
_local20.mat = _local21;
_arg2.push(_local20);
_arg1.body0.collisions.push(_local20);
_arg1.body1.collisions.push(_local20);
};
}
}
}//package jiglib.collision
Section 20
//CollDetectSpherePlane (jiglib.collision.CollDetectSpherePlane)
package jiglib.collision {
import jiglib.math.*;
import jiglib.physics.*;
import jiglib.geometry.*;
import jiglib.cof.*;
public class CollDetectSpherePlane extends CollDetectFunctor {
public function CollDetectSpherePlane(){
name = "SpherePlane";
type0 = "SPHERE";
type1 = "PLANE";
}
override public function collDetect(_arg1:CollDetectInfo, _arg2:Array):void{
var _local3:RigidBody;
var _local4:JSphere;
var _local5:JPlane;
var _local6:Number;
var _local7:Number;
var _local8:Array;
var _local9:CollPointInfo;
var _local10:Number;
var _local11:JNumber3D;
var _local12:CollisionInfo;
var _local13:MaterialProperties;
if (_arg1.body0.type == "PLANE"){
_local3 = _arg1.body0;
_arg1.body0 = _arg1.body1;
_arg1.body1 = _local3;
};
_local4 = (_arg1.body0 as JSphere);
_local5 = (_arg1.body1 as JPlane);
_local6 = _local5.pointPlaneDistance(_local4.oldState.position);
_local7 = _local5.pointPlaneDistance(_local4.currentState.position);
if (Math.min(_local7, _local6) > (_local4.boundingSphere + JConfig.collToll)){
return;
};
_local8 = [];
_local10 = (_local4.radius - _local6);
_local11 = JNumber3D.sub(_local4.oldState.position, JNumber3D.multiply(_local5.normal, _local4.radius));
_local9 = new CollPointInfo();
_local9.r0 = JNumber3D.sub(_local11, _local4.oldState.position);
_local9.r1 = JNumber3D.sub(_local11, _local5.oldState.position);
_local9.initialPenetration = _local10;
_local8.push(_local9);
_local12 = new CollisionInfo();
_local12.objInfo = _arg1;
_local12.dirToBody = _local5.normal;
_local12.pointInfo = _local8;
_local13 = new MaterialProperties();
_local13.restitution = Math.sqrt((_local4.material.restitution * _local5.material.restitution));
_local13.friction = Math.sqrt((_local4.material.friction * _local5.material.friction));
_local12.mat = _local13;
_arg2.push(_local12);
_arg1.body0.collisions.push(_local12);
_arg1.body1.collisions.push(_local12);
}
}
}//package jiglib.collision
Section 21
//CollDetectSphereSphere (jiglib.collision.CollDetectSphereSphere)
package jiglib.collision {
import jiglib.math.*;
import jiglib.physics.*;
import jiglib.geometry.*;
import jiglib.cof.*;
public class CollDetectSphereSphere extends CollDetectFunctor {
public function CollDetectSphereSphere(){
name = "SphereSphere";
type0 = "SPHERE";
type1 = "SPHERE";
}
override public function collDetect(_arg1:CollDetectInfo, _arg2:Array):void{
var _local3:JSphere;
var _local4:JSphere;
var _local5:JNumber3D;
var _local6:JNumber3D;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:JNumber3D;
var _local13:Array;
var _local14:CollPointInfo;
var _local15:CollisionInfo;
var _local16:MaterialProperties;
_local3 = (_arg1.body0 as JSphere);
_local4 = (_arg1.body1 as JSphere);
_local5 = JNumber3D.sub(_local3.oldState.position, _local4.oldState.position);
_local6 = JNumber3D.sub(_local3.currentState.position, _local4.currentState.position);
_local7 = _local5.modulo2;
_local8 = _local6.modulo2;
_local9 = (_local3.radius + _local4.radius);
if (Math.min(_local7, _local8) < Math.pow((_local9 + JConfig.collToll), 2)){
_local10 = Math.sqrt(_local7);
_local11 = (_local9 - _local10);
if (_local10 > JNumber3D.NUM_TINY){
_local5 = JNumber3D.divide(_local5, _local10);
} else {
_local5 = JNumber3D.UP;
JMatrix3D.multiplyVector(JMatrix3D.rotationMatrix(0, 0, 1, (360 * Math.random())), _local5);
};
_local12 = JNumber3D.add(_local4.oldState.position, JNumber3D.multiply(_local5, (_local4.radius - (0.5 * _local11))));
_local13 = [];
_local14 = new CollPointInfo();
_local14.r0 = JNumber3D.sub(_local12, _local3.oldState.position);
_local14.r1 = JNumber3D.sub(_local12, _local4.oldState.position);
_local14.initialPenetration = _local11;
_local13.push(_local14);
_local15 = new CollisionInfo();
_local15.objInfo = _arg1;
_local15.dirToBody = _local5;
_local15.pointInfo = _local13;
_local16 = new MaterialProperties();
_local16.restitution = Math.sqrt((_local3.material.restitution * _local4.material.restitution));
_local16.friction = Math.sqrt((_local3.material.friction * _local4.material.friction));
_local15.mat = _local16;
_arg2.push(_local15);
_arg1.body0.collisions.push(_local15);
_arg1.body1.collisions.push(_local15);
};
}
}
}//package jiglib.collision
Section 22
//CollisionInfo (jiglib.collision.CollisionInfo)
package jiglib.collision {
import jiglib.math.*;
import jiglib.physics.*;
public class CollisionInfo {
public var mat:MaterialProperties;
public var objInfo:CollDetectInfo;
public var dirToBody:JNumber3D;
public var satisfied:Boolean;
public var pointInfo:Array;
public function CollisionInfo(){
mat = new MaterialProperties();
super();
}
}
}//package jiglib.collision
Section 23
//CollisionSystem (jiglib.collision.CollisionSystem)
package jiglib.collision {
import jiglib.math.*;
import jiglib.physics.*;
import jiglib.geometry.*;
public class CollisionSystem {
private var detectionFunctors:Array;
private var collBody:Array;
public function CollisionSystem(){
collBody = new Array();
detectionFunctors = new Array();
detectionFunctors["BOX"] = new Array();
detectionFunctors["BOX"]["BOX"] = new CollDetectBoxBox();
detectionFunctors["BOX"]["SPHERE"] = new CollDetectSphereBox();
detectionFunctors["BOX"]["CAPSULE"] = new CollDetectCapsuleBox();
detectionFunctors["BOX"]["PLANE"] = new CollDetectBoxPlane();
detectionFunctors["SPHERE"] = new Array();
detectionFunctors["SPHERE"]["BOX"] = new CollDetectSphereBox();
detectionFunctors["SPHERE"]["SPHERE"] = new CollDetectSphereSphere();
detectionFunctors["SPHERE"]["CAPSULE"] = new CollDetectSphereCapsule();
detectionFunctors["SPHERE"]["PLANE"] = new CollDetectSpherePlane();
detectionFunctors["PLANE"] = new Array();
detectionFunctors["PLANE"]["BOX"] = new CollDetectBoxPlane();
detectionFunctors["PLANE"]["SPHERE"] = new CollDetectSpherePlane();
detectionFunctors["PLANE"]["CAPSULE"] = new CollDetectCapsulePlane();
detectionFunctors["CAPSULE"] = new Array();
detectionFunctors["CAPSULE"]["CAPSULE"] = new CollDetectCapsuleCapsule();
detectionFunctors["CAPSULE"]["BOX"] = new CollDetectCapsuleBox();
detectionFunctors["CAPSULE"]["SPHERE"] = new CollDetectSphereCapsule();
detectionFunctors["CAPSULE"]["PLANE"] = new CollDetectCapsulePlane();
}
public function detectCollisions(_arg1:RigidBody, _arg2:Array):void{
var _local3:CollDetectInfo;
var _local4:CollDetectFunctor;
var _local5:String;
if (!_arg1.isActive()){
return;
};
for (_local5 in collBody) {
if (((((!((_arg1 == collBody[_local5]))) && (checkCollidables(_arg1, collBody[_local5])))) && (!((detectionFunctors[_arg1.type][collBody[_local5].type] == undefined))))){
_local3 = new CollDetectInfo();
_local3.body0 = _arg1;
_local3.body1 = collBody[_local5];
_local4 = detectionFunctors[_local3.body0.type][_local3.body1.type];
_local4.collDetect(_local3, _arg2);
};
};
}
public function segmentIntersect(_arg1:Object, _arg2:JSegment, _arg3:RigidBody):Boolean{
var _local4:Object;
var _local5:String;
_arg1.fracOut = JNumber3D.NUM_HUGE;
_arg1.posOut = new JNumber3D();
_arg1.normalOut = new JNumber3D();
_local4 = new Object();
for (_local5 in collBody) {
if (((!((collBody[_local5] == _arg3))) && (segmentBounding(_arg2, collBody[_local5])))){
if (collBody[_local5].segmentIntersect(_local4, _arg2, collBody[_local5].currentState)){
if (_local4.fracOut < _arg1.fracOut){
_arg1.posOut = _local4.posOut;
_arg1.normalOut = _local4.normalOut;
_arg1.fracOut = _local4.fracOut;
_arg1.bodyOut = collBody[_local5];
};
};
};
};
if (_arg1.fracOut > 1){
return (false);
};
if (_arg1.fracOut < 0){
_arg1.fracOut = 0;
} else {
if (_arg1.fracOut > 1){
_arg1.fracOut = 1;
};
};
return (true);
}
public function removeCollisionBody(_arg1:RigidBody):void{
if (findBody(_arg1)){
collBody.splice(collBody.indexOf(_arg1), 1);
};
}
private function checkCollidables(_arg1:RigidBody, _arg2:RigidBody):Boolean{
var _local3:String;
if ((((_arg1.nonCollidables.length == 0)) && ((_arg2.nonCollidables.length == 0)))){
return (true);
};
for (_local3 in _arg1.nonCollidables) {
if (_arg2 == _arg1.nonCollidables[_local3]){
return (false);
};
};
for (_local3 in _arg2.nonCollidables) {
if (_arg1 == _arg2.nonCollidables[_local3]){
return (false);
};
};
return (true);
}
public function addCollisionBody(_arg1:RigidBody):void{
if (!findBody(_arg1)){
collBody.push(_arg1);
};
}
public function segmentBounding(_arg1:JSegment, _arg2:RigidBody):Boolean{
var _local3:JNumber3D;
var _local4:Number;
var _local5:Number;
var _local6:Number;
_local3 = _arg1.getPoint(0.5);
_local4 = (_arg1.delta.modulo / 2);
if (_arg2.type != "PLANE"){
_local5 = JNumber3D.sub(_local3, _arg2.currentState.position).modulo;
_local6 = (_local4 + _arg2.boundingSphere);
if (_local5 <= _local6){
return (true);
};
return (false);
//unresolved jump
};
return (true);
}
private function findBody(_arg1:RigidBody):Boolean{
var _local2:String;
for (_local2 in collBody) {
if (_arg1 == collBody[_local2]){
return (true);
};
};
return (false);
}
public function removeAllCollisionBodys():void{
collBody = [];
}
public function detectAllCollisions(_arg1:Array, _arg2:Array):void{
var _local3:CollDetectInfo;
var _local4:CollDetectFunctor;
var _local5:String;
var _local6:String;
for (_local5 in _arg1) {
for (_local6 in collBody) {
if (_arg1[_local5] == collBody[_local6]){
} else {
if (((collBody[_local6].isActive()) && ((_arg1[_local5].id > collBody[_local6].id)))){
} else {
if (((checkCollidables(_arg1[_local5], collBody[_local6])) && (!((detectionFunctors[_arg1[_local5].type][collBody[_local6].type] == undefined))))){
_local3 = new CollDetectInfo();
_local3.body0 = _arg1[_local5];
_local3.body1 = collBody[_local6];
_local4 = detectionFunctors[_local3.body0.type][_local3.body1.type];
_local4.collDetect(_local3, _arg2);
};
};
};
};
};
}
}
}//package jiglib.collision
Section 24
//CollPointInfo (jiglib.collision.CollPointInfo)
package jiglib.collision {
import jiglib.math.*;
public class CollPointInfo {
public var minSeparationVel:Number;// = 0
public var denominator:Number;// = 0
public var position:JNumber3D;
public var r0:JNumber3D;
public var accumulatedNormalImpulseAux:Number;// = 0
public var accumulatedNormalImpulse:Number;// = 0
public var initialPenetration:Number;
public var accumulatedFrictionImpulse:JNumber3D;
public var r1:JNumber3D;
public function CollPointInfo(){
minSeparationVel = 0;
denominator = 0;
accumulatedNormalImpulse = 0;
accumulatedNormalImpulseAux = 0;
accumulatedFrictionImpulse = new JNumber3D();
super();
}
}
}//package jiglib.collision
Section 25
//JBox (jiglib.geometry.JBox)
package jiglib.geometry {
import jiglib.plugin.*;
import jiglib.math.*;
import jiglib.physics.*;
public class JBox extends RigidBody {
private var _points:Array;
private var _sideLengths:JNumber3D;
private var _face:Array;
private var _edges:Array;
public function JBox(_arg1:ISkin3D, _arg2:Number, _arg3:Number, _arg4:Number){
_edges = [{ind0:0, ind1:1}, {ind0:3, ind1:1}, {ind0:2, ind1:3}, {ind0:2, ind1:0}, {ind0:4, ind1:5}, {ind0:5, ind1:7}, {ind0:6, ind1:7}, {ind0:4, ind1:6}, {ind0:7, ind1:1}, {ind0:5, ind1:3}, {ind0:4, ind1:2}, {ind0:6, ind1:0}];
_face = [[6, 7, 1, 0], [5, 4, 2, 3], [3, 1, 7, 5], [4, 6, 0, 2], [1, 3, 2, 0], [7, 6, 4, 5]];
super(_arg1);
_type = "BOX";
_sideLengths = new JNumber3D(_arg2, _arg4, _arg3);
_boundingSphere = (0.5 * _sideLengths.modulo);
initPoint();
mass = 1;
}
public function getVolume():Number{
return (((_sideLengths.x * _sideLengths.y) * _sideLengths.z));
}
public function getCornerPoints(_arg1:PhysicsState):Array{
var _local2:JNumber3D;
var _local3:Array;
var _local4:JMatrix3D;
var _local5:String;
_local3 = [];
_local4 = JMatrix3D.multiply(JMatrix3D.translationMatrix(_arg1.position.x, _arg1.position.y, _arg1.position.z), _arg1.orientation);
for (_local5 in _points) {
_local2 = new JNumber3D(_points[_local5].x, _points[_local5].y, _points[_local5].z);
JMatrix3D.multiplyVector(_local4, _local2);
_local3.push(_local2);
};
return (_local3);
}
override public function segmentIntersect(_arg1:Object, _arg2:JSegment, _arg3:PhysicsState):Boolean{
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:JNumber3D;
var _local11:JNumber3D;
var _local12:JNumber3D;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
_arg1.fracOut = 0;
_arg1.posOut = new JNumber3D();
_arg1.normalOut = new JNumber3D();
_local4 = JNumber3D.NUM_HUGE;
_local5 = -(JNumber3D.NUM_HUGE);
_local6 = JNumber3D.NUM_HUGE;
_local7 = 0;
_local8 = 0;
_local9 = 0;
_local10 = JNumber3D.sub(_arg3.position, _arg2.origin);
_local11 = JNumber3D.multiply(_sideLengths, 0.5);
_local9 = 0;
while (_local9 < 3) {
_local13 = JNumber3D.dot(_arg3.orientation.getCols()[_local9], _local10);
_local14 = JNumber3D.dot(_arg3.orientation.getCols()[_local9], _arg2.delta);
if (Math.abs(_local14) > JNumber3D.NUM_TINY){
_local16 = ((_local13 + _local11.toArray()[_local9]) / _local14);
_local17 = ((_local13 - _local11.toArray()[_local9]) / _local14);
if (_local16 > _local17){
_local15 = _local16;
_local16 = _local17;
_local17 = _local15;
};
if (_local16 > _local5){
_local5 = _local16;
_local7 = _local9;
};
if (_local17 < _local6){
_local6 = _local17;
_local8 = _local9;
};
if (_local5 > _local6){
return (false);
};
if (_local6 < 0){
return (false);
};
} else {
if (((((-(_local13) - _local11.toArray()[_local9]) > 0)) || (((-(_local13) + _local11.toArray()[_local9]) < 0)))){
return (false);
};
};
_local9++;
};
if (_local5 > 0){
_local9 = _local7;
_local4 = _local5;
} else {
_local9 = _local8;
_local4 = _local6;
};
if (_local4 < 0){
_local4 = 0;
};
if (_local4 > 1){
_local4 = 1;
};
if (_local4 > (1 - JNumber3D.NUM_TINY)){
return (false);
};
_arg1.fracOut = _local4;
_arg1.posOut = _arg2.getPoint(_local4);
if (JNumber3D.dot(_arg3.orientation.getCols()[_local9], _arg2.delta) < 0){
_arg1.normalOut = JNumber3D.multiply(_arg3.orientation.getCols()[_local9], -1);
} else {
_arg1.normalOut = _arg3.orientation.getCols()[_local9];
};
_arg1.normalOut.normalize();
return (true);
}
public function getSqDistanceToPoint(_arg1:PhysicsState, _arg2:Object, _arg3:JNumber3D):Number{
var _local4:Number;
var _local5:Number;
var _local6:JNumber3D;
_arg2.pos = JNumber3D.sub(_arg3, _arg1.position);
JMatrix3D.multiplyVector(JMatrix3D.transpose(_arg1.orientation), _arg2.pos);
_local4 = 0;
_local5 = 0;
_local6 = getHalfSideLengths();
if (_arg2.pos.x < -(_local6.x)){
_local4 = (_arg2.pos.x + _local6.x);
_local5 = (_local5 + (_local4 * _local4));
_arg2.pos.x = -(_local6.x);
} else {
if (_arg2.pos.x > _local6.x){
_local4 = (_arg2.pos.x - _local6.x);
_local5 = (_local5 + (_local4 * _local4));
_arg2.pos.x = _local6.x;
};
};
if (_arg2.pos.y < -(_local6.y)){
_local4 = (_arg2.pos.y + _local6.y);
_local5 = (_local5 + (_local4 * _local4));
_arg2.pos.y = -(_local6.y);
} else {
if (_arg2.pos.y > _local6.y){
_local4 = (_arg2.pos.y - _local6.y);
_local5 = (_local5 + (_local4 * _local4));
_arg2.pos.y = _local6.y;
};
};
if (_arg2.pos.z < -(_local6.z)){
_local4 = (_arg2.pos.z + _local6.z);
_local5 = (_local5 + (_local4 * _local4));
_arg2.pos.z = -(_local6.z);
} else {
if (_arg2.pos.z > _local6.z){
_local4 = (_arg2.pos.z - _local6.z);
_local5 = (_local5 + (_local4 * _local4));
_arg2.pos.z = _local6.z;
};
};
JMatrix3D.multiplyVector(_arg1.orientation, _arg2.pos);
_arg2.pos = JNumber3D.add(_arg1.position, _arg2.pos);
return (_local5);
}
public function get edges():Array{
return (_edges);
}
private function initPoint():void{
var _local1:JNumber3D;
_local1 = getHalfSideLengths();
_points = [];
_points[0] = new JNumber3D(_local1.x, -(_local1.y), _local1.z);
_points[1] = new JNumber3D(_local1.x, _local1.y, _local1.z);
_points[2] = new JNumber3D(-(_local1.x), -(_local1.y), _local1.z);
_points[3] = new JNumber3D(-(_local1.x), _local1.y, _local1.z);
_points[4] = new JNumber3D(-(_local1.x), -(_local1.y), -(_local1.z));
_points[5] = new JNumber3D(-(_local1.x), _local1.y, -(_local1.z));
_points[6] = new JNumber3D(_local1.x, -(_local1.y), -(_local1.z));
_points[7] = new JNumber3D(_local1.x, _local1.y, -(_local1.z));
}
public function pointIntersect(_arg1:JNumber3D):Boolean{
var _local2:JNumber3D;
var _local3:JNumber3D;
var _local4:JNumber3D;
var _local5:int;
_local2 = JNumber3D.sub(_arg1, currentState.position);
_local3 = JNumber3D.multiply(_sideLengths, 0.5);
while (_local5 < 3) {
_local4 = currentState.orientation.getCols()[_local5].clone();
_local4.normalize();
if (Math.abs(JNumber3D.dot(_local4, _local2)) > (_local3.toArray()[_local5] + JNumber3D.NUM_TINY)){
return (false);
};
_local5++;
};
return (true);
}
public function getHalfSideLengths():JNumber3D{
return (JNumber3D.multiply(_sideLengths, 0.5));
}
public function getSurfaceArea():Number{
return ((2 * (((_sideLengths.x * _sideLengths.y) + (_sideLengths.x * _sideLengths.z)) + (_sideLengths.y * _sideLengths.z))));
}
public function getSupportVertices(_arg1:JNumber3D):Array{
var _local2:Array;
var _local3:Array;
var _local4:JNumber3D;
var _local5:Array;
var _local6:uint;
var _local7:int;
var _local8:int;
var _local9:int;
var _local10:int;
var _local11:int;
_local2 = [];
_local3 = new Array(3);
_local5 = currentState.orientation.getCols();
_local5[0].normalize();
_local5[1].normalize();
_local5[2].normalize();
_local6 = 0;
while (_local6 < 3) {
_local3[_local6] = JNumber3D.dot(_arg1, _local5[_local6]);
if (Math.abs(_local3[_local6]) > (1 - 0.001)){
_local7 = ((_local3[_local6])<0) ? (_local6 * 2) : ((_local6 * 2) + 1);
_local8 = 0;
while (_local8 < 4) {
_local4 = _points[_face[_local7][_local8]];
_local2[_local8] = currentState.position.clone();
_local2[_local8] = JNumber3D.add(_local2[_local8], JNumber3D.multiply(_local5[0], _local4.x));
_local2[_local8] = JNumber3D.add(_local2[_local8], JNumber3D.multiply(_local5[1], _local4.y));
_local2[_local8] = JNumber3D.add(_local2[_local8], JNumber3D.multiply(_local5[2], _local4.z));
_local8++;
};
return (_local2);
};
_local6++;
};
_local6 = 0;
while (_local6 < 3) {
if (Math.abs(_local3[_local6]) < 0.005){
_local10 = ((_local6 + 1) % 3);
_local11 = ((_local6 + 2) % 3);
_local4 = currentState.position.clone();
_local9 = ((_local3[_local10])>0) ? -1 : 1;
_local4 = JNumber3D.add(_local4, JNumber3D.multiply(_local5[_local10], ((_local9 * _sideLengths.toArray()[_local10]) / 2)));
_local9 = ((_local3[_local11])>0) ? -1 : 1;
_local4 = JNumber3D.add(_local4, JNumber3D.multiply(_local5[_local11], ((_local9 * _sideLengths.toArray()[_local11]) / 2)));
_local2[0] = JNumber3D.add(_local4, JNumber3D.multiply(_local5[_local6], (_sideLengths.toArray()[_local6] / 2)));
_local2[1] = JNumber3D.add(_local4, JNumber3D.multiply(_local5[_local6], (-(_sideLengths.toArray()[_local6]) / 2)));
return (_local2);
};
_local6++;
};
_local2[0] = currentState.position.clone();
_local9 = ((_local3[0])>0) ? -1 : 1;
_local2[0] = JNumber3D.add(_local2[0], JNumber3D.multiply(_local5[0], ((_local9 * _sideLengths.x) / 2)));
_local9 = ((_local3[1])>0) ? -1 : 1;
_local2[0] = JNumber3D.add(_local2[0], JNumber3D.multiply(_local5[1], ((_local9 * _sideLengths.y) / 2)));
_local9 = ((_local3[2])>0) ? -1 : 1;
_local2[0] = JNumber3D.add(_local2[0], JNumber3D.multiply(_local5[2], ((_local9 * _sideLengths.z) / 2)));
return (_local2);
}
public function getSpan(_arg1:JNumber3D):Object{
var _local2:Object;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
_local2 = new Object();
_local3 = (Math.abs(JNumber3D.dot(_arg1, currentState.orientation.getCols()[0])) * (0.5 * _sideLengths.x));
_local4 = (Math.abs(JNumber3D.dot(_arg1, currentState.orientation.getCols()[1])) * (0.5 * _sideLengths.y));
_local5 = (Math.abs(JNumber3D.dot(_arg1, currentState.orientation.getCols()[2])) * (0.5 * _sideLengths.z));
_local6 = ((_local3 + _local4) + _local5);
_local7 = JNumber3D.dot(currentState.position, _arg1);
_local2.min = (_local7 - _local6);
_local2.max = (_local7 + _local6);
return (_local2);
}
override public function getInertiaProperties(_arg1:Number):JMatrix3D{
var _local2:JMatrix3D;
_local2 = new JMatrix3D();
_local2.n11 = ((_arg1 / 12) * ((_sideLengths.y * _sideLengths.y) + (_sideLengths.z * _sideLengths.z)));
_local2.n22 = ((_arg1 / 12) * ((_sideLengths.x * _sideLengths.x) + (_sideLengths.z * _sideLengths.z)));
_local2.n33 = ((_arg1 / 12) * ((_sideLengths.x * _sideLengths.x) + (_sideLengths.y * _sideLengths.y)));
return (_local2);
}
public function getDistanceToPoint(_arg1:PhysicsState, _arg2:Object, _arg3:JNumber3D):Number{
return (Math.sqrt(getSqDistanceToPoint(_arg1, _arg2, _arg3)));
}
public function set sideLengths(_arg1:JNumber3D):void{
_sideLengths = _arg1.clone();
_boundingSphere = (0.5 * _sideLengths.modulo);
initPoint();
setInertia(getInertiaProperties(mass));
setActive();
}
public function get sideLengths():JNumber3D{
return (_sideLengths);
}
}
}//package jiglib.geometry
Section 26
//JCapsule (jiglib.geometry.JCapsule)
package jiglib.geometry {
import jiglib.plugin.*;
import jiglib.math.*;
import jiglib.physics.*;
public class JCapsule extends RigidBody {
private var _length:Number;
private var _radius:Number;
public function JCapsule(_arg1:ISkin3D, _arg2:Number, _arg3:Number){
super(_arg1);
_type = "CAPSULE";
_radius = _arg2;
_length = _arg3;
_boundingSphere = getBoundingSphere(_arg2, _arg3);
mass = 1;
}
private function getVolume():Number{
return (((((((4 / 3) * Math.PI) * _radius) * _radius) * _radius) + (((_length * Math.PI) * _radius) * _radius)));
}
public function set radius(_arg1:Number):void{
_radius = _arg1;
_boundingSphere = getBoundingSphere(_radius, _length);
setInertia(getInertiaProperties(mass));
setActive();
}
override public function segmentIntersect(_arg1:Object, _arg2:JSegment, _arg3:PhysicsState):Boolean{
var _local4:JNumber3D;
var _local5:Number;
var _local6:Number;
var _local7:JSegment;
var _local8:JNumber3D;
var _local9:JNumber3D;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:Number;
var _local20:Number;
_arg1.fracOut = 0;
_arg1.posOut = new JNumber3D();
_arg1.normalOut = new JNumber3D();
_local4 = _arg2.delta;
_local5 = JNumber3D.dot(_local4, _local4);
_local6 = (_radius * _radius);
_local7 = new JSegment(getBottomPos(_arg3), _arg3.orientation.getCols()[1]);
_local8 = _local7.delta;
_local9 = JNumber3D.sub(_local7.origin, _arg2.origin);
_local10 = JNumber3D.dot(_local8, _local8);
if (Math.abs(_local10) < JNumber3D.NUM_TINY){
return (false);
};
_local11 = JNumber3D.dot(_local8, _local4);
_local12 = JNumber3D.dot(_local9, _local4);
_local13 = JNumber3D.dot(_local8, _local9);
_local14 = JNumber3D.dot(_local9, _local9);
_local15 = JNumber3D.sub(_local9, JNumber3D.divide(JNumber3D.multiply(_local8, _local13), _local10)).modulo2;
if (_local15 < _local6){
_arg1.fracOut = 0;
_arg1.posOut = _arg2.origin.clone();
_arg1.normalOut = JNumber3D.sub(_arg1.posOut, getBottomPos(_arg3));
_arg1.normalOut = JNumber3D.sub(_arg1.normalOut, JNumber3D.multiply(_arg3.orientation.getCols()[1], JNumber3D.dot(_arg1.normalOut, _arg3.orientation.getCols()[1])));
_arg1.normalOut.normalize();
return (true);
};
_local16 = ((_local10 * _local5) - (_local11 * _local11));
if (Math.abs(_local16) < JNumber3D.NUM_TINY){
return (false);
};
_local17 = (2 * ((_local13 * _local11) - (_local10 * _local12)));
_local18 = ((_local10 * (_local14 - _local6)) - (_local13 * _local13));
_local19 = ((_local17 * _local17) - ((4 * _local16) * _local18));
if (_local19 < 0){
return (false);
};
_local20 = ((-(_local17) - Math.sqrt(_local19)) / (2 * _local16));
if ((((_local20 < 0)) || ((_local20 > 1)))){
return (false);
};
_arg1.fracOut = _local20;
_arg1.posOut = _arg2.getPoint(_local20);
_arg1.normalOut = JNumber3D.sub(_arg1.posOut, getBottomPos(_arg3));
_arg1.normalOut = JNumber3D.sub(_arg1.normalOut, JNumber3D.multiply(_arg3.orientation.getCols()[1], JNumber3D.dot(_arg1.normalOut, _arg3.orientation.getCols()[1])));
_arg1.normalOut.normalize();
return (true);
}
public function getEndPos(_arg1:PhysicsState):JNumber3D{
var _local2:JNumber3D;
_local2 = _arg1.orientation.getCols()[1];
_local2.normalize();
return (JNumber3D.add(_arg1.position, JNumber3D.multiply(_local2, (_length / 2))));
}
public function getBottomPos(_arg1:PhysicsState):JNumber3D{
var _local2:JNumber3D;
_local2 = _arg1.orientation.getCols()[1];
_local2.normalize();
return (JNumber3D.add(_arg1.position, JNumber3D.multiply(_local2, (-(_length) / 2))));
}
private function getBoundingSphere(_arg1:Number, _arg2:Number):Number{
return ((Math.sqrt((Math.pow((_arg2 / 2), 2) + (_arg1 * _arg1))) + _arg1));
}
public function get radius():Number{
return (_radius);
}
public function set length(_arg1:Number):void{
_length = _arg1;
_boundingSphere = getBoundingSphere(_radius, _length);
setInertia(getInertiaProperties(mass));
setActive();
}
override public function getInertiaProperties(_arg1:Number):JMatrix3D{
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:JMatrix3D;
_local2 = (((((_arg1 * Math.PI) * _radius) * _radius) * _length) / getVolume());
_local3 = ((((0.25 * _local2) * _radius) * _radius) + ((((1 / 12) * _local2) * _length) * _length));
_local4 = (((0.5 * _local2) * _radius) * _radius);
_local5 = _local3;
_local6 = (_arg1 - _local2);
_local3 = (_local3 + ((((0.4 * _local6) * _radius) * _radius) + (_local6 * Math.pow((0.5 * _length), 2))));
_local4 = (_local4 + (((0.2 * _local6) * _radius) * _radius));
_local5 = (_local5 + ((((0.4 * _local6) * _radius) * _radius) + (_local6 * Math.pow((0.5 * _length), 2))));
_local7 = new JMatrix3D();
_local7.n11 = _local3;
_local7.n22 = _local4;
_local7.n33 = _local5;
return (_local7);
}
public function get length():Number{
return (_length);
}
}
}//package jiglib.geometry
Section 27
//JPlane (jiglib.geometry.JPlane)
package jiglib.geometry {
import jiglib.plugin.*;
import jiglib.math.*;
import jiglib.physics.*;
public class JPlane extends RigidBody {
private var _normal:JNumber3D;
private var _distance:Number;
public function JPlane(_arg1:ISkin3D){
super(_arg1);
_type = "PLANE";
_normal = new JNumber3D(0, 0, -1);
_distance = 0;
this.movable = false;
}
override public function segmentIntersect(_arg1:Object, _arg2:JSegment, _arg3:PhysicsState):Boolean{
var _local4:Number;
var _local5:Number;
var _local6:Number;
_arg1.fracOut = 0;
_arg1.posOut = new JNumber3D();
_arg1.normalOut = new JNumber3D();
_local4 = 0;
_local6 = JNumber3D.dot(_normal, _arg2.delta);
if (Math.abs(_local6) > JNumber3D.NUM_TINY){
_local5 = ((-1 * (JNumber3D.dot(_normal, _arg2.origin) - _distance)) / _local6);
if ((((_local5 < 0)) || ((_local5 > 1)))){
return (false);
};
_local4 = _local5;
_arg1.fracOut = _local4;
_arg1.posOut = _arg2.getPoint(_local4);
_arg1.normalOut = _normal.clone();
_arg1.normalOut.normalize();
return (true);
//unresolved jump
};
return (false);
}
override protected function updateState():void{
super.updateState();
_normal = new JNumber3D(0, 0, -1);
JMatrix3D.multiplyVector(_currState.orientation, _normal);
_distance = JNumber3D.dot(_currState.position, _normal);
}
public function pointPlaneDistance(_arg1:JNumber3D):Number{
return ((JNumber3D.dot(_normal, _arg1) - _distance));
}
public function get normal():JNumber3D{
return (_normal);
}
public function get distance():Number{
return (_distance);
}
}
}//package jiglib.geometry
Section 28
//JRay (jiglib.geometry.JRay)
package jiglib.geometry {
import jiglib.math.*;
public class JRay {
public var origin:JNumber3D;
public var dir:JNumber3D;
public function JRay(_arg1:JNumber3D, _arg2:JNumber3D){
origin = _arg1;
dir = _arg2;
}
public function getOrigin(_arg1:Number):JNumber3D{
return (JNumber3D.add(origin, JNumber3D.multiply(dir, _arg1)));
}
}
}//package jiglib.geometry
Section 29
//JSegment (jiglib.geometry.JSegment)
package jiglib.geometry {
import jiglib.math.*;
import jiglib.physics.*;
public class JSegment {
private var _origin:JNumber3D;
private var _delta:JNumber3D;
public function JSegment(_arg1:JNumber3D, _arg2:JNumber3D){
_origin = _arg1;
_delta = _arg2;
}
private function case0(_arg1:Object, _arg2:int, _arg3:int, _arg4:int, _arg5:JNumber3D, _arg6:JBox):void{
var _local7:JNumber3D;
var _local8:Array;
var _local9:Array;
var _local10:Array;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:Number;
_local7 = _arg6.getHalfSideLengths();
_local8 = _local7.toArray();
_local9 = _arg1.rkPnt.toArray();
_local10 = _arg5.toArray();
_local11 = (_local9[_arg2] - _local8[_arg2]);
_local12 = (_local9[_arg3] - _local8[_arg3]);
_local13 = (_local10[_arg3] * _local11);
_local14 = (_local10[_arg2] * _local12);
if (_local13 >= _local14){
_local9[_arg2] = _local8[_arg2];
_local18 = (_local9[_arg3] + _local8[_arg3]);
_local15 = (_local13 - (_local10[_arg2] * _local18));
if (_local15 >= 0){
_local16 = (1 / ((_local10[_arg2] * _local10[_arg2]) + (_local10[_arg3] * _local10[_arg3])));
_arg1.rfSqrDistance = (_arg1.rfSqrDistance + ((_local15 * _local15) * _local16));
_local9[_arg3] = -(_local8[_arg3]);
_arg1.pfLParam = (-(((_local10[_arg2] * _local11) + (_local10[_arg3] * _local18))) * _local16);
} else {
_local17 = (1 / _local10[_arg2]);
_local9[_arg3] = (_local9[_arg3] - (_local13 * _local17));
_arg1.pfLParam = (-(_local11) * _local17);
};
_arg1.rkPnt.copyFromArray(_local9);
} else {
_local9[_arg3] = _local8[_arg3];
_local19 = (_local9[_arg2] + _local8[_arg2]);
_local15 = (_local14 - (_local10[_arg3] * _local19));
if (_local15 >= 0){
_local16 = (1 / ((_local10[_arg2] * _local10[_arg2]) + (_local10[_arg3] * _local10[_arg3])));
_arg1.rfSqrDistance = (_arg1.rfSqrDistance + ((_local15 * _local15) * _local16));
_local9[_arg2] = -(_local8[_arg2]);
_arg1.pfLParam = (-(((_local10[_arg2] * _local19) + (_local10[_arg3] * _local12))) * _local16);
} else {
_local17 = (1 / _local10[_arg3]);
_local9[_arg2] = (_local9[_arg2] - (_local14 * _local17));
_arg1.pfLParam = (-(_local12) * _local17);
};
_arg1.rkPnt.copyFromArray(_local9);
};
if (_local9[_arg4] < -(_local8[_arg4])){
_local15 = (_local9[_arg4] + _local8[_arg4]);
_arg1.rfSqrDistance = (_arg1.rfSqrDistance + (_local15 * _local15));
_local9[_arg4] = -(_local8[_arg4]);
} else {
if (_local9[_arg4] > _local8[_arg4]){
_local15 = (_local9[_arg4] - _local8[_arg4]);
_arg1.rfSqrDistance = (_arg1.rfSqrDistance + (_local15 * _local15));
_local9[_arg4] = _local8[_arg4];
};
};
_arg1.rkPnt.copyFromArray(_local9);
}
public function segmentSegmentDistanceSq(_arg1:Object, _arg2:JSegment):Number{
var _local3:JNumber3D;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
_arg1.t0 = 0;
_arg1.t1 = 0;
_local3 = JNumber3D.sub(_origin, _arg2.origin);
_local4 = _delta.modulo2;
_local5 = -(JNumber3D.dot(_delta, _arg2.delta));
_local6 = _arg2.delta.modulo2;
_local7 = JNumber3D.dot(_local3, _delta);
_local8 = _local3.modulo2;
_local9 = Math.abs(((_local4 * _local6) - (_local5 * _local5)));
if (_local9 >= JNumber3D.NUM_TINY){
_local10 = -(JNumber3D.dot(_local3, _arg2.delta));
_local11 = ((_local5 * _local10) - (_local6 * _local7));
_local12 = ((_local5 * _local7) - (_local4 * _local10));
if (_local11 >= 0){
if (_local11 <= _local9){
if (_local12 >= 0){
if (_local12 <= _local9){
_local15 = (1 / _local9);
_local11 = (_local11 * _local15);
_local12 = (_local12 * _local15);
_local13 = (((_local11 * (((_local4 * _local11) + (_local5 * _local12)) + (2 * _local7))) + (_local12 * (((_local5 * _local11) + (_local6 * _local12)) + (2 * _local10)))) + _local8);
} else {
_local12 = 1;
_local14 = (_local5 + _local7);
if (_local14 >= 0){
_local11 = 0;
_local13 = ((_local6 + (2 * _local10)) + _local8);
} else {
if (-(_local14) >= _local4){
_local11 = 1;
_local13 = (((_local4 + _local6) + _local8) + (2 * (_local10 + _local14)));
} else {
_local11 = (-(_local14) / _local4);
_local13 = ((((_local14 * _local11) + _local6) + (2 * _local10)) + _local8);
};
};
};
} else {
_local12 = 0;
if (_local7 >= 0){
_local11 = 0;
_local13 = _local8;
} else {
if (-(_local7) >= _local4){
_local11 = 1;
_local13 = ((_local4 + (2 * _local7)) + _local8);
} else {
_local11 = (-(_local7) / _local4);
_local13 = ((_local7 * _local11) + _local8);
};
};
};
} else {
if (_local12 >= 0){
if (_local12 <= _local9){
_local11 = 1;
_local14 = (_local5 + _local10);
if (_local14 >= 0){
_local12 = 0;
_local13 = ((_local4 + (2 * _local7)) + _local8);
} else {
if (-(_local14) >= _local6){
_local12 = 1;
_local13 = (((_local4 + _local6) + _local8) + (2 * (_local7 + _local14)));
} else {
_local12 = (-(_local14) / _local6);
_local13 = ((((_local14 * _local12) + _local4) + (2 * _local7)) + _local8);
};
};
} else {
_local14 = (_local5 + _local7);
if (-(_local14) <= _local4){
_local12 = 1;
if (_local14 >= 0){
_local11 = 0;
_local13 = ((_local6 + (2 * _local10)) + _local8);
} else {
_local11 = (-(_local14) / _local4);
_local13 = ((((_local14 * _local11) + _local6) + (2 * _local10)) + _local8);
};
} else {
_local11 = 1;
_local14 = (_local5 + _local10);
if (_local14 >= 0){
_local12 = 0;
_local13 = ((_local4 + (2 * _local7)) + _local8);
} else {
if (-(_local14) >= _local6){
_local12 = 1;
_local13 = (((_local4 + _local6) + _local8) + (2 * (_local7 + _local14)));
} else {
_local12 = (-(_local14) / _local6);
_local13 = ((((_local14 * _local12) + _local4) + (2 * _local7)) + _local8);
};
};
};
};
} else {
if (-(_local7) < _local4){
_local12 = 0;
if (_local7 >= 0){
_local11 = 0;
_local13 = _local8;
} else {
_local11 = (-(_local7) / _local4);
_local13 = ((_local7 * _local11) + _local8);
};
} else {
_local11 = 1;
_local14 = (_local5 + _local10);
if (_local14 >= 0){
_local12 = 0;
_local13 = ((_local4 + (2 * _local7)) + _local8);
} else {
if (-(_local14) >= _local6){
_local12 = 1;
_local13 = (((_local4 + _local6) + _local8) + (2 * (_local7 + _local14)));
} else {
_local12 = (-(_local14) / _local6);
_local13 = ((((_local14 * _local12) + _local4) + (2 * _local7)) + _local8);
};
};
};
};
};
} else {
if (_local12 >= 0){
if (_local12 <= _local9){
_local11 = 0;
if (_local10 >= 0){
_local12 = 0;
_local13 = _local8;
} else {
if (-(_local10) >= _local6){
_local12 = 1;
_local13 = ((_local6 + (2 * _local10)) + _local8);
} else {
_local12 = (-(_local10) / _local6);
_local13 = ((_local10 * _local12) + _local8);
};
};
} else {
_local14 = (_local5 + _local7);
if (_local14 < 0){
_local12 = 1;
if (-(_local14) >= _local4){
_local11 = 1;
_local13 = (((_local4 + _local6) + _local8) + (2 * (_local10 + _local14)));
} else {
_local11 = (-(_local14) / _local4);
_local13 = ((((_local14 * _local11) + _local6) + (2 * _local10)) + _local8);
};
} else {
_local11 = 0;
if (_local10 >= 0){
_local12 = 0;
_local13 = _local8;
} else {
if (-(_local10) >= _local6){
_local12 = 1;
_local13 = ((_local6 + (2 * _local10)) + _local8);
} else {
_local12 = (-(_local10) / _local6);
_local13 = ((_local10 * _local12) + _local8);
};
};
};
};
} else {
if (_local7 < 0){
_local12 = 0;
if (-(_local7) >= _local4){
_local11 = 1;
_local13 = ((_local4 + (2 * _local7)) + _local8);
} else {
_local11 = (-(_local7) / _local4);
_local13 = ((_local7 * _local11) + _local8);
};
} else {
_local11 = 0;
if (_local10 >= 0){
_local12 = 0;
_local13 = _local8;
} else {
if (-(_local10) >= _local6){
_local12 = 1;
_local13 = ((_local6 + (2 * _local10)) + _local8);
} else {
_local12 = (-(_local10) / _local6);
_local13 = ((_local10 * _local12) + _local8);
};
};
};
};
};
} else {
if (_local5 > 0){
if (_local7 >= 0){
_local11 = 0;
_local12 = 0;
_local13 = _local8;
} else {
if (-(_local7) <= _local4){
_local11 = (-(_local7) / _local4);
_local12 = 0;
_local13 = ((_local7 * _local11) + _local8);
} else {
_local10 = -(JNumber3D.dot(_local3, _arg2.delta));
_local11 = 1;
_local14 = (_local4 + _local7);
if (-(_local14) >= _local5){
_local12 = 1;
_local13 = (((_local4 + _local6) + _local8) + (2 * ((_local5 + _local7) + _local10)));
} else {
_local12 = (-(_local14) / _local5);
_local13 = (((_local4 + (2 * _local7)) + _local8) + (_local12 * ((_local6 * _local12) + (2 * (_local5 + _local10)))));
};
};
};
} else {
if (-(_local7) >= _local4){
_local11 = 1;
_local12 = 0;
_local13 = ((_local4 + (2 * _local7)) + _local8);
} else {
if (_local7 <= 0){
_local11 = (-(_local7) / _local4);
_local12 = 0;
_local13 = ((_local7 * _local11) + _local8);
} else {
_local10 = -(JNumber3D.dot(_local3, _arg2.delta));
_local11 = 0;
if (_local7 >= -(_local5)){
_local12 = 1;
_local13 = ((_local6 + (2 * _local10)) + _local8);
} else {
_local12 = (-(_local7) / _local5);
_local13 = (_local8 + (_local12 * ((2 * _local10) + (_local6 * _local12))));
};
};
};
};
};
_arg1.t0 = _local11;
_arg1.t1 = _local12;
return (Math.abs(_local13));
}
private function sqrDistanceLine(_arg1:Object, _arg2:JRay, _arg3:JBox, _arg4:PhysicsState):Number{
var _local5:JNumber3D;
var _local6:JNumber3D;
var _local7:JNumber3D;
var _local8:Array;
var _local9:Array;
var _local10:Array;
var _local11:int;
var _local12:Object;
_arg1.num = 0;
_arg1.num0 = 0;
_arg1.num1 = 0;
_arg1.num2 = 0;
_local5 = JNumber3D.sub(_arg2.origin, _arg4.position);
_local6 = new JNumber3D(JNumber3D.dot(_local5, _arg4.orientation.getCols()[0]), JNumber3D.dot(_local5, _arg4.orientation.getCols()[1]), JNumber3D.dot(_local5, _arg4.orientation.getCols()[2]));
_local7 = new JNumber3D(JNumber3D.dot(_arg2.dir, _arg4.orientation.getCols()[0]), JNumber3D.dot(_arg2.dir, _arg4.orientation.getCols()[1]), JNumber3D.dot(_arg2.dir, _arg4.orientation.getCols()[2]));
_local8 = _local6.toArray();
_local9 = _local7.toArray();
_local10 = new Array(3);
_local11 = 0;
while (_local11 < 3) {
if (_local9[_local11] < 0){
_local8[_local11] = -(_local8[_local11]);
_local9[_local11] = -(_local9[_local11]);
_local10[_local11] = true;
} else {
_local10[_local11] = false;
};
_local11++;
};
_local6.copyFromArray(_local8);
_local7.copyFromArray(_local9);
_local12 = new Object();
_local12.rkPnt = _local6.clone();
_local12.pfLParam = 0;
_local12.rfSqrDistance = 0;
if (_local7.x > 0){
if (_local7.y > 0){
if (_local7.z > 0){
caseNoZeros(_local12, _local7, _arg3);
_arg1.num = _local12.pfLParam;
} else {
case0(_local12, 0, 1, 2, _local7, _arg3);
_arg1.num = _local12.pfLParam;
};
} else {
if (_local7.z > 0){
case0(_local12, 0, 2, 1, _local7, _arg3);
_arg1.num = _local12.pfLParam;
} else {
case00(_local12, 0, 1, 2, _local7, _arg3);
_arg1.num = _local12.pfLParam;
};
};
} else {
if (_local7.y > 0){
if (_local7.z > 0){
case0(_local12, 1, 2, 0, _local7, _arg3);
_arg1.num = _local12.pfLParam;
} else {
case00(_local12, 1, 0, 2, _local7, _arg3);
_arg1.num = _local12.pfLParam;
};
} else {
if (_local7.z > 0){
case00(_local12, 2, 0, 1, _local7, _arg3);
_arg1.num = _local12.pfLParam;
} else {
case000(_local12, _arg3);
_arg1.num = 0;
};
};
};
_local8 = _local12.rkPnt.toArray();
_local11 = 0;
while (_local11 < 3) {
if (_local10[_local11]){
_local8[_local11] = -(_local8[_local11]);
};
_local11++;
};
_local12.rkPnt.copyFromArray(_local8);
_arg1.num0 = _local12.rkPnt.x;
_arg1.num1 = _local12.rkPnt.y;
_arg1.num2 = _local12.rkPnt.z;
return (Math.max(_local12.rfSqrDistance, 0));
}
public function get origin():JNumber3D{
return (_origin);
}
private function caseNoZeros(_arg1:Object, _arg2:JNumber3D, _arg3:JBox):void{
var _local4:JNumber3D;
var _local5:JNumber3D;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
_local4 = _arg3.getHalfSideLengths();
_local5 = new JNumber3D((_arg1.rkPnt.x - _local4.x), (_arg1.rkPnt.y - _local4.y), (_arg1.rkPnt.z - _local4.z));
_local6 = (_arg2.x * _local5.y);
_local7 = (_arg2.y * _local5.x);
if (_local7 >= _local6){
_local8 = (_arg2.z * _local5.x);
_local9 = (_arg2.x * _local5.z);
if (_local8 >= _local9){
face(_arg1, 0, 1, 2, _arg2, _arg3, _local5);
} else {
face(_arg1, 2, 0, 1, _arg2, _arg3, _local5);
};
} else {
_local10 = (_arg2.z * _local5.y);
_local11 = (_arg2.y * _local5.z);
if (_local10 >= _local11){
face(_arg1, 1, 2, 0, _arg2, _arg3, _local5);
} else {
face(_arg1, 2, 0, 1, _arg2, _arg3, _local5);
};
};
}
public function segmentBoxDistanceSq(_arg1:Object, _arg2:JBox, _arg3:PhysicsState):Number{
var _local4:Object;
var _local5:JRay;
var _local6:Number;
_arg1.pfLParam = 0;
_arg1.pfLParam0 = 0;
_arg1.pfLParam1 = 0;
_arg1.pfLParam2 = 0;
_local4 = new Object();
_local5 = new JRay(_origin, _delta);
_local6 = sqrDistanceLine(_local4, _local5, _arg2, _arg3);
if (_local4.num >= 0){
if (_local4.num <= 1){
_arg1.pfLParam = _local4.num;
_arg1.pfLParam0 = _local4.num0;
_arg1.pfLParam1 = _local4.num1;
_arg1.pfLParam2 = _local4.num2;
return (Math.max(_local6, 0));
};
_local6 = sqrDistancePoint(_arg1, JNumber3D.add(_origin, _delta), _arg2, _arg3);
_arg1.pfLParam = 1;
return (Math.max(_local6, 0));
//unresolved jump
};
_local6 = sqrDistancePoint(_arg1, _origin, _arg2, _arg3);
_arg1.pfLParam = 0;
return (Math.max(_local6, 0));
}
public function set origin(_arg1:JNumber3D):void{
_origin = _arg1;
}
private function case000(_arg1:Object, _arg2:JBox):void{
var _local3:Number;
var _local4:JNumber3D;
_local3 = 0;
_local4 = _arg2.getHalfSideLengths();
if (_arg1.rkPnt.x < -(_local4.x)){
_local3 = (_arg1.rkPnt.x + _local4.x);
_arg1.rfSqrDistance = (_arg1.rfSqrDistance + (_local3 * _local3));
_arg1.rkPnt.x = -(_local4.x);
} else {
if (_arg1.rkPnt.x > _local4.x){
_local3 = (_arg1.rkPnt.x - _local4.x);
_arg1.rfSqrDistance = (_arg1.rfSqrDistance + (_local3 * _local3));
_arg1.rkPnt.x = _local4.x;
};
};
if (_arg1.rkPnt.y < -(_local4.y)){
_local3 = (_arg1.rkPnt.y + _local4.y);
_arg1.rfSqrDistance = (_arg1.rfSqrDistance + (_local3 * _local3));
_arg1.rkPnt.y = -(_local4.y);
} else {
if (_arg1.rkPnt.y > _local4.y){
_local3 = (_arg1.rkPnt.y - _local4.y);
_arg1.rfSqrDistance = (_arg1.rfSqrDistance + (_local3 * _local3));
_arg1.rkPnt.y = _local4.y;
};
};
if (_arg1.rkPnt.z < -(_local4.z)){
_local3 = (_arg1.rkPnt.z + _local4.z);
_arg1.rfSqrDistance = (_arg1.rfSqrDistance + (_local3 * _local3));
_arg1.rkPnt.z = -(_local4.z);
} else {
if (_arg1.rkPnt.z > _local4.z){
_local3 = (_arg1.rkPnt.z - _local4.z);
_arg1.rfSqrDistance = (_arg1.rfSqrDistance + (_local3 * _local3));
_arg1.rkPnt.z = _local4.z;
};
};
}
private function sqrDistancePoint(_arg1:Object, _arg2:JNumber3D, _arg3:JBox, _arg4:PhysicsState):Number{
var _local5:JNumber3D;
var _local6:JNumber3D;
var _local7:Number;
var _local8:Number;
var _local9:JNumber3D;
_local5 = JNumber3D.sub(_arg2, _arg4.position);
_local6 = new JNumber3D(JNumber3D.dot(_local5, _arg4.orientation.getCols()[0]), JNumber3D.dot(_local5, _arg4.orientation.getCols()[1]), JNumber3D.dot(_local5, _arg4.orientation.getCols()[2]));
_local7 = 0;
_local9 = _arg3.getHalfSideLengths();
if (_local6.x < -(_local9.x)){
_local8 = (_local6.x + _local9.x);
_local7 = (_local7 + (_local8 * _local8));
_local6.x = -(_local9.x);
} else {
if (_local6.x > _local9.x){
_local8 = (_local6.x - _local9.x);
_local7 = (_local7 + (_local8 * _local8));
_local6.x = _local9.x;
};
};
if (_local6.y < -(_local9.y)){
_local8 = (_local6.y + _local9.y);
_local7 = (_local7 + (_local8 * _local8));
_local6.y = -(_local9.y);
} else {
if (_local6.y > _local9.y){
_local8 = (_local6.y - _local9.y);
_local7 = (_local7 + (_local8 * _local8));
_local6.y = _local9.y;
};
};
if (_local6.z < -(_local9.z)){
_local8 = (_local6.z + _local9.z);
_local7 = (_local7 + (_local8 * _local8));
_local6.z = -(_local9.z);
} else {
if (_local6.z > _local9.z){
_local8 = (_local6.z - _local9.z);
_local7 = (_local7 + (_local8 * _local8));
_local6.z = _local9.z;
};
};
_arg1.pfLParam0 = _local6.x;
_arg1.pfLParam1 = _local6.y;
_arg1.pfLParam2 = _local6.z;
return (Math.max(_local7, 0));
}
public function set delta(_arg1:JNumber3D):void{
_delta = _arg1;
}
public function getEnd():JNumber3D{
return (JNumber3D.add(_origin, _delta));
}
private function face(_arg1:Object, _arg2:int, _arg3:int, _arg4:int, _arg5:JNumber3D, _arg6:JBox, _arg7:JNumber3D):void{
var _local8:JNumber3D;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:JNumber3D;
var _local16:Array;
var _local17:Array;
var _local18:Array;
var _local19:Array;
var _local20:Array;
_local8 = new JNumber3D();
_local15 = _arg6.getHalfSideLengths();
_local16 = _local15.toArray();
_local17 = _arg1.rkPnt.toArray();
_local18 = _arg5.toArray();
_local19 = _local8.toArray();
_local20 = _arg7.toArray();
_local19[_arg3] = (_local17[_arg3] + _local16[_arg3]);
_local19[_arg4] = (_local17[_arg4] + _local16[_arg4]);
_arg7.copyFromArray(_local19);
if ((_local18[_arg2] * _local19[_arg3]) >= (_local18[_arg3] * _local20[_arg2])){
if ((_local18[_arg2] * _local19[_arg4]) >= (_local18[_arg4] * _local20[_arg2])){
_local17[_arg2] = _local16[_arg2];
_local10 = (1 / _local18[_arg2]);
_local17[_arg3] = (_local17[_arg3] - ((_local18[_arg3] * _local20[_arg2]) * _local10));
_local17[_arg4] = (_local17[_arg4] - ((_local18[_arg4] * _local20[_arg2]) * _local10));
_arg1.pfLParam = (-(_local20[_arg2]) * _local10);
_arg1.rkPnt.copyFromArray(_local17);
} else {
_local9 = ((_local18[_arg2] * _local18[_arg2]) + (_local18[_arg4] * _local18[_arg4]));
_local11 = ((_local9 * _local19[_arg3]) - (_local18[_arg3] * ((_local18[_arg2] * _local20[_arg2]) + (_local18[_arg4] * _local19[_arg4]))));
if (_local11 <= ((2 * _local9) * _local16[_arg3])){
_local13 = (_local11 / _local9);
_local9 = (_local9 + (_local18[_arg3] * _local18[_arg3]));
_local11 = (_local19[_arg3] - _local13);
_local14 = (((_local18[_arg2] * _local20[_arg2]) + (_local18[_arg3] * _local11)) + (_local18[_arg4] * _local19[_arg4]));
_local12 = (-(_local14) / _local9);
_arg1.rfSqrDistance = (_arg1.rfSqrDistance + ((((_local20[_arg2] * _local20[_arg2]) + (_local11 * _local11)) + (_local19[_arg4] * _local19[_arg4])) + (_local14 * _local12)));
_arg1.pfLParam = _local12;
_local17[_arg2] = _local16[_arg2];
_local17[_arg3] = (_local13 - _local16[_arg3]);
_local17[_arg4] = -(_local16[_arg4]);
_arg1.rkPnt.copyFromArray(_local17);
} else {
_local9 = (_local9 + (_local18[_arg3] * _local18[_arg3]));
_local14 = (((_local18[_arg2] * _local20[_arg2]) + (_local18[_arg3] * _local20[_arg3])) + (_local18[_arg4] * _local19[_arg4]));
_local12 = (-(_local14) / _local9);
_arg1.rfSqrDistance = (_arg1.rfSqrDistance + ((((_local20[_arg2] * _local20[_arg2]) + (_local20[_arg3] * _local20[_arg3])) + (_local19[_arg4] * _local19[_arg4])) + (_local14 * _local12)));
_arg1.pfLParam = _local12;
_local17[_arg2] = _local16[_arg2];
_local17[_arg3] = _local16[_arg3];
_local17[_arg4] = -(_local16[_arg4]);
_arg1.rkPnt.copyFromArray(_local17);
};
};
} else {
if ((_local18[_arg2] * _local19[_arg4]) >= (_local18[_arg4] * _local20[_arg2])){
_local9 = ((_local18[_arg2] * _local18[_arg2]) + (_local18[_arg3] * _local18[_arg3]));
_local11 = ((_local9 * _local19[_arg4]) - (_local18[_arg4] * ((_local18[_arg2] * _local20[_arg2]) + (_local18[_arg3] * _local19[_arg3]))));
if (_local11 <= ((2 * _local9) * _local16[_arg4])){
_local13 = (_local11 / _local9);
_local9 = (_local9 + (_local18[_arg4] * _local18[_arg4]));
_local11 = (_local19[_arg4] - _local13);
_local14 = (((_local18[_arg2] * _local20[_arg2]) + (_local18[_arg3] * _local19[_arg3])) + (_local18[_arg4] * _local11));
_local12 = (-(_local14) / _local9);
_arg1.rfSqrDistance = (_arg1.rfSqrDistance + ((((_local20[_arg2] * _local20[_arg2]) + (_local19[_arg3] * _local19[_arg3])) + (_local11 * _local11)) + (_local14 * _local12)));
_arg1.pfLParam = _local12;
_local17[_arg2] = _local16[_arg2];
_local17[_arg3] = -(_local16[_arg3]);
_local17[_arg4] = (_local13 - _local16[_arg4]);
_arg1.rkPnt.copyFromArray(_local17);
} else {
_local9 = (_local9 + (_local18[_arg4] * _local18[_arg4]));
_local14 = (((_local18[_arg2] * _local20[_arg2]) + (_local18[_arg3] * _local19[_arg3])) + (_local18[_arg4] * _local20[_arg4]));
_local12 = (-(_local14) / _local9);
_arg1.rfSqrDistance = (_arg1.rfSqrDistance + ((((_local20[_arg2] * _local20[_arg2]) + (_local19[_arg3] * _local19[_arg3])) + (_local20[_arg4] * _local20[_arg4])) + (_local14 * _local12)));
_arg1.pfLParam = _local12;
_local17[_arg2] = _local16[_arg2];
_local17[_arg3] = -(_local16[_arg3]);
_local17[_arg4] = _local16[_arg4];
_arg1.rkPnt.copyFromArray(_local17);
};
} else {
_local9 = ((_local18[_arg2] * _local18[_arg2]) + (_local18[_arg4] * _local18[_arg4]));
_local11 = ((_local9 * _local19[_arg3]) - (_local18[_arg3] * ((_local18[_arg2] * _local20[_arg2]) + (_local18[_arg4] * _local19[_arg4]))));
if (_local11 >= 0){
if (_local11 <= ((2 * _local9) * _local16[_arg3])){
_local13 = (_local11 / _local9);
_local9 = (_local9 + (_local18[_arg3] * _local18[_arg3]));
_local11 = (_local19[_arg3] - _local13);
_local14 = (((_local18[_arg2] * _local20[_arg2]) + (_local18[_arg3] * _local11)) + (_local18[_arg4] * _local19[_arg4]));
_local12 = (-(_local14) / _local9);
_arg1.rfSqrDistance = (_arg1.rfSqrDistance + ((((_local20[_arg2] * _local20[_arg2]) + (_local11 * _local11)) + (_local19[_arg4] * _local19[_arg4])) + (_local14 * _local12)));
_arg1.pfLParam = _local12;
_local17[_arg2] = _local16[_arg2];
_local17[_arg3] = (_local13 - _local16[_arg3]);
_local17[_arg4] = -(_local16[_arg4]);
_arg1.rkPnt.copyFromArray(_local17);
} else {
_local9 = (_local9 + (_local18[_arg3] * _local18[_arg3]));
_local14 = (((_local18[_arg2] * _local20[_arg2]) + (_local18[_arg3] * _local20[_arg3])) + (_local18[_arg4] * _local19[_arg4]));
_local12 = (-(_local14) / _local9);
_arg1.rfSqrDistance = (_arg1.rfSqrDistance + ((((_local20[_arg2] * _local20[_arg2]) + (_local20[_arg3] * _local20[_arg3])) + (_local19[_arg4] * _local19[_arg4])) + (_local14 * _local12)));
_arg1.pfLParam = _local12;
_local17[_arg2] = _local16[_arg2];
_local17[_arg3] = _local16[_arg3];
_local17[_arg4] = -(_local16[_arg4]);
_arg1.rkPnt.copyFromArray(_local17);
};
return;
};
_local9 = ((_local18[_arg2] * _local18[_arg2]) + (_local18[_arg3] * _local18[_arg3]));
_local11 = ((_local9 * _local19[_arg4]) - (_local18[_arg4] * ((_local18[_arg2] * _local20[_arg2]) + (_local18[_arg3] * _local19[_arg3]))));
if (_local11 >= 0){
if (_local11 <= ((2 * _local9) * _local16[_arg4])){
_local13 = (_local11 / _local9);
_local9 = (_local9 + (_local18[_arg4] * _local18[_arg4]));
_local11 = (_local19[_arg4] - _local13);
_local14 = (((_local18[_arg2] * _local20[_arg2]) + (_local18[_arg3] * _local19[_arg3])) + (_local18[_arg4] * _local11));
_local12 = (-(_local14) / _local9);
_arg1.rfSqrDistance = (_arg1.rfSqrDistance + ((((_local20[_arg2] * _local20[_arg2]) + (_local19[_arg3] * _local19[_arg3])) + (_local11 * _local11)) + (_local14 * _local12)));
_arg1.pfLParam = _local12;
_local17[_arg2] = _local16[_arg2];
_local17[_arg3] = -(_local16[_arg3]);
_local17[_arg4] = (_local13 - _local16[_arg4]);
_arg1.rkPnt.copyFromArray(_local17);
} else {
_local9 = (_local9 + (_local18[_arg4] * _local18[_arg4]));
_local14 = (((_local18[_arg2] * _local20[_arg2]) + (_local18[_arg3] * _local19[_arg3])) + (_local18[_arg4] * _local20[_arg4]));
_local12 = (-(_local14) / _local9);
_arg1.rfSqrDistance = (_arg1.rfSqrDistance + ((((_local20[_arg2] * _local20[_arg2]) + (_local19[_arg3] * _local19[_arg3])) + (_local20[_arg4] * _local20[_arg4])) + (_local14 * _local12)));
_arg1.pfLParam = _local12;
_local17[_arg2] = _local16[_arg2];
_local17[_arg3] = -(_local16[_arg3]);
_local17[_arg4] = _local16[_arg4];
_arg1.rkPnt.copyFromArray(_local17);
};
return;
};
_local9 = (_local9 + (_local18[_arg4] * _local18[_arg4]));
_local14 = (((_local18[_arg2] * _local20[_arg2]) + (_local18[_arg3] * _local19[_arg3])) + (_local18[_arg4] * _local19[_arg4]));
_local12 = (-(_local14) / _local9);
_arg1.rfSqrDistance = (_arg1.rfSqrDistance + ((((_local20[_arg2] * _local20[_arg2]) + (_local19[_arg3] * _local19[_arg3])) + (_local19[_arg4] * _local19[_arg4])) + (_local14 * _local12)));
_arg1.pfLParam = _local12;
_local17[_arg2] = _local16[_arg2];
_local17[_arg3] = -(_local16[_arg3]);
_local17[_arg4] = -(_local16[_arg4]);
_arg1.rkPnt.copyFromArray(_local17);
};
};
}
public function pointSegmentDistanceSq(_arg1:Object, _arg2:JNumber3D):Number{
var _local3:JNumber3D;
var _local4:Number;
var _local5:Number;
_arg1.t = 0;
_local3 = JNumber3D.sub(_arg2, _origin);
_local4 = JNumber3D.dot(_local3, _delta);
if (_local4 <= 0){
_local4 = 0;
} else {
_local5 = _delta.modulo2;
if (_local4 >= _local5){
_local4 = 1;
_local3 = JNumber3D.sub(_local3, _delta);
} else {
_local4 = (_local4 / _local5);
_local3 = JNumber3D.sub(_local3, JNumber3D.multiply(_delta, _local4));
};
};
_arg1.t = _local4;
return (_local3.modulo2);
}
private function case00(_arg1:Object, _arg2:int, _arg3:int, _arg4:int, _arg5:JNumber3D, _arg6:JBox):void{
var _local7:Number;
var _local8:JNumber3D;
var _local9:Array;
var _local10:Array;
var _local11:Array;
_local7 = 0;
_local8 = _arg6.getHalfSideLengths();
_local9 = _local8.toArray();
_local10 = _arg1.rkPnt.toArray();
_local11 = _arg5.toArray();
_arg1.pfLParam = ((_local9[_arg2] - _local10[_arg2]) / _local11[_arg2]);
_local10[_arg2] = _local9[_arg2];
if (_local10[_arg3] < -(_local9[_arg3])){
_local7 = (_local10[_arg3] + _local9[_arg3]);
_arg1.rfSqrDistance = (_arg1.rfSqrDistance + (_local7 * _local7));
_local10[_arg3] = -(_local9[_arg3]);
} else {
if (_local10[_arg3] > _local9[_arg3]){
_local7 = (_local10[_arg3] - _local9[_arg3]);
_arg1.rfSqrDistance = (_arg1.rfSqrDistance + (_local7 * _local7));
_local10[_arg3] = _local9[_arg3];
};
};
if (_local10[_arg4] < -(_local9[_arg4])){
_local7 = (_local10[_arg4] + _local9[_arg4]);
_arg1.rfSqrDistance = (_arg1.rfSqrDistance + (_local7 * _local7));
_local10[_arg4] = -(_local9[_arg4]);
} else {
if (_local10[_arg4] > _local9[_arg4]){
_local7 = (_local10[_arg4] - _local9[_arg4]);
_arg1.rfSqrDistance = (_arg1.rfSqrDistance + (_local7 * _local7));
_local10[_arg4] = _local9[_arg4];
};
};
_arg1.rkPnt.copyFromArray(_local10);
}
public function get delta():JNumber3D{
return (_delta);
}
public function getPoint(_arg1:Number):JNumber3D{
return (JNumber3D.add(_origin, JNumber3D.multiply(_delta, _arg1)));
}
public function clone():JSegment{
return (new JSegment(_origin, _delta));
}
}
}//package jiglib.geometry
Section 30
//JSphere (jiglib.geometry.JSphere)
package jiglib.geometry {
import jiglib.plugin.*;
import jiglib.math.*;
import jiglib.physics.*;
public class JSphere extends RigidBody {
public var name:String;
private var _radius:Number;
public function JSphere(_arg1:ISkin3D, _arg2:Number){
super(_arg1);
_type = "SPHERE";
_radius = _arg2;
_boundingSphere = _radius;
mass = 1;
}
public function set radius(_arg1:Number):void{
_radius = _arg1;
_boundingSphere = _radius;
setInertia(getInertiaProperties(mass));
setActive();
}
override public function segmentIntersect(_arg1:Object, _arg2:JSegment, _arg3:PhysicsState):Boolean{
var _local4:Number;
var _local5:JNumber3D;
var _local6:JNumber3D;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
_arg1.fracOut = 0;
_arg1.posOut = new JNumber3D();
_arg1.normalOut = new JNumber3D();
_local4 = 0;
_local5 = _arg2.delta;
_local6 = JNumber3D.sub(_arg2.origin, _arg3.position);
_local7 = (_radius * _radius);
_local8 = _local5.modulo2;
if (_local8 < _local7){
_arg1.fracOut = 0;
_arg1.posOut = _arg2.origin.clone();
_arg1.normalOut = JNumber3D.sub(_arg1.posOut, _arg3.position);
_arg1.normalOut.normalize();
return (true);
};
_local9 = JNumber3D.dot(_local6, _local5);
_local10 = _local6.modulo2;
_local11 = ((_local9 * _local9) - (_local8 * (_local10 - _local7)));
if (_local11 < 0){
return (false);
};
_local12 = Math.sqrt(_local11);
_local13 = ((-(_local9) - _local12) / _local8);
_local14 = ((-(_local9) + _local12) / _local8);
if ((((_local13 > 1)) || ((_local14 < 0)))){
return (false);
};
_local4 = Math.max(_local13, 0);
_arg1.fracOut = _local4;
_arg1.posOut = _arg2.getPoint(_local4);
_arg1.normalOut = JNumber3D.sub(_arg1.posOut, _arg3.position);
_arg1.normalOut.normalize();
return (true);
}
public function get radius():Number{
return (_radius);
}
override public function getInertiaProperties(_arg1:Number):JMatrix3D{
var _local2:JMatrix3D;
var _local3:Number;
_local2 = new JMatrix3D();
_local3 = (((0.4 * _arg1) * _radius) * _radius);
_local2.n11 = _local3;
_local2.n22 = _local3;
_local2.n33 = _local3;
return (_local2);
}
}
}//package jiglib.geometry
Section 31
//JMatrix3D (jiglib.math.JMatrix3D)
package jiglib.math {
public class JMatrix3D {
public var n11:Number;
public var n13:Number;
public var n14:Number;
public var n12:Number;
public var n21:Number;
public var n22:Number;
public var n23:Number;
public var n24:Number;
public var type:String;// = ""
public var n31:Number;
public var n32:Number;
public var n33:Number;
public var n34:Number;
public var sid:String;
public var n41:Number;
public var n43:Number;
public var n44:Number;
public var n42:Number;
private static var _cos:Function = Math.cos;
private static var _sin:Function = Math.sin;
private static var toDEGREES:Number = 57.2957795130823;
private static var toRADIANS:Number = 0.0174532925199433;
public function JMatrix3D(_arg1:Array=null){
type = "";
super();
if (((!(_arg1)) || ((_arg1.length < 12)))){
n11 = (n22 = (n33 = (n44 = 1)));
n12 = (n13 = (n14 = (n21 = (n23 = (n24 = (n31 = (n32 = (n34 = (n41 = (n42 = (n43 = 0)))))))))));
} else {
n11 = _arg1[0];
n12 = _arg1[1];
n13 = _arg1[2];
n14 = _arg1[3];
n21 = _arg1[4];
n22 = _arg1[5];
n23 = _arg1[6];
n24 = _arg1[7];
n31 = _arg1[8];
n32 = _arg1[9];
n33 = _arg1[10];
n34 = _arg1[11];
if (_arg1.length == 16){
n41 = _arg1[12];
n42 = _arg1[13];
n43 = _arg1[14];
n44 = _arg1[15];
};
};
}
public function calculateMultiply4x4(_arg1:JMatrix3D, _arg2:JMatrix3D):void{
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:Number;
var _local20:Number;
var _local21:Number;
var _local22:Number;
var _local23:Number;
var _local24:Number;
var _local25:Number;
var _local26:Number;
var _local27:Number;
var _local28:Number;
var _local29:Number;
var _local30:Number;
var _local31:Number;
var _local32:Number;
var _local33:Number;
var _local34:Number;
_local3 = _arg1.n11;
_local4 = _arg2.n11;
_local5 = _arg1.n21;
_local6 = _arg2.n21;
_local7 = _arg1.n31;
_local8 = _arg2.n31;
_local9 = _arg1.n41;
_local10 = _arg2.n41;
_local11 = _arg1.n12;
_local12 = _arg2.n12;
_local13 = _arg1.n22;
_local14 = _arg2.n22;
_local15 = _arg1.n32;
_local16 = _arg2.n32;
_local17 = _arg1.n42;
_local18 = _arg2.n42;
_local19 = _arg1.n13;
_local20 = _arg2.n13;
_local21 = _arg1.n23;
_local22 = _arg2.n23;
_local23 = _arg1.n33;
_local24 = _arg2.n33;
_local25 = _arg1.n43;
_local26 = _arg2.n43;
_local27 = _arg1.n14;
_local28 = _arg2.n14;
_local29 = _arg1.n24;
_local30 = _arg2.n24;
_local31 = _arg1.n34;
_local32 = _arg2.n34;
_local33 = _arg1.n44;
_local34 = _arg2.n44;
this.n11 = (((_local3 * _local4) + (_local11 * _local6)) + (_local19 * _local8));
this.n12 = (((_local3 * _local12) + (_local11 * _local14)) + (_local19 * _local16));
this.n13 = (((_local3 * _local20) + (_local11 * _local22)) + (_local19 * _local24));
this.n14 = ((((_local3 * _local28) + (_local11 * _local30)) + (_local19 * _local32)) + _local27);
this.n21 = (((_local5 * _local4) + (_local13 * _local6)) + (_local21 * _local8));
this.n22 = (((_local5 * _local12) + (_local13 * _local14)) + (_local21 * _local16));
this.n23 = (((_local5 * _local20) + (_local13 * _local22)) + (_local21 * _local24));
this.n24 = ((((_local5 * _local28) + (_local13 * _local30)) + (_local21 * _local32)) + _local29);
this.n31 = (((_local7 * _local4) + (_local15 * _local6)) + (_local23 * _local8));
this.n32 = (((_local7 * _local12) + (_local15 * _local14)) + (_local23 * _local16));
this.n33 = (((_local7 * _local20) + (_local15 * _local22)) + (_local23 * _local24));
this.n34 = ((((_local7 * _local28) + (_local15 * _local30)) + (_local23 * _local32)) + _local31);
this.n41 = (((_local9 * _local4) + (_local17 * _local6)) + (_local25 * _local8));
this.n42 = (((_local9 * _local12) + (_local17 * _local14)) + (_local25 * _local16));
this.n43 = (((_local9 * _local20) + (_local17 * _local22)) + (_local25 * _local24));
this.n44 = ((((_local9 * _local28) + (_local17 * _local30)) + (_local25 * _local32)) + _local33);
}
public function get det():Number{
return ((((((this.n11 * this.n22) - (this.n21 * this.n12)) * this.n33) - (((this.n11 * this.n32) - (this.n31 * this.n12)) * this.n23)) + (((this.n21 * this.n32) - (this.n31 * this.n22)) * this.n13)));
}
public function copy3x3(_arg1:JMatrix3D):JMatrix3D{
this.n11 = _arg1.n11;
this.n12 = _arg1.n12;
this.n13 = _arg1.n13;
this.n21 = _arg1.n21;
this.n22 = _arg1.n22;
this.n23 = _arg1.n23;
this.n31 = _arg1.n31;
this.n32 = _arg1.n32;
this.n33 = _arg1.n33;
return (this);
}
public function calculateMultiply(_arg1:JMatrix3D, _arg2:JMatrix3D):void{
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:Number;
var _local20:Number;
var _local21:Number;
var _local22:Number;
var _local23:Number;
var _local24:Number;
var _local25:Number;
var _local26:Number;
_local3 = _arg1.n11;
_local4 = _arg2.n11;
_local5 = _arg1.n21;
_local6 = _arg2.n21;
_local7 = _arg1.n31;
_local8 = _arg2.n31;
_local9 = _arg1.n12;
_local10 = _arg2.n12;
_local11 = _arg1.n22;
_local12 = _arg2.n22;
_local13 = _arg1.n32;
_local14 = _arg2.n32;
_local15 = _arg1.n13;
_local16 = _arg2.n13;
_local17 = _arg1.n23;
_local18 = _arg2.n23;
_local19 = _arg1.n33;
_local20 = _arg2.n33;
_local21 = _arg1.n14;
_local22 = _arg2.n14;
_local23 = _arg1.n24;
_local24 = _arg2.n24;
_local25 = _arg1.n34;
_local26 = _arg2.n34;
this.n11 = (((_local3 * _local4) + (_local9 * _local6)) + (_local15 * _local8));
this.n12 = (((_local3 * _local10) + (_local9 * _local12)) + (_local15 * _local14));
this.n13 = (((_local3 * _local16) + (_local9 * _local18)) + (_local15 * _local20));
this.n14 = ((((_local3 * _local22) + (_local9 * _local24)) + (_local15 * _local26)) + _local21);
this.n21 = (((_local5 * _local4) + (_local11 * _local6)) + (_local17 * _local8));
this.n22 = (((_local5 * _local10) + (_local11 * _local12)) + (_local17 * _local14));
this.n23 = (((_local5 * _local16) + (_local11 * _local18)) + (_local17 * _local20));
this.n24 = ((((_local5 * _local22) + (_local11 * _local24)) + (_local17 * _local26)) + _local23);
this.n31 = (((_local7 * _local4) + (_local13 * _local6)) + (_local19 * _local8));
this.n32 = (((_local7 * _local10) + (_local13 * _local12)) + (_local19 * _local14));
this.n33 = (((_local7 * _local16) + (_local13 * _local18)) + (_local19 * _local20));
this.n34 = ((((_local7 * _local22) + (_local13 * _local24)) + (_local19 * _local26)) + _local25);
}
public function calculateMultiply3x3(_arg1:JMatrix3D, _arg2:JMatrix3D):void{
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:Number;
var _local20:Number;
_local3 = _arg1.n11;
_local4 = _arg2.n11;
_local5 = _arg1.n21;
_local6 = _arg2.n21;
_local7 = _arg1.n31;
_local8 = _arg2.n31;
_local9 = _arg1.n12;
_local10 = _arg2.n12;
_local11 = _arg1.n22;
_local12 = _arg2.n22;
_local13 = _arg1.n32;
_local14 = _arg2.n32;
_local15 = _arg1.n13;
_local16 = _arg2.n13;
_local17 = _arg1.n23;
_local18 = _arg2.n23;
_local19 = _arg1.n33;
_local20 = _arg2.n33;
this.n11 = (((_local3 * _local4) + (_local9 * _local6)) + (_local15 * _local8));
this.n12 = (((_local3 * _local10) + (_local9 * _local12)) + (_local15 * _local14));
this.n13 = (((_local3 * _local16) + (_local9 * _local18)) + (_local15 * _local20));
this.n21 = (((_local5 * _local4) + (_local11 * _local6)) + (_local17 * _local8));
this.n22 = (((_local5 * _local10) + (_local11 * _local12)) + (_local17 * _local14));
this.n23 = (((_local5 * _local16) + (_local11 * _local18)) + (_local17 * _local20));
this.n31 = (((_local7 * _local4) + (_local13 * _local6)) + (_local19 * _local8));
this.n32 = (((_local7 * _local10) + (_local13 * _local12)) + (_local19 * _local14));
this.n33 = (((_local7 * _local16) + (_local13 * _local18)) + (_local19 * _local20));
}
public function get trace():Number{
return ((((this.n11 + this.n22) + this.n33) + 1));
}
public function calculateAdd(_arg1:JMatrix3D, _arg2:JMatrix3D):void{
this.n11 = (_arg1.n11 + _arg2.n11);
this.n12 = (_arg1.n12 + _arg2.n12);
this.n13 = (_arg1.n13 + _arg2.n13);
this.n14 = (_arg1.n14 + _arg2.n14);
this.n21 = (_arg1.n21 + _arg2.n21);
this.n22 = (_arg1.n22 + _arg2.n22);
this.n23 = (_arg1.n23 + _arg2.n23);
this.n24 = (_arg1.n24 + _arg2.n24);
this.n31 = (_arg1.n31 + _arg2.n31);
this.n32 = (_arg1.n32 + _arg2.n32);
this.n33 = (_arg1.n33 + _arg2.n33);
this.n34 = (_arg1.n34 + _arg2.n34);
}
public function getCols():Array{
var _local1:Array;
_local1 = new Array();
_local1[0] = new JNumber3D(n11, n21, n31);
_local1[1] = new JNumber3D(n12, n22, n32);
_local1[2] = new JNumber3D(n13, n23, n33);
return (_local1);
}
public function calculateInverse(_arg1:JMatrix3D):void{
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
_local2 = _arg1.det;
if (Math.abs(_local2) > 0.001){
_local2 = (1 / _local2);
_local3 = _arg1.n11;
_local4 = _arg1.n21;
_local5 = _arg1.n31;
_local6 = _arg1.n12;
_local7 = _arg1.n22;
_local8 = _arg1.n32;
_local9 = _arg1.n13;
_local10 = _arg1.n23;
_local11 = _arg1.n33;
_local12 = _arg1.n14;
_local13 = _arg1.n24;
_local14 = _arg1.n34;
this.n11 = (_local2 * ((_local7 * _local11) - (_local8 * _local10)));
this.n12 = (-(_local2) * ((_local6 * _local11) - (_local8 * _local9)));
this.n13 = (_local2 * ((_local6 * _local10) - (_local7 * _local9)));
this.n14 = (-(_local2) * (((_local6 * ((_local10 * _local14) - (_local11 * _local13))) - (_local7 * ((_local9 * _local14) - (_local11 * _local12)))) + (_local8 * ((_local9 * _local13) - (_local10 * _local12)))));
this.n21 = (-(_local2) * ((_local4 * _local11) - (_local5 * _local10)));
this.n22 = (_local2 * ((_local3 * _local11) - (_local5 * _local9)));
this.n23 = (-(_local2) * ((_local3 * _local10) - (_local4 * _local9)));
this.n24 = (_local2 * (((_local3 * ((_local10 * _local14) - (_local11 * _local13))) - (_local4 * ((_local9 * _local14) - (_local11 * _local12)))) + (_local5 * ((_local9 * _local13) - (_local10 * _local12)))));
this.n31 = (_local2 * ((_local4 * _local8) - (_local5 * _local7)));
this.n32 = (-(_local2) * ((_local3 * _local8) - (_local5 * _local6)));
this.n33 = (_local2 * ((_local3 * _local7) - (_local4 * _local6)));
this.n34 = (-(_local2) * (((_local3 * ((_local7 * _local14) - (_local8 * _local13))) - (_local4 * ((_local6 * _local14) - (_local8 * _local12)))) + (_local5 * ((_local6 * _local13) - (_local7 * _local12)))));
};
}
public function toString():String{
var _local1:String;
_local1 = "";
_local1 = (_local1 + ((((((((int((n11 * 1000)) / 1000) + "\t\t") + (int((n12 * 1000)) / 1000)) + "\t\t") + (int((n13 * 1000)) / 1000)) + "\t\t") + (int((n14 * 1000)) / 1000)) + "\n"));
_local1 = (_local1 + ((((((((int((n21 * 1000)) / 1000) + "\t\t") + (int((n22 * 1000)) / 1000)) + "\t\t") + (int((n23 * 1000)) / 1000)) + "\t\t") + (int((n24 * 1000)) / 1000)) + "\n"));
_local1 = (_local1 + ((((((((int((n31 * 1000)) / 1000) + "\t\t") + (int((n32 * 1000)) / 1000)) + "\t\t") + (int((n33 * 1000)) / 1000)) + "\t\t") + (int((n34 * 1000)) / 1000)) + "\n"));
_local1 = (_local1 + ((((((((int((n41 * 1000)) / 1000) + "\t\t") + (int((n42 * 1000)) / 1000)) + "\t\t") + (int((n43 * 1000)) / 1000)) + "\t\t") + (int((n44 * 1000)) / 1000)) + "\n"));
return (_local1);
}
public function copy(_arg1:JMatrix3D):JMatrix3D{
this.n11 = _arg1.n11;
this.n12 = _arg1.n12;
this.n13 = _arg1.n13;
this.n14 = _arg1.n14;
this.n21 = _arg1.n21;
this.n22 = _arg1.n22;
this.n23 = _arg1.n23;
this.n24 = _arg1.n24;
this.n31 = _arg1.n31;
this.n32 = _arg1.n32;
this.n33 = _arg1.n33;
this.n34 = _arg1.n34;
return (this);
}
public function calculateSub(_arg1:JMatrix3D, _arg2:JMatrix3D):void{
this.n11 = (_arg1.n11 - _arg2.n11);
this.n12 = (_arg1.n12 - _arg2.n12);
this.n13 = (_arg1.n13 - _arg2.n13);
this.n14 = (_arg1.n14 - _arg2.n14);
this.n21 = (_arg1.n21 - _arg2.n21);
this.n22 = (_arg1.n22 - _arg2.n22);
this.n23 = (_arg1.n23 - _arg2.n23);
this.n24 = (_arg1.n24 - _arg2.n24);
this.n31 = (_arg1.n31 - _arg2.n31);
this.n32 = (_arg1.n32 - _arg2.n32);
this.n33 = (_arg1.n33 - _arg2.n33);
this.n34 = (_arg1.n34 - _arg2.n34);
}
public static function sub(_arg1:JMatrix3D, _arg2:JMatrix3D):JMatrix3D{
var _local3:JMatrix3D;
_local3 = new (JMatrix3D);
_local3.calculateSub(_arg1, _arg2);
return (_local3);
}
public static function rotationMatrixWithReference(_arg1:JNumber3D, _arg2:Number, _arg3:JNumber3D):JMatrix3D{
var _local4:JMatrix3D;
_local4 = JMatrix3D.translationMatrix(_arg3.x, -(_arg3.y), _arg3.z);
JMatrix3D.translationMatrix(_arg3.x, -(_arg3.y), _arg3.z).calculateMultiply(_local4, JMatrix3D.rotationMatrix(_arg1.x, _arg1.y, _arg1.z, _arg2));
_local4.calculateMultiply(_local4, JMatrix3D.translationMatrix(-(_arg3.x), _arg3.y, -(_arg3.z)));
return (_local4);
}
public static function multiplyVector3x3(_arg1:JMatrix3D, _arg2:JNumber3D):void{
var _local3:Number;
var _local4:Number;
var _local5:Number;
_local3 = _arg2.x;
_local4 = _arg2.y;
_local5 = _arg2.z;
_arg2.x = (((_local3 * _arg1.n11) + (_local4 * _arg1.n12)) + (_local5 * _arg1.n13));
_arg2.y = (((_local3 * _arg1.n21) + (_local4 * _arg1.n22)) + (_local5 * _arg1.n23));
_arg2.z = (((_local3 * _arg1.n31) + (_local4 * _arg1.n32)) + (_local5 * _arg1.n33));
}
public static function multiply3x3(_arg1:JMatrix3D, _arg2:JMatrix3D):JMatrix3D{
var _local3:JMatrix3D;
_local3 = new (JMatrix3D);
_local3.calculateMultiply3x3(_arg1, _arg2);
return (_local3);
}
public static function normalizeQuaternion(_arg1:Object):Object{
var _local2:Number;
_local2 = magnitudeQuaternion(_arg1);
_arg1.x = (_arg1.x / _local2);
_arg1.y = (_arg1.y / _local2);
_arg1.z = (_arg1.z / _local2);
_arg1.w = (_arg1.w / _local2);
return (_arg1);
}
public static function multiplyVector(_arg1:JMatrix3D, _arg2:JNumber3D):void{
var _local3:Number;
var _local4:Number;
var _local5:Number;
_local3 = _arg2.x;
_local4 = _arg2.y;
_local5 = _arg2.z;
_arg2.x = ((((_local3 * _arg1.n11) + (_local4 * _arg1.n12)) + (_local5 * _arg1.n13)) + _arg1.n14);
_arg2.y = ((((_local3 * _arg1.n21) + (_local4 * _arg1.n22)) + (_local5 * _arg1.n23)) + _arg1.n24);
_arg2.z = ((((_local3 * _arg1.n31) + (_local4 * _arg1.n32)) + (_local5 * _arg1.n33)) + _arg1.n34);
}
public static function axis2quaternion(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Object{
var _local5:Number;
var _local6:Number;
var _local7:Object;
_local5 = Math.sin((_arg4 / 2));
_local6 = Math.cos((_arg4 / 2));
_local7 = new Object();
_local7.x = (_arg1 * _local5);
_local7.y = (_arg2 * _local5);
_local7.z = (_arg3 * _local5);
_local7.w = _local6;
return (normalizeQuaternion(_local7));
}
public static function translationMatrix(_arg1:Number, _arg2:Number, _arg3:Number):JMatrix3D{
var _local4:JMatrix3D;
_local4 = IDENTITY;
_local4.n14 = _arg1;
_local4.n24 = _arg2;
_local4.n34 = _arg3;
return (_local4);
}
public static function magnitudeQuaternion(_arg1:Object):Number{
return (Math.sqrt(((((_arg1.w * _arg1.w) + (_arg1.x * _arg1.x)) + (_arg1.y * _arg1.y)) + (_arg1.z * _arg1.z))));
}
public static function euler2quaternion(_arg1:Number, _arg2:Number, _arg3:Number):Object{
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Object;
_local4 = Math.sin((_arg1 * 0.5));
_local5 = Math.cos((_arg1 * 0.5));
_local6 = Math.sin((_arg2 * 0.5));
_local7 = Math.cos((_arg2 * 0.5));
_local8 = Math.sin((_arg3 * 0.5));
_local9 = Math.cos((_arg3 * 0.5));
_local10 = (_local5 * _local7);
_local11 = (_local4 * _local6);
_local12 = new Object();
_local12.x = ((_local8 * _local10) - (_local9 * _local11));
_local12.y = (((_local9 * _local4) * _local7) + ((_local8 * _local5) * _local6));
_local12.z = (((_local9 * _local5) * _local6) - ((_local8 * _local4) * _local7));
_local12.w = ((_local9 * _local10) + (_local8 * _local11));
return (_local12);
}
public static function rotationX(_arg1:Number):JMatrix3D{
var _local2:JMatrix3D;
var _local3:Number;
var _local4:Number;
_local2 = IDENTITY;
_local3 = Math.cos(_arg1);
_local4 = Math.sin(_arg1);
_local2.n22 = _local3;
_local2.n23 = -(_local4);
_local2.n32 = _local4;
_local2.n33 = _local3;
return (_local2);
}
public static function rotationY(_arg1:Number):JMatrix3D{
var _local2:JMatrix3D;
var _local3:Number;
var _local4:Number;
_local2 = IDENTITY;
_local3 = Math.cos(_arg1);
_local4 = Math.sin(_arg1);
_local2.n11 = _local3;
_local2.n13 = -(_local4);
_local2.n31 = _local4;
_local2.n33 = _local3;
return (_local2);
}
public static function rotationZ(_arg1:Number):JMatrix3D{
var _local2:JMatrix3D;
var _local3:Number;
var _local4:Number;
_local2 = IDENTITY;
_local3 = Math.cos(_arg1);
_local4 = Math.sin(_arg1);
_local2.n11 = _local3;
_local2.n12 = -(_local4);
_local2.n21 = _local4;
_local2.n22 = _local3;
return (_local2);
}
public static function clone(_arg1:JMatrix3D):JMatrix3D{
return (new JMatrix3D([_arg1.n11, _arg1.n12, _arg1.n13, _arg1.n14, _arg1.n21, _arg1.n22, _arg1.n23, _arg1.n24, _arg1.n31, _arg1.n32, _arg1.n33, _arg1.n34]));
}
public static function rotationMatrix(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):JMatrix3D{
var _local5:JMatrix3D;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
_local5 = IDENTITY;
_local6 = Math.cos(_arg4);
_local7 = Math.sin(_arg4);
_local8 = (1 - _local6);
_local9 = ((_arg1 * _arg2) * _local8);
_local10 = ((_arg2 * _arg3) * _local8);
_local11 = ((_arg1 * _arg3) * _local8);
_local12 = (_local7 * _arg3);
_local13 = (_local7 * _arg2);
_local14 = (_local7 * _arg1);
_local5.n11 = (_local6 + ((_arg1 * _arg1) * _local8));
_local5.n12 = (-(_local12) + _local9);
_local5.n13 = (_local13 + _local11);
_local5.n21 = (_local12 + _local9);
_local5.n22 = (_local6 + ((_arg2 * _arg2) * _local8));
_local5.n23 = (-(_local14) + _local10);
_local5.n31 = (-(_local13) + _local11);
_local5.n32 = (_local14 + _local10);
_local5.n33 = (_local6 + ((_arg3 * _arg3) * _local8));
return (_local5);
}
public static function add(_arg1:JMatrix3D, _arg2:JMatrix3D):JMatrix3D{
var _local3:JMatrix3D;
_local3 = new (JMatrix3D);
_local3.calculateAdd(_arg1, _arg2);
return (_local3);
}
public static function rotateAxis(_arg1:JMatrix3D, _arg2:JNumber3D):void{
var _local3:Number;
var _local4:Number;
var _local5:Number;
_local3 = _arg2.x;
_local4 = _arg2.y;
_local5 = _arg2.z;
_arg2.x = (((_local3 * _arg1.n11) + (_local4 * _arg1.n12)) + (_local5 * _arg1.n13));
_arg2.y = (((_local3 * _arg1.n21) + (_local4 * _arg1.n22)) + (_local5 * _arg1.n23));
_arg2.z = (((_local3 * _arg1.n31) + (_local4 * _arg1.n32)) + (_local5 * _arg1.n33));
_arg2.normalize();
}
public static function multiply(_arg1:JMatrix3D, _arg2:JMatrix3D):JMatrix3D{
var _local3:JMatrix3D;
_local3 = new (JMatrix3D);
_local3.calculateMultiply(_arg1, _arg2);
return (_local3);
}
public static function multiplyQuaternion(_arg1:Object, _arg2:Object):Object{
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Object;
_local3 = _arg1.x;
_local4 = _arg1.y;
_local5 = _arg1.z;
_local6 = _arg1.w;
_local7 = _arg2.x;
_local8 = _arg2.y;
_local9 = _arg2.z;
_local10 = _arg2.w;
_local11 = new Object();
_local11.x = ((((_local6 * _local7) + (_local3 * _local10)) + (_local4 * _local9)) - (_local5 * _local8));
_local11.y = ((((_local6 * _local8) + (_local4 * _local10)) + (_local5 * _local7)) - (_local3 * _local9));
_local11.z = ((((_local6 * _local9) + (_local5 * _local10)) + (_local3 * _local8)) - (_local4 * _local7));
_local11.w = ((((_local6 * _local10) - (_local3 * _local7)) - (_local4 * _local8)) - (_local5 * _local9));
return (_local11);
}
public static function euler2matrix(_arg1:JNumber3D):JMatrix3D{
var _local2:JMatrix3D;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
_local2 = IDENTITY;
_local3 = (_arg1.x * toRADIANS);
_local4 = (_arg1.y * toRADIANS);
_local5 = (_arg1.z * toRADIANS);
_local6 = Math.cos(_local3);
_local7 = Math.sin(_local3);
_local8 = Math.cos(_local4);
_local9 = Math.sin(_local4);
_local10 = Math.cos(_local5);
_local11 = Math.sin(_local5);
_local12 = (_local6 * _local9);
_local13 = (_local7 * _local9);
_local2.n11 = (_local8 * _local10);
_local2.n12 = (-(_local8) * _local11);
_local2.n13 = _local9;
_local2.n21 = ((_local13 * _local10) + (_local6 * _local11));
_local2.n22 = ((-(_local13) * _local11) + (_local6 * _local10));
_local2.n23 = (-(_local7) * _local8);
_local2.n31 = ((-(_local12) * _local10) + (_local7 * _local11));
_local2.n32 = ((_local12 * _local11) + (_local7 * _local10));
_local2.n33 = (_local6 * _local8);
return (_local2);
}
public static function scaleMatrix(_arg1:Number, _arg2:Number, _arg3:Number):JMatrix3D{
var _local4:JMatrix3D;
_local4 = IDENTITY;
_local4.n11 = _arg1;
_local4.n22 = _arg2;
_local4.n33 = _arg3;
return (_local4);
}
public static function quaternion2matrix(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):JMatrix3D{
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:JMatrix3D;
_local5 = (_arg1 * _arg1);
_local6 = (_arg1 * _arg2);
_local7 = (_arg1 * _arg3);
_local8 = (_arg1 * _arg4);
_local9 = (_arg2 * _arg2);
_local10 = (_arg2 * _arg3);
_local11 = (_arg2 * _arg4);
_local12 = (_arg3 * _arg3);
_local13 = (_arg3 * _arg4);
_local14 = IDENTITY;
_local14.n11 = (1 - (2 * (_local9 + _local12)));
_local14.n12 = (2 * (_local6 - _local13));
_local14.n13 = (2 * (_local7 + _local11));
_local14.n21 = (2 * (_local6 + _local13));
_local14.n22 = (1 - (2 * (_local5 + _local12)));
_local14.n23 = (2 * (_local10 - _local8));
_local14.n31 = (2 * (_local7 - _local11));
_local14.n32 = (2 * (_local10 + _local8));
_local14.n33 = (1 - (2 * (_local5 + _local9)));
return (_local14);
}
public static function inverse(_arg1:JMatrix3D):JMatrix3D{
var _local2:JMatrix3D;
_local2 = new (JMatrix3D);
_local2.calculateInverse(_arg1);
return (_local2);
}
public static function matrix2euler(_arg1:JMatrix3D, _arg2:JNumber3D=null, _arg3:JNumber3D=null):JNumber3D{
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
_arg2 = ((_arg2) || (new JNumber3D()));
_local4 = (((_arg3) && ((_arg3.x == 1)))) ? 1 : Math.sqrt((((_arg1.n11 * _arg1.n11) + (_arg1.n21 * _arg1.n21)) + (_arg1.n31 * _arg1.n31)));
_local5 = (((_arg3) && ((_arg3.y == 1)))) ? 1 : Math.sqrt((((_arg1.n12 * _arg1.n12) + (_arg1.n22 * _arg1.n22)) + (_arg1.n32 * _arg1.n32)));
_local6 = (((_arg3) && ((_arg3.z == 1)))) ? 1 : Math.sqrt((((_arg1.n13 * _arg1.n13) + (_arg1.n23 * _arg1.n23)) + (_arg1.n33 * _arg1.n33)));
_local7 = (_arg1.n11 / _local4);
_local8 = (_arg1.n21 / _local5);
_local9 = (_arg1.n31 / _local6);
_local10 = (_arg1.n32 / _local6);
_local11 = (_arg1.n33 / _local6);
_local9 = ((_local9 > 1)) ? 1 : _local9;
_local9 = ((_local9 < -1)) ? -1 : _local9;
_arg2.y = Math.asin(-(_local9));
_arg2.z = Math.atan2(_local8, _local7);
_arg2.x = Math.atan2(_local10, _local11);
_arg2.x = (_arg2.x * toDEGREES);
_arg2.y = (_arg2.y * toDEGREES);
_arg2.z = (_arg2.z * toDEGREES);
return (_arg2);
}
public static function transpose(_arg1:JMatrix3D):JMatrix3D{
var _local2:JMatrix3D;
_local2 = new (JMatrix3D);
_local2.n11 = _arg1.n11;
_local2.n12 = _arg1.n21;
_local2.n13 = _arg1.n31;
_local2.n14 = _arg1.n41;
_local2.n21 = _arg1.n12;
_local2.n22 = _arg1.n22;
_local2.n23 = _arg1.n32;
_local2.n24 = _arg1.n42;
_local2.n31 = _arg1.n13;
_local2.n32 = _arg1.n23;
_local2.n33 = _arg1.n33;
_local2.n34 = _arg1.n43;
_local2.n41 = _arg1.n14;
_local2.n42 = _arg1.n24;
_local2.n43 = _arg1.n34;
_local2.n44 = _arg1.n44;
return (_local2);
}
public static function get IDENTITY():JMatrix3D{
return (new JMatrix3D([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]));
}
}
}//package jiglib.math
Section 32
//JNumber3D (jiglib.math.JNumber3D)
package jiglib.math {
public class JNumber3D {
public var x:Number;
public var y:Number;
public var z:Number;
public function JNumber3D(_arg1:Number=0, _arg2:Number=0, _arg3:Number=0){
this.x = _arg1;
this.y = _arg2;
this.z = _arg3;
}
public function isFinite():Boolean{
if ((((this.x > 1000000)) || ((this.x < -1000000)))){
return (true);
};
if ((((this.y > 1000000)) || ((this.y < -1000000)))){
return (true);
};
if ((((this.z > 1000000)) || ((this.z < -1000000)))){
return (true);
};
return (false);
}
public function setTo(_arg1:Number=0, _arg2:Number=0, _arg3:Number=0):void{
this.x = _arg1;
this.y = _arg2;
this.z = _arg3;
}
public function copyFromArray(_arg1:Array):void{
if (_arg1.length >= 3){
this.x = _arg1[0];
this.y = _arg1[1];
this.z = _arg1[2];
};
}
public function toString():String{
return (((((("x:" + x) + " y:") + y) + " z:") + z));
}
public function normalize():void{
var _local1:Number;
_local1 = this.modulo;
if (((!((_local1 == 0))) && (!((_local1 == 1))))){
this.x = (this.x / _local1);
this.y = (this.y / _local1);
this.z = (this.z / _local1);
};
}
public function get modulo():Number{
return (Math.sqrt((((this.x * this.x) + (this.y * this.y)) + (this.z * this.z))));
}
public function copyTo(_arg1:JNumber3D):void{
_arg1.x = x;
_arg1.y = y;
_arg1.z = z;
}
public function get modulo2():Number{
return ((((this.x * this.x) + (this.y * this.y)) + (this.z * this.z)));
}
public function clone():JNumber3D{
return (new JNumber3D(this.x, this.y, this.z));
}
public function toArray():Array{
return (new Array(this.x, this.y, this.z));
}
public static function sub(_arg1:JNumber3D, _arg2:JNumber3D):JNumber3D{
return (new JNumber3D((_arg1.x - _arg2.x), (_arg1.y - _arg2.y), (_arg1.z - _arg2.z)));
}
public static function add(_arg1:JNumber3D, _arg2:JNumber3D):JNumber3D{
return (new JNumber3D((_arg1.x + _arg2.x), (_arg1.y + _arg2.y), (_arg1.z + _arg2.z)));
}
public static function multiply(_arg1:JNumber3D, _arg2:Number):JNumber3D{
return (new JNumber3D((_arg1.x * _arg2), (_arg1.y * _arg2), (_arg1.z * _arg2)));
}
public static function cross(_arg1:JNumber3D, _arg2:JNumber3D):JNumber3D{
return (new JNumber3D(((_arg2.y * _arg1.z) - (_arg2.z * _arg1.y)), ((_arg2.z * _arg1.x) - (_arg2.x * _arg1.z)), ((_arg2.x * _arg1.y) - (_arg2.y * _arg1.x))));
}
public static function get ZERO():JNumber3D{
return (new JNumber3D(0, 0, 0));
}
public static function dot(_arg1:JNumber3D, _arg2:JNumber3D):Number{
return ((((_arg1.x * _arg2.x) + (_arg1.y * _arg2.y)) + (_arg2.z * _arg1.z)));
}
public static function get NUM_HUGE():Number{
return (100000);
}
public static function get FRONT():JNumber3D{
return (new JNumber3D(0, 0, 1));
}
public static function get NUM_TINY():Number{
return (1E-5);
}
public static function limiteNumber(_arg1:Number, _arg2:Number, _arg3:Number):Number{
var _local4:Number;
_local4 = _arg1;
if (_local4 < _arg2){
_local4 = _arg2;
} else {
if (_local4 > _arg3){
_local4 = _arg3;
};
};
return (_local4);
}
public static function divide(_arg1:JNumber3D, _arg2:Number):JNumber3D{
if (_arg2 != 0){
return (new JNumber3D((_arg1.x / _arg2), (_arg1.y / _arg2), (_arg1.z / _arg2)));
};
return (new (JNumber3D));
}
public static function get UP():JNumber3D{
return (new JNumber3D(0, 1, 0));
}
public static function get RIGHT():JNumber3D{
return (new JNumber3D(1, 0, 0));
}
public static function getNormal(_arg1:JNumber3D, _arg2:JNumber3D, _arg3:JNumber3D):JNumber3D{
var _local4:JNumber3D;
var _local5:JNumber3D;
var _local6:JNumber3D;
_local4 = _arg2.clone();
_local4 = JNumber3D.sub(_local4, _arg1);
_local5 = _arg3.clone();
_local5 = JNumber3D.sub(_local5, _arg2);
_local6 = JNumber3D.cross(_local5, _local4);
_local6.normalize();
return (_local6);
}
}
}//package jiglib.math
Section 33
//JConstraint (jiglib.physics.constraint.JConstraint)
package jiglib.physics.constraint {
import jiglib.physics.*;
public class JConstraint {
private var _constraintEnabled:Boolean;
private var _satisfied:Boolean;
public function JConstraint(){
_constraintEnabled = false;
enableConstraint();
}
public function enableConstraint():void{
if (_constraintEnabled){
return;
};
_constraintEnabled = true;
PhysicsSystem.getInstance().addConstraint(this);
}
public function set satisfied(_arg1:Boolean):void{
_satisfied = _arg1;
}
public function preApply(_arg1:Number):void{
_satisfied = false;
}
public function disableConstraint():void{
if (!_constraintEnabled){
return;
};
_constraintEnabled = false;
PhysicsSystem.getInstance().removeConstraint(this);
}
public function apply(_arg1:Number):Boolean{
return (false);
}
public function get satisfied():Boolean{
return (_satisfied);
}
public function get constraintEnabled():Boolean{
return (_constraintEnabled);
}
}
}//package jiglib.physics.constraint
Section 34
//BodyPair (jiglib.physics.BodyPair)
package jiglib.physics {
import jiglib.math.*;
public class BodyPair {
public var r:JNumber3D;
public var body0:RigidBody;
public var body1:RigidBody;
public function BodyPair(_arg1:RigidBody, _arg2:RigidBody, _arg3:JNumber3D, _arg4:JNumber3D){
if (_arg1.id > _arg2.id){
this.body0 = _arg1;
this.body1 = _arg2;
this.r = _arg3;
} else {
this.body0 = _arg2;
this.body1 = _arg1;
this.r = _arg4;
};
}
}
}//package jiglib.physics
Section 35
//CachedImpulse (jiglib.physics.CachedImpulse)
package jiglib.physics {
import jiglib.math.*;
public class CachedImpulse {
public var normalImpulseAux:Number;
public var frictionImpulse:JNumber3D;
public var normalImpulse:Number;
public function CachedImpulse(_arg1:Number, _arg2:Number, _arg3:JNumber3D){
this.normalImpulse = _arg1;
this.normalImpulseAux = _arg2;
this.frictionImpulse = _arg3;
}
}
}//package jiglib.physics
Section 36
//MaterialProperties (jiglib.physics.MaterialProperties)
package jiglib.physics {
public class MaterialProperties {
private var _restitution:Number;
private var _friction:Number;
public function MaterialProperties(_arg1:Number=0.2, _arg2:Number=0.5){
this._restitution = _arg1;
this._friction = _arg2;
}
public function get restitution():Number{
return (_restitution);
}
public function set restitution(_arg1:Number):void{
_restitution = _arg1;
}
public function get friction():Number{
return (_friction);
}
public function set friction(_arg1:Number):void{
_friction = _arg1;
}
}
}//package jiglib.physics
Section 37
//PhysicsController (jiglib.physics.PhysicsController)
package jiglib.physics {
public class PhysicsController {
private var _controllerEnabled:Boolean;
public function PhysicsController(){
_controllerEnabled = false;
}
public function disableController():void{
if (!_controllerEnabled){
return;
};
_controllerEnabled = false;
PhysicsSystem.getInstance().removeController(this);
}
public function updateController(_arg1:Number):void{
}
public function get controllerEnabled():Boolean{
return (_controllerEnabled);
}
public function enableController():void{
if (_controllerEnabled){
return;
};
_controllerEnabled = true;
PhysicsSystem.getInstance().addController(this);
}
}
}//package jiglib.physics
Section 38
//PhysicsState (jiglib.physics.PhysicsState)
package jiglib.physics {
import jiglib.math.*;
public class PhysicsState {
public var position:JNumber3D;
public var linVelocity:JNumber3D;
public var orientation:JMatrix3D;
public var rotVelocity:JNumber3D;
public function PhysicsState(){
position = new JNumber3D();
orientation = new JMatrix3D();
linVelocity = new JNumber3D();
rotVelocity = new JNumber3D();
super();
}
}
}//package jiglib.physics
Section 39
//PhysicsSystem (jiglib.physics.PhysicsSystem)
package jiglib.physics {
import jiglib.math.*;
import jiglib.collision.*;
import jiglib.physics.constraint.*;
import jiglib.cof.*;
public class PhysicsSystem {
private const _minVelForProcessing:Number = 0.001;
private const _maxVelMag:Number = 0.5;
private var _gravity:JNumber3D;
private var _controllers:Array;
private var preProcessContactFn:Function;
private var _collisions:Array;
private var processCollisionFn:Function;
private var preProcessCollisionFn:Function;
private var _cachedContacts:Array;
private var _doingIntegration:Boolean;
private var _collisionSystem:CollisionSystem;
private var _activeBodies:Array;
private var _gravityAxis:int;
private var processContactFn:Function;
private var _bodies:Array;
private var _constraints:Array;
private static var _currentPhysicsSystem:PhysicsSystem;
public function PhysicsSystem(){
setSolverType(JConfig.solverType);
_doingIntegration = false;
_bodies = new Array();
_collisions = new Array();
_activeBodies = new Array();
_constraints = new Array();
_controllers = new Array();
_cachedContacts = new Array();
_collisionSystem = new CollisionSystem();
setGravity(JNumber3D.multiply(JNumber3D.UP, -2));
}
private function findBody(_arg1:RigidBody):Boolean{
var _local2:String;
for (_local2 in _bodies) {
if (_arg1 == _bodies[_local2]){
return (true);
};
};
return (false);
}
private function processCollision(_arg1:CollisionInfo, _arg2:Number):Boolean{
var _local3:RigidBody;
var _local4:RigidBody;
var _local5:Boolean;
var _local6:JNumber3D;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:JNumber3D;
var _local12:JNumber3D;
var _local13:JNumber3D;
var _local14:CollPointInfo;
var _local15:int;
var _local16:int;
var _local17:JNumber3D;
var _local18:JNumber3D;
var _local19:JNumber3D;
var _local20:Number;
var _local21:JNumber3D;
var _local22:Number;
var _local23:Number;
_arg1.satisfied = true;
_local3 = _arg1.objInfo.body0;
_local4 = _arg1.objInfo.body1;
_local5 = false;
_local6 = _arg1.dirToBody;
_local7 = 0;
_local8 = 0;
_local9 = 0;
_local10 = 0;
_local15 = _arg1.pointInfo.length;
_local16 = 0;
while (_local16 < _local15) {
_local14 = _arg1.pointInfo[_local16];
_local12 = _local3.getVelocity(_local14.r0);
_local13 = _local4.getVelocity(_local14.r1);
_local8 = JNumber3D.dot(JNumber3D.sub(_local12, _local13), _local6);
if (_local8 > _local14.minSeparationVel){
} else {
_local9 = ((-1 * _arg1.mat.restitution) * _local8);
if (_local9 < _minVelForProcessing){
_local9 = _local14.minSeparationVel;
};
_local7 = (_local9 - _local8);
if (_local7 <= _minVelForProcessing){
} else {
_local10 = (_local7 / _local14.denominator);
_local5 = true;
_local11 = JNumber3D.multiply(_local6, _local10);
_local3.applyBodyWorldImpulse(_local11, _local14.r0);
_local4.applyBodyWorldImpulse(JNumber3D.multiply(_local11, -1), _local14.r1);
_local18 = JNumber3D.sub(_local12, _local13);
_local19 = JNumber3D.sub(_local18, JNumber3D.multiply(_local6, JNumber3D.dot(_local18, _local6)));
_local20 = _local19.modulo;
if (_local20 > _minVelForProcessing){
_local21 = JNumber3D.multiply(JNumber3D.divide(_local19, _local20), -1);
_local22 = 0;
if (_local3.movable){
_local17 = JNumber3D.cross(_local21, _local14.r0);
JMatrix3D.multiplyVector(_local3.worldInvInertia, _local17);
_local22 = (_local3.invMass + JNumber3D.dot(_local21, JNumber3D.cross(_local14.r0, _local17)));
};
if (_local4.movable){
_local17 = JNumber3D.cross(_local21, _local14.r1);
JMatrix3D.multiplyVector(_local4.worldInvInertia, _local17);
_local22 = (_local22 + (_local4.invMass + JNumber3D.dot(_local21, JNumber3D.cross(_local14.r1, _local17))));
};
if (_local22 > JNumber3D.NUM_TINY){
_local23 = ((Math.pow(_arg1.mat.friction, 3) * _local20) / _local22);
_local21 = JNumber3D.multiply(_local21, _local23);
_local3.applyBodyWorldImpulse(_local21, _local14.r0);
_local4.applyBodyWorldImpulse(JNumber3D.multiply(_local21, -1), _local14.r1);
};
};
};
};
_local16++;
};
if (_local5){
_local3.setConstraintsAndCollisionsUnsatisfied();
_local4.setConstraintsAndCollisionsUnsatisfied();
};
return (_local5);
}
public function removeConstraint(_arg1:JConstraint):void{
if (findConstraint(_arg1)){
_constraints.splice(_constraints.indexOf(_arg1), 1);
};
}
public function setGravity(_arg1:JNumber3D):void{
_gravity = _arg1;
if ((((_gravity.x == _gravity.y)) && ((_gravity.y == _gravity.z)))){
_gravityAxis = -1;
};
_gravityAxis = 0;
if (Math.abs(_gravity.y) > Math.abs(_gravity.z)){
_gravityAxis = 1;
};
if (Math.abs(_gravity.z) > Math.abs(_gravity.toArray()[_gravityAxis])){
_gravityAxis = 2;
};
}
public function get bodys():Array{
return (_bodies);
}
public function activateObject(_arg1:RigidBody):void{
var _local2:int;
var _local3:RigidBody;
var _local4:JNumber3D;
var _local5:int;
var _local6:int;
if (((!(_arg1.movable)) || (_arg1.isActive()))){
return;
};
_arg1.setActive();
_activeBodies.push(_arg1);
_local2 = _collisions.length;
_collisionSystem.detectCollisions(_arg1, _collisions);
_local5 = _collisions.length;
_local6 = _local2;
while (_local6 < _local5) {
_local3 = _collisions[_local6].objInfo.body0;
_local4 = _collisions[_local6].dirToBody;
if (_local3 == _arg1){
_local3 = _collisions[_local6].objInfo.body1;
_local4 = JNumber3D.multiply(_collisions[_local6].dirToBody, -1);
};
if (((!(_local3.isActive())) && ((JNumber3D.dot(_local3.force, _local4) < -(JNumber3D.NUM_TINY))))){
activateObject(_local3);
};
_local6++;
};
}
public function removeAllBodys():void{
_bodies = [];
_collisionSystem.removeAllCollisionBodys();
}
public function removeAllControllers():void{
_controllers = [];
}
private function activateAllFrozenObjectsLeftHanging():void{
var _local1:RigidBody;
var _local2:String;
var _local3:String;
for (_local2 in _bodies) {
if (_bodies[_local2].isActive()){
_bodies[_local2].doMovementActivations();
if (_bodies[_local2].collisions.length > 0){
for (_local3 in _bodies[_local2].collisions) {
_local1 = _bodies[_local2].collisions[_local3].objInfo.body0;
if (_local1 == _bodies[_local2]){
_local1 = _bodies[_local2].collisions[_local3].objInfo.body1;
};
if (!_local1.isActive()){
_bodies[_local2].addMovementActivation(_bodies[_local2].currentState.position, _local1);
};
};
};
};
};
}
public function addController(_arg1:PhysicsController):void{
if (!findController(_arg1)){
_controllers.push(_arg1);
};
}
private function detectAllCollisions(_arg1:Number):void{
var _local2:String;
for (_local2 in _activeBodies) {
_activeBodies[_local2].storeState();
};
updateAllVelocities(_arg1);
updateAllPositions(_arg1);
for (_local2 in _bodies) {
_bodies[_local2].collisions = [];
};
_collisions = [];
_collisionSystem.detectAllCollisions(_activeBodies, _collisions);
for (_local2 in _activeBodies) {
_activeBodies[_local2].restoreState();
};
}
private function preProcessCollisionAccumulated(_arg1:CollisionInfo, _arg2:Number):void{
var _local3:RigidBody;
var _local4:RigidBody;
var _local5:JNumber3D;
var _local6:Number;
var _local7:JNumber3D;
var _local8:CollPointInfo;
var _local9:Number;
var _local10:int;
var _local11:int;
var _local12:Number;
var _local13:BodyPair;
var _local14:String;
var _local15:Number;
var _local16:JNumber3D;
_arg1.satisfied = false;
_local3 = _arg1.objInfo.body0;
_local4 = _arg1.objInfo.body1;
_local5 = _arg1.dirToBody;
_local6 = (JConfig.numPenetrationRelaxationTimesteps * _arg2);
_local9 = 0;
_local10 = _arg1.pointInfo.length;
_local11 = 0;
while (_local11 < _local10) {
_local8 = _arg1.pointInfo[_local11];
if (!_local3.movable){
_local8.denominator = 0;
} else {
_local7 = JNumber3D.cross(_local5, _local8.r0);
JMatrix3D.multiplyVector(_local3.worldInvInertia, _local7);
_local8.denominator = (_local3.invMass + JNumber3D.dot(_local5, JNumber3D.cross(_local8.r0, _local7)));
};
if (_local4.movable){
_local7 = JNumber3D.cross(_local5, _local8.r1);
JMatrix3D.multiplyVector(_local4.worldInvInertia, _local7);
_local8.denominator = (_local8.denominator + (_local4.invMass + JNumber3D.dot(_local5, JNumber3D.cross(_local8.r1, _local7))));
};
if (_local8.denominator < JNumber3D.NUM_TINY){
_local8.denominator = JNumber3D.NUM_TINY;
};
if (_local8.initialPenetration > JConfig.allowedPenetration){
_local8.minSeparationVel = ((_local8.initialPenetration - JConfig.allowedPenetration) / _local6);
} else {
_local9 = ((-0.1 * (_local8.initialPenetration - JConfig.allowedPenetration)) / JConfig.allowedPenetration);
if (_local9 < JNumber3D.NUM_TINY){
_local9 = JNumber3D.NUM_TINY;
} else {
if (_local9 > 1){
_local9 = 1;
};
};
_local8.minSeparationVel = ((_local9 * (_local8.initialPenetration - JConfig.allowedPenetration)) / Math.max(_arg2, JNumber3D.NUM_TINY));
};
_local8.accumulatedNormalImpulse = 0;
_local8.accumulatedNormalImpulseAux = 0;
_local8.accumulatedFrictionImpulse = new JNumber3D();
_local12 = 0.04;
_local13 = new BodyPair(_local3, _local4, JNumber3D.ZERO, JNumber3D.ZERO);
for (_local14 in _cachedContacts) {
if (!(((_local13.body0 == _cachedContacts[_local14].Pair.body0)) && ((_local13.body1 == _cachedContacts[_local14].Pair.body1)))){
} else {
_local15 = ((_cachedContacts[_local14].Pair.body0)==_local3) ? JNumber3D.sub(_cachedContacts[_local14].Pair.r, _local8.r0).modulo2 : JNumber3D.sub(_cachedContacts[_local14].Pair.r, _local8.r1).modulo2;
if (_local15 < _local12){
_local12 = _local15;
_local8.accumulatedNormalImpulse = _cachedContacts[_local14].Impulse.normalImpulse;
_local8.accumulatedNormalImpulseAux = _cachedContacts[_local14].Impulse.normalImpulseAux;
_local8.accumulatedFrictionImpulse = _cachedContacts[_local14].Impulse.frictionImpulse;
if (_cachedContacts[_local14].Pair.body0 != _local3){
_local8.accumulatedFrictionImpulse = JNumber3D.multiply(_local8.accumulatedFrictionImpulse, -1);
};
};
};
};
if (_local8.accumulatedNormalImpulse != 0){
_local16 = JNumber3D.multiply(_local5, _local8.accumulatedNormalImpulse);
_local16 = JNumber3D.add(_local16, _local8.accumulatedFrictionImpulse);
_local3.applyBodyWorldImpulse(_local16, _local8.r0);
_local4.applyBodyWorldImpulse(JNumber3D.multiply(_local16, -1), _local8.r1);
};
if (_local8.accumulatedNormalImpulseAux != 0){
_local16 = JNumber3D.multiply(_local5, _local8.accumulatedNormalImpulseAux);
_local3.applyBodyWorldImpulseAux(_local16, _local8.r0);
_local4.applyBodyWorldImpulseAux(JNumber3D.multiply(_local16, -1), _local8.r1);
};
_local11++;
};
}
private function updateAllObject3D():void{
var _local1:String;
for (_local1 in _bodies) {
_bodies[_local1].updateObject3D();
};
}
private function handleAllConstraints(_arg1:Number, _arg2:int, _arg3:Boolean):void{
var _local4:int;
var _local5:String;
var _local6:Boolean;
var _local7:Boolean;
var _local8:int;
var _local9:uint;
var _local10:String;
var _local11:int;
_local4 = _collisions.length;
for (_local5 in _constraints) {
_constraints[_local5].preApply(_arg1);
};
if (_arg3){
for (_local10 in _collisions) {
_collisions[_local10].mat.restitution = 0;
_collisions[_local10].satisfied = false;
preProcessContactFn(_collisions[_local10], _arg1);
};
} else {
for (_local10 in _collisions) {
preProcessCollisionFn(_collisions[_local10], _arg1);
};
};
_local9 = 0;
while (_local9 < _arg2) {
_local7 = false;
for (_local10 in _collisions) {
if (!_collisions[_local10].satisfied){
if (_arg3){
_local6 = processContactFn(_collisions[_local10], _arg1);
_local7 = ((_local7) || (_local6));
} else {
_local6 = processCollisionFn(_collisions[_local10], _arg1);
_local7 = ((_local7) || (_local6));
};
};
};
for (_local5 in _constraints) {
if (!_constraints[_local5].satisfied){
_local6 = _constraints[_local5].apply(_arg1);
_local7 = ((_local7) || (_local6));
};
};
tryToActivateAllFrozenObjects();
if (_arg3){
_local8 = _collisions.length;
_local11 = _local4;
while (_local11 < _local8) {
_collisions[_local11].mat.restitution = 0;
_collisions[_local11].satisfied = false;
preProcessContactFn(_collisions[_local11], _arg1);
_local11++;
};
} else {
_local8 = _collisions.length;
_local11 = _local4;
while (_local11 < _local8) {
preProcessCollisionFn(_collisions[_local11], _arg1);
_local11++;
};
};
_local4 = _collisions.length;
if (!_local7){
break;
};
_local9++;
};
}
public function get gravityAxis():int{
return (_gravityAxis);
}
private function findController(_arg1:PhysicsController):Boolean{
var _local2:String;
for (_local2 in _controllers) {
if (_arg1 == _controllers[_local2]){
return (true);
};
};
return (false);
}
private function dampAllActiveBodies():void{
var _local1:String;
for (_local1 in _activeBodies) {
_activeBodies[_local1].dampForDeactivation();
};
}
private function updateAllPositions(_arg1:Number):void{
var _local2:String;
for (_local2 in _activeBodies) {
_activeBodies[_local2].updatePositionWithAux(_arg1);
};
}
private function updateContactCache():void{
var _local1:CollisionInfo;
var _local2:CollPointInfo;
var _local3:JNumber3D;
var _local4:Object;
var _local5:String;
var _local6:String;
_cachedContacts = [];
for (_local5 in _collisions) {
_local1 = _collisions[_local5];
for (_local6 in _local1.pointInfo) {
_local2 = _local1.pointInfo[_local6];
_local3 = ((_local1.objInfo.body0.id)>_local1.objInfo.body1.id) ? _local2.accumulatedFrictionImpulse : JNumber3D.multiply(_local2.accumulatedFrictionImpulse, -1);
_local4 = new Object();
_local4.Pair = new BodyPair(_local1.objInfo.body0, _local1.objInfo.body1, _local2.r0, _local2.r1);
_local4.Impulse = new CachedImpulse(_local2.accumulatedNormalImpulse, _local2.accumulatedNormalImpulseAux, _local2.accumulatedFrictionImpulse);
_cachedContacts.push(_local4);
};
};
}
private function findAllActiveBodies():void{
var _local1:String;
_activeBodies = [];
for (_local1 in _bodies) {
if (_bodies[_local1].isActive()){
_activeBodies.push(_bodies[_local1]);
};
};
}
private function processCollisionAccumulated(_arg1:CollisionInfo, _arg2:Number):Boolean{
var _local3:Boolean;
var _local4:JNumber3D;
var _local5:RigidBody;
var _local6:RigidBody;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:JNumber3D;
var _local11:JNumber3D;
var _local12:JNumber3D;
var _local13:CollPointInfo;
var _local14:int;
var _local15:int;
var _local16:Number;
var _local17:Number;
var _local18:JNumber3D;
var _local19:JNumber3D;
var _local20:JNumber3D;
var _local21:Number;
var _local22:JNumber3D;
var _local23:Number;
var _local24:Number;
var _local25:JNumber3D;
var _local26:JNumber3D;
var _local27:Number;
var _local28:Number;
var _local29:JNumber3D;
_arg1.satisfied = true;
_local3 = false;
_local4 = _arg1.dirToBody;
_local5 = _arg1.objInfo.body0;
_local6 = _arg1.objInfo.body1;
_local7 = 0;
_local8 = 0;
_local9 = 0;
_local14 = _arg1.pointInfo.length;
_local15 = 0;
while (_local15 < _local14) {
_local13 = _arg1.pointInfo[_local15];
_local11 = _local5.getVelocity(_local13.r0);
_local12 = _local6.getVelocity(_local13.r1);
_local8 = JNumber3D.dot(JNumber3D.sub(_local11, _local12), _local4);
_local7 = -(_local8);
if (_local13.minSeparationVel < 0){
_local7 = (_local7 + _local13.minSeparationVel);
};
if (Math.abs(_local7) > _minVelForProcessing){
_local9 = (_local7 / _local13.denominator);
_local16 = _local13.accumulatedNormalImpulse;
_local13.accumulatedNormalImpulse = Math.max((_local13.accumulatedNormalImpulse + _local9), 0);
_local17 = (_local13.accumulatedNormalImpulse - _local16);
_local10 = JNumber3D.multiply(_local4, _local17);
_local5.applyBodyWorldImpulse(_local10, _local13.r0);
_local6.applyBodyWorldImpulse(JNumber3D.multiply(_local10, -1), _local13.r1);
_local3 = true;
};
_local11 = _local5.getVelocityAux(_local13.r0);
_local12 = _local6.getVelocityAux(_local13.r1);
_local8 = JNumber3D.dot(JNumber3D.sub(_local11, _local12), _local4);
_local7 = -(_local8);
if (_local13.minSeparationVel > 0){
_local7 = (_local7 + _local13.minSeparationVel);
};
if (Math.abs(_local7) > _minVelForProcessing){
_local9 = (_local7 / _local13.denominator);
_local16 = _local13.accumulatedNormalImpulseAux;
_local13.accumulatedNormalImpulseAux = Math.max((_local13.accumulatedNormalImpulseAux + _local9), 0);
_local17 = (_local13.accumulatedNormalImpulseAux - _local16);
_local10 = JNumber3D.multiply(_local4, _local17);
_local5.applyBodyWorldImpulseAux(_local10, _local13.r0);
_local6.applyBodyWorldImpulseAux(JNumber3D.multiply(_local10, -1), _local13.r1);
_local3 = true;
};
if (_local13.accumulatedNormalImpulse > 0){
_local11 = _local5.getVelocity(_local13.r0);
_local12 = _local6.getVelocity(_local13.r1);
_local19 = JNumber3D.sub(_local11, _local12);
_local20 = JNumber3D.sub(_local19, JNumber3D.multiply(_local4, JNumber3D.dot(_local19, _local4)));
_local21 = _local20.modulo;
if (_local21 > _minVelForProcessing){
_local22 = JNumber3D.multiply(JNumber3D.divide(_local20, _local21), -1);
_local23 = 0;
if (_local5.movable){
_local18 = JNumber3D.cross(_local22, _local13.r0);
JMatrix3D.multiplyVector(_local5.worldInvInertia, _local18);
_local23 = (_local5.invMass + JNumber3D.dot(_local22, JNumber3D.cross(_local13.r0, _local18)));
};
if (_local6.movable){
_local18 = JNumber3D.cross(_local22, _local13.r1);
JMatrix3D.multiplyVector(_local6.worldInvInertia, _local18);
_local23 = (_local23 + (_local6.invMass + JNumber3D.dot(_local22, JNumber3D.cross(_local13.r1, _local18))));
};
if (_local23 > JNumber3D.NUM_TINY){
_local24 = (_local21 / _local23);
_local25 = JNumber3D.multiply(_local22, _local24);
_local26 = _local13.accumulatedFrictionImpulse.clone();
_local13.accumulatedFrictionImpulse = JNumber3D.add(_local13.accumulatedFrictionImpulse, _local25);
_local27 = _local13.accumulatedFrictionImpulse.modulo;
_local28 = (_arg1.mat.friction * _local13.accumulatedNormalImpulse);
if ((((_local27 > JNumber3D.NUM_TINY)) && ((_local27 > _local28)))){
_local13.accumulatedFrictionImpulse = JNumber3D.multiply(_local13.accumulatedFrictionImpulse, (_local28 / _local27));
};
_local29 = JNumber3D.sub(_local13.accumulatedFrictionImpulse, _local26);
_local5.applyBodyWorldImpulse(_local29, _local13.r0);
_local6.applyBodyWorldImpulse(JNumber3D.multiply(_local29, -1), _local13.r1);
};
};
};
_local15++;
};
if (_local3){
_local5.setConstraintsAndCollisionsUnsatisfied();
_local6.setConstraintsAndCollisionsUnsatisfied();
};
return (_local3);
}
private function limitAllVelocities():void{
var _local1:String;
for (_local1 in _activeBodies) {
_activeBodies[_local1].limitVel();
_activeBodies[_local1].limitAngVel();
};
}
public function removeBody(_arg1:RigidBody):void{
if (findBody(_arg1)){
_bodies.splice(_bodies.indexOf(_arg1), 1);
_collisionSystem.removeCollisionBody(_arg1);
};
}
public function removeController(_arg1:PhysicsController):void{
if (findController(_arg1)){
_controllers.splice(_controllers.indexOf(_arg1), 1);
};
}
private function preProcessCollisionFast(_arg1:CollisionInfo, _arg2:Number):void{
var _local3:RigidBody;
var _local4:RigidBody;
var _local5:JNumber3D;
var _local6:Number;
var _local7:Number;
var _local8:CollPointInfo;
var _local9:JNumber3D;
var _local10:int;
var _local11:int;
var _local12:JNumber3D;
var _local13:JNumber3D;
var _local14:Number;
var _local15:int;
_arg1.satisfied = false;
_local3 = _arg1.objInfo.body0;
_local4 = _arg1.objInfo.body1;
_local5 = _arg1.dirToBody;
_local6 = (JConfig.numPenetrationRelaxationTimesteps * _arg2);
_local7 = 0;
_local10 = _arg1.pointInfo.length;
if (_local10 > 1){
_local12 = new JNumber3D();
_local13 = new JNumber3D();
_local14 = 0;
_local15 = 0;
while (_local15 < _local10) {
_local8 = _arg1.pointInfo[_local15];
_local12 = JNumber3D.add(_local12, _local8.r0);
_local13 = JNumber3D.add(_local13, _local8.r1);
_local14 = (_local14 + _local8.initialPenetration);
_local15++;
};
_local12 = JNumber3D.divide(_local12, Number(_local10));
_local13 = JNumber3D.divide(_local13, Number(_local10));
_local14 = (_local14 / _local10);
_arg1.pointInfo = [];
_arg1.pointInfo[0] = new CollPointInfo();
_arg1.pointInfo[0].r0 = _local12;
_arg1.pointInfo[0].r1 = _local13;
_arg1.pointInfo[0].initialPenetration = _local14;
};
_local11 = _arg1.pointInfo.length;
_local15 = 0;
while (_local15 < _local11) {
_local8 = _arg1.pointInfo[_local15];
if (!_local3.movable){
_local8.denominator = 0;
} else {
_local9 = JNumber3D.cross(_local5, _local8.r0);
JMatrix3D.multiplyVector(_local3.worldInvInertia, _local9);
_local8.denominator = (_local3.invMass + JNumber3D.dot(_local5, JNumber3D.cross(_local8.r0, _local9)));
};
if (_local4.movable){
_local9 = JNumber3D.cross(_local5, _local8.r1);
JMatrix3D.multiplyVector(_local4.worldInvInertia, _local9);
_local8.denominator = (_local8.denominator + (_local4.invMass + JNumber3D.dot(_local5, JNumber3D.cross(_local8.r1, _local9))));
};
if (_local8.denominator < JNumber3D.NUM_TINY){
_local8.denominator = JNumber3D.NUM_TINY;
};
if (_local8.initialPenetration > JConfig.allowedPenetration){
_local8.minSeparationVel = ((_local8.initialPenetration - JConfig.allowedPenetration) / _local6);
} else {
_local7 = ((-0.1 * (_local8.initialPenetration - JConfig.allowedPenetration)) / JConfig.allowedPenetration);
if (_local7 < JNumber3D.NUM_TINY){
_local7 = JNumber3D.NUM_TINY;
} else {
if (_local7 > 1){
_local7 = 1;
};
};
_local8.minSeparationVel = ((_local7 * (_local8.initialPenetration - JConfig.allowedPenetration)) / Math.max(_arg2, JNumber3D.NUM_TINY));
};
if (_local8.minSeparationVel > _maxVelMag){
_local8.minSeparationVel = _maxVelMag;
};
_local15++;
};
}
private function copyAllCurrentStatesToOld():void{
var _local1:String;
for (_local1 in _bodies) {
if (((_bodies[_local1].isActive()) || (_bodies[_local1].getVelChanged()))){
_bodies[_local1].copyCurrentStateToOld();
};
};
}
public function getCollisionSystem():CollisionSystem{
return (_collisionSystem);
}
private function preProcessCollisionNormal(_arg1:CollisionInfo, _arg2:Number):void{
var _local3:RigidBody;
var _local4:RigidBody;
var _local5:JNumber3D;
var _local6:Number;
var _local7:Number;
var _local8:CollPointInfo;
var _local9:JNumber3D;
var _local10:int;
var _local11:int;
_arg1.satisfied = false;
_local3 = _arg1.objInfo.body0;
_local4 = _arg1.objInfo.body1;
_local5 = _arg1.dirToBody;
_local6 = (JConfig.numPenetrationRelaxationTimesteps * _arg2);
_local7 = 0;
_local10 = _arg1.pointInfo.length;
_local11 = 0;
while (_local11 < _local10) {
_local8 = _arg1.pointInfo[_local11];
if (!_local3.movable){
_local8.denominator = 0;
} else {
_local9 = JNumber3D.cross(_local5, _local8.r0);
JMatrix3D.multiplyVector(_local3.worldInvInertia, _local9);
_local8.denominator = (_local3.invMass + JNumber3D.dot(_local5, JNumber3D.cross(_local8.r0, _local9)));
};
if (_local4.movable){
_local9 = JNumber3D.cross(_local5, _local8.r1);
JMatrix3D.multiplyVector(_local4.worldInvInertia, _local9);
_local8.denominator = (_local8.denominator + (_local4.invMass + JNumber3D.dot(_local5, JNumber3D.cross(_local8.r1, _local9))));
};
if (_local8.denominator < JNumber3D.NUM_TINY){
_local8.denominator = JNumber3D.NUM_TINY;
};
if (_local8.initialPenetration > JConfig.allowedPenetration){
_local8.minSeparationVel = ((_local8.initialPenetration - JConfig.allowedPenetration) / _local6);
} else {
_local7 = ((-0.1 * (_local8.initialPenetration - JConfig.allowedPenetration)) / JConfig.allowedPenetration);
if (_local7 < JNumber3D.NUM_TINY){
_local7 = JNumber3D.NUM_TINY;
} else {
if (_local7 > 1){
_local7 = 1;
};
};
_local8.minSeparationVel = ((_local7 * (_local8.initialPenetration - JConfig.allowedPenetration)) / Math.max(_arg2, JNumber3D.NUM_TINY));
};
if (_local8.minSeparationVel > _maxVelMag){
_local8.minSeparationVel = _maxVelMag;
};
_local11++;
};
}
public function get gravity():JNumber3D{
return (_gravity);
}
private function notifyAllPostPhysics(_arg1:Number):void{
var _local2:String;
for (_local2 in _bodies) {
_bodies[_local2].postPhysics(_arg1);
};
}
public function integrate(_arg1:Number):void{
var _local2:String;
_doingIntegration = true;
findAllActiveBodies();
copyAllCurrentStatesToOld();
getAllExternalForces(_arg1);
detectAllCollisions(_arg1);
handleAllConstraints(_arg1, JConfig.numCollisionIterations, false);
updateAllVelocities(_arg1);
handleAllConstraints(_arg1, JConfig.numContactIterations, true);
dampAllActiveBodies();
tryToFreezeAllObjects(_arg1);
activateAllFrozenObjectsLeftHanging();
if (JConfig.limitVelocities){
limitAllVelocities();
};
updateAllPositions(_arg1);
notifyAllPostPhysics(_arg1);
updateAllObject3D();
if (JConfig.solverType == "ACCUMULATED"){
updateContactCache();
};
for (_local2 in _bodies) {
_bodies[_local2].clearForces();
};
_doingIntegration = false;
}
private function getAllExternalForces(_arg1:Number):void{
var _local2:String;
for (_local2 in _bodies) {
_bodies[_local2].addExternalForces(_arg1);
};
for (_local2 in _controllers) {
_controllers[_local2].updateController(_arg1);
};
}
private function tryToFreezeAllObjects(_arg1:Number):void{
var _local2:String;
for (_local2 in _activeBodies) {
_activeBodies[_local2].tryToFreeze(_arg1);
};
}
public function addBody(_arg1:RigidBody):void{
if (!findBody(_arg1)){
_bodies.push(_arg1);
_collisionSystem.addCollisionBody(_arg1);
};
}
public function addConstraint(_arg1:JConstraint):void{
if (!findConstraint(_arg1)){
_constraints.push(_arg1);
};
}
public function setSolverType(_arg1:String):void{
switch (_arg1){
case "FAST":
preProcessCollisionFn = preProcessCollisionFast;
preProcessContactFn = preProcessCollisionFast;
processCollisionFn = processCollision;
processContactFn = processCollision;
return;
case "NORMAL":
preProcessCollisionFn = preProcessCollisionNormal;
preProcessContactFn = preProcessCollisionNormal;
processCollisionFn = processCollision;
processContactFn = processCollision;
return;
case "ACCUMULATED":
preProcessCollisionFn = preProcessCollisionNormal;
preProcessContactFn = preProcessCollisionAccumulated;
processCollisionFn = processCollision;
processContactFn = processCollisionAccumulated;
return;
default:
preProcessCollisionFn = preProcessCollisionNormal;
preProcessContactFn = preProcessCollisionNormal;
processCollisionFn = processCollision;
processContactFn = processCollision;
return;
};
}
private function updateAllVelocities(_arg1:Number):void{
var _local2:String;
for (_local2 in _activeBodies) {
_activeBodies[_local2].updateVelocity(_arg1);
};
}
public function removeAllConstraints():void{
_constraints = [];
}
private function tryToActivateAllFrozenObjects():void{
var _local1:String;
for (_local1 in _bodies) {
if (!_bodies[_local1].isActive()){
if (_bodies[_local1].getShouldBeActive()){
activateObject(_bodies[_local1]);
} else {
if (_bodies[_local1].getVelChanged()){
_bodies[_local1].setVelocity(JNumber3D.ZERO);
_bodies[_local1].setAngVel(JNumber3D.ZERO);
_bodies[_local1].clearVelChanged();
};
};
};
};
}
private function findConstraint(_arg1:JConstraint):Boolean{
var _local2:String;
for (_local2 in _constraints) {
if (_arg1 == _constraints[_local2]){
return (true);
};
};
return (false);
}
public static function getInstance():PhysicsSystem{
if (!_currentPhysicsSystem){
trace("version: JigLibFlash v0.32 (2009-5-7)");
_currentPhysicsSystem = new (PhysicsSystem);
};
return (_currentPhysicsSystem);
}
}
}//package jiglib.physics
Section 40
//RigidBody (jiglib.physics.RigidBody)
package jiglib.physics {
import jiglib.plugin.*;
import jiglib.math.*;
import jiglib.geometry.*;
import jiglib.cof.*;
public class RigidBody {
protected var _currState:PhysicsState;
private var _bodyInertia:JMatrix3D;
private var _oldState:PhysicsState;
protected var _type:String;
private var _rotationX:Number;// = 0
private var _rotationY:Number;// = 0
private var _rotationZ:Number;// = 0
private var _lastPositionForDeactivation:JNumber3D;
private var _lastOrientationForDeactivation:JMatrix3D;
private var _torque:JNumber3D;
private var _origMovable:Boolean;
private var _movable:Boolean;
private var _invOrientation:JMatrix3D;
private var _invMass:Number;
private var _useDegrees:Boolean;
private var _skin:ISkin3D;
private var _activity:Boolean;
private var _storedPositionForActivation:JNumber3D;
private var _worldInvInertia:JMatrix3D;
private var _material:MaterialProperties;
private var _bodiesToBeActivatedOnMovement:Array;
public var collisions:Array;
private var _worldInertia:JMatrix3D;
protected var _boundingSphere:Number;
private var _inactiveTime:Number;
private var _id:int;
private var _currRotVelocityAux:JNumber3D;
private var _nonCollidables:Array;
private var _currLinVelocityAux:JNumber3D;
private var _storeState:PhysicsState;
private var _mass:Number;
private var _bodyInvInertia:JMatrix3D;
private var _force:JNumber3D;
private var _velChanged:Boolean;
private static var idCounter:int = 0;
public function RigidBody(_arg1:ISkin3D){
_rotationX = 0;
_rotationY = 0;
_rotationZ = 0;
super();
_useDegrees = ((JConfig.rotationType)=="DEGREES") ? true : false;
_id = idCounter++;
_skin = _arg1;
_material = new MaterialProperties();
_bodyInertia = JMatrix3D.IDENTITY;
_bodyInvInertia = JMatrix3D.inverse(_bodyInertia);
_currState = new PhysicsState();
_oldState = new PhysicsState();
_storeState = new PhysicsState();
_invOrientation = JMatrix3D.inverse(_currState.orientation);
_currLinVelocityAux = new JNumber3D();
_currRotVelocityAux = new JNumber3D();
_force = new JNumber3D();
_torque = new JNumber3D();
_velChanged = false;
_inactiveTime = 0;
_activity = true;
_movable = true;
_origMovable = true;
collisions = new Array();
_nonCollidables = new Array();
_storedPositionForActivation = new JNumber3D();
_bodiesToBeActivatedOnMovement = new Array();
_lastPositionForDeactivation = _currState.position.clone();
_lastOrientationForDeactivation = JMatrix3D.clone(_currState.orientation);
_type = "Object3D";
_boundingSphere = 0;
}
public function getShouldBeActive():Boolean{
return ((((_currState.linVelocity.modulo > JConfig.velThreshold)) || ((_currState.rotVelocity.modulo > JConfig.angVelThreshold))));
}
public function get mass():Number{
return (_mass);
}
public function copyCurrentStateToOld():void{
_currState.position.copyTo(_oldState.position);
_oldState.orientation.copy(_currState.orientation);
_currState.linVelocity.copyTo(_oldState.linVelocity);
_currState.rotVelocity.copyTo(_oldState.rotVelocity);
}
public function set restitution(_arg1:Number):void{
_material.restitution = _arg1;
}
private function degreesToRadians(_arg1:Number):Number{
return (((_arg1 * Math.PI) / 180));
}
public function setOrientation(_arg1:JMatrix3D):void{
_currState.orientation.copy(_arg1);
_invOrientation = JMatrix3D.transpose(_currState.orientation);
_worldInertia = JMatrix3D.multiply(JMatrix3D.multiply(_currState.orientation, _bodyInertia), _invOrientation);
_worldInvInertia = JMatrix3D.multiply(JMatrix3D.multiply(_currState.orientation, _bodyInvInertia), _invOrientation);
updateState();
}
public function set friction(_arg1:Number):void{
_material.friction = _arg1;
}
public function setActive(_arg1:Number=1):void{
if (_movable){
_activity = true;
_inactiveTime = ((1 - _arg1) * JConfig.deactivationTime);
};
}
public function setAngVelAux(_arg1:JNumber3D):void{
_arg1.copyTo(_currRotVelocityAux);
}
public function updatePosition(_arg1:Number):void{
var _local2:JNumber3D;
var _local3:Number;
var _local4:JMatrix3D;
if (((!(_movable)) || (!(_activity)))){
return;
};
_currState.position = JNumber3D.add(_currState.position, JNumber3D.multiply(_currState.linVelocity, _arg1));
_local2 = _currState.rotVelocity.clone();
_local3 = _local2.modulo;
if (_local3 > 0){
_local2.normalize();
_local3 = (_local3 * _arg1);
_local4 = JMatrix3D.rotationMatrix(_local2.x, _local2.y, _local2.z, _local3);
_currState.orientation = JMatrix3D.multiply(_local4, _currState.orientation);
_invOrientation = JMatrix3D.transpose(_currState.orientation);
_worldInertia = JMatrix3D.multiply(JMatrix3D.multiply(_currState.orientation, _bodyInertia), _invOrientation);
_worldInvInertia = JMatrix3D.multiply(JMatrix3D.multiply(_currState.orientation, _bodyInvInertia), _invOrientation);
};
}
public function get material():MaterialProperties{
return (_material);
}
public function get id():int{
return (_id);
}
public function moveTo(_arg1:JNumber3D):void{
_arg1.copyTo(_currState.position);
updateState();
}
public function storeState():void{
_currState.position.copyTo(_storeState.position);
_storeState.orientation.copy(_currState.orientation);
_currState.linVelocity.copyTo(_storeState.linVelocity);
_currState.rotVelocity.copyTo(_storeState.rotVelocity);
}
public function set rotationX(_arg1:Number):void{
var _local2:Number;
_local2 = (_useDegrees) ? degreesToRadians(_arg1) : _arg1;
_rotationX = _local2;
setOrientation(createRotationMatrix());
}
public function segmentIntersect(_arg1:Object, _arg2:JSegment, _arg3:PhysicsState):Boolean{
return (false);
}
public function set rotationY(_arg1:Number):void{
var _local2:Number;
_local2 = (_useDegrees) ? degreesToRadians(_arg1) : _arg1;
_rotationY = _local2;
setOrientation(createRotationMatrix());
}
public function set rotationZ(_arg1:Number):void{
var _local2:Number;
_local2 = (_useDegrees) ? degreesToRadians(_arg1) : _arg1;
_rotationZ = _local2;
setOrientation(createRotationMatrix());
}
public function pitch(_arg1:Number):void{
var _local2:Number;
_local2 = (_useDegrees) ? degreesToRadians(_arg1) : _arg1;
setOrientation(JMatrix3D.multiply(currentState.orientation, JMatrix3D.rotationX(_arg1)));
}
public function get type():String{
return (_type);
}
protected function updateState():void{
_currState.linVelocity = JNumber3D.ZERO;
_currState.rotVelocity = JNumber3D.ZERO;
copyCurrentStateToOld();
}
public function getVelChanged():Boolean{
return (_velChanged);
}
public function applyBodyWorldImpulse(_arg1:JNumber3D, _arg2:JNumber3D):void{
var _local3:JNumber3D;
if (!_movable){
return;
};
_currState.linVelocity = JNumber3D.add(_currState.linVelocity, JNumber3D.multiply(_arg1, _invMass));
_local3 = JNumber3D.cross(_arg1, _arg2);
JMatrix3D.multiplyVector(_worldInvInertia, _local3);
_velChanged = true;
}
public function getVelocity(_arg1:JNumber3D):JNumber3D{
return (JNumber3D.add(_currState.linVelocity, JNumber3D.cross(_arg1, _currState.rotVelocity)));
}
public function get friction():Number{
return (_material.friction);
}
public function setVelocity(_arg1:JNumber3D):void{
_arg1.copyTo(_currState.linVelocity);
}
public function enableCollisions(_arg1:RigidBody):void{
if (findNonCollidablesBody(_arg1)){
_nonCollidables.splice(_nonCollidables.indexOf(_arg1), 1);
};
}
public function setAngVel(_arg1:JNumber3D):void{
_arg1.copyTo(_currState.rotVelocity);
}
public function doMovementActivations():void{
var _local1:int;
if ((((_bodiesToBeActivatedOnMovement.length == 0)) || ((JNumber3D.sub(_currState.position, _storedPositionForActivation).modulo < JConfig.posThreshold)))){
return;
};
_local1 = 0;
while (_local1 < _bodiesToBeActivatedOnMovement.length) {
PhysicsSystem.getInstance().activateObject(_bodiesToBeActivatedOnMovement[_local1]);
_local1++;
};
_bodiesToBeActivatedOnMovement = [];
}
public function addGravity():void{
if (!_movable){
return;
};
_force = JNumber3D.add(_force, JNumber3D.multiply(PhysicsSystem.getInstance().gravity, _mass));
_velChanged = true;
}
public function yaw(_arg1:Number):void{
var _local2:Number;
_local2 = (_useDegrees) ? degreesToRadians(_arg1) : _arg1;
setOrientation(JMatrix3D.multiply(currentState.orientation, JMatrix3D.rotationY(_arg1)));
}
public function applyBodyWorldImpulseAux(_arg1:JNumber3D, _arg2:JNumber3D):void{
var _local3:JNumber3D;
if (!_movable){
return;
};
_currLinVelocityAux = JNumber3D.add(_currLinVelocityAux, JNumber3D.multiply(_arg1, _invMass));
_local3 = JNumber3D.cross(_arg1, _arg2);
JMatrix3D.multiplyVector(_worldInvInertia, _local3);
_currRotVelocityAux = JNumber3D.add(_currRotVelocityAux, _local3);
_velChanged = true;
}
public function getShouldBeActiveAux():Boolean{
return ((((_currLinVelocityAux.modulo > JConfig.velThreshold)) || ((_currRotVelocityAux.modulo > JConfig.angVelThreshold))));
}
public function applyWorldImpulseAux(_arg1:JNumber3D, _arg2:JNumber3D):void{
var _local3:JNumber3D;
if (!_movable){
return;
};
_currLinVelocityAux = JNumber3D.add(_currLinVelocityAux, JNumber3D.multiply(_arg1, _invMass));
_local3 = JNumber3D.cross(_arg1, JNumber3D.sub(_arg2, _currState.position));
JMatrix3D.multiplyVector(_worldInvInertia, _local3);
_currRotVelocityAux = JNumber3D.add(_currRotVelocityAux, _local3);
_velChanged = true;
}
public function get x():Number{
return (_currState.position.x);
}
public function get y():Number{
return (_currState.position.y);
}
public function get z():Number{
return (_currState.position.z);
}
public function roll(_arg1:Number):void{
var _local2:Number;
_local2 = (_useDegrees) ? degreesToRadians(_arg1) : _arg1;
setOrientation(JMatrix3D.multiply(currentState.orientation, JMatrix3D.rotationZ(_arg1)));
}
public function getVelocityAux(_arg1:JNumber3D):JNumber3D{
return (JNumber3D.add(_currLinVelocityAux, JNumber3D.cross(_arg1, _currRotVelocityAux)));
}
public function clearVelChanged():void{
_velChanged = false;
}
public function get invMass():Number{
return (_invMass);
}
public function postPhysics(_arg1:Number):void{
}
public function setConstraintsAndCollisionsUnsatisfied():void{
var _local1:String;
for (_local1 in collisions) {
collisions[_local1].satisfied = false;
};
}
private function findNonCollidablesBody(_arg1:RigidBody):Boolean{
var _local2:String;
for (_local2 in _nonCollidables) {
if (_arg1 == _nonCollidables[_local2]){
return (true);
};
};
return (false);
}
public function applyWorldImpulse(_arg1:JNumber3D, _arg2:JNumber3D):void{
var _local3:JNumber3D;
if (!_movable){
return;
};
_currState.linVelocity = JNumber3D.add(_currState.linVelocity, JNumber3D.multiply(_arg1, _invMass));
_local3 = JNumber3D.cross(_arg1, JNumber3D.sub(_arg2, _currState.position));
JMatrix3D.multiplyVector(_worldInvInertia, _local3);
_currState.rotVelocity = JNumber3D.add(_currState.rotVelocity, _local3);
_velChanged = true;
}
public function addExternalForces(_arg1:Number):void{
addGravity();
}
public function clearForces():void{
_force = JNumber3D.ZERO;
_torque = JNumber3D.ZERO;
}
public function get restitution():Number{
return (_material.restitution);
}
public function disableCollisions(_arg1:RigidBody):void{
if (!findNonCollidablesBody(_arg1)){
_nonCollidables.push(_arg1);
};
}
public function get rotationX():Number{
return ((_useDegrees) ? radiansToDegrees(_rotationX) : _rotationX);
}
public function get rotationY():Number{
return ((_useDegrees) ? radiansToDegrees(_rotationY) : _rotationY);
}
public function get rotationZ():Number{
return ((_useDegrees) ? radiansToDegrees(_rotationZ) : _rotationZ);
}
public function get currentState():PhysicsState{
return (_currState);
}
public function get boundingSphere():Number{
return (_boundingSphere);
}
public function restoreState():void{
_storeState.position.copyTo(_currState.position);
_currState.orientation.copy(_storeState.orientation);
_storeState.linVelocity.copyTo(_currState.linVelocity);
_storeState.rotVelocity.copyTo(_currState.rotVelocity);
}
public function get nonCollidables():Array{
return (_nonCollidables);
}
public function get oldState():PhysicsState{
return (_oldState);
}
public function updatePositionWithAux(_arg1:Number):void{
var _local2:int;
var _local3:JNumber3D;
var _local4:Number;
var _local5:Array;
var _local6:JMatrix3D;
if (((!(_movable)) || (!(_activity)))){
_currLinVelocityAux = JNumber3D.ZERO;
_currRotVelocityAux = JNumber3D.ZERO;
return;
};
_local2 = PhysicsSystem.getInstance().gravityAxis;
if (_local2 != -1){
_local5 = _currLinVelocityAux.toArray();
_local5[((_local2 + 1) % 3)] = (_local5[((_local2 + 1) % 3)] * 0.1);
_local5[((_local2 + 2) % 3)] = (_local5[((_local2 + 2) % 3)] * 0.1);
_currLinVelocityAux.copyFromArray(_local5);
};
_currState.position = JNumber3D.add(_currState.position, JNumber3D.multiply(JNumber3D.add(_currState.linVelocity, _currLinVelocityAux), _arg1));
_local3 = JNumber3D.add(_currState.rotVelocity, _currRotVelocityAux);
_local4 = _local3.modulo;
if (_local4 > 0){
_local3.normalize();
_local4 = (_local4 * _arg1);
_local6 = JMatrix3D.rotationMatrix(_local3.x, _local3.y, _local3.z, _local4);
_currState.orientation = JMatrix3D.multiply(_local6, _currState.orientation);
_invOrientation = JMatrix3D.transpose(_currState.orientation);
_worldInertia = JMatrix3D.multiply(JMatrix3D.multiply(_currState.orientation, _bodyInertia), _invOrientation);
_worldInvInertia = JMatrix3D.multiply(JMatrix3D.multiply(_currState.orientation, _bodyInvInertia), _invOrientation);
};
_currLinVelocityAux = JNumber3D.ZERO;
_currRotVelocityAux = JNumber3D.ZERO;
}
public function addMovementActivation(_arg1:JNumber3D, _arg2:RigidBody):void{
var _local3:int;
var _local4:int;
_local3 = _bodiesToBeActivatedOnMovement.length;
_local4 = 0;
while (_local4 < _local3) {
if (_bodiesToBeActivatedOnMovement[_local4] == _arg2){
return;
};
_local4++;
};
if (_bodiesToBeActivatedOnMovement.length == 0){
_storedPositionForActivation = _arg1;
};
_bodiesToBeActivatedOnMovement.push(_arg2);
}
public function get movable():Boolean{
return (_movable);
}
public function get skin():ISkin3D{
return (_skin);
}
public function internalRestoreImmovable():void{
_movable = _origMovable;
}
public function get worldInvInertia():JMatrix3D{
return (_worldInvInertia);
}
public function getTransform():JMatrix3D{
if (_skin != null){
return (_skin.transform);
};
return (null);
}
public function dampForDeactivation():void{
var _local1:Number;
var _local2:Number;
var _local3:Number;
_local1 = 0.5;
_local2 = (_inactiveTime / JConfig.deactivationTime);
if (_local2 < _local1){
return;
};
_local3 = (1 - ((_local2 - _local1) / (1 - _local1)));
if (_local3 < 0){
_local3 = 0;
} else {
if (_local3 > 1){
_local3 = 1;
};
};
_currState.linVelocity = JNumber3D.multiply(_currState.linVelocity, _local3);
_currState.rotVelocity = JNumber3D.multiply(_currState.rotVelocity, _local3);
}
public function updateVelocity(_arg1:Number):void{
var _local2:JNumber3D;
if (((!(_movable)) || (!(_activity)))){
return;
};
_currState.linVelocity = JNumber3D.add(_currState.linVelocity, JNumber3D.multiply(_force, (_invMass * _arg1)));
_local2 = JNumber3D.multiply(_torque, _arg1);
JMatrix3D.multiplyVector(_worldInvInertia, _local2);
_currState.rotVelocity = JNumber3D.add(_currState.rotVelocity, _local2);
_currState.linVelocity = JNumber3D.multiply(_currState.linVelocity, JConfig.damping);
_currState.rotVelocity = JNumber3D.multiply(_currState.rotVelocity, JConfig.damping);
}
public function addBodyForce(_arg1:JNumber3D, _arg2:JNumber3D):void{
if (!_movable){
return;
};
JMatrix3D.multiplyVector(_currState.orientation, _arg1);
JMatrix3D.multiplyVector(_currState.orientation, _arg2);
addWorldForce(_arg1, JNumber3D.add(_currState.position, _arg2));
}
public function addBodyTorque(_arg1:JNumber3D):void{
if (!_movable){
return;
};
JMatrix3D.multiplyVector(_currState.orientation, _arg1);
addWorldTorque(_arg1);
}
public function isActive():Boolean{
return (_activity);
}
public function hitTestObject3D(_arg1:RigidBody):Boolean{
var _local2:Number;
var _local3:Number;
_local2 = JNumber3D.sub(_currState.position, _arg1.currentState.position).modulo;
_local3 = (_boundingSphere + _arg1.boundingSphere);
if (_local2 <= _local3){
return (true);
};
return (false);
}
public function getInertiaProperties(_arg1:Number):JMatrix3D{
return (new JMatrix3D());
}
public function updateObject3D():void{
var _local1:JMatrix3D;
if (_skin != null){
_local1 = JMatrix3D.multiply(JMatrix3D.translationMatrix(_currState.position.x, _currState.position.y, _currState.position.z), _currState.orientation);
_skin.transform = _local1;
};
}
private function radiansToDegrees(_arg1:Number):Number{
return (((_arg1 * 180) / Math.PI));
}
public function addWorldTorque(_arg1:JNumber3D):void{
if (!_movable){
return;
};
_torque = JNumber3D.add(_torque, _arg1);
_velChanged = true;
setActive();
}
public function get worldInertia():JMatrix3D{
return (_worldInertia);
}
public function limitVel():void{
_currState.linVelocity.x = JNumber3D.limiteNumber(_currState.linVelocity.x, -100, 100);
_currState.linVelocity.y = JNumber3D.limiteNumber(_currState.linVelocity.y, -100, 100);
_currState.linVelocity.z = JNumber3D.limiteNumber(_currState.linVelocity.z, -100, 100);
}
public function set movable(_arg1:Boolean):void{
_movable = _arg1;
_activity = _arg1;
_origMovable = _arg1;
}
public function setVelocityAux(_arg1:JNumber3D):void{
_arg1.copyTo(_currLinVelocityAux);
}
public function get force():JNumber3D{
return (_force);
}
public function setInactive():void{
if (_movable){
_activity = false;
};
}
public function tryToFreeze(_arg1:Number):void{
var _local2:JMatrix3D;
if (((!(_movable)) || (!(_activity)))){
return;
};
if (JNumber3D.sub(_currState.position, _lastPositionForDeactivation).modulo > JConfig.posThreshold){
_currState.position.copyTo(_lastPositionForDeactivation);
_inactiveTime = 0;
return;
};
_local2 = JMatrix3D.sub(_currState.orientation, _lastOrientationForDeactivation);
if ((((((_local2.getCols()[0].modulo > JConfig.orientThreshold)) || ((_local2.getCols()[1].modulo > JConfig.orientThreshold)))) || ((_local2.getCols()[2].modulo > JConfig.orientThreshold)))){
_lastOrientationForDeactivation.copy(_currState.orientation);
_inactiveTime = 0;
return;
};
if (getShouldBeActive()){
return;
};
_inactiveTime = (_inactiveTime + _arg1);
if (_inactiveTime > JConfig.deactivationTime){
_currState.position.copyTo(_lastPositionForDeactivation);
_lastOrientationForDeactivation.copy(_currState.orientation);
setInactive();
};
}
public function set x(_arg1:Number):void{
_currState.position.x = _arg1;
updateState();
}
public function set y(_arg1:Number):void{
_currState.position.y = _arg1;
updateState();
}
public function set z(_arg1:Number):void{
_currState.position.z = _arg1;
updateState();
}
public function set mass(_arg1:Number):void{
_mass = _arg1;
_invMass = (1 / _arg1);
setInertia(getInertiaProperties(_arg1));
}
public function addWorldForce(_arg1:JNumber3D, _arg2:JNumber3D):void{
if (!_movable){
return;
};
_force = JNumber3D.add(_force, _arg1);
addWorldTorque(JNumber3D.cross(_arg1, JNumber3D.sub(_arg2, _currState.position)));
_velChanged = true;
setActive();
}
private function createRotationMatrix():JMatrix3D{
var _local1:JMatrix3D;
var _local2:JMatrix3D;
var _local3:JMatrix3D;
var _local4:JMatrix3D;
_local1 = JMatrix3D.rotationX(_rotationX);
_local2 = JMatrix3D.rotationY(_rotationY);
_local3 = JMatrix3D.rotationZ(_rotationZ);
_local4 = JMatrix3D.multiply(_local1, _local2);
_local4 = JMatrix3D.multiply(_local4, _local3);
return (_local4);
}
public function internalSetImmovable():void{
_origMovable = _movable;
_movable = false;
}
public function limitAngVel():void{
var _local1:Number;
var _local2:Number;
var _local3:Number;
var _local4:Number;
_local1 = (Math.abs(_currState.rotVelocity.x) / 50);
_local2 = (Math.abs(_currState.rotVelocity.y) / 50);
_local3 = (Math.abs(_currState.rotVelocity.z) / 50);
_local4 = Math.max(_local1, _local2, _local3);
if (_local4 > 1){
_currState.rotVelocity = JNumber3D.divide(_currState.rotVelocity, _local4);
};
}
public function setInertia(_arg1:JMatrix3D):void{
_bodyInertia = JMatrix3D.clone(_arg1);
_bodyInvInertia = JMatrix3D.inverse(_arg1);
_worldInertia = JMatrix3D.multiply(JMatrix3D.multiply(_currState.orientation, _bodyInertia), _invOrientation);
_worldInvInertia = JMatrix3D.multiply(JMatrix3D.multiply(_currState.orientation, _bodyInvInertia), _invOrientation);
}
}
}//package jiglib.physics
Section 41
//Papervision3DPhysics (jiglib.plugin.papervision3d.Papervision3DPhysics)
package jiglib.plugin.papervision3d {
import jiglib.plugin.*;
import jiglib.math.*;
import jiglib.physics.*;
import jiglib.geometry.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.materials.utils.*;
import org.papervision3d.objects.*;
import org.papervision3d.objects.primitives.*;
public class Papervision3DPhysics extends AbstractPhysics {
public var arr_objects:Array;
private var scene:DisplayObjectContainer3D;
public function Papervision3DPhysics(_arg1:DisplayObjectContainer3D, _arg2:Number=1){
super(_arg2);
this.scene = _arg1;
arr_objects = [];
}
public function createSphere(_arg1:MaterialObject3D, _arg2:Number=100, _arg3:int=8, _arg4:int=6):RigidBody{
var _local5:Sphere;
var _local6:JSphere;
_local5 = new Sphere(_arg1, _arg2, _arg3, _arg4);
scene.addChild(_local5);
_local6 = new JSphere(new Pv3dMesh(_local5), _arg2);
arr_objects.push([_local5, _local6]);
addBody(_local6);
return (_local6);
}
public function getMesh(_arg1:RigidBody):DisplayObject3D{
return (Pv3dMesh(_arg1.skin).mesh);
}
public function createCube(_arg1:MaterialsList, _arg2:Number=500, _arg3:Number=500, _arg4:Number=500, _arg5:int=1, _arg6:int=1, _arg7:int=1, _arg8:int=0, _arg9:int=0):RigidBody{
var _local10:Cube;
var _local11:JBox;
_local10 = new Cube(_arg1, _arg2, _arg3, _arg4, _arg5, _arg6, _arg7, _arg8, _arg9);
scene.addChild(_local10);
_local11 = new JBox(new Pv3dMesh(_local10), _arg2, _arg3, _arg4);
addBody(_local11);
arr_objects.push([_local10, _local11]);
return (_local11);
}
public function createGround(_arg1:MaterialObject3D, _arg2:Number, _arg3:Number):RigidBody{
var _local4:Plane;
var _local5:JPlane;
_local4 = new Plane(_arg1, _arg2, _arg2);
scene.addChild(_local4);
_local5 = new JPlane(new Pv3dMesh(_local4));
_local5.movable = false;
_local5.setOrientation(JMatrix3D.rotationX((Math.PI / 2)));
_local5.y = _arg3;
addBody(_local5);
arr_objects.push([_local4, _local5]);
return (_local5);
}
}
}//package jiglib.plugin.papervision3d
Section 42
//Pv3dMesh (jiglib.plugin.papervision3d.Pv3dMesh)
package jiglib.plugin.papervision3d {
import jiglib.plugin.*;
import jiglib.math.*;
import org.papervision3d.core.math.*;
import org.papervision3d.objects.*;
public class Pv3dMesh implements ISkin3D {
private var do3d:DisplayObject3D;
public function Pv3dMesh(_arg1:DisplayObject3D){
this.do3d = _arg1;
}
public function set transform(_arg1:JMatrix3D):void{
var _local2:Matrix3D;
_local2 = new Matrix3D();
_local2.n11 = _arg1.n11;
_local2.n12 = _arg1.n12;
_local2.n13 = _arg1.n13;
_local2.n14 = _arg1.n14;
_local2.n21 = _arg1.n21;
_local2.n22 = _arg1.n22;
_local2.n23 = _arg1.n23;
_local2.n24 = _arg1.n24;
_local2.n31 = _arg1.n31;
_local2.n32 = _arg1.n32;
_local2.n33 = _arg1.n33;
_local2.n34 = _arg1.n34;
_local2.n41 = _arg1.n41;
_local2.n42 = _arg1.n42;
_local2.n43 = _arg1.n43;
_local2.n44 = _arg1.n44;
do3d.transform = _local2;
}
public function get transform():JMatrix3D{
var _local1:JMatrix3D;
_local1 = new JMatrix3D();
_local1.n11 = do3d.transform.n11;
_local1.n12 = do3d.transform.n12;
_local1.n13 = do3d.transform.n13;
_local1.n14 = do3d.transform.n14;
_local1.n21 = do3d.transform.n21;
_local1.n22 = do3d.transform.n22;
_local1.n23 = do3d.transform.n23;
_local1.n24 = do3d.transform.n24;
_local1.n31 = do3d.transform.n31;
_local1.n32 = do3d.transform.n32;
_local1.n33 = do3d.transform.n33;
_local1.n34 = do3d.transform.n34;
_local1.n41 = do3d.transform.n41;
_local1.n42 = do3d.transform.n42;
_local1.n43 = do3d.transform.n43;
_local1.n44 = do3d.transform.n44;
return (_local1);
}
public function get mesh():DisplayObject3D{
return (do3d);
}
}
}//package jiglib.plugin.papervision3d
Section 43
//AbstractPhysics (jiglib.plugin.AbstractPhysics)
package jiglib.plugin {
import jiglib.physics.*;
import flash.utils.*;
public class AbstractPhysics {
private var deltaTime:Number;// = 0
private var speed:Number;
private var stepTime:int;
private var initTime:int;
public function AbstractPhysics(_arg1:Number=5){
deltaTime = 0;
super();
this.speed = _arg1;
initTime = getTimer();
}
public function get engine():PhysicsSystem{
return (PhysicsSystem.getInstance());
}
public function addBody(_arg1:RigidBody):void{
PhysicsSystem.getInstance().addBody((_arg1 as RigidBody));
}
public function removeBody(_arg1:RigidBody):void{
PhysicsSystem.getInstance().removeBody((_arg1 as RigidBody));
}
public function step():void{
stepTime = getTimer();
deltaTime = (((stepTime - initTime) / 1000) * speed);
initTime = stepTime;
PhysicsSystem.getInstance().integrate(deltaTime);
}
}
}//package jiglib.plugin
Section 44
//ISkin3D (jiglib.plugin.ISkin3D)
package jiglib.plugin {
import jiglib.math.*;
public interface ISkin3D {
function set transform(_arg1:JMatrix3D):void;
function get transform():JMatrix3D;
}
}//package jiglib.plugin
Section 45
//MochiDigits (mochi.as3.MochiDigits)
package mochi.as3 {
public final class MochiDigits {
private var Sibling:MochiDigits;
private var Fragment:Number;
private var Encoder:Number;
public function MochiDigits(_arg1:Number=0, _arg2:uint=0):void{
Encoder = 0;
setValue(_arg1, _arg2);
}
public function set value(_arg1:Number):void{
setValue(_arg1);
}
public function reencode():void{
var _local1:uint;
_local1 = int((2147483647 * Math.random()));
Fragment = (Fragment ^ (_local1 ^ Encoder));
Encoder = _local1;
}
public function toString():String{
var _local1:String;
_local1 = String.fromCharCode((Fragment ^ Encoder));
if (Sibling != null){
_local1 = (_local1 + Sibling.toString());
};
return (_local1);
}
public function get value():Number{
return (Number(this.toString()));
}
public function setValue(_arg1:Number=0, _arg2:uint=0):void{
var _local3:String;
_local3 = _arg1.toString();
var _temp1 = _arg2;
_arg2 = (_arg2 + 1);
Fragment = (_local3.charCodeAt(_temp1) ^ Encoder);
if (_arg2 < _local3.length){
Sibling = new MochiDigits(_arg1, _arg2);
} else {
Sibling = null;
};
reencode();
}
public function addValue(_arg1:Number):void{
value = (value + _arg1);
}
}
}//package mochi.as3
Section 46
//MochiScores (mochi.as3.MochiScores)
package mochi.as3 {
import flash.display.*;
import flash.text.*;
public class MochiScores {
private static var boardID:String;
public static var onErrorHandler:Object;
public static var onCloseHandler:Object;
public static function showLeaderboard(_arg1:Object=null):void{
var n:Number;
var options = _arg1;
if (options != null){
if (options.clip != null){
if ((options.clip is Sprite)){
MochiServices.setContainer(options.clip);
};
delete options.clip;
} else {
MochiServices.setContainer();
};
MochiServices.stayOnTop();
if (options.name != null){
if ((options.name is TextField)){
if (options.name.text.length > 0){
options.name = options.name.text;
};
};
};
if (options.score != null){
if ((options.score is TextField)){
if (options.score.text.length > 0){
options.score = options.score.text;
};
} else {
if ((options.score is MochiDigits)){
options.score = options.score.value;
};
};
n = Number(options.score);
if (isNaN(n)){
trace((("ERROR: Submitted score '" + options.score) + "' will be rejected, score is 'Not a Number'"));
} else {
if ((((n == Number.NEGATIVE_INFINITY)) || ((n == Number.POSITIVE_INFINITY)))){
trace((("ERROR: Submitted score '" + options.score) + "' will be rejected, score is an infinite"));
} else {
if (Math.floor(n) != n){
trace((("WARNING: Submitted score '" + options.score) + "' will be truncated"));
};
options.score = n;
};
};
};
if (options.onDisplay != null){
options.onDisplay();
} else {
if (MochiServices.clip != null){
if ((MochiServices.clip is MovieClip)){
MochiServices.clip.stop();
} else {
trace("Warning: Container is not a MovieClip, cannot call default onDisplay.");
};
};
};
} else {
options = {};
if ((MochiServices.clip is MovieClip)){
MochiServices.clip.stop();
} else {
trace("Warning: Container is not a MovieClip, cannot call default onDisplay.");
};
};
if (options.onClose != null){
onCloseHandler = options.onClose;
} else {
onCloseHandler = function ():void{
if ((MochiServices.clip is MovieClip)){
} else {
trace("Warning: Container is not a MovieClip, cannot call default onClose.");
};
};
};
if (options.onError != null){
onErrorHandler = options.onError;
} else {
onErrorHandler = null;
};
if (options.boardID == null){
if (MochiScores.boardID != null){
options.boardID = MochiScores.boardID;
};
};
trace("[MochiScores] NOTE: Security Sandbox Violation errors below are normal");
MochiServices.send("scores_showLeaderboard", {options:options}, null, onClose);
}
public static function closeLeaderboard():void{
MochiServices.send("scores_closeLeaderboard");
}
public static function getPlayerInfo(_arg1:Object, _arg2:Object=null):void{
MochiServices.send("scores_getPlayerInfo", null, _arg1, _arg2);
}
public static function requestList(_arg1:Object, _arg2:Object=null):void{
MochiServices.send("scores_requestList", null, _arg1, _arg2);
}
public static function scoresArrayToObjects(_arg1:Object):Object{
var _local2:Object;
var _local3:Number;
var _local4:Number;
var _local5:Object;
var _local6:Object;
var _local7:String;
var _local8:String;
_local2 = {};
for (_local7 in _arg1) {
if (typeof(_arg1[_local7]) == "object"){
if (((!((_arg1[_local7].cols == null))) && (!((_arg1[_local7].rows == null))))){
_local2[_local7] = [];
_local5 = _arg1[_local7];
_local4 = 0;
while (_local4 < _local5.rows.length) {
_local6 = {};
_local3 = 0;
while (_local3 < _local5.cols.length) {
_local6[_local5.cols[_local3]] = _local5.rows[_local4][_local3];
_local3++;
};
_local2[_local7].push(_local6);
_local4++;
};
} else {
_local2[_local7] = {};
for (_local8 in _arg1[_local7]) {
_local2[_local7][_local8] = _arg1[_local7][_local8];
};
};
} else {
_local2[_local7] = _arg1[_local7];
};
};
return (_local2);
}
public static function submit(_arg1:Number, _arg2:String, _arg3:Object=null, _arg4:Object=null):void{
_arg1 = Number(_arg1);
if (isNaN(_arg1)){
trace((("ERROR: Submitted score '" + String(_arg1)) + "' will be rejected, score is 'Not a Number'"));
} else {
if ((((_arg1 == Number.NEGATIVE_INFINITY)) || ((_arg1 == Number.POSITIVE_INFINITY)))){
trace((("ERROR: Submitted score '" + String(_arg1)) + "' will be rejected, score is an infinite"));
} else {
if (Math.floor(_arg1) != _arg1){
trace((("WARNING: Submitted score '" + String(_arg1)) + "' will be truncated"));
};
_arg1 = Number(_arg1);
};
};
MochiServices.send("scores_submit", {score:_arg1, name:_arg2}, _arg3, _arg4);
}
public static function onClose(_arg1:Object=null):void{
if (_arg1 != null){
if (_arg1.error != null){
if (_arg1.error == true){
if (onErrorHandler != null){
if (_arg1.errorCode == null){
_arg1.errorCode = "IOError";
};
onErrorHandler(_arg1.errorCode);
MochiServices.doClose();
return;
};
};
};
};
onCloseHandler();
MochiServices.doClose();
}
public static function setBoardID(_arg1:String):void{
MochiScores.boardID = _arg1;
MochiServices.send("scores_setBoardID", {boardID:_arg1});
}
}
}//package mochi.as3
Section 47
//MochiServices (mochi.as3.MochiServices)
package mochi.as3 {
import flash.display.*;
import flash.events.*;
import flash.geom.*;
import flash.utils.*;
import flash.net.*;
import flash.system.*;
public class MochiServices {
private static var _container:Object;
private static var _connected:Boolean = false;
private static var _swfVersion:String;
public static var netupAttempted:Boolean = false;
private static var _sendChannel:LocalConnection;
private static var _clip:MovieClip;
private static var _loader:Loader;
private static var _id:String;
private static var _listenChannel:LocalConnection;
public static var widget:Boolean = false;
private static var _timer:Timer;
private static var _sendChannelName:String;
private static var _connecting:Boolean = false;
public static var onError:Object;
private static var _listenChannelName:String = "__ms_";
private static var _servicesURL:String = "http://www.mochiads.com/static/lib/services/services.swf";
public static var netup:Boolean = true;
public static function isNetworkAvailable():Boolean{
return (!((Security.sandboxType == "localWithFile")));
}
public static function get connected():Boolean{
return (_connected);
}
private static function flush(_arg1:Boolean):void{
var _local2:Object;
var _local3:Object;
if (_clip != null){
if (_clip._queue != null){
while (_clip._queue.length > 0) {
_local2 = _clip._queue.shift();
_local3 = null;
if (_local2 != null){
if (_local2.callbackID != null){
_local3 = _clip._callbacks[_local2.callbackID];
};
delete _clip._callbacks[_local2.callbackID];
if (((_arg1) && (!((_local3 == null))))){
handleError(_local2.args, _local3.callbackObject, _local3.callbackMethod);
};
};
};
};
};
}
public static function send(_arg1:String, _arg2:Object=null, _arg3:Object=null, _arg4:Object=null):void{
if (_connected){
_sendChannel.send(_sendChannelName, "onReceive", {methodName:_arg1, args:_arg2, callbackID:_clip._nextcallbackID});
} else {
if ((((_clip == null)) || (!(_connecting)))){
onError("NotConnected");
handleError(_arg2, _arg3, _arg4);
flush(true);
return;
};
_clip._queue.push({methodName:_arg1, args:_arg2, callbackID:_clip._nextcallbackID});
};
if (_clip != null){
if (((!((_clip._callbacks == null))) && (!((_clip._nextcallbackID == null))))){
_clip._callbacks[_clip._nextcallbackID] = {callbackObject:_arg3, callbackMethod:_arg4};
_clip._nextcallbackID++;
};
};
}
private static function init(_arg1:String, _arg2:Object):void{
_id = _arg1;
if (_arg2 != null){
_container = _arg2;
loadCommunicator(_arg1, _container);
};
}
public static function get childClip():Object{
return (_clip);
}
private static function clickMovie(_arg1:String, _arg2:Function):MovieClip{
var _local3:Array;
var _local4:int;
var _local5:Array;
var _local6:Array;
var _local7:MovieClip;
var _local8:LocalConnection;
var _local9:String;
var _local10:ByteArray;
var _local11:ByteArray;
var _local12:uint;
var _local13:uint;
var _local14:Loader;
_local3 = [150, 21, 0, 7, 1, 0, 0, 0, 0, 98, 116, 110, 0, 7, 2, 0, 0, 0, 0, 116, 104, 105, 115, 0, 28, 150, 22, 0, 0, 99, 114, 101, 97, 116, 101, 69, 109, 112, 116, 121, 77, 111, 118, 105, 101, 67, 108, 105, 112, 0, 82, 135, 1, 0, 0, 23, 150, 13, 0, 4, 0, 0, 111, 110, 82, 101, 108, 101, 97, 115, 101, 0, 142, 8, 0, 0, 0, 0, 2, 42, 0, 114, 0, 150, 17, 0, 0, 32, 0, 7, 1, 0, 0, 0, 8, 0, 0, 115, 112, 108, 105, 116, 0, 82, 135, 1, 0, 1, 23, 150, 7, 0, 4, 1, 7, 0, 0, 0, 0, 78, 150, 8, 0, 0, 95, 98, 108, 97, 110, 107, 0, 154, 1, 0, 0, 150, 7, 0, 0, 99, 108, 105, 99, 107, 0, 150, 7, 0, 4, 1, 7, 1, 0, 0, 0, 78, 150, 27, 0, 7, 2, 0, 0, 0, 7, 0, 0, 0, 0, 0, 76, 111, 99, 97, 108, 67, 111, 110, 110, 101, 99, 116, 105, 111, 110, 0, 64, 150, 6, 0, 0, 115, 101, 110, 100, 0, 82, 79, 150, 15, 0, 4, 0, 0, 95, 97, 108, 112, 104, 97, 0, 7, 0, 0, 0, 0, 79, 150, 23, 0, 7, 0xFF, 0, 0xFF, 0, 7, 1, 0, 0, 0, 4, 0, 0, 98, 101, 103, 105, 110, 70, 105, 108, 108, 0, 82, 23, 150, 25, 0, 7, 0, 0, 0, 0, 7, 0, 0, 0, 0, 7, 2, 0, 0, 0, 4, 0, 0, 109, 111, 118, 101, 84, 111, 0, 82, 23, 150, 25, 0, 7, 100, 0, 0, 0, 7, 0, 0, 0, 0, 7, 2, 0, 0, 0, 4, 0, 0, 108, 105, 110, 101, 84, 111, 0, 82, 23, 150, 25, 0, 7, 100, 0, 0, 0, 7, 100, 0, 0, 0, 7, 2, 0, 0, 0, 4, 0, 0, 108, 105, 110, 101, 84, 111, 0, 82, 23, 150, 25, 0, 7, 0, 0, 0, 0, 7, 100, 0, 0, 0, 7, 2, 0, 0, 0, 4, 0, 0, 108, 105, 110, 101, 84, 111, 0, 82, 23, 150, 25, 0, 7, 0, 0, 0, 0, 7, 0, 0, 0, 0, 7, 2, 0, 0, 0, 4, 0, 0, 108, 105, 110, 101, 84, 111, 0, 82, 23, 150, 16, 0, 7, 0, 0, 0, 0, 4, 0, 0, 101, 110, 100, 70, 105, 108, 108, 0, 82, 23];
_local5 = [104, 0, 31, 64, 0, 7, 208, 0, 0, 12, 1, 0, 67, 2, 0xFF, 0xFF, 0xFF, 63, 3];
_local6 = [0, 64, 0, 0, 0];
_local7 = new MovieClip();
_local8 = new LocalConnection();
_local9 = ((("_click_" + Math.floor((Math.random() * 999999))) + "_") + Math.floor(new Date().getTime()));
_local8 = new LocalConnection();
_local7.lc = _local8;
_local7.click = _arg2;
_local8.client = _local7;
_local8.connect(_local9);
_local10 = new ByteArray();
_local11 = new ByteArray();
_local11.endian = Endian.LITTLE_ENDIAN;
_local11.writeShort(1);
_local11.writeUTFBytes(((_arg1 + " ") + _local9));
_local11.writeByte(0);
_local12 = ((_local3.length + _local11.length) + 4);
_local13 = (_local12 + 35);
_local10.endian = Endian.LITTLE_ENDIAN;
_local10.writeUTFBytes("FWS");
_local10.writeByte(8);
_local10.writeUnsignedInt(_local13);
for each (_local4 in _local5) {
_local10.writeByte(_local4);
};
_local10.writeUnsignedInt(_local12);
_local10.writeByte(136);
_local10.writeShort(_local11.length);
_local10.writeBytes(_local11);
for each (_local4 in _local3) {
_local10.writeByte(_local4);
};
for each (_local4 in _local6) {
_local10.writeByte(_local4);
};
_local14 = new Loader();
_local14.loadBytes(_local10);
_local7.addChild(_local14);
return (_local7);
}
public static function stayOnTop():void{
_container.addEventListener(Event.ENTER_FRAME, MochiServices.bringToTop, false, 0, true);
if (_clip != null){
_clip.visible = true;
};
}
public static function addLinkEvent(_arg1:String, _arg2:String, _arg3:DisplayObjectContainer, _arg4:Function=null):void{
var vars:Object;
var avm1Click:DisplayObject;
var s:String;
var i:Number;
var x:String;
var req:URLRequest;
var loader:Loader;
var setURL:Function;
var err:Function;
var complete:Function;
var url = _arg1;
var burl = _arg2;
var btn = _arg3;
var onClick = _arg4;
vars = new Object();
vars["mav"] = getVersion();
vars["swfv"] = "9";
vars["swfurl"] = btn.loaderInfo.loaderURL;
vars["fv"] = Capabilities.version;
vars["os"] = Capabilities.os;
vars["lang"] = Capabilities.language;
vars["scres"] = ((Capabilities.screenResolutionX + "x") + Capabilities.screenResolutionY);
s = "?";
i = 0;
for (x in vars) {
if (i != 0){
s = (s + "&");
};
i = (i + 1);
s = (((s + x) + "=") + escape(vars[x]));
};
req = new URLRequest("http://x.mochiads.com/linkping.swf");
loader = new Loader();
setURL = function (_arg1:String):void{
var _local2:Rectangle;
if (avm1Click){
btn.removeChild(avm1Click);
};
avm1Click = clickMovie(_arg1, onClick);
_local2 = btn.getBounds(btn);
btn.addChild(avm1Click);
avm1Click.x = _local2.x;
avm1Click.y = _local2.y;
avm1Click.scaleX = (0.01 * _local2.width);
avm1Click.scaleY = (0.01 * _local2.height);
};
err = function (_arg1:Object):void{
netup = false;
_arg1.target.removeEventListener(_arg1.type, arguments.callee);
setURL(burl);
};
complete = function (_arg1:Object):void{
_arg1.target.removeEventListener(_arg1.type, arguments.callee);
};
if (netup){
setURL((url + s));
} else {
setURL(burl);
};
if (!((netupAttempted) || (_connected))){
netupAttempted = true;
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, err);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, complete);
loader.load(req);
};
}
public static function disconnect():void{
if (((_connected) || (_connecting))){
if (_clip != null){
if (_clip.parent != null){
if ((_clip.parent is Sprite)){
Sprite(_clip.parent).removeChild(_clip);
_clip = null;
};
};
};
_connecting = (_connected = false);
flush(true);
try {
_listenChannel.close();
} catch(error:Error) {
};
};
if (_timer != null){
try {
_timer.stop();
} catch(error:Error) {
};
};
}
public static function allowDomains(_arg1:String):String{
var _local2:String;
if (Security.sandboxType != "application"){
Security.allowDomain("*");
Security.allowInsecureDomain("*");
};
if (_arg1.indexOf("http://") != -1){
_local2 = _arg1.split("/")[2].split(":")[0];
if (Security.sandboxType != "application"){
Security.allowDomain(_local2);
Security.allowInsecureDomain(_local2);
};
};
return (_local2);
}
public static function getVersion():String{
return ("3.0");
}
public static function doClose():void{
_container.removeEventListener(Event.ENTER_FRAME, MochiServices.bringToTop);
if (_clip.parent != null){
Sprite(_clip.parent).removeChild(_clip);
};
}
private static function onStatus(_arg1:StatusEvent):void{
switch (_arg1.level){
case "error":
_connected = false;
_listenChannel.connect(_listenChannelName);
break;
};
}
public static function get id():String{
return (_id);
}
private static function urlOptions(_arg1:Object):Object{
var _local2:Object;
var _local3:String;
var _local4:Array;
var _local5:Number;
var _local6:Array;
_local2 = {};
_local3 = _arg1.loaderInfo.parameters.mochiad_options;
if (_local3){
_local4 = _local3.split("&");
_local5 = 0;
while (_local5 < _local4.length) {
_local6 = _local4[_local5].split("=");
_local2[unescape(_local6[0])] = unescape(_local6[1]);
_local5++;
};
};
return (_local2);
}
public static function setContainer(_arg1:Object=null, _arg2:Boolean=true):void{
if (_arg1 != null){
if ((_arg1 is Sprite)){
_container = _arg1;
};
};
if (_arg2){
if ((_container is Sprite)){
Sprite(_container).addChild(_clip);
};
};
}
private static function handleError(_arg1:Object, _arg2:Object, _arg3:Object):void{
var args = _arg1;
var callbackObject = _arg2;
var callbackMethod = _arg3;
if (args != null){
if (args.onError != null){
args.onError.apply(null, ["NotConnected"]);
};
if (((!((args.options == null))) && (!((args.options.onError == null))))){
args.options.onError.apply(null, ["NotConnected"]);
};
};
if (callbackMethod != null){
args = {};
args.error = true;
args.errorCode = "NotConnected";
if (((!((callbackObject == null))) && ((callbackMethod is String)))){
try {
var _local5 = callbackObject;
_local5[callbackMethod](args);
} catch(error:Error) {
};
} else {
if (callbackMethod != null){
try {
callbackMethod.apply(args);
} catch(error:Error) {
};
};
};
};
}
private static function initComChannels():void{
if (!_connected){
_sendChannel.addEventListener(StatusEvent.STATUS, MochiServices.onStatus);
_sendChannel.send(_sendChannelName, "onReceive", {methodName:"handshakeDone"});
_sendChannel.send(_sendChannelName, "onReceive", {methodName:"registerGame", id:_id, clip:_container, version:getVersion(), parentURL:_container.loaderInfo.loaderURL});
_listenChannel.addEventListener(StatusEvent.STATUS, MochiServices.onStatus);
_clip.onReceive = function (_arg1:Object):void{
var cb:String;
var cblst:Object;
var method:*;
var methodName:String;
var obj:Object;
var pkg = _arg1;
cb = pkg.callbackID;
cblst = this.client._callbacks[cb];
if (!cblst){
return;
};
method = cblst.callbackMethod;
methodName = "";
obj = cblst.callbackObject;
if (((obj) && ((typeof(method) == "string")))){
methodName = method;
if (obj[method] != null){
method = obj[method];
} else {
trace((("Error: Method " + method) + " does not exist."));
};
};
if (method != undefined){
try {
method.apply(obj, pkg.args);
} catch(error:Error) {
trace(((("Error invoking callback method '" + methodName) + "': ") + error.toString()));
};
} else {
if (obj != null){
try {
obj(pkg.args);
} catch(error:Error) {
trace(("Error invoking method on object: " + error.toString()));
};
};
};
delete this.client._callbacks[cb];
};
_clip.onError = function ():void{
MochiServices.onError("IOError");
};
trace("connected!");
_connecting = false;
_connected = true;
while (_clip._queue.length > 0) {
_sendChannel.send(_sendChannelName, "onReceive", _clip._queue.shift());
};
};
}
private static function listen():void{
_listenChannel = new LocalConnection();
_listenChannel.client = _clip;
_clip.handshake = function (_arg1:Object):void{
MochiServices.comChannelName = _arg1.newChannel;
};
_listenChannel.allowDomain("*", "localhost");
_listenChannel.allowInsecureDomain("*", "localhost");
_listenChannel.connect(_listenChannelName);
trace("Waiting for MochiAds services to connect...");
}
public static function set comChannelName(_arg1:String):void{
if (_arg1 != null){
if (_arg1.length > 3){
_sendChannelName = (_arg1 + "_fromgame");
initComChannels();
};
};
}
private static function loadCommunicator(_arg1:String, _arg2:Object):MovieClip{
var clipname:String;
var f:Function;
var req:URLRequest;
var vars:URLVariables;
var id = _arg1;
var clip = _arg2;
clipname = ("_mochiservices_com_" + id);
if (_clip != null){
return (_clip);
};
if (!MochiServices.isNetworkAvailable()){
return (null);
};
if (urlOptions(clip).servicesURL != undefined){
_servicesURL = urlOptions(clip).servicesURL;
};
MochiServices.allowDomains(_servicesURL);
_clip = createEmptyMovieClip(clip, clipname, 10336, false);
_loader = new Loader();
f = function (_arg1:Object):void{
_clip._mochiad_ctr_failed = true;
trace("MochiServices could not load.");
MochiServices.disconnect();
MochiServices.onError("IOError");
};
_listenChannelName = (_listenChannelName + ((Math.floor(new Date().getTime()) + "_") + Math.floor((Math.random() * 99999))));
_loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, f);
req = new URLRequest(_servicesURL);
vars = new URLVariables();
vars.listenLC = _listenChannelName;
vars.mochiad_options = clip.loaderInfo.parameters.mochiad_options;
if (widget){
vars.widget = true;
};
req.data = vars;
listen();
_loader.load(req);
_clip.addChild(_loader);
_clip._mochiservices_com = _loader;
_sendChannel = new LocalConnection();
_clip._queue = [];
_clip._nextcallbackID = 0;
_clip._callbacks = {};
_timer = new Timer(10000, 1);
_timer.addEventListener(TimerEvent.TIMER, connectWait);
_timer.start();
return (_clip);
}
public static function get clip():Object{
return (_container);
}
public static function bringToTop(_arg1:Event):void{
var e = _arg1;
if (MochiServices.clip != null){
if (MochiServices.childClip != null){
try {
if (MochiServices.clip.numChildren > 1){
MochiServices.clip.setChildIndex(MochiServices.childClip, (MochiServices.clip.numChildren - 1));
};
} catch(errorObject:Error) {
trace("Warning: Depth sort error.");
_container.removeEventListener(Event.ENTER_FRAME, MochiServices.bringToTop);
};
};
};
}
public static function connect(_arg1:String, _arg2:Object, _arg3:Object=null):void{
var id = _arg1;
var clip = _arg2;
var onError = _arg3;
if ((clip is DisplayObject)){
if (((!(_connected)) && ((_clip == null)))){
trace("MochiServices Connecting...");
_connecting = true;
init(id, clip);
};
} else {
trace("Error, MochiServices requires a Sprite, Movieclip or instance of the stage.");
};
if (onError != null){
MochiServices.onError = onError;
} else {
if (MochiServices.onError == null){
MochiServices.onError = function (_arg1:String):void{
trace(_arg1);
};
};
};
}
public static function createEmptyMovieClip(_arg1:Object, _arg2:String, _arg3:Number, _arg4:Boolean=true):MovieClip{
var mc:MovieClip;
var parent = _arg1;
var name = _arg2;
var depth = _arg3;
var doAdd = _arg4;
mc = new MovieClip();
if (doAdd){
if (((false) && (depth))){
parent.addChildAt(mc, depth);
} else {
parent.addChild(mc);
};
};
try {
parent[name] = mc;
} catch(e:Error) {
throw (new Error("MochiServices requires a clip that is an instance of a dynamic class. If your class extends Sprite or MovieClip, you must make it dynamic."));
};
mc["_name"] = name;
return (mc);
}
public static function connectWait(_arg1:TimerEvent):void{
if (!_connected){
_clip._mochiad_ctr_failed = true;
trace("MochiServices could not load. (timeout)");
MochiServices.disconnect();
MochiServices.onError("IOError");
};
}
}
}//package mochi.as3
Section 48
//Camera3D (org.papervision3d.cameras.Camera3D)
package org.papervision3d.cameras {
import org.papervision3d.core.proto.*;
import org.papervision3d.core.math.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.geom.renderables.*;
import flash.geom.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.culling.*;
public class Camera3D extends CameraObject3D {
private var _prevZoom:Number;
private var _prevOrthoProjection:Boolean;
private var _prevHeight:Number;
private var _prevFocus:Number;
private var _prevUseProjection:Boolean;
private var _focusFix:Matrix3D;
private var _prevOrtho:Boolean;
private var _prevWidth:Number;
private var _projection:Matrix3D;
public function Camera3D(_arg1:Number=60, _arg2:Number=10, _arg3:Number=5000, _arg4:Boolean=false, _arg5:Boolean=false){
super(_arg2, 40);
_prevFocus = 0;
_prevZoom = 0;
_prevOrtho = false;
_prevUseProjection = false;
_useCulling = _arg4;
_useProjectionMatrix = _arg5;
_far = _arg3;
_focusFix = Matrix3D.IDENTITY;
}
override public function set far(_arg1:Number):void{
if (_arg1 > this.focus){
_far = _arg1;
this.update(this.viewport);
};
}
override public function projectVertices(_arg1:DisplayObject3D, _arg2:RenderSessionData):Number{
var _local3:Matrix3D;
var _local4:Array;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:Number;
var _local20:Number;
var _local21:Number;
var _local22:Number;
var _local23:Number;
var _local24:Vertex3D;
var _local25:Vertex3DInstance;
var _local26:Number;
var _local27:int;
var _local28:Number;
var _local29:Number;
var _local30:Number;
var _local31:Number;
var _local32:Number;
var _local33:Number;
if (((!(_arg1.geometry)) || (!(_arg1.geometry.vertices)))){
return (0);
};
_local3 = _arg1.view;
_local4 = _arg1.geometry.vertices;
_local5 = _local3.n11;
_local6 = _local3.n12;
_local7 = _local3.n13;
_local8 = _local3.n21;
_local9 = _local3.n22;
_local10 = _local3.n23;
_local11 = _local3.n31;
_local12 = _local3.n32;
_local13 = _local3.n33;
_local14 = _local3.n41;
_local15 = _local3.n42;
_local16 = _local3.n43;
_local27 = _local4.length;
_local28 = _arg2.camera.focus;
_local29 = (_local28 * _arg2.camera.zoom);
_local30 = (viewport.width / 2);
_local31 = (viewport.height / 2);
_local32 = _arg2.camera.far;
_local33 = (_local32 - _local28);
while ((_local24 = _local4[--_local27])) {
_local17 = _local24.x;
_local18 = _local24.y;
_local19 = _local24.z;
_local22 = ((((_local17 * _local11) + (_local18 * _local12)) + (_local19 * _local13)) + _local3.n34);
_local25 = _local24.vertex3DInstance;
if (_useProjectionMatrix){
_local23 = ((((_local17 * _local14) + (_local18 * _local15)) + (_local19 * _local16)) + _local3.n44);
_local22 = (_local22 / _local23);
if ((_local25.visible = (((_local22 > 0)) && ((_local22 < 1))))){
_local20 = (((((_local17 * _local5) + (_local18 * _local6)) + (_local19 * _local7)) + _local3.n14) / _local23);
_local21 = (((((_local17 * _local8) + (_local18 * _local9)) + (_local19 * _local10)) + _local3.n24) / _local23);
_local25.x = (_local20 * _local30);
_local25.y = (_local21 * _local31);
_local25.z = (_local22 * _local23);
};
} else {
if ((_local25.visible = ((_local28 + _local22) > 0))){
_local20 = ((((_local17 * _local5) + (_local18 * _local6)) + (_local19 * _local7)) + _local3.n14);
_local21 = ((((_local17 * _local8) + (_local18 * _local9)) + (_local19 * _local10)) + _local3.n24);
_local26 = (_local29 / (_local28 + _local22));
_local25.x = (_local20 * _local26);
_local25.y = (_local21 * _local26);
_local25.z = _local22;
};
};
};
return (0);
}
override public function transformView(_arg1:Matrix3D=null):void{
if (((((((((((!((ortho == _prevOrtho))) || (!((_prevUseProjection == _useProjectionMatrix))))) || (!((focus == _prevFocus))))) || (!((zoom == _prevZoom))))) || (!((viewport.width == _prevWidth))))) || (!((viewport.height == _prevHeight))))){
update(viewport);
};
if (_target){
lookAt(_target);
} else {
if (_transformDirty){
updateTransform();
};
};
if (_useProjectionMatrix){
super.transformView();
this.eye.calculateMultiply4x4(_projection, this.eye);
} else {
_focusFix.copy(this.transform);
_focusFix.n14 = (_focusFix.n14 + (focus * this.transform.n13));
_focusFix.n24 = (_focusFix.n24 + (focus * this.transform.n23));
_focusFix.n34 = (_focusFix.n34 + (focus * this.transform.n33));
super.transformView(_focusFix);
};
if ((culler is FrustumCuller)){
FrustumCuller(culler).transform.copy(this.transform);
};
}
override public function orbit(_arg1:Number, _arg2:Number, _arg3:Boolean=true, _arg4:DisplayObject3D=null):void{
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
_arg4 = ((_arg4) || (_target));
_arg4 = ((_arg4) || (DisplayObject3D.ZERO));
if (_arg3){
_arg1 = (_arg1 * (Math.PI / 180));
_arg2 = (_arg2 * (Math.PI / 180));
};
_local5 = (_arg4.world.n14 - this.x);
_local6 = (_arg4.world.n24 - this.y);
_local7 = (_arg4.world.n34 - this.z);
_local8 = Math.sqrt((((_local5 * _local5) + (_local6 * _local6)) + (_local7 * _local7)));
_local9 = (Math.cos(_arg2) * Math.sin(_arg1));
_local10 = (Math.sin(_arg2) * Math.sin(_arg1));
_local11 = Math.cos(_arg1);
this.x = (_arg4.world.n14 + (_local9 * _local8));
this.y = (_arg4.world.n24 + (_local11 * _local8));
this.z = (_arg4.world.n34 + (_local10 * _local8));
this.lookAt(_arg4);
}
override public function set near(_arg1:Number):void{
if (_arg1 > 0){
this.focus = _arg1;
this.update(this.viewport);
};
}
public function update(_arg1:Rectangle):void{
if (!_arg1){
throw (new Error(("Camera3D#update: Invalid viewport rectangle! " + _arg1)));
};
this.viewport = _arg1;
_prevFocus = this.focus;
_prevZoom = this.zoom;
_prevWidth = this.viewport.width;
_prevHeight = this.viewport.height;
if (_prevOrtho != this.ortho){
if (this.ortho){
_prevOrthoProjection = this.useProjectionMatrix;
this.useProjectionMatrix = true;
} else {
this.useProjectionMatrix = _prevOrthoProjection;
};
} else {
if (_prevUseProjection != _useProjectionMatrix){
this.useProjectionMatrix = this._useProjectionMatrix;
};
};
_prevOrtho = this.ortho;
_prevUseProjection = _useProjectionMatrix;
this.useCulling = _useCulling;
}
override public function set orthoScale(_arg1:Number):void{
super.orthoScale = _arg1;
this.useProjectionMatrix = this.useProjectionMatrix;
_prevOrtho = !(this.ortho);
this.update(this.viewport);
}
override public function set useProjectionMatrix(_arg1:Boolean):void{
var _local2:Number;
var _local3:Number;
if (_arg1){
if (this.ortho){
_local2 = (viewport.width / 2);
_local3 = (viewport.height / 2);
_projection = createOrthoMatrix(-(_local2), _local2, -(_local3), _local3, -(_far), _far);
_projection = Matrix3D.multiply(_orthoScaleMatrix, _projection);
} else {
_projection = createPerspectiveMatrix(fov, (viewport.width / viewport.height), this.focus, this.far);
};
} else {
if (this.ortho){
_arg1 = true;
};
};
super.useProjectionMatrix = _arg1;
}
override public function set useCulling(_arg1:Boolean):void{
super.useCulling = _arg1;
if (_useCulling){
if (!this.culler){
this.culler = new FrustumCuller();
};
FrustumCuller(this.culler).initialize(this.fov, (this.viewport.width / this.viewport.height), (this.focus / this.zoom), _far);
} else {
this.culler = null;
};
}
public static function createPerspectiveMatrix(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Matrix3D{
var _local5:Number;
var _local6:Number;
var _local7:Number;
_local5 = ((_arg1 / 2) * (Math.PI / 180));
_local6 = Math.tan(_local5);
_local7 = (1 / _local6);
return (new Matrix3D([(_local7 / _arg2), 0, 0, 0, 0, _local7, 0, 0, 0, 0, -(((_arg3 + _arg4) / (_arg3 - _arg4))), (((2 * _arg4) * _arg3) / (_arg3 - _arg4)), 0, 0, 1, 0]));
}
public static function createOrthoMatrix(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:Number):Matrix3D{
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Matrix3D;
_local7 = ((_arg2 + _arg1) / (_arg2 - _arg1));
_local8 = ((_arg4 + _arg3) / (_arg4 - _arg3));
_local9 = ((_arg6 + _arg5) / (_arg6 - _arg5));
_local10 = new Matrix3D([(2 / (_arg2 - _arg1)), 0, 0, _local7, 0, (2 / (_arg4 - _arg3)), 0, _local8, 0, 0, (-2 / (_arg6 - _arg5)), _local9, 0, 0, 0, 1]);
_local10.calculateMultiply(Matrix3D.scaleMatrix(1, 1, -1), _local10);
return (_local10);
}
}
}//package org.papervision3d.cameras
Section 49
//CameraType (org.papervision3d.cameras.CameraType)
package org.papervision3d.cameras {
public class CameraType {
public static var TARGET:String = "Target";
public static var DEBUG:String = "Debug";
public static var FREE:String = "Free";
}
}//package org.papervision3d.cameras
Section 50
//DebugCamera3D (org.papervision3d.cameras.DebugCamera3D)
package org.papervision3d.cameras {
import flash.display.*;
import flash.events.*;
import org.papervision3d.view.*;
import flash.geom.*;
import flash.text.*;
import flash.ui.*;
public class DebugCamera3D extends Camera3D {
protected var targetRotationX:Number;// = 0
protected var targetRotationY:Number;// = 0
protected var startRotationY:Number;
protected var startPoint:Point;
protected var startRotationX:Number;
protected var rotationYText:TextField;
protected var forwardFactor:Number;// = 0
protected var zText:TextField;
protected var rotationXText:TextField;
protected var farText:TextField;
protected var keyRight:Boolean;// = false
protected var keyLeft:Boolean;// = false
protected var yText:TextField;
protected var keyForward:Boolean;// = false
protected var keyBackward:Boolean;// = false
protected var nearText:TextField;
protected var _inertia:Number;// = 3
protected var _propertiesDisplay:Sprite;
protected var sideFactor:Number;// = 0
protected var viewport3D:Viewport3D;
protected var fovText:TextField;
protected var xText:TextField;
protected var rotationZText:TextField;
protected var viewportStage:Stage;
public function DebugCamera3D(_arg1:Viewport3D, _arg2:Number=90, _arg3:Number=10, _arg4:Number=5000){
_inertia = 3;
targetRotationY = 0;
targetRotationX = 0;
keyRight = false;
keyLeft = false;
keyForward = false;
keyBackward = false;
forwardFactor = 0;
sideFactor = 0;
super(_arg2, _arg3, _arg4, true);
this.viewport3D = _arg1;
this.viewport = _arg1.sizeRectangle;
this.focus = ((this.viewport.height / 2) / Math.tan(((_arg2 / 2) * (Math.PI / 180))));
this.zoom = (this.focus / _arg3);
this.focus = _arg3;
this.far = _arg4;
displayProperties();
checkStageReady();
}
protected function onEnterFrameHandler(_arg1:Event):void{
var _local2:Number;
var _local3:Number;
if (keyForward){
forwardFactor = (forwardFactor + 50);
};
if (keyBackward){
forwardFactor = (forwardFactor + -50);
};
if (keyLeft){
sideFactor = (sideFactor + -50);
};
if (keyRight){
sideFactor = (sideFactor + 50);
};
_local2 = (this.rotationX + ((targetRotationX - this.rotationX) / _inertia));
_local3 = (this.rotationY + ((targetRotationY - this.rotationY) / _inertia));
this.rotationX = (Math.round((_local2 * 10)) / 10);
this.rotationY = (Math.round((_local3 * 10)) / 10);
forwardFactor = (forwardFactor + ((0 - forwardFactor) / _inertia));
sideFactor = (sideFactor + ((0 - sideFactor) / _inertia));
if (forwardFactor > 0){
this.moveForward(forwardFactor);
} else {
this.moveBackward(-(forwardFactor));
};
if (sideFactor > 0){
this.moveRight(sideFactor);
} else {
this.moveLeft(-(sideFactor));
};
xText.text = ("x:" + int(x));
yText.text = ("y:" + int(y));
zText.text = ("z:" + int(z));
rotationXText.text = ("rotationX:" + int(_local2));
rotationYText.text = ("rotationY:" + int(_local3));
rotationZText.text = ("rotationZ:" + int(rotationZ));
fovText.text = ("fov:" + Math.round(fov));
nearText.text = ("near:" + Math.round(near));
farText.text = ("far:" + Math.round(far));
}
protected function mouseMoveHandler(_arg1:MouseEvent):void{
targetRotationY = (startRotationY - ((startPoint.x - viewportStage.mouseX) / 2));
targetRotationX = (startRotationX + ((startPoint.y - viewportStage.mouseY) / 2));
}
protected function mouseDownHandler(_arg1:MouseEvent):void{
viewportStage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
startPoint = new Point(viewportStage.mouseX, viewportStage.mouseY);
startRotationY = this.rotationY;
startRotationX = this.rotationX;
}
protected function keyDownHandler(_arg1:KeyboardEvent):void{
switch (_arg1.keyCode){
case "W".charCodeAt():
case Keyboard.UP:
keyForward = true;
keyBackward = false;
break;
case "S".charCodeAt():
case Keyboard.DOWN:
keyBackward = true;
keyForward = false;
break;
case "A".charCodeAt():
case Keyboard.LEFT:
keyLeft = true;
keyRight = false;
break;
case "D".charCodeAt():
case Keyboard.RIGHT:
keyRight = true;
keyLeft = false;
break;
case "Q".charCodeAt():
rotationZ--;
break;
case "E".charCodeAt():
rotationZ++;
break;
case "F".charCodeAt():
fov--;
break;
case "R".charCodeAt():
fov++;
break;
case "G".charCodeAt():
near = (near - 10);
break;
case "T".charCodeAt():
near = (near + 10);
break;
case "H".charCodeAt():
far = (far - 10);
break;
case "Y".charCodeAt():
far = (far + 10);
break;
};
}
private function checkStageReady():void{
if (viewport3D.containerSprite.stage == null){
viewport3D.containerSprite.addEventListener(Event.ADDED_TO_STAGE, onAddedToStageHandler);
} else {
setupEvents();
};
}
public function set propsDisplay(_arg1:Sprite):void{
_propertiesDisplay = _arg1;
}
protected function keyUpHandler(_arg1:KeyboardEvent):void{
switch (_arg1.keyCode){
case "W".charCodeAt():
case Keyboard.UP:
keyForward = false;
break;
case "S".charCodeAt():
case Keyboard.DOWN:
keyBackward = false;
break;
case "A".charCodeAt():
case Keyboard.LEFT:
keyLeft = false;
break;
case "D".charCodeAt():
case Keyboard.RIGHT:
keyRight = false;
break;
};
}
public function get inertia():Number{
return (_inertia);
}
protected function mouseUpHandler(_arg1:MouseEvent):void{
viewportStage.removeEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
}
public function get propsDisplay():Sprite{
return (_propertiesDisplay);
}
protected function onAddedToStageHandler(_arg1:Event):void{
setupEvents();
}
public function set inertia(_arg1:Number):void{
_inertia = _arg1;
}
protected function displayProperties():void{
var _local1:TextFormat;
var _local2:Array;
var _local3:int;
var _local4:Number;
_propertiesDisplay = new Sprite();
_propertiesDisplay.graphics.beginFill(0);
_propertiesDisplay.graphics.drawRect(0, 0, 100, 100);
_propertiesDisplay.graphics.endFill();
_propertiesDisplay.x = 0;
_propertiesDisplay.y = 0;
_local1 = new TextFormat("_sans", 9);
xText = new TextField();
yText = new TextField();
zText = new TextField();
rotationXText = new TextField();
rotationYText = new TextField();
rotationZText = new TextField();
fovText = new TextField();
nearText = new TextField();
farText = new TextField();
_local2 = [xText, yText, zText, rotationXText, rotationYText, rotationZText, fovText, nearText, farText];
_local3 = 10;
_local4 = 0;
while (_local4 < _local2.length) {
_local2[_local4].width = 100;
_local2[_local4].selectable = false;
_local2[_local4].textColor = 0xFFFF00;
_local2[_local4].text = "";
_local2[_local4].defaultTextFormat = _local1;
_local2[_local4].y = (_local3 * _local4);
_propertiesDisplay.addChild(_local2[_local4]);
_local4++;
};
viewport3D.addChild(_propertiesDisplay);
}
protected function setupEvents():void{
viewportStage = viewport3D.containerSprite.stage;
viewportStage.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
viewportStage.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
viewportStage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
viewportStage.addEventListener(KeyboardEvent.KEY_UP, keyUpHandler);
viewportStage.addEventListener(Event.ENTER_FRAME, onEnterFrameHandler);
}
}
}//package org.papervision3d.cameras
Section 51
//SpringCamera3D (org.papervision3d.cameras.SpringCamera3D)
package org.papervision3d.cameras {
import org.papervision3d.core.math.*;
import org.papervision3d.objects.*;
public class SpringCamera3D extends Camera3D {
public var lookOffset:Number3D;
private var _velocity:Number3D;
private var _xPosition:Number3D;
private var _acceleration:Number3D;
private var _lookAtPosition:Number3D;
private var _targetTransform:Matrix3D;
public var _camTarget:DisplayObject3D;
private var _xLookOffset:Number3D;
public var damping:Number;// = 4
public var positionOffset:Number3D;
public var mass:Number;// = 40
private var _dv:Number3D;
public var stiffness:Number;// = 1
private var _xPositionOffset:Number3D;
private var _desiredPosition:Number3D;
private var _xLookAtObject:DisplayObject3D;
private var _stretch:Number3D;
private var _force:Number3D;
private var _zrot:Number;// = 0
public function SpringCamera3D(_arg1:Number=60, _arg2:Number=10, _arg3:Number=5000, _arg4:Boolean=false, _arg5:Boolean=false){
stiffness = 1;
damping = 4;
mass = 40;
positionOffset = new Number3D(0, 5, -50);
lookOffset = new Number3D(0, 2, 10);
_zrot = 0;
_velocity = new Number3D();
_dv = new Number3D();
_stretch = new Number3D();
_force = new Number3D();
_acceleration = new Number3D();
_desiredPosition = new Number3D();
_lookAtPosition = new Number3D();
_targetTransform = new Matrix3D();
_xPositionOffset = new Number3D();
_xLookOffset = new Number3D();
_xPosition = new Number3D();
_xLookAtObject = new DisplayObject3D();
super(_arg1, _arg2, _arg3, _arg4, _arg5);
}
override public function transformView(_arg1:Matrix3D=null):void{
if (_camTarget != null){
_targetTransform.n31 = _camTarget.transform.n31;
_targetTransform.n32 = _camTarget.transform.n32;
_targetTransform.n33 = _camTarget.transform.n33;
_targetTransform.n21 = _camTarget.transform.n21;
_targetTransform.n22 = _camTarget.transform.n22;
_targetTransform.n23 = _camTarget.transform.n23;
_targetTransform.n11 = _camTarget.transform.n11;
_targetTransform.n12 = _camTarget.transform.n12;
_targetTransform.n13 = _camTarget.transform.n13;
_xPositionOffset.x = positionOffset.x;
_xPositionOffset.y = positionOffset.y;
_xPositionOffset.z = positionOffset.z;
Matrix3D.multiplyVector(_targetTransform, _xPositionOffset);
_xLookOffset.x = lookOffset.x;
_xLookOffset.y = lookOffset.y;
_xLookOffset.z = lookOffset.z;
Matrix3D.multiplyVector(_targetTransform, _xLookOffset);
_desiredPosition.x = (_camTarget.x + _xPositionOffset.x);
_desiredPosition.y = (_camTarget.y + _xPositionOffset.y);
_desiredPosition.z = (_camTarget.z + _xPositionOffset.z);
_lookAtPosition.x = (_camTarget.x + _xLookOffset.x);
_lookAtPosition.y = (_camTarget.y + _xLookOffset.y);
_lookAtPosition.z = (_camTarget.z + _xLookOffset.z);
_stretch.x = ((x - _desiredPosition.x) * -(stiffness));
_stretch.y = ((y - _desiredPosition.y) * -(stiffness));
_stretch.z = ((z - _desiredPosition.z) * -(stiffness));
_dv.x = (_velocity.x * damping);
_dv.y = (_velocity.y * damping);
_dv.z = (_velocity.z * damping);
_force.x = (_stretch.x - _dv.x);
_force.y = (_stretch.y - _dv.y);
_force.z = (_stretch.z - _dv.z);
_acceleration.x = (_force.x * (1 / mass));
_acceleration.y = (_force.y * (1 / mass));
_acceleration.z = (_force.z * (1 / mass));
_velocity.plusEq(_acceleration);
_xPosition.x = (x + _velocity.x);
_xPosition.y = (y + _velocity.y);
_xPosition.z = (z + _velocity.z);
x = _xPosition.x;
y = _xPosition.y;
z = _xPosition.z;
_xLookAtObject.x = _lookAtPosition.x;
_xLookAtObject.y = _lookAtPosition.y;
_xLookAtObject.z = _lookAtPosition.z;
lookAt(_xLookAtObject);
if (Math.abs(_zrot) > 0){
this.rotationZ = _zrot;
};
};
return (super.transformView(_arg1));
}
public function set zrot(_arg1:Number):void{
_zrot = _arg1;
if (_zrot < 0.001){
_arg1 = 0;
};
}
public function get zrot():Number{
return (_zrot);
}
override public function set target(_arg1:DisplayObject3D):void{
_camTarget = _arg1;
}
override public function get target():DisplayObject3D{
return (_camTarget);
}
}
}//package org.papervision3d.cameras
Section 52
//DefaultLineCuller (org.papervision3d.core.culling.DefaultLineCuller)
package org.papervision3d.core.culling {
import org.papervision3d.core.geom.renderables.*;
public class DefaultLineCuller implements ILineCuller {
public function testLine(_arg1:Line3D):Boolean{
return (((_arg1.v0.vertex3DInstance.visible) && (_arg1.v1.vertex3DInstance.visible)));
}
}
}//package org.papervision3d.core.culling
Section 53
//DefaultParticleCuller (org.papervision3d.core.culling.DefaultParticleCuller)
package org.papervision3d.core.culling {
import org.papervision3d.core.geom.renderables.*;
public class DefaultParticleCuller implements IParticleCuller {
public function testParticle(_arg1:Particle):Boolean{
if (_arg1.material.invisible == false){
if (_arg1.vertex3D.vertex3DInstance.visible == true){
return (true);
};
};
return (false);
}
}
}//package org.papervision3d.core.culling
Section 54
//DefaultTriangleCuller (org.papervision3d.core.culling.DefaultTriangleCuller)
package org.papervision3d.core.culling {
import org.papervision3d.core.proto.*;
import org.papervision3d.core.geom.renderables.*;
public class DefaultTriangleCuller implements ITriangleCuller {
protected static var y2:Number;
protected static var y1:Number;
protected static var y0:Number;
protected static var x0:Number;
protected static var x1:Number;
protected static var x2:Number;
public function testFace(_arg1:Triangle3D, _arg2:Vertex3DInstance, _arg3:Vertex3DInstance, _arg4:Vertex3DInstance):Boolean{
var _local5:MaterialObject3D;
if (((((_arg2.visible) && (_arg3.visible))) && (_arg4.visible))){
_local5 = (_arg1.material) ? _arg1.material : _arg1.instance.material;
if (_local5.invisible){
return (false);
};
x0 = _arg2.x;
y0 = _arg2.y;
x1 = _arg3.x;
y1 = _arg3.y;
x2 = _arg4.x;
y2 = _arg4.y;
if (_local5.oneSide){
if (_local5.opposite){
if ((((x2 - x0) * (y1 - y0)) - ((y2 - y0) * (x1 - x0))) > 0){
return (false);
};
} else {
if ((((x2 - x0) * (y1 - y0)) - ((y2 - y0) * (x1 - x0))) < 0){
return (false);
};
};
};
return (true);
};
return (false);
}
}
}//package org.papervision3d.core.culling
Section 55
//FrustumCuller (org.papervision3d.core.culling.FrustumCuller)
package org.papervision3d.core.culling {
import org.papervision3d.core.math.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.objects.*;
public class FrustumCuller implements IObjectCuller {
private var _tang:Number;
private var _ratio:Number;
private var _near:Number;
private var _fov:Number;
private var _far:Number;
private var _nh:Number;
private var _fh:Number;
public var transform:Matrix3D;
private var _sphereY:Number;
private var _nw:Number;
private var _sphereX:Number;
private var _fw:Number;
public static const OUTSIDE:int = -1;
public static const INSIDE:int = 1;
public static const INTERSECT:int = 0;
public function FrustumCuller(){
this.transform = Matrix3D.IDENTITY;
this.initialize();
}
public function get ratio():Number{
return (_ratio);
}
public function pointInFrustum(_arg1:Number, _arg2:Number, _arg3:Number):int{
var _local4:Matrix3D;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
_local4 = this.transform;
_local5 = (_arg1 - _local4.n14);
_local6 = (_arg2 - _local4.n24);
_local7 = (_arg3 - _local4.n34);
_local8 = (((_local5 * _local4.n13) + (_local6 * _local4.n23)) + (_local7 * _local4.n33));
if ((((_local8 > _far)) || ((_local8 < _near)))){
return (OUTSIDE);
};
_local9 = (((_local5 * _local4.n12) + (_local6 * _local4.n22)) + (_local7 * _local4.n32));
_local10 = (_local8 * _tang);
if ((((_local9 > _local10)) || ((_local9 < -(_local10))))){
return (OUTSIDE);
};
_local11 = (((_local5 * _local4.n11) + (_local6 * _local4.n21)) + (_local7 * _local4.n31));
_local10 = (_local10 * _ratio);
if ((((_local11 > _local10)) || ((_local11 < -(_local10))))){
return (OUTSIDE);
};
return (INSIDE);
}
public function initialize(_arg1:Number=60, _arg2:Number=1.333, _arg3:Number=1, _arg4:Number=5000):void{
var _local5:Number;
var _local6:Number;
_fov = _arg1;
_ratio = _arg2;
_near = _arg3;
_far = _arg4;
_local5 = (((Math.PI / 180) * _fov) * 0.5);
_tang = Math.tan(_local5);
_nh = (_near * _tang);
_nw = (_nh * _ratio);
_fh = (_far * _tang);
_fw = (_fh * _ratio);
_local6 = Math.atan((_tang * _ratio));
_sphereX = (1 / Math.cos(_local6));
_sphereY = (1 / Math.cos(_local5));
}
public function get fov():Number{
return (_fov);
}
public function set ratio(_arg1:Number):void{
this.initialize(_fov, _arg1, _near, _far);
}
public function get far():Number{
return (_far);
}
public function set fov(_arg1:Number):void{
this.initialize(_arg1, _ratio, _near, _far);
}
public function get near():Number{
return (_near);
}
public function set far(_arg1:Number):void{
this.initialize(_fov, _ratio, _near, _arg1);
}
public function set near(_arg1:Number):void{
this.initialize(_fov, _ratio, _arg1, _far);
}
public function sphereInFrustum(_arg1:DisplayObject3D, _arg2:BoundingSphere):int{
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:int;
var _local9:Matrix3D;
var _local10:Number;
var _local11:Number;
var _local12:Number;
_local3 = _arg2.radius;
_local8 = INSIDE;
_local9 = this.transform;
_local10 = (_arg1.world.n14 - _local9.n14);
_local11 = (_arg1.world.n24 - _local9.n24);
_local12 = (_arg1.world.n34 - _local9.n34);
_local7 = (((_local10 * _local9.n13) + (_local11 * _local9.n23)) + (_local12 * _local9.n33));
if ((((_local7 > (_far + _local3))) || ((_local7 < (_near - _local3))))){
return (OUTSIDE);
};
if ((((_local7 > (_far - _local3))) || ((_local7 < (_near + _local3))))){
_local8 = INTERSECT;
};
_local6 = (((_local10 * _local9.n12) + (_local11 * _local9.n22)) + (_local12 * _local9.n32));
_local4 = (_sphereY * _local3);
_local7 = (_local7 * _tang);
if ((((_local6 > (_local7 + _local4))) || ((_local6 < (-(_local7) - _local4))))){
return (OUTSIDE);
};
if ((((_local6 > (_local7 - _local4))) || ((_local6 < (-(_local7) + _local4))))){
_local8 = INTERSECT;
};
_local5 = (((_local10 * _local9.n11) + (_local11 * _local9.n21)) + (_local12 * _local9.n31));
_local7 = (_local7 * _ratio);
_local4 = (_sphereX * _local3);
if ((((_local5 > (_local7 + _local4))) || ((_local5 < (-(_local7) - _local4))))){
return (OUTSIDE);
};
if ((((_local5 > (_local7 - _local4))) || ((_local5 < (-(_local7) + _local4))))){
_local8 = INTERSECT;
};
return (_local8);
}
public function testObject(_arg1:DisplayObject3D):int{
var _local2:int;
_local2 = INSIDE;
if (((((!(_arg1.geometry)) || (!(_arg1.geometry.vertices)))) || (!(_arg1.geometry.vertices.length)))){
return (_local2);
};
switch (_arg1.frustumTestMethod){
case FrustumTestMethod.BOUNDING_SPHERE:
_local2 = sphereInFrustum(_arg1, _arg1.geometry.boundingSphere);
break;
case FrustumTestMethod.BOUNDING_BOX:
_local2 = aabbInFrustum(_arg1, _arg1.geometry.aabb);
break;
case FrustumTestMethod.NO_TESTING:
break;
default:
break;
};
return (_local2);
}
public function aabbInFrustum(_arg1:DisplayObject3D, _arg2:AxisAlignedBoundingBox, _arg3:Boolean=true):int{
var _local4:Vertex3D;
var _local5:Number3D;
var _local6:int;
var _local7:int;
var _local8:Array;
_local6 = 0;
_local7 = 0;
_local8 = _arg2.getBoxVertices();
for each (_local4 in _local8) {
_local5 = _local4.toNumber3D();
Matrix3D.multiplyVector(_arg1.world, _local5);
if (pointInFrustum(_local5.x, _local5.y, _local5.z) == INSIDE){
_local6++;
if (_arg3){
return (INSIDE);
};
} else {
_local7++;
};
if (((_local6) && (_local7))){
return (INTERSECT);
};
};
if (_local6){
return (((_local6 < 8)) ? INTERSECT : INSIDE);
//unresolved jump
};
return (OUTSIDE);
}
}
}//package org.papervision3d.core.culling
Section 56
//FrustumTestMethod (org.papervision3d.core.culling.FrustumTestMethod)
package org.papervision3d.core.culling {
public class FrustumTestMethod {
public static const BOUNDING_BOX:int = 1;
public static const NO_TESTING:int = -1;
public static const BOUNDING_SPHERE:int = 0;
}
}//package org.papervision3d.core.culling
Section 57
//ILineCuller (org.papervision3d.core.culling.ILineCuller)
package org.papervision3d.core.culling {
import org.papervision3d.core.geom.renderables.*;
public interface ILineCuller {
function testLine(_arg1:Line3D):Boolean;
}
}//package org.papervision3d.core.culling
Section 58
//IObjectCuller (org.papervision3d.core.culling.IObjectCuller)
package org.papervision3d.core.culling {
import org.papervision3d.objects.*;
public interface IObjectCuller {
function testObject(_arg1:DisplayObject3D):int;
}
}//package org.papervision3d.core.culling
Section 59
//IParticleCuller (org.papervision3d.core.culling.IParticleCuller)
package org.papervision3d.core.culling {
import org.papervision3d.core.geom.renderables.*;
public interface IParticleCuller {
function testParticle(_arg1:Particle):Boolean;
}
}//package org.papervision3d.core.culling
Section 60
//ITriangleCuller (org.papervision3d.core.culling.ITriangleCuller)
package org.papervision3d.core.culling {
import org.papervision3d.core.geom.renderables.*;
public interface ITriangleCuller {
function testFace(_arg1:Triangle3D, _arg2:Vertex3DInstance, _arg3:Vertex3DInstance, _arg4:Vertex3DInstance):Boolean;
}
}//package org.papervision3d.core.culling
Section 61
//RectangleLineCuller (org.papervision3d.core.culling.RectangleLineCuller)
package org.papervision3d.core.culling {
import org.papervision3d.core.geom.renderables.*;
import flash.geom.*;
import org.papervision3d.core.math.util.*;
public class RectangleLineCuller implements ILineCuller {
private var rectIntersection:Rectangle;
private var lineBoundsRect:Rectangle;
private var cullingRectangle:Rectangle;
public function RectangleLineCuller(_arg1:Rectangle=null):void{
if (_arg1){
this.cullingRectangle = _arg1;
};
lineBoundsRect = new Rectangle();
rectIntersection = new Rectangle();
}
public function testLine(_arg1:Line3D):Boolean{
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
if (((!(_arg1.v0.vertex3DInstance.visible)) || (!(_arg1.v1.vertex3DInstance.visible)))){
return (false);
};
_local2 = _arg1.v0.vertex3DInstance.x;
_local3 = _arg1.v0.vertex3DInstance.y;
_local4 = _arg1.v1.vertex3DInstance.x;
_local5 = _arg1.v1.vertex3DInstance.y;
lineBoundsRect.width = Math.abs((_local4 - _local2));
lineBoundsRect.height = Math.abs((_local5 - _local3));
if (_local2 < _local4){
lineBoundsRect.x = _local2;
} else {
lineBoundsRect.x = _local4;
};
if (_local3 < _local5){
lineBoundsRect.y = _local3;
} else {
lineBoundsRect.y = _local5;
};
if (cullingRectangle.containsRect(lineBoundsRect)){
return (true);
};
if (!FastRectangleTools.intersects(lineBoundsRect, cullingRectangle)){
return (false);
};
rectIntersection = FastRectangleTools.intersection(lineBoundsRect, cullingRectangle);
_local6 = ((_local5 - _local3) / (_local4 - _local2));
_local7 = (_local3 - (_local6 * _local2));
_local8 = ((cullingRectangle.top - _local7) / _local6);
if ((((_local8 > rectIntersection.left)) && ((_local8 < rectIntersection.right)))){
return (true);
};
_local8 = ((cullingRectangle.bottom - _local7) / _local6);
if ((((_local8 > rectIntersection.left)) && ((_local8 < rectIntersection.right)))){
return (true);
};
_local9 = ((_local6 * cullingRectangle.left) + _local7);
if ((((_local9 > rectIntersection.top)) && ((_local9 < rectIntersection.bottom)))){
return (true);
};
_local9 = ((_local6 * cullingRectangle.right) + _local7);
if ((((_local9 > rectIntersection.top)) && ((_local9 < rectIntersection.bottom)))){
return (true);
};
return (false);
}
}
}//package org.papervision3d.core.culling
Section 62
//RectangleParticleCuller (org.papervision3d.core.culling.RectangleParticleCuller)
package org.papervision3d.core.culling {
import org.papervision3d.core.geom.renderables.*;
import flash.geom.*;
import org.papervision3d.core.math.util.*;
public class RectangleParticleCuller implements IParticleCuller {
public var cullingRectangle:Rectangle;
private static var vInstance:Vertex3DInstance;
private static var testPoint:Point;
public function RectangleParticleCuller(_arg1:Rectangle=null){
this.cullingRectangle = _arg1;
testPoint = new Point();
}
public function testParticle(_arg1:Particle):Boolean{
vInstance = _arg1.vertex3D.vertex3DInstance;
if (_arg1.material.invisible == false){
if (vInstance.visible){
if (FastRectangleTools.intersects(_arg1.renderRect, cullingRectangle)){
return (true);
};
};
};
return (false);
}
}
}//package org.papervision3d.core.culling
Section 63
//RectangleTriangleCuller (org.papervision3d.core.culling.RectangleTriangleCuller)
package org.papervision3d.core.culling {
import org.papervision3d.core.geom.renderables.*;
import flash.geom.*;
import org.papervision3d.core.math.util.*;
public class RectangleTriangleCuller extends DefaultTriangleCuller implements ITriangleCuller {
public var cullingRectangle:Rectangle;
private static const DEFAULT_RECT_X:Number = -((DEFAULT_RECT_W / 2));
private static const DEFAULT_RECT_W:Number = 640;
private static const DEFAULT_RECT_H:Number = 480;
private static const DEFAULT_RECT_Y:Number = -((DEFAULT_RECT_H / 2));
private static var hitRect:Rectangle = new Rectangle();
public function RectangleTriangleCuller(_arg1:Rectangle=null):void{
cullingRectangle = new Rectangle(DEFAULT_RECT_X, DEFAULT_RECT_Y, DEFAULT_RECT_W, DEFAULT_RECT_H);
super();
if (_arg1){
this.cullingRectangle = _arg1;
};
}
override public function testFace(_arg1:Triangle3D, _arg2:Vertex3DInstance, _arg3:Vertex3DInstance, _arg4:Vertex3DInstance):Boolean{
if (super.testFace(_arg1, _arg2, _arg3, _arg4)){
hitRect.x = Math.min(_arg4.x, Math.min(_arg3.x, _arg2.x));
hitRect.width = (Math.max(_arg4.x, Math.max(_arg3.x, _arg2.x)) + Math.abs(hitRect.x));
hitRect.y = Math.min(_arg4.y, Math.min(_arg3.y, _arg2.y));
hitRect.height = (Math.max(_arg4.y, Math.max(_arg3.y, _arg2.y)) + Math.abs(hitRect.y));
return (FastRectangleTools.intersects(cullingRectangle, hitRect));
};
return (false);
}
}
}//package org.papervision3d.core.culling
Section 64
//ViewportObjectFilter (org.papervision3d.core.culling.ViewportObjectFilter)
package org.papervision3d.core.culling {
import org.papervision3d.objects.*;
import flash.utils.*;
public class ViewportObjectFilter implements IObjectCuller {
protected var _mode:int;
protected var objects:Dictionary;
public function ViewportObjectFilter(_arg1:int):void{
this.mode = _arg1;
init();
}
public function addObject(_arg1:DisplayObject3D):void{
objects[_arg1] = _arg1;
}
public function removeObject(_arg1:DisplayObject3D):void{
delete objects[_arg1];
}
public function set mode(_arg1:int):void{
_mode = _arg1;
}
public function get mode():int{
return (_mode);
}
private function init():void{
objects = new Dictionary(true);
}
public function testObject(_arg1:DisplayObject3D):int{
if (objects[_arg1]){
if (_mode == ViewportObjectFilterMode.INCLUSIVE){
return (1);
};
if (_mode == ViewportObjectFilterMode.EXCLUSIVE){
return (0);
};
} else {
if (_mode == ViewportObjectFilterMode.INCLUSIVE){
return (0);
};
if (_mode == ViewportObjectFilterMode.EXCLUSIVE){
return (1);
};
};
return (0);
}
public function destroy():void{
objects = null;
}
}
}//package org.papervision3d.core.culling
Section 65
//ViewportObjectFilterMode (org.papervision3d.core.culling.ViewportObjectFilterMode)
package org.papervision3d.core.culling {
public class ViewportObjectFilterMode {
public static const INCLUSIVE:int = 0;
public static const EXCLUSIVE:int = 1;
}
}//package org.papervision3d.core.culling
Section 66
//UserData (org.papervision3d.core.data.UserData)
package org.papervision3d.core.data {
public class UserData {
public var data;
public function UserData(_arg1=null){
this.data = _arg1;
}
}
}//package org.papervision3d.core.data
Section 67
//AbstractRenderable (org.papervision3d.core.geom.renderables.AbstractRenderable)
package org.papervision3d.core.geom.renderables {
import org.papervision3d.core.render.command.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.data.*;
public class AbstractRenderable implements IRenderable {
public var _userData:UserData;
public var instance:DisplayObject3D;
public function getRenderListItem():IRenderListItem{
return (null);
}
public function set userData(_arg1:UserData):void{
_userData = _arg1;
}
public function get userData():UserData{
return (_userData);
}
}
}//package org.papervision3d.core.geom.renderables
Section 68
//IRenderable (org.papervision3d.core.geom.renderables.IRenderable)
package org.papervision3d.core.geom.renderables {
import org.papervision3d.core.render.command.*;
public interface IRenderable {
function getRenderListItem():IRenderListItem;
}
}//package org.papervision3d.core.geom.renderables
Section 69
//Line3D (org.papervision3d.core.geom.renderables.Line3D)
package org.papervision3d.core.geom.renderables {
import org.papervision3d.core.render.command.*;
import org.papervision3d.materials.special.*;
import org.papervision3d.core.geom.*;
public class Line3D extends AbstractRenderable implements IRenderable {
public var size:Number;
public var cV:Vertex3D;
public var renderCommand:RenderLine;
public var material:LineMaterial;
public var v0:Vertex3D;
public var v1:Vertex3D;
public function Line3D(_arg1:Lines3D, _arg2:LineMaterial, _arg3:Number, _arg4:Vertex3D, _arg5:Vertex3D, _arg6:Vertex3D=null){
this.size = _arg3;
this.material = _arg2;
this.v0 = _arg4;
this.v1 = _arg5;
this.cV = _arg5;
this.instance = _arg1;
this.renderCommand = new RenderLine(this);
}
public function addControlVertex(_arg1:Number, _arg2:Number, _arg3:Number):void{
cV = new Vertex3D(_arg1, _arg2, _arg3);
if (instance.geometry.vertices.indexOf(cV) == -1){
instance.geometry.vertices.push(cV);
};
}
override public function getRenderListItem():IRenderListItem{
return (this.renderCommand);
}
}
}//package org.papervision3d.core.geom.renderables
Section 70
//Particle (org.papervision3d.core.geom.renderables.Particle)
package org.papervision3d.core.geom.renderables {
import org.papervision3d.core.render.command.*;
import flash.geom.*;
import org.papervision3d.materials.special.*;
public class Particle extends AbstractRenderable implements IRenderable {
public var size:Number;
public var renderScale:Number;
public var vertex3D:Vertex3D;
public var renderRect:Rectangle;
public var renderCommand:RenderParticle;
public var material:ParticleMaterial;
public function Particle(_arg1:ParticleMaterial, _arg2:Number=1, _arg3:Number=0, _arg4:Number=0, _arg5:Number=0){
this.material = _arg1;
this.size = _arg2;
this.renderCommand = new RenderParticle(this);
this.renderRect = new Rectangle();
vertex3D = new Vertex3D(_arg3, _arg4, _arg5);
}
public function get y():Number{
return (vertex3D.y);
}
public function updateRenderRect():void{
material.updateRenderRect(this);
}
public function set z(_arg1:Number):void{
vertex3D.z = _arg1;
}
public function set x(_arg1:Number):void{
vertex3D.x = _arg1;
}
public function set y(_arg1:Number):void{
vertex3D.y = _arg1;
}
public function get x():Number{
return (vertex3D.x);
}
public function get z():Number{
return (vertex3D.z);
}
override public function getRenderListItem():IRenderListItem{
return (renderCommand);
}
}
}//package org.papervision3d.core.geom.renderables
Section 71
//Triangle3D (org.papervision3d.core.geom.renderables.Triangle3D)
package org.papervision3d.core.geom.renderables {
import org.papervision3d.core.proto.*;
import org.papervision3d.core.math.*;
import org.papervision3d.core.render.command.*;
import org.papervision3d.objects.*;
public class Triangle3D extends AbstractRenderable implements IRenderable {
public var vertices:Array;
public var v1:Vertex3D;
public var face3DInstance:Triangle3DInstance;
public var _uvArray:Array;
public var visible:Boolean;
public var id:Number;
public var material:MaterialObject3D;
public var renderCommand:RenderTriangle;
public var screenZ:Number;
public var uv0:NumberUV;
public var uv1:NumberUV;
public var uv2:NumberUV;
public var faceNormal:Number3D;
public var _materialName:String;
public var v0:Vertex3D;
public var v2:Vertex3D;
private static var _totalFaces:Number = 0;
public function Triangle3D(_arg1:DisplayObject3D, _arg2:Array, _arg3:MaterialObject3D=null, _arg4:Array=null){
this.instance = _arg1;
this.renderCommand = new RenderTriangle(this);
face3DInstance = new Triangle3DInstance(this, _arg1);
faceNormal = new Number3D();
if (((_arg2) && ((_arg2.length == 3)))){
this.vertices = _arg2;
v0 = _arg2[0];
v1 = _arg2[1];
v2 = _arg2[2];
createNormal();
} else {
_arg2 = new Array();
v0 = (_arg2[0] = new Vertex3D());
v1 = (_arg2[1] = new Vertex3D());
v2 = (_arg2[2] = new Vertex3D());
};
this.material = _arg3;
this.uv = _arg4;
this.id = _totalFaces++;
}
public function set uv(_arg1:Array):void{
if (((_arg1) && ((_arg1.length == 3)))){
uv0 = NumberUV(_arg1[0]);
uv1 = NumberUV(_arg1[1]);
uv2 = NumberUV(_arg1[2]);
};
_uvArray = _arg1;
}
public function createNormal():void{
var _local1:Number3D;
var _local2:Number3D;
var _local3:Number3D;
_local1 = v0.getPosition();
_local2 = v1.getPosition();
_local3 = v2.getPosition();
_local2.minusEq(_local1);
_local3.minusEq(_local1);
faceNormal = Number3D.cross(_local2, _local3, faceNormal);
faceNormal.normalize();
}
public function get uv():Array{
return (_uvArray);
}
public function updateVertices():void{
v0 = vertices[0];
v1 = vertices[1];
v2 = vertices[2];
}
override public function getRenderListItem():IRenderListItem{
return (renderCommand);
}
}
}//package org.papervision3d.core.geom.renderables
Section 72
//Triangle3DInstance (org.papervision3d.core.geom.renderables.Triangle3DInstance)
package org.papervision3d.core.geom.renderables {
import flash.display.*;
import org.papervision3d.core.math.*;
import org.papervision3d.objects.*;
public class Triangle3DInstance {
public var container:Sprite;
public var faceNormal:Number3D;
public var screenZ:Number;
public var visible:Boolean;// = false
public var instance:DisplayObject3D;
public function Triangle3DInstance(_arg1:Triangle3D, _arg2:DisplayObject3D){
visible = false;
super();
this.instance = _arg2;
faceNormal = new Number3D();
}
}
}//package org.papervision3d.core.geom.renderables
Section 73
//Vertex3D (org.papervision3d.core.geom.renderables.Vertex3D)
package org.papervision3d.core.geom.renderables {
import org.papervision3d.core.math.*;
import org.papervision3d.core.render.command.*;
import flash.utils.*;
public class Vertex3D extends AbstractRenderable implements IRenderable {
public var vertex3DInstance:Vertex3DInstance;
public var extra:Object;
public var normal:Number3D;
protected var position:Number3D;
public var connectedFaces:Dictionary;
public var x:Number;
public var y:Number;
public var z:Number;
public function Vertex3D(_arg1:Number=0, _arg2:Number=0, _arg3:Number=0){
position = new Number3D();
super();
this.x = (position.x = _arg1);
this.y = (position.y = _arg2);
this.z = (position.z = _arg3);
this.vertex3DInstance = new Vertex3DInstance();
this.normal = new Number3D();
this.connectedFaces = new Dictionary();
}
public function clone():Vertex3D{
var _local1:Vertex3D;
_local1 = new Vertex3D(x, y, z);
_local1.extra = extra;
_local1.vertex3DInstance = vertex3DInstance.clone();
_local1.normal = normal.clone();
return (_local1);
}
public function getPosition():Number3D{
position.x = x;
position.y = y;
position.z = z;
return (position);
}
public function toNumber3D():Number3D{
return (new Number3D(x, y, z));
}
public function calculateNormal():void{
var _local1:Triangle3D;
var _local2:Number;
var _local3:Number3D;
_local2 = 0;
normal.reset();
for each (_local1 in connectedFaces) {
if (_local1.faceNormal){
_local2++;
normal.plusEq(_local1.faceNormal);
};
};
_local3 = getPosition();
_local3.x = (_local3.x / _local2);
_local3.y = (_local3.y / _local2);
_local3.z = (_local3.z / _local2);
_local3.normalize();
normal.plusEq(_local3);
normal.normalize();
}
override public function getRenderListItem():IRenderListItem{
return (null);
}
}
}//package org.papervision3d.core.geom.renderables
Section 74
//Vertex3DInstance (org.papervision3d.core.geom.renderables.Vertex3DInstance)
package org.papervision3d.core.geom.renderables {
import org.papervision3d.core.math.*;
public class Vertex3DInstance {
public var visible:Boolean;
public var normal:Number3D;
public var extra:Object;
public var x:Number;
public var y:Number;
public var z:Number;
public function Vertex3DInstance(_arg1:Number=0, _arg2:Number=0, _arg3:Number=0){
this.x = _arg1;
this.y = _arg2;
this.z = _arg3;
this.visible = false;
this.normal = new Number3D();
}
public function clone():Vertex3DInstance{
var _local1:Vertex3DInstance;
_local1 = new Vertex3DInstance(x, y, z);
_local1.visible = visible;
_local1.extra = extra;
return (_local1);
}
public static function cross(_arg1:Vertex3DInstance, _arg2:Vertex3DInstance):Number{
return (((_arg1.x * _arg2.y) - (_arg2.x * _arg1.y)));
}
public static function dot(_arg1:Vertex3DInstance, _arg2:Vertex3DInstance):Number{
return (((_arg1.x * _arg2.x) + (_arg1.y * _arg2.y)));
}
public static function subTo(_arg1:Vertex3DInstance, _arg2:Vertex3DInstance, _arg3:Vertex3DInstance):void{
_arg3.x = (_arg2.x - _arg1.x);
_arg3.y = (_arg2.y - _arg1.y);
}
public static function sub(_arg1:Vertex3DInstance, _arg2:Vertex3DInstance):Vertex3DInstance{
return (new Vertex3DInstance((_arg2.x - _arg1.x), (_arg2.y - _arg1.y)));
}
}
}//package org.papervision3d.core.geom.renderables
Section 75
//Lines3D (org.papervision3d.core.geom.Lines3D)
package org.papervision3d.core.geom {
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.log.*;
import org.papervision3d.materials.special.*;
import org.papervision3d.core.render.draw.*;
public class Lines3D extends Vertices3D {
public var lines:Array;
private var _material:ILineDrawer;
public function Lines3D(_arg1:LineMaterial, _arg2:String=null){
super(null, _arg2);
this.material = _arg1;
init();
}
private function init():void{
this.lines = new Array();
}
override public function project(_arg1:DisplayObject3D, _arg2:RenderSessionData):Number{
var _local3:Line3D;
var _local4:Number;
super.project(_arg1, _arg2);
for each (_local3 in lines) {
if (_arg2.viewPort.lineCuller.testLine(_local3)){
_local3.renderCommand.renderer = _local3.material;
_local4 = (_local4 + (_local3.renderCommand.screenDepth = ((_local3.v0.vertex3DInstance.z + _local3.v1.vertex3DInstance.z) / 2)));
_arg2.renderer.addToRenderList(_local3.renderCommand);
};
};
return ((_local4 / (lines.length + 1)));
}
public function addLine(_arg1:Line3D):void{
lines.push(_arg1);
_arg1.instance = this;
if (geometry.vertices.indexOf(_arg1.v0) == -1){
geometry.vertices.push(_arg1.v0);
};
if (geometry.vertices.indexOf(_arg1.v1) == -1){
geometry.vertices.push(_arg1.v1);
};
if (_arg1.cV){
if (geometry.vertices.indexOf(_arg1.cV) == -1){
geometry.vertices.push(_arg1.cV);
};
};
}
public function addNewSegmentedLine(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:Number, _arg7:Number, _arg8:Number):void{
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Line3D;
var _local13:Vertex3D;
var _local14:Vertex3D;
var _local15:Number;
_local9 = ((_arg6 - _arg3) / _arg2);
_local10 = ((_arg7 - _arg4) / _arg2);
_local11 = ((_arg8 - _arg5) / _arg2);
_local13 = new Vertex3D(_arg3, _arg4, _arg5);
_local15 = 0;
while (_local15 <= _arg2) {
_local14 = new Vertex3D((_arg3 + (_local9 * _local15)), (_arg4 + (_local10 * _local15)), (_arg5 + (_local11 * _local15)));
_local12 = new Line3D(this, (material as LineMaterial), _arg1, _local13, _local14);
addLine(_local12);
_local13 = _local14;
_local15++;
};
}
public function removeAllLines():void{
PaperLogger.warning("Lines3D.removeAllLines not yet implemented");
}
public function removeLine(_arg1:Line3D):void{
var _local2:int;
_local2 = lines.indexOf(_arg1);
if (_local2 > -1){
lines.splice(_local2, 1);
} else {
PaperLogger.warning("Papervision3D Lines3D.removeLine : WARNING removal of non-existant line attempted. ");
};
}
public function addNewLine(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:Number, _arg7:Number):Line3D{
var _local8:Line3D;
_local8 = new Line3D(this, (material as LineMaterial), _arg1, new Vertex3D(_arg2, _arg3, _arg4), new Vertex3D(_arg5, _arg6, _arg7));
addLine(_local8);
return (_local8);
}
}
}//package org.papervision3d.core.geom
Section 76
//TriangleMesh3D (org.papervision3d.core.geom.TriangleMesh3D)
package org.papervision3d.core.geom {
import org.papervision3d.core.proto.*;
import org.papervision3d.core.math.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.render.command.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.culling.*;
import flash.utils.*;
import org.papervision3d.core.render.draw.*;
public class TriangleMesh3D extends Vertices3D {
public function TriangleMesh3D(_arg1:MaterialObject3D, _arg2:Array, _arg3:Array, _arg4:String=null){
super(_arg2, _arg4);
this.geometry.faces = ((_arg3) || (new Array()));
this.material = ((_arg1) || (MaterialObject3D.DEFAULT));
}
override public function project(_arg1:DisplayObject3D, _arg2:RenderSessionData):Number{
var _local3:Array;
var _local4:Number;
var _local5:Number;
var _local6:ITriangleCuller;
var _local7:Vertex3DInstance;
var _local8:Vertex3DInstance;
var _local9:Vertex3DInstance;
var _local10:Triangle3DInstance;
var _local11:Triangle3D;
var _local12:MaterialObject3D;
var _local13:RenderTriangle;
super.project(_arg1, _arg2);
if (!this.culled){
_local3 = this.geometry.faces;
_local4 = 0;
_local5 = 0;
_local6 = _arg2.triangleCuller;
for each (_local11 in _local3) {
_local12 = (_local11.material) ? _local11.material : material;
_local10 = _local11.face3DInstance;
_local7 = _local11.v0.vertex3DInstance;
_local8 = _local11.v1.vertex3DInstance;
_local9 = _local11.v2.vertex3DInstance;
if ((_local10.visible = _local6.testFace(_local11, _local7, _local8, _local9))){
_local4 = (_local4 + (_local10.screenZ = (((_local7.z + _local8.z) + _local9.z) / 3)));
_local13 = _local11.renderCommand;
_local5++;
_local13.renderer = (_local12 as ITriangleDrawer);
_local13.screenDepth = _local10.screenZ;
_arg2.renderer.addToRenderList(_local13);
} else {
_arg2.renderStatistics.culledTriangles++;
};
};
return ((this.screenZ = (_local4 / _local5)));
} else {
_arg2.renderStatistics.culledObjects++;
};
return (0);
}
public function mergeVertices():void{
var _local1:Dictionary;
var _local2:Array;
var _local3:Vertex3D;
var _local4:Triangle3D;
var _local5:Vertex3D;
_local1 = new Dictionary();
_local2 = new Array();
for each (_local3 in this.geometry.vertices) {
for each (_local5 in _local1) {
if ((((((_local3.x == _local5.x)) && ((_local3.y == _local5.y)))) && ((_local3.z == _local5.z)))){
_local1[_local3] = _local5;
break;
};
};
if (!_local1[_local3]){
_local1[_local3] = _local3;
_local2.push(_local3);
};
};
this.geometry.vertices = _local2;
for each (_local4 in geometry.faces) {
_local4.v0 = _local1[_local4.v0];
_local4.v1 = _local1[_local4.v1];
_local4.v2 = _local1[_local4.v2];
};
}
override public function clone():DisplayObject3D{
var _local1:DisplayObject3D;
var _local2:TriangleMesh3D;
_local1 = super.clone();
_local2 = new TriangleMesh3D(this.material, [], [], _local1.name);
if (this.materials){
_local2.materials = this.materials.clone();
};
if (_local1.geometry){
_local2.geometry = _local1.geometry.clone(_local2);
};
_local2.copyTransform(this.transform);
return (_local2);
}
override public function set material(_arg1:MaterialObject3D):void{
var _local2:Triangle3D;
super.material = _arg1;
for each (_local2 in geometry.faces) {
_local2.material = _arg1;
};
}
public function quarterFaces():void{
var _local1:Array;
var _local2:Array;
var _local3:Array;
var _local4:Triangle3D;
var _local5:int;
var _local6:Vertex3D;
var _local7:Vertex3D;
var _local8:Vertex3D;
var _local9:Vertex3D;
var _local10:Vertex3D;
var _local11:Vertex3D;
var _local12:NumberUV;
var _local13:NumberUV;
var _local14:NumberUV;
var _local15:NumberUV;
var _local16:NumberUV;
var _local17:NumberUV;
var _local18:Triangle3D;
var _local19:Triangle3D;
var _local20:Triangle3D;
var _local21:Triangle3D;
_local1 = new Array();
_local2 = new Array();
_local3 = this.geometry.faces;
_local5 = _local3.length;
while ((_local4 = _local3[--_local5])) {
_local6 = _local4.v0;
_local7 = _local4.v1;
_local8 = _local4.v2;
_local9 = new Vertex3D(((_local6.x + _local7.x) / 2), ((_local6.y + _local7.y) / 2), ((_local6.z + _local7.z) / 2));
_local10 = new Vertex3D(((_local7.x + _local8.x) / 2), ((_local7.y + _local8.y) / 2), ((_local7.z + _local8.z) / 2));
_local11 = new Vertex3D(((_local8.x + _local6.x) / 2), ((_local8.y + _local6.y) / 2), ((_local8.z + _local6.z) / 2));
this.geometry.vertices.push(_local9, _local10, _local11);
_local12 = _local4.uv[0];
_local13 = _local4.uv[1];
_local14 = _local4.uv[2];
_local15 = new NumberUV(((_local12.u + _local13.u) / 2), ((_local12.v + _local13.v) / 2));
_local16 = new NumberUV(((_local13.u + _local14.u) / 2), ((_local13.v + _local14.v) / 2));
_local17 = new NumberUV(((_local14.u + _local12.u) / 2), ((_local14.v + _local12.v) / 2));
_local18 = new Triangle3D(this, [_local6, _local9, _local11], _local4.material, [_local12, _local15, _local17]);
_local19 = new Triangle3D(this, [_local9, _local7, _local10], _local4.material, [_local15, _local13, _local16]);
_local20 = new Triangle3D(this, [_local11, _local10, _local8], _local4.material, [_local17, _local16, _local14]);
_local21 = new Triangle3D(this, [_local9, _local10, _local11], _local4.material, [_local15, _local16, _local17]);
_local2.push(_local18, _local19, _local20, _local21);
};
this.geometry.faces = _local2;
this.mergeVertices();
this.geometry.ready = true;
}
public function projectTexture(_arg1:String="x", _arg2:String="y"):void{
var _local3:Array;
var _local4:Object;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:MaterialObject3D;
var _local10:String;
var _local11:Triangle3D;
var _local12:Array;
var _local13:Vertex3D;
var _local14:Vertex3D;
var _local15:Vertex3D;
var _local16:NumberUV;
var _local17:NumberUV;
var _local18:NumberUV;
_local3 = this.geometry.faces;
_local4 = this.boundingBox();
_local5 = _local4.min[_arg1];
_local6 = _local4.size[_arg1];
_local7 = _local4.min[_arg2];
_local8 = _local4.size[_arg2];
_local9 = this.material;
for (_local10 in _local3) {
_local11 = _local3[Number(_local10)];
_local12 = _local11.vertices;
_local13 = _local12[0];
_local14 = _local12[1];
_local15 = _local12[2];
_local16 = new NumberUV(((_local13[_arg1] - _local5) / _local6), ((_local13[_arg2] - _local7) / _local8));
_local17 = new NumberUV(((_local14[_arg1] - _local5) / _local6), ((_local14[_arg2] - _local7) / _local8));
_local18 = new NumberUV(((_local15[_arg1] - _local5) / _local6), ((_local15[_arg2] - _local7) / _local8));
_local11.uv = [_local16, _local17, _local18];
};
}
}
}//package org.papervision3d.core.geom
Section 77
//Vertices3D (org.papervision3d.core.geom.Vertices3D)
package org.papervision3d.core.geom {
import org.papervision3d.core.proto.*;
import org.papervision3d.core.math.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.culling.*;
public class Vertices3D extends DisplayObject3D {
public function Vertices3D(_arg1:Array, _arg2:String=null){
super(_arg2, new GeometryObject3D());
this.geometry.vertices = ((_arg1) || (new Array()));
}
public function projectFrustum(_arg1:DisplayObject3D, _arg2:RenderSessionData):Number{
return (0);
}
override public function project(_arg1:DisplayObject3D, _arg2:RenderSessionData):Number{
super.project(_arg1, _arg2);
if (this.culled){
return (0);
};
if ((_arg2.camera is IObjectCuller)){
return (projectFrustum(_arg1, _arg2));
};
return (_arg2.camera.projectVertices(this, _arg2));
}
override public function clone():DisplayObject3D{
var _local1:DisplayObject3D;
var _local2:Vertices3D;
_local1 = super.clone();
_local2 = new Vertices3D(null, _local1.name);
_local2.material = _local1.material;
if (_local1.materials){
_local2.materials = _local1.materials.clone();
};
if (this.geometry){
_local2.geometry = this.geometry.clone(_local2);
};
_local2.copyTransform(this.transform);
return (_local2);
}
public function transformVertices(_arg1:Matrix3D):void{
geometry.transformVertices(_arg1);
}
public function boundingBox():Object{
var _local1:Array;
var _local2:Object;
var _local3:Vertex3D;
_local1 = this.geometry.vertices;
_local2 = new Object();
_local2.min = new Number3D(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
_local2.max = new Number3D(-(Number.MAX_VALUE), -(Number.MAX_VALUE), -(Number.MAX_VALUE));
_local2.size = new Number3D();
for each (_local3 in _local1) {
_local2.min.x = Math.min(_local3.x, _local2.min.x);
_local2.min.y = Math.min(_local3.y, _local2.min.y);
_local2.min.z = Math.min(_local3.z, _local2.min.z);
_local2.max.x = Math.max(_local3.x, _local2.max.x);
_local2.max.y = Math.max(_local3.y, _local2.max.y);
_local2.max.z = Math.max(_local3.z, _local2.max.z);
};
_local2.size.x = (_local2.max.x - _local2.min.x);
_local2.size.y = (_local2.max.y - _local2.min.y);
_local2.size.z = (_local2.max.z - _local2.min.z);
return (_local2);
}
}
}//package org.papervision3d.core.geom
Section 78
//PaperLoggerEvent (org.papervision3d.core.log.event.PaperLoggerEvent)
package org.papervision3d.core.log.event {
import flash.events.*;
import org.papervision3d.core.log.*;
public class PaperLoggerEvent extends Event {
public var paperLogVO:PaperLogVO;
public static const TYPE_LOGEVENT:String = "logEvent";
public function PaperLoggerEvent(_arg1:PaperLogVO){
super(TYPE_LOGEVENT);
this.paperLogVO = _arg1;
}
}
}//package org.papervision3d.core.log.event
Section 79
//AbstractPaperLogger (org.papervision3d.core.log.AbstractPaperLogger)
package org.papervision3d.core.log {
import org.papervision3d.core.log.event.*;
public class AbstractPaperLogger implements IPaperLogger {
public function registerWithPaperLogger(_arg1:PaperLogger):void{
_arg1.addEventListener(PaperLoggerEvent.TYPE_LOGEVENT, onLogEvent);
}
public function debug(_arg1:String, _arg2:Object=null, _arg3:Array=null):void{
}
public function log(_arg1:String, _arg2:Object=null, _arg3:Array=null):void{
}
public function fatal(_arg1:String, _arg2:Object=null, _arg3:Array=null):void{
}
public function error(_arg1:String, _arg2:Object=null, _arg3:Array=null):void{
}
protected function onLogEvent(_arg1:PaperLoggerEvent):void{
var _local2:PaperLogVO;
_local2 = _arg1.paperLogVO;
switch (_local2.level){
case LogLevel.LOG:
log(_local2.msg, _local2.object, _local2.arg);
break;
case LogLevel.INFO:
info(_local2.msg, _local2.object, _local2.arg);
break;
case LogLevel.ERROR:
error(_local2.msg, _local2.object, _local2.arg);
break;
case LogLevel.DEBUG:
debug(_local2.msg, _local2.object, _local2.arg);
break;
case LogLevel.WARNING:
warning(_local2.msg, _local2.object, _local2.arg);
break;
case LogLevel.FATAL:
fatal(_local2.msg, _local2.object, _local2.arg);
break;
default:
log(_local2.msg, _local2.object, _local2.arg);
break;
};
}
public function unregisterFromPaperLogger(_arg1:PaperLogger):void{
_arg1.removeEventListener(PaperLoggerEvent.TYPE_LOGEVENT, onLogEvent);
}
public function warning(_arg1:String, _arg2:Object=null, _arg3:Array=null):void{
}
public function info(_arg1:String, _arg2:Object=null, _arg3:Array=null):void{
}
}
}//package org.papervision3d.core.log
Section 80
//IPaperLogger (org.papervision3d.core.log.IPaperLogger)
package org.papervision3d.core.log {
public interface IPaperLogger {
function debug(_arg1:String, _arg2:Object=null, _arg3:Array=null):void;
function log(_arg1:String, _arg2:Object=null, _arg3:Array=null):void;
function error(_arg1:String, _arg2:Object=null, _arg3:Array=null):void;
function fatal(_arg1:String, _arg2:Object=null, _arg3:Array=null):void;
function warning(_arg1:String, _arg2:Object=null, _arg3:Array=null):void;
function info(_arg1:String, _arg2:Object=null, _arg3:Array=null):void;
}
}//package org.papervision3d.core.log
Section 81
//LogLevel (org.papervision3d.core.log.LogLevel)
package org.papervision3d.core.log {
public class LogLevel {
public static const FATAL:int = 5;
public static const ERROR:int = 4;
public static const LOG:int = 0;
public static const INFO:int = 1;
public static const DEBUG:int = 2;
public static const WARNING:int = 3;
}
}//package org.papervision3d.core.log
Section 82
//PaperLogger (org.papervision3d.core.log.PaperLogger)
package org.papervision3d.core.log {
import flash.events.*;
import org.papervision3d.core.log.event.*;
public class PaperLogger extends EventDispatcher {
public var traceLogger:PaperTraceLogger;
private static var instance:PaperLogger;
public function PaperLogger(){
if (instance){
throw (new Error("Don't call the PaperLogger constructor directly"));
};
traceLogger = new PaperTraceLogger();
registerLogger(traceLogger);
}
public function registerLogger(_arg1:AbstractPaperLogger):void{
_arg1.registerWithPaperLogger(this);
}
public function warning(_arg1:String, _arg2:Object=null, ... _args):void{
var _local4:PaperLogVO;
var _local5:PaperLoggerEvent;
_local4 = new PaperLogVO(LogLevel.WARNING, _arg1, _arg2, _args);
_local5 = new PaperLoggerEvent(_local4);
dispatchEvent(_local5);
}
public function log(_arg1:String, _arg2:Object=null, ... _args):void{
var _local4:PaperLogVO;
var _local5:PaperLoggerEvent;
_local4 = new PaperLogVO(LogLevel.LOG, _arg1, _arg2, _args);
_local5 = new PaperLoggerEvent(_local4);
dispatchEvent(_local5);
}
public function error(_arg1:String, _arg2:Object=null, ... _args):void{
var _local4:PaperLogVO;
var _local5:PaperLoggerEvent;
_local4 = new PaperLogVO(LogLevel.ERROR, _arg1, _arg2, _args);
_local5 = new PaperLoggerEvent(_local4);
dispatchEvent(_local5);
}
public function info(_arg1:String, _arg2:Object=null, ... _args):void{
var _local4:PaperLogVO;
var _local5:PaperLoggerEvent;
_local4 = new PaperLogVO(LogLevel.INFO, _arg1, _arg2, _args);
_local5 = new PaperLoggerEvent(_local4);
dispatchEvent(_local5);
}
public function unregisterLogger(_arg1:AbstractPaperLogger):void{
_arg1.unregisterFromPaperLogger(this);
}
public function debug(_arg1:String, _arg2:Object=null, ... _args):void{
var _local4:PaperLogVO;
var _local5:PaperLoggerEvent;
_local4 = new PaperLogVO(LogLevel.DEBUG, _arg1, _arg2, _args);
_local5 = new PaperLoggerEvent(_local4);
dispatchEvent(_local5);
}
public static function debug(_arg1:String, _arg2:Object=null, ... _args):void{
getInstance().debug(_arg1);
}
public static function log(_arg1:String, _arg2:Object=null, ... _args):void{
getInstance().log(_arg1);
}
public static function error(_arg1:String, _arg2:Object=null, ... _args):void{
getInstance().error(_arg1);
}
public static function getInstance():PaperLogger{
if (!instance){
instance = new (PaperLogger);
};
return (instance);
}
public static function warning(_arg1:String, _arg2:Object=null, ... _args):void{
getInstance().warning(_arg1);
}
public static function info(_arg1:String, _arg2:Object=null, ... _args):void{
getInstance().info(_arg1);
}
}
}//package org.papervision3d.core.log
Section 83
//PaperLogVO (org.papervision3d.core.log.PaperLogVO)
package org.papervision3d.core.log {
public class PaperLogVO {
public var msg:String;
public var level:int;
public var arg:Array;
public var object:Object;
public function PaperLogVO(_arg1:int, _arg2:String, _arg3:Object, _arg4:Array){
this.level = _arg1;
this.msg = _arg2;
this.object = _arg3;
this.arg = _arg4;
}
}
}//package org.papervision3d.core.log
Section 84
//PaperTraceLogger (org.papervision3d.core.log.PaperTraceLogger)
package org.papervision3d.core.log {
public class PaperTraceLogger extends AbstractPaperLogger implements IPaperLogger {
override public function fatal(_arg1:String, _arg2:Object=null, _arg3:Array=null):void{
trace("FATAL:", _arg1, _arg3);
}
override public function error(_arg1:String, _arg2:Object=null, _arg3:Array=null):void{
trace("ERROR:", _arg1, _arg3);
}
override public function debug(_arg1:String, _arg2:Object=null, _arg3:Array=null):void{
trace("DEBUG:", _arg1, _arg3);
}
override public function warning(_arg1:String, _arg2:Object=null, _arg3:Array=null):void{
trace("WARNING:", _arg1, _arg3);
}
override public function log(_arg1:String, _arg2:Object=null, _arg3:Array=null):void{
trace("LOG:", _arg1, _arg3);
}
override public function info(_arg1:String, _arg2:Object=null, _arg3:Array=null):void{
trace("INFO:", _arg1, _arg3);
}
}
}//package org.papervision3d.core.log
Section 85
//TriangleMaterial (org.papervision3d.core.material.TriangleMaterial)
package org.papervision3d.core.material {
import org.papervision3d.core.proto.*;
import flash.display.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.geom.renderables.*;
import flash.geom.*;
import org.papervision3d.core.render.draw.*;
public class TriangleMaterial extends MaterialObject3D implements ITriangleDrawer {
override public function drawTriangle(_arg1:Triangle3D, _arg2:Graphics, _arg3:RenderSessionData, _arg4:BitmapData=null, _arg5:Matrix=null):void{
}
}
}//package org.papervision3d.core.material
Section 86
//FastRectangleTools (org.papervision3d.core.math.util.FastRectangleTools)
package org.papervision3d.core.math.util {
import flash.geom.*;
public class FastRectangleTools {
public static function intersection(_arg1:Rectangle, _arg2:Rectangle, _arg3:Rectangle=null):Rectangle{
if (!_arg3){
_arg3 = new Rectangle();
};
if (!intersects(_arg1, _arg2)){
_arg3.x = (_arg3.y = (_arg3.width = (_arg3.height = 0)));
return (_arg3);
};
_arg3.left = ((_arg1.left)>_arg2.left) ? _arg1.left : _arg2.left;
_arg3.right = ((_arg1.right)<_arg2.right) ? _arg1.right : _arg2.right;
_arg3.top = ((_arg1.top)>_arg2.top) ? _arg1.top : _arg2.top;
_arg3.bottom = ((_arg1.bottom)<_arg2.bottom) ? _arg1.bottom : _arg2.bottom;
return (_arg3);
}
public static function intersects(_arg1:Rectangle, _arg2:Rectangle):Boolean{
if (!(((_arg1.right < _arg2.left)) || ((_arg1.left > _arg2.right)))){
if (!(((_arg1.bottom < _arg2.top)) || ((_arg1.top > _arg2.bottom)))){
return (true);
};
};
return (false);
}
}
}//package org.papervision3d.core.math.util
Section 87
//AxisAlignedBoundingBox (org.papervision3d.core.math.AxisAlignedBoundingBox)
package org.papervision3d.core.math {
import org.papervision3d.core.geom.renderables.*;
public class AxisAlignedBoundingBox {
public var minX:Number;
public var minY:Number;
public var minZ:Number;
public var maxX:Number;
public var maxY:Number;
protected var _vertices:Array;
public var maxZ:Number;
public function AxisAlignedBoundingBox(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:Number){
this.minX = _arg1;
this.minY = _arg2;
this.minZ = _arg3;
this.maxX = _arg4;
this.maxY = _arg5;
this.maxZ = _arg6;
createBoxVertices();
}
protected function createBoxVertices():void{
_vertices = new Array();
_vertices.push(new Vertex3D(minX, minY, minZ));
_vertices.push(new Vertex3D(minX, minY, maxZ));
_vertices.push(new Vertex3D(minX, maxY, minZ));
_vertices.push(new Vertex3D(minX, maxY, maxZ));
_vertices.push(new Vertex3D(maxX, minY, minZ));
_vertices.push(new Vertex3D(maxX, minY, maxZ));
_vertices.push(new Vertex3D(maxX, maxY, minZ));
_vertices.push(new Vertex3D(maxX, maxY, maxZ));
}
public function getBoxVertices():Array{
return (_vertices);
}
public function merge(_arg1:AxisAlignedBoundingBox):void{
this.minX = Math.min(this.minX, _arg1.minX);
this.minY = Math.min(this.minY, _arg1.minY);
this.minZ = Math.min(this.minZ, _arg1.minZ);
this.maxX = Math.max(this.maxX, _arg1.maxX);
this.maxY = Math.max(this.maxY, _arg1.maxY);
this.maxZ = Math.max(this.maxZ, _arg1.maxZ);
createBoxVertices();
}
public static function createFromVertices(_arg1:Array):AxisAlignedBoundingBox{
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Vertex3D;
_local2 = Number.MAX_VALUE;
_local3 = Number.MAX_VALUE;
_local4 = Number.MAX_VALUE;
_local5 = -(_local2);
_local6 = -(_local3);
_local7 = -(_local4);
for each (_local8 in _arg1) {
_local2 = Math.min(_local2, _local8.x);
_local3 = Math.min(_local3, _local8.y);
_local4 = Math.min(_local4, _local8.z);
_local5 = Math.max(_local5, _local8.x);
_local6 = Math.max(_local6, _local8.y);
_local7 = Math.max(_local7, _local8.z);
};
return (new AxisAlignedBoundingBox(_local2, _local3, _local4, _local5, _local6, _local7));
}
}
}//package org.papervision3d.core.math
Section 88
//BoundingSphere (org.papervision3d.core.math.BoundingSphere)
package org.papervision3d.core.math {
import org.papervision3d.core.geom.renderables.*;
public class BoundingSphere {
public var maxDistance:Number;
public var radius:Number;
public function BoundingSphere(_arg1:Number){
this.maxDistance = _arg1;
this.radius = Math.sqrt(_arg1);
}
public static function getFromVertices(_arg1:Array):BoundingSphere{
var _local2:Number;
var _local3:Number;
var _local4:Vertex3D;
_local2 = 0;
for each (_local4 in _arg1) {
_local3 = (((_local4.x * _local4.x) + (_local4.y * _local4.y)) + (_local4.z * _local4.z));
_local2 = ((_local3)>_local2) ? _local3 : _local2;
};
return (new BoundingSphere(_local2));
}
}
}//package org.papervision3d.core.math
Section 89
//Matrix3D (org.papervision3d.core.math.Matrix3D)
package org.papervision3d.core.math {
import org.papervision3d.*;
public class Matrix3D {
public var n31:Number;
public var n32:Number;
public var n11:Number;
public var n13:Number;
public var n14:Number;
public var n33:Number;
public var n12:Number;
public var n42:Number;
public var n21:Number;
public var n22:Number;
public var n23:Number;
public var n24:Number;
public var n34:Number;
public var n41:Number;
public var n43:Number;
public var n44:Number;
private static var _cos:Function = Math.cos;
private static var _sin:Function = Math.sin;
private static var temp:Matrix3D = Matrix3D.IDENTITY;
private static var n3Di:Number3D = Number3D.ZERO;
private static var n3Dj:Number3D = Number3D.ZERO;
private static var n3Dk:Number3D = Number3D.ZERO;
private static var toDEGREES:Number = 57.2957795130823;
private static var toRADIANS:Number = 0.0174532925199433;
public function Matrix3D(_arg1:Array=null){
reset(_arg1);
}
public function calculateMultiply3x3(_arg1:Matrix3D, _arg2:Matrix3D):void{
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:Number;
var _local20:Number;
_local3 = _arg1.n11;
_local4 = _arg2.n11;
_local5 = _arg1.n21;
_local6 = _arg2.n21;
_local7 = _arg1.n31;
_local8 = _arg2.n31;
_local9 = _arg1.n12;
_local10 = _arg2.n12;
_local11 = _arg1.n22;
_local12 = _arg2.n22;
_local13 = _arg1.n32;
_local14 = _arg2.n32;
_local15 = _arg1.n13;
_local16 = _arg2.n13;
_local17 = _arg1.n23;
_local18 = _arg2.n23;
_local19 = _arg1.n33;
_local20 = _arg2.n33;
this.n11 = (((_local3 * _local4) + (_local9 * _local6)) + (_local15 * _local8));
this.n12 = (((_local3 * _local10) + (_local9 * _local12)) + (_local15 * _local14));
this.n13 = (((_local3 * _local16) + (_local9 * _local18)) + (_local15 * _local20));
this.n21 = (((_local5 * _local4) + (_local11 * _local6)) + (_local17 * _local8));
this.n22 = (((_local5 * _local10) + (_local11 * _local12)) + (_local17 * _local14));
this.n23 = (((_local5 * _local16) + (_local11 * _local18)) + (_local17 * _local20));
this.n31 = (((_local7 * _local4) + (_local13 * _local6)) + (_local19 * _local8));
this.n32 = (((_local7 * _local10) + (_local13 * _local12)) + (_local19 * _local14));
this.n33 = (((_local7 * _local16) + (_local13 * _local18)) + (_local19 * _local20));
}
public function calculateMultiply4x4(_arg1:Matrix3D, _arg2:Matrix3D):void{
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:Number;
var _local20:Number;
var _local21:Number;
var _local22:Number;
var _local23:Number;
var _local24:Number;
var _local25:Number;
var _local26:Number;
var _local27:Number;
var _local28:Number;
var _local29:Number;
var _local30:Number;
var _local31:Number;
var _local32:Number;
var _local33:Number;
var _local34:Number;
_local3 = _arg1.n11;
_local4 = _arg2.n11;
_local5 = _arg1.n21;
_local6 = _arg2.n21;
_local7 = _arg1.n31;
_local8 = _arg2.n31;
_local9 = _arg1.n41;
_local10 = _arg2.n41;
_local11 = _arg1.n12;
_local12 = _arg2.n12;
_local13 = _arg1.n22;
_local14 = _arg2.n22;
_local15 = _arg1.n32;
_local16 = _arg2.n32;
_local17 = _arg1.n42;
_local18 = _arg2.n42;
_local19 = _arg1.n13;
_local20 = _arg2.n13;
_local21 = _arg1.n23;
_local22 = _arg2.n23;
_local23 = _arg1.n33;
_local24 = _arg2.n33;
_local25 = _arg1.n43;
_local26 = _arg2.n43;
_local27 = _arg1.n14;
_local28 = _arg2.n14;
_local29 = _arg1.n24;
_local30 = _arg2.n24;
_local31 = _arg1.n34;
_local32 = _arg2.n34;
_local33 = _arg1.n44;
_local34 = _arg2.n44;
this.n11 = (((_local3 * _local4) + (_local11 * _local6)) + (_local19 * _local8));
this.n12 = (((_local3 * _local12) + (_local11 * _local14)) + (_local19 * _local16));
this.n13 = (((_local3 * _local20) + (_local11 * _local22)) + (_local19 * _local24));
this.n14 = ((((_local3 * _local28) + (_local11 * _local30)) + (_local19 * _local32)) + _local27);
this.n21 = (((_local5 * _local4) + (_local13 * _local6)) + (_local21 * _local8));
this.n22 = (((_local5 * _local12) + (_local13 * _local14)) + (_local21 * _local16));
this.n23 = (((_local5 * _local20) + (_local13 * _local22)) + (_local21 * _local24));
this.n24 = ((((_local5 * _local28) + (_local13 * _local30)) + (_local21 * _local32)) + _local29);
this.n31 = (((_local7 * _local4) + (_local15 * _local6)) + (_local23 * _local8));
this.n32 = (((_local7 * _local12) + (_local15 * _local14)) + (_local23 * _local16));
this.n33 = (((_local7 * _local20) + (_local15 * _local22)) + (_local23 * _local24));
this.n34 = ((((_local7 * _local28) + (_local15 * _local30)) + (_local23 * _local32)) + _local31);
this.n41 = (((_local9 * _local4) + (_local17 * _local6)) + (_local25 * _local8));
this.n42 = (((_local9 * _local12) + (_local17 * _local14)) + (_local25 * _local16));
this.n43 = (((_local9 * _local20) + (_local17 * _local22)) + (_local25 * _local24));
this.n44 = ((((_local9 * _local28) + (_local17 * _local30)) + (_local25 * _local32)) + _local33);
}
public function get det():Number{
return ((((((this.n11 * this.n22) - (this.n21 * this.n12)) * this.n33) - (((this.n11 * this.n32) - (this.n31 * this.n12)) * this.n23)) + (((this.n21 * this.n32) - (this.n31 * this.n22)) * this.n13)));
}
public function copy(_arg1:Matrix3D):Matrix3D{
this.n11 = _arg1.n11;
this.n12 = _arg1.n12;
this.n13 = _arg1.n13;
this.n14 = _arg1.n14;
this.n21 = _arg1.n21;
this.n22 = _arg1.n22;
this.n23 = _arg1.n23;
this.n24 = _arg1.n24;
this.n31 = _arg1.n31;
this.n32 = _arg1.n32;
this.n33 = _arg1.n33;
this.n34 = _arg1.n34;
return (this);
}
public function copy3x3(_arg1:Matrix3D):Matrix3D{
this.n11 = _arg1.n11;
this.n12 = _arg1.n12;
this.n13 = _arg1.n13;
this.n21 = _arg1.n21;
this.n22 = _arg1.n22;
this.n23 = _arg1.n23;
this.n31 = _arg1.n31;
this.n32 = _arg1.n32;
this.n33 = _arg1.n33;
return (this);
}
public function calculateAdd(_arg1:Matrix3D, _arg2:Matrix3D):void{
this.n11 = (_arg1.n11 + _arg2.n11);
this.n12 = (_arg1.n12 + _arg2.n12);
this.n13 = (_arg1.n13 + _arg2.n13);
this.n14 = (_arg1.n14 + _arg2.n14);
this.n21 = (_arg1.n21 + _arg2.n21);
this.n22 = (_arg1.n22 + _arg2.n22);
this.n23 = (_arg1.n23 + _arg2.n23);
this.n24 = (_arg1.n24 + _arg2.n24);
this.n31 = (_arg1.n31 + _arg2.n31);
this.n32 = (_arg1.n32 + _arg2.n32);
this.n33 = (_arg1.n33 + _arg2.n33);
this.n34 = (_arg1.n34 + _arg2.n34);
}
public function calculateMultiply(_arg1:Matrix3D, _arg2:Matrix3D):void{
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:Number;
var _local20:Number;
var _local21:Number;
var _local22:Number;
var _local23:Number;
var _local24:Number;
var _local25:Number;
var _local26:Number;
_local3 = _arg1.n11;
_local4 = _arg2.n11;
_local5 = _arg1.n21;
_local6 = _arg2.n21;
_local7 = _arg1.n31;
_local8 = _arg2.n31;
_local9 = _arg1.n12;
_local10 = _arg2.n12;
_local11 = _arg1.n22;
_local12 = _arg2.n22;
_local13 = _arg1.n32;
_local14 = _arg2.n32;
_local15 = _arg1.n13;
_local16 = _arg2.n13;
_local17 = _arg1.n23;
_local18 = _arg2.n23;
_local19 = _arg1.n33;
_local20 = _arg2.n33;
_local21 = _arg1.n14;
_local22 = _arg2.n14;
_local23 = _arg1.n24;
_local24 = _arg2.n24;
_local25 = _arg1.n34;
_local26 = _arg2.n34;
this.n11 = (((_local3 * _local4) + (_local9 * _local6)) + (_local15 * _local8));
this.n12 = (((_local3 * _local10) + (_local9 * _local12)) + (_local15 * _local14));
this.n13 = (((_local3 * _local16) + (_local9 * _local18)) + (_local15 * _local20));
this.n14 = ((((_local3 * _local22) + (_local9 * _local24)) + (_local15 * _local26)) + _local21);
this.n21 = (((_local5 * _local4) + (_local11 * _local6)) + (_local17 * _local8));
this.n22 = (((_local5 * _local10) + (_local11 * _local12)) + (_local17 * _local14));
this.n23 = (((_local5 * _local16) + (_local11 * _local18)) + (_local17 * _local20));
this.n24 = ((((_local5 * _local22) + (_local11 * _local24)) + (_local17 * _local26)) + _local23);
this.n31 = (((_local7 * _local4) + (_local13 * _local6)) + (_local19 * _local8));
this.n32 = (((_local7 * _local10) + (_local13 * _local12)) + (_local19 * _local14));
this.n33 = (((_local7 * _local16) + (_local13 * _local18)) + (_local19 * _local20));
this.n34 = ((((_local7 * _local22) + (_local13 * _local24)) + (_local19 * _local26)) + _local25);
}
public function invert():void{
temp.copy(this);
calculateInverse(temp);
}
public function calculateInverse(_arg1:Matrix3D):void{
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
_local2 = _arg1.det;
if (Math.abs(_local2) > 0.001){
_local2 = (1 / _local2);
_local3 = _arg1.n11;
_local4 = _arg1.n21;
_local5 = _arg1.n31;
_local6 = _arg1.n12;
_local7 = _arg1.n22;
_local8 = _arg1.n32;
_local9 = _arg1.n13;
_local10 = _arg1.n23;
_local11 = _arg1.n33;
_local12 = _arg1.n14;
_local13 = _arg1.n24;
_local14 = _arg1.n34;
this.n11 = (_local2 * ((_local7 * _local11) - (_local8 * _local10)));
this.n12 = (-(_local2) * ((_local6 * _local11) - (_local8 * _local9)));
this.n13 = (_local2 * ((_local6 * _local10) - (_local7 * _local9)));
this.n14 = (-(_local2) * (((_local6 * ((_local10 * _local14) - (_local11 * _local13))) - (_local7 * ((_local9 * _local14) - (_local11 * _local12)))) + (_local8 * ((_local9 * _local13) - (_local10 * _local12)))));
this.n21 = (-(_local2) * ((_local4 * _local11) - (_local5 * _local10)));
this.n22 = (_local2 * ((_local3 * _local11) - (_local5 * _local9)));
this.n23 = (-(_local2) * ((_local3 * _local10) - (_local4 * _local9)));
this.n24 = (_local2 * (((_local3 * ((_local10 * _local14) - (_local11 * _local13))) - (_local4 * ((_local9 * _local14) - (_local11 * _local12)))) + (_local5 * ((_local9 * _local13) - (_local10 * _local12)))));
this.n31 = (_local2 * ((_local4 * _local8) - (_local5 * _local7)));
this.n32 = (-(_local2) * ((_local3 * _local8) - (_local5 * _local6)));
this.n33 = (_local2 * ((_local3 * _local7) - (_local4 * _local6)));
this.n34 = (-(_local2) * (((_local3 * ((_local7 * _local14) - (_local8 * _local13))) - (_local4 * ((_local6 * _local14) - (_local8 * _local12)))) + (_local5 * ((_local6 * _local13) - (_local7 * _local12)))));
};
}
public function calculateTranspose():void{
var _local1:Number;
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
_local1 = this.n11;
_local2 = this.n21;
_local3 = this.n31;
_local4 = this.n41;
_local5 = this.n12;
_local6 = this.n22;
_local7 = this.n32;
_local8 = this.n42;
_local9 = this.n13;
_local10 = this.n23;
_local11 = this.n33;
_local12 = this.n43;
_local13 = this.n14;
_local14 = this.n24;
_local15 = this.n34;
_local16 = this.n44;
this.n11 = _local1;
this.n12 = _local2;
this.n13 = _local3;
this.n14 = _local4;
this.n21 = _local5;
this.n22 = _local6;
this.n23 = _local7;
this.n24 = _local8;
this.n31 = _local9;
this.n32 = _local10;
this.n33 = _local11;
this.n34 = _local12;
this.n41 = _local13;
this.n42 = _local14;
this.n43 = _local15;
this.n44 = _local16;
}
public function toString():String{
var _local1:String;
_local1 = "";
_local1 = (_local1 + ((((((((int((n11 * 1000)) / 1000) + "\t\t") + (int((n12 * 1000)) / 1000)) + "\t\t") + (int((n13 * 1000)) / 1000)) + "\t\t") + (int((n14 * 1000)) / 1000)) + "\n"));
_local1 = (_local1 + ((((((((int((n21 * 1000)) / 1000) + "\t\t") + (int((n22 * 1000)) / 1000)) + "\t\t") + (int((n23 * 1000)) / 1000)) + "\t\t") + (int((n24 * 1000)) / 1000)) + "\n"));
_local1 = (_local1 + ((((((((int((n31 * 1000)) / 1000) + "\t\t") + (int((n32 * 1000)) / 1000)) + "\t\t") + (int((n33 * 1000)) / 1000)) + "\t\t") + (int((n34 * 1000)) / 1000)) + "\n"));
_local1 = (_local1 + ((((((((int((n41 * 1000)) / 1000) + "\t\t") + (int((n42 * 1000)) / 1000)) + "\t\t") + (int((n43 * 1000)) / 1000)) + "\t\t") + (int((n44 * 1000)) / 1000)) + "\n"));
return (_local1);
}
public function reset(_arg1:Array=null):void{
if (((!(_arg1)) || ((_arg1.length < 12)))){
n11 = (n22 = (n33 = (n44 = 1)));
n12 = (n13 = (n14 = (n21 = (n23 = (n24 = (n31 = (n32 = (n34 = (n41 = (n42 = (n43 = 0)))))))))));
} else {
n11 = _arg1[0];
n12 = _arg1[1];
n13 = _arg1[2];
n14 = _arg1[3];
n21 = _arg1[4];
n22 = _arg1[5];
n23 = _arg1[6];
n24 = _arg1[7];
n31 = _arg1[8];
n32 = _arg1[9];
n33 = _arg1[10];
n34 = _arg1[11];
if (_arg1.length == 16){
n41 = _arg1[12];
n42 = _arg1[13];
n43 = _arg1[14];
n44 = _arg1[15];
} else {
n41 = (n42 = (n43 = 0));
n44 = 1;
};
};
}
public static function rotationMatrixWithReference(_arg1:Number3D, _arg2:Number, _arg3:Number3D):Matrix3D{
var _local4:Matrix3D;
_local4 = Matrix3D.translationMatrix(_arg3.x, -(_arg3.y), _arg3.z);
Matrix3D.translationMatrix(_arg3.x, -(_arg3.y), _arg3.z).calculateMultiply(_local4, Matrix3D.rotationMatrix(_arg1.x, _arg1.y, _arg1.z, _arg2));
_local4.calculateMultiply(_local4, Matrix3D.translationMatrix(-(_arg3.x), _arg3.y, -(_arg3.z)));
return (_local4);
}
public static function multiplyVector(_arg1:Matrix3D, _arg2:Number3D):void{
var _local3:Number;
var _local4:Number;
var _local5:Number;
_local3 = _arg2.x;
_local4 = _arg2.y;
_local5 = _arg2.z;
_arg2.x = ((((_local3 * _arg1.n11) + (_local4 * _arg1.n12)) + (_local5 * _arg1.n13)) + _arg1.n14);
_arg2.y = ((((_local3 * _arg1.n21) + (_local4 * _arg1.n22)) + (_local5 * _arg1.n23)) + _arg1.n24);
_arg2.z = ((((_local3 * _arg1.n31) + (_local4 * _arg1.n32)) + (_local5 * _arg1.n33)) + _arg1.n34);
}
public static function multiplyVector4x4(_arg1:Matrix3D, _arg2:Number3D):void{
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
_local3 = _arg2.x;
_local4 = _arg2.y;
_local5 = _arg2.z;
_local6 = (1 / ((((_local3 * _arg1.n41) + (_local4 * _arg1.n42)) + (_local5 * _arg1.n43)) + _arg1.n44));
_arg2.x = ((((_local3 * _arg1.n11) + (_local4 * _arg1.n12)) + (_local5 * _arg1.n13)) + _arg1.n14);
_arg2.y = ((((_local3 * _arg1.n21) + (_local4 * _arg1.n22)) + (_local5 * _arg1.n23)) + _arg1.n24);
_arg2.z = ((((_local3 * _arg1.n31) + (_local4 * _arg1.n32)) + (_local5 * _arg1.n33)) + _arg1.n34);
_arg2.x = (_arg2.x * _local6);
_arg2.y = (_arg2.y * _local6);
_arg2.z = (_arg2.z * _local6);
}
public static function multiply3x3(_arg1:Matrix3D, _arg2:Matrix3D):Matrix3D{
var _local3:Matrix3D;
_local3 = new (Matrix3D);
_local3.calculateMultiply3x3(_arg1, _arg2);
return (_local3);
}
public static function normalizeQuaternion(_arg1:Object):Object{
var _local2:Number;
_local2 = magnitudeQuaternion(_arg1);
_arg1.x = (_arg1.x / _local2);
_arg1.y = (_arg1.y / _local2);
_arg1.z = (_arg1.z / _local2);
_arg1.w = (_arg1.w / _local2);
return (_arg1);
}
public static function multiplyVector3x3(_arg1:Matrix3D, _arg2:Number3D):void{
var _local3:Number;
var _local4:Number;
var _local5:Number;
_local3 = _arg2.x;
_local4 = _arg2.y;
_local5 = _arg2.z;
_arg2.x = (((_local3 * _arg1.n11) + (_local4 * _arg1.n12)) + (_local5 * _arg1.n13));
_arg2.y = (((_local3 * _arg1.n21) + (_local4 * _arg1.n22)) + (_local5 * _arg1.n23));
_arg2.z = (((_local3 * _arg1.n31) + (_local4 * _arg1.n32)) + (_local5 * _arg1.n33));
}
public static function axis2quaternion(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Object{
var _local5:Number;
var _local6:Number;
var _local7:Object;
_local5 = Math.sin((_arg4 / 2));
_local6 = Math.cos((_arg4 / 2));
_local7 = new Object();
_local7.x = (_arg1 * _local5);
_local7.y = (_arg2 * _local5);
_local7.z = (_arg3 * _local5);
_local7.w = _local6;
return (normalizeQuaternion(_local7));
}
public static function translationMatrix(_arg1:Number, _arg2:Number, _arg3:Number):Matrix3D{
var _local4:Matrix3D;
_local4 = IDENTITY;
_local4.n14 = _arg1;
_local4.n24 = _arg2;
_local4.n34 = _arg3;
return (_local4);
}
public static function magnitudeQuaternion(_arg1:Object):Number{
return (Math.sqrt(((((_arg1.w * _arg1.w) + (_arg1.x * _arg1.x)) + (_arg1.y * _arg1.y)) + (_arg1.z * _arg1.z))));
}
public static function rotationX(_arg1:Number):Matrix3D{
var _local2:Matrix3D;
var _local3:Number;
var _local4:Number;
_local2 = IDENTITY;
_local3 = Math.cos(_arg1);
_local4 = Math.sin(_arg1);
_local2.n22 = _local3;
_local2.n23 = -(_local4);
_local2.n32 = _local4;
_local2.n33 = _local3;
return (_local2);
}
public static function rotationY(_arg1:Number):Matrix3D{
var _local2:Matrix3D;
var _local3:Number;
var _local4:Number;
_local2 = IDENTITY;
_local3 = Math.cos(_arg1);
_local4 = Math.sin(_arg1);
_local2.n11 = _local3;
_local2.n13 = -(_local4);
_local2.n31 = _local4;
_local2.n33 = _local3;
return (_local2);
}
public static function rotationZ(_arg1:Number):Matrix3D{
var _local2:Matrix3D;
var _local3:Number;
var _local4:Number;
_local2 = IDENTITY;
_local3 = Math.cos(_arg1);
_local4 = Math.sin(_arg1);
_local2.n11 = _local3;
_local2.n12 = -(_local4);
_local2.n21 = _local4;
_local2.n22 = _local3;
return (_local2);
}
public static function clone(_arg1:Matrix3D):Matrix3D{
return (new Matrix3D([_arg1.n11, _arg1.n12, _arg1.n13, _arg1.n14, _arg1.n21, _arg1.n22, _arg1.n23, _arg1.n24, _arg1.n31, _arg1.n32, _arg1.n33, _arg1.n34]));
}
public static function rotationMatrix(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Matrix3D=null):Matrix3D{
var _local6:Matrix3D;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
if (!_arg5){
_local6 = IDENTITY;
} else {
_local6 = _arg5;
};
_local7 = Math.cos(_arg4);
_local8 = Math.sin(_arg4);
_local9 = (1 - _local7);
_local10 = ((_arg1 * _arg2) * _local9);
_local11 = ((_arg2 * _arg3) * _local9);
_local12 = ((_arg1 * _arg3) * _local9);
_local13 = (_local8 * _arg3);
_local14 = (_local8 * _arg2);
_local15 = (_local8 * _arg1);
_local6.n11 = (_local7 + ((_arg1 * _arg1) * _local9));
_local6.n12 = (-(_local13) + _local10);
_local6.n13 = (_local14 + _local12);
_local6.n14 = 0;
_local6.n21 = (_local13 + _local10);
_local6.n22 = (_local7 + ((_arg2 * _arg2) * _local9));
_local6.n23 = (-(_local15) + _local11);
_local6.n24 = 0;
_local6.n31 = (-(_local14) + _local12);
_local6.n32 = (_local15 + _local11);
_local6.n33 = (_local7 + ((_arg3 * _arg3) * _local9));
_local6.n34 = 0;
return (_local6);
}
public static function add(_arg1:Matrix3D, _arg2:Matrix3D):Matrix3D{
var _local3:Matrix3D;
_local3 = new (Matrix3D);
_local3.calculateAdd(_arg1, _arg2);
return (_local3);
}
public static function multiply(_arg1:Matrix3D, _arg2:Matrix3D):Matrix3D{
var _local3:Matrix3D;
_local3 = new (Matrix3D);
_local3.calculateMultiply(_arg1, _arg2);
return (_local3);
}
public static function euler2quaternion(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Quaternion=null):Quaternion{
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Quaternion;
_local5 = Math.sin((_arg1 * 0.5));
_local6 = Math.cos((_arg1 * 0.5));
_local7 = Math.sin((_arg2 * 0.5));
_local8 = Math.cos((_arg2 * 0.5));
_local9 = Math.sin((_arg3 * 0.5));
_local10 = Math.cos((_arg3 * 0.5));
_local11 = (_local6 * _local8);
_local12 = (_local5 * _local7);
if (!_arg4){
_local13 = new Quaternion();
} else {
_local13 = _arg4;
};
_local13.x = ((_local9 * _local11) - (_local10 * _local12));
_local13.y = (((_local10 * _local5) * _local8) + ((_local9 * _local6) * _local7));
_local13.z = (((_local10 * _local6) * _local7) - ((_local9 * _local5) * _local8));
_local13.w = ((_local10 * _local11) + (_local9 * _local12));
return (_local13);
}
public static function quaternion2matrix(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Matrix3D=null):Matrix3D{
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Matrix3D;
_local6 = (_arg1 * _arg1);
_local7 = (_arg1 * _arg2);
_local8 = (_arg1 * _arg3);
_local9 = (_arg1 * _arg4);
_local10 = (_arg2 * _arg2);
_local11 = (_arg2 * _arg3);
_local12 = (_arg2 * _arg4);
_local13 = (_arg3 * _arg3);
_local14 = (_arg3 * _arg4);
if (!_arg5){
_local15 = IDENTITY;
} else {
_local15 = _arg5;
};
_local15.n11 = (1 - (2 * (_local10 + _local13)));
_local15.n12 = (2 * (_local7 - _local14));
_local15.n13 = (2 * (_local8 + _local12));
_local15.n21 = (2 * (_local7 + _local14));
_local15.n22 = (1 - (2 * (_local6 + _local13)));
_local15.n23 = (2 * (_local11 - _local9));
_local15.n31 = (2 * (_local8 - _local12));
_local15.n32 = (2 * (_local11 + _local9));
_local15.n33 = (1 - (2 * (_local6 + _local10)));
return (_local15);
}
public static function inverse(_arg1:Matrix3D):Matrix3D{
var _local2:Matrix3D;
_local2 = new (Matrix3D);
_local2.calculateInverse(_arg1);
return (_local2);
}
public static function euler2matrix(_arg1:Number3D):Matrix3D{
var _local2:Matrix3D;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
temp.reset();
_local2 = temp;
_local2 = temp;
_local3 = (_arg1.x * toRADIANS);
_local4 = (_arg1.y * toRADIANS);
_local5 = (_arg1.z * toRADIANS);
_local6 = Math.cos(_local3);
_local7 = Math.sin(_local3);
_local8 = Math.cos(_local4);
_local9 = Math.sin(_local4);
_local10 = Math.cos(_local5);
_local11 = Math.sin(_local5);
_local12 = (_local6 * _local9);
_local13 = (_local7 * _local9);
_local2.n11 = (_local8 * _local10);
_local2.n12 = (-(_local8) * _local11);
_local2.n13 = _local9;
_local2.n21 = ((_local13 * _local10) + (_local6 * _local11));
_local2.n22 = ((-(_local13) * _local11) + (_local6 * _local10));
_local2.n23 = (-(_local7) * _local8);
_local2.n31 = ((-(_local12) * _local10) + (_local7 * _local11));
_local2.n32 = ((_local12 * _local11) + (_local7 * _local10));
_local2.n33 = (_local6 * _local8);
return (_local2);
}
public static function scaleMatrix(_arg1:Number, _arg2:Number, _arg3:Number):Matrix3D{
var _local4:Matrix3D;
_local4 = IDENTITY;
_local4.n11 = _arg1;
_local4.n22 = _arg2;
_local4.n33 = _arg3;
return (_local4);
}
public static function rotateAxis(_arg1:Matrix3D, _arg2:Number3D):void{
var _local3:Number;
var _local4:Number;
var _local5:Number;
_local3 = _arg2.x;
_local4 = _arg2.y;
_local5 = _arg2.z;
_arg2.x = (((_local3 * _arg1.n11) + (_local4 * _arg1.n12)) + (_local5 * _arg1.n13));
_arg2.y = (((_local3 * _arg1.n21) + (_local4 * _arg1.n22)) + (_local5 * _arg1.n23));
_arg2.z = (((_local3 * _arg1.n31) + (_local4 * _arg1.n32)) + (_local5 * _arg1.n33));
_arg2.normalize();
}
public static function matrix2euler(_arg1:Matrix3D, _arg2:Number3D=null, _arg3:Number3D=null):Number3D{
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
_arg2 = ((_arg2) || (new Number3D()));
_local4 = (((_arg3) && ((_arg3.x == 1)))) ? 1 : Math.sqrt((((_arg1.n11 * _arg1.n11) + (_arg1.n21 * _arg1.n21)) + (_arg1.n31 * _arg1.n31)));
_local5 = (((_arg3) && ((_arg3.y == 1)))) ? 1 : Math.sqrt((((_arg1.n12 * _arg1.n12) + (_arg1.n22 * _arg1.n22)) + (_arg1.n32 * _arg1.n32)));
_local6 = (((_arg3) && ((_arg3.z == 1)))) ? 1 : Math.sqrt((((_arg1.n13 * _arg1.n13) + (_arg1.n23 * _arg1.n23)) + (_arg1.n33 * _arg1.n33)));
_local7 = (_arg1.n11 / _local4);
_local8 = (_arg1.n21 / _local5);
_local9 = (_arg1.n31 / _local6);
_local10 = (_arg1.n32 / _local6);
_local11 = (_arg1.n33 / _local6);
_local9 = ((_local9 > 1)) ? 1 : _local9;
_local9 = ((_local9 < -1)) ? -1 : _local9;
_arg2.y = Math.asin(-(_local9));
_arg2.z = Math.atan2(_local8, _local7);
_arg2.x = Math.atan2(_local10, _local11);
if (Papervision3D.useDEGREES){
_arg2.x = (_arg2.x * toDEGREES);
_arg2.y = (_arg2.y * toDEGREES);
_arg2.z = (_arg2.z * toDEGREES);
};
return (_arg2);
}
public static function multiplyQuaternion(_arg1:Object, _arg2:Object):Object{
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Object;
_local3 = _arg1.x;
_local4 = _arg1.y;
_local5 = _arg1.z;
_local6 = _arg1.w;
_local7 = _arg2.x;
_local8 = _arg2.y;
_local9 = _arg2.z;
_local10 = _arg2.w;
_local11 = new Object();
_local11.x = ((((_local6 * _local7) + (_local3 * _local10)) + (_local4 * _local9)) - (_local5 * _local8));
_local11.y = ((((_local6 * _local8) + (_local4 * _local10)) + (_local5 * _local7)) - (_local3 * _local9));
_local11.z = ((((_local6 * _local9) + (_local5 * _local10)) + (_local3 * _local8)) - (_local4 * _local7));
_local11.w = ((((_local6 * _local10) - (_local3 * _local7)) - (_local4 * _local8)) - (_local5 * _local9));
return (_local11);
}
public static function get IDENTITY():Matrix3D{
return (new Matrix3D([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]));
}
}
}//package org.papervision3d.core.math
Section 90
//Number2D (org.papervision3d.core.math.Number2D)
package org.papervision3d.core.math {
import org.papervision3d.*;
public class Number2D {
public var x:Number;
public var y:Number;
public static const DEGTORAD:Number = 0.0174532925199433;
public static const RADTODEG:Number = 57.2957795130823;
public function Number2D(_arg1:Number=0, _arg2:Number=0){
this.x = _arg1;
this.y = _arg2;
}
public function divideEq(_arg1:Number):void{
x = (x / _arg1);
y = (y / _arg1);
}
public function copyTo(_arg1:Number2D):void{
_arg1.x = this.x;
_arg1.y = this.y;
}
public function get moduloSquared():Number{
return (((this.x * this.x) + (this.y * this.y)));
}
public function angle():Number{
if (Papervision3D.useDEGREES){
return ((RADTODEG * Math.atan2(y, x)));
};
return (Math.atan2(y, x));
}
public function reset(_arg1:Number=0, _arg2:Number=0):void{
this.x = _arg1;
this.y = _arg2;
}
public function isModuloGreaterThan(_arg1:Number):Boolean{
return ((moduloSquared > (_arg1 * _arg1)));
}
public function clone():Number2D{
return (new Number2D(this.x, this.y));
}
public function reverse():void{
this.x = -(this.x);
this.y = -(this.y);
}
public function plusEq(_arg1:Number2D):void{
x = (x + _arg1.x);
y = (y + _arg1.y);
}
public function rotate(_arg1:Number):void{
var _local2:Number;
var _local3:Number;
var _local4:Number2D;
if (Papervision3D.useDEGREES){
_arg1 = (_arg1 * DEGTORAD);
};
_local2 = Math.cos(_arg1);
_local3 = Math.sin(_arg1);
_local4 = clone();
this.x = ((_local4.x * _local2) - (_local4.y * _local3));
this.y = ((_local4.x * _local3) + (_local4.y * _local2));
}
public function toString():String{
var _local1:Number;
var _local2:Number;
_local1 = (Math.round((this.x * 1000)) / 1000);
_local2 = (Math.round((this.y * 1000)) / 1000);
return ((((("[" + _local1) + ", ") + _local2) + "]"));
}
public function isModuloEqualTo(_arg1:Number):Boolean{
return ((moduloSquared == (_arg1 * _arg1)));
}
public function multiplyEq(_arg1:Number):void{
x = (x * _arg1);
y = (y * _arg1);
}
public function normalise():void{
var _local1:Number;
_local1 = this.modulo;
this.x = (this.x / _local1);
this.y = (this.y / _local1);
}
public function get modulo():Number{
return (Math.sqrt(((x * x) + (y * y))));
}
public function isModuloLessThan(_arg1:Number):Boolean{
return ((moduloSquared < (_arg1 * _arg1)));
}
public function minusEq(_arg1:Number2D):void{
x = (x - _arg1.x);
y = (y - _arg1.y);
}
public function copyFrom(_arg1:Number2D):void{
this.x = _arg1.x;
this.y = _arg1.y;
}
public static function multiplyScalar(_arg1:Number2D, _arg2:Number):Number2D{
return (new Number2D((_arg1.x * _arg2), (_arg1.y * _arg2)));
}
public static function add(_arg1:Number2D, _arg2:Number2D):Number2D{
return (new Number2D((_arg1.x = (_arg1.x + _arg2.x)), (_arg1.y + _arg2.y)));
}
public static function dot(_arg1:Number2D, _arg2:Number2D):Number{
return (((_arg1.x * _arg2.x) + (_arg1.y * _arg2.y)));
}
public static function subtract(_arg1:Number2D, _arg2:Number2D):Number2D{
return (new Number2D((_arg1.x - _arg2.x), (_arg1.y - _arg2.y)));
}
}
}//package org.papervision3d.core.math
Section 91
//Number3D (org.papervision3d.core.math.Number3D)
package org.papervision3d.core.math {
import org.papervision3d.*;
public class Number3D {
public var z:Number;
public var x:Number;
public var y:Number;
public static var toDEGREES:Number = (180 / Math.PI);
private static var temp:Number3D = Number3D.ZERO;
public static var toRADIANS:Number = (Math.PI / 180);
public function Number3D(_arg1:Number=0, _arg2:Number=0, _arg3:Number=0){
this.x = _arg1;
this.y = _arg2;
this.z = _arg3;
}
public function normalize():void{
var _local1:Number;
_local1 = this.modulo;
if (((!((_local1 == 0))) && (!((_local1 == 1))))){
this.x = (this.x / _local1);
this.y = (this.y / _local1);
this.z = (this.z / _local1);
};
}
public function copyTo(_arg1:Number3D):void{
_arg1.x = x;
_arg1.y = y;
_arg1.z = z;
}
public function get moduloSquared():Number{
return ((((this.x * this.x) + (this.y * this.y)) + (this.z * this.z)));
}
public function reset(_arg1:Number=0, _arg2:Number=0, _arg3:Number=0):void{
x = _arg1;
y = _arg2;
z = _arg3;
}
public function isModuloGreaterThan(_arg1:Number):Boolean{
return ((moduloSquared > (_arg1 * _arg1)));
}
public function rotateX(_arg1:Number):void{
var _local2:Number;
var _local3:Number;
if (Papervision3D.useDEGREES){
_arg1 = (_arg1 * toRADIANS);
};
_local2 = Math.cos(_arg1);
_local3 = Math.sin(_arg1);
temp.copyFrom(this);
this.y = ((temp.y * _local2) - (temp.z * _local3));
this.z = ((temp.y * _local3) + (temp.z * _local2));
}
public function rotateY(_arg1:Number):void{
var _local2:Number;
var _local3:Number;
if (Papervision3D.useDEGREES){
_arg1 = (_arg1 * toRADIANS);
};
_local2 = Math.cos(_arg1);
_local3 = Math.sin(_arg1);
temp.copyFrom(this);
this.x = ((temp.x * _local2) + (temp.z * _local3));
this.z = ((temp.x * -(_local3)) + (temp.z * _local2));
}
public function rotateZ(_arg1:Number):void{
var _local2:Number;
var _local3:Number;
if (Papervision3D.useDEGREES){
_arg1 = (_arg1 * toRADIANS);
};
_local2 = Math.cos(_arg1);
_local3 = Math.sin(_arg1);
temp.copyFrom(this);
this.x = ((temp.x * _local2) - (temp.y * _local3));
this.y = ((temp.x * _local3) + (temp.y * _local2));
}
public function clone():Number3D{
return (new Number3D(this.x, this.y, this.z));
}
public function plusEq(_arg1:Number3D):void{
x = (x + _arg1.x);
y = (y + _arg1.y);
z = (z + _arg1.z);
}
public function toString():String{
return (((((("x:" + (Math.round((x * 100)) / 100)) + " y:") + (Math.round((y * 100)) / 100)) + " z:") + (Math.round((z * 100)) / 100)));
}
public function isModuloEqualTo(_arg1:Number):Boolean{
return ((moduloSquared == (_arg1 * _arg1)));
}
public function multiplyEq(_arg1:Number):void{
x = (x * _arg1);
y = (y * _arg1);
z = (z * _arg1);
}
public function get modulo():Number{
return (Math.sqrt((((this.x * this.x) + (this.y * this.y)) + (this.z * this.z))));
}
public function isModuloLessThan(_arg1:Number):Boolean{
return ((moduloSquared < (_arg1 * _arg1)));
}
public function minusEq(_arg1:Number3D):void{
x = (x - _arg1.x);
y = (y - _arg1.y);
z = (z - _arg1.z);
}
public function copyFrom(_arg1:Number3D):void{
x = _arg1.x;
y = _arg1.y;
z = _arg1.z;
}
public static function sub(_arg1:Number3D, _arg2:Number3D):Number3D{
return (new Number3D((_arg1.x - _arg2.x), (_arg1.y - _arg2.y), (_arg1.z - _arg2.z)));
}
public static function add(_arg1:Number3D, _arg2:Number3D):Number3D{
return (new Number3D((_arg1.x + _arg2.x), (_arg1.y + _arg2.y), (_arg1.z + _arg2.z)));
}
public static function cross(_arg1:Number3D, _arg2:Number3D, _arg3:Number3D=null):Number3D{
if (!_arg3){
_arg3 = ZERO;
};
_arg3.reset(((_arg2.y * _arg1.z) - (_arg2.z * _arg1.y)), ((_arg2.z * _arg1.x) - (_arg2.x * _arg1.z)), ((_arg2.x * _arg1.y) - (_arg2.y * _arg1.x)));
return (_arg3);
}
public static function dot(_arg1:Number3D, _arg2:Number3D):Number{
return ((((_arg1.x * _arg2.x) + (_arg1.y * _arg2.y)) + (_arg2.z * _arg1.z)));
}
public static function get ZERO():Number3D{
return (new Number3D(0, 0, 0));
}
}
}//package org.papervision3d.core.math
Section 92
//NumberUV (org.papervision3d.core.math.NumberUV)
package org.papervision3d.core.math {
public class NumberUV {
public var u:Number;
public var v:Number;
public function NumberUV(_arg1:Number=0, _arg2:Number=0){
this.u = _arg1;
this.v = _arg2;
}
public function toString():String{
return (((("u:" + u) + " v:") + v));
}
public function clone():NumberUV{
return (new NumberUV(this.u, this.v));
}
public static function get ZERO():NumberUV{
return (new NumberUV(0, 0));
}
}
}//package org.papervision3d.core.math
Section 93
//Quaternion (org.papervision3d.core.math.Quaternion)
package org.papervision3d.core.math {
public class Quaternion {
private var _matrix:Matrix3D;
public var w:Number;
public var x:Number;
public var y:Number;
public var z:Number;
public static const EPSILON:Number = 1E-6;
public static const DEGTORAD:Number = 0.0174532925199433;
public static const RADTODEG:Number = 57.2957795130823;
public function Quaternion(_arg1:Number=0, _arg2:Number=0, _arg3:Number=0, _arg4:Number=1){
this.x = _arg1;
this.y = _arg2;
this.z = _arg3;
this.w = _arg4;
_matrix = Matrix3D.IDENTITY;
}
public function setFromEuler(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Boolean=false):void{
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
if (_arg4){
_arg1 = (_arg1 * DEGTORAD);
_arg2 = (_arg2 * DEGTORAD);
_arg3 = (_arg3 * DEGTORAD);
};
_local5 = Math.sin((_arg1 * 0.5));
_local6 = Math.cos((_arg1 * 0.5));
_local7 = Math.sin((_arg2 * 0.5));
_local8 = Math.cos((_arg2 * 0.5));
_local9 = Math.sin((_arg3 * 0.5));
_local10 = Math.cos((_arg3 * 0.5));
_local11 = (_local6 * _local8);
_local12 = (_local5 * _local7);
this.x = ((_local9 * _local11) - (_local10 * _local12));
this.y = (((_local10 * _local5) * _local8) + ((_local9 * _local6) * _local7));
this.z = (((_local10 * _local6) * _local7) - ((_local9 * _local5) * _local8));
this.w = ((_local10 * _local11) + (_local9 * _local12));
}
public function setFromAxisAngle(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):void{
var _local5:Number;
var _local6:Number;
_local5 = Math.sin((_arg4 / 2));
_local6 = Math.cos((_arg4 / 2));
this.x = (_arg1 * _local5);
this.y = (_arg2 * _local5);
this.z = (_arg3 * _local5);
this.w = _local6;
this.normalize();
}
public function get matrix():Matrix3D{
var _local1:Number;
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
_local1 = (x * x);
_local2 = (x * y);
_local3 = (x * z);
_local4 = (x * w);
_local5 = (y * y);
_local6 = (y * z);
_local7 = (y * w);
_local8 = (z * z);
_local9 = (z * w);
_matrix.n11 = (1 - (2 * (_local5 + _local8)));
_matrix.n12 = (2 * (_local2 - _local9));
_matrix.n13 = (2 * (_local3 + _local7));
_matrix.n21 = (2 * (_local2 + _local9));
_matrix.n22 = (1 - (2 * (_local1 + _local8)));
_matrix.n23 = (2 * (_local6 - _local4));
_matrix.n31 = (2 * (_local3 - _local7));
_matrix.n32 = (2 * (_local6 + _local4));
_matrix.n33 = (1 - (2 * (_local1 + _local5)));
return (_matrix);
}
public function calculateMultiply(_arg1:Quaternion, _arg2:Quaternion):void{
this.x = ((((_arg1.w * _arg2.x) + (_arg1.x * _arg2.w)) + (_arg1.y * _arg2.z)) - (_arg1.z * _arg2.y));
this.y = ((((_arg1.w * _arg2.y) - (_arg1.x * _arg2.z)) + (_arg1.y * _arg2.w)) + (_arg1.z * _arg2.x));
this.z = ((((_arg1.w * _arg2.z) + (_arg1.x * _arg2.y)) - (_arg1.y * _arg2.x)) + (_arg1.z * _arg2.w));
this.w = ((((_arg1.w * _arg2.w) - (_arg1.x * _arg2.x)) - (_arg1.y * _arg2.y)) - (_arg1.z * _arg2.z));
}
public function toString():String{
return (((((((("Quaternion: x:" + this.x) + " y:") + this.y) + " z:") + this.z) + " w:") + this.w));
}
public function normalize():void{
var _local1:Number;
var _local2:Number;
_local1 = this.modulo;
if (Math.abs(_local1) < EPSILON){
x = (y = (z = 0));
w = 1;
} else {
_local2 = (1 / _local1);
x = (x * _local2);
y = (y * _local2);
z = (z * _local2);
w = (w * _local2);
};
}
public function get modulo():Number{
return (Math.sqrt(((((x * x) + (y * y)) + (z * z)) + (w * w))));
}
public function toEuler():Number3D{
var _local1:Number3D;
var _local2:Quaternion;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
_local1 = new Number3D();
_local2 = this;
_local3 = ((_local2.x * _local2.y) + (_local2.z * _local2.w));
if (_local3 > 0.499){
_local1.x = (2 * Math.atan2(_local2.x, _local2.w));
_local1.y = (Math.PI / 2);
_local1.z = 0;
return (_local1);
};
if (_local3 < -0.499){
_local1.x = (-2 * Math.atan2(_local2.x, _local2.w));
_local1.y = (-(Math.PI) / 2);
_local1.z = 0;
return (_local1);
};
_local4 = (_local2.x * _local2.x);
_local5 = (_local2.y * _local2.y);
_local6 = (_local2.z * _local2.z);
_local1.x = Math.atan2((((2 * _local2.y) * _local2.w) - ((2 * _local2.x) * _local2.z)), ((1 - (2 * _local5)) - (2 * _local6)));
_local1.y = Math.asin((2 * _local3));
_local1.z = Math.atan2((((2 * _local2.x) * _local2.w) - ((2 * _local2.y) * _local2.z)), ((1 - (2 * _local4)) - (2 * _local6)));
return (_local1);
}
public function clone():Quaternion{
return (new Quaternion(this.x, this.y, this.z, this.w));
}
public function mult(_arg1:Quaternion):void{
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:Number;
_local2 = this.w;
_local3 = this.x;
_local4 = this.y;
_local5 = this.z;
x = ((((_local2 * _arg1.x) + (_local3 * _arg1.w)) + (_local4 * _arg1.z)) - (_local5 * _arg1.y));
y = ((((_local2 * _arg1.y) - (_local3 * _arg1.z)) + (_local4 * _arg1.w)) + (_local5 * _arg1.x));
z = ((((_local2 * _arg1.z) + (_local3 * _arg1.y)) - (_local4 * _arg1.x)) + (_local5 * _arg1.w));
w = ((((_local2 * _arg1.w) - (_local3 * _arg1.x)) - (_local4 * _arg1.y)) - (_local5 * _arg1.z));
}
public static function sub(_arg1:Quaternion, _arg2:Quaternion):Quaternion{
return (new Quaternion((_arg1.x - _arg2.x), (_arg1.y - _arg2.y), (_arg1.z - _arg2.z), (_arg1.w - _arg2.w)));
}
public static function add(_arg1:Quaternion, _arg2:Quaternion):Quaternion{
return (new Quaternion((_arg1.x + _arg2.x), (_arg1.y + _arg2.y), (_arg1.z + _arg2.z), (_arg1.w + _arg2.w)));
}
public static function createFromEuler(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Boolean=false):Quaternion{
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Quaternion;
if (_arg4){
_arg1 = (_arg1 * DEGTORAD);
_arg2 = (_arg2 * DEGTORAD);
_arg3 = (_arg3 * DEGTORAD);
};
_local5 = Math.sin((_arg1 * 0.5));
_local6 = Math.cos((_arg1 * 0.5));
_local7 = Math.sin((_arg2 * 0.5));
_local8 = Math.cos((_arg2 * 0.5));
_local9 = Math.sin((_arg3 * 0.5));
_local10 = Math.cos((_arg3 * 0.5));
_local11 = (_local6 * _local8);
_local12 = (_local5 * _local7);
_local13 = new (Quaternion);
_local13.x = ((_local9 * _local11) - (_local10 * _local12));
_local13.y = (((_local10 * _local5) * _local8) + ((_local9 * _local6) * _local7));
_local13.z = (((_local10 * _local6) * _local7) - ((_local9 * _local5) * _local8));
_local13.w = ((_local10 * _local11) + (_local9 * _local12));
return (_local13);
}
public static function createFromMatrix(_arg1:Matrix3D):Quaternion{
var _local2:Quaternion;
var _local3:Number;
var _local4:Array;
var _local5:int;
var _local6:int;
var _local7:int;
var _local8:Number;
var _local9:Array;
var _local10:Array;
_local2 = new (Quaternion);
_local4 = new Array(4);
_local8 = ((_arg1.n11 + _arg1.n22) + _arg1.n33);
if (_local8 > 0){
_local3 = Math.sqrt((_local8 + 1));
_local2.w = (_local3 / 2);
_local3 = (0.5 / _local3);
_local2.x = ((_arg1.n32 - _arg1.n23) * _local3);
_local2.y = ((_arg1.n13 - _arg1.n31) * _local3);
_local2.z = ((_arg1.n21 - _arg1.n12) * _local3);
} else {
_local9 = [1, 2, 0];
_local10 = [[_arg1.n11, _arg1.n12, _arg1.n13, _arg1.n14], [_arg1.n21, _arg1.n22, _arg1.n23, _arg1.n24], [_arg1.n31, _arg1.n32, _arg1.n33, _arg1.n34]];
_local5 = 0;
if (_local10[1][1] > _local10[0][0]){
_local5 = 1;
};
if (_local10[2][2] > _local10[_local5][_local5]){
_local5 = 2;
};
_local6 = _local9[_local5];
_local7 = _local9[_local6];
_local3 = Math.sqrt(((_local10[_local5][_local5] - (_local10[_local6][_local6] + _local10[_local7][_local7])) + 1));
_local4[_local5] = (_local3 * 0.5);
if (_local3 != 0){
_local3 = (0.5 / _local3);
};
_local4[3] = ((_local10[_local7][_local6] - _local10[_local6][_local7]) * _local3);
_local4[_local6] = ((_local10[_local6][_local5] + _local10[_local5][_local6]) * _local3);
_local4[_local7] = ((_local10[_local7][_local5] + _local10[_local5][_local7]) * _local3);
_local2.x = _local4[0];
_local2.y = _local4[1];
_local2.z = _local4[2];
_local2.w = _local4[3];
};
return (_local2);
}
public static function dot(_arg1:Quaternion, _arg2:Quaternion):Number{
return (((((_arg1.x * _arg2.x) + (_arg1.y * _arg2.y)) + (_arg1.z * _arg2.z)) + (_arg1.w * _arg2.w)));
}
public static function multiply(_arg1:Quaternion, _arg2:Quaternion):Quaternion{
var _local3:Quaternion;
_local3 = new (Quaternion);
_local3.x = ((((_arg1.w * _arg2.x) + (_arg1.x * _arg2.w)) + (_arg1.y * _arg2.z)) - (_arg1.z * _arg2.y));
_local3.y = ((((_arg1.w * _arg2.y) - (_arg1.x * _arg2.z)) + (_arg1.y * _arg2.w)) + (_arg1.z * _arg2.x));
_local3.z = ((((_arg1.w * _arg2.z) + (_arg1.x * _arg2.y)) - (_arg1.y * _arg2.x)) + (_arg1.z * _arg2.w));
_local3.w = ((((_arg1.w * _arg2.w) - (_arg1.x * _arg2.x)) - (_arg1.y * _arg2.y)) - (_arg1.z * _arg2.z));
return (_local3);
}
public static function createFromAxisAngle(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Quaternion{
var _local5:Quaternion;
_local5 = new (Quaternion);
_local5.setFromAxisAngle(_arg1, _arg2, _arg3, _arg4);
return (_local5);
}
public static function slerp(_arg1:Quaternion, _arg2:Quaternion, _arg3:Number):Quaternion{
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
_local4 = ((((_arg1.w * _arg2.w) + (_arg1.x * _arg2.x)) + (_arg1.y * _arg2.y)) + (_arg1.z * _arg2.z));
if (_local4 < 0){
_arg1.x = (_arg1.x * -1);
_arg1.y = (_arg1.y * -1);
_arg1.z = (_arg1.z * -1);
_arg1.w = (_arg1.w * -1);
_local4 = (_local4 * -1);
};
if ((_local4 + 1) > EPSILON){
if ((1 - _local4) >= EPSILON){
_local7 = Math.acos(_local4);
_local8 = (1 / Math.sin(_local7));
_local5 = (Math.sin((_local7 * (1 - _arg3))) * _local8);
_local6 = (Math.sin((_local7 * _arg3)) * _local8);
} else {
_local5 = (1 - _arg3);
_local6 = _arg3;
};
} else {
_arg2.y = -(_arg1.y);
_arg2.x = _arg1.x;
_arg2.w = -(_arg1.w);
_arg2.z = _arg1.z;
_local5 = Math.sin((Math.PI * (0.5 - _arg3)));
_local6 = Math.sin((Math.PI * _arg3));
};
return (new Quaternion(((_local5 * _arg1.x) + (_local6 * _arg2.x)), ((_local5 * _arg1.y) + (_local6 * _arg2.y)), ((_local5 * _arg1.z) + (_local6 * _arg2.z)), ((_local5 * _arg1.w) + (_local6 * _arg2.w))));
}
public static function createFromOrthoMatrix(_arg1:Matrix3D):Quaternion{
var _local2:Quaternion;
_local2 = new (Quaternion);
_local2.w = (Math.sqrt(Math.max(0, (((1 + _arg1.n11) + _arg1.n22) + _arg1.n33))) / 2);
_local2.x = (Math.sqrt(Math.max(0, (((1 + _arg1.n11) - _arg1.n22) - _arg1.n33))) / 2);
_local2.y = (Math.sqrt(Math.max(0, (((1 - _arg1.n11) + _arg1.n22) - _arg1.n33))) / 2);
_local2.z = (Math.sqrt(Math.max(0, (((1 - _arg1.n11) - _arg1.n22) + _arg1.n33))) / 2);
_local2.x = (((_arg1.n32 - _arg1.n23) < 0)) ? ((_local2.x < 0)) ? _local2.x : -(_local2.x) : ((_local2.x < 0)) ? -(_local2.x) : _local2.x;
_local2.y = (((_arg1.n13 - _arg1.n31) < 0)) ? ((_local2.y < 0)) ? _local2.y : -(_local2.y) : ((_local2.y < 0)) ? -(_local2.y) : _local2.y;
_local2.z = (((_arg1.n21 - _arg1.n12) < 0)) ? ((_local2.z < 0)) ? _local2.z : -(_local2.z) : ((_local2.z < 0)) ? -(_local2.z) : _local2.z;
return (_local2);
}
public static function conjugate(_arg1:Quaternion):Quaternion{
var _local2:Quaternion;
_local2 = new (Quaternion);
_local2.x = -(_arg1.x);
_local2.y = -(_arg1.y);
_local2.z = -(_arg1.z);
_local2.w = _arg1.w;
return (_local2);
}
public static function slerpOld(_arg1:Quaternion, _arg2:Quaternion, _arg3:Number):Quaternion{
var _local4:Quaternion;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
_local4 = new (Quaternion);
_local5 = ((((_arg1.w * _arg2.w) + (_arg1.x * _arg2.x)) + (_arg1.y * _arg2.y)) + (_arg1.z * _arg2.z));
if (Math.abs(_local5) >= 1){
_local4.w = _arg1.w;
_local4.x = _arg1.x;
_local4.y = _arg1.y;
_local4.z = _arg1.z;
return (_local4);
};
_local6 = Math.acos(_local5);
_local7 = Math.sqrt((1 - (_local5 * _local5)));
if (Math.abs(_local7) < 0.001){
_local4.w = ((_arg1.w * 0.5) + (_arg2.w * 0.5));
_local4.x = ((_arg1.x * 0.5) + (_arg2.x * 0.5));
_local4.y = ((_arg1.y * 0.5) + (_arg2.y * 0.5));
_local4.z = ((_arg1.z * 0.5) + (_arg2.z * 0.5));
return (_local4);
};
_local8 = (Math.sin(((1 - _arg3) * _local6)) / _local7);
_local9 = (Math.sin((_arg3 * _local6)) / _local7);
_local4.w = ((_arg1.w * _local8) + (_arg2.w * _local9));
_local4.x = ((_arg1.x * _local8) + (_arg2.x * _local9));
_local4.y = ((_arg1.y * _local8) + (_arg2.y * _local9));
_local4.z = ((_arg1.z * _local8) + (_arg2.z * _local9));
return (_local4);
}
}
}//package org.papervision3d.core.math
Section 94
//pv3dview (org.papervision3d.core.ns.pv3dview)
package org.papervision3d.core.ns {
public namespace pv3dview;
}//package org.papervision3d.core.ns
Section 95
//CameraObject3D (org.papervision3d.core.proto.CameraObject3D)
package org.papervision3d.core.proto {
import org.papervision3d.core.math.*;
import org.papervision3d.core.render.data.*;
import flash.geom.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.log.*;
import org.papervision3d.core.culling.*;
import org.papervision3d.*;
public class CameraObject3D extends DisplayObject3D {
protected var _orthoScale:Number;// = 1
protected var _orthoScaleMatrix:Matrix3D;
protected var _useCulling:Boolean;
public var eye:Matrix3D;
public var culler:IObjectCuller;
public var sort:Boolean;
public var viewport:Rectangle;
protected var _far:Number;
protected var _ortho:Boolean;
public var zoom:Number;
public var yUP:Boolean;
protected var _target:DisplayObject3D;
public var focus:Number;
protected var _useProjectionMatrix:Boolean;
public static var DEFAULT_VIEWPORT:Rectangle = new Rectangle(0, 0, 550, 400);
public static var DEFAULT_POS:Number3D = new Number3D(0, 0, -1000);
public static var DEFAULT_UP:Number3D = new Number3D(0, 1, 0);
private static var _flipY:Matrix3D = Matrix3D.scaleMatrix(1, -1, 1);
public function CameraObject3D(_arg1:Number=500, _arg2:Number=3){
_orthoScale = 1;
super();
this.x = DEFAULT_POS.x;
this.y = DEFAULT_POS.y;
this.z = DEFAULT_POS.z;
this.zoom = _arg2;
this.focus = _arg1;
this.eye = Matrix3D.IDENTITY;
this.viewport = DEFAULT_VIEWPORT;
this.sort = true;
_ortho = false;
_orthoScaleMatrix = Matrix3D.scaleMatrix(1, 1, 1);
if (Papervision3D.useRIGHTHANDED){
DEFAULT_UP.y = -1;
this.yUP = false;
this.lookAt(DisplayObject3D.ZERO);
} else {
this.yUP = true;
};
}
public function get far():Number{
return (_far);
}
public function set target(_arg1:DisplayObject3D):void{
_target = _arg1;
}
public function set ortho(_arg1:Boolean):void{
_ortho = _arg1;
}
public function set far(_arg1:Number):void{
if (_arg1 > this.focus){
_far = _arg1;
};
}
public function get near():Number{
return (this.focus);
}
override public function lookAt(_arg1:DisplayObject3D, _arg2:Number3D=null):void{
if (this.yUP){
super.lookAt(_arg1, _arg2);
} else {
super.lookAt(_arg1, ((_arg2) || (DEFAULT_UP)));
};
}
public function projectVertices(_arg1:DisplayObject3D, _arg2:RenderSessionData):Number{
return (0);
}
public function set useProjectionMatrix(_arg1:Boolean):void{
_useProjectionMatrix = _arg1;
}
public function set useCulling(_arg1:Boolean):void{
_useCulling = _arg1;
}
public function set near(_arg1:Number):void{
if (_arg1 > 0){
this.focus = _arg1;
};
}
public function unproject(_arg1:Number, _arg2:Number):Number3D{
var _local3:Number;
var _local4:Number3D;
_local3 = ((focus * zoom) / focus);
_local4 = new Number3D((_arg1 / _local3), (-(_arg2) / _local3), focus);
Matrix3D.multiplyVector3x3(transform, _local4);
return (_local4);
}
public function transformView(_arg1:Matrix3D=null):void{
if (this.yUP){
eye.calculateMultiply(((_arg1) || (this.transform)), _flipY);
eye.invert();
} else {
eye.calculateInverse(((_arg1) || (this.transform)));
};
}
public function get target():DisplayObject3D{
return (_target);
}
public function pan(_arg1:Number):void{
}
public function set fov(_arg1:Number):void{
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
if (((!(viewport)) || (viewport.isEmpty()))){
PaperLogger.warning("CameraObject3D#viewport not set, can't set fov!");
return;
};
_local2 = 0;
_local3 = 0;
_local4 = 0;
if (_target){
_local2 = _target.world.n14;
_local3 = _target.world.n24;
_local4 = _target.world.n34;
};
_local5 = (this.x - _local2);
_local6 = (this.y - _local3);
_local7 = (this.z - _local4);
_local8 = (viewport.height / 2);
_local9 = (Math.sqrt((((_local5 * _local5) + (_local6 * _local6)) + (_local7 * _local7))) + this.focus);
_local10 = (180 / Math.PI);
_local11 = ((_arg1 / 2) * (Math.PI / 180));
this.focus = ((_local8 / Math.tan(_local11)) / this.zoom);
}
public function get useProjectionMatrix():Boolean{
return (_useProjectionMatrix);
}
public function get ortho():Boolean{
return (_ortho);
}
public function get orthoScale():Number{
return (_orthoScale);
}
public function tilt(_arg1:Number):void{
}
public function get fov():Number{
var _local1:Number;
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
if (((!(viewport)) || (viewport.isEmpty()))){
PaperLogger.warning("CameraObject3D#viewport not set, can't calculate fov!");
return (NaN);
};
_local1 = 0;
_local2 = 0;
_local3 = 0;
if (_target){
_local1 = _target.world.n14;
_local2 = _target.world.n24;
_local3 = _target.world.n34;
};
_local4 = (this.x - _local1);
_local5 = (this.y - _local2);
_local6 = (this.z - _local3);
_local7 = this.focus;
_local8 = this.zoom;
_local9 = (Math.sqrt((((_local4 * _local4) + (_local5 * _local5)) + (_local6 * _local6))) + _local7);
_local10 = (viewport.height / 2);
_local11 = (180 / Math.PI);
return (((Math.atan(((((_local9 / _local7) / _local8) * _local10) / _local9)) * _local11) * 2));
}
public function orbit(_arg1:Number, _arg2:Number, _arg3:Boolean=true, _arg4:DisplayObject3D=null):void{
}
public function get useCulling():Boolean{
return (_useCulling);
}
public function set orthoScale(_arg1:Number):void{
_orthoScale = ((_arg1 > 0)) ? _arg1 : 0.0001;
_orthoScaleMatrix.n11 = _orthoScale;
_orthoScaleMatrix.n22 = _orthoScale;
_orthoScaleMatrix.n33 = _orthoScale;
}
}
}//package org.papervision3d.core.proto
Section 96
//DisplayObjectContainer3D (org.papervision3d.core.proto.DisplayObjectContainer3D)
package org.papervision3d.core.proto {
import flash.events.*;
import org.papervision3d.objects.*;
import flash.utils.*;
public class DisplayObjectContainer3D extends EventDispatcher {
protected var _childrenByName:Object;
private var _childrenTotal:int;
public var root:DisplayObjectContainer3D;
protected var _children:Dictionary;
public function DisplayObjectContainer3D():void{
this._children = new Dictionary(false);
this._childrenByName = new Dictionary(true);
this._childrenTotal = 0;
}
public function addChild(_arg1:DisplayObject3D, _arg2:String=null):DisplayObject3D{
_arg2 = ((((_arg2) || (_arg1.name))) || (String(_arg1.id)));
this._children[_arg1] = _arg2;
this._childrenByName[_arg2] = _arg1;
this._childrenTotal++;
_arg1.parent = this;
_arg1.root = this.root;
return (_arg1);
}
private function findChildByName(_arg1:String, _arg2:DisplayObject3D=null):DisplayObject3D{
var _local3:DisplayObject3D;
var _local4:DisplayObject3D;
_arg2 = ((_arg2) || (DisplayObject3D(this)));
if (!_arg2){
return (null);
};
if (_arg2.name == _arg1){
return (_arg2);
};
for each (_local3 in _arg2.children) {
_local4 = findChildByName(_arg1, _local3);
if (_local4){
return (_local4);
};
};
return (null);
}
public function getChildByName(_arg1:String, _arg2:Boolean=false):DisplayObject3D{
if (_arg2){
return (findChildByName(_arg1));
};
return (this._childrenByName[_arg1]);
}
public function get numChildren():int{
return (this._childrenTotal);
}
public function removeChildByName(_arg1:String):DisplayObject3D{
return (removeChild(getChildByName(_arg1)));
}
override public function toString():String{
return (childrenList());
}
public function addChildren(_arg1:DisplayObject3D):DisplayObjectContainer3D{
var _local2:DisplayObject3D;
for each (_local2 in _arg1.children) {
_arg1.removeChild(_local2);
this.addChild(_local2);
};
return (this);
}
public function removeChild(_arg1:DisplayObject3D):DisplayObject3D{
if (_arg1){
delete this._childrenByName[this._children[_arg1]];
delete this._children[_arg1];
_arg1.parent = null;
_arg1.root = null;
_childrenTotal--;
return (_arg1);
};
return (null);
}
public function childrenList():String{
var _local1:String;
var _local2:String;
_local1 = "";
for (_local2 in this._children) {
_local1 = (_local1 + (_local2 + "\n"));
};
return (_local1);
}
public function get children():Object{
return (this._childrenByName);
}
}
}//package org.papervision3d.core.proto
Section 97
//GeometryObject3D (org.papervision3d.core.proto.GeometryObject3D)
package org.papervision3d.core.proto {
import flash.events.*;
import org.papervision3d.core.math.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.objects.*;
import flash.utils.*;
public class GeometryObject3D extends EventDispatcher {
protected var _boundingSphereDirty:Boolean;// = true
public var dirty:Boolean;
protected var _aabbDirty:Boolean;// = true
public var _ready:Boolean;// = false
protected var _boundingSphere:BoundingSphere;
public var faces:Array;
private var _numInstances:uint;// = 0
public var vertices:Array;
protected var _aabb:AxisAlignedBoundingBox;
public function GeometryObject3D():void{
_boundingSphereDirty = true;
_aabbDirty = true;
_numInstances = 0;
_ready = false;
super();
dirty = true;
}
public function transformVertices(_arg1:Matrix3D):void{
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:int;
var _local15:Vertex3D;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:Number;
var _local20:Number;
var _local21:Number;
_local2 = _arg1.n11;
_local3 = _arg1.n12;
_local4 = _arg1.n13;
_local5 = _arg1.n21;
_local6 = _arg1.n22;
_local7 = _arg1.n23;
_local8 = _arg1.n31;
_local9 = _arg1.n32;
_local10 = _arg1.n33;
_local11 = _arg1.n14;
_local12 = _arg1.n24;
_local13 = _arg1.n34;
_local14 = vertices.length;
while ((_local15 = vertices[--_local14])) {
_local16 = _local15.x;
_local17 = _local15.y;
_local18 = _local15.z;
_local19 = ((((_local16 * _local2) + (_local17 * _local3)) + (_local18 * _local4)) + _local11);
_local20 = ((((_local16 * _local5) + (_local17 * _local6)) + (_local18 * _local7)) + _local12);
_local21 = ((((_local16 * _local8) + (_local17 * _local9)) + (_local18 * _local10)) + _local13);
_local15.x = _local19;
_local15.y = _local20;
_local15.z = _local21;
};
}
public function flipFaces():void{
var _local1:Triangle3D;
var _local2:Vertex3D;
for each (_local1 in this.faces) {
_local2 = _local1.v0;
_local1.v0 = _local1.v2;
_local1.v2 = _local2;
_local1.uv = [_local1.uv2, _local1.uv1, _local1.uv0];
_local1.createNormal();
};
this.ready = true;
}
private function createVertexNormals():void{
var _local1:Dictionary;
var _local2:Triangle3D;
var _local3:Vertex3D;
_local1 = new Dictionary(true);
for each (_local2 in faces) {
_local2.v0.connectedFaces[_local2] = _local2;
_local2.v1.connectedFaces[_local2] = _local2;
_local2.v2.connectedFaces[_local2] = _local2;
_local1[_local2.v0] = _local2.v0;
_local1[_local2.v1] = _local2.v1;
_local1[_local2.v2] = _local2.v2;
};
for each (_local3 in _local1) {
_local3.calculateNormal();
};
}
public function transformUV(_arg1:MaterialObject3D):void{
var _local2:String;
if (_arg1.bitmap){
for (_local2 in this.faces) {
faces[_local2].transformUV(_arg1);
};
};
}
public function clone(_arg1:DisplayObject3D=null):GeometryObject3D{
var _local2:Dictionary;
var _local3:Dictionary;
var _local4:GeometryObject3D;
var _local5:int;
var _local6:MaterialObject3D;
var _local7:Vertex3D;
var _local8:Triangle3D;
var _local9:Vertex3D;
var _local10:Vertex3D;
var _local11:Vertex3D;
_local2 = new Dictionary(true);
_local3 = new Dictionary(true);
_local4 = new GeometryObject3D();
_local4.vertices = new Array();
_local4.faces = new Array();
_local5 = 0;
while (_local5 < this.vertices.length) {
_local7 = this.vertices[_local5];
_local3[_local7] = _local7.clone();
_local4.vertices.push(_local3[_local7]);
_local5++;
};
_local5 = 0;
while (_local5 < this.faces.length) {
_local8 = this.faces[_local5];
_local9 = _local3[_local8.v0];
_local10 = _local3[_local8.v1];
_local11 = _local3[_local8.v2];
_local4.faces.push(new Triangle3D(_arg1, [_local9, _local10, _local11], _local8.material, _local8.uv));
_local2[_local8.material] = _local8.material;
_local5++;
};
for each (_local6 in _local2) {
_local6.registerObject(_arg1);
};
return (_local4);
}
public function set ready(_arg1:Boolean):void{
if (_arg1){
createVertexNormals();
this.dirty = false;
};
_ready = _arg1;
}
public function get ready():Boolean{
return (_ready);
}
public function get aabb():AxisAlignedBoundingBox{
if (_aabbDirty){
_aabb = AxisAlignedBoundingBox.createFromVertices(vertices);
_aabbDirty = false;
};
return (_aabb);
}
public function get boundingSphere():BoundingSphere{
if (_boundingSphereDirty){
_boundingSphere = BoundingSphere.getFromVertices(vertices);
_boundingSphereDirty = false;
};
return (_boundingSphere);
}
}
}//package org.papervision3d.core.proto
Section 98
//LightObject3D (org.papervision3d.core.proto.LightObject3D)
package org.papervision3d.core.proto {
import org.papervision3d.core.math.*;
import org.papervision3d.objects.*;
import org.papervision3d.materials.*;
import org.papervision3d.objects.primitives.*;
public class LightObject3D extends DisplayObject3D {
private var displaySphere:Sphere;
public var lightMatrix:Matrix3D;
public var flipped:Boolean;
private var _showLight:Boolean;
public function LightObject3D(_arg1:Boolean=false, _arg2:Boolean=false){
this.lightMatrix = Matrix3D.IDENTITY;
this.showLight = _arg1;
this.flipped = _arg2;
}
public function set showLight(_arg1:Boolean):void{
if (_showLight){
removeChild(displaySphere);
};
if (_arg1){
displaySphere = new Sphere(new WireframeMaterial(0xFFFF00), 10, 3, 2);
addChild(displaySphere);
};
_showLight = _arg1;
}
public function get showLight():Boolean{
return (_showLight);
}
}
}//package org.papervision3d.core.proto
Section 99
//MaterialObject3D (org.papervision3d.core.proto.MaterialObject3D)
package org.papervision3d.core.proto {
import flash.display.*;
import flash.events.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.geom.renderables.*;
import flash.geom.*;
import org.papervision3d.objects.*;
import org.papervision3d.materials.*;
import org.papervision3d.core.render.material.*;
import flash.utils.*;
import org.papervision3d.core.render.draw.*;
public class MaterialObject3D extends EventDispatcher implements ITriangleDrawer {
public var maxV:Number;
public var name:String;
public var heightOffset:Number;// = 0
public var fillAlpha:Number;// = 0
public var fillColor:Number;
public var id:Number;
protected var objects:Dictionary;
public var invisible:Boolean;// = false
public var smooth:Boolean;// = false
public var bitmap:BitmapData;
public var lineColor:Number;
public var lineAlpha:Number;// = 0
public var oneSide:Boolean;// = true
public var lineThickness:Number;// = 1
public var interactive:Boolean;// = false
public var opposite:Boolean;// = false
public var maxU:Number;
public var tiled:Boolean;// = false
public var widthOffset:Number;// = 0
public static var DEFAULT_COLOR:int = 0;
public static var DEBUG_COLOR:int = 0xFF00FF;
private static var _totalMaterialObjects:Number = 0;
public function MaterialObject3D(){
smooth = false;
tiled = false;
lineColor = DEFAULT_COLOR;
lineAlpha = 0;
lineThickness = 1;
fillColor = DEFAULT_COLOR;
fillAlpha = 0;
oneSide = true;
invisible = false;
opposite = false;
widthOffset = 0;
heightOffset = 0;
interactive = false;
super();
this.id = _totalMaterialObjects++;
MaterialManager.registerMaterial(this);
objects = new Dictionary(true);
}
public function drawTriangle(_arg1:Triangle3D, _arg2:Graphics, _arg3:RenderSessionData, _arg4:BitmapData=null, _arg5:Matrix=null):void{
}
public function get doubleSided():Boolean{
return (!(this.oneSide));
}
public function unregisterObject(_arg1:DisplayObject3D):void{
if (((objects) && (!((objects[_arg1] == null))))){
delete objects[_arg1];
};
}
public function set doubleSided(_arg1:Boolean):void{
this.oneSide = !(_arg1);
}
public function registerObject(_arg1:DisplayObject3D):void{
objects[_arg1] = _arg1;
}
public function updateBitmap():void{
}
override public function toString():String{
return (((((("[MaterialObject3D] bitmap:" + this.bitmap) + " lineColor:") + this.lineColor) + " fillColor:") + fillColor));
}
public function copy(_arg1:MaterialObject3D):void{
this.bitmap = _arg1.bitmap;
this.smooth = _arg1.smooth;
this.lineColor = _arg1.lineColor;
this.lineAlpha = _arg1.lineAlpha;
this.fillColor = _arg1.fillColor;
this.fillAlpha = _arg1.fillAlpha;
this.oneSide = _arg1.oneSide;
this.opposite = _arg1.opposite;
this.invisible = _arg1.invisible;
this.name = _arg1.name;
this.maxU = _arg1.maxU;
this.maxV = _arg1.maxV;
}
public function destroy():void{
objects = null;
bitmap = null;
MaterialManager.unRegisterMaterial(this);
}
public function clone():MaterialObject3D{
var _local1:MaterialObject3D;
_local1 = new MaterialObject3D();
_local1.copy(this);
return (_local1);
}
public static function get DEFAULT():MaterialObject3D{
var _local1:MaterialObject3D;
_local1 = new WireframeMaterial();
_local1.lineColor = (0xFFFFFF * Math.random());
_local1.lineAlpha = 1;
_local1.fillColor = DEFAULT_COLOR;
_local1.fillAlpha = 1;
_local1.doubleSided = false;
return (_local1);
}
public static function get DEBUG():MaterialObject3D{
var _local1:MaterialObject3D;
_local1 = new (MaterialObject3D);
_local1.lineColor = (0xFFFFFF * Math.random());
_local1.lineAlpha = 1;
_local1.fillColor = DEBUG_COLOR;
_local1.fillAlpha = 0.37;
_local1.doubleSided = true;
return (_local1);
}
}
}//package org.papervision3d.core.proto
Section 100
//SceneObject3D (org.papervision3d.core.proto.SceneObject3D)
package org.papervision3d.core.proto {
import org.papervision3d.materials.utils.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.log.*;
import org.papervision3d.*;
public class SceneObject3D extends DisplayObjectContainer3D {
public var objects:Array;
public var materials:MaterialsList;
public function SceneObject3D(){
this.objects = new Array();
this.materials = new MaterialsList();
PaperLogger.info((((((Papervision3D.NAME + " ") + Papervision3D.VERSION) + " (") + Papervision3D.DATE) + ")\n"));
this.root = this;
}
override public function removeChild(_arg1:DisplayObject3D):DisplayObject3D{
var _local2:int;
super.removeChild(_arg1);
_local2 = 0;
while (_local2 < this.objects.length) {
if (this.objects[_local2] === _arg1){
this.objects.splice(_local2, 1);
return (_arg1);
};
_local2++;
};
return (_arg1);
}
override public function addChild(_arg1:DisplayObject3D, _arg2:String=null):DisplayObject3D{
var _local3:DisplayObject3D;
_local3 = super.addChild(_arg1, (_arg2) ? _arg2 : _arg1.name);
_arg1.scene = this;
_arg1.parent = null;
this.objects.push(_local3);
return (_local3);
}
}
}//package org.papervision3d.core.proto
Section 101
//AbstractRenderListItem (org.papervision3d.core.render.command.AbstractRenderListItem)
package org.papervision3d.core.render.command {
import flash.display.*;
import org.papervision3d.core.render.data.*;
public class AbstractRenderListItem implements IRenderListItem {
public var screenDepth:Number;
public function render(_arg1:RenderSessionData, _arg2:Graphics):void{
}
}
}//package org.papervision3d.core.render.command
Section 102
//IRenderListItem (org.papervision3d.core.render.command.IRenderListItem)
package org.papervision3d.core.render.command {
import flash.display.*;
import org.papervision3d.core.render.data.*;
public interface IRenderListItem {
function render(_arg1:RenderSessionData, _arg2:Graphics):void;
}
}//package org.papervision3d.core.render.command
Section 103
//RenderableListItem (org.papervision3d.core.render.command.RenderableListItem)
package org.papervision3d.core.render.command {
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.geom.renderables.*;
import flash.geom.*;
import org.papervision3d.objects.*;
public class RenderableListItem extends AbstractRenderListItem {
public var renderableInstance:AbstractRenderable;
public var renderable:Class;
public var instance:DisplayObject3D;
public function hitTestPoint2D(_arg1:Point, _arg2:RenderHitData):RenderHitData{
return (_arg2);
}
}
}//package org.papervision3d.core.render.command
Section 104
//RenderLine (org.papervision3d.core.render.command.RenderLine)
package org.papervision3d.core.render.command {
import flash.display.*;
import org.papervision3d.core.math.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.geom.renderables.*;
import flash.geom.*;
import org.papervision3d.materials.special.*;
public class RenderLine extends RenderableListItem implements IRenderListItem {
public var renderer:LineMaterial;
private var l1:Number2D;
private var l2:Number2D;
public var line:Line3D;
private var v:Number2D;
private var cp3d:Number3D;
private var p:Number2D;
private static var mouseVector:Number3D = Number3D.ZERO;
private static var lineVector:Number3D = Number3D.ZERO;
public function RenderLine(_arg1:Line3D){
this.renderable = Line3D;
this.renderableInstance = _arg1;
this.line = _arg1;
p = new Number2D();
l1 = new Number2D();
l2 = new Number2D();
v = new Number2D();
cp3d = new Number3D();
}
override public function render(_arg1:RenderSessionData, _arg2:Graphics):void{
renderer.drawLine(line, _arg2, _arg1);
}
override public function hitTestPoint2D(_arg1:Point, _arg2:RenderHitData):RenderHitData{
var _local3:Number;
var _local4:Number;
var _local5:Number;
if (renderer.interactive){
_local3 = line.size;
p.reset(_arg1.x, _arg1.y);
l1.reset(line.v0.vertex3DInstance.x, line.v0.vertex3DInstance.y);
l2.reset(line.v1.vertex3DInstance.x, line.v1.vertex3DInstance.y);
v.copyFrom(l2);
v.minusEq(l1);
_local4 = ((((p.x - l1.x) * (l2.x - l1.x)) + ((p.y - l1.y) * (l2.y - l1.y))) / ((v.x * v.x) + (v.y * v.y)));
if ((((_local4 > 0)) && ((_local4 < 1)))){
v.multiplyEq(_local4);
v.plusEq(l1);
v.minusEq(p);
_local5 = ((v.x * v.x) + (v.y * v.y));
if (_local5 < (_local3 * _local3)){
_arg2.displayObject3D = line.instance;
_arg2.material = renderer;
_arg2.renderable = line;
_arg2.hasHit = true;
cp3d.reset((line.v1.x - line.v0.x), (line.v1.y - line.v0.y), (line.v1.x - line.v0.x));
cp3d.x = (cp3d.x * _local4);
cp3d.y = (cp3d.y * _local4);
cp3d.z = (cp3d.z * _local4);
cp3d.x = (cp3d.x + line.v0.x);
cp3d.y = (cp3d.y + line.v0.y);
cp3d.z = (cp3d.z + line.v0.z);
_arg2.x = cp3d.x;
_arg2.y = cp3d.y;
_arg2.z = cp3d.z;
_arg2.u = 0;
_arg2.v = 0;
return (_arg2);
};
};
};
return (_arg2);
}
}
}//package org.papervision3d.core.render.command
Section 105
//RenderParticle (org.papervision3d.core.render.command.RenderParticle)
package org.papervision3d.core.render.command {
import flash.display.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.geom.renderables.*;
import flash.geom.*;
import org.papervision3d.materials.special.*;
public class RenderParticle extends RenderableListItem implements IRenderListItem {
public var particle:Particle;
public var renderMat:ParticleMaterial;
public function RenderParticle(_arg1:Particle){
this.particle = _arg1;
this.renderableInstance = _arg1;
this.renderable = Particle;
}
override public function render(_arg1:RenderSessionData, _arg2:Graphics):void{
particle.material.drawParticle(particle, _arg2, _arg1);
}
override public function hitTestPoint2D(_arg1:Point, _arg2:RenderHitData):RenderHitData{
renderMat = particle.material;
if (renderMat.interactive){
if (particle.renderRect.contains(_arg1.x, _arg1.y)){
_arg2.displayObject3D = particle.instance;
_arg2.material = renderMat;
_arg2.renderable = particle;
_arg2.hasHit = true;
_arg2.x = particle.x;
_arg2.y = particle.y;
_arg2.z = particle.z;
_arg2.u = 0;
_arg2.v = 0;
return (_arg2);
};
};
return (_arg2);
}
}
}//package org.papervision3d.core.render.command
Section 106
//RenderTriangle (org.papervision3d.core.render.command.RenderTriangle)
package org.papervision3d.core.render.command {
import org.papervision3d.core.proto.*;
import flash.display.*;
import org.papervision3d.core.math.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.geom.renderables.*;
import flash.geom.*;
import org.papervision3d.materials.*;
import org.papervision3d.core.render.draw.*;
public class RenderTriangle extends RenderableListItem implements IRenderListItem {
public var renderer:ITriangleDrawer;
public var triangle:Triangle3D;
public var container:Sprite;
private var position:Number3D;
protected var vx1:Vertex3DInstance;
public var renderMat:MaterialObject3D;
protected var vx0:Vertex3DInstance;
protected var vPoint:Vertex3DInstance;
protected var vx2:Vertex3DInstance;
protected static var resPA:Vertex3DInstance = new Vertex3DInstance();
protected static var resBA:Vertex3DInstance = new Vertex3DInstance();
protected static var vPoint:Vertex3DInstance = new Vertex3DInstance();
protected static var resRA:Vertex3DInstance = new Vertex3DInstance();
public function RenderTriangle(_arg1:Triangle3D):void{
position = new Number3D();
super();
this.triangle = _arg1;
renderableInstance = _arg1;
renderable = Triangle3D;
}
override public function render(_arg1:RenderSessionData, _arg2:Graphics):void{
renderer.drawTriangle(triangle, _arg2, _arg1);
}
override public function hitTestPoint2D(_arg1:Point, _arg2:RenderHitData):RenderHitData{
renderMat = triangle.material;
if (!renderMat){
renderMat = triangle.instance.material;
};
if (renderMat.interactive){
vPoint = RenderTriangle.vPoint;
vPoint.x = _arg1.x;
vPoint.y = _arg1.y;
vx0 = triangle.v0.vertex3DInstance;
vx1 = triangle.v1.vertex3DInstance;
vx2 = triangle.v2.vertex3DInstance;
if (sameSide(vPoint, vx0, vx1, vx2)){
if (sameSide(vPoint, vx1, vx0, vx2)){
if (sameSide(vPoint, vx2, vx0, vx1)){
return (deepHitTest(triangle, vPoint, _arg2));
};
};
};
};
return (_arg2);
}
public function sameSide(_arg1:Vertex3DInstance, _arg2:Vertex3DInstance, _arg3:Vertex3DInstance, _arg4:Vertex3DInstance):Boolean{
Vertex3DInstance.subTo(_arg4, _arg3, resBA);
Vertex3DInstance.subTo(_arg1, _arg3, resPA);
Vertex3DInstance.subTo(_arg2, _arg3, resRA);
return (((Vertex3DInstance.cross(resBA, resPA) * Vertex3DInstance.cross(resBA, resRA)) >= 0));
}
private function deepHitTest(_arg1:Triangle3D, _arg2:Vertex3DInstance, _arg3:RenderHitData):RenderHitData{
var _local4:Vertex3DInstance;
var _local5:Vertex3DInstance;
var _local6:Vertex3DInstance;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:Number;
var _local20:Number;
var _local21:Number;
var _local22:Number;
var _local23:Number;
var _local24:Number;
var _local25:Number;
var _local26:Number;
var _local27:Number;
var _local28:Number;
var _local29:Number;
var _local30:Array;
var _local31:Number;
var _local32:Number;
var _local33:Number;
var _local34:Number;
var _local35:Number;
var _local36:Number;
var _local37:Number;
var _local38:Number;
var _local39:BitmapData;
var _local40:Number;
var _local41:Number;
var _local42:Number;
var _local43:Number;
var _local44:MovieMaterial;
var _local45:Rectangle;
_local4 = _arg1.v0.vertex3DInstance;
_local5 = _arg1.v1.vertex3DInstance;
_local6 = _arg1.v2.vertex3DInstance;
_local7 = (_local6.x - _local4.x);
_local8 = (_local6.y - _local4.y);
_local9 = (_local5.x - _local4.x);
_local10 = (_local5.y - _local4.y);
_local11 = (_arg2.x - _local4.x);
_local12 = (_arg2.y - _local4.y);
_local13 = ((_local7 * _local7) + (_local8 * _local8));
_local14 = ((_local7 * _local9) + (_local8 * _local10));
_local15 = ((_local7 * _local11) + (_local8 * _local12));
_local16 = ((_local9 * _local9) + (_local10 * _local10));
_local17 = ((_local9 * _local11) + (_local10 * _local12));
_local18 = (1 / ((_local13 * _local16) - (_local14 * _local14)));
_local19 = (((_local16 * _local15) - (_local14 * _local17)) * _local18);
_local20 = (((_local13 * _local17) - (_local14 * _local15)) * _local18);
_local21 = (_arg1.v2.x - _arg1.v0.x);
_local22 = (_arg1.v2.y - _arg1.v0.y);
_local23 = (_arg1.v2.z - _arg1.v0.z);
_local24 = (_arg1.v1.x - _arg1.v0.x);
_local25 = (_arg1.v1.y - _arg1.v0.y);
_local26 = (_arg1.v1.z - _arg1.v0.z);
_local27 = ((_arg1.v0.x + (_local21 * _local19)) + (_local24 * _local20));
_local28 = ((_arg1.v0.y + (_local22 * _local19)) + (_local25 * _local20));
_local29 = ((_arg1.v0.z + (_local23 * _local19)) + (_local26 * _local20));
_local30 = _arg1.uv;
_local31 = _local30[0].u;
_local32 = _local30[1].u;
_local33 = _local30[2].u;
_local34 = _local30[0].v;
_local35 = _local30[1].v;
_local36 = _local30[2].v;
_local37 = ((((_local32 - _local31) * _local20) + ((_local33 - _local31) * _local19)) + _local31);
_local38 = ((((_local35 - _local34) * _local20) + ((_local36 - _local34) * _local19)) + _local34);
if (triangle.material){
renderMat = _arg1.material;
} else {
renderMat = _arg1.instance.material;
};
_local39 = renderMat.bitmap;
_local40 = 1;
_local41 = 1;
_local42 = 0;
_local43 = 0;
if ((renderMat is MovieMaterial)){
_local44 = (renderMat as MovieMaterial);
_local45 = _local44.rect;
if (_local45){
_local42 = _local45.x;
_local43 = _local45.y;
_local40 = _local45.width;
_local41 = _local45.height;
};
} else {
if (_local39){
_local40 = (BitmapMaterial.AUTO_MIP_MAPPING) ? renderMat.widthOffset : _local39.width;
_local41 = (BitmapMaterial.AUTO_MIP_MAPPING) ? renderMat.heightOffset : _local39.height;
};
};
_arg3.displayObject3D = _arg1.instance;
_arg3.material = renderMat;
_arg3.renderable = _arg1;
_arg3.hasHit = true;
position.x = _local27;
position.y = _local28;
position.z = _local29;
Matrix3D.multiplyVector(_arg1.instance.world, position);
_arg3.x = position.x;
_arg3.y = position.y;
_arg3.z = position.z;
_arg3.u = ((_local37 * _local40) + _local42);
_arg3.v = ((_local41 - (_local38 * _local41)) + _local43);
return (_arg3);
}
}
}//package org.papervision3d.core.render.command
Section 107
//RenderHitData (org.papervision3d.core.render.data.RenderHitData)
package org.papervision3d.core.render.data {
import org.papervision3d.core.proto.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.objects.*;
public class RenderHitData {
public var y:Number;
public var endTime:int;// = 0
public var displayObject3D:DisplayObject3D;
public var startTime:int;// = 0
public var hasHit:Boolean;// = false
public var material:MaterialObject3D;
public var renderable:IRenderable;
public var u:Number;
public var v:Number;
public var x:Number;
public var z:Number;
public function RenderHitData():void{
startTime = 0;
endTime = 0;
hasHit = false;
super();
}
public function clear():void{
startTime = 0;
endTime = 0;
hasHit = false;
displayObject3D = null;
material = null;
renderable = null;
u = 0;
v = 0;
x = 0;
y = 0;
z = 0;
}
public function clone():RenderHitData{
var _local1:RenderHitData;
_local1 = new RenderHitData();
_local1.startTime = startTime;
_local1.endTime = endTime;
_local1.hasHit = hasHit;
_local1.displayObject3D = displayObject3D;
_local1.material = material;
_local1.renderable = renderable;
_local1.u = u;
_local1.v = v;
_local1.x = x;
_local1.y = y;
_local1.z = z;
return (_local1);
}
public function toString():String{
return (((displayObject3D + " ") + renderable));
}
}
}//package org.papervision3d.core.render.data
Section 108
//RenderSessionData (org.papervision3d.core.render.data.RenderSessionData)
package org.papervision3d.core.render.data {
import org.papervision3d.core.proto.*;
import flash.display.*;
import org.papervision3d.view.*;
import org.papervision3d.core.culling.*;
import org.papervision3d.core.render.*;
public class RenderSessionData {
public var renderer:IRenderEngine;
public var particleCuller:IParticleCuller;
public var viewPort:Viewport3D;
public var triangleCuller:ITriangleCuller;
public var container:Sprite;
public var scene:SceneObject3D;
public var renderStatistics:RenderStatistics;
public var renderObjects:Array;
public var camera:CameraObject3D;
public var renderLayers:Array;
public var sorted:Boolean;
public function RenderSessionData():void{
this.renderStatistics = new RenderStatistics();
}
public function destroy():void{
triangleCuller = null;
particleCuller = null;
viewPort = null;
container = null;
scene = null;
camera = null;
renderer = null;
renderStatistics = null;
renderObjects = null;
renderLayers = null;
}
public function clone():RenderSessionData{
var _local1:RenderSessionData;
_local1 = new RenderSessionData();
_local1.triangleCuller = triangleCuller;
_local1.particleCuller = particleCuller;
_local1.viewPort = viewPort;
_local1.container = container;
_local1.scene = scene;
_local1.camera = camera;
_local1.renderer = renderer;
_local1.renderStatistics = renderStatistics.clone();
return (_local1);
}
}
}//package org.papervision3d.core.render.data
Section 109
//RenderStatistics (org.papervision3d.core.render.data.RenderStatistics)
package org.papervision3d.core.render.data {
public class RenderStatistics {
public var renderTime:int;// = 0
public var culledObjects:int;// = 0
public var shadedTriangles:int;// = 0
public var culledParticles:int;// = 0
public var culledTriangles:int;// = 0
public var triangles:int;// = 0
public var particles:int;// = 0
public var rendered:int;// = 0
public var projectionTime:int;// = 0
public var filteredObjects:int;// = 0
public var lines:int;// = 0
public function RenderStatistics(){
projectionTime = 0;
renderTime = 0;
rendered = 0;
triangles = 0;
culledTriangles = 0;
particles = 0;
culledParticles = 0;
lines = 0;
shadedTriangles = 0;
filteredObjects = 0;
culledObjects = 0;
super();
}
public function clone():RenderStatistics{
var _local1:RenderStatistics;
_local1 = new RenderStatistics();
_local1.projectionTime = projectionTime;
_local1.renderTime = renderTime;
_local1.rendered = rendered;
_local1.particles = particles;
_local1.triangles = triangles;
_local1.culledTriangles = culledTriangles;
_local1.lines = lines;
_local1.shadedTriangles = shadedTriangles;
_local1.filteredObjects = filteredObjects;
_local1.culledObjects = culledObjects;
return (_local1);
}
public function clear():void{
projectionTime = 0;
renderTime = 0;
rendered = 0;
particles = 0;
triangles = 0;
culledTriangles = 0;
culledParticles = 0;
lines = 0;
shadedTriangles = 0;
filteredObjects = 0;
culledObjects = 0;
}
public function toString():String{
return (new String((((((((((((((((((("ProjectionTime:" + projectionTime) + " RenderTime:") + renderTime) + " Particles:") + particles) + " CulledParticles :") + culledParticles) + " Triangles:") + triangles) + " ShadedTriangles :") + shadedTriangles) + " CulledTriangles:") + culledTriangles) + " FilteredObjects:") + filteredObjects) + " CulledObjects:") + culledObjects) + "")));
}
}
}//package org.papervision3d.core.render.data
Section 110
//ILineDrawer (org.papervision3d.core.render.draw.ILineDrawer)
package org.papervision3d.core.render.draw {
import flash.display.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.geom.renderables.*;
public interface ILineDrawer {
function drawLine(_arg1:Line3D, _arg2:Graphics, _arg3:RenderSessionData):void;
}
}//package org.papervision3d.core.render.draw
Section 111
//IParticleDrawer (org.papervision3d.core.render.draw.IParticleDrawer)
package org.papervision3d.core.render.draw {
import flash.display.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.geom.renderables.*;
public interface IParticleDrawer {
function updateRenderRect(_arg1:Particle):void;
function drawParticle(_arg1:Particle, _arg2:Graphics, _arg3:RenderSessionData):void;
}
}//package org.papervision3d.core.render.draw
Section 112
//ITriangleDrawer (org.papervision3d.core.render.draw.ITriangleDrawer)
package org.papervision3d.core.render.draw {
import flash.display.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.geom.renderables.*;
import flash.geom.*;
public interface ITriangleDrawer {
function drawTriangle(_arg1:Triangle3D, _arg2:Graphics, _arg3:RenderSessionData, _arg4:BitmapData=null, _arg5:Matrix=null):void;
}
}//package org.papervision3d.core.render.draw
Section 113
//BasicRenderFilter (org.papervision3d.core.render.filter.BasicRenderFilter)
package org.papervision3d.core.render.filter {
public class BasicRenderFilter implements IRenderFilter {
public function filter(_arg1:Array):int{
return (0);
}
}
}//package org.papervision3d.core.render.filter
Section 114
//IRenderFilter (org.papervision3d.core.render.filter.IRenderFilter)
package org.papervision3d.core.render.filter {
public interface IRenderFilter {
function filter(_arg1:Array):int;
}
}//package org.papervision3d.core.render.filter
Section 115
//IUpdateAfterMaterial (org.papervision3d.core.render.material.IUpdateAfterMaterial)
package org.papervision3d.core.render.material {
import org.papervision3d.core.render.data.*;
public interface IUpdateAfterMaterial {
function updateAfterRender(_arg1:RenderSessionData):void;
}
}//package org.papervision3d.core.render.material
Section 116
//IUpdateBeforeMaterial (org.papervision3d.core.render.material.IUpdateBeforeMaterial)
package org.papervision3d.core.render.material {
import org.papervision3d.core.render.data.*;
public interface IUpdateBeforeMaterial {
function updateBeforeRender(_arg1:RenderSessionData):void;
}
}//package org.papervision3d.core.render.material
Section 117
//MaterialManager (org.papervision3d.core.render.material.MaterialManager)
package org.papervision3d.core.render.material {
import org.papervision3d.core.proto.*;
import org.papervision3d.core.render.data.*;
import flash.utils.*;
public class MaterialManager {
private var materials:Dictionary;
private static var instance:MaterialManager;
public function MaterialManager():void{
if (instance){
throw (new Error("Only 1 instance of materialmanager allowed"));
};
init();
}
private function init():void{
materials = new Dictionary(true);
}
private function _unRegisterMaterial(_arg1:MaterialObject3D):void{
delete materials[_arg1];
}
public function updateMaterialsAfterRender(_arg1:RenderSessionData):void{
var _local2:IUpdateAfterMaterial;
var _local3:MaterialObject3D;
for each (_local3 in materials) {
if ((_local3 is IUpdateAfterMaterial)){
_local2 = (_local3 as IUpdateAfterMaterial);
_local2.updateAfterRender(_arg1);
};
};
}
private function _registerMaterial(_arg1:MaterialObject3D):void{
materials[_arg1] = _arg1;
}
public function updateMaterialsBeforeRender(_arg1:RenderSessionData):void{
var _local2:IUpdateBeforeMaterial;
var _local3:MaterialObject3D;
for each (_local3 in materials) {
if ((_local3 is IUpdateBeforeMaterial)){
_local2 = (_local3 as IUpdateBeforeMaterial);
_local2.updateBeforeRender(_arg1);
};
};
}
public static function getInstance():MaterialManager{
if (!instance){
instance = new (MaterialManager);
};
return (instance);
}
public static function unRegisterMaterial(_arg1:MaterialObject3D):void{
getInstance()._unRegisterMaterial(_arg1);
}
public static function registerMaterial(_arg1:MaterialObject3D):void{
getInstance()._registerMaterial(_arg1);
}
}
}//package org.papervision3d.core.render.material
Section 118
//BasicProjectionPipeline (org.papervision3d.core.render.project.BasicProjectionPipeline)
package org.papervision3d.core.render.project {
import org.papervision3d.core.render.data.*;
import org.papervision3d.objects.*;
public class BasicProjectionPipeline extends ProjectionPipeline {
public function BasicProjectionPipeline(){
init();
}
protected function init():void{
}
protected function projectObject(_arg1:DisplayObject3D, _arg2:RenderSessionData):void{
_arg1.project(_arg2.camera, _arg2);
}
override public function project(_arg1:RenderSessionData):void{
var _local2:Array;
var _local3:DisplayObject3D;
var _local4:Number;
_arg1.camera.transformView();
_local2 = _arg1.renderObjects;
_local4 = _local2.length;
if (_arg1.camera.useProjectionMatrix){
for each (_local3 in _local2) {
if (_local3.visible){
if (_arg1.viewPort.viewportObjectFilter){
if (_arg1.viewPort.viewportObjectFilter.testObject(_local3)){
projectObject(_local3, _arg1);
} else {
_arg1.renderStatistics.filteredObjects++;
};
} else {
projectObject(_local3, _arg1);
};
};
};
} else {
for each (_local3 in _local2) {
if (_local3.visible){
if (_arg1.viewPort.viewportObjectFilter){
if (_arg1.viewPort.viewportObjectFilter.testObject(_local3)){
projectObject(_local3, _arg1);
} else {
_arg1.renderStatistics.filteredObjects++;
};
} else {
projectObject(_local3, _arg1);
};
};
};
};
}
}
}//package org.papervision3d.core.render.project
Section 119
//ProjectionPipeline (org.papervision3d.core.render.project.ProjectionPipeline)
package org.papervision3d.core.render.project {
import org.papervision3d.core.render.data.*;
public class ProjectionPipeline {
public function project(_arg1:RenderSessionData):void{
}
}
}//package org.papervision3d.core.render.project
Section 120
//IShaderRenderer (org.papervision3d.core.render.shader.IShaderRenderer)
package org.papervision3d.core.render.shader {
import flash.display.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.materials.shaders.*;
public interface IShaderRenderer {
function getLayerForShader(_arg1:Shader):Sprite;
function render(_arg1:RenderSessionData):void;
function destroy():void;
function clear():void;
}
}//package org.papervision3d.core.render.shader
Section 121
//ShaderObjectData (org.papervision3d.core.render.shader.ShaderObjectData)
package org.papervision3d.core.render.shader {
import flash.display.*;
import org.papervision3d.core.geom.renderables.*;
import flash.geom.*;
import org.papervision3d.objects.*;
import org.papervision3d.materials.*;
import org.papervision3d.materials.shaders.*;
import flash.utils.*;
public class ShaderObjectData {
public var shaderRenderer:ShaderRenderer;
public var triangleUVS:Dictionary;
public var renderTriangleUVS:Dictionary;
public var lightMatrices:Dictionary;
public var shadedMaterial:ShadedMaterial;
public var uvMatrices:Dictionary;
private var origin:Point;
public var triangleRects:Dictionary;
public var material:BitmapMaterial;
protected var triangleBitmaps:Dictionary;
public var object:DisplayObject3D;
public function ShaderObjectData(_arg1:DisplayObject3D, _arg2:BitmapMaterial, _arg3:ShadedMaterial):void{
origin = new Point(0, 0);
super();
shaderRenderer = new ShaderRenderer();
lightMatrices = new Dictionary();
uvMatrices = new Dictionary();
this.object = _arg1;
this.material = _arg2;
this.shadedMaterial = _arg3;
triangleUVS = new Dictionary();
renderTriangleUVS = new Dictionary();
triangleBitmaps = new Dictionary();
triangleRects = new Dictionary();
}
public function getRectFor(_arg1:Triangle3D):Rectangle{
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
if (!triangleRects[_arg1]){
_local2 = material.bitmap.width;
_local3 = material.bitmap.height;
_local4 = (_arg1.uv[0].u * _local2);
_local5 = ((1 - _arg1.uv[0].v) * _local3);
_local6 = (_arg1.uv[1].u * _local2);
_local7 = ((1 - _arg1.uv[1].v) * _local3);
_local8 = (_arg1.uv[2].u * _local2);
_local9 = ((1 - _arg1.uv[2].v) * _local3);
_local10 = Math.min(Math.min(_local4, _local6), _local8);
_local11 = Math.min(Math.min(_local5, _local7), _local9);
_local12 = Math.max(Math.max(_local4, _local6), _local8);
_local13 = Math.max(Math.max(_local5, _local7), _local9);
_local14 = (_local12 - _local10);
_local15 = (_local13 - _local11);
if (_local14 <= 0){
_local14 = 1;
};
if (_local15 <= 0){
_local15 = 1;
};
return ((triangleRects[_arg1] = new Rectangle(_local10, _local11, _local14, _local15)));
};
return (triangleRects[_arg1]);
}
private function perturbUVMatrix(_arg1:Matrix, _arg2:Triangle3D, _arg3:Number=2):void{
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:Number;
var _local20:Number;
var _local21:Number;
var _local22:Number;
var _local23:Number;
var _local24:Number;
var _local25:Number;
var _local26:Number;
var _local27:Number;
var _local28:Number;
var _local29:Number;
var _local30:Number;
var _local31:Number;
var _local32:Number;
var _local33:Number;
var _local34:Number;
_local4 = material.bitmap.width;
_local5 = material.bitmap.height;
_local6 = _arg2.uv[0].u;
_local7 = (1 - _arg2.uv[0].v);
_local8 = _arg2.uv[1].u;
_local9 = (1 - _arg2.uv[1].v);
_local10 = _arg2.uv[2].u;
_local11 = (1 - _arg2.uv[2].v);
_local12 = (_local6 * _local4);
_local13 = (_local7 * _local5);
_local14 = (_local8 * _local4);
_local15 = (_local9 * _local5);
_local16 = (_local10 * _local4);
_local17 = (_local11 * _local5);
_local18 = (((_local10 + _local8) + _local6) / 3);
_local19 = (((_local11 + _local9) + _local7) / 3);
_local20 = (_local6 - _local18);
_local21 = (_local7 - _local19);
_local22 = (_local8 - _local18);
_local23 = (_local9 - _local19);
_local24 = (_local10 - _local18);
_local25 = (_local11 - _local19);
_local26 = ((_local20)<0) ? -(_local20) : _local20;
_local27 = ((_local21)<0) ? -(_local21) : _local21;
_local28 = ((_local22)<0) ? -(_local22) : _local22;
_local29 = ((_local23)<0) ? -(_local23) : _local23;
_local30 = ((_local24)<0) ? -(_local24) : _local24;
_local31 = ((_local25)<0) ? -(_local25) : _local25;
_local32 = ((_local26)>_local27) ? (1 / _local26) : (1 / _local27);
_local33 = ((_local28)>_local29) ? (1 / _local28) : (1 / _local29);
_local34 = ((_local30)>_local31) ? (1 / _local30) : (1 / _local31);
_local12 = (_local12 - ((-(_local20) * _local32) * _arg3));
_local13 = (_local13 - ((-(_local21) * _local32) * _arg3));
_local14 = (_local14 - ((-(_local22) * _local33) * _arg3));
_local15 = (_local15 - ((-(_local23) * _local33) * _arg3));
_local16 = (_local16 - ((-(_local24) * _local34) * _arg3));
_local17 = (_local17 - ((-(_local25) * _local34) * _arg3));
_arg1.tx = _local12;
_arg1.ty = _local13;
_arg1.a = (_local14 - _local12);
_arg1.b = (_local15 - _local13);
_arg1.c = (_local16 - _local12);
_arg1.d = (_local17 - _local13);
}
public function getOutputBitmapFor(_arg1:Triangle3D):BitmapData{
var _local2:Rectangle;
var _local3:BitmapData;
var _local4:Rectangle;
if (!triangleBitmaps[_arg1]){
_local2 = getRectFor(_arg1);
_local3 = (triangleBitmaps[_arg1] = new BitmapData(Math.ceil(_local2.width), Math.ceil(_local2.height), false, 0));
_local4 = new Rectangle(0, 0, _local3.width, _local3.height);
_local3.copyPixels(material.bitmap, _local4, origin);
} else {
_local2 = getRectFor(_arg1);
};
if (((material.bitmap) && (_local2))){
triangleBitmaps[_arg1].copyPixels(material.bitmap, _local2, origin);
};
return (triangleBitmaps[_arg1]);
}
public function updateBeforeRender():void{
}
public function getPerTriUVForShader(_arg1:Triangle3D):Matrix{
var _local2:Matrix;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Rectangle;
if (!renderTriangleUVS[_arg1]){
_local2 = (renderTriangleUVS[_arg1] = new Matrix());
_local3 = material.bitmap.width;
_local4 = material.bitmap.height;
_local5 = (_arg1.uv[0].u * _local3);
_local6 = ((1 - _arg1.uv[0].v) * _local4);
_local7 = (_arg1.uv[1].u * _local3);
_local8 = ((1 - _arg1.uv[1].v) * _local4);
_local9 = (_arg1.uv[2].u * _local3);
_local10 = ((1 - _arg1.uv[2].v) * _local4);
_local11 = getRectFor(_arg1);
_local2.tx = (_local5 - _local11.x);
_local2.ty = (_local6 - _local11.y);
_local2.a = (_local7 - _local5);
_local2.b = (_local8 - _local6);
_local2.c = (_local9 - _local5);
_local2.d = (_local10 - _local6);
};
return (renderTriangleUVS[_arg1]);
}
public function getPerTriUVForDraw(_arg1:Triangle3D):Matrix{
var _local2:Matrix;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Rectangle;
if (!triangleUVS[_arg1]){
_local2 = (triangleUVS[_arg1] = new Matrix());
_local3 = material.bitmap.width;
_local4 = material.bitmap.height;
_local5 = (_arg1.uv[0].u * _local3);
_local6 = ((1 - _arg1.uv[0].v) * _local4);
_local7 = (_arg1.uv[1].u * _local3);
_local8 = ((1 - _arg1.uv[1].v) * _local4);
_local9 = (_arg1.uv[2].u * _local3);
_local10 = ((1 - _arg1.uv[2].v) * _local4);
_local11 = getRectFor(_arg1);
_local2.tx = (_local5 - _local11.x);
_local2.ty = (_local6 - _local11.y);
_local2.a = (_local7 - _local5);
_local2.b = (_local8 - _local6);
_local2.c = (_local9 - _local5);
_local2.d = (_local10 - _local6);
_local2.invert();
};
return (triangleUVS[_arg1]);
}
public function getUVMatrixForTriangle(_arg1:Triangle3D, _arg2:Boolean=false):Matrix{
var _local3:Matrix;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
_local3 = uvMatrices[_arg1];
if (!_local3){
_local3 = new Matrix();
if (_arg2){
perturbUVMatrix(_local3, _arg1, 2);
} else {
if (material.bitmap){
_local4 = material.bitmap.width;
_local5 = material.bitmap.height;
_local6 = (_arg1.uv[0].u * _local4);
_local7 = ((1 - _arg1.uv[0].v) * _local5);
_local8 = (_arg1.uv[1].u * _local4);
_local9 = ((1 - _arg1.uv[1].v) * _local5);
_local10 = (_arg1.uv[2].u * _local4);
_local11 = ((1 - _arg1.uv[2].v) * _local5);
_local3.tx = _local6;
_local3.ty = _local7;
_local3.a = (_local8 - _local6);
_local3.b = (_local9 - _local7);
_local3.c = (_local10 - _local6);
_local3.d = (_local11 - _local7);
};
};
if (material.bitmap){
uvMatrices[_arg1] = _local3;
};
};
return (_local3);
}
public function destroy():void{
var _local1:Object;
for each (_local1 in uvMatrices) {
uvMatrices[_local1] = null;
};
uvMatrices = null;
shaderRenderer.destroy();
shaderRenderer = null;
lightMatrices = null;
}
}
}//package org.papervision3d.core.render.shader
Section 122
//ShaderRenderer (org.papervision3d.core.render.shader.ShaderRenderer)
package org.papervision3d.core.render.shader {
import flash.display.*;
import flash.events.*;
import org.papervision3d.core.render.data.*;
import flash.geom.*;
import org.papervision3d.materials.shaders.*;
import flash.utils.*;
public class ShaderRenderer extends EventDispatcher implements IShaderRenderer {
public var container:Sprite;
public var outputBitmap:BitmapData;
public var bitmapContainer:Bitmap;
public var shadeLayers:Dictionary;
public var bitmapLayer:Sprite;
private var _inputBitmapData:BitmapData;
public var resizedInput:Boolean;// = false
public function ShaderRenderer(){
resizedInput = false;
super();
container = new Sprite();
bitmapLayer = new Sprite();
bitmapContainer = new Bitmap();
bitmapLayer.addChild(bitmapContainer);
bitmapLayer.blendMode = BlendMode.NORMAL;
shadeLayers = new Dictionary();
container.addChild(bitmapLayer);
}
public function destroy():void{
bitmapLayer = null;
outputBitmap.dispose();
}
public function getLayerForShader(_arg1:Shader):Sprite{
var _local2:Sprite;
var _local3:Sprite;
_local2 = new Sprite();
shadeLayers[_arg1] = _local2;
_local3 = new Sprite();
_local2.addChild(_local3);
if (inputBitmap != null){
_local3.graphics.beginFill(0, 0);
_local3.graphics.drawRect(0, 0, inputBitmap.width, inputBitmap.height);
_local3.graphics.endFill();
};
container.addChild(_local2);
_local2.blendMode = _arg1.layerBlendMode;
return (_local2);
}
public function get inputBitmap():BitmapData{
return (_inputBitmapData);
}
public function clear():void{
var _local1:Sprite;
for each (_local1 in shadeLayers) {
if (((((inputBitmap) && ((inputBitmap.width > 0)))) && ((inputBitmap.height > 0)))){
_local1.graphics.clear();
_local1.graphics.beginFill(0, 1);
_local1.graphics.drawRect(0, 0, inputBitmap.width, inputBitmap.height);
_local1.graphics.endFill();
};
};
}
public function render(_arg1:RenderSessionData):void{
if (outputBitmap){
outputBitmap.fillRect(outputBitmap.rect, 0);
bitmapContainer.bitmapData = inputBitmap;
outputBitmap.draw(container, null, null, null, outputBitmap.rect, false);
if (outputBitmap.transparent){
outputBitmap.copyChannel(inputBitmap, outputBitmap.rect, new Point(0, 0), BitmapDataChannel.ALPHA, BitmapDataChannel.ALPHA);
};
};
}
public function set inputBitmap(_arg1:BitmapData):void{
if (_arg1 != null){
if (_inputBitmapData != _arg1){
_inputBitmapData = _arg1;
if (outputBitmap){
if (((!((_inputBitmapData.width == outputBitmap.width))) || (!((_inputBitmapData.height == outputBitmap.height))))){
resizedInput = true;
outputBitmap.dispose();
outputBitmap = _inputBitmapData.clone();
};
} else {
resizedInput = true;
outputBitmap = _inputBitmapData.clone();
};
};
};
}
}
}//package org.papervision3d.core.render.shader
Section 123
//BasicRenderSorter (org.papervision3d.core.render.sort.BasicRenderSorter)
package org.papervision3d.core.render.sort {
public class BasicRenderSorter implements IRenderSorter {
public function sort(_arg1:Array):void{
_arg1.sortOn("screenDepth", Array.NUMERIC);
}
}
}//package org.papervision3d.core.render.sort
Section 124
//IRenderSorter (org.papervision3d.core.render.sort.IRenderSorter)
package org.papervision3d.core.render.sort {
public interface IRenderSorter {
function sort(_arg1:Array):void;
}
}//package org.papervision3d.core.render.sort
Section 125
//AbstractRenderEngine (org.papervision3d.core.render.AbstractRenderEngine)
package org.papervision3d.core.render {
import org.papervision3d.core.proto.*;
import flash.events.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.view.*;
import org.papervision3d.core.render.command.*;
public class AbstractRenderEngine extends EventDispatcher implements IRenderEngine {
public function AbstractRenderEngine(_arg1:IEventDispatcher=null){
super(_arg1);
}
public function removeFromRenderList(_arg1:IRenderListItem):int{
return (0);
}
public function addToRenderList(_arg1:IRenderListItem):int{
return (0);
}
public function renderScene(_arg1:SceneObject3D, _arg2:CameraObject3D, _arg3:Viewport3D, _arg4:Boolean=true):RenderStatistics{
return (null);
}
}
}//package org.papervision3d.core.render
Section 126
//IRenderEngine (org.papervision3d.core.render.IRenderEngine)
package org.papervision3d.core.render {
import org.papervision3d.core.proto.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.view.*;
import org.papervision3d.core.render.command.*;
public interface IRenderEngine {
function addToRenderList(_arg1:IRenderListItem):int;
function removeFromRenderList(_arg1:IRenderListItem):int;
function renderScene(_arg1:SceneObject3D, _arg2:CameraObject3D, _arg3:Viewport3D, _arg4:Boolean=true):RenderStatistics;
}
}//package org.papervision3d.core.render
Section 127
//IVirtualMouseEvent (org.papervision3d.core.utils.virtualmouse.IVirtualMouseEvent)
package org.papervision3d.core.utils.virtualmouse {
public interface IVirtualMouseEvent {
}
}//package org.papervision3d.core.utils.virtualmouse
Section 128
//VirtualMouse (org.papervision3d.core.utils.virtualmouse.VirtualMouse)
package org.papervision3d.core.utils.virtualmouse {
import flash.display.*;
import flash.events.*;
import flash.geom.*;
import org.papervision3d.core.log.*;
import flash.utils.*;
public class VirtualMouse extends EventDispatcher {
private var _container:Sprite;
private var lastDownTarget:DisplayObject;
private var target:InteractiveObject;
private var updateMouseDown:Boolean;// = false
private var eventEvent:Class;
private var _lastEvent:Event;
private var mouseEventEvent:Class;
private var location:Point;
private var delta:int;// = 0
private var disabledEvents:Object;
private var ignoredInstances:Dictionary;
private var isLocked:Boolean;// = false
private var lastWithinStage:Boolean;// = true
private var lastLocation:Point;
private var isDoubleClickEvent:Boolean;// = false
private var lastMouseDown:Boolean;// = false
private var altKey:Boolean;// = false
private var _useNativeEvents:Boolean;// = false
private var ctrlKey:Boolean;// = false
private var shiftKey:Boolean;// = false
private var _stage:Stage;
public static const UPDATE:String = "update";
private static var _mouseIsDown:Boolean = false;
public function VirtualMouse(_arg1:Stage=null, _arg2:Sprite=null, _arg3:Number=0, _arg4:Number=0){
altKey = false;
ctrlKey = false;
shiftKey = false;
delta = 0;
isLocked = false;
isDoubleClickEvent = false;
disabledEvents = new Object();
ignoredInstances = new Dictionary(true);
lastMouseDown = false;
updateMouseDown = false;
lastWithinStage = true;
_useNativeEvents = false;
eventEvent = VirtualMouseEvent;
mouseEventEvent = VirtualMouseMouseEvent;
super();
this.stage = _arg1;
this.container = _arg2;
location = new Point(_arg3, _arg4);
lastLocation = location.clone();
addEventListener(UPDATE, handleUpdate);
update();
}
public function get mouseIsDown():Boolean{
return (_mouseIsDown);
}
public function get stage():Stage{
return (_stage);
}
public function get container():Sprite{
return (_container);
}
public function exitContainer():void{
var _local1:Point;
if (!container){
return;
};
_local1 = target.globalToLocal(location);
if (!disabledEvents[MouseEvent.MOUSE_OUT]){
_lastEvent = new mouseEventEvent(MouseEvent.MOUSE_OUT, true, false, _local1.x, _local1.y, container, ctrlKey, altKey, shiftKey, _mouseIsDown, delta);
container.dispatchEvent(new mouseEventEvent(MouseEvent.MOUSE_OUT, true, false, _local1.x, _local1.y, container, ctrlKey, altKey, shiftKey, _mouseIsDown, delta));
dispatchEvent(new mouseEventEvent(MouseEvent.MOUSE_OUT, true, false, _local1.x, _local1.y, container, ctrlKey, altKey, shiftKey, _mouseIsDown, delta));
};
if (!disabledEvents[MouseEvent.ROLL_OUT]){
_lastEvent = new mouseEventEvent(MouseEvent.ROLL_OUT, false, false, _local1.x, _local1.y, container, ctrlKey, altKey, shiftKey, _mouseIsDown, delta);
container.dispatchEvent(new mouseEventEvent(MouseEvent.ROLL_OUT, false, false, _local1.x, _local1.y, container, ctrlKey, altKey, shiftKey, _mouseIsDown, delta));
dispatchEvent(new mouseEventEvent(MouseEvent.ROLL_OUT, false, false, _local1.x, _local1.y, container, ctrlKey, altKey, shiftKey, _mouseIsDown, delta));
};
if (target != container){
if (!disabledEvents[MouseEvent.MOUSE_OUT]){
_lastEvent = new mouseEventEvent(MouseEvent.MOUSE_OUT, true, false, _local1.x, _local1.y, container, ctrlKey, altKey, shiftKey, _mouseIsDown, delta);
target.dispatchEvent(new mouseEventEvent(MouseEvent.MOUSE_OUT, true, false, _local1.x, _local1.y, container, ctrlKey, altKey, shiftKey, _mouseIsDown, delta));
dispatchEvent(new mouseEventEvent(MouseEvent.MOUSE_OUT, true, false, _local1.x, _local1.y, container, ctrlKey, altKey, shiftKey, _mouseIsDown, delta));
};
if (!disabledEvents[MouseEvent.ROLL_OUT]){
_lastEvent = new mouseEventEvent(MouseEvent.ROLL_OUT, false, false, _local1.x, _local1.y, container, ctrlKey, altKey, shiftKey, _mouseIsDown, delta);
target.dispatchEvent(new mouseEventEvent(MouseEvent.ROLL_OUT, false, false, _local1.x, _local1.y, container, ctrlKey, altKey, shiftKey, _mouseIsDown, delta));
dispatchEvent(new mouseEventEvent(MouseEvent.ROLL_OUT, false, false, _local1.x, _local1.y, container, ctrlKey, altKey, shiftKey, _mouseIsDown, delta));
};
};
target = _stage;
}
public function release():void{
updateMouseDown = true;
_mouseIsDown = false;
if (!isLocked){
update();
};
}
public function click():void{
press();
release();
}
public function disableEvent(_arg1:String):void{
disabledEvents[_arg1] = true;
}
public function set container(_arg1:Sprite):void{
_container = _arg1;
}
public function get y():Number{
return (location.y);
}
public function set x(_arg1:Number):void{
location.x = _arg1;
if (!isLocked){
update();
};
}
public function get lastEvent():Event{
return (_lastEvent);
}
private function handleUpdate(_arg1:Event):void{
var _local2:Point;
var _local3:Array;
var _local4:InteractiveObject;
var _local5:DisplayObject;
var _local6:int;
var _local7:Point;
var _local8:Point;
var _local9:Boolean;
if (!container){
return;
};
if (container.scrollRect){
PaperLogger.warning("The container that virtualMouse is trying to test against has a scrollRect defined, and may cause an issue with finding objects under a defined point. Use MovieMaterial.rect to set a rectangle area instead");
};
_local2 = new Point();
_local2.x = container.x;
_local2.y = container.y;
container.x = (container.y = 0);
_local3 = container.getObjectsUnderPoint(location);
container.x = _local2.x;
container.y = _local2.y;
_local6 = _local3.length;
while (_local6--) {
_local5 = _local3[_local6];
while (_local5) {
if (ignoredInstances[_local5]){
_local4 = null;
break;
};
if (((_local4) && ((_local5 is SimpleButton)))){
_local4 = null;
} else {
if (((_local4) && (!(DisplayObjectContainer(_local5).mouseChildren)))){
_local4 = null;
};
};
if (((((!(_local4)) && ((_local5 is InteractiveObject)))) && (InteractiveObject(_local5).mouseEnabled))){
_local4 = InteractiveObject(_local5);
};
_local5 = _local5.parent;
};
if (_local4){
break;
};
};
if (!_local4){
_local4 = _stage;
};
_local7 = target.globalToLocal(location);
_local8 = _local4.globalToLocal(location);
if (((!((lastLocation.x == location.x))) || (!((lastLocation.y == location.y))))){
_local9 = false;
if (stage){
_local9 = (((((((location.x >= 0)) && ((location.y >= 0)))) && ((location.x <= stage.stageWidth)))) && ((location.y <= stage.stageHeight)));
};
if (((((!(_local9)) && (lastWithinStage))) && (!(disabledEvents[Event.MOUSE_LEAVE])))){
_lastEvent = new eventEvent(Event.MOUSE_LEAVE, false, false);
stage.dispatchEvent(_lastEvent);
dispatchEvent(_lastEvent);
};
if (((_local9) && (!(disabledEvents[MouseEvent.MOUSE_MOVE])))){
_lastEvent = new mouseEventEvent(MouseEvent.MOUSE_MOVE, true, false, _local8.x, _local8.y, _local4, ctrlKey, altKey, shiftKey, _mouseIsDown, delta);
_local4.dispatchEvent(_lastEvent);
dispatchEvent(_lastEvent);
};
lastWithinStage = _local9;
};
if (_local4 != target){
if (!disabledEvents[MouseEvent.MOUSE_OUT]){
_lastEvent = new mouseEventEvent(MouseEvent.MOUSE_OUT, true, false, _local7.x, _local7.y, _local4, ctrlKey, altKey, shiftKey, _mouseIsDown, delta);
target.dispatchEvent(_lastEvent);
dispatchEvent(_lastEvent);
};
if (!disabledEvents[MouseEvent.ROLL_OUT]){
_lastEvent = new mouseEventEvent(MouseEvent.ROLL_OUT, false, false, _local7.x, _local7.y, _local4, ctrlKey, altKey, shiftKey, _mouseIsDown, delta);
target.dispatchEvent(_lastEvent);
dispatchEvent(_lastEvent);
};
if (!disabledEvents[MouseEvent.MOUSE_OVER]){
_lastEvent = new mouseEventEvent(MouseEvent.MOUSE_OVER, true, false, _local8.x, _local8.y, target, ctrlKey, altKey, shiftKey, _mouseIsDown, delta);
_local4.dispatchEvent(_lastEvent);
dispatchEvent(_lastEvent);
};
if (!disabledEvents[MouseEvent.ROLL_OVER]){
_lastEvent = new mouseEventEvent(MouseEvent.ROLL_OVER, false, false, _local8.x, _local8.y, target, ctrlKey, altKey, shiftKey, _mouseIsDown, delta);
_local4.dispatchEvent(_lastEvent);
dispatchEvent(_lastEvent);
};
};
if (updateMouseDown){
if (_mouseIsDown){
if (!disabledEvents[MouseEvent.MOUSE_DOWN]){
_lastEvent = new mouseEventEvent(MouseEvent.MOUSE_DOWN, true, false, _local8.x, _local8.y, _local4, ctrlKey, altKey, shiftKey, _mouseIsDown, delta);
_local4.dispatchEvent(_lastEvent);
dispatchEvent(_lastEvent);
};
lastDownTarget = _local4;
updateMouseDown = false;
} else {
if (!disabledEvents[MouseEvent.MOUSE_UP]){
_lastEvent = new mouseEventEvent(MouseEvent.MOUSE_UP, true, false, _local8.x, _local8.y, _local4, ctrlKey, altKey, shiftKey, _mouseIsDown, delta);
_local4.dispatchEvent(_lastEvent);
dispatchEvent(_lastEvent);
};
if (((!(disabledEvents[MouseEvent.CLICK])) && ((_local4 == lastDownTarget)))){
_lastEvent = new mouseEventEvent(MouseEvent.CLICK, true, false, _local8.x, _local8.y, _local4, ctrlKey, altKey, shiftKey, _mouseIsDown, delta);
_local4.dispatchEvent(_lastEvent);
dispatchEvent(_lastEvent);
};
lastDownTarget = null;
updateMouseDown = false;
};
};
if (((((isDoubleClickEvent) && (!(disabledEvents[MouseEvent.DOUBLE_CLICK])))) && (_local4.doubleClickEnabled))){
_lastEvent = new mouseEventEvent(MouseEvent.DOUBLE_CLICK, true, false, _local8.x, _local8.y, _local4, ctrlKey, altKey, shiftKey, _mouseIsDown, delta);
_local4.dispatchEvent(_lastEvent);
dispatchEvent(_lastEvent);
};
lastLocation = location.clone();
lastMouseDown = _mouseIsDown;
target = _local4;
}
public function getLocation():Point{
return (location.clone());
}
public function get x():Number{
return (location.x);
}
public function lock():void{
isLocked = true;
}
public function get useNativeEvents():Boolean{
return (_useNativeEvents);
}
public function setLocation(_arg1, _arg2=null):void{
var _local3:Point;
if ((_arg1 is Point)){
_local3 = (_arg1 as Point);
location.x = _local3.x;
location.y = _local3.y;
} else {
location.x = Number(_arg1);
location.y = Number(_arg2);
};
if (!isLocked){
update();
};
}
private function keyHandler(_arg1:KeyboardEvent):void{
altKey = _arg1.altKey;
ctrlKey = _arg1.ctrlKey;
shiftKey = _arg1.shiftKey;
}
public function unignore(_arg1:DisplayObject):void{
if ((_arg1 in ignoredInstances)){
delete ignoredInstances[_arg1];
};
}
public function doubleClick():void{
if (isLocked){
release();
} else {
click();
press();
isDoubleClickEvent = true;
release();
isDoubleClickEvent = false;
};
}
public function update():void{
dispatchEvent(new Event(UPDATE, false, false));
}
public function unlock():void{
isLocked = false;
update();
}
public function ignore(_arg1:DisplayObject):void{
ignoredInstances[_arg1] = true;
}
public function enableEvent(_arg1:String):void{
if ((_arg1 in disabledEvents)){
delete disabledEvents[_arg1];
};
}
public function press():void{
updateMouseDown = true;
_mouseIsDown = true;
if (!isLocked){
update();
};
}
public function set useNativeEvents(_arg1:Boolean):void{
if (_arg1 == _useNativeEvents){
return;
};
_useNativeEvents = _arg1;
if (_useNativeEvents){
eventEvent = VirtualMouseEvent;
mouseEventEvent = VirtualMouseMouseEvent;
} else {
eventEvent = Event;
mouseEventEvent = MouseEvent;
};
}
public function set y(_arg1:Number):void{
location.y = _arg1;
if (!isLocked){
update();
};
}
public function set stage(_arg1:Stage):void{
var _local2:Boolean;
if (_stage){
_local2 = true;
_stage.removeEventListener(KeyboardEvent.KEY_DOWN, keyHandler);
_stage.removeEventListener(KeyboardEvent.KEY_UP, keyHandler);
} else {
_local2 = false;
};
_stage = _arg1;
if (_stage){
_stage.addEventListener(KeyboardEvent.KEY_DOWN, keyHandler);
_stage.addEventListener(KeyboardEvent.KEY_UP, keyHandler);
target = _stage;
if (!_local2){
update();
};
};
}
}
}//package org.papervision3d.core.utils.virtualmouse
Section 129
//VirtualMouseEvent (org.papervision3d.core.utils.virtualmouse.VirtualMouseEvent)
package org.papervision3d.core.utils.virtualmouse {
import flash.events.*;
public class VirtualMouseEvent extends Event implements IVirtualMouseEvent {
public function VirtualMouseEvent(_arg1:String, _arg2:Boolean=false, _arg3:Boolean=false){
super(_arg1, _arg2, _arg3);
}
}
}//package org.papervision3d.core.utils.virtualmouse
Section 130
//VirtualMouseMouseEvent (org.papervision3d.core.utils.virtualmouse.VirtualMouseMouseEvent)
package org.papervision3d.core.utils.virtualmouse {
import flash.display.*;
import flash.events.*;
public class VirtualMouseMouseEvent extends MouseEvent implements IVirtualMouseEvent {
public function VirtualMouseMouseEvent(_arg1:String, _arg2:Boolean=false, _arg3:Boolean=false, _arg4:Number=NaN, _arg5:Number=NaN, _arg6:InteractiveObject=null, _arg7:Boolean=false, _arg8:Boolean=false, _arg9:Boolean=false, _arg10:Boolean=false, _arg11:int=0){
super(_arg1, _arg2, _arg3, _arg4, _arg5, _arg6, _arg7, _arg8, _arg9, _arg10, _arg11);
}
}
}//package org.papervision3d.core.utils.virtualmouse
Section 131
//InteractiveSceneManager (org.papervision3d.core.utils.InteractiveSceneManager)
package org.papervision3d.core.utils {
import org.papervision3d.core.proto.*;
import flash.display.*;
import flash.events.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.view.*;
import org.papervision3d.core.geom.renderables.*;
import flash.geom.*;
import org.papervision3d.objects.*;
import org.papervision3d.materials.*;
import org.papervision3d.core.utils.virtualmouse.*;
import org.papervision3d.events.*;
public class InteractiveSceneManager extends EventDispatcher {
public var container:Sprite;
public var currentMousePos:Point;
public var currentDisplayObject3D:DisplayObject3D;
public var lastMousePos:Point;
public var viewport:Viewport3D;
public var currentMaterial:MaterialObject3D;
public var debug:Boolean;// = false
public var mouse3D:Mouse3D;
public var enableOverOut:Boolean;// = true
public var virtualMouse:VirtualMouse;
public var _viewportRendered:Boolean;// = false
public var renderHitData:RenderHitData;
public var currentMouseDO3D:DisplayObject3D;// = null
public static var MOUSE_IS_DOWN:Boolean = false;
public function InteractiveSceneManager(_arg1:Viewport3D){
virtualMouse = new VirtualMouse();
mouse3D = new Mouse3D();
enableOverOut = true;
currentMouseDO3D = null;
debug = false;
currentMousePos = new Point();
lastMousePos = new Point();
_viewportRendered = false;
super();
this.viewport = _arg1;
this.container = _arg1.containerSprite;
init();
}
public function updateAfterRender():void{
_viewportRendered = true;
}
protected function initVirtualMouse():void{
virtualMouse.stage = container.stage;
virtualMouse.container = container;
}
public function initListeners():void{
if (viewport.interactive){
container.addEventListener(MouseEvent.MOUSE_DOWN, handleMousePress, false, 0, true);
container.addEventListener(MouseEvent.MOUSE_UP, handleMouseRelease, false, 0, true);
container.addEventListener(MouseEvent.CLICK, handleMouseClick, false, 0, true);
container.addEventListener(MouseEvent.DOUBLE_CLICK, handleMouseDoubleClick, false, 0, true);
container.stage.addEventListener(Event.ENTER_FRAME, handleEnterFrame);
};
}
protected function handleMouseDoubleClick(_arg1:MouseEvent):void{
if ((_arg1 is IVirtualMouseEvent)){
return;
};
if (((renderHitData) && (renderHitData.hasHit))){
dispatchObjectEvent(InteractiveScene3DEvent.OBJECT_DOUBLE_CLICK, currentDisplayObject3D);
};
}
public function updateRenderHitData():void{
resolveRenderHitData();
currentDisplayObject3D = renderHitData.displayObject3D;
currentMaterial = renderHitData.material;
manageOverOut();
}
public function init():void{
if (container){
if (container.stage){
initVirtualMouse();
initListeners();
} else {
container.addEventListener(Event.ADDED_TO_STAGE, handleAddedToStage);
};
};
}
protected function handleMouseClick(_arg1:MouseEvent):void{
if ((_arg1 is IVirtualMouseEvent)){
return;
};
if (((renderHitData) && (renderHitData.hasHit))){
dispatchObjectEvent(InteractiveScene3DEvent.OBJECT_CLICK, currentDisplayObject3D);
};
}
protected function handleMouseOut(_arg1:DisplayObject3D):void{
var _local2:MovieMaterial;
if (_arg1){
_local2 = (_arg1.material as MovieMaterial);
if (_local2){
virtualMouse.exitContainer();
};
};
dispatchObjectEvent(InteractiveScene3DEvent.OBJECT_OUT, _arg1);
}
protected function manageOverOut():void{
if (!enableOverOut){
return;
};
if (((renderHitData) && (renderHitData.hasHit))){
if (((!(currentMouseDO3D)) && (currentDisplayObject3D))){
handleMouseOver(currentDisplayObject3D);
currentMouseDO3D = currentDisplayObject3D;
} else {
if (((currentMouseDO3D) && (!((currentMouseDO3D == currentDisplayObject3D))))){
handleMouseOut(currentMouseDO3D);
handleMouseOver(currentDisplayObject3D);
currentMouseDO3D = currentDisplayObject3D;
};
};
} else {
if (currentMouseDO3D != null){
handleMouseOut(currentMouseDO3D);
currentMouseDO3D = null;
};
};
}
protected function handleEnterFrame(_arg1:Event):void{
var _local2:Boolean;
var _local3:MovieMaterial;
currentMousePos.x = container.mouseX;
currentMousePos.y = container.mouseY;
_local2 = !(currentMousePos.equals(lastMousePos));
if (((_local2) || (_viewportRendered))){
updateRenderHitData();
_viewportRendered = false;
if ((_arg1 is IVirtualMouseEvent)){
return;
};
if (((virtualMouse) && (renderHitData))){
_local3 = (currentMaterial as MovieMaterial);
if (_local3){
virtualMouse.container = (_local3.movie as Sprite);
};
if (virtualMouse.container){
virtualMouse.setLocation(renderHitData.u, renderHitData.v);
};
if (((((Mouse3D.enabled) && (renderHitData))) && (renderHitData.hasHit))){
mouse3D.updatePosition(renderHitData);
};
dispatchObjectEvent(InteractiveScene3DEvent.OBJECT_MOVE, currentDisplayObject3D);
} else {
if (((renderHitData) && (renderHitData.hasHit))){
dispatchObjectEvent(InteractiveScene3DEvent.OBJECT_MOVE, currentDisplayObject3D);
};
};
};
lastMousePos.x = currentMousePos.x;
lastMousePos.y = currentMousePos.y;
}
protected function dispatchObjectEvent(_arg1:String, _arg2:DisplayObject3D):void{
var _local3:Number;
var _local4:Number;
if (((renderHitData) && (renderHitData.hasHit))){
_local3 = (renderHitData.u) ? renderHitData.u : 0;
_local4 = (renderHitData.v) ? renderHitData.v : 0;
dispatchEvent(new InteractiveScene3DEvent(_arg1, _arg2, container, (renderHitData.renderable as Triangle3D), _local3, _local4));
_arg2.dispatchEvent(new InteractiveScene3DEvent(_arg1, _arg2, container, (renderHitData.renderable as Triangle3D), _local3, _local4));
} else {
dispatchEvent(new InteractiveScene3DEvent(_arg1, _arg2, container));
if (_arg2){
_arg2.dispatchEvent(new InteractiveScene3DEvent(_arg1, _arg2, container));
};
};
}
protected function handleMouseOver(_arg1:DisplayObject3D):void{
dispatchObjectEvent(InteractiveScene3DEvent.OBJECT_OVER, _arg1);
}
protected function resolveRenderHitData():void{
renderHitData = (viewport.hitTestPoint2D(currentMousePos) as RenderHitData);
}
protected function handleMousePress(_arg1:MouseEvent):void{
if ((_arg1 is IVirtualMouseEvent)){
return;
};
MOUSE_IS_DOWN = true;
if (virtualMouse){
virtualMouse.press();
};
if (((((Mouse3D.enabled) && (renderHitData))) && (!((renderHitData.renderable == null))))){
mouse3D.updatePosition(renderHitData);
};
if (((renderHitData) && (renderHitData.hasHit))){
dispatchObjectEvent(InteractiveScene3DEvent.OBJECT_PRESS, currentDisplayObject3D);
};
}
protected function handleMouseRelease(_arg1:MouseEvent):void{
if ((_arg1 is IVirtualMouseEvent)){
return;
};
MOUSE_IS_DOWN = false;
if (virtualMouse){
virtualMouse.release();
};
if (((((Mouse3D.enabled) && (renderHitData))) && (!((renderHitData.renderable == null))))){
mouse3D.updatePosition(renderHitData);
};
if (((renderHitData) && (renderHitData.hasHit))){
dispatchObjectEvent(InteractiveScene3DEvent.OBJECT_RELEASE, currentDisplayObject3D);
};
}
protected function handleAddedToStage(_arg1:Event):void{
initVirtualMouse();
initListeners();
}
public function destroy():void{
viewport = null;
renderHitData = null;
currentDisplayObject3D = null;
currentMaterial = null;
currentMouseDO3D = null;
container.removeEventListener(MouseEvent.MOUSE_DOWN, handleMousePress);
container.removeEventListener(MouseEvent.MOUSE_UP, handleMouseRelease);
container.removeEventListener(MouseEvent.CLICK, handleMouseClick);
container.removeEventListener(MouseEvent.DOUBLE_CLICK, handleMouseDoubleClick);
if (container.stage){
container.stage.removeEventListener(Event.ENTER_FRAME, handleEnterFrame);
};
container = null;
}
}
}//package org.papervision3d.core.utils
Section 132
//Mouse3D (org.papervision3d.core.utils.Mouse3D)
package org.papervision3d.core.utils {
import org.papervision3d.core.math.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.objects.*;
public class Mouse3D extends DisplayObject3D {
private var position:Number3D;
private var target:Number3D;
public static var enabled:Boolean = false;
private static var UP:Number3D = new Number3D(0, 1, 0);
public function Mouse3D():void{
position = new Number3D(0, 0, 0);
target = new Number3D();
super();
}
public function updatePosition(_arg1:RenderHitData):void{
var _local2:Triangle3D;
var _local3:Number3D;
var _local4:Matrix3D;
var _local5:Number3D;
var _local6:Number3D;
var _local7:Matrix3D;
_local2 = (_arg1.renderable as Triangle3D);
target.x = _local2.faceNormal.x;
target.y = _local2.faceNormal.y;
target.z = _local2.faceNormal.z;
_local3 = Number3D.sub(target, position);
_local3.normalize();
if (_local3.modulo > 0.1){
_local5 = Number3D.cross(_local3, UP);
_local5.normalize();
_local6 = Number3D.cross(_local3, _local5);
_local6.normalize();
_local7 = this.transform;
_local7.n11 = _local5.x;
_local7.n21 = _local5.y;
_local7.n31 = _local5.z;
_local7.n12 = -(_local6.x);
_local7.n22 = -(_local6.y);
_local7.n32 = -(_local6.z);
_local7.n13 = _local3.x;
_local7.n23 = _local3.y;
_local7.n33 = _local3.z;
};
_local4 = Matrix3D.IDENTITY;
this.transform = Matrix3D.multiply(_local2.instance.world, _local7);
x = _arg1.x;
y = _arg1.y;
z = _arg1.z;
}
}
}//package org.papervision3d.core.utils
Section 133
//StopWatch (org.papervision3d.core.utils.StopWatch)
package org.papervision3d.core.utils {
import flash.events.*;
import flash.utils.*;
public class StopWatch extends EventDispatcher {
private var startTime:int;
private var elapsedTime:int;
private var stopTime:int;
private var isRunning:Boolean;
public function stop():int{
if (isRunning){
stopTime = getTimer();
elapsedTime = (stopTime - startTime);
isRunning = false;
return (elapsedTime);
};
return (0);
}
public function start():void{
if (!isRunning){
startTime = getTimer();
isRunning = true;
};
}
public function reset():void{
isRunning = false;
}
}
}//package org.papervision3d.core.utils
Section 134
//IView (org.papervision3d.core.view.IView)
package org.papervision3d.core.view {
public interface IView {
function stopRendering(_arg1:Boolean=false, _arg2:Boolean=false):void;
function startRendering():void;
function singleRender():void;
}
}//package org.papervision3d.core.view
Section 135
//IViewport3D (org.papervision3d.core.view.IViewport3D)
package org.papervision3d.core.view {
import org.papervision3d.core.render.data.*;
public interface IViewport3D {
function updateAfterRender(_arg1:RenderSessionData):void;
function updateBeforeRender(_arg1:RenderSessionData):void;
}
}//package org.papervision3d.core.view
Section 136
//InteractiveScene3DEvent (org.papervision3d.events.InteractiveScene3DEvent)
package org.papervision3d.events {
import flash.display.*;
import flash.events.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.objects.*;
public class InteractiveScene3DEvent extends Event {
public var sprite:Sprite;// = null
public var displayObject3D:DisplayObject3D;// = null
public var face3d:Triangle3D;// = null
public var renderHitData:RenderHitData;
public var x:Number;// = 0
public var y:Number;// = 0
public static const OBJECT_ADDED:String = "objectAdded";
public static const OBJECT_PRESS:String = "mousePress";
public static const OBJECT_RELEASE:String = "mouseRelease";
public static const OBJECT_CLICK:String = "mouseClick";
public static const OBJECT_RELEASE_OUTSIDE:String = "mouseReleaseOutside";
public static const OBJECT_OUT:String = "mouseOut";
public static const OBJECT_MOVE:String = "mouseMove";
public static const OBJECT_OVER:String = "mouseOver";
public static const OBJECT_DOUBLE_CLICK:String = "mouseDoubleClick";
public function InteractiveScene3DEvent(_arg1:String, _arg2:DisplayObject3D=null, _arg3:Sprite=null, _arg4:Triangle3D=null, _arg5:Number=0, _arg6:Number=0, _arg7:RenderHitData=null, _arg8:Boolean=false, _arg9:Boolean=false){
displayObject3D = null;
sprite = null;
face3d = null;
x = 0;
y = 0;
super(_arg1, _arg8, _arg9);
this.displayObject3D = _arg2;
this.sprite = _arg3;
this.face3d = _arg4;
this.x = _arg5;
this.y = _arg6;
this.renderHitData = _arg7;
}
override public function toString():String{
return (((((((("Type : " + type) + ", DO3D : ") + displayObject3D) + " Sprite : ") + sprite) + " Face : ") + face3d));
}
}
}//package org.papervision3d.events
Section 137
//RendererEvent (org.papervision3d.events.RendererEvent)
package org.papervision3d.events {
import flash.events.*;
import org.papervision3d.core.render.data.*;
public class RendererEvent extends Event {
public var renderSessionData:RenderSessionData;
public static const PROJECTION_DONE:String = "projectionDone";
public static const RENDER_DONE:String = "renderDone";
public function RendererEvent(_arg1:String, _arg2:RenderSessionData){
super(_arg1);
this.renderSessionData = _arg2;
}
public function clear():void{
renderSessionData = null;
}
override public function clone():Event{
return (new RendererEvent(type, renderSessionData));
}
}
}//package org.papervision3d.events
Section 138
//PointLight3D (org.papervision3d.lights.PointLight3D)
package org.papervision3d.lights {
import org.papervision3d.core.proto.*;
import org.papervision3d.core.math.*;
public class PointLight3D extends LightObject3D {
public static var DEFAULT_POS:Number3D = new Number3D(0, 0, -1000);
public function PointLight3D(_arg1:Boolean=false, _arg2:Boolean=false){
super(_arg1, _arg2);
x = DEFAULT_POS.x;
y = DEFAULT_POS.y;
z = DEFAULT_POS.z;
}
}
}//package org.papervision3d.lights
Section 139
//GouraudShader (org.papervision3d.materials.shaders.GouraudShader)
package org.papervision3d.materials.shaders {
import org.papervision3d.core.proto.*;
import org.papervision3d.materials.utils.*;
import flash.display.*;
import org.papervision3d.core.math.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.geom.renderables.*;
import flash.geom.*;
import org.papervision3d.core.render.shader.*;
public class GouraudShader extends LightShader {
private var _ambientColor:int;
private var gouraudMap:BitmapData;
private var lightMatrix:Matrix3D;
private static var p0:Number;
private static var p1:Number;
private static var p2:Number;
private static var triMatrix:Matrix = new Matrix();
private static var transformMatrix:Matrix = new Matrix();
private static var light:Number3D;
private static var q0:Number;
private static var q1:Number;
private static var q2:Number;
private static var currentGraphics:Graphics;
private static var v0:Vertex3DInstance;
private static var v1:Vertex3DInstance;
private static var v2:Vertex3DInstance;
private static var ts:Sprite = new Sprite();
public function GouraudShader(_arg1:LightObject3D, _arg2:int=0xFFFFFF, _arg3:int=0){
this.light = _arg1;
gouraudMap = LightMaps.getGouraudMap(_arg2, _arg3);
}
override public function renderTri(_arg1:Triangle3D, _arg2:RenderSessionData, _arg3:ShaderObjectData, _arg4:BitmapData):void{
lightMatrix = Matrix3D(_arg3.lightMatrices[this]);
p0 = ((((_arg1.v0.normal.x * lightMatrix.n31) + (_arg1.v0.normal.y * lightMatrix.n32)) + (_arg1.v0.normal.z * lightMatrix.n33)) * 0xFF);
transformMatrix.tx = p0;
transformMatrix.ty = 1;
transformMatrix.a = (((((_arg1.v1.normal.x * lightMatrix.n31) + (_arg1.v1.normal.y * lightMatrix.n32)) + (_arg1.v1.normal.z * lightMatrix.n33)) * 0xFF) - p0);
transformMatrix.c = (((((_arg1.v2.normal.x * lightMatrix.n31) + (_arg1.v2.normal.y * lightMatrix.n32)) + (_arg1.v2.normal.z * lightMatrix.n33)) * 0xFF) - p0);
transformMatrix.b = 2;
transformMatrix.d = 3;
transformMatrix.invert();
triMatrix = (_arg3.renderTriangleUVS[_arg1]) ? _arg3.renderTriangleUVS[_arg1] : _arg3.getPerTriUVForShader(_arg1);
transformMatrix.concat(triMatrix);
ts.graphics.clear();
ts.graphics.beginBitmapFill(gouraudMap, transformMatrix, false, false);
ts.graphics.drawRect(0, 0, _arg4.rect.width, _arg4.rect.height);
ts.graphics.endFill();
_arg4.draw(ts, null, null, layerBlendMode, _arg4.rect, false);
}
public function set ambientColor(_arg1:int):void{
_ambientColor = _arg1;
}
override public function renderLayer(_arg1:Triangle3D, _arg2:RenderSessionData, _arg3:ShaderObjectData):void{
lightMatrix = Matrix3D(_arg3.lightMatrices[this]);
p0 = ((((_arg1.v0.normal.x * lightMatrix.n31) + (_arg1.v0.normal.y * lightMatrix.n32)) + (_arg1.v0.normal.z * lightMatrix.n33)) * 0xFF);
transformMatrix.tx = p0;
transformMatrix.ty = 1;
transformMatrix.a = (((((_arg1.v1.normal.x * lightMatrix.n31) + (_arg1.v1.normal.y * lightMatrix.n32)) + (_arg1.v1.normal.z * lightMatrix.n33)) * 0xFF) - p0);
transformMatrix.c = (((((_arg1.v2.normal.x * lightMatrix.n31) + (_arg1.v2.normal.y * lightMatrix.n32)) + (_arg1.v2.normal.z * lightMatrix.n33)) * 0xFF) - p0);
transformMatrix.b = 2;
transformMatrix.d = 3;
transformMatrix.invert();
triMatrix = (_arg3.uvMatrices[_arg1]) ? _arg3.uvMatrices[_arg1] : _arg3.getUVMatrixForTriangle(_arg1);
transformMatrix.concat(triMatrix);
currentGraphics = Sprite(layers[_arg3.object]).graphics;
currentGraphics.beginBitmapFill(gouraudMap, transformMatrix, false, false);
currentGraphics.moveTo(triMatrix.tx, triMatrix.ty);
currentGraphics.lineTo((triMatrix.a + triMatrix.tx), (triMatrix.b + triMatrix.ty));
currentGraphics.lineTo((triMatrix.c + triMatrix.tx), (triMatrix.d + triMatrix.ty));
currentGraphics.lineTo(triMatrix.tx, triMatrix.ty);
currentGraphics.endFill();
}
public function get ambientColor():int{
return (_ambientColor);
}
}
}//package org.papervision3d.materials.shaders
Section 140
//ILightShader (org.papervision3d.materials.shaders.ILightShader)
package org.papervision3d.materials.shaders {
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.render.shader.*;
public interface ILightShader {
function updateLightMatrix(_arg1:ShaderObjectData, _arg2:RenderSessionData):void;
}
}//package org.papervision3d.materials.shaders
Section 141
//IShader (org.papervision3d.materials.shaders.IShader)
package org.papervision3d.materials.shaders {
import flash.display.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.render.shader.*;
public interface IShader {
function renderTri(_arg1:Triangle3D, _arg2:RenderSessionData, _arg3:ShaderObjectData, _arg4:BitmapData):void;
function updateAfterRender(_arg1:RenderSessionData, _arg2:ShaderObjectData):void;
function destroy():void;
function renderLayer(_arg1:Triangle3D, _arg2:RenderSessionData, _arg3:ShaderObjectData):void;
}
}//package org.papervision3d.materials.shaders
Section 142
//LightShader (org.papervision3d.materials.shaders.LightShader)
package org.papervision3d.materials.shaders {
import org.papervision3d.core.proto.*;
import org.papervision3d.materials.utils.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.render.shader.*;
public class LightShader extends Shader implements IShader, ILightShader {
private var _light:LightObject3D;
public function LightShader():void{
}
public function set light(_arg1:LightObject3D):void{
_light = _arg1;
}
public function get light():LightObject3D{
return (_light);
}
public function updateLightMatrix(_arg1:ShaderObjectData, _arg2:RenderSessionData):void{
_arg1.lightMatrices[this] = LightMatrix.getLightMatrix(light, _arg1.object, _arg2, _arg1.lightMatrices[this]);
}
}
}//package org.papervision3d.materials.shaders
Section 143
//ShadedMaterial (org.papervision3d.materials.shaders.ShadedMaterial)
package org.papervision3d.materials.shaders {
import flash.display.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.geom.renderables.*;
import flash.geom.*;
import org.papervision3d.core.render.shader.*;
import org.papervision3d.objects.*;
import org.papervision3d.materials.*;
import org.papervision3d.core.render.material.*;
import org.papervision3d.core.log.*;
import flash.utils.*;
import org.papervision3d.core.render.draw.*;
import org.papervision3d.core.material.*;
public class ShadedMaterial extends TriangleMaterial implements ITriangleDrawer, IUpdateBeforeMaterial, IUpdateAfterMaterial {
private var _shaderCompositeMode:int;
public var material:BitmapMaterial;
public var shader:Shader;
public var shaderObjectData:Dictionary;
private static var bmp:BitmapData;
public function ShadedMaterial(_arg1:BitmapMaterial, _arg2:Shader, _arg3:int=0){
this.shader = _arg2;
this.material = _arg1;
shaderCompositeMode = _arg3;
init();
}
public function updateBeforeRender(_arg1:RenderSessionData):void{
var _local2:ShaderObjectData;
var _local3:ILightShader;
for each (_local2 in shaderObjectData) {
_local2.shaderRenderer.inputBitmap = material.bitmap;
if (shaderCompositeMode == ShaderCompositeModes.PER_LAYER){
if (_local2.shaderRenderer.resizedInput){
_local2.shaderRenderer.resizedInput = false;
_local2.uvMatrices = new Dictionary();
};
_local2.shaderRenderer.clear();
};
if ((shader is ILightShader)){
_local3 = (shader as ILightShader);
_local3.updateLightMatrix(_local2, _arg1);
};
};
}
public function updateAfterRender(_arg1:RenderSessionData):void{
var _local2:ShaderObjectData;
for each (_local2 in shaderObjectData) {
shader.updateAfterRender(_arg1, _local2);
if (shaderCompositeMode == ShaderCompositeModes.PER_LAYER){
_local2.shaderRenderer.render(_arg1);
};
};
}
private function init():void{
shaderObjectData = new Dictionary();
}
override public function unregisterObject(_arg1:DisplayObject3D):void{
var _local2:ShaderObjectData;
super.unregisterObject(_arg1);
_local2 = shaderObjectData[_arg1];
_local2.destroy();
delete shaderObjectData[_arg1];
}
public function set shaderCompositeMode(_arg1:int):void{
_shaderCompositeMode = _arg1;
}
override public function registerObject(_arg1:DisplayObject3D):void{
var _local2:ShaderObjectData;
super.registerObject(_arg1);
_local2 = (shaderObjectData[_arg1] = new ShaderObjectData(_arg1, material, this));
_local2.shaderRenderer.inputBitmap = material.bitmap;
shader.setContainerForObject(_arg1, _local2.shaderRenderer.getLayerForShader(shader));
}
public function getOutputBitmapDataFor(_arg1:DisplayObject3D):BitmapData{
var _local2:ShaderObjectData;
if (shaderCompositeMode == ShaderCompositeModes.PER_LAYER){
if (shaderObjectData[_arg1]){
_local2 = ShaderObjectData(shaderObjectData[_arg1]);
return (_local2.shaderRenderer.outputBitmap);
};
PaperLogger.warning("object not registered with shaded material");
} else {
PaperLogger.warning("getOutputBitmapDataFor only works on per layer mode");
};
return (null);
}
override public function destroy():void{
var _local1:ShaderObjectData;
super.destroy();
for each (_local1 in shaderObjectData) {
_local1.destroy();
};
material = null;
shader = null;
}
override public function drawTriangle(_arg1:Triangle3D, _arg2:Graphics, _arg3:RenderSessionData, _arg4:BitmapData=null, _arg5:Matrix=null):void{
var _local6:ShaderObjectData;
_local6 = ShaderObjectData(shaderObjectData[_arg1.instance]);
if (shaderCompositeMode == ShaderCompositeModes.PER_LAYER){
material.drawTriangle(_arg1, _arg2, _arg3, _local6.shaderRenderer.outputBitmap);
shader.renderLayer(_arg1, _arg3, _local6);
} else {
if (shaderCompositeMode == ShaderCompositeModes.PER_TRIANGLE_IN_BITMAP){
bmp = _local6.getOutputBitmapFor(_arg1);
material.drawTriangle(_arg1, _arg2, _arg3, bmp, (_local6.triangleUVS[_arg1]) ? _local6.triangleUVS[_arg1] : _local6.getPerTriUVForDraw(_arg1));
shader.renderTri(_arg1, _arg3, _local6, bmp);
};
};
}
public function get shaderCompositeMode():int{
return (_shaderCompositeMode);
}
}
}//package org.papervision3d.materials.shaders
Section 144
//Shader (org.papervision3d.materials.shaders.Shader)
package org.papervision3d.materials.shaders {
import flash.display.*;
import flash.events.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.render.shader.*;
import org.papervision3d.objects.*;
import flash.filters.*;
import flash.utils.*;
public class Shader extends EventDispatcher implements IShader {
protected var layers:Dictionary;
protected var _filter:BitmapFilter;
protected var _blendMode:String;// = "multiply"
protected var _object:DisplayObject3D;
public function Shader(){
_blendMode = BlendMode.MULTIPLY;
super();
this.layers = new Dictionary(true);
}
public function get layerBlendMode():String{
return (_blendMode);
}
public function updateAfterRender(_arg1:RenderSessionData, _arg2:ShaderObjectData):void{
}
public function renderLayer(_arg1:Triangle3D, _arg2:RenderSessionData, _arg3:ShaderObjectData):void{
}
public function set layerBlendMode(_arg1:String):void{
_blendMode = _arg1;
}
public function setContainerForObject(_arg1:DisplayObject3D, _arg2:Sprite):void{
layers[_arg1] = _arg2;
}
public function set filter(_arg1:BitmapFilter):void{
_filter = _arg1;
}
public function renderTri(_arg1:Triangle3D, _arg2:RenderSessionData, _arg3:ShaderObjectData, _arg4:BitmapData):void{
}
public function get filter():BitmapFilter{
return (_filter);
}
public function destroy():void{
}
}
}//package org.papervision3d.materials.shaders
Section 145
//ShaderCompositeModes (org.papervision3d.materials.shaders.ShaderCompositeModes)
package org.papervision3d.materials.shaders {
public class ShaderCompositeModes {
public static var PER_TRIANGLE_IN_BITMAP:int = 1;
public static var PER_LAYER:int = 0;
}
}//package org.papervision3d.materials.shaders
Section 146
//LineMaterial (org.papervision3d.materials.special.LineMaterial)
package org.papervision3d.materials.special {
import org.papervision3d.core.proto.*;
import flash.display.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.render.draw.*;
public class LineMaterial extends MaterialObject3D implements ILineDrawer {
public function LineMaterial(_arg1:Number=0xFF0000, _arg2:Number=1){
this.lineColor = _arg1;
this.lineAlpha = _arg2;
}
public function drawLine(_arg1:Line3D, _arg2:Graphics, _arg3:RenderSessionData):void{
_arg2.lineStyle(_arg1.size, lineColor, lineAlpha);
_arg2.moveTo(_arg1.v0.vertex3DInstance.x, _arg1.v0.vertex3DInstance.y);
if (_arg1.cV){
_arg2.curveTo(_arg1.cV.vertex3DInstance.x, _arg1.cV.vertex3DInstance.y, _arg1.v1.vertex3DInstance.x, _arg1.v1.vertex3DInstance.y);
} else {
_arg2.lineTo(_arg1.v1.vertex3DInstance.x, _arg1.v1.vertex3DInstance.y);
};
_arg2.moveTo(0, 0);
_arg2.lineStyle();
}
}
}//package org.papervision3d.materials.special
Section 147
//ParticleMaterial (org.papervision3d.materials.special.ParticleMaterial)
package org.papervision3d.materials.special {
import org.papervision3d.core.proto.*;
import flash.display.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.geom.renderables.*;
import flash.geom.*;
import org.papervision3d.core.log.*;
import org.papervision3d.core.render.draw.*;
public class ParticleMaterial extends MaterialObject3D implements IParticleDrawer {
public var shape:int;
public static var SHAPE_SQUARE:int = 0;
public static var SHAPE_CIRCLE:int = 1;
public function ParticleMaterial(_arg1:Number, _arg2:Number, _arg3:int=0){
this.shape = _arg3;
this.fillAlpha = _arg2;
this.fillColor = _arg1;
}
public function updateRenderRect(_arg1:Particle):void{
var _local2:Rectangle;
_local2 = _arg1.renderRect;
if (_arg1.size == 0){
_local2.width = 1;
_local2.height = 1;
} else {
_local2.width = (_arg1.renderScale * _arg1.size);
_local2.height = (_arg1.renderScale * _arg1.size);
};
_local2.x = (_arg1.vertex3D.vertex3DInstance.x - (_local2.width / 2));
_local2.y = (_arg1.vertex3D.vertex3DInstance.y - (_local2.width / 2));
}
public function drawParticle(_arg1:Particle, _arg2:Graphics, _arg3:RenderSessionData):void{
var _local4:Rectangle;
_arg2.beginFill(fillColor, fillAlpha);
_local4 = _arg1.renderRect;
if (shape == SHAPE_SQUARE){
_arg2.drawRect(_local4.x, _local4.y, _local4.width, _local4.height);
} else {
if (shape == SHAPE_CIRCLE){
_arg2.drawCircle((_local4.x + (_local4.width / 2)), (_local4.y + (_local4.width / 2)), (_local4.width / 2));
} else {
PaperLogger.warning("Particle material has no valid shape - Must be ParticleMaterial.SHAPE_SQUARE or ParticleMaterial.SHAPE_CIRCLE");
};
};
_arg2.endFill();
_arg3.renderStatistics.particles++;
}
}
}//package org.papervision3d.materials.special
Section 148
//LightMaps (org.papervision3d.materials.utils.LightMaps)
package org.papervision3d.materials.utils {
import flash.display.*;
import flash.geom.*;
import flash.filters.*;
public class LightMaps {
private static var origin:Point = new Point();
public static function getGouraudMaterialMap(_arg1:int, _arg2:int):BitmapData{
var _local3:BitmapData;
var _local4:Sprite;
var _local5:Matrix;
_local3 = new BitmapData(0x0100, 3, false, 0xFFFFFF);
_local4 = new Sprite();
_local5 = new Matrix();
_local5.createGradientBox(0x0100, 3, 0, 0, 0);
_local4.graphics.beginGradientFill(GradientType.LINEAR, [_arg2, _arg1], [1, 1], [119, 0xFF], _local5);
_local4.graphics.drawRect(0, 0, 0x0100, 3);
_local4.graphics.endFill();
_local3.draw(_local4);
return (_local3);
}
public static function getPhongMap(_arg1:int, _arg2:int, _arg3:int, _arg4:int=0xFF, _arg5:int=0xFF):BitmapData{
var _local6:Number;
var _local7:Number;
var _local8:Sprite;
var _local9:Matrix;
var _local10:BitmapData;
_local6 = _arg4;
_local7 = _arg5;
_local8 = new Sprite();
_local9 = new Matrix();
_local9.createGradientBox(_local6, _local6, 0, 0, 0);
_local8.graphics.beginGradientFill(GradientType.RADIAL, [_arg1, _arg2, _arg2], [1, 1, 1], [0, (0xFF - _arg3), 0xFF], _local9);
_local8.graphics.drawRect(0, 0, _local6, _local6);
_local8.graphics.endFill();
_local10 = new BitmapData(_local6, _local6, false, 0xFF);
_local10.draw(_local8);
return (_local10);
}
public static function getCellMap(_arg1:int, _arg2:int, _arg3:int):BitmapData{
var _local4:BitmapData;
var _local5:Number;
var _local6:int;
var _local7:int;
var _local8:int;
var _local9:Array;
var _local10:Array;
var _local11:Array;
var _local12:int;
_local4 = LightMaps.getPhongMap(_arg1, _arg2, 0, 0xFF, 0xFF);
_local5 = 0;
_local6 = ((_arg1 & 0xFF0000) >> 16);
_local7 = ((_arg2 & 0xFF0000) >> 16);
_local8 = (_local7 - _local6);
_local9 = new Array();
_local10 = new Array();
_local11 = new Array();
_local12 = 0;
while (_local12 <= 0xFF) {
_local9[_local12] = ((_local12 - (_local12 % Math.round((0x0100 / _arg3)))) << 16);
_local10[_local12] = ((_local12 - (_local12 % Math.round((0x0100 / _arg3)))) << 8);
_local11[_local12] = (_local12 - (_local12 % Math.round((0x0100 / _arg3))));
_local12++;
};
_local4.paletteMap(_local4, _local4.rect, origin, _local9, _local10, _local11);
_local4.applyFilter(_local4, _local4.rect, origin, new BlurFilter(2, 2, 2));
return (_local4);
}
public static function getGouraudMap(_arg1:int, _arg2:int):BitmapData{
var _local3:BitmapData;
var _local4:Sprite;
var _local5:Matrix;
_local3 = new BitmapData(0xFF, 3, false, 0xFFFFFF);
_local4 = new Sprite();
_local5 = new Matrix();
_local5.createGradientBox(0xFF, 3, 0, 0, 0);
_local4.graphics.beginGradientFill(GradientType.LINEAR, [_arg2, _arg1], [1, 1], [0, 0xFF], _local5);
_local4.graphics.drawRect(0, 0, 0xFF, 3);
_local4.graphics.endFill();
_local3.draw(_local4);
return (_local3);
}
public static function getFlatMapArray(_arg1:int, _arg2:int, _arg3:int):Array{
var _local4:Array;
var _local5:BitmapData;
var _local6:Sprite;
var _local7:Matrix;
var _local8:int;
_local4 = new Array();
_local5 = new BitmapData(0x0100, 1, false, 0);
_local6 = new Sprite();
_local7 = new Matrix();
_local7.createGradientBox(0xFF, 1, 0, 0, 0);
_local6.graphics.beginGradientFill(GradientType.LINEAR, [_arg1, _arg2], [1, 1], [0, 0xFF], _local7);
_local6.graphics.drawRect(0, 0, 0xFF, 1);
_local6.graphics.endFill();
_local5.draw(_local6);
_local8 = 0x0100;
while (_local8--) {
_local4.push(_local5.getPixel(_local8, 0));
};
return (_local4);
}
public static function getFlatMap(_arg1:int, _arg2:int, _arg3:int):BitmapData{
var _local4:Array;
var _local5:BitmapData;
var _local6:Sprite;
var _local7:Matrix;
_local4 = new Array();
_local5 = new BitmapData(0xFF, 1, false, 0);
_local6 = new Sprite();
_local7 = new Matrix();
_local7.createGradientBox(0xFF, 1, 0, 0, 0);
_local6.graphics.beginGradientFill(GradientType.LINEAR, [_arg2, _arg1], [1, 1], [0, 0xFF], _local7);
_local6.graphics.drawRect(0, 0, 0xFF, 1);
_local6.graphics.endFill();
_local5.draw(_local6);
return (_local5);
}
}
}//package org.papervision3d.materials.utils
Section 149
//LightMatrix (org.papervision3d.materials.utils.LightMatrix)
package org.papervision3d.materials.utils {
import org.papervision3d.core.proto.*;
import org.papervision3d.core.math.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.objects.*;
import org.papervision3d.*;
import org.papervision3d.lights.*;
public class LightMatrix {
private static var _targetPos:Number3D = new Number3D();
private static var _lightUp:Number3D = new Number3D();
private static var _lightSide:Number3D = new Number3D();
private static var _lightDir:Number3D = new Number3D();
private static var lightMatrix:Matrix3D = Matrix3D.IDENTITY;
private static var invMatrix:Matrix3D = Matrix3D.IDENTITY;
protected static var UP:Number3D = new Number3D(0, 1, 0);
private static var _lightPos:Number3D = new Number3D();
public static function getLightMatrix(_arg1:LightObject3D, _arg2:DisplayObject3D, _arg3:RenderSessionData, _arg4:Matrix3D):Matrix3D{
var _local5:Matrix3D;
var _local6:Matrix3D;
var _local7:Matrix3D;
_local5 = (_arg4) ? _arg4 : Matrix3D.IDENTITY;
if (_arg1 == null){
_arg1 = new PointLight3D();
_arg1.copyPosition(_arg3.camera);
};
_targetPos.reset();
_lightPos.reset();
_lightDir.reset();
_lightUp.reset();
_lightSide.reset();
_local6 = _arg1.transform;
_local7 = _arg2.world;
_lightPos.x = -(_local6.n14);
_lightPos.y = -(_local6.n24);
_lightPos.z = -(_local6.n34);
_targetPos.x = -(_local7.n14);
_targetPos.y = -(_local7.n24);
_targetPos.z = -(_local7.n34);
_lightDir.x = (_targetPos.x - _lightPos.x);
_lightDir.y = (_targetPos.y - _lightPos.y);
_lightDir.z = (_targetPos.z - _lightPos.z);
invMatrix.calculateInverse(_arg2.world);
Matrix3D.multiplyVector3x3(invMatrix, _lightDir);
_lightDir.normalize();
_lightSide.x = ((_lightDir.y * UP.z) - (_lightDir.z * UP.y));
_lightSide.y = ((_lightDir.z * UP.x) - (_lightDir.x * UP.z));
_lightSide.z = ((_lightDir.x * UP.y) - (_lightDir.y * UP.x));
_lightSide.normalize();
_lightUp.x = ((_lightSide.y * _lightDir.z) - (_lightSide.z * _lightDir.y));
_lightUp.y = ((_lightSide.z * _lightDir.x) - (_lightSide.x * _lightDir.z));
_lightUp.z = ((_lightSide.x * _lightDir.y) - (_lightSide.y * _lightDir.x));
_lightUp.normalize();
if (((Papervision3D.useRIGHTHANDED) || (_arg2.flipLightDirection))){
_lightDir.x = -(_lightDir.x);
_lightDir.y = -(_lightDir.y);
_lightDir.z = -(_lightDir.z);
};
_local5.n11 = _lightSide.x;
_local5.n12 = _lightSide.y;
_local5.n13 = _lightSide.z;
_local5.n21 = _lightUp.x;
_local5.n22 = _lightUp.y;
_local5.n23 = _lightUp.z;
_local5.n31 = _lightDir.x;
_local5.n32 = _lightDir.y;
_local5.n33 = _lightDir.z;
return (_local5);
}
}
}//package org.papervision3d.materials.utils
Section 150
//MaterialsList (org.papervision3d.materials.utils.MaterialsList)
package org.papervision3d.materials.utils {
import org.papervision3d.core.proto.*;
import flash.utils.*;
public class MaterialsList {
protected var _materials:Dictionary;
public var materialsByName:Dictionary;
private var _materialsTotal:int;
public function MaterialsList(_arg1=null):void{
var _local2:String;
var _local3:String;
super();
this.materialsByName = new Dictionary(true);
this._materials = new Dictionary(false);
this._materialsTotal = 0;
if (_arg1){
if ((_arg1 is Array)){
for (_local2 in _arg1) {
this.addMaterial(_arg1[_local2]);
};
} else {
if ((_arg1 is Object)){
for (_local3 in _arg1) {
this.addMaterial(_arg1[_local3], _local3);
};
};
};
};
}
public function get numMaterials():int{
return (_materialsTotal);
}
public function addMaterial(_arg1:MaterialObject3D, _arg2:String=null):MaterialObject3D{
_arg2 = ((((_arg2) || (_arg1.name))) || (String(_arg1.id)));
this._materials[_arg1] = _arg2;
this.materialsByName[_arg2] = _arg1;
this._materialsTotal++;
return (_arg1);
}
public function removeMaterial(_arg1:MaterialObject3D):MaterialObject3D{
if (this._materials[_arg1]){
delete this.materialsByName[this._materials[_arg1]];
delete this._materials[_arg1];
_materialsTotal--;
};
return (_arg1);
}
public function toString():String{
var _local1:String;
var _local2:MaterialObject3D;
_local1 = "";
for each (_local2 in this.materialsByName) {
_local1 = (_local1 + (this._materials[_local2] + "\n"));
};
return (_local1);
}
public function removeMaterialByName(_arg1:String):MaterialObject3D{
return (removeMaterial(getMaterialByName(_arg1)));
}
public function clone():MaterialsList{
var _local1:MaterialsList;
var _local2:MaterialObject3D;
_local1 = new MaterialsList();
for each (_local2 in this.materialsByName) {
_local1.addMaterial(_local2.clone(), this._materials[_local2]);
};
return (_local1);
}
public function getMaterialByName(_arg1:String):MaterialObject3D{
return ((this.materialsByName[_arg1]) ? this.materialsByName[_arg1] : this.materialsByName["all"]);
}
}
}//package org.papervision3d.materials.utils
Section 151
//RenderRecStorage (org.papervision3d.materials.utils.RenderRecStorage)
package org.papervision3d.materials.utils {
import org.papervision3d.core.geom.renderables.*;
import flash.geom.*;
public class RenderRecStorage {
public var mat:Matrix;
public var v0:Vertex3DInstance;
public var v1:Vertex3DInstance;
public var v2:Vertex3DInstance;
public function RenderRecStorage(){
v0 = new Vertex3DInstance();
v1 = new Vertex3DInstance();
v2 = new Vertex3DInstance();
mat = new Matrix();
super();
}
}
}//package org.papervision3d.materials.utils
Section 152
//BitmapAssetMaterial (org.papervision3d.materials.BitmapAssetMaterial)
package org.papervision3d.materials {
import flash.display.*;
import org.papervision3d.core.log.*;
import flash.utils.*;
import org.papervision3d.core.render.draw.*;
public class BitmapAssetMaterial extends BitmapMaterial implements ITriangleDrawer {
private static var _library:Object = new Object();
private static var _count:Object = new Object();
public function BitmapAssetMaterial(_arg1:String, _arg2:Boolean=false){
texture = _arg1;
this.precise = _arg2;
}
override public function get texture():Object{
return (this._texture);
}
override public function set texture(_arg1:Object):void{
if ((_arg1 is String) == false){
PaperLogger.error("BitmapMaterial.texture requires a BitmapData object for the texture");
return;
};
bitmap = createBitmapFromLinkageID(String(_arg1));
_texture = _arg1;
}
protected function createBitmapFromLinkageID(_arg1:String):BitmapData{
var _local2:BitmapData;
var _local3:BitmapData;
var _local4:BitmapData;
var _local5:Class;
var _local6:XML;
if (this._texture != _arg1){
var _local7 = _count;
var _local8 = this._texture;
var _local9 = (_local7[_local8] - 1);
_local7[_local8] = _local9;
_local4 = _library[this._texture];
if (((_local4) && ((_count[this._texture] == 0)))){
_local4.dispose();
};
};
_local3 = _library[_arg1];
if (!_local3){
_local5 = (getDefinitionByName(_arg1) as Class);
_local6 = describeType(_local5);
if (_local6..constructor.length() == 0){
_local3 = (new (_local5) as BitmapData);
} else {
_local3 = (new _local5(0, 0) as BitmapData);
};
_local2 = createBitmap(_local3);
_library[_arg1] = _local2;
_count[_arg1] = 0;
} else {
_local2 = _local3;
maxU = (maxV = 1);
_local7 = _count;
_local8 = _arg1;
_local9 = (_local7[_local8] + 1);
_local7[_local8] = _local9;
};
return (_local2);
}
}
}//package org.papervision3d.materials
Section 153
//BitmapMaterial (org.papervision3d.materials.BitmapMaterial)
package org.papervision3d.materials {
import org.papervision3d.core.proto.*;
import org.papervision3d.materials.utils.*;
import flash.display.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.geom.renderables.*;
import flash.geom.*;
import org.papervision3d.core.log.*;
import flash.utils.*;
import org.papervision3d.core.render.draw.*;
import org.papervision3d.*;
import org.papervision3d.core.material.*;
public class BitmapMaterial extends TriangleMaterial implements ITriangleDrawer {
protected var renderRecStorage:Array;
protected var mabz:Number;
protected var dcay:Number;
protected var dsab:Number;
protected var tempTriangleMatrix:Matrix;
protected var dsbc:Number;
private var b2:Number;
protected var _precise:Boolean;
protected var faz:Number;
public var uvMatrices:Dictionary;
protected var dsca:Number;
protected var ax:Number;
protected var az:Number;
protected var ay:Number;
protected var mcay:Number;
protected var bx:Number;
protected var by:Number;
protected var fbz:Number;
protected var tempPreGrp:Graphics;
protected var fcz:Number;
public var minimumRenderSize:Number;// = 4
protected var bz:Number;
private var c2:Number;
protected var mcax:Number;
protected var dbcx:Number;
protected var cx:Number;
protected var cy:Number;
protected var cz:Number;
protected var dmax:Number;
protected var cullRect:Rectangle;
private var d2:Number;
protected var mcaz:Number;
protected var dbcy:Number;
protected var dabx:Number;
protected var _perPixelPrecision:int;// = 8
protected var daby:Number;
private var x0:Number;
private var x1:Number;
private var x2:Number;
protected var mbcy:Number;
protected var mbcz:Number;
protected var tempPreRSD:RenderSessionData;
private var y0:Number;
private var y1:Number;
private var y2:Number;
protected var _texture:Object;
protected var focus:Number;// = 200
protected var tempPreBmp:BitmapData;
protected var maby:Number;
protected var mabx:Number;
protected var dcax:Number;
protected var mbcx:Number;
private var a2:Number;
protected var _precision:int;// = 8
protected static const DEFAULT_FOCUS:Number = 200;
protected static var _triMatrix:Matrix = new Matrix();
protected static var _triMap:Matrix;
public static var AUTO_MIP_MAPPING:Boolean = false;
public static var MIP_MAP_DEPTH:Number = 8;
protected static var hitRect:Rectangle = new Rectangle();
protected static var _localMatrix:Matrix = new Matrix();
public function BitmapMaterial(_arg1:BitmapData=null, _arg2:Boolean=false){
focus = 200;
_precision = 8;
_perPixelPrecision = 8;
minimumRenderSize = 4;
uvMatrices = new Dictionary();
tempTriangleMatrix = new Matrix();
super();
if (_arg1){
texture = _arg1;
};
this.precise = _arg2;
createRenderRecStorage();
}
public function transformUV(_arg1:Triangle3D):Matrix{
var _local2:Array;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Matrix;
var _local16:Matrix;
if (!_arg1.uv){
PaperLogger.error("MaterialObject3D: transformUV() uv not found!");
} else {
if (bitmap){
_local2 = _arg1.uv;
_local3 = (bitmap.width * maxU);
_local4 = (bitmap.height * maxV);
_local5 = (_local3 * _arg1.uv0.u);
_local6 = (_local4 * (1 - _arg1.uv0.v));
_local7 = (_local3 * _arg1.uv1.u);
_local8 = (_local4 * (1 - _arg1.uv1.v));
_local9 = (_local3 * _arg1.uv2.u);
_local10 = (_local4 * (1 - _arg1.uv2.v));
if ((((((_local5 == _local7)) && ((_local6 == _local8)))) || ((((_local5 == _local9)) && ((_local6 == _local10)))))){
_local5 = (_local5 - ((_local5)>0.05) ? 0.05 : -0.05);
_local6 = (_local6 - ((_local6)>0.07) ? 0.07 : -0.07);
};
if ((((_local9 == _local7)) && ((_local10 == _local8)))){
_local9 = (_local9 - ((_local9)>0.05) ? 0.04 : -0.04);
_local10 = (_local10 - ((_local10)>0.06) ? 0.06 : -0.06);
};
_local11 = (_local7 - _local5);
_local12 = (_local8 - _local6);
_local13 = (_local9 - _local5);
_local14 = (_local10 - _local6);
_local15 = new Matrix(_local11, _local12, _local13, _local14, _local5, _local6);
if (Papervision3D.useRIGHTHANDED){
_local15.scale(-1, 1);
_local15.translate(_local3, 0);
};
_local15.invert();
_local16 = (uvMatrices[_arg1]) ? uvMatrices[_arg1] : uvMatrices[_arg1] = _local15.clone();
_local16.a = _local15.a;
_local16.b = _local15.b;
_local16.c = _local15.c;
_local16.d = _local15.d;
_local16.tx = _local15.tx;
_local16.ty = _local15.ty;
} else {
PaperLogger.error("MaterialObject3D: transformUV() material.bitmap not found!");
};
};
return (_local16);
}
protected function renderRec(_arg1:Matrix, _arg2:Vertex3DInstance, _arg3:Vertex3DInstance, _arg4:Vertex3DInstance, _arg5:Number):void{
var _local6:int;
var _local7:RenderRecStorage;
var _local8:Matrix;
az = _arg2.z;
bz = _arg3.z;
cz = _arg4.z;
if ((((((az <= 0)) && ((bz <= 0)))) && ((cz <= 0)))){
return;
};
cx = _arg4.x;
cy = _arg4.y;
bx = _arg3.x;
by = _arg3.y;
ax = _arg2.x;
ay = _arg2.y;
if (cullRect){
hitRect.x = ((bx < ax)) ? ((bx < cx)) ? bx : cx : ((ax < cx)) ? ax : cx;
hitRect.width = (((bx > ax)) ? ((bx > cx)) ? bx : cx : ((ax > cx)) ? ax : cx + ((hitRect.x < 0)) ? -(hitRect.x) : hitRect.x);
hitRect.y = ((by < ay)) ? ((by < cy)) ? by : cy : ((ay < cy)) ? ay : cy;
hitRect.height = (((by > ay)) ? ((by > cy)) ? by : cy : ((ay > cy)) ? ay : cy + ((hitRect.y < 0)) ? -(hitRect.y) : hitRect.y);
if (!(((hitRect.right < cullRect.left)) || ((hitRect.left > cullRect.right)))){
if (!(((hitRect.bottom < cullRect.top)) || ((hitRect.top > cullRect.bottom)))){
} else {
return;
};
} else {
return;
};
};
if ((((((((_arg5 >= 100)) || ((hitRect.width < minimumRenderSize)))) || ((hitRect.height < minimumRenderSize)))) || ((focus == Infinity)))){
a2 = (_arg3.x - _arg2.x);
b2 = (_arg3.y - _arg2.y);
c2 = (_arg4.x - _arg2.x);
d2 = (_arg4.y - _arg2.y);
tempTriangleMatrix.a = ((_arg1.a * a2) + (_arg1.b * c2));
tempTriangleMatrix.b = ((_arg1.a * b2) + (_arg1.b * d2));
tempTriangleMatrix.c = ((_arg1.c * a2) + (_arg1.d * c2));
tempTriangleMatrix.d = ((_arg1.c * b2) + (_arg1.d * d2));
tempTriangleMatrix.tx = (((_arg1.tx * a2) + (_arg1.ty * c2)) + _arg2.x);
tempTriangleMatrix.ty = (((_arg1.tx * b2) + (_arg1.ty * d2)) + _arg2.y);
if (lineAlpha){
tempPreGrp.lineStyle(lineThickness, lineColor, lineAlpha);
};
tempPreGrp.beginBitmapFill(tempPreBmp, tempTriangleMatrix, tiled, smooth);
tempPreGrp.moveTo(_arg2.x, _arg2.y);
tempPreGrp.lineTo(_arg3.x, _arg3.y);
tempPreGrp.lineTo(_arg4.x, _arg4.y);
tempPreGrp.endFill();
if (lineAlpha){
tempPreGrp.lineStyle();
};
tempPreRSD.renderStatistics.triangles++;
return;
};
faz = (focus + az);
fbz = (focus + bz);
fcz = (focus + cz);
mabz = (2 / (faz + fbz));
mbcz = (2 / (fbz + fcz));
mcaz = (2 / (fcz + faz));
mabx = (((ax * faz) + (bx * fbz)) * mabz);
maby = (((ay * faz) + (by * fbz)) * mabz);
mbcx = (((bx * fbz) + (cx * fcz)) * mbcz);
mbcy = (((by * fbz) + (cy * fcz)) * mbcz);
mcax = (((cx * fcz) + (ax * faz)) * mcaz);
mcay = (((cy * fcz) + (ay * faz)) * mcaz);
dabx = ((ax + bx) - mabx);
daby = ((ay + by) - maby);
dbcx = ((bx + cx) - mbcx);
dbcy = ((by + cy) - mbcy);
dcax = ((cx + ax) - mcax);
dcay = ((cy + ay) - mcay);
dsab = ((dabx * dabx) + (daby * daby));
dsbc = ((dbcx * dbcx) + (dbcy * dbcy));
dsca = ((dcax * dcax) + (dcay * dcay));
_local6 = (_arg5 + 1);
_local7 = RenderRecStorage(renderRecStorage[int(_arg5)]);
_local8 = _local7.mat;
if ((((((dsab <= _precision)) && ((dsca <= _precision)))) && ((dsbc <= _precision)))){
a2 = (_arg3.x - _arg2.x);
b2 = (_arg3.y - _arg2.y);
c2 = (_arg4.x - _arg2.x);
d2 = (_arg4.y - _arg2.y);
tempTriangleMatrix.a = ((_arg1.a * a2) + (_arg1.b * c2));
tempTriangleMatrix.b = ((_arg1.a * b2) + (_arg1.b * d2));
tempTriangleMatrix.c = ((_arg1.c * a2) + (_arg1.d * c2));
tempTriangleMatrix.d = ((_arg1.c * b2) + (_arg1.d * d2));
tempTriangleMatrix.tx = (((_arg1.tx * a2) + (_arg1.ty * c2)) + _arg2.x);
tempTriangleMatrix.ty = (((_arg1.tx * b2) + (_arg1.ty * d2)) + _arg2.y);
if (lineAlpha){
tempPreGrp.lineStyle(lineThickness, lineColor, lineAlpha);
};
tempPreGrp.beginBitmapFill(tempPreBmp, tempTriangleMatrix, tiled, smooth);
tempPreGrp.moveTo(_arg2.x, _arg2.y);
tempPreGrp.lineTo(_arg3.x, _arg3.y);
tempPreGrp.lineTo(_arg4.x, _arg4.y);
tempPreGrp.endFill();
if (lineAlpha){
tempPreGrp.lineStyle();
};
tempPreRSD.renderStatistics.triangles++;
return;
};
if ((((((dsab > _precision)) && ((dsca > _precision)))) && ((dsbc > _precision)))){
_local8.a = (_arg1.a * 2);
_local8.b = (_arg1.b * 2);
_local8.c = (_arg1.c * 2);
_local8.d = (_arg1.d * 2);
_local8.tx = (_arg1.tx * 2);
_local8.ty = (_arg1.ty * 2);
_local7.v0.x = (mabx * 0.5);
_local7.v0.y = (maby * 0.5);
_local7.v0.z = ((az + bz) * 0.5);
_local7.v1.x = (mbcx * 0.5);
_local7.v1.y = (mbcy * 0.5);
_local7.v1.z = ((bz + cz) * 0.5);
_local7.v2.x = (mcax * 0.5);
_local7.v2.y = (mcay * 0.5);
_local7.v2.z = ((cz + az) * 0.5);
renderRec(_local8, _arg2, _local7.v0, _local7.v2, _local6);
_local8.tx = (_local8.tx - 1);
renderRec(_local8, _local7.v0, _arg3, _local7.v1, _local6);
_local8.ty = (_local8.ty - 1);
_local8.tx = (_arg1.tx * 2);
renderRec(_local8, _local7.v2, _local7.v1, _arg4, _local6);
_local8.a = (-(_arg1.a) * 2);
_local8.b = (-(_arg1.b) * 2);
_local8.c = (-(_arg1.c) * 2);
_local8.d = (-(_arg1.d) * 2);
_local8.tx = ((-(_arg1.tx) * 2) + 1);
_local8.ty = ((-(_arg1.ty) * 2) + 1);
renderRec(_local8, _local7.v1, _local7.v2, _local7.v0, _local6);
return;
};
dmax = ((dsca > dsbc)) ? ((dsca > dsab)) ? dsca : dsab : ((dsbc > dsab)) ? dsbc : dsab;
if (dsab == dmax){
_local8.a = (_arg1.a * 2);
_local8.b = _arg1.b;
_local8.c = (_arg1.c * 2);
_local8.d = _arg1.d;
_local8.tx = (_arg1.tx * 2);
_local8.ty = _arg1.ty;
_local7.v0.x = (mabx * 0.5);
_local7.v0.y = (maby * 0.5);
_local7.v0.z = ((az + bz) * 0.5);
renderRec(_local8, _arg2, _local7.v0, _arg4, _local6);
_local8.a = ((_arg1.a * 2) + _arg1.b);
_local8.c = ((2 * _arg1.c) + _arg1.d);
_local8.tx = (((_arg1.tx * 2) + _arg1.ty) - 1);
renderRec(_local8, _local7.v0, _arg3, _arg4, _local6);
return;
};
if (dsca == dmax){
_local8.a = _arg1.a;
_local8.b = (_arg1.b * 2);
_local8.c = _arg1.c;
_local8.d = (_arg1.d * 2);
_local8.tx = _arg1.tx;
_local8.ty = (_arg1.ty * 2);
_local7.v2.x = (mcax * 0.5);
_local7.v2.y = (mcay * 0.5);
_local7.v2.z = ((cz + az) * 0.5);
renderRec(_local8, _arg2, _arg3, _local7.v2, _local6);
_local8.b = (_local8.b + _arg1.a);
_local8.d = (_local8.d + _arg1.c);
_local8.ty = (_local8.ty + (_arg1.tx - 1));
renderRec(_local8, _local7.v2, _arg3, _arg4, _local6);
return;
};
_local8.a = (_arg1.a - _arg1.b);
_local8.b = (_arg1.b * 2);
_local8.c = (_arg1.c - _arg1.d);
_local8.d = (_arg1.d * 2);
_local8.tx = (_arg1.tx - _arg1.ty);
_local8.ty = (_arg1.ty * 2);
_local7.v1.x = (mbcx * 0.5);
_local7.v1.y = (mbcy * 0.5);
_local7.v1.z = ((bz + cz) * 0.5);
renderRec(_local8, _arg2, _arg3, _local7.v1, _local6);
_local8.a = (_arg1.a * 2);
_local8.b = (_arg1.b - _arg1.a);
_local8.c = (_arg1.c * 2);
_local8.d = (_arg1.d - _arg1.c);
_local8.tx = (_arg1.tx * 2);
_local8.ty = (_arg1.ty - _arg1.tx);
renderRec(_local8, _arg2, _local7.v1, _arg4, _local6);
}
protected function createRenderRecStorage():void{
var _local1:int;
this.renderRecStorage = new Array();
_local1 = 0;
while (_local1 <= 100) {
this.renderRecStorage[_local1] = new RenderRecStorage();
_local1++;
};
}
public function resetUVS():void{
uvMatrices = new Dictionary(false);
}
public function get texture():Object{
return (this._texture);
}
public function set pixelPrecision(_arg1:int):void{
_precision = ((_arg1 * _arg1) * 1.4);
_perPixelPrecision = _arg1;
}
protected function correctBitmap(_arg1:BitmapData):BitmapData{
var _local2:BitmapData;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Boolean;
_local3 = (1 << MIP_MAP_DEPTH);
_local4 = (_arg1.width / _local3);
_local4 = ((_local4 == uint(_local4))) ? _local4 : (uint(_local4) + 1);
_local5 = (_arg1.height / _local3);
_local5 = ((_local5 == uint(_local5))) ? _local5 : (uint(_local5) + 1);
_local6 = (_local3 * _local4);
_local7 = (_local3 * _local5);
_local8 = true;
if (_local6 > 2880){
_local6 = _arg1.width;
_local8 = false;
};
if (_local7 > 2880){
_local7 = _arg1.height;
_local8 = false;
};
if (!_local8){
PaperLogger.warning((("Material " + this.name) + ": Texture too big for mip mapping. Resizing recommended for better performance and quality."));
};
if (((_arg1) && (((!(((_arg1.width % _local3) == 0))) || (!(((_arg1.height % _local3) == 0))))))){
_local2 = new BitmapData(_local6, _local7, _arg1.transparent, 0);
widthOffset = _arg1.width;
heightOffset = _arg1.height;
this.maxU = (_arg1.width / _local6);
this.maxV = (_arg1.height / _local7);
_local2.draw(_arg1);
extendBitmapEdges(_local2, _arg1.width, _arg1.height);
} else {
this.maxU = (this.maxV = 1);
_local2 = _arg1;
};
return (_local2);
}
protected function createBitmap(_arg1:BitmapData):BitmapData{
var _local2:BitmapData;
resetMapping();
if (AUTO_MIP_MAPPING){
_local2 = correctBitmap(_arg1);
} else {
this.maxU = (this.maxV = 1);
_local2 = _arg1;
};
return (_local2);
}
public function get precise():Boolean{
return (_precise);
}
override public function clone():MaterialObject3D{
var _local1:MaterialObject3D;
_local1 = super.clone();
_local1.maxU = this.maxU;
_local1.maxV = this.maxV;
return (_local1);
}
override public function toString():String{
return (((((("Texture:" + this.texture) + " lineColor:") + this.lineColor) + " lineAlpha:") + this.lineAlpha));
}
override public function copy(_arg1:MaterialObject3D):void{
super.copy(_arg1);
this.maxU = _arg1.maxU;
this.maxV = _arg1.maxV;
}
override public function drawTriangle(_arg1:Triangle3D, _arg2:Graphics, _arg3:RenderSessionData, _arg4:BitmapData=null, _arg5:Matrix=null):void{
if (!_precise){
if (lineAlpha){
_arg2.lineStyle(lineThickness, lineColor, lineAlpha);
};
if (bitmap){
_triMap = (_arg5) ? _arg5 : ((uvMatrices[_arg1]) || (transformUV(_arg1)));
x0 = _arg1.v0.vertex3DInstance.x;
y0 = _arg1.v0.vertex3DInstance.y;
x1 = _arg1.v1.vertex3DInstance.x;
y1 = _arg1.v1.vertex3DInstance.y;
x2 = _arg1.v2.vertex3DInstance.x;
y2 = _arg1.v2.vertex3DInstance.y;
_triMatrix.a = (x1 - x0);
_triMatrix.b = (y1 - y0);
_triMatrix.c = (x2 - x0);
_triMatrix.d = (y2 - y0);
_triMatrix.tx = x0;
_triMatrix.ty = y0;
_localMatrix.a = _triMap.a;
_localMatrix.b = _triMap.b;
_localMatrix.c = _triMap.c;
_localMatrix.d = _triMap.d;
_localMatrix.tx = _triMap.tx;
_localMatrix.ty = _triMap.ty;
_localMatrix.concat(_triMatrix);
_arg2.beginBitmapFill((_arg4) ? _arg4 : bitmap, _localMatrix, tiled, smooth);
};
_arg2.moveTo(x0, y0);
_arg2.lineTo(x1, y1);
_arg2.lineTo(x2, y2);
_arg2.lineTo(x0, y0);
if (bitmap){
_arg2.endFill();
};
if (lineAlpha){
_arg2.lineStyle();
};
_arg3.renderStatistics.triangles++;
} else {
if (bitmap){
_triMap = (_arg5) ? _arg5 : ((uvMatrices[_arg1]) || (transformUV(_arg1)));
focus = _arg3.camera.focus;
tempPreBmp = (_arg4) ? _arg4 : bitmap;
tempPreRSD = _arg3;
tempPreGrp = _arg2;
cullRect = _arg3.viewPort.cullingRectangle;
renderRec(_triMap, _arg1.v0.vertex3DInstance, _arg1.v1.vertex3DInstance, _arg1.v2.vertex3DInstance, 0);
};
};
}
public function resetMapping():void{
uvMatrices = new Dictionary();
}
public function set texture(_arg1:Object):void{
if ((_arg1 is BitmapData) == false){
PaperLogger.error("BitmapMaterial.texture requires a BitmapData object for the texture");
return;
};
bitmap = createBitmap(BitmapData(_arg1));
_texture = _arg1;
}
public function get pixelPrecision():int{
return (_perPixelPrecision);
}
public function set precise(_arg1:Boolean):void{
_precise = _arg1;
}
public function get precision():int{
return (_precision);
}
protected function extendBitmapEdges(_arg1:BitmapData, _arg2:Number, _arg3:Number):void{
var _local4:Rectangle;
var _local5:Point;
var _local6:int;
_local4 = new Rectangle();
_local5 = new Point();
if (_arg1.width > _arg2){
_local4.x = (_arg2 - 1);
_local4.y = 0;
_local4.width = 1;
_local4.height = _arg3;
_local5.y = 0;
_local6 = _arg2;
while (_local6 < _arg1.width) {
_local5.x = _local6;
_arg1.copyPixels(_arg1, _local4, _local5);
_local6++;
};
};
if (_arg1.height > _arg3){
_local4.x = 0;
_local4.y = (_arg3 - 1);
_local4.width = _arg1.width;
_local4.height = 1;
_local5.x = 0;
_local6 = _arg3;
while (_local6 < _arg1.height) {
_local5.y = _local6;
_arg1.copyPixels(_arg1, _local4, _local5);
_local6++;
};
};
}
override public function destroy():void{
super.destroy();
if (uvMatrices){
uvMatrices = null;
};
if (bitmap){
bitmap.dispose();
};
this.renderRecStorage = null;
}
public function set precision(_arg1:int):void{
_precision = _arg1;
}
}
}//package org.papervision3d.materials
Section 154
//MovieMaterial (org.papervision3d.materials.MovieMaterial)
package org.papervision3d.materials {
import flash.display.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.geom.renderables.*;
import flash.geom.*;
import org.papervision3d.core.render.material.*;
import org.papervision3d.core.log.*;
import org.papervision3d.core.render.draw.*;
public class MovieMaterial extends BitmapMaterial implements ITriangleDrawer, IUpdateBeforeMaterial, IUpdateAfterMaterial {
public var movieTransparent:Boolean;
private var materialIsUsed:Boolean;// = false
private var quality:String;
private var autoClipRect:Rectangle;
public var movie:DisplayObject;
private var movieAnimated:Boolean;
protected var recreateBitmapInSuper:Boolean;
public var allowAutoResize:Boolean;// = false
private var stage:Stage;
private var userClipRect:Rectangle;
public function MovieMaterial(_arg1:DisplayObject=null, _arg2:Boolean=false, _arg3:Boolean=false, _arg4:Boolean=false, _arg5:Rectangle=null){
materialIsUsed = false;
allowAutoResize = false;
super();
movieTransparent = _arg2;
this.animated = _arg3;
this.precise = _arg4;
userClipRect = _arg5;
if (_arg1){
texture = _arg1;
};
}
public function get rect():Rectangle{
var _local1:Rectangle;
_local1 = ((userClipRect) || (autoClipRect));
if (((!(_local1)) && (movie))){
_local1 = movie.getBounds(movie);
};
return (_local1);
}
public function updateAfterRender(_arg1:RenderSessionData):void{
if ((((movieAnimated == true)) && ((materialIsUsed == true)))){
drawBitmap();
if (recreateBitmapInSuper){
bitmap = super.createBitmap(bitmap);
recreateBitmapInSuper = false;
};
};
}
public function drawBitmap():void{
var _local1:Rectangle;
var _local2:Matrix;
var _local3:String;
bitmap.fillRect(bitmap.rect, fillColor);
if (((stage) && (quality))){
_local3 = stage.quality;
stage.quality = quality;
};
_local1 = rect;
_local2 = new Matrix(1, 0, 0, 1, -(_local1.x), -(_local1.y));
bitmap.draw(movie, _local2, movie.transform.colorTransform, null);
if (!userClipRect){
autoClipRect = movie.getBounds(movie);
};
if (((stage) && (quality))){
stage.quality = _local3;
};
}
override public function get texture():Object{
return (this._texture);
}
public function set animated(_arg1:Boolean):void{
movieAnimated = _arg1;
}
public function setQuality(_arg1:String, _arg2:Stage, _arg3:Boolean=true):void{
this.quality = _arg1;
this.stage = _arg2;
if (_arg3){
createBitmapFromSprite(movie);
};
}
public function updateBeforeRender(_arg1:RenderSessionData):void{
var _local2:int;
var _local3:int;
materialIsUsed = false;
if (movieAnimated){
if (userClipRect){
_local2 = int((userClipRect.width + 0.5));
_local3 = int((userClipRect.height + 0.5));
} else {
_local2 = int((movie.width + 0.5));
_local3 = int((movie.height + 0.5));
};
if (((allowAutoResize) && (((!((_local2 == bitmap.width))) || (!((_local3 == bitmap.height))))))){
initBitmap(movie);
recreateBitmapInSuper = true;
};
};
}
override public function drawTriangle(_arg1:Triangle3D, _arg2:Graphics, _arg3:RenderSessionData, _arg4:BitmapData=null, _arg5:Matrix=null):void{
materialIsUsed = true;
super.drawTriangle(_arg1, _arg2, _arg3, _arg4, _arg5);
}
override public function set texture(_arg1:Object):void{
if ((_arg1 is DisplayObject) == false){
PaperLogger.error("MovieMaterial.texture requires a Sprite to be passed as the object");
return;
};
bitmap = createBitmapFromSprite(DisplayObject(_arg1));
_texture = _arg1;
}
protected function initBitmap(_arg1:DisplayObject):void{
if (bitmap){
bitmap.dispose();
};
if (userClipRect){
bitmap = new BitmapData(int((userClipRect.width + 0.5)), int((userClipRect.height + 0.5)), movieTransparent, fillColor);
} else {
if ((((_arg1.width == 0)) || ((_arg1.height == 0)))){
bitmap = new BitmapData(0x0100, 0x0100, movieTransparent, fillColor);
} else {
bitmap = new BitmapData(int((_arg1.width + 0.5)), int((_arg1.height + 0.5)), movieTransparent, fillColor);
};
};
}
public function get animated():Boolean{
return (movieAnimated);
}
public function set rect(_arg1:Rectangle):void{
userClipRect = _arg1;
createBitmapFromSprite(movie);
}
protected function createBitmapFromSprite(_arg1:DisplayObject):BitmapData{
movie = _arg1;
initBitmap(movie);
drawBitmap();
bitmap = super.createBitmap(bitmap);
return (bitmap);
}
}
}//package org.papervision3d.materials
Section 155
//WireframeMaterial (org.papervision3d.materials.WireframeMaterial)
package org.papervision3d.materials {
import flash.display.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.geom.renderables.*;
import flash.geom.*;
import org.papervision3d.core.render.draw.*;
import org.papervision3d.core.material.*;
public class WireframeMaterial extends TriangleMaterial implements ITriangleDrawer {
public function WireframeMaterial(_arg1:Number=0xFF00FF, _arg2:Number=100, _arg3:Number=0){
this.lineColor = _arg1;
this.lineAlpha = _arg2;
this.lineThickness = _arg3;
this.doubleSided = false;
}
override public function toString():String{
return (((("WireframeMaterial - color:" + this.lineColor) + " alpha:") + this.lineAlpha));
}
override public function drawTriangle(_arg1:Triangle3D, _arg2:Graphics, _arg3:RenderSessionData, _arg4:BitmapData=null, _arg5:Matrix=null):void{
var _local6:Number;
var _local7:Number;
_local6 = _arg1.v0.vertex3DInstance.x;
_local7 = _arg1.v0.vertex3DInstance.y;
if (lineAlpha){
_arg2.lineStyle(lineThickness, lineColor, lineAlpha);
_arg2.moveTo(_local6, _local7);
_arg2.lineTo(_arg1.v1.vertex3DInstance.x, _arg1.v1.vertex3DInstance.y);
_arg2.lineTo(_arg1.v2.vertex3DInstance.x, _arg1.v2.vertex3DInstance.y);
_arg2.lineTo(_local6, _local7);
_arg2.lineStyle();
_arg3.renderStatistics.triangles++;
};
}
}
}//package org.papervision3d.materials
Section 156
//Cube (org.papervision3d.objects.primitives.Cube)
package org.papervision3d.objects.primitives {
import org.papervision3d.core.proto.*;
import org.papervision3d.materials.utils.*;
import org.papervision3d.core.math.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.log.*;
import org.papervision3d.core.geom.*;
import org.papervision3d.*;
public class Cube extends TriangleMesh3D {
private var insideFaces:int;
public var segments:Number3D;
private var excludeFaces:int;
public static var ALL:int = (((((FRONT + BACK) + RIGHT) + LEFT) + TOP) + BOTTOM);
public static var LEFT:int = 8;
public static var FRONT:int = 1;
public static var BOTTOM:int = 32;
public static var TOP:int = 16;
public static var BACK:int = 2;
public static var NONE:int = 0;
public static var RIGHT:int = 4;
public function Cube(_arg1:MaterialsList, _arg2:Number=500, _arg3:Number=500, _arg4:Number=500, _arg5:int=1, _arg6:int=1, _arg7:int=1, _arg8:int=0, _arg9:int=0){
super(_arg1.getMaterialByName("all"), new Array(), new Array(), null);
this.materials = _arg1;
this.insideFaces = _arg8;
this.excludeFaces = _arg9;
segments = new Number3D(_arg5, _arg6, _arg7);
buildCube(_arg2, _arg4, _arg3);
}
private function buildPlane(_arg1:String, _arg2:String, _arg3:String, _arg4:Number, _arg5:Number, _arg6:Number, _arg7:Boolean=false):void{
var _local8:MaterialObject3D;
var _local9:String;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Array;
var _local16:Array;
var _local17:Array;
var _local18:Number;
var _local19:Number;
var _local20:Number;
var _local21:Number;
var _local22:int;
var _local23:NumberUV;
var _local24:NumberUV;
var _local25:NumberUV;
var _local26:int;
var _local27:Vertex3D;
var _local28:Vertex3D;
var _local29:Vertex3D;
var _local30:Vertex3D;
_local8 = materials.getMaterialByName(_arg1);
if (!_local8){
_local8 = materials.getMaterialByName("all");
if (!_local8){
PaperLogger.warning("Required material not found in given materials list. Supported materials are: front, back, right, left, top, bottom & all.");
return;
};
};
_local8.registerObject(this);
if ((((((_arg2 == "x")) && ((_arg3 == "y")))) || ((((_arg2 == "y")) && ((_arg3 == "x")))))){
_local9 = "z";
} else {
if ((((((_arg2 == "x")) && ((_arg3 == "z")))) || ((((_arg2 == "z")) && ((_arg3 == "x")))))){
_local9 = "y";
} else {
if ((((((_arg2 == "z")) && ((_arg3 == "y")))) || ((((_arg2 == "y")) && ((_arg3 == "z")))))){
_local9 = "x";
};
};
};
_local10 = (_arg7) ? -1 : 1;
_local11 = this.segments[_arg2];
_local12 = this.segments[_arg3];
_local13 = (_local11 + 1);
_local14 = (_local12 + 1);
_local15 = this.geometry.vertices;
_local16 = this.geometry.faces;
_local17 = new Array();
_local18 = (_arg4 / 2);
_local19 = (_arg5 / 2);
_local20 = (_arg4 / _local11);
_local21 = (_arg5 / _local12);
_local22 = 0;
while (_local22 < _local13) {
_local26 = 0;
while (_local26 < _local14) {
_local27 = new Vertex3D();
_local27[_arg2] = (((_local22 * _local20) - _local18) * _local10);
_local27[_arg3] = ((_local26 * _local21) - _local19);
_local27[_local9] = _arg6;
_local15.push(_local27);
_local17.push(_local27);
_local26++;
};
_local22++;
};
_local22 = 0;
while (_local22 < _local11) {
_local26 = 0;
while (_local26 < _local12) {
_local28 = _local17[((_local22 * _local14) + _local26)];
_local29 = _local17[((_local22 * _local14) + (_local26 + 1))];
_local30 = _local17[(((_local22 + 1) * _local14) + _local26)];
_local23 = new NumberUV((_local22 / _local11), (_local26 / _local12));
_local24 = new NumberUV((_local22 / _local11), ((_local26 + 1) / _local12));
_local25 = new NumberUV(((_local22 + 1) / _local11), (_local26 / _local12));
_local16.push(new Triangle3D(this, [_local28, _local30, _local29], _local8, [_local23, _local25, _local24]));
_local28 = _local17[(((_local22 + 1) * _local14) + (_local26 + 1))];
_local29 = _local17[(((_local22 + 1) * _local14) + _local26)];
_local30 = _local17[((_local22 * _local14) + (_local26 + 1))];
_local23 = new NumberUV(((_local22 + 1) / _local11), ((_local26 + 1) / _local12));
_local24 = new NumberUV(((_local22 + 1) / _local11), (_local26 / _local12));
_local25 = new NumberUV((_local22 / _local11), ((_local26 + 1) / _local12));
_local16.push(new Triangle3D(this, [_local29, _local28, _local30], _local8, [_local24, _local23, _local25]));
_local26++;
};
_local22++;
};
}
private function buildCube(_arg1:Number, _arg2:Number, _arg3:Number):void{
var _local4:Number;
var _local5:Number;
var _local6:Number;
_local4 = (_arg1 / 2);
_local5 = (_arg2 / 2);
_local6 = (_arg3 / 2);
if (!(excludeFaces & FRONT)){
buildPlane("front", "x", "y", _arg1, _arg2, _local6, !(Boolean((insideFaces & FRONT))));
};
if (!(excludeFaces & BACK)){
buildPlane("back", "x", "y", _arg1, _arg2, -(_local6), Boolean((insideFaces & BACK)));
};
if (!(excludeFaces & RIGHT)){
buildPlane("right", "z", "y", _arg3, _arg2, _local4, Boolean((insideFaces & RIGHT)));
};
if (!(excludeFaces & LEFT)){
buildPlane("left", "z", "y", _arg3, _arg2, -(_local4), !(Boolean((insideFaces & LEFT))));
};
if (!(excludeFaces & TOP)){
buildPlane("top", "x", "z", _arg1, _arg3, _local5, Boolean((insideFaces & TOP)));
};
if (!(excludeFaces & BOTTOM)){
buildPlane("bottom", "x", "z", _arg1, _arg3, -(_local5), !(Boolean((insideFaces & BOTTOM))));
};
mergeVertices();
this.geometry.ready = true;
if (Papervision3D.useRIGHTHANDED){
this.geometry.flipFaces();
};
}
public function destroy():void{
var _local1:MaterialObject3D;
for each (_local1 in materials) {
_local1.unregisterObject(this);
};
}
}
}//package org.papervision3d.objects.primitives
Section 157
//Plane (org.papervision3d.objects.primitives.Plane)
package org.papervision3d.objects.primitives {
import org.papervision3d.core.proto.*;
import org.papervision3d.core.math.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.geom.*;
import org.papervision3d.*;
public class Plane extends TriangleMesh3D {
public var segmentsH:Number;
public var segmentsW:Number;
public static var DEFAULT_SCALE:Number = 1;
public static var DEFAULT_SEGMENTS:Number = 1;
public static var DEFAULT_SIZE:Number = 500;
public function Plane(_arg1:MaterialObject3D=null, _arg2:Number=0, _arg3:Number=0, _arg4:Number=0, _arg5:Number=0){
var _local6:Number;
super(_arg1, new Array(), new Array(), null);
this.segmentsW = ((_arg4) || (DEFAULT_SEGMENTS));
this.segmentsH = ((_arg5) || (this.segmentsW));
_local6 = DEFAULT_SCALE;
if (!_arg3){
if (_arg2){
_local6 = _arg2;
};
if (((_arg1) && (_arg1.bitmap))){
_arg2 = (_arg1.bitmap.width * _local6);
_arg3 = (_arg1.bitmap.height * _local6);
} else {
_arg2 = (DEFAULT_SIZE * _local6);
_arg3 = (DEFAULT_SIZE * _local6);
};
};
buildPlane(_arg2, _arg3);
}
private function buildPlane(_arg1:Number, _arg2:Number):void{
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Array;
var _local8:Array;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:int;
var _local14:NumberUV;
var _local15:NumberUV;
var _local16:NumberUV;
var _local17:int;
var _local18:Number;
var _local19:Number;
var _local20:Vertex3D;
var _local21:Vertex3D;
var _local22:Vertex3D;
_local3 = this.segmentsW;
_local4 = this.segmentsH;
_local5 = (_local3 + 1);
_local6 = (_local4 + 1);
_local7 = this.geometry.vertices;
_local8 = this.geometry.faces;
_local9 = (_arg1 / 2);
_local10 = (_arg2 / 2);
_local11 = (_arg1 / _local3);
_local12 = (_arg2 / _local4);
_local13 = 0;
while (_local13 < (_local3 + 1)) {
_local17 = 0;
while (_local17 < _local6) {
_local18 = ((_local13 * _local11) - _local9);
_local19 = ((_local17 * _local12) - _local10);
_local7.push(new Vertex3D(_local18, _local19, 0));
_local17++;
};
_local13++;
};
_local13 = 0;
while (_local13 < _local3) {
_local17 = 0;
while (_local17 < _local4) {
_local20 = _local7[((_local13 * _local6) + _local17)];
_local21 = _local7[((_local13 * _local6) + (_local17 + 1))];
_local22 = _local7[(((_local13 + 1) * _local6) + _local17)];
_local14 = new NumberUV((_local13 / _local3), (_local17 / _local4));
_local15 = new NumberUV((_local13 / _local3), ((_local17 + 1) / _local4));
_local16 = new NumberUV(((_local13 + 1) / _local3), (_local17 / _local4));
_local8.push(new Triangle3D(this, [_local20, _local22, _local21], material, [_local14, _local16, _local15]));
_local20 = _local7[(((_local13 + 1) * _local6) + (_local17 + 1))];
_local21 = _local7[(((_local13 + 1) * _local6) + _local17)];
_local22 = _local7[((_local13 * _local6) + (_local17 + 1))];
_local14 = new NumberUV(((_local13 + 1) / _local3), ((_local17 + 1) / _local4));
_local15 = new NumberUV(((_local13 + 1) / _local3), (_local17 / _local4));
_local16 = new NumberUV((_local13 / _local3), ((_local17 + 1) / _local4));
_local8.push(new Triangle3D(this, [_local20, _local22, _local21], material, [_local14, _local16, _local15]));
_local17++;
};
_local13++;
};
this.geometry.ready = true;
if (Papervision3D.useRIGHTHANDED){
this.geometry.flipFaces();
};
}
}
}//package org.papervision3d.objects.primitives
Section 158
//Sphere (org.papervision3d.objects.primitives.Sphere)
package org.papervision3d.objects.primitives {
import org.papervision3d.core.proto.*;
import org.papervision3d.core.math.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.geom.*;
import org.papervision3d.*;
public class Sphere extends TriangleMesh3D {
private var segmentsH:Number;
private var segmentsW:Number;
public static var MIN_SEGMENTSW:Number = 3;
public static var DEFAULT_SCALE:Number = 1;
public static var DEFAULT_RADIUS:Number = 100;
public static var DEFAULT_SEGMENTSH:Number = 6;
public static var MIN_SEGMENTSH:Number = 2;
public static var DEFAULT_SEGMENTSW:Number = 8;
public function Sphere(_arg1:MaterialObject3D=null, _arg2:Number=100, _arg3:int=8, _arg4:int=6){
var _local5:Number;
super(_arg1, new Array(), new Array(), null);
this.segmentsW = Math.max(MIN_SEGMENTSW, ((_arg3) || (DEFAULT_SEGMENTSW)));
this.segmentsH = Math.max(MIN_SEGMENTSH, ((_arg4) || (DEFAULT_SEGMENTSH)));
if (_arg2 == 0){
_arg2 = DEFAULT_RADIUS;
};
_local5 = DEFAULT_SCALE;
buildSphere(_arg2);
}
private function buildSphere(_arg1:Number):void{
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Array;
var _local8:Array;
var _local9:Array;
var _local10:int;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Array;
var _local15:Vertex3D;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:int;
var _local20:Boolean;
var _local21:Vertex3D;
var _local22:Vertex3D;
var _local23:Vertex3D;
var _local24:Vertex3D;
var _local25:Number;
var _local26:Number;
var _local27:Number;
var _local28:Number;
var _local29:NumberUV;
var _local30:NumberUV;
var _local31:NumberUV;
var _local32:NumberUV;
_local5 = Math.max(3, this.segmentsW);
_local6 = Math.max(2, this.segmentsH);
_local7 = this.geometry.vertices;
_local8 = this.geometry.faces;
_local9 = new Array();
_local3 = 0;
while (_local3 < (_local6 + 1)) {
_local11 = Number((_local3 / _local6));
_local12 = (-(_arg1) * Math.cos((_local11 * Math.PI)));
_local13 = (_arg1 * Math.sin((_local11 * Math.PI)));
_local14 = new Array();
_local2 = 0;
while (_local2 < _local5) {
_local16 = Number(((2 * _local2) / _local5));
_local17 = (_local13 * Math.sin((_local16 * Math.PI)));
_local18 = (_local13 * Math.cos((_local16 * Math.PI)));
if (!(((((_local3 == 0)) || ((_local3 == _local6)))) && ((_local2 > 0)))){
_local15 = new Vertex3D(_local18, _local12, _local17);
_local7.push(_local15);
};
_local14.push(_local15);
_local2++;
};
_local9.push(_local14);
_local3++;
};
_local10 = _local9.length;
_local3 = 0;
while (_local3 < _local10) {
_local19 = _local9[_local3].length;
if (_local3 > 0){
_local2 = 0;
while (_local2 < _local19) {
_local20 = (_local2 == (_local19 - 0));
_local21 = _local9[_local3][(_local20) ? 0 : _local2];
_local22 = _local9[_local3][(((_local2 == 0)) ? _local19 : _local2 - 1)];
_local23 = _local9[(_local3 - 1)][(((_local2 == 0)) ? _local19 : _local2 - 1)];
_local24 = _local9[(_local3 - 1)][(_local20) ? 0 : _local2];
_local25 = (_local3 / (_local10 - 1));
_local26 = ((_local3 - 1) / (_local10 - 1));
_local27 = ((_local2 + 1) / _local19);
_local28 = (_local2 / _local19);
_local29 = new NumberUV(_local27, _local26);
_local30 = new NumberUV(_local27, _local25);
_local31 = new NumberUV(_local28, _local25);
_local32 = new NumberUV(_local28, _local26);
if (_local3 < (_local9.length - 1)){
_local8.push(new Triangle3D(this, new Array(_local21, _local22, _local23), material, new Array(_local30, _local31, _local32)));
};
if (_local3 > 1){
_local8.push(new Triangle3D(this, new Array(_local21, _local23, _local24), material, new Array(_local30, _local32, _local29)));
};
_local2++;
};
};
_local3++;
};
this.geometry.ready = true;
if (Papervision3D.useRIGHTHANDED){
this.geometry.flipFaces();
};
}
}
}//package org.papervision3d.objects.primitives
Section 159
//DisplayObject3D (org.papervision3d.objects.DisplayObject3D)
package org.papervision3d.objects {
import org.papervision3d.core.proto.*;
import org.papervision3d.materials.utils.*;
import flash.display.*;
import org.papervision3d.core.math.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.view.*;
import org.papervision3d.view.layer.*;
import org.papervision3d.core.log.*;
import org.papervision3d.core.data.*;
import org.papervision3d.core.culling.*;
import org.papervision3d.*;
public class DisplayObject3D extends DisplayObjectContainer3D {
public var filters:Array;
public var extra:Object;
public var frustumTestMethod:int;// = 0
private var _rot:Quaternion;
public var id:int;
private var _rotationY:Number;
private var _rotationZ:Number;
public var meshSort:uint;// = 1
public var materials:MaterialsList;
private var _rotationX:Number;
private var _qYaw:Quaternion;
private var _xAxis:Number3D;
private var _zAxis:Number3D;
private var _scaleDirty:Boolean;// = false
private var _tempScale:Number3D;
private var _autoCalcScreenCoords:Boolean;// = false
private var _numClones:uint;// = 0
public var alpha:Number;// = 1
public var screen:Number3D;
private var _scaleX:Number;
public var screenZ:Number;
private var _scaleZ:Number;
public var geometry:GeometryObject3D;
protected var _userData:UserData;
private var _scaleY:Number;
public var visible:Boolean;
private var _qPitch:Quaternion;
protected var _useOwnContainer:Boolean;// = false
public var name:String;
public var transform:Matrix3D;
private var _position:Number3D;
public var container:ViewportLayer;
public var culled:Boolean;
public var world:Matrix3D;
public var blendMode:String;// = "normal"
private var _qRoll:Quaternion;
private var _localRotationZ:Number;// = 0
protected var _scene:SceneObject3D;// = null
private var _localRotationX:Number;// = 0
private var _material:MaterialObject3D;
public var view:Matrix3D;
private var _localRotationY:Number;// = 0
public var parent:DisplayObjectContainer3D;
private var _target:Number3D;
public var faces:Array;
private var _yAxis:Number3D;
public var flipLightDirection:Boolean;// = false
private var _rotation:Number3D;
protected var _sorted:Array;
protected var _transformDirty:Boolean;// = false
private var _rotationDirty:Boolean;// = false
public var parentContainer:DisplayObject3D;
public static const MESH_SORT_CENTER:uint = 1;
private static const LEFT:Number3D = new Number3D(-1, 0, 0);
public static const MESH_SORT_CLOSE:uint = 3;
private static const BACKWARD:Number3D = new Number3D(0, 0, -1);
private static const FORWARD:Number3D = new Number3D(0, 0, 1);
public static const MESH_SORT_FAR:uint = 2;
private static const DOWN:Number3D = new Number3D(0, -1, 0);
private static const UP:Number3D = new Number3D(0, 1, 0);
private static const RIGHT:Number3D = new Number3D(1, 0, 0);
private static var entry_count:uint = 0;
private static var _newID:int = 0;
private static var _tempMatrix:Matrix3D = Matrix3D.IDENTITY;
public static var sortedArray:Array = new Array();
public static var faceLevelMode:Boolean;
private static var _tempQuat:Quaternion = new Quaternion();
private static var toRADIANS:Number = 0.0174532925199433;
private static var toDEGREES:Number = 57.2957795130823;
public function DisplayObject3D(_arg1:String=null, _arg2:GeometryObject3D=null):void{
var _local3:Number;
faces = new Array();
meshSort = MESH_SORT_CENTER;
alpha = 1;
blendMode = BlendMode.NORMAL;
filters = [];
flipLightDirection = false;
frustumTestMethod = FrustumTestMethod.BOUNDING_SPHERE;
screen = new Number3D();
_transformDirty = false;
_useOwnContainer = false;
_scene = null;
_position = Number3D.ZERO;
_target = Number3D.ZERO;
_zAxis = Number3D.ZERO;
_xAxis = Number3D.ZERO;
_yAxis = Number3D.ZERO;
_rotation = Number3D.ZERO;
_rotationDirty = false;
_scaleDirty = false;
_numClones = 0;
_rot = new Quaternion();
_qPitch = new Quaternion();
_qYaw = new Quaternion();
_qRoll = new Quaternion();
_localRotationX = 0;
_localRotationY = 0;
_localRotationZ = 0;
_autoCalcScreenCoords = false;
super();
if (_arg1 != null){
PaperLogger.info(("DisplayObject3D: " + _arg1));
};
this.culled = false;
this.transform = Matrix3D.IDENTITY;
this.world = Matrix3D.IDENTITY;
this.view = Matrix3D.IDENTITY;
this.x = 0;
this.y = 0;
this.z = 0;
rotationX = 0;
rotationY = 0;
rotationZ = 0;
_localRotationX = (_localRotationY = (_localRotationZ = 0));
_local3 = (Papervision3D.usePERCENT) ? 100 : 1;
scaleX = _local3;
scaleY = _local3;
scaleZ = _local3;
_tempScale = new Number3D();
this.visible = true;
this.id = _newID++;
this.name = ((_arg1) || (String(this.id)));
_numClones = 0;
if (_arg2){
addGeometry(_arg2);
};
}
public function moveDown(_arg1:Number):void{
translate(_arg1, DOWN);
}
public function project(_arg1:DisplayObject3D, _arg2:RenderSessionData):Number{
var _local3:Number;
var _local4:Number;
var _local5:DisplayObject3D;
if (this._transformDirty){
updateTransform();
};
this.world.calculateMultiply(_arg1.world, this.transform);
if (_arg2.camera.culler){
if (this === _arg2.camera){
this.culled = true;
} else {
this.culled = (_arg2.camera.culler.testObject(this) < 0);
};
if (this.culled){
_arg2.renderStatistics.culledObjects++;
return (0);
};
};
if (_arg1 !== _arg2.camera){
if (_arg2.camera.useProjectionMatrix){
this.view.calculateMultiply4x4(_arg1.view, this.transform);
} else {
this.view.calculateMultiply(_arg1.view, this.transform);
};
} else {
if (_arg2.camera.useProjectionMatrix){
this.view.calculateMultiply4x4(_arg2.camera.eye, this.transform);
} else {
this.view.calculateMultiply(_arg2.camera.eye, this.transform);
};
};
if (_autoCalcScreenCoords){
calculateScreenCoords(_arg2.camera);
};
_local3 = 0;
_local4 = 0;
for each (_local5 in this._childrenByName) {
if (_local5.visible){
_local3 = (_local3 + _local5.project(this, _arg2));
_local4++;
};
};
return ((this.screenZ = (_local3 / _local4)));
}
public function set scene(_arg1:SceneObject3D):void{
var _local2:DisplayObject3D;
_scene = _arg1;
for each (_local2 in this._childrenByName) {
if (_local2.scene == null){
_local2.scene = _scene;
};
};
}
public function set z(_arg1:Number):void{
this.transform.n34 = _arg1;
}
public function get userData():UserData{
return (_userData);
}
public function get material():MaterialObject3D{
return (_material);
}
public function set userData(_arg1:UserData):void{
_userData = _arg1;
}
public function lookAt(_arg1:DisplayObject3D, _arg2:Number3D=null):void{
var _local3:DisplayObject3D;
var _local4:Matrix3D;
if ((this is CameraObject3D)){
_position.reset(this.x, this.y, this.z);
} else {
_local3 = (this.parent as DisplayObject3D);
if (_local3){
world.calculateMultiply(_local3.world, transform);
} else {
world.copy(transform);
};
_position.reset(world.n14, world.n24, world.n34);
};
if ((_arg1 is CameraObject3D)){
_target.reset(_arg1.x, _arg1.y, _arg1.z);
} else {
_local3 = (_arg1.parent as DisplayObject3D);
if (_local3){
_arg1.world.calculateMultiply(_local3.world, _arg1.transform);
} else {
_arg1.world.copy(_arg1.transform);
};
_target.reset(_arg1.world.n14, _arg1.world.n24, _arg1.world.n34);
};
_zAxis.copyFrom(_target);
_zAxis.minusEq(_position);
_zAxis.normalize();
if (_zAxis.modulo > 0.1){
_xAxis = Number3D.cross(_zAxis, ((_arg2) || (UP)), _xAxis);
_xAxis.normalize();
_yAxis = Number3D.cross(_zAxis, _xAxis, _yAxis);
_yAxis.normalize();
_local4 = this.transform;
_local4.n11 = (_xAxis.x * _scaleX);
_local4.n21 = (_xAxis.y * _scaleX);
_local4.n31 = (_xAxis.z * _scaleX);
_local4.n12 = (-(_yAxis.x) * _scaleY);
_local4.n22 = (-(_yAxis.y) * _scaleY);
_local4.n32 = (-(_yAxis.z) * _scaleY);
_local4.n13 = (_zAxis.x * _scaleZ);
_local4.n23 = (_zAxis.y * _scaleZ);
_local4.n33 = (_zAxis.z * _scaleZ);
_localRotationX = (_localRotationY = (_localRotationZ = 0));
this._transformDirty = false;
this._rotationDirty = true;
} else {
PaperLogger.error("lookAt error");
};
}
public function set rotationX(_arg1:Number):void{
this._rotationX = (Papervision3D.useDEGREES) ? (_arg1 * toRADIANS) : _arg1;
this._transformDirty = true;
}
public function calculateScreenCoords(_arg1:CameraObject3D):void{
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
if (_arg1.useProjectionMatrix){
_local2 = 0;
_local3 = 0;
_local4 = 0;
_local5 = ((((_local2 * view.n41) + (_local3 * view.n42)) + (_local4 * view.n43)) + view.n44);
_local6 = (_arg1.viewport.width / 2);
_local7 = (_arg1.viewport.height / 2);
screen.x = (((((_local2 * view.n11) + (_local3 * view.n12)) + (_local4 * view.n13)) + view.n14) / _local5);
screen.y = (((((_local2 * view.n21) + (_local3 * view.n22)) + (_local4 * view.n23)) + view.n24) / _local5);
screen.z = ((((_local2 * view.n31) + (_local3 * view.n32)) + (_local4 * view.n33)) + view.n34);
screen.x = (screen.x * _local6);
screen.y = (screen.y * _local7);
} else {
_local8 = ((_arg1.focus * _arg1.zoom) / (_arg1.focus + view.n34));
screen.x = (view.n14 * _local8);
screen.y = (view.n24 * _local8);
screen.z = view.n34;
};
}
public function set rotationZ(_arg1:Number):void{
this._rotationZ = (Papervision3D.useDEGREES) ? (_arg1 * toRADIANS) : _arg1;
this._transformDirty = true;
}
protected function setParentContainer(_arg1:DisplayObject3D, _arg2:Boolean=true):void{
var _local3:DisplayObject3D;
if (((_arg2) && (!((_arg1 == this))))){
parentContainer = _arg1;
};
for each (_local3 in children) {
_local3.setParentContainer(_arg1, _arg2);
};
}
public function addGeometry(_arg1:GeometryObject3D=null):void{
if (_arg1){
this.geometry = _arg1;
};
}
public function get sceneX():Number{
return (this.world.n14);
}
public function get scaleY():Number{
if (Papervision3D.usePERCENT){
return ((this._scaleY * 100));
};
return (this._scaleY);
}
public function get scaleZ():Number{
if (Papervision3D.usePERCENT){
return ((this._scaleZ * 100));
};
return (this._scaleZ);
}
public function moveUp(_arg1:Number):void{
translate(_arg1, UP);
}
public function get scaleX():Number{
if (Papervision3D.usePERCENT){
return ((this._scaleX * 100));
};
return (this._scaleX);
}
public function distanceTo(_arg1:DisplayObject3D):Number{
var _local2:Number;
var _local3:Number;
var _local4:Number;
_local2 = (this.x - _arg1.x);
_local3 = (this.y - _arg1.y);
_local4 = (this.z - _arg1.z);
return (Math.sqrt((((_local2 * _local2) + (_local3 * _local3)) + (_local4 * _local4))));
}
public function get scale():Number{
if ((((this._scaleX == this._scaleY)) && ((this._scaleX == this._scaleZ)))){
if (Papervision3D.usePERCENT){
return ((this._scaleX * 100));
};
return (this._scaleX);
//unresolved jump
};
return (NaN);
}
public function set rotationY(_arg1:Number):void{
this._rotationY = (Papervision3D.useDEGREES) ? (_arg1 * toRADIANS) : _arg1;
this._transformDirty = true;
}
public function clone():DisplayObject3D{
var _local1:String;
var _local2:DisplayObject3D;
var _local3:DisplayObject3D;
_local1 = ((this.name + "_") + _numClones++);
_local2 = new DisplayObject3D(_local1);
if (this.material){
_local2.material = this.material;
};
if (this.materials){
_local2.materials = this.materials.clone();
};
if (this.geometry){
_local2.geometry = this.geometry.clone(_local2);
_local2.geometry.ready = true;
};
_local2.copyTransform(this.transform);
for each (_local3 in this.children) {
_local2.addChild(_local3.clone());
};
return (_local2);
}
public function get sceneZ():Number{
return (this.world.n34);
}
private function updateRotation():void{
_tempScale.x = (Papervision3D.usePERCENT) ? (_scaleX * 100) : _scaleX;
_tempScale.y = (Papervision3D.usePERCENT) ? (_scaleY * 100) : _scaleY;
_tempScale.z = (Papervision3D.usePERCENT) ? (_scaleZ * 100) : _scaleZ;
_rotation = Matrix3D.matrix2euler(this.transform, _rotation, _tempScale);
this._rotationX = (_rotation.x * toRADIANS);
this._rotationY = (_rotation.y * toRADIANS);
this._rotationZ = (_rotation.z * toRADIANS);
this._rotationDirty = false;
}
public function hitTestObject(_arg1:DisplayObject3D, _arg2:Number=1):Boolean{
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
_local3 = (this.x - _arg1.x);
_local4 = (this.y - _arg1.y);
_local5 = (this.z - _arg1.z);
_local6 = (((_local3 * _local3) + (_local4 * _local4)) + (_local5 * _local5));
_local7 = (this.geometry) ? this.geometry.boundingSphere.maxDistance : 0;
_local8 = (_arg1.geometry) ? _arg1.geometry.boundingSphere.maxDistance : 0;
_local7 = (_local7 * _arg2);
return (((_local7 + _local8) > _local6));
}
public function set material(_arg1:MaterialObject3D):void{
if (_material){
_material.unregisterObject(this);
};
_material = _arg1;
_material.registerObject(this);
}
public function get localRotationZ():Number{
return ((Papervision3D.useDEGREES) ? (_localRotationZ * toDEGREES) : _localRotationZ);
}
override public function toString():String{
return (((((((this.name + ": x:") + Math.round(this.x)) + " y:") + Math.round(this.y)) + " z:") + Math.round(this.z)));
}
public function get localRotationY():Number{
return ((Papervision3D.useDEGREES) ? (_localRotationY * toDEGREES) : _localRotationY);
}
public function get z():Number{
return (this.transform.n34);
}
public function get localRotationX():Number{
return ((Papervision3D.useDEGREES) ? (_localRotationX * toDEGREES) : _localRotationX);
}
public function get x():Number{
return (this.transform.n14);
}
public function set autoCalcScreenCoords(_arg1:Boolean):void{
_autoCalcScreenCoords = _arg1;
}
public function moveLeft(_arg1:Number):void{
translate(_arg1, LEFT);
}
public function get scene():SceneObject3D{
return (_scene);
}
public function set useOwnContainer(_arg1:Boolean):void{
_useOwnContainer = _arg1;
setParentContainer(this, true);
}
public function copyTransform(_arg1):void{
var _local2:Matrix3D;
var _local3:Matrix3D;
if ((_arg1 is DisplayObject3D)){
DisplayObject3D(_arg1).updateTransform();
};
_local2 = this.transform;
_local3 = ((_arg1 is DisplayObject3D)) ? _arg1.transform : _arg1;
_local2.n11 = _local3.n11;
_local2.n12 = _local3.n12;
_local2.n13 = _local3.n13;
_local2.n14 = _local3.n14;
_local2.n21 = _local3.n21;
_local2.n22 = _local3.n22;
_local2.n23 = _local3.n23;
_local2.n24 = _local3.n24;
_local2.n31 = _local3.n31;
_local2.n32 = _local3.n32;
_local2.n33 = _local3.n33;
_local2.n34 = _local3.n34;
this._transformDirty = false;
this._rotationDirty = true;
}
public function get y():Number{
return (this.transform.n24);
}
public function roll(_arg1:Number):void{
_arg1 = (Papervision3D.useDEGREES) ? (_arg1 * toRADIANS) : _arg1;
if (_transformDirty){
updateTransform();
};
_qRoll.setFromAxisAngle(transform.n13, transform.n23, transform.n33, _arg1);
transform.calculateMultiply3x3(_qRoll.matrix, transform);
_localRotationZ = (_localRotationZ + _arg1);
_rotationDirty = true;
}
public function set scaleZ(_arg1:Number):void{
if (Papervision3D.usePERCENT){
this._scaleZ = (_arg1 / 100);
} else {
this._scaleZ = _arg1;
};
this._transformDirty = true;
}
public function get rotationY():Number{
if (this._rotationDirty){
updateRotation();
};
return ((Papervision3D.useDEGREES) ? (this._rotationY * toDEGREES) : this._rotationY);
}
public function get rotationZ():Number{
if (this._rotationDirty){
updateRotation();
};
return ((Papervision3D.useDEGREES) ? (this._rotationZ * toDEGREES) : this._rotationZ);
}
public function yaw(_arg1:Number):void{
_arg1 = (Papervision3D.useDEGREES) ? (_arg1 * toRADIANS) : _arg1;
if (_transformDirty){
updateTransform();
};
_qYaw.setFromAxisAngle(transform.n12, transform.n22, transform.n32, _arg1);
transform.calculateMultiply3x3(_qYaw.matrix, transform);
_localRotationY = (_localRotationY + _arg1);
_rotationDirty = true;
}
public function get rotationX():Number{
if (this._rotationDirty){
updateRotation();
};
return ((Papervision3D.useDEGREES) ? (this._rotationX * toDEGREES) : this._rotationX);
}
public function set scaleX(_arg1:Number):void{
if (Papervision3D.usePERCENT){
this._scaleX = (_arg1 / 100);
} else {
this._scaleX = _arg1;
};
this._transformDirty = true;
}
public function set scaleY(_arg1:Number):void{
if (Papervision3D.usePERCENT){
this._scaleY = (_arg1 / 100);
} else {
this._scaleY = _arg1;
};
this._transformDirty = true;
}
public function createViewportLayer(_arg1:Viewport3D, _arg2:Boolean=true):ViewportLayer{
var _local3:ViewportLayer;
_local3 = _arg1.getChildLayer(this, true);
if (_arg2){
addChildrenToLayer(this, _local3);
};
return (_local3);
}
public function translate(_arg1:Number, _arg2:Number3D):void{
var _local3:Number3D;
_local3 = _arg2.clone();
if (this._transformDirty){
updateTransform();
};
Matrix3D.rotateAxis(transform, _local3);
this.x = (this.x + (_arg1 * _local3.x));
this.y = (this.y + (_arg1 * _local3.y));
this.z = (this.z + (_arg1 * _local3.z));
}
public function updateTransform():void{
_rot.setFromEuler(_rotationY, _rotationZ, _rotationX);
this.transform.copy3x3(_rot.matrix);
_tempMatrix.reset();
_tempMatrix.n11 = this._scaleX;
_tempMatrix.n22 = this._scaleY;
_tempMatrix.n33 = this._scaleZ;
this.transform.calculateMultiply(this.transform, _tempMatrix);
_transformDirty = false;
}
public function get autoCalcScreenCoords():Boolean{
return (_autoCalcScreenCoords);
}
public function addChildrenToLayer(_arg1:DisplayObject3D, _arg2:ViewportLayer):void{
var _local3:DisplayObject3D;
for each (_local3 in _arg1.children) {
_arg2.addDisplayObject3D(_local3);
_local3.addChildrenToLayer(_local3, _arg2);
};
}
public function copyPosition(_arg1):void{
var _local2:Matrix3D;
var _local3:Matrix3D;
_local2 = this.transform;
_local3 = ((_arg1 is DisplayObject3D)) ? _arg1.transform : _arg1;
_local2.n14 = _local3.n14;
_local2.n24 = _local3.n24;
_local2.n34 = _local3.n34;
}
public function get useOwnContainer():Boolean{
return (_useOwnContainer);
}
public function getMaterialByName(_arg1:String):MaterialObject3D{
var _local2:MaterialObject3D;
var _local3:DisplayObject3D;
_local2 = (this.materials) ? this.materials.getMaterialByName(_arg1) : null;
if (_local2){
return (_local2);
};
for each (_local3 in this._childrenByName) {
_local2 = _local3.getMaterialByName(_arg1);
if (_local2){
return (_local2);
};
};
return (null);
}
public function hitTestPoint(_arg1:Number, _arg2:Number, _arg3:Number):Boolean{
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
_local4 = (this.x - _arg1);
_local5 = (this.y - _arg2);
_local6 = (this.z - _arg3);
_local7 = (((_local4 * _local4) + (_local5 * _local5)) + (_local6 * _local6));
_local8 = (this.geometry) ? this.geometry.boundingSphere.maxDistance : 0;
return ((_local8 > _local7));
}
public function moveForward(_arg1:Number):void{
translate(_arg1, FORWARD);
}
public function set scale(_arg1:Number):void{
if (Papervision3D.usePERCENT){
_arg1 = (_arg1 / 100);
};
this._scaleX = (this._scaleY = (this._scaleZ = _arg1));
this._transformDirty = true;
}
public function get sceneY():Number{
return (this.world.n24);
}
public function moveRight(_arg1:Number):void{
translate(_arg1, RIGHT);
}
public function moveBackward(_arg1:Number):void{
translate(_arg1, BACKWARD);
}
public function set localRotationY(_arg1:Number):void{
_arg1 = (Papervision3D.useDEGREES) ? (_arg1 * toRADIANS) : _arg1;
if (_transformDirty){
updateTransform();
};
_qYaw.setFromAxisAngle(transform.n12, transform.n22, transform.n32, (_localRotationY - _arg1));
transform.calculateMultiply3x3(_qYaw.matrix, transform);
_localRotationY = _arg1;
_rotationDirty = true;
}
public function set localRotationZ(_arg1:Number):void{
_arg1 = (Papervision3D.useDEGREES) ? (_arg1 * toRADIANS) : _arg1;
if (_transformDirty){
updateTransform();
};
_qRoll.setFromAxisAngle(transform.n13, transform.n23, transform.n33, (_localRotationZ - _arg1));
transform.calculateMultiply3x3(_qRoll.matrix, transform);
_localRotationZ = _arg1;
_rotationDirty = true;
}
public function set localRotationX(_arg1:Number):void{
_arg1 = (Papervision3D.useDEGREES) ? (_arg1 * toRADIANS) : _arg1;
if (this._transformDirty){
updateTransform();
};
_qPitch.setFromAxisAngle(transform.n11, transform.n21, transform.n31, (_localRotationX - _arg1));
this.transform.calculateMultiply3x3(_qPitch.matrix, transform);
_localRotationX = _arg1;
_rotationDirty = true;
}
public function set x(_arg1:Number):void{
this.transform.n14 = _arg1;
}
public function materialsList():String{
var _local1:String;
var _local2:String;
var _local3:DisplayObject3D;
_local1 = "";
for (_local2 in this.materials) {
_local1 = (_local1 + (_local2 + "\n"));
};
for each (_local3 in this._childrenByName) {
for (_local2 in _local3.materials.materialsByName) {
_local1 = (_local1 + (("+ " + _local2) + "\n"));
};
};
return (_local1);
}
public function set y(_arg1:Number):void{
this.transform.n24 = _arg1;
}
override public function addChild(_arg1:DisplayObject3D, _arg2:String=null):DisplayObject3D{
_arg1 = super.addChild(_arg1, _arg2);
if (_arg1.scene == null){
_arg1.scene = scene;
};
if (this.useOwnContainer){
_arg1.parentContainer = this;
};
return (_arg1);
}
public function pitch(_arg1:Number):void{
_arg1 = (Papervision3D.useDEGREES) ? (_arg1 * toRADIANS) : _arg1;
if (this._transformDirty){
updateTransform();
};
_qPitch.setFromAxisAngle(transform.n11, transform.n21, transform.n31, _arg1);
this.transform.calculateMultiply3x3(_qPitch.matrix, transform);
_localRotationX = (_localRotationX + _arg1);
_rotationDirty = true;
}
public static function get ZERO():DisplayObject3D{
return (new (DisplayObject3D));
}
}
}//package org.papervision3d.objects
Section 160
//BasicRenderEngine (org.papervision3d.render.BasicRenderEngine)
package org.papervision3d.render {
import org.papervision3d.core.proto.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.view.*;
import org.papervision3d.core.render.command.*;
import flash.geom.*;
import org.papervision3d.core.render.material.*;
import org.papervision3d.view.layer.*;
import org.papervision3d.core.render.*;
import org.papervision3d.core.render.sort.*;
import org.papervision3d.core.render.filter.*;
import org.papervision3d.core.render.project.*;
import org.papervision3d.events.*;
import org.papervision3d.core.utils.*;
public class BasicRenderEngine extends AbstractRenderEngine implements IRenderEngine {
public var sorter:IRenderSorter;
public var projectionPipeline:ProjectionPipeline;
protected var renderStatistics:RenderStatistics;
protected var renderDoneEvent:RendererEvent;
protected var renderList:Array;
protected var renderSessionData:RenderSessionData;
protected var stopWatch:StopWatch;
protected var projectionDoneEvent:RendererEvent;
public var filter:IRenderFilter;
protected var cleanRHD:RenderHitData;
public function BasicRenderEngine():void{
cleanRHD = new RenderHitData();
super();
init();
}
override public function removeFromRenderList(_arg1:IRenderListItem):int{
return (renderList.splice(renderList.indexOf(_arg1), 1));
}
protected function doRender(_arg1:RenderSessionData, _arg2:Array=null):RenderStatistics{
var _local3:RenderableListItem;
var _local4:Viewport3D;
var _local5:ViewportLayer;
stopWatch.reset();
stopWatch.start();
MaterialManager.getInstance().updateMaterialsBeforeRender(_arg1);
filter.filter(renderList);
sorter.sort(renderList);
_local4 = _arg1.viewPort;
while ((_local3 = renderList.pop())) {
_local5 = _local4.accessLayerFor(_local3, true);
_local3.render(_arg1, _local5.graphicsChannel);
_local4.lastRenderList.push(_local3);
_local5.processRenderItem(_local3);
};
MaterialManager.getInstance().updateMaterialsAfterRender(_arg1);
_arg1.renderStatistics.renderTime = stopWatch.stop();
_arg1.viewPort.updateAfterRender(_arg1);
return (renderStatistics);
}
protected function init():void{
renderStatistics = new RenderStatistics();
projectionPipeline = new BasicProjectionPipeline();
stopWatch = new StopWatch();
sorter = new BasicRenderSorter();
filter = new BasicRenderFilter();
renderList = new Array();
renderSessionData = new RenderSessionData();
renderSessionData.renderer = this;
projectionDoneEvent = new RendererEvent(RendererEvent.PROJECTION_DONE, renderSessionData);
renderDoneEvent = new RendererEvent(RendererEvent.RENDER_DONE, renderSessionData);
}
override public function renderScene(_arg1:SceneObject3D, _arg2:CameraObject3D, _arg3:Viewport3D, _arg4:Boolean=true):RenderStatistics{
_arg2.viewport = _arg3.sizeRectangle;
renderSessionData.scene = _arg1;
renderSessionData.camera = _arg2;
renderSessionData.viewPort = _arg3;
renderSessionData.container = _arg3.containerSprite;
renderSessionData.triangleCuller = _arg3.triangleCuller;
renderSessionData.particleCuller = _arg3.particleCuller;
renderSessionData.renderObjects = _arg1.objects;
renderSessionData.renderLayers = null;
renderSessionData.renderStatistics.clear();
_arg3.updateBeforeRender(renderSessionData);
projectionPipeline.project(renderSessionData);
if (hasEventListener(RendererEvent.PROJECTION_DONE)){
dispatchEvent(projectionDoneEvent);
};
doRender(renderSessionData, null);
if (hasEventListener(RendererEvent.RENDER_DONE)){
dispatchEvent(renderDoneEvent);
};
return (renderSessionData.renderStatistics);
}
public function hitTestPoint2D(_arg1:Point, _arg2:Viewport3D):RenderHitData{
return (_arg2.hitTestPoint2D(_arg1));
}
override public function addToRenderList(_arg1:IRenderListItem):int{
return (renderList.push(_arg1));
}
public function renderLayers(_arg1:SceneObject3D, _arg2:CameraObject3D, _arg3:Viewport3D, _arg4:Array=null, _arg5:Boolean=true):RenderStatistics{
renderSessionData.scene = _arg1;
renderSessionData.camera = _arg2;
renderSessionData.viewPort = _arg3;
renderSessionData.container = _arg3.containerSprite;
renderSessionData.triangleCuller = _arg3.triangleCuller;
renderSessionData.particleCuller = _arg3.particleCuller;
renderSessionData.renderObjects = getLayerObjects(_arg4);
renderSessionData.renderLayers = _arg4;
renderSessionData.renderStatistics.clear();
_arg3.updateBeforeRender(renderSessionData);
projectionPipeline.project(renderSessionData);
if (hasEventListener(RendererEvent.PROJECTION_DONE)){
dispatchEvent(projectionDoneEvent);
};
doRender(renderSessionData);
if (hasEventListener(RendererEvent.RENDER_DONE)){
dispatchEvent(renderDoneEvent);
};
return (renderSessionData.renderStatistics);
}
private function getLayerObjects(_arg1:Array):Array{
var _local2:Array;
var _local3:ViewportLayer;
_local2 = new Array();
for each (_local3 in _arg1) {
_local2 = _local2.concat(_local3.getLayerObjects());
};
return (_local2);
}
public function destroy():void{
renderDoneEvent = null;
projectionDoneEvent = null;
projectionPipeline = null;
sorter = null;
filter = null;
renderStatistics = null;
renderList = null;
renderSessionData.destroy();
renderSessionData = null;
cleanRHD = null;
stopWatch = null;
}
}
}//package org.papervision3d.render
Section 161
//Scene3D (org.papervision3d.scenes.Scene3D)
package org.papervision3d.scenes {
import org.papervision3d.core.proto.*;
public class Scene3D extends SceneObject3D {
}
}//package org.papervision3d.scenes
Section 162
//ViewportLayerSortMode (org.papervision3d.view.layer.util.ViewportLayerSortMode)
package org.papervision3d.view.layer.util {
public class ViewportLayerSortMode {
public static var Z_SORT:String = "z";
public static var INDEX_SORT:String = "index";
}
}//package org.papervision3d.view.layer.util
Section 163
//ViewportBaseLayer (org.papervision3d.view.layer.ViewportBaseLayer)
package org.papervision3d.view.layer {
import org.papervision3d.view.*;
import org.papervision3d.objects.*;
public class ViewportBaseLayer extends ViewportLayer {
public function ViewportBaseLayer(_arg1:Viewport3D){
super(_arg1, null);
}
override public function updateBeforeRender():void{
var _local1:int;
clear();
_local1 = (childLayers.length - 1);
while (_local1 >= 0) {
if (childLayers[_local1].dynamicLayer){
removeLayerAt(_local1);
};
_local1--;
};
super.updateBeforeRender();
}
override public function getChildLayer(_arg1:DisplayObject3D, _arg2:Boolean=true, _arg3:Boolean=false):ViewportLayer{
if (layers[_arg1]){
return (layers[_arg1]);
};
if (((_arg2) || (_arg1.useOwnContainer))){
return (getChildLayerFor(_arg1, _arg3));
};
return (this);
}
}
}//package org.papervision3d.view.layer
Section 164
//ViewportLayer (org.papervision3d.view.layer.ViewportLayer)
package org.papervision3d.view.layer {
import flash.display.*;
import org.papervision3d.view.*;
import org.papervision3d.core.render.command.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.log.*;
import flash.utils.*;
import org.papervision3d.view.layer.util.*;
public class ViewportLayer extends Sprite {
public var layerIndex:Number;
public var layers:Dictionary;
public var dynamicLayer:Boolean;// = false
public var sortMode:String;
public var weight:Number;// = 0
public var childLayers:Array;
public var forceDepth:Boolean;// = false
protected var viewport:Viewport3D;
public var screenDepth:Number;// = 0
public var displayObject3D:DisplayObject3D;
public var displayObjects:Dictionary;
public var graphicsChannel:Graphics;
public function ViewportLayer(_arg1:Viewport3D, _arg2:DisplayObject3D, _arg3:Boolean=false){
layers = new Dictionary(true);
displayObjects = new Dictionary(true);
forceDepth = false;
screenDepth = 0;
weight = 0;
sortMode = ViewportLayerSortMode.Z_SORT;
dynamicLayer = false;
super();
this.viewport = _arg1;
this.displayObject3D = _arg2;
this.dynamicLayer = _arg3;
this.graphicsChannel = this.graphics;
if (_arg3){
this.filters = _arg2.filters;
this.blendMode = _arg2.blendMode;
this.alpha = _arg2.alpha;
};
if (_arg2){
addDisplayObject3D(_arg2);
};
init();
}
public function getLayerObjects(_arg1:Array=null):Array{
var _local2:DisplayObject3D;
var _local3:ViewportLayer;
if (!_arg1){
_arg1 = new Array();
};
for each (_local2 in this.displayObjects) {
if (((_local2) && ((_local2.parent == null)))){
_arg1.push(_local2);
};
};
for each (_local3 in childLayers) {
_local3.getLayerObjects(_arg1);
};
return (_arg1);
}
protected function init():void{
childLayers = new Array();
}
public function updateInfo():void{
var _local1:ViewportLayer;
for each (_local1 in childLayers) {
_local1.updateInfo();
if (!forceDepth){
this.weight = (this.weight + _local1.weight);
this.screenDepth = (this.screenDepth + (_local1.screenDepth * _local1.weight));
};
};
if (!forceDepth){
this.screenDepth = (this.screenDepth / this.weight);
};
}
public function sortChildLayers():void{
if (sortMode == ViewportLayerSortMode.Z_SORT){
childLayers.sortOn("screenDepth", (Array.DESCENDING | Array.NUMERIC));
} else {
childLayers.sortOn("layerIndex", Array.NUMERIC);
};
orderLayers();
}
private function onChildRemoved(_arg1:ViewportLayerEvent):void{
if (_arg1.do3d){
unlinkChild(_arg1.do3d, _arg1);
};
}
public function removeAllLayers():void{
var _local1:int;
_local1 = (childLayers.length - 1);
while (_local1 >= 0) {
removeLayerAt(_local1);
_local1--;
};
}
public function updateAfterRender():void{
var _local1:ViewportLayer;
for each (_local1 in childLayers) {
_local1.updateAfterRender();
};
}
public function removeLayer(_arg1:ViewportLayer):void{
var _local2:int;
_local2 = getChildIndex(_arg1);
if (_local2 > -1){
removeLayerAt(_local2);
} else {
PaperLogger.error("Layer not found for removal.");
};
}
protected function getChildLayerFor(_arg1:DisplayObject3D, _arg2:Boolean=false):ViewportLayer{
var _local3:ViewportLayer;
if (_arg1){
_local3 = new ViewportLayer(viewport, _arg1, _arg1.useOwnContainer);
addLayer(_local3);
if (_arg2){
_arg1.addChildrenToLayer(_arg1, _local3);
};
return (_local3);
} else {
PaperLogger.warning("Needs to be a do3d");
};
return (null);
}
public function addLayer(_arg1:ViewportLayer):void{
var _local2:DisplayObject3D;
var _local3:ViewportLayer;
childLayers.push(_arg1);
addChild(_arg1);
_arg1.addEventListener(ViewportLayerEvent.CHILD_ADDED, onChildAdded);
_arg1.addEventListener(ViewportLayerEvent.CHILD_REMOVED, onChildRemoved);
for each (_local2 in _arg1.displayObjects) {
linkChild(_local2, _arg1);
};
for each (_local3 in _arg1.layers) {
for each (_local2 in _local3.displayObjects) {
linkChild(_local2, _local3);
};
};
}
public function childLayerIndex(_arg1:DisplayObject3D):Number{
var _local2:int;
_arg1 = (_arg1.parentContainer) ? _arg1.parentContainer : _arg1;
_local2 = 0;
while (_local2 < childLayers.length) {
if (childLayers[_local2].hasDisplayObject3D(_arg1)){
return (_local2);
};
_local2++;
};
return (-1);
}
protected function orderLayers():void{
var _local1:int;
_local1 = 0;
while (_local1 < childLayers.length) {
this.setChildIndex(childLayers[_local1], _local1);
childLayers[_local1].sortChildLayers();
_local1++;
};
}
public function removeLayerAt(_arg1:Number):void{
var _local2:DisplayObject3D;
for each (_local2 in childLayers[_arg1].displayObjects) {
unlinkChild(_local2);
};
removeChild(childLayers[_arg1]);
childLayers.splice(_arg1, 1);
}
protected function reset():void{
if (!forceDepth){
screenDepth = 0;
};
this.weight = 0;
}
private function linkChild(_arg1:DisplayObject3D, _arg2:ViewportLayer, _arg3:ViewportLayerEvent=null):void{
layers[_arg1] = _arg2;
dispatchEvent(new ViewportLayerEvent(ViewportLayerEvent.CHILD_ADDED, _arg1, _arg2));
}
public function updateBeforeRender():void{
var _local1:ViewportLayer;
clear();
for each (_local1 in childLayers) {
_local1.updateBeforeRender();
};
}
private function onChildAdded(_arg1:ViewportLayerEvent):void{
if (_arg1.do3d){
linkChild(_arg1.do3d, _arg1.layer, _arg1);
};
}
public function getChildLayer(_arg1:DisplayObject3D, _arg2:Boolean=true, _arg3:Boolean=false):ViewportLayer{
_arg1 = (_arg1.parentContainer) ? _arg1.parentContainer : _arg1;
if (layers[_arg1]){
return (layers[_arg1]);
};
if (_arg2){
return (getChildLayerFor(_arg1, _arg3));
};
return (null);
}
public function processRenderItem(_arg1:RenderableListItem):void{
if (!forceDepth){
this.screenDepth = (this.screenDepth + _arg1.screenDepth);
this.weight++;
};
}
public function clear():void{
graphicsChannel.clear();
reset();
}
public function removeDisplayObject3D(_arg1:DisplayObject3D):void{
displayObjects[_arg1] = null;
dispatchEvent(new ViewportLayerEvent(ViewportLayerEvent.CHILD_REMOVED, _arg1, this));
}
private function unlinkChild(_arg1:DisplayObject3D, _arg2:ViewportLayerEvent=null):void{
layers[_arg1] = null;
dispatchEvent(new ViewportLayerEvent(ViewportLayerEvent.CHILD_REMOVED, _arg1));
}
public function addDisplayObject3D(_arg1:DisplayObject3D, _arg2:Boolean=false):void{
if (!_arg1){
return;
};
displayObjects[_arg1] = _arg1;
dispatchEvent(new ViewportLayerEvent(ViewportLayerEvent.CHILD_ADDED, _arg1, this));
if (_arg2){
_arg1.addChildrenToLayer(_arg1, this);
};
}
public function hasDisplayObject3D(_arg1:DisplayObject3D):Boolean{
return (!((displayObjects[_arg1] == null)));
}
}
}//package org.papervision3d.view.layer
Section 165
//ViewportLayerEvent (org.papervision3d.view.layer.ViewportLayerEvent)
package org.papervision3d.view.layer {
import flash.events.*;
import org.papervision3d.objects.*;
public class ViewportLayerEvent extends Event {
public var layer:ViewportLayer;
public var do3d:DisplayObject3D;
public static const CHILD_REMOVED:String = "childRemoved";
public static const CHILD_ADDED:String = "childAdded";
public function ViewportLayerEvent(_arg1:String, _arg2:DisplayObject3D=null, _arg3:ViewportLayer=null){
super(_arg1, false, false);
this.do3d = _arg2;
this.layer = _arg3;
}
}
}//package org.papervision3d.view.layer
Section 166
//AbstractView (org.papervision3d.view.AbstractView)
package org.papervision3d.view {
import org.papervision3d.core.proto.*;
import flash.display.*;
import flash.events.*;
import org.papervision3d.core.view.*;
import org.papervision3d.render.*;
import org.papervision3d.scenes.*;
public class AbstractView extends Sprite implements IView {
protected var _camera:CameraObject3D;
protected var _height:Number;
public var viewport:Viewport3D;
public var scene:Scene3D;
public var renderer:BasicRenderEngine;
protected var _width:Number;
public function singleRender():void{
onRenderTick();
}
public function get camera():CameraObject3D{
return (_camera);
}
public function startRendering():void{
addEventListener(Event.ENTER_FRAME, onRenderTick);
viewport.containerSprite.cacheAsBitmap = false;
}
public function get viewportHeight():Number{
return (_height);
}
public function set viewportWidth(_arg1:Number):void{
_width = _arg1;
viewport.width = _arg1;
}
protected function onRenderTick(_arg1:Event=null):void{
renderer.renderScene(scene, _camera, viewport);
}
public function stopRendering(_arg1:Boolean=false, _arg2:Boolean=false):void{
removeEventListener(Event.ENTER_FRAME, onRenderTick);
if (_arg1){
onRenderTick();
};
if (_arg2){
viewport.containerSprite.cacheAsBitmap = true;
} else {
viewport.containerSprite.cacheAsBitmap = false;
};
}
public function get viewportWidth():Number{
return (_width);
}
public function set viewportHeight(_arg1:Number):void{
_height = _arg1;
viewport.height = _arg1;
}
}
}//package org.papervision3d.view
Section 167
//BasicView (org.papervision3d.view.BasicView)
package org.papervision3d.view {
import org.papervision3d.objects.*;
import org.papervision3d.cameras.*;
import org.papervision3d.core.view.*;
import org.papervision3d.render.*;
import org.papervision3d.scenes.*;
public class BasicView extends AbstractView implements IView {
public function BasicView(_arg1:Number=640, _arg2:Number=480, _arg3:Boolean=true, _arg4:Boolean=false, _arg5:String="Target"){
scene = new Scene3D();
viewport = new Viewport3D(_arg1, _arg2, _arg3, _arg4);
addChild(viewport);
renderer = new BasicRenderEngine();
switch (_arg5){
case CameraType.DEBUG:
_camera = new DebugCamera3D(viewport);
break;
case CameraType.TARGET:
_camera = new Camera3D(60);
_camera.target = DisplayObject3D.ZERO;
break;
case CameraType.FREE:
default:
_camera = new Camera3D(60);
break;
};
cameraAsCamera3D.update(viewport.sizeRectangle);
}
public function get cameraAsCamera3D():Camera3D{
return ((_camera as Camera3D));
}
public function get cameraAsDebugCamera3D():DebugCamera3D{
return ((_camera as DebugCamera3D));
}
}
}//package org.papervision3d.view
Section 168
//Viewport3D (org.papervision3d.view.Viewport3D)
package org.papervision3d.view {
import flash.display.*;
import flash.events.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.render.command.*;
import flash.geom.*;
import org.papervision3d.objects.*;
import org.papervision3d.view.layer.*;
import org.papervision3d.core.log.*;
import org.papervision3d.core.culling.*;
import org.papervision3d.core.view.*;
import flash.utils.*;
import org.papervision3d.core.render.*;
import org.papervision3d.core.utils.*;
public class Viewport3D extends Sprite implements IViewport3D {
protected var _interactive:Boolean;
public var cullingRectangle:Rectangle;
private var stageScaleModeSet:Boolean;// = false
protected var _viewportObjectFilter:ViewportObjectFilter;
protected var _layerInstances:Dictionary;
protected var _hWidth:Number;
protected var _autoScaleToStage:Boolean;
protected var _lastRenderer:IRenderEngine;
protected var _containerSprite:ViewportBaseLayer;
protected var _hHeight:Number;
public var sizeRectangle:Rectangle;
protected var renderHitData:RenderHitData;
protected var _autoClipping:Boolean;
protected var _height:Number;
public var interactiveSceneManager:InteractiveSceneManager;
public var lastRenderList:Array;
public var lineCuller:ILineCuller;
protected var _autoCulling:Boolean;
public var particleCuller:IParticleCuller;
protected var _width:Number;
public var triangleCuller:ITriangleCuller;
public function Viewport3D(_arg1:Number=640, _arg2:Number=480, _arg3:Boolean=false, _arg4:Boolean=false, _arg5:Boolean=true, _arg6:Boolean=true){
stageScaleModeSet = false;
super();
init();
this.interactive = _arg4;
this.viewportWidth = _arg1;
this.viewportHeight = _arg2;
this.autoClipping = _arg5;
this.autoCulling = _arg6;
this.autoScaleToStage = _arg3;
this._layerInstances = new Dictionary(true);
}
public function set autoCulling(_arg1:Boolean):void{
if (_arg1){
triangleCuller = new RectangleTriangleCuller(cullingRectangle);
particleCuller = new RectangleParticleCuller(cullingRectangle);
lineCuller = new RectangleLineCuller(cullingRectangle);
} else {
if (!_arg1){
triangleCuller = new DefaultTriangleCuller();
particleCuller = new DefaultParticleCuller();
lineCuller = new DefaultLineCuller();
};
};
_autoCulling = _arg1;
}
protected function onRemovedFromStage(_arg1:Event):void{
stage.removeEventListener(Event.RESIZE, onStageResize);
}
public function hitTestMouse():RenderHitData{
var _local1:Point;
_local1 = new Point(containerSprite.mouseX, containerSprite.mouseY);
return (hitTestPoint2D(_local1));
}
protected function init():void{
this.renderHitData = new RenderHitData();
lastRenderList = new Array();
sizeRectangle = new Rectangle();
cullingRectangle = new Rectangle();
_containerSprite = new ViewportBaseLayer(this);
_containerSprite.doubleClickEnabled = true;
addChild(_containerSprite);
addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
addEventListener(Event.REMOVED_FROM_STAGE, onRemovedFromStage);
}
protected function onStageResize(_arg1:Event=null):void{
if (_autoScaleToStage){
viewportWidth = stage.stageWidth;
viewportHeight = stage.stageHeight;
};
}
public function set autoClipping(_arg1:Boolean):void{
if (_arg1){
scrollRect = sizeRectangle;
} else {
scrollRect = null;
};
_autoClipping = _arg1;
}
public function updateAfterRender(_arg1:RenderSessionData):void{
var _local2:ViewportLayer;
if (interactive){
interactiveSceneManager.updateAfterRender();
};
if (_arg1.renderLayers){
for each (_local2 in _arg1.renderLayers) {
_local2.updateInfo();
_local2.sortChildLayers();
_local2.updateAfterRender();
};
} else {
containerSprite.updateInfo();
containerSprite.updateAfterRender();
};
containerSprite.sortChildLayers();
}
public function accessLayerFor(_arg1:RenderableListItem, _arg2:Boolean=false):ViewportLayer{
var _local3:DisplayObject3D;
if (_arg1.renderableInstance){
_local3 = _arg1.renderableInstance.instance;
_local3 = (_local3.parentContainer) ? _local3.parentContainer : _local3;
if (containerSprite.layers[_local3]){
if (_arg2){
_local3.container = containerSprite.layers[_local3];
};
return (containerSprite.layers[_local3]);
} else {
if (_local3.useOwnContainer){
return (containerSprite.getChildLayer(_local3, true, true));
};
};
};
return (containerSprite);
}
public function get viewportHeight():Number{
return (_height);
}
public function get autoCulling():Boolean{
return (_autoCulling);
}
public function updateBeforeRender(_arg1:RenderSessionData):void{
var _local2:ViewportLayer;
lastRenderList.length = 0;
if (_arg1.renderLayers){
for each (_local2 in _arg1.renderLayers) {
_local2.updateBeforeRender();
};
} else {
_containerSprite.updateBeforeRender();
};
_layerInstances = new Dictionary(true);
}
protected function onAddedToStage(_arg1:Event):void{
if (_autoScaleToStage){
setStageScaleMode();
};
stage.addEventListener(Event.RESIZE, onStageResize);
onStageResize();
}
public function getChildLayer(_arg1:DisplayObject3D, _arg2:Boolean=true, _arg3:Boolean=true):ViewportLayer{
return (containerSprite.getChildLayer(_arg1, _arg2, _arg3));
}
public function hitTestPoint2D(_arg1:Point):RenderHitData{
var _local2:RenderableListItem;
var _local3:RenderHitData;
var _local4:IRenderListItem;
var _local5:uint;
renderHitData.clear();
if (interactive){
_local3 = renderHitData;
_local5 = lastRenderList.length;
while ((_local4 = lastRenderList[--_local5])) {
if ((_local4 is RenderableListItem)){
_local2 = (_local4 as RenderableListItem);
_local3 = _local2.hitTestPoint2D(_arg1, _local3);
if (_local3.hasHit){
return (_local3);
};
};
};
};
return (renderHitData);
}
public function get containerSprite():ViewportLayer{
return (_containerSprite);
}
public function set viewportWidth(_arg1:Number):void{
_width = _arg1;
_hWidth = (_arg1 / 2);
containerSprite.x = _hWidth;
cullingRectangle.x = -(_hWidth);
cullingRectangle.width = _arg1;
sizeRectangle.width = _arg1;
if (_autoClipping){
scrollRect = sizeRectangle;
};
}
public function get autoClipping():Boolean{
return (_autoClipping);
}
protected function setStageScaleMode():void{
if (!stageScaleModeSet){
PaperLogger.info("Viewport autoScaleToStage : Papervision has changed the Stage scale mode.");
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
stageScaleModeSet = true;
};
}
public function get viewportWidth():Number{
return (_width);
}
public function set autoScaleToStage(_arg1:Boolean):void{
_autoScaleToStage = _arg1;
if (((_arg1) && (!((stage == null))))){
setStageScaleMode();
onStageResize();
};
}
public function set viewportObjectFilter(_arg1:ViewportObjectFilter):void{
_viewportObjectFilter = _arg1;
}
public function set interactive(_arg1:Boolean):void{
if (_arg1 != _interactive){
if (((_interactive) && (interactiveSceneManager))){
interactiveSceneManager.destroy();
interactiveSceneManager = null;
};
_interactive = _arg1;
if (_arg1){
interactiveSceneManager = new InteractiveSceneManager(this);
};
};
}
public function set viewportHeight(_arg1:Number):void{
_height = _arg1;
_hHeight = (_arg1 / 2);
containerSprite.y = _hHeight;
cullingRectangle.y = -(_hHeight);
cullingRectangle.height = _arg1;
sizeRectangle.height = _arg1;
if (_autoClipping){
scrollRect = sizeRectangle;
};
}
public function get viewportObjectFilter():ViewportObjectFilter{
return (_viewportObjectFilter);
}
public function get autoScaleToStage():Boolean{
return (_autoScaleToStage);
}
public function get interactive():Boolean{
return (_interactive);
}
public function destroy():void{
if (interactiveSceneManager){
interactiveSceneManager.destroy();
interactiveSceneManager = null;
};
lastRenderList = null;
}
}
}//package org.papervision3d.view
Section 169
//Papervision3D (org.papervision3d.Papervision3D)
package org.papervision3d {
import org.papervision3d.core.log.*;
public class Papervision3D {
public static var useDEGREES:Boolean = true;
public static var useRIGHTHANDED:Boolean = false;
public static var NAME:String = "Papervision3D";
public static var DATE:String = "20.08.08";
public static var AUTHOR:String = "(c) 2006-2008 Copyright by Carlos Ulloa | John Grden | Ralph Hauwert | Tim Knip | Andy Zupko";
public static var PAPERLOGGER:PaperLogger = PaperLogger.getInstance();
public static var usePERCENT:Boolean = false;
public static var VERSION:String = "Public Beta 2.0 - Great White";
}
}//package org.papervision3d
Section 170
//akce_36 (PRELOADED_fla.akce_36)
package PRELOADED_fla {
import flash.display.*;
import flash.events.*;
import flash.net.*;
public dynamic class akce_36 extends MovieClip {
public var btn:SimpleButton;
public function akce_36(){
addFrameScript(0, frame1);
}
function frame1(){
btn.addEventListener(MouseEvent.CLICK, openIphone);
}
public function openIphone(_arg1:MouseEvent):void{
navigateToURL(new URLRequest("http://iphone.flier.cz"), "_blank");
}
}
}//package PRELOADED_fla
Section 171
//arrow_114 (PRELOADED_fla.arrow_114)
package PRELOADED_fla {
import flash.display.*;
public dynamic class arrow_114 extends MovieClip {
public function arrow_114(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package PRELOADED_fla
Section 172
//btnBack_33 (PRELOADED_fla.btnBack_33)
package PRELOADED_fla {
import flash.display.*;
public dynamic class btnBack_33 extends MovieClip {
public function btnBack_33(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package PRELOADED_fla
Section 173
//btnCredits_23 (PRELOADED_fla.btnCredits_23)
package PRELOADED_fla {
import flash.display.*;
public dynamic class btnCredits_23 extends MovieClip {
public function btnCredits_23(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package PRELOADED_fla
Section 174
//btnExit2_11 (PRELOADED_fla.btnExit2_11)
package PRELOADED_fla {
import flash.display.*;
public dynamic class btnExit2_11 extends MovieClip {
public function btnExit2_11(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package PRELOADED_fla
Section 175
//btnHow_19 (PRELOADED_fla.btnHow_19)
package PRELOADED_fla {
import flash.display.*;
public dynamic class btnHow_19 extends MovieClip {
public function btnHow_19(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package PRELOADED_fla
Section 176
//btnload_21 (PRELOADED_fla.btnload_21)
package PRELOADED_fla {
import flash.display.*;
public dynamic class btnload_21 extends MovieClip {
public function btnload_21(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package PRELOADED_fla
Section 177
//btnMore_25 (PRELOADED_fla.btnMore_25)
package PRELOADED_fla {
import flash.display.*;
public dynamic class btnMore_25 extends MovieClip {
public function btnMore_25(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package PRELOADED_fla
Section 178
//btnStart_15 (PRELOADED_fla.btnStart_15)
package PRELOADED_fla {
import flash.display.*;
public dynamic class btnStart_15 extends MovieClip {
public function btnStart_15(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package PRELOADED_fla
Section 179
//button_4 (PRELOADED_fla.button_4)
package PRELOADED_fla {
import flash.display.*;
import flash.events.*;
import flash.geom.*;
import flash.filters.*;
import flash.media.*;
import flash.utils.*;
import flash.text.*;
import flash.net.*;
import flash.system.*;
import flash.ui.*;
import adobe.utils.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.printing.*;
import flash.xml.*;
public dynamic class button_4 extends MovieClip {
public function button_4(){
addFrameScript(0, frame1);
}
function frame1(){
addEventListener(MouseEvent.CLICK, clickHandler);
}
public function clickHandler(_arg1:Event):void{
MovieClip(this.parent).removeAd();
}
}
}//package PRELOADED_fla
Section 180
//ccc_82 (PRELOADED_fla.ccc_82)
package PRELOADED_fla {
import flash.display.*;
public dynamic class ccc_82 extends MovieClip {
public function ccc_82(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package PRELOADED_fla
Section 181
//credits_127 (PRELOADED_fla.credits_127)
package PRELOADED_fla {
import flash.display.*;
public dynamic class credits_127 extends MovieClip {
public function credits_127(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package PRELOADED_fla
Section 182
//damage_116 (PRELOADED_fla.damage_116)
package PRELOADED_fla {
import flash.display.*;
public dynamic class damage_116 extends MovieClip {
public var maska:MovieClip;
}
}//package PRELOADED_fla
Section 183
//damagecopy_119 (PRELOADED_fla.damagecopy_119)
package PRELOADED_fla {
import flash.display.*;
public dynamic class damagecopy_119 extends MovieClip {
public var maska:MovieClip;
}
}//package PRELOADED_fla
Section 184
//extra_content_29 (PRELOADED_fla.extra_content_29)
package PRELOADED_fla {
import flash.display.*;
import flash.events.*;
import flash.geom.*;
import flash.filters.*;
import flash.media.*;
import flash.utils.*;
import flash.text.*;
import flash.net.*;
import flash.system.*;
import flash.ui.*;
import adobe.utils.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.printing.*;
import flash.xml.*;
public dynamic class extra_content_29 extends MovieClip {
public var btnBack:MovieClip;
public function extra_content_29(){
addFrameScript(0, frame1, 1, frame2, 5, frame6, 6, frame7);
}
public function rollMe(_arg1:MouseEvent):void{
if (_arg1.target.currentFrame == 1){
_arg1.target.gotoAndStop("over");
} else {
_arg1.target.gotoAndStop("up");
};
}
function frame6(){
stop();
}
function frame7(){
stop();
btnBack.addEventListener(MouseEvent.CLICK, goBack);
btnBack.buttonMode = true;
btnBack.mouseChildren = false;
btnBack.addEventListener(MouseEvent.ROLL_OVER, rollMe);
btnBack.addEventListener(MouseEvent.ROLL_OUT, rollMe);
}
function frame1(){
stop();
}
function frame2(){
btnBack.addEventListener(MouseEvent.CLICK, goBack);
btnBack.buttonMode = true;
btnBack.mouseChildren = false;
btnBack.addEventListener(MouseEvent.ROLL_OVER, rollMe);
btnBack.addEventListener(MouseEvent.ROLL_OUT, rollMe);
}
public function goBack(_arg1:MouseEvent):void{
gotoAndStop(1);
}
}
}//package PRELOADED_fla
Section 185
//iconMap_96 (PRELOADED_fla.iconMap_96)
package PRELOADED_fla {
import flash.display.*;
public dynamic class iconMap_96 extends MovieClip {
public function iconMap_96(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package PRELOADED_fla
Section 186
//interface_mc_106 (PRELOADED_fla.interface_mc_106)
package PRELOADED_fla {
import flash.display.*;
import flash.text.*;
public dynamic class interface_mc_106 extends MovieClip {
public var arrow:MovieClip;
public var count:TextField;
public var radarek:MovieClip;
public var timer:MovieClip;
public var current_score:TextField;
public var char:MovieClip;
public var damage:MovieClip;
public var icon:MovieClip;
public var btnMute:MovieClip;
public var btnExit:MovieClip;
public var level:TextField;
public var limit:MovieClip;
public var p1:MovieClip;
public var p2:MovieClip;
public var p3:MovieClip;
public var p4:MovieClip;
public var total_score:TextField;
}
}//package PRELOADED_fla
Section 187
//kostkaK_66 (PRELOADED_fla.kostkaK_66)
package PRELOADED_fla {
import flash.display.*;
public dynamic class kostkaK_66 extends MovieClip {
public function kostkaK_66(){
addFrameScript(28, frame29);
}
function frame29(){
gotoAndPlay(2);
}
}
}//package PRELOADED_fla
Section 188
//logoAnimdd_124 (PRELOADED_fla.logoAnimdd_124)
package PRELOADED_fla {
import flash.display.*;
import flash.events.*;
import flash.geom.*;
import flash.filters.*;
import flash.media.*;
import flash.utils.*;
import flash.text.*;
import flash.net.*;
import flash.system.*;
import flash.ui.*;
import adobe.utils.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.printing.*;
import flash.xml.*;
public dynamic class logoAnimdd_124 extends MovieClip {
public var btn:MovieClip;
public function logoAnimdd_124(){
addFrameScript(9, frame10);
}
function frame10(){
btn.addEventListener(MouseEvent.CLICK, clickMe);
btn.buttonMode = true;
MovieClip(root).animReady = true;
}
public function clickMe(_arg1:MouseEvent):void{
}
}
}//package PRELOADED_fla
Section 189
//looo_126 (PRELOADED_fla.looo_126)
package PRELOADED_fla {
import flash.display.*;
import flash.events.*;
import flash.geom.*;
import flash.filters.*;
import flash.media.*;
import flash.utils.*;
import flash.text.*;
import flash.net.*;
import flash.system.*;
import flash.ui.*;
import adobe.utils.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.printing.*;
import flash.xml.*;
public dynamic class looo_126 extends MovieClip {
public function looo_126(){
addFrameScript(0, frame1, 156, frame157);
}
function frame157(){
initPlay();
stop();
}
public function openLBP(_arg1:MouseEvent):void{
navigateToURL(new URLRequest("http://www.littlebigplay.com"), "_blank");
}
public function initPlay():void{
MovieClip(root).nextFrame();
}
function frame1(){
MovieClip(this.parent).logo.addEventListener(MouseEvent.CLICK, openLBP);
MovieClip(this.parent).logo.buttonMode = true;
MovieClip(this.parent).logo.mouseChildren = false;
}
}
}//package PRELOADED_fla
Section 190
//MainTimeline (PRELOADED_fla.MainTimeline)
package PRELOADED_fla {
import flash.display.*;
import flash.events.*;
import flash.geom.*;
import flash.filters.*;
import flash.media.*;
import flash.utils.*;
import mochi.as3.*;
import CPMStar.*;
import flash.text.*;
import flash.net.*;
import flash.system.*;
import flash.ui.*;
import adobe.utils.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.printing.*;
import flash.xml.*;
public dynamic class MainTimeline extends MovieClip {
public var animReady:Boolean;
public var ad:DisplayObject;
public var loading:Boolean;
public var closeButton:MovieClip;
public var preloader1:MovieClip;
public var adBox:MovieClip;
public var CPMStarContentSpotID:String;
public var logo:MovieClip;
public function MainTimeline(){
addFrameScript(0, frame1, 2, frame3, 3, frame4);
}
function frame3(){
stop();
}
function frame1(){
MochiServices.connect("7a4d61af79147190", root);
MochiBot.track(this, "49c75572");
animReady = false;
loading = false;
closeButton.visible = false;
preloader1.scaleX = 0;
preloader1.addEventListener(Event.ENTER_FRAME, onEnterFramePreload);
stop();
CPMStarContentSpotID = "1203QB27509D8";
ad = new AdLoader(CPMStarContentSpotID);
adBox.addChild(ad);
closeButton.buttonMode = true;
}
function frame4(){
}
public function onEnterFramePreload(_arg1:Event):void{
var _local2:uint;
var _local3:uint;
_local2 = this.root.loaderInfo.bytesLoaded;
_local3 = this.root.loaderInfo.bytesTotal;
_arg1.target.scaleX = (_local2 / _local3);
if (_local3 == _local2){
loading = true;
preloader1.removeEventListener(Event.ENTER_FRAME, onEnterFramePreload);
closeButton.visible = true;
};
}
public function removeAd():void{
removeChild(adBox);
gotoAndStop(3);
}
public function submitMe(_arg1):void{
MochiScores.showLeaderboard({boardID:"90ac1f16959551a6", score:_arg1});
}
}
}//package PRELOADED_fla
Section 191
//meric_105 (PRELOADED_fla.meric_105)
package PRELOADED_fla {
import flash.display.*;
public dynamic class meric_105 extends MovieClip {
public function meric_105(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package PRELOADED_fla
Section 192
//panacek_107 (PRELOADED_fla.panacek_107)
package PRELOADED_fla {
import flash.display.*;
public dynamic class panacek_107 extends MovieClip {
public function panacek_107(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package PRELOADED_fla
Section 193
//panacekk_111 (PRELOADED_fla.panacekk_111)
package PRELOADED_fla {
import flash.display.*;
public dynamic class panacekk_111 extends MovieClip {
public function panacekk_111(){
addFrameScript(1, frame2, 15, frame16);
}
function frame16(){
gotoAndStop(2);
}
function frame2(){
stop();
}
}
}//package PRELOADED_fla
Section 194
//s_12 (PRELOADED_fla.s_12)
package PRELOADED_fla {
import flash.display.*;
public dynamic class s_12 extends MovieClip {
public function s_12(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package PRELOADED_fla
Section 195
//static_78 (PRELOADED_fla.static_78)
package PRELOADED_fla {
import flash.display.*;
import flash.events.*;
import flash.net.*;
public dynamic class static_78 extends MovieClip {
public var bc:MovieClip;
public function static_78(){
addFrameScript(0, frame1);
}
public function openLBP(_arg1:MouseEvent):void{
navigateToURL(new URLRequest("http://www.littlebigplay.com"), "_blank");
}
function frame1(){
bc.addEventListener(MouseEvent.CLICK, openLBP);
bc.buttonMode = true;
bc.mouseChildren = false;
}
}
}//package PRELOADED_fla
Section 196
//static2_80 (PRELOADED_fla.static2_80)
package PRELOADED_fla {
import flash.display.*;
public dynamic class static2_80 extends MovieClip {
public function static2_80(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package PRELOADED_fla
Section 197
//Symbol12_115 (PRELOADED_fla.Symbol12_115)
package PRELOADED_fla {
import flash.display.*;
public dynamic class Symbol12_115 extends MovieClip {
public function Symbol12_115(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package PRELOADED_fla
Section 198
//Symbol17_103 (PRELOADED_fla.Symbol17_103)
package PRELOADED_fla {
import flash.display.*;
public dynamic class Symbol17_103 extends MovieClip {
public function Symbol17_103(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package PRELOADED_fla
Section 199
//Symbol3_41 (PRELOADED_fla.Symbol3_41)
package PRELOADED_fla {
import flash.display.*;
public dynamic class Symbol3_41 extends MovieClip {
public function Symbol3_41(){
addFrameScript(29, frame30);
}
function frame30(){
gotoAndPlay(16);
}
}
}//package PRELOADED_fla
Section 200
//accomplished (accomplished)
package {
import flash.media.*;
public dynamic class accomplished extends Sound {
}
}//package
Section 201
//accomplishedShort (accomplishedShort)
package {
import flash.media.*;
public dynamic class accomplishedShort extends Sound {
}
}//package
Section 202
//backS (backS)
package {
import flash.media.*;
public dynamic class backS extends Sound {
}
}//package
Section 203
//bigEx (bigEx)
package {
import flash.media.*;
public dynamic class bigEx extends Sound {
}
}//package
Section 204
//black (black)
package {
import flash.display.*;
public dynamic class black extends BitmapData {
public function black(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 205
//Character (Character)
package {
import flash.display.*;
public dynamic class Character extends BitmapData {
public function Character(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 206
//Dum (Dum)
package {
import flash.display.*;
public dynamic class Dum extends BitmapData {
public function Dum(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 207
//gameControls (gameControls)
package {
import flash.display.*;
public dynamic class gameControls extends MovieClip {
}
}//package
Section 208
//Ground (Ground)
package {
import flash.display.*;
public dynamic class Ground extends BitmapData {
public function Ground(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 209
//helicopter (helicopter)
package {
import flash.media.*;
public dynamic class helicopter extends Sound {
}
}//package
Section 210
//heliSides (heliSides)
package {
import flash.display.*;
public dynamic class heliSides extends BitmapData {
public function heliSides(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 211
//helpMe (helpMe)
package {
import flash.media.*;
public dynamic class helpMe extends Sound {
}
}//package
Section 212
//Ice (Ice)
package {
import flash.display.*;
public dynamic class Ice extends BitmapData {
public function Ice(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 213
//maskac (maskac)
package {
import flash.display.*;
public dynamic class maskac extends BitmapData {
public function maskac(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 214
//mc_again (mc_again)
package {
import flash.display.*;
public dynamic class mc_again extends MovieClip {
public function mc_again(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package
Section 215
//mcKonec (mcKonec)
package {
import flash.display.*;
import flash.text.*;
public dynamic class mcKonec extends MovieClip {
public var blocker:MovieClip;
public var btnExit2:MovieClip;
public var score:TextField;
public var btnSubmit:MovieClip;
public function mcKonec(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package
Section 216
//Menu (Menu)
package {
import flash.display.*;
public dynamic class Menu extends MovieClip {
public var blocker:MovieClip;
public var btnHow:MovieClip;
public var btnStart:MovieClip;
public var btnLoad:MovieClip;
public var bb:MovieClip;
public var extra_content:MovieClip;
public var btnCredits:MovieClip;
public var btnMore:MovieClip;
public function Menu(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
blocker.mouseEnabled = false;
bb.mouseEnabled = true;
}
}
}//package
Section 217
//menu_music (menu_music)
package {
import flash.media.*;
public dynamic class menu_music extends Sound {
}
}//package
Section 218
//MochiBot (MochiBot)
package {
import flash.display.*;
import flash.net.*;
import flash.system.*;
public dynamic class MochiBot extends Sprite {
public static function track(_arg1:Sprite, _arg2:String):MochiBot{
var _local3:MochiBot;
var _local4:String;
var _local5:URLVariables;
var _local6:String;
var _local7:URLRequest;
var _local8:Loader;
if (Security.sandboxType == "localWithFile"){
return (null);
};
_local3 = new (MochiBot);
_arg1.addChild(_local3);
Security.allowDomain("*");
Security.allowInsecureDomain("*");
_local4 = "http://core.mochibot.com/my/core.swf";
_local5 = new URLVariables();
_local5["sb"] = Security.sandboxType;
_local5["v"] = Capabilities.version;
_local5["swfid"] = _arg2;
_local5["mv"] = "8";
_local5["fv"] = "9";
_local6 = _local3.root.loaderInfo.loaderURL;
if (_local6.indexOf("http") == 0){
_local5["url"] = _local6;
} else {
_local5["url"] = "local";
};
_local7 = new URLRequest(_local4);
_local7.contentType = "application/x-www-form-urlencoded";
_local7.method = URLRequestMethod.POST;
_local7.data = _local5;
_local8 = new Loader();
_local3.addChild(_local8);
_local8.load(_local7);
return (_local3);
}
}
}//package
Section 219
//newLevel (newLevel)
package {
import flash.display.*;
import flash.events.*;
import flash.text.*;
import flash.net.*;
public dynamic class newLevel extends MovieClip {
public var blocker:MovieClip;
public var w12:MovieClip;
public var chopper:MovieClip;
public var score:TextField;
public var w1:MovieClip;
public var w4:MovieClip;
public var w6:MovieClip;
public var w8:MovieClip;
public var w7:MovieClip;
public var btnSubmit:MovieClip;
public var w9:MovieClip;
public var w2:MovieClip;
public var btnClick:MovieClip;
public var w3:MovieClip;
public var btnMore:MovieClip;
public var w10:MovieClip;
public var w5:MovieClip;
public var w13:MovieClip;
public var w14:MovieClip;
public var w11:MovieClip;
public function newLevel(){
addFrameScript(0, frame1);
}
public function openLink(_arg1:MouseEvent):void{
navigateToURL(new URLRequest("http://www.littlebigplay.com/3D"), "_blank");
}
function frame1(){
stop();
btnMore.addEventListener(MouseEvent.CLICK, openLink);
btnMore.buttonMode = true;
}
}
}//package
Section 220
//panacekPng (panacekPng)
package {
import flash.display.*;
public dynamic class panacekPng extends BitmapData {
public function panacekPng(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 221
//podlaha1 (podlaha1)
package {
import flash.display.*;
public dynamic class podlaha1 extends BitmapData {
public function podlaha1(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 222
//podlahaa3 (podlahaa3)
package {
import flash.display.*;
public dynamic class podlahaa3 extends BitmapData {
public function podlahaa3(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 223
//radarek (radarek)
package {
import flash.display.*;
public dynamic class radarek extends MovieClip {
}
}//package
Section 224
//Road (Road)
package {
import flash.display.*;
public dynamic class Road extends BitmapData {
public function Road(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 225
//Rocks (Rocks)
package {
import flash.display.*;
public dynamic class Rocks extends BitmapData {
public function Rocks(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 226
//RollBall_class (RollBall_class)
package {
import jiglib.math.*;
import jiglib.physics.*;
import jiglib.geometry.*;
import org.papervision3d.materials.utils.*;
import flash.display.*;
import flash.events.*;
import org.papervision3d.core.math.*;
import caurina.transitions.*;
import org.papervision3d.view.*;
import org.papervision3d.objects.*;
import org.papervision3d.materials.*;
import org.papervision3d.materials.shaders.*;
import org.papervision3d.cameras.*;
import flash.media.*;
import org.papervision3d.objects.primitives.*;
import flash.utils.*;
import mochi.as3.*;
import org.papervision3d.view.layer.util.*;
import jiglib.plugin.papervision3d.*;
import org.papervision3d.lights.*;
import flash.net.*;
import flash.ui.*;
public class RollBall_class extends BasicView {
private var map4_1:Array;
private var which;
var addingTimer:Timer;
private var countEx:Number;// = 0
private var map15_1:Array;
private var slots:Number;// = 4
public var bc:MovieClip;
private var map3_1:Array;
private var exited:Boolean;// = false
private var map3:Number;// = 1
private var map4:Number;// = 1
private var current_score:Number;// = 0
public var interface_mc:MovieClip;
private var map2:Number;// = 1
private var physics:Papervision3DPhysics;
private var map5:Number;// = 1
private var map6:Number;// = 1
private var map7:Number;// = 1
private var so;
private var physicsObject:RigidBody;
private var speed:Number;
private var map8:Number;// = 1
private var map1:Number;// = 1
private var allowJumpTimer:Timer;
private var gouraudShaderMat:ShadedMaterial;
private var map14_1:Array;
private var arr_posuv_right:Array;
private var map9:Number;// = 1
public var t:DisplayObject3D;
private var map11:Number;// = 1
private var arr_chars:Array;
private var tm:Timer;
private var map12:Number;// = 1
private var map15:Number;// = 1
private var map10:Number;// = 1
private var map13:Number;// = 1
private var map2_1:Array;
private var finish:Boolean;// = false
private var arr_posuv_left:Array;
private var map13_1:Array;
private var finishPoint:RigidBody;
private var controls:MovieClip;
private var flying:Boolean;// = false
private var map1_1:Array;
private var gouraudShader:GouraudShader;
private var map9_2:Array;
private var map9_1:Array;
private var keyRight:Boolean;// = false
private var added:Boolean;// = true
private var keyLeft:Boolean;// = false
private var map12_1:Array;
private var mc_tryagain:MovieClip;
private var allowJump:Boolean;// = true
private var cameraTarget:DisplayObject3D;
private var map11_1:Array;
private var map8_1:Array;
private var map14:Number;// = 1
private var arr_posuv_up:Array;
private var map7_1:Array;
private var canvas:Sprite;
private var arr_posuv_down:Array;
private var keyUp:Boolean;// = false
private var menu:MovieClip;
private var keyForward:Boolean;// = false
private var tileW:Number;// = 600
private var arr_lifts:Array;
private var map10_1:Array;
private var arr_pos:Array;
private var sphereObject:Cube;
private var keyReverse:Boolean;// = false
private var level:Number;// = 1
private var ground:RigidBody;
public var EarthTexture:Class;
private var springCamera:SpringCamera3D;
private var moveForce:Number;// = 10
private var map6_1:Array;
private var mc_konec:MovieClip;
private var pHelp:Boolean;// = true
private var map5_1:Array;
private var audio:Number;// = 1
private var total_score:Number;// = 0
private var sceneLight:PointLight3D;
private var mc_next:MovieClip;
private var zastav:Boolean;// = false
public function RollBall_class(){
keyRight = false;
keyLeft = false;
keyForward = false;
keyReverse = false;
keyUp = false;
moveForce = 10;
arr_lifts = [];
arr_posuv_right = [];
arr_posuv_left = [];
arr_posuv_up = [];
arr_posuv_down = [];
zastav = false;
arr_pos = [];
level = 1;
mc_next = new newLevel();
mc_tryagain = new mc_again();
controls = new gameControls();
mc_konec = new mcKonec();
finish = false;
exited = false;
tm = new Timer(100);
current_score = 0;
total_score = 0;
allowJumpTimer = new Timer(1000, 1);
so = SharedObject.getLocal("HELIX3");
added = true;
arr_chars = [];
slots = 4;
tileW = 600;
map1 = 1;
map1_1 = [];
map2 = 1;
map2_1 = [];
map3 = 1;
map3_1 = [];
map4 = 1;
map4_1 = [];
map5 = 1;
map5_1 = [];
map6 = 1;
map6_1 = [];
map7 = 1;
map7_1 = [];
map8 = 1;
map8_1 = [];
map9 = 1;
map9_1 = [];
map9_2 = [];
map10 = 1;
map10_1 = [];
map11 = 1;
map11_1 = [];
map12 = 1;
map12_1 = [];
map13 = 1;
map13_1 = [];
map14 = 1;
map14_1 = [];
map15 = 1;
map15_1 = [];
pHelp = true;
allowJump = true;
flying = false;
audio = 1;
countEx = 0;
canvas = new Sprite();
super(600, 400, true, false, CameraType.TARGET);
addEventListener(Event.ADDED_TO_STAGE, aplicationInited);
}
public function destroy(_arg1:Plane):void{
scene.removeChild(_arg1);
_arg1 = null;
}
private function deleteAll():void{
var _local1:uint;
var _local2:uint;
interface_mc.arrow.gotoAndStop(1);
_local1 = 0;
while (_local1 < physics.arr_objects.length) {
scene.removeChild(physics.arr_objects[_local1][0]);
physics.removeBody(physics.arr_objects[_local1][1]);
_local1++;
};
_local2 = 0;
while (_local2 < arr_chars.length) {
scene.removeChild(arr_chars[_local2]);
interface_mc.radarek.removeChild(arr_chars[_local2].extra);
arr_chars[_local2].extra = null;
arr_chars[_local2] = null;
_local2++;
};
arr_chars = [];
}
private function restart():void{
deleteAll();
arr_chars = [];
countEx = 0;
interface_mc.damage.maska.scaleX = 1;
initArrays();
physics.arr_objects = [];
initMaps();
createFloor(1);
createSphere();
createChopper();
resetCurrentScore();
}
public function moveDown(_arg1):void{
if (_arg1){
Tweener.addTween(_arg1, {y:(_arg1.y - 50), time:0.2, transition:"linear", onComplete:againJump, onCompleteParams:[_arg1]});
};
}
private function submitScore2(_arg1:MouseEvent):void{
MovieClip(root).submitMe(total_score);
}
private function mute(_arg1:MouseEvent):void{
if (audio == 1){
audio = 0;
interface_mc.btnMute.alpha = 0.5;
SoundMixer.soundTransform = new SoundTransform(0);
} else {
audio = 1;
interface_mc.btnMute.alpha = 1;
SoundMixer.soundTransform = new SoundTransform(1);
};
}
private function setCurrentScore(_arg1:TimerEvent):void{
current_score = (current_score - speed);
interface_mc.timer.maska.scaleX = (current_score / 1000);
interface_mc.current_score.text = current_score.toString();
if (interface_mc.timer.maska.scaleX <= 0){
stopTiming();
zastav = true;
bigExplode(sphereObject);
scene.removeChild(t);
removeBall();
playSound(new bigEx(), 1, 0, 200);
};
}
private function setCamera():void{
springCamera = new SpringCamera3D();
springCamera.mass = 10;
springCamera.damping = 10;
springCamera.stiffness = 1;
springCamera.lookOffset = new Number3D(0, 0, 0);
springCamera.positionOffset = new Number3D(-3500, 1000, 0);
springCamera.focus = 100;
springCamera.zoom = 10;
}
private function goRight(_arg1:RigidBody):void{
Tweener.addTween(_arg1, {x:(_arg1.x + tileW), time:2, onComplete:goLeft, transition:"linear", onCompleteParams:[_arg1]});
}
private function playSound(_arg1:Sound, _arg2:Number, _arg3:Number=0, _arg4:Number=0):void{
var _local5:*;
var _local6:SoundTransform;
_local5 = _arg1.play(_arg4, _arg3);
_local6 = _local5.soundTransform;
_local6.volume = _arg2;
_local5.soundTransform = _local6;
}
private function resetScores():void{
interface_mc.total_score.text = total_score.toString();
interface_mc.current_score.text = current_score.toString();
}
private function restartTimer():void{
}
private function createFloor(_arg1:Number):void{
var _local2:Array;
var _local3:MaterialsList;
var _local4:BitmapAssetMaterial;
var _local5:BitmapAssetMaterial;
var _local6:RigidBody;
var _local7:Number;
var _local8:Boolean;
var _local9:Number;
var _local10:Number;
var _local11:BitmapAssetMaterial;
var _local12:BitmapAssetMaterial;
var _local13:Number;
var _local14:Cube;
var _local15:MovieClip;
_local2 = this[((("map" + level) + "_") + _arg1)];
speed = this[((("map" + level) + "_") + _arg1)].speed;
_local3 = new MaterialsList();
if (level <= 5){
_local3.addMaterial(new BitmapAssetMaterial("Rocks"), "all");
_local4 = new BitmapAssetMaterial("Rocks");
_local5 = new BitmapAssetMaterial("Rocks");
bc.gotoAndStop(1);
};
if ((((level > 5)) && ((level <= 10)))){
_local3.addMaterial(new BitmapAssetMaterial("Snow"), "all");
_local4 = new BitmapAssetMaterial("Snow");
_local5 = new BitmapAssetMaterial("Ice");
bc.gotoAndStop(2);
};
if (level > 10){
_local3.addMaterial(new BitmapAssetMaterial("Dum"), "all");
_local4 = new BitmapAssetMaterial("Ground");
_local5 = new BitmapAssetMaterial("Road");
_local11 = new BitmapAssetMaterial("Dum");
_local12 = new BitmapAssetMaterial("topCity");
bc.gotoAndStop(3);
};
_local7 = 0;
_local8 = false;
_local9 = 5;
_local10 = 0;
while (_local10 < _local2.length) {
_local13 = 0;
while (_local13 < _local2[0].length) {
if (_local2[_local10][_local13] == 4){
arr_pos.push((_local10 * tileW), (2990 - ((_local10 - 1) * 600)), (-(_local13) * tileW));
_local2[_local10][_local13] = 1;
_local8 = true;
};
if (_local2[_local10][_local13] == 1){
if (_local2[_local10][_local13] == 1){
if (_local8){
_local8 = false;
_local6 = physics.createCube(new MaterialsList({front:_local4, back:_local4, left:_local4, right:_local4, top:new BitmapAssetMaterial("Znacka"), bottom:_local4}), tileW, tileW, tileW, 3, 1, 1);
finishPoint = _local6;
} else {
_local6 = physics.createCube(_local3, tileW, tileW, tileW, 3, 1, 1);
};
_local6.z = (-(_local13) * tileW);
_local6.y = (2600 - ((_local10 - 1) * 600));
_local6.mass = 0.1;
_local6.movable = false;
};
} else {
if (_local2[_local10][_local13] == 2){
_local6 = physics.createCube(new MaterialsList({front:_local4, back:_local4, left:_local4, right:_local4, top:_local5, bottom:_local4}), tileW, tileW, tileW, 3, 1, 1);
_local6.z = (-(_local13) * tileW);
_local6.y = (2600 - ((_local10 - 1) * 600));
_local6.mass = 0.1;
_local6.movable = false;
} else {
if (_local2[_local10][_local13] == 3){
_local14 = new Cube(new MaterialsList({front:null, back:null, left:new BitmapAssetMaterial("panacekPng"), right:new BitmapAssetMaterial("panacekPng"), top:null, bottom:new BitmapAssetMaterial("panacekPng")}), 100, 100, 200, 1, 1, 1);
scene.addChild(_local14);
_local14.z = (-(_local13) * tileW);
_local14.y = (2400 - ((_local10 - 1) * 600));
_local15 = new radarek();
_local15.name = (("t_" + _local10) + _local13);
_local14.extra = _local15;
interface_mc.radarek.addChild(_local15);
arr_chars.push(_local14);
} else {
if (_local2[_local10][_local13] == 5){
_local6 = physics.createCube(new MaterialsList({front:_local11, back:_local11, left:_local11, right:_local11, top:_local12, bottom:_local11}), tileW, tileW, tileW);
_local6.z = (-(_local13) * tileW);
_local6.y = (2600 - ((_local10 - 1) * 600));
_local6.mass = 0.1;
_local6.movable = false;
};
};
};
};
_local13++;
};
_local10++;
};
_arg1++;
if (_arg1 <= this[("map" + level)]){
createFloor(_arg1);
};
setupInfo();
addChild(interface_mc);
}
private function keyUpHandler(_arg1:KeyboardEvent):void{
switch (_arg1.keyCode){
case Keyboard.LEFT:
keyForward = false;
break;
case Keyboard.RIGHT:
keyReverse = false;
break;
case Keyboard.DOWN:
keyLeft = false;
break;
case Keyboard.UP:
flying = false;
break;
case Keyboard.SPACE:
flying = false;
};
}
public function checkPos():void{
var _local1:*;
if (pHelp){
_local1 = 0;
while (_local1 < arr_chars.length) {
if ((((t.distanceTo(arr_chars[_local1]) < 800)) && (!((which == arr_chars[_local1]))))){
playHelp(new helpMe(), 0.2, 0, 900);
which = arr_chars[_local1];
Tweener.addTween(arr_chars[_local1], {y:(arr_chars[_local1].y + 50), time:0.2, transition:"linear", onComplete:moveDown, onCompleteParams:[arr_chars[_local1]]});
break;
};
arr_chars[_local1].extra.x = ((t.z - arr_chars[_local1].z) / 120);
arr_chars[_local1].extra.y = ((t.y - arr_chars[_local1].y) / 120);
_local1++;
};
};
}
private function initArrays():void{
arr_lifts = [];
arr_pos = [];
arr_posuv_left = [];
arr_posuv_right = [];
arr_posuv_up = [];
arr_posuv_down = [];
if (physics){
physics.arr_objects = [];
};
}
private function playHelp(_arg1:Sound, _arg2:Number, _arg3:Number=0, _arg4:Number=0):void{
var _local5:*;
var _local6:SoundTransform;
_local5 = _arg1.play(_arg4, _arg3);
_local6 = _local5.soundTransform;
_local6.volume = _arg2;
_local5.soundTransform = _local6;
_local5.addEventListener(Event.SOUND_COMPLETE, allowSound);
pHelp = false;
}
private function initButtons():void{
menu.btnStart.addEventListener(MouseEvent.CLICK, startGame, false, 0, true);
menu.btnHow.addEventListener(MouseEvent.CLICK, showExtra, false, 0, true);
menu.btnCredits.addEventListener(MouseEvent.CLICK, showExtra, false, 0, true);
menu.btnMore.addEventListener(MouseEvent.CLICK, openLink, false, 0, true);
menu.btnStart.addEventListener(MouseEvent.ROLL_OVER, rollMe, false, 0, true);
menu.btnHow.addEventListener(MouseEvent.ROLL_OVER, rollMe, false, 0, true);
menu.btnCredits.addEventListener(MouseEvent.ROLL_OVER, rollMe, false, 0, true);
menu.btnMore.addEventListener(MouseEvent.ROLL_OVER, rollMe, false, 0, true);
menu.btnStart.addEventListener(MouseEvent.ROLL_OUT, rollMe, false, 0, true);
menu.btnHow.addEventListener(MouseEvent.ROLL_OUT, rollMe, false, 0, true);
menu.btnCredits.addEventListener(MouseEvent.ROLL_OUT, rollMe, false, 0, true);
menu.btnMore.addEventListener(MouseEvent.ROLL_OUT, rollMe, false, 0, true);
menu.btnStart.buttonMode = true;
menu.btnHow.buttonMode = true;
menu.btnCredits.buttonMode = true;
menu.btnMore.buttonMode = true;
menu.btnStart.mouseChildren = false;
menu.btnHow.mouseChildren = false;
menu.btnCredits.mouseChildren = false;
menu.btnMore.mouseChildren = false;
if (so.data.Level == undefined){
menu.btnLoad.mouseEnabled = false;
menu.btnLoad.alpha = 0.4;
} else {
menu.btnLoad.addEventListener(MouseEvent.CLICK, loadGame, false, 0, true);
menu.btnLoad.addEventListener(MouseEvent.ROLL_OVER, rollMe, false, 0, true);
menu.btnLoad.addEventListener(MouseEvent.ROLL_OUT, rollMe, false, 0, true);
menu.btnLoad.mouseEnabled = true;
menu.btnLoad.alpha = 1;
menu.btnLoad.buttonMode = true;
menu.btnLoad.mouseChildren = false;
current_score = 1000;
interface_mc.timer.maska.scaleX = (current_score / 1000);
};
}
private function setupLight():void{
sceneLight.x = sphereObject.x;
sceneLight.y = (sphereObject.y + 400);
sceneLight.z = (sphereObject.z - 300);
}
private function setupLighting():void{
sceneLight = new PointLight3D(true, true);
sceneLight.x = 0;
sceneLight.y = 400;
sceneLight.z = -300;
}
private function tryAgain():void{
restart();
addChild(mc_tryagain);
mc_tryagain.gotoAndStop(1);
added = true;
}
public function aplicationInited(_arg1:Event):void{
removeEventListener(Event.ADDED_TO_STAGE, aplicationInited);
initMenu();
}
public function checkEnd():void{
if (((!(finish)) && ((arr_chars.length == 0)))){
stopTiming();
finish = true;
SoundMixer.stopAll();
if (level != 14){
playSound(new accomplishedShort(), 1, 0, 200);
} else {
playSound(new accomplished(), 1, 0, 200);
};
showFinish();
};
}
private function goForward(_arg1:RigidBody):void{
Tweener.addTween(_arg1, {z:(_arg1.z - (2 * tileW)), time:3, onComplete:goBackward, transition:"linear", onCompleteParams:[_arg1]});
}
private function finalLaunch():void{
SoundMixer.stopAll();
mc_next.btnClick.removeEventListener(MouseEvent.CLICK, startMe);
removeChild(mc_next);
mc_next = null;
current_score = 1000;
interface_mc.timer.maska.scaleX = (current_score / 1000);
initGameSettings();
createChopper();
playSound(new helicopter(), 1, 999);
removeChild(menu);
menu = null;
}
public function setupInfo():void{
interface_mc.count.text = arr_chars.length.toString();
if (arr_chars.length == 0){
playSound(new backS(), 1, 0);
interface_mc.arrow.gotoAndStop(2);
};
}
private function initMenu():void{
menu = new Menu();
menu.extra_content.gotoAndStop(1);
addChild(menu);
initButtons();
SoundMixer.stopAll();
playSound(new menu_music(), 0.5, 999);
}
private function exit2(_arg1:MouseEvent):void{
removeChild(mc_konec);
deleteAll();
removeBall();
scene.removeChild(t);
t = null;
tm.removeEventListener(TimerEvent.TIMER, setCurrentScore);
initMenu();
exited = true;
finish = false;
}
private function gameLoaded():void{
mc_next = new newLevel();
addChild(mc_next);
mc_next.score.text = total_score.toString();
gameLaunched2();
}
private function nextLevel(_arg1:MouseEvent):void{
SoundMixer.stopAll();
addChild(mc_tryagain);
interface_mc.damage.maska.scaleX = 1;
mc_tryagain.gotoAndStop(1);
addingTimer.removeEventListener(TimerEvent.TIMER, addScore);
resetCurrentScore();
interface_mc.level.text = level.toString();
mc_next.btnClick.removeEventListener(MouseEvent.CLICK, nextLevel);
removeChild(mc_next);
mc_next = null;
initMaps();
deleteAll();
removeBall();
deleteAll();
arr_chars = [];
physics.arr_objects = [];
arr_lifts = [];
arr_pos = [];
arr_posuv_left = [];
arr_posuv_right = [];
arr_posuv_up = [];
arr_posuv_down = [];
createFloor(1);
createSphere();
zastav = false;
finish = false;
stage.focus = this;
stage.focus = null;
playSound(new helicopter(), 1, 999);
}
private function keyDownHandler(_arg1:KeyboardEvent):void{
switch (_arg1.keyCode){
case Keyboard.LEFT:
keyForward = true;
keyReverse = false;
break;
case Keyboard.RIGHT:
keyReverse = true;
keyForward = false;
break;
case Keyboard.DOWN:
keyLeft = true;
keyRight = false;
break;
case Keyboard.UP:
flying = true;
break;
case Keyboard.SPACE:
if (physicsObject.movable == false){
runMe();
} else {
if (!zastav){
flying = true;
};
};
break;
};
}
public function findCollumn(_arg1:DisplayObject3D):Number{
return (Math.floor((_arg1.x / tileW)));
}
private function removeBall():void{
physics.removeBody(physicsObject);
scene.removeChild(sphereObject);
}
private function stopTiming():void{
tm.removeEventListener(TimerEvent.TIMER, setCurrentScore);
}
private function showExtra(_arg1:MouseEvent):void{
menu.extra_content.gotoAndStop(_arg1.target.name);
menu.extra_content.scaleX = (menu.extra_content.scaleY = 5);
Tweener.addTween(menu.extra_content, {scaleX:1, scaleY:1, time:1});
}
private function addScore(_arg1:TimerEvent):void{
var _local2:Number;
_local2 = Number(mc_next.score.text);
_local2++;
mc_next.score.text = _local2.toString();
}
private function saveData():void{
so.data.Level = level;
so.data.Score = total_score;
}
private function goLeft(_arg1:RigidBody):void{
Tweener.addTween(_arg1, {x:(_arg1.x - tileW), time:2, onComplete:goRight, transition:"linear", onCompleteParams:[_arg1]});
}
public function setArrow():void{
if (arr_chars[0]){
interface_mc.arrow.rotation = (((180 / Math.PI) * Math.atan2((arr_chars[0].y - t.y), (arr_chars[0].z - t.z))) - 180);
} else {
interface_mc.arrow.rotation = (((180 / Math.PI) * Math.atan2((arr_pos[1] - t.y), (arr_pos[2] - t.z))) - 180);
};
}
private function goBackward(_arg1:RigidBody):void{
Tweener.addTween(_arg1, {z:(_arg1.z + (2 * tileW)), time:3, onComplete:goForward, transition:"linear", onCompleteParams:[_arg1]});
}
private function destroyMe(_arg1:Plane):void{
scene.removeChild(_arg1);
_arg1 = null;
countEx++;
if (countEx == 50){
tryAgain();
};
}
public function resetMeters():void{
var _local1:*;
_local1 = 1;
while (_local1 <= 4) {
interface_mc[("p" + _local1)].gotoAndStop(1);
_local1++;
};
slots = 4;
}
public function explode(_arg1:DisplayObject3D):void{
var _local2:uint;
var _local3:Plane;
var _local4:*;
var _local5:*;
var _local6:*;
var _local7:*;
var _local8:*;
_local2 = 0;
while (_local2 <= 18) {
_local3 = new Plane(new BitmapAssetMaterial("black"), (Math.random() * 50), (Math.random() * 50));
_local3.x = _arg1.x;
_local3.z = _arg1.z;
_local3.y = _arg1.y;
_local4 = ((_local3.x + (Math.random() * 700)) - 350);
_local5 = ((_local3.y + (Math.random() * 700)) - 350);
_local6 = ((_local3.z + (Math.random() * 700)) - 350);
_local7 = ((Math.random() * 400) - 200);
_local8 = ((Math.random() * 400) - 200);
Tweener.addTween(_local3, {z:_local6, x:_local4, y:_local5, rotationX:_local7, rotationY:_local8, transition:"linear", time:1, onComplete:destroy, onCompleteParams:[_local3]});
scene.addChild(_local3);
_local2++;
};
}
private function gameLaunched2():void{
mc_next.btnClick.addEventListener(MouseEvent.CLICK, startMe, false, 0, true);
mc_next.btnClick.buttonMode = true;
mc_next.btnClick.mouseChildren = false;
mc_next.btnSubmit.visible = false;
setIcons();
level++;
}
private function rollMe(_arg1:MouseEvent):void{
if (_arg1.target.currentFrame == 1){
_arg1.target.gotoAndStop(2);
if (((!((_arg1.target.name == "btnExit2"))) && (!((_arg1.target.name == "btnSubmit"))))){
Tweener.addTween(_arg1.target, {y:340.4, time:1});
};
} else {
_arg1.target.gotoAndStop(1);
if (((!((_arg1.target.name == "btnExit2"))) && (!((_arg1.target.name == "btnSubmit"))))){
Tweener.addTween(_arg1.target, {y:360.4, time:1});
};
};
}
private function startTiming():void{
tm.addEventListener(TimerEvent.TIMER, setCurrentScore);
tm.start();
}
private function allowSound(_arg1:Event):void{
pHelp = true;
}
private function exit(_arg1:MouseEvent):void{
deleteAll();
removeBall();
scene.removeChild(t);
t = null;
if (added){
removeChild(mc_tryagain);
};
tm.removeEventListener(TimerEvent.TIMER, setCurrentScore);
stage.removeEventListener(MouseEvent.MOUSE_UP, runMe);
exited = true;
interface_mc.btnExit.removeEventListener(MouseEvent.CLICK, exit);
interface_mc.btnExit.buttonMode = false;
initMenu();
}
private function openLink(_arg1:MouseEvent):void{
navigateToURL(new URLRequest("http://www.littlebigplay.com/3D"), "_blank");
}
public function findRow(_arg1:DisplayObject3D):Number{
return (Math.floor((_arg1.z / tileW)));
}
private function submitScore(_arg1:MouseEvent):void{
var _local2:Number;
_local2 = Number(mc_konec.score.text);
MovieClip(root).submitMe(_local2);
}
private function startAddingPoints():void{
mc_next.score.text = interface_mc.total_score.text;
addingTimer = new Timer(0.0005, current_score);
addingTimer.addEventListener(TimerEvent.TIMER, addScore, false, 0, true);
addingTimer.start();
}
private function addKeyboardListeners():void{
stage.focus = this;
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
stage.addEventListener(KeyboardEvent.KEY_UP, keyUpHandler);
stage.focus = null;
}
private function initGameSettings():void{
initArrays();
addChild(controls);
interface_mc.btnMute.addEventListener(MouseEvent.CLICK, mute, false, 0, true);
interface_mc.btnExit.addEventListener(MouseEvent.CLICK, exit, false, 0, true);
interface_mc.btnExit.buttonMode = true;
interface_mc.btnMute.buttonMode = true;
interface_mc.btnMute.mouseChildren = false;
interface_mc.btnExit.mouseChildren = false;
interface_mc.level.text = level.toString();
resetScores();
initMaps();
viewport.containerSprite.sortMode = ViewportLayerSortMode.INDEX_SORT;
physics = new Papervision3DPhysics(scene, 15);
addKeyboardListeners();
createFloor(1);
setCamera();
createSphere();
startRendering();
exited = false;
allowJumpTimer.addEventListener(TimerEvent.TIMER, setJump);
addChild(mc_tryagain);
mc_tryagain.gotoAndStop(1);
added = true;
}
public function againJumpDown(_arg1):void{
if (_arg1){
Tweener.addTween(_arg1, {y:(_arg1.y - 50), time:0.2, transition:"linear"});
};
}
private function runMe():void{
if ((((physicsObject.movable == false)) && (!(finish)))){
physicsObject.movable = true;
startTiming();
zastav = false;
mc_tryagain.gotoAndStop(2);
added = false;
};
}
private function resetCurrentScore():void{
current_score = 1000;
interface_mc.current_score.text = current_score;
interface_mc.timer.maska.scaleX = (current_score / 1000);
}
override protected function onRenderTick(_arg1:Event=null):void{
var _local2:*;
if (!exited){
if (physicsObject.collisions.length != 0){
moveForce = 10;
} else {
moveForce = 3;
};
if (keyLeft){
};
if (keyRight){
};
if (keyForward){
Tweener.addTween(t, {rotationY:0, time:1});
physicsObject.addWorldForce(new JNumber3D(0, 0, moveForce), physicsObject.currentState.position);
};
if (keyReverse){
Tweener.addTween(t, {rotationY:180, time:1});
physicsObject.addWorldForce(new JNumber3D(0, 0, -(moveForce)), physicsObject.currentState.position);
};
if (flying){
physicsObject.addWorldForce(new JNumber3D(0, 5, 0), physicsObject.currentState.position);
};
physics.step();
renderer.renderScene(scene, springCamera, viewport);
cameraTarget.copyPosition(sphereObject);
if (finishPoint.collisions.length > 0){
resetMeters();
checkEnd();
};
if ((((physicsObject.collisions.length > 0)) && (!(zastav)))){
if (physicsObject.collisions[0].objInfo.body0 == finishPoint){
} else {
if (physicsObject.collisions[0].objInfo.body1 == finishPoint){
} else {
interface_mc.damage.maska.scaleX = (interface_mc.damage.maska.scaleX - 0.2);
if (interface_mc.damage.maska.scaleX <= 0.2){
interface_mc.damage.maska.scaleX = 0;
stopTiming();
zastav = true;
bigExplode(sphereObject);
scene.removeChild(t);
removeBall();
playSound(new bigEx(), 1, 0, 200);
} else {
explode(sphereObject);
playSound(new takeSound(), 1, 0, 100);
};
};
};
};
if (sphereObject){
_local2 = 0;
while (_local2 < arr_chars.length) {
if (arr_chars[_local2].hitTestObject(sphereObject)){
scene.removeChild(arr_chars[_local2]);
interface_mc.radarek.removeChild(arr_chars[_local2].extra);
arr_chars[_local2].extra = null;
arr_chars[_local2] = null;
arr_chars.splice(_local2, 1);
setupInfo();
playSound(new takeS(), 0.2, 0);
if (arr_chars.length != 0){
interface_mc.char.play();
};
};
_local2++;
};
};
};
if (t){
t.x = sphereObject.x;
t.y = (sphereObject.y - 70);
t.z = sphereObject.z;
setArrow();
checkPos();
};
}
private function startGame(_arg1:MouseEvent):void{
total_score = 0;
Tweener.addTween(menu.blocker, {alpha:1, time:1, transition:"linear", onComplete:newGame});
menu.btnStart.removeEventListener(MouseEvent.CLICK, startGame);
menu.btnHow.removeEventListener(MouseEvent.CLICK, showExtra);
menu.btnCredits.removeEventListener(MouseEvent.CLICK, showExtra);
menu.btnMore.removeEventListener(MouseEvent.CLICK, openLink);
}
private function gameLaunched():void{
mc_next.btnClick.addEventListener(MouseEvent.CLICK, startMe, false, 0, true);
mc_next.btnClick.buttonMode = true;
mc_next.btnClick.mouseChildren = false;
mc_next.btnSubmit.visible = false;
setIcons();
level = 1;
}
private function startMe(_arg1:MouseEvent):void{
mc_next.blocker.gotoAndStop(2);
mc_next.blocker.alpha = 0;
Tweener.addTween(mc_next.blocker, {alpha:1, time:1, transition:"linear", onComplete:finalLaunch});
}
private function setJump(_arg1:TimerEvent):void{
allowJump = true;
}
public function rotateVrtule(_arg1:DisplayObject3D):void{
Tweener.addTween(_arg1, {rotationY:(_arg1.rotationY + 360), transition:"linear", time:0.5, onComplete:rotateVrtule, onCompleteParams:[_arg1]});
}
public function newGame():void{
level = 0;
mc_next = new newLevel();
addChild(mc_next);
gameLaunched();
}
private function setTotalScore():void{
total_score = (total_score + current_score);
total_score = Math.floor(total_score);
interface_mc.total_score.text = total_score.toString();
}
public function createChopper():void{
var _local1:BitmapAssetMaterial;
var _local2:BitmapAssetMaterial;
var _local3:BitmapAssetMaterial;
var _local4:BitmapAssetMaterial;
var _local5:BitmapAssetMaterial;
var _local6:*;
var _local7:*;
var _local8:*;
var _local9:*;
var _local10:*;
var _local11:*;
var _local12:*;
var _local13:Plane;
t = new DisplayObject3D();
_local1 = new BitmapAssetMaterial("maskac");
_local2 = new BitmapAssetMaterial("maskac");
_local3 = new BitmapAssetMaterial("heliSides");
_local4 = new BitmapAssetMaterial("sideLeft");
_local5 = new BitmapAssetMaterial("zadek");
_local6 = new Cube(new MaterialsList({front:_local2, back:_local5, left:_local4, right:_local3, top:_local1, bottom:_local1}), 20, 40, 20, 1, 1, 1);
_local7 = new Cube(new MaterialsList({all:new BitmapAssetMaterial("black")}), 80, 5, 1);
_local8 = new Cube(new MaterialsList({all:new BitmapAssetMaterial("black")}), 80, 5, 1);
_local9 = new Cube(new MaterialsList({all:_local1}), 10, 40, 5);
_local10 = new Cube(new MaterialsList({all:new BitmapAssetMaterial("black")}), 5, 8, 5);
_local11 = new Cube(new MaterialsList({all:new BitmapAssetMaterial("black")}), 20, 10, 1);
_local12 = new Cube(new MaterialsList({all:new BitmapAssetMaterial("black")}), 2, 10, 10);
_local13 = new Plane(new BitmapAssetMaterial("black"), 50, 10, 1, 1);
_local13.pitch(90);
_local13.y = 20;
_local13.z = 5;
_local7.y = 35;
_local8.y = 35;
_local8.rotationY = 90;
_local11.y = 30;
_local11.z = -40;
_local12.y = 35;
_local12.z = -40;
_local9.y = 22.5;
_local9.z = -25;
_local10.z = 23;
_local10.y = 17;
rotateVrtule(_local7);
rotateVrtule(_local8);
_local6.y = 20;
t.addChild(_local6);
t.addChild(_local7);
t.addChild(_local8);
t.addChild(_local9);
t.addChild(_local11);
t.addChild(_local12);
t.addChild(_local10);
t.addChild(_local13);
t.x = sphereObject.x;
t.z = sphereObject.z;
t.y = 2990;
t.rotationY = 180;
t.scale = 3;
scene.addChild(t);
}
public function againJump(_arg1):void{
if (_arg1){
Tweener.addTween(_arg1, {y:(_arg1.y + 50), time:0.2, transition:"linear", onComplete:againJumpDown, onCompleteParams:[_arg1]});
};
}
public function bigExplode(_arg1:DisplayObject3D):void{
var _local2:uint;
var _local3:BitmapAssetMaterial;
var _local4:Plane;
var _local5:*;
var _local6:*;
var _local7:*;
var _local8:*;
var _local9:*;
_local2 = 0;
while (_local2 <= 50) {
_local3 = new BitmapAssetMaterial("black");
_local3.doubleSided = true;
_local4 = new Plane(_local3, (Math.random() * 50), (Math.random() * 50));
_local4.x = _arg1.x;
_local4.z = _arg1.z;
_local4.y = _arg1.y;
_local5 = ((_local4.x + (Math.random() * 700)) - 350);
_local6 = ((_local4.y + (Math.random() * 700)) - 350);
_local7 = ((_local4.z + (Math.random() * 700)) - 350);
_local8 = ((Math.random() * 200) - 100);
_local9 = ((Math.random() * 200) - 100);
Tweener.addTween(_local4, {z:_local7, x:_local5, y:_local6, rotationX:_local8, rotationY:_local9, transition:"linear", time:1, onComplete:destroyMe, onCompleteParams:[_local4]});
scene.addChild(_local4);
_local2++;
};
}
private function initMaps():void{
map1_1 = new Array([0, 0, 0, 0, 3, 3], [0, 0, 3, 0, 2, 2], [4, 2, 2, 2, 2, 2]);
map2_1 = new Array([0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 3, 0, 0], [0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 2, 0, 0], [0, 0, 3, 0, 2, 2, 2, 3, 0, 0, 2, 3, 0], [0, 0, 2, 2, 2, 2, 2, 2, 0, 0, 2, 2, 0], [4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]);
map3_1 = new Array([0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3], [3, 0, 2, 0, 0, 4, 0, 0, 0, 0, 0, 0, 2], [2, 0, 2, 0, 0, 2, 3, 0, 0, 3, 0, 0, 2], [2, 3, 2, 3, 3, 2, 2, 0, 3, 2, 2, 3, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]);
map4_1 = new Array([0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [0, 0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 2], [0, 0, 0, 0, 0, 0, 0, 3, 0, 3, 0, 3, 2], [0, 0, 0, 2, 0, 0, 0, 2, 2, 2, 0, 2, 2], [0, 0, 3, 2, 0, 0, 2, 2, 0, 0, 0, 0, 2], [0, 0, 2, 2, 3, 0, 0, 0, 0, 0, 2, 0, 2], [0, 0, 2, 2, 2, 0, 0, 3, 0, 0, 2, 3, 2], [4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]);
map5_1 = new Array([0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 2, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0], [3, 0, 2, 4, 0, 0, 2, 0, 0, 3, 3, 3, 0], [2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 0], [2, 3, 0, 0, 0, 0, 0, 2, 3, 2, 0, 2, 0], [2, 2, 0, 0, 0, 0, 0, 2, 2, 2, 0, 2, 0], [2, 0, 0, 0, 2, 2, 0, 0, 2, 3, 0, 0, 0], [2, 3, 0, 0, 0, 2, 0, 0, 2, 2, 2, 0, 2], [2, 2, 2, 0, 3, 2, 3, 0, 3, 0, 0, 0, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]);
map6_1 = new Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 3, 2, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 0, 0, 0, 0, 3, 2, 2, 2, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 3, 2, 2, 2, 3, 0, 0, 0, 2, 2, 2, 2, 0, 0, 0], [0, 0, 0, 0, 0, 2, 3, 2, 2, 2, 2, 2, 0, 0, 0, 2, 0, 2, 2, 3, 0, 3], [0, 0, 0, 0, 2, 2, 2, 2, 2, 0, 0, 2, 0, 0, 0, 0, 0, 2, 2, 2, 0, 2], [0, 0, 0, 2, 2, 2, 2, 2, 2, 3, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0, 2], [4, 0, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 2, 0, 0, 3, 0, 0, 0, 3, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]);
map7_1 = new Array([2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [2, 0, 0, 2, 0, 2, 0, 0, 2, 0, 0, 3, 0, 2], [2, 3, 0, 0, 0, 2, 0, 0, 2, 0, 0, 2, 0, 2], [2, 2, 0, 3, 3, 3, 0, 0, 0, 0, 2, 2, 3, 2], [2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2], [2, 2, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 2], [2, 0, 0, 3, 2, 2, 0, 0, 0, 0, 0, 0, 3, 2], [2, 0, 0, 2, 2, 0, 0, 0, 3, 0, 0, 2, 2, 2], [2, 0, 0, 3, 0, 0, 0, 2, 2, 2, 0, 0, 0, 2], [2, 0, 2, 2, 0, 2, 0, 0, 0, 2, 0, 0, 0, 2], [2, 0, 0, 2, 0, 2, 0, 0, 0, 2, 2, 2, 0, 2], [2, 3, 0, 0, 0, 2, 2, 2, 0, 2, 3, 0, 0, 2], [2, 2, 0, 0, 0, 0, 0, 3, 0, 2, 2, 0, 0, 2], [2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]);
map8_1 = new Array([4, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 0, 2, 3, 0, 0, 3, 0, 2], [2, 0, 3, 2, 0, 2, 2, 0, 0, 2, 0, 2], [2, 0, 2, 2, 0, 2, 0, 0, 2, 2, 0, 2], [2, 0, 2, 0, 0, 2, 3, 0, 2, 2, 0, 2], [2, 0, 2, 0, 2, 2, 2, 0, 0, 0, 0, 2], [2, 0, 2, 3, 3, 0, 2, 0, 0, 0, 0, 2], [2, 0, 2, 2, 2, 0, 2, 0, 2, 2, 0, 2], [2, 0, 2, 2, 2, 0, 2, 0, 2, 3, 0, 2], [2, 3, 0, 2, 0, 0, 2, 0, 2, 2, 0, 2], [2, 2, 0, 0, 0, 0, 0, 0, 2, 3, 0, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]);
map9_1 = new Array([0, 0, 3, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 2, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 2, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 2, 2, 2, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 2, 2, 2, 3, 2, 0, 0, 0, 0, 0, 0, 0, 0], [3, 2, 0, 0, 0, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0], [2, 2, 2, 2, 0, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0], [2, 2, 2, 2, 0, 2, 2, 2, 0, 0, 3, 0, 0, 0, 0, 0], [2, 2, 0, 3, 0, 0, 2, 2, 3, 0, 2, 0, 0, 0, 0, 0], [2, 0, 0, 2, 0, 3, 0, 2, 2, 0, 2, 3, 0, 0, 0, 0], [2, 0, 2, 2, 2, 2, 0, 2, 2, 0, 2, 2, 0, 3, 0, 0], [2, 0, 2, 2, 2, 2, 0, 2, 2, 0, 2, 2, 3, 2, 0, 0], [2, 0, 0, 0, 0, 2, 0, 2, 2, 0, 2, 2, 2, 2, 0, 0], [2, 3, 2, 0, 0, 0, 0, 3, 0, 0, 2, 2, 2, 2, 2, 4], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]);
map10_1 = new Array([0, 2, 2, 2, 2, 2, 2, 2, 0, 2, 0, 0, 0, 2, 2, 2], [0, 2, 0, 3, 0, 0, 0, 2, 2, 2, 0, 2, 0, 2, 2, 2], [0, 2, 0, 2, 0, 2, 0, 0, 3, 0, 0, 2, 0, 3, 0, 2], [0, 2, 0, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2], [0, 2, 3, 0, 0, 2, 0, 2, 0, 0, 0, 2, 2, 2, 0, 2], [0, 2, 2, 0, 0, 0, 0, 2, 0, 2, 0, 0, 2, 2, 0, 2], [0, 0, 2, 2, 2, 2, 0, 3, 0, 2, 2, 0, 2, 2, 0, 2], [0, 0, 2, 0, 0, 2, 2, 2, 2, 0, 2, 3, 0, 2, 0, 2], [0, 0, 2, 0, 3, 0, 2, 0, 3, 0, 2, 2, 0, 2, 0, 2], [0, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0, 0, 2, 3, 2], [4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]);
map11_1 = new Array([0, 0, 0, 0, 0, 0, 3, 3, 0, 3, 3, 3, 0, 0, 0, 0, 0, 0, 3, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3], [0, 0, 0, 3, 3, 0, 5, 5, 0, 5, 5, 5, 0, 0, 0, 0, 0, 0, 5, 5, 0, 5, 0, 5, 0, 0, 3, 3, 3, 0, 0, 5], [0, 0, 0, 5, 5, 0, 5, 5, 0, 5, 5, 5, 3, 3, 5, 5, 0, 3, 5, 5, 3, 5, 3, 5, 0, 0, 5, 5, 5, 0, 3, 5], [4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]);
map12_1 = new Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 0, 0, 0, 0, 0, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4], [0, 0, 0, 3, 0, 0, 0, 0, 0, 5, 5, 0, 0, 0, 0, 0, 5, 5, 0, 0, 0, 0, 3, 3, 3, 0, 0, 0, 0, 0, 0, 2], [0, 0, 0, 5, 0, 0, 3, 0, 0, 5, 5, 0, 0, 0, 0, 3, 2, 2, 0, 0, 0, 0, 5, 5, 5, 0, 0, 0, 0, 0, 0, 2], [0, 0, 0, 5, 0, 0, 5, 0, 0, 5, 5, 0, 0, 0, 2, 2, 2, 2, 0, 0, 0, 0, 2, 2, 2, 0, 0, 0, 0, 0, 0, 2], [0, 0, 0, 5, 0, 0, 5, 0, 0, 5, 5, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 2, 2, 2, 0, 0, 0, 3, 3, 3, 2], [0, 0, 3, 5, 3, 0, 5, 0, 3, 5, 5, 3, 0, 0, 2, 2, 3, 3, 0, 0, 5, 5, 2, 2, 2, 0, 0, 0, 5, 5, 5, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]);
map13_1 = new Array([3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0], [5, 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 5, 5, 0, 3, 0, 3], [2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 5, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 5, 0, 5], [2, 2, 0, 0, 0, 0, 0, 0, 3, 3, 0, 0, 5, 0, 5, 2, 0, 2, 5, 0, 3, 0, 0, 0, 0, 0, 2, 2, 0, 5, 0, 5], [2, 2, 0, 0, 0, 0, 0, 0, 5, 5, 0, 0, 5, 3, 2, 2, 0, 2, 2, 3, 5, 0, 0, 0, 3, 0, 2, 2, 0, 5, 3, 5], [3, 3, 0, 0, 3, 3, 0, 0, 5, 5, 0, 0, 5, 2, 2, 2, 0, 2, 2, 2, 5, 0, 0, 0, 5, 5, 2, 2, 0, 2, 2, 2], [5, 5, 0, 0, 5, 5, 3, 3, 5, 5, 3, 3, 5, 2, 0, 0, 0, 2, 2, 2, 5, 3, 3, 3, 5, 5, 2, 2, 3, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]);
map14_1 = new Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 2, 2, 2, 2, 3, 0, 2, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 3, 0, 0, 2, 2, 0, 2, 2, 2, 2, 0, 0, 5, 0, 0, 2, 2], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 0, 2, 2, 0, 3, 0, 0, 2, 0, 3, 2, 0, 0, 5, 3, 0, 2, 2], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 2, 2, 0, 0, 2, 2, 2, 2, 0, 2, 0, 2, 2, 2, 0, 5, 5, 0, 2, 2], [0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 0, 2, 2, 2, 3, 0, 0, 2, 3, 0, 2, 3, 0, 0, 2, 0, 5, 5, 0, 2, 2], [0, 0, 3, 3, 3, 0, 0, 0, 2, 2, 2, 0, 0, 0, 2, 2, 2, 0, 2, 2, 0, 2, 2, 2, 0, 2, 3, 5, 5, 3, 2, 2], [0, 0, 5, 5, 5, 0, 0, 2, 2, 2, 2, 3, 2, 0, 0, 0, 2, 0, 2, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2], [4, 0, 5, 5, 5, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 3, 0, 2, 2, 2, 2, 3, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]);
map1_1.speed = 1;
map2_1.speed = 1.2;
map3_1.speed = 1.1;
map4_1.speed = 1.5;
map5_1.speed = 0.8;
map6_1.speed = 0.8;
map7_1.speed = 0.7;
map8_1.speed = 0.75;
map9_1.speed = 0.8;
map10_1.speed = 0.75;
map11_1.speed = 1.3;
map12_1.speed = 0.8;
map13_1.speed = 0.6;
map14_1.speed = 0.5;
}
private function createPanacek():void{
}
private function setIcons():void{
var _local1:*;
var _local2:*;
_local1 = 1;
while (_local1 < 14) {
mc_next[("w" + _local1)].gotoAndStop(1);
_local1++;
};
_local2 = 1;
while (_local2 <= level) {
mc_next[("w" + _local2)].gotoAndStop(2);
_local2++;
};
if (level == 0){
mc_next.chopper.x = mc_next[("w" + 1)].x;
mc_next.chopper.y = mc_next[("w" + 1)].y;
} else {
mc_next.chopper.x = mc_next[("w" + level)].x;
mc_next.chopper.y = mc_next[("w" + level)].y;
};
Tweener.addTween(mc_next.chopper, {x:mc_next[("w" + (level + 1))].x, y:mc_next[("w" + (level + 1))].y, time:1, transition:"linear"});
}
private function createSphere():void{
sphereObject = new Cube(new MaterialsList({front:new BitmapAssetMaterial("Character"), back:new BitmapAssetMaterial("Character"), left:new BitmapAssetMaterial("Character"), right:new BitmapAssetMaterial("Character"), top:new BitmapAssetMaterial("Character"), bottom:new BitmapAssetMaterial("Character")}), 100, 220, 100, 1, 1, 1);
scene.addChild(sphereObject);
sphereObject.visible = false;
physicsObject = new JBox(new Pv3dMesh(sphereObject), 100, 220, 100);
physicsObject.y = arr_pos[1];
physicsObject.z = arr_pos[2];
physicsObject.mass = 1;
physicsObject.friction = 0.2;
physicsObject.restitution = 5;
physics.addBody(physicsObject);
physicsObject.movable = false;
cameraTarget = new DisplayObject3D();
cameraTarget.copyPosition(sphereObject);
scene.addChild(cameraTarget);
springCamera.target = cameraTarget;
}
private function showFinish():void{
physicsObject.movable = false;
if (level != 14){
mc_next = new newLevel();
addChild(mc_next);
startAddingPoints();
setTotalScore();
setIcons();
saveData();
level++;
mc_next.btnClick.addEventListener(MouseEvent.CLICK, nextLevel, false, 0, true);
mc_next.btnClick.buttonMode = true;
mc_next.btnClick.mouseChildren = false;
mc_next.btnSubmit.addEventListener(MouseEvent.CLICK, submitScore2, false, 0, true);
mc_next.btnSubmit.buttonMode = true;
mc_next.btnSubmit.mouseChildren = false;
} else {
setTotalScore();
addChild(mc_konec);
mc_konec.score.text = Math.floor(total_score);
mc_konec.btnSubmit.addEventListener(MouseEvent.ROLL_OVER, rollMe, false, 0, true);
mc_konec.btnExit2.addEventListener(MouseEvent.ROLL_OVER, rollMe, false, 0, true);
mc_konec.btnSubmit.addEventListener(MouseEvent.ROLL_OUT, rollMe, false, 0, true);
mc_konec.btnExit2.addEventListener(MouseEvent.ROLL_OUT, rollMe, false, 0, true);
mc_konec.btnExit2.addEventListener(MouseEvent.CLICK, exit2, false, 0, true);
mc_konec.btnSubmit.addEventListener(MouseEvent.CLICK, submitScore, false, 0, true);
mc_konec.btnSubmit.buttonMode = true;
mc_konec.btnExit2.buttonMode = true;
mc_konec.btnSubmit.mouseChildren = false;
mc_konec.btnExit2.mouseChildren = false;
};
}
private function loadGame(_arg1:MouseEvent):void{
level = so.data.Level;
total_score = so.data.Score;
interface_mc.damage.maska.scaleX = 1;
Tweener.addTween(menu.blocker, {alpha:1, time:1, transition:"linear", onComplete:gameLoaded});
menu.btnStart.removeEventListener(MouseEvent.CLICK, startGame);
menu.btnHow.removeEventListener(MouseEvent.CLICK, showExtra);
menu.btnCredits.removeEventListener(MouseEvent.CLICK, showExtra);
menu.btnMore.removeEventListener(MouseEvent.CLICK, openLink);
}
}
}//package
Section 227
//sideLeft (sideLeft)
package {
import flash.display.*;
public dynamic class sideLeft extends BitmapData {
public function sideLeft(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 228
//Snow (Snow)
package {
import flash.display.*;
public dynamic class Snow extends BitmapData {
public function Snow(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 229
//takeS (takeS)
package {
import flash.media.*;
public dynamic class takeS extends Sound {
}
}//package
Section 230
//takeSound (takeSound)
package {
import flash.media.*;
public dynamic class takeSound extends Sound {
}
}//package
Section 231
//topCity (topCity)
package {
import flash.display.*;
public dynamic class topCity extends BitmapData {
public function topCity(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 232
//tucnakMc (tucnakMc)
package {
import flash.display.*;
public dynamic class tucnakMc extends MovieClip {
}
}//package
Section 233
//zadek (zadek)
package {
import flash.display.*;
public dynamic class zadek extends BitmapData {
public function zadek(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package
Section 234
//Znacka (Znacka)
package {
import flash.display.*;
public dynamic class Znacka extends BitmapData {
public function Znacka(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package