Section 1
//BGAnimation_2 (BoardBG_fla.BGAnimation_2)
package BoardBG_fla {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import flash.geom.*;
import flash.filters.*;
import flash.text.*;
import flash.net.*;
import flash.media.*;
import flash.ui.*;
import flash.system.*;
import adobe.utils.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.printing.*;
import flash.xml.*;
public dynamic class BGAnimation_2 extends MovieClip {
public var count:uint;
public var i:uint;
public var particle:MovieClip;
public var particleInst1:BGElement;
public var particleInst2:BGElement;
public function BGAnimation_2(){
addFrameScript(0, frame1);
}
function frame1(){
particleInst1.visible = false;
particleInst2.visible = false;
count = 100;
i = 0;
while (i < count) {
particle = new BGElement();
var _local2 = particle;
with (_local2) {
x = (Math.random() * 700);
y = (Math.random() * 480);
rotation = (Math.random() * 360);
scaleX = (scaleY = Math.random());
alpha = Math.random();
gotoAndStop(int((Math.random() * 6)));
};
addChild(particle);
i++;
};
}
}
}//package BoardBG_fla
Section 2
//b2CircleDef (Box2D.Collision.Shapes.b2CircleDef)
package Box2D.Collision.Shapes {
import Box2D.Common.Math.*;
public class b2CircleDef extends b2ShapeDef {
public var radius:Number;
public var localPosition:b2Vec2;
public function b2CircleDef(){
localPosition = new b2Vec2(0, 0);
super();
type = b2Shape.e_circleShape;
radius = 1;
}
}
}//package Box2D.Collision.Shapes
Section 3
//b2CircleShape (Box2D.Collision.Shapes.b2CircleShape)
package Box2D.Collision.Shapes {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Collision.*;
import Box2D.Common.*;
public class b2CircleShape extends b2Shape {
public var m_localPosition:b2Vec2;
public var m_radius:Number;
public function b2CircleShape(_arg1:b2ShapeDef){
m_localPosition = new b2Vec2();
super(_arg1);
var _local2:b2CircleDef = (_arg1 as b2CircleDef);
m_type = e_circleShape;
m_localPosition.SetV(_local2.localPosition);
m_radius = _local2.radius;
}
override public function TestSegment(_arg1:b2XForm, _arg2:Array, _arg3:b2Vec2, _arg4:b2Segment, _arg5:Number):Boolean{
var _local10:Number;
var _local6:b2Mat22 = _arg1.R;
var _local7:Number = (_arg1.position.x + ((_local6.col1.x * m_localPosition.x) + (_local6.col2.x * m_localPosition.y)));
var _local8:Number = (_arg1.position.x + ((_local6.col1.y * m_localPosition.x) + (_local6.col2.y * m_localPosition.y)));
var _local9:Number = (_arg4.p1.x - _local7);
_local10 = (_arg4.p1.y - _local8);
var _local11:Number = (((_local9 * _local9) + (_local10 * _local10)) - (m_radius * m_radius));
if (_local11 < 0){
return (false);
};
var _local12:Number = (_arg4.p2.x - _arg4.p1.x);
var _local13:Number = (_arg4.p2.y - _arg4.p1.y);
var _local14:Number = ((_local9 * _local12) + (_local10 * _local13));
var _local15:Number = ((_local12 * _local12) + (_local13 * _local13));
var _local16:Number = ((_local14 * _local14) - (_local15 * _local11));
if ((((_local16 < 0)) || ((_local15 < Number.MIN_VALUE)))){
return (false);
};
var _local17:Number = -((_local14 + Math.sqrt(_local16)));
if ((((0 <= _local17)) && ((_local17 <= (_arg5 * _local15))))){
_local17 = (_local17 / _local15);
_arg2[0] = _local17;
_arg3.x = (_local9 + (_local17 * _local12));
_arg3.y = (_local10 + (_local17 * _local13));
_arg3.Normalize();
return (true);
};
return (false);
}
override public function ComputeSubmergedArea(_arg1:b2Vec2, _arg2:Number, _arg3:b2XForm, _arg4:b2Vec2):Number{
var _local5:b2Vec2 = b2Math.b2MulX(_arg3, m_localPosition);
var _local6:Number = -((b2Math.b2Dot(_arg1, _local5) - _arg2));
if (_local6 < (-(m_radius) + Number.MIN_VALUE)){
return (0);
};
if (_local6 > m_radius){
_arg4.SetV(_local5);
return (((b2Settings.b2_pi * m_radius) * m_radius));
};
var _local7:Number = (m_radius * m_radius);
var _local8:Number = (_local6 * _local6);
var _local9:Number = ((_local7 * (Math.asin((_local6 / m_radius)) + (b2Settings.b2_pi / 2))) + (_local6 * Math.sqrt((_local7 - _local8))));
var _local10:Number = (((-2 / 3) * Math.pow((_local7 - _local8), 1.5)) / _local9);
_arg4.x = (_local5.x + (_arg1.x * _local10));
_arg4.y = (_local5.y + (_arg1.y * _local10));
return (_local9);
}
public function GetLocalPosition():b2Vec2{
return (m_localPosition);
}
public function GetRadius():Number{
return (m_radius);
}
override public function ComputeMass(_arg1:b2MassData):void{
_arg1.mass = (((m_density * b2Settings.b2_pi) * m_radius) * m_radius);
_arg1.center.SetV(m_localPosition);
_arg1.I = (_arg1.mass * (((0.5 * m_radius) * m_radius) + ((m_localPosition.x * m_localPosition.x) + (m_localPosition.y * m_localPosition.y))));
}
override public function ComputeSweptAABB(_arg1:b2AABB, _arg2:b2XForm, _arg3:b2XForm):void{
var _local4:b2Mat22;
_local4 = _arg2.R;
var _local5:Number = (_arg2.position.x + ((_local4.col1.x * m_localPosition.x) + (_local4.col2.x * m_localPosition.y)));
var _local6:Number = (_arg2.position.y + ((_local4.col1.y * m_localPosition.x) + (_local4.col2.y * m_localPosition.y)));
_local4 = _arg3.R;
var _local7:Number = (_arg3.position.x + ((_local4.col1.x * m_localPosition.x) + (_local4.col2.x * m_localPosition.y)));
var _local8:Number = (_arg3.position.y + ((_local4.col1.y * m_localPosition.x) + (_local4.col2.y * m_localPosition.y)));
_arg1.lowerBound.Set((((_local5 < _local7)) ? _local5 : _local7 - m_radius), (((_local6 < _local8)) ? _local6 : _local8 - m_radius));
_arg1.upperBound.Set((((_local5 > _local7)) ? _local5 : _local7 + m_radius), (((_local6 > _local8)) ? _local6 : _local8 + m_radius));
}
override public function UpdateSweepRadius(_arg1:b2Vec2):void{
var _local2:Number = (m_localPosition.x - _arg1.x);
var _local3:Number = (m_localPosition.y - _arg1.y);
_local2 = Math.sqrt(((_local2 * _local2) + (_local3 * _local3)));
m_sweepRadius = ((_local2 + m_radius) - b2Settings.b2_toiSlop);
}
override public function ComputeAABB(_arg1:b2AABB, _arg2:b2XForm):void{
var _local3:b2Mat22 = _arg2.R;
var _local4:Number = (_arg2.position.x + ((_local3.col1.x * m_localPosition.x) + (_local3.col2.x * m_localPosition.y)));
var _local5:Number = (_arg2.position.y + ((_local3.col1.y * m_localPosition.x) + (_local3.col2.y * m_localPosition.y)));
_arg1.lowerBound.Set((_local4 - m_radius), (_local5 - m_radius));
_arg1.upperBound.Set((_local4 + m_radius), (_local5 + m_radius));
}
override public function TestPoint(_arg1:b2XForm, _arg2:b2Vec2):Boolean{
var _local3:b2Mat22 = _arg1.R;
var _local4:Number = (_arg1.position.x + ((_local3.col1.x * m_localPosition.x) + (_local3.col2.x * m_localPosition.y)));
var _local5:Number = (_arg1.position.y + ((_local3.col1.y * m_localPosition.x) + (_local3.col2.y * m_localPosition.y)));
_local4 = (_arg2.x - _local4);
_local5 = (_arg2.y - _local5);
return ((((_local4 * _local4) + (_local5 * _local5)) <= (m_radius * m_radius)));
}
}
}//package Box2D.Collision.Shapes
Section 4
//b2FilterData (Box2D.Collision.Shapes.b2FilterData)
package Box2D.Collision.Shapes {
public class b2FilterData {
public var maskBits:uint;// = 0xFFFF
public var groupIndex:int;// = 0
public var categoryBits:uint;// = 1
public function Copy():b2FilterData{
var _local1:b2FilterData = new b2FilterData();
_local1.categoryBits = categoryBits;
_local1.maskBits = maskBits;
_local1.groupIndex = groupIndex;
return (_local1);
}
}
}//package Box2D.Collision.Shapes
Section 5
//b2MassData (Box2D.Collision.Shapes.b2MassData)
package Box2D.Collision.Shapes {
import Box2D.Common.Math.*;
public class b2MassData {
public var mass:Number;// = 0
public var center:b2Vec2;
public var I:Number;// = 0
public function b2MassData(){
center = new b2Vec2(0, 0);
super();
}
}
}//package Box2D.Collision.Shapes
Section 6
//b2PolygonDef (Box2D.Collision.Shapes.b2PolygonDef)
package Box2D.Collision.Shapes {
import Box2D.Common.Math.*;
import Box2D.Common.*;
public class b2PolygonDef extends b2ShapeDef {
public var vertices:Array;
public var vertexCount:int;
private static var s_mat:b2Mat22 = new b2Mat22();
public function b2PolygonDef(){
vertices = new Array(b2Settings.b2_maxPolygonVertices);
super();
type = b2Shape.e_polygonShape;
vertexCount = 0;
var _local1:int;
while (_local1 < b2Settings.b2_maxPolygonVertices) {
vertices[_local1] = new b2Vec2();
_local1++;
};
}
public function SetAsOrientedBox(_arg1:Number, _arg2:Number, _arg3:b2Vec2=null, _arg4:Number=0):void{
var _local5:b2Vec2;
var _local6:b2Mat22;
var _local7:int;
vertexCount = 4;
vertices[0].Set(-(_arg1), -(_arg2));
vertices[1].Set(_arg1, -(_arg2));
vertices[2].Set(_arg1, _arg2);
vertices[3].Set(-(_arg1), _arg2);
if (_arg3){
_local5 = _arg3;
_local6 = s_mat;
_local6.Set(_arg4);
_local7 = 0;
while (_local7 < vertexCount) {
_arg3 = vertices[_local7];
_arg1 = (_local5.x + ((_local6.col1.x * _arg3.x) + (_local6.col2.x * _arg3.y)));
_arg3.y = (_local5.y + ((_local6.col1.y * _arg3.x) + (_local6.col2.y * _arg3.y)));
_arg3.x = _arg1;
_local7++;
};
};
}
public function SetAsBox(_arg1:Number, _arg2:Number):void{
vertexCount = 4;
vertices[0].Set(-(_arg1), -(_arg2));
vertices[1].Set(_arg1, -(_arg2));
vertices[2].Set(_arg1, _arg2);
vertices[3].Set(-(_arg1), _arg2);
}
}
}//package Box2D.Collision.Shapes
Section 7
//b2PolygonShape (Box2D.Collision.Shapes.b2PolygonShape)
package Box2D.Collision.Shapes {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Collision.*;
import Box2D.Common.*;
public class b2PolygonShape extends b2Shape {
public var m_coreVertices:Array;
public var m_vertices:Array;
private var s_supportVec:b2Vec2;
public var m_centroid:b2Vec2;
public var m_normals:Array;
public var m_obb:b2OBB;
public var m_vertexCount:int;
private static var s_computeMat:b2Mat22 = new b2Mat22();
private static var s_sweptAABB1:b2AABB = new b2AABB();
private static var s_sweptAABB2:b2AABB = new b2AABB();
public function b2PolygonShape(_arg1:b2ShapeDef){
var _local3:int;
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;
s_supportVec = new b2Vec2();
m_obb = new b2OBB();
m_vertices = new Array(b2Settings.b2_maxPolygonVertices);
m_normals = new Array(b2Settings.b2_maxPolygonVertices);
m_coreVertices = new Array(b2Settings.b2_maxPolygonVertices);
super(_arg1);
m_type = e_polygonShape;
var _local2:b2PolygonDef = (_arg1 as b2PolygonDef);
m_vertexCount = _local2.vertexCount;
var _local4:int = _local3;
var _local5:int = _local3;
_local3 = 0;
while (_local3 < m_vertexCount) {
m_vertices[_local3] = _local2.vertices[_local3].Copy();
_local3++;
};
_local3 = 0;
while (_local3 < m_vertexCount) {
_local4 = _local3;
_local5 = (((_local3 + 1) < m_vertexCount)) ? (_local3 + 1) : 0;
_local6 = (m_vertices[_local5].x - m_vertices[_local4].x);
_local7 = (m_vertices[_local5].y - m_vertices[_local4].y);
_local8 = Math.sqrt(((_local6 * _local6) + (_local7 * _local7)));
m_normals[_local3] = new b2Vec2((_local7 / _local8), (-(_local6) / _local8));
_local3++;
};
m_centroid = ComputeCentroid(_local2.vertices, _local2.vertexCount);
ComputeOBB(m_obb, m_vertices, m_vertexCount);
_local3 = 0;
while (_local3 < m_vertexCount) {
_local4 = (((_local3 - 1) >= 0)) ? (_local3 - 1) : (m_vertexCount - 1);
_local5 = _local3;
_local9 = m_normals[_local4].x;
_local10 = m_normals[_local4].y;
_local11 = m_normals[_local5].x;
_local12 = m_normals[_local5].y;
_local13 = (m_vertices[_local3].x - m_centroid.x);
_local14 = (m_vertices[_local3].y - m_centroid.y);
_local15 = (((_local9 * _local13) + (_local10 * _local14)) - b2Settings.b2_toiSlop);
_local16 = (((_local11 * _local13) + (_local12 * _local14)) - b2Settings.b2_toiSlop);
_local17 = (1 / ((_local9 * _local12) - (_local10 * _local11)));
m_coreVertices[_local3] = new b2Vec2(((_local17 * ((_local12 * _local15) - (_local10 * _local16))) + m_centroid.x), ((_local17 * ((_local9 * _local16) - (_local11 * _local15))) + m_centroid.y));
_local3++;
};
}
override public function ComputeSubmergedArea(_arg1:b2Vec2, _arg2:Number, _arg3:b2XForm, _arg4:b2Vec2):Number{
var _local13:int;
var _local22:b2Vec2;
var _local24:Boolean;
var _local25:b2MassData;
var _local26:Number;
var _local27:Number;
var _local28:Number;
var _local29:Number;
var _local30:Number;
var _local31:Number;
var _local5:b2Vec2 = b2Math.b2MulTMV(_arg3.R, _arg1);
var _local6:Number = (_arg2 - b2Math.b2Dot(_arg1, _arg3.position));
var _local7:Array = [];
var _local8:int;
var _local9 = -1;
var _local10 = -1;
var _local11:b2Vec2;
var _local12:Boolean;
_local13 = 0;
while (_local13 < m_vertexCount) {
_local11 = m_vertices[_local13];
_local7[_local13] = (((_local5.x * _local11.x) + (_local5.y * _local11.y)) - _local6);
_local24 = (_local7[_local13] < -(Number.MIN_VALUE));
if (_local13 > 0){
if (_local24){
if (!_local12){
_local9 = (_local13 - 1);
_local8++;
};
} else {
if (_local12){
_local10 = (_local13 - 1);
_local8++;
};
};
};
_local12 = _local24;
_local13++;
};
switch (_local8){
case 0:
if (_local12){
_local25 = new b2MassData();
ComputeMass(_local25);
_arg4.SetV(b2Math.b2MulX(_arg3, _local25.center));
return ((_local25.mass / m_density));
};
return (0);
case 1:
if (_local9 == -1){
_local9 = (m_vertexCount - 1);
} else {
_local10 = (m_vertexCount - 1);
};
break;
};
var _local14:int = ((_local9 + 1) % m_vertexCount);
var _local15:int = ((_local10 + 1) % m_vertexCount);
var _local16:Number = ((0 - _local7[_local9]) / (_local7[_local14] - _local7[_local9]));
var _local17:Number = ((0 - _local7[_local10]) / (_local7[_local15] - _local7[_local10]));
var _local18:b2Vec2 = new b2Vec2(((m_vertices[_local9].x * (1 - _local16)) + (m_vertices[_local14].x * _local16)), ((m_vertices[_local9].y * (1 - _local16)) + (m_vertices[_local14].y * _local16)));
var _local19:b2Vec2 = new b2Vec2(((m_vertices[_local10].x * (1 - _local17)) + (m_vertices[_local15].x * _local17)), ((m_vertices[_local10].y * (1 - _local17)) + (m_vertices[_local15].y * _local17)));
var _local20:Number = 0;
_arg4.Set(0, 0);
var _local21:b2Vec2 = m_vertices[_local14];
var _local23:Number = (1 / 3);
_local13 = _local14;
while (_local13 != _local15) {
_local13 = ((_local13 + 1) % m_vertexCount);
if (_local13 == _local15){
_local22 = _local19;
} else {
_local22 = m_vertices[_local13];
};
_local26 = (_local21.x - _local18.x);
_local27 = (_local21.y - _local18.y);
_local28 = (_local22.x - _local18.x);
_local29 = (_local22.y - _local18.y);
_local30 = ((_local26 * _local29) - (_local27 * _local28));
_local31 = (0.5 * _local30);
_local20 = (_local20 + _local31);
_arg4.x = (_arg4.x + ((_local31 * _local23) * ((_local18.x + _local21.x) + _local22.x)));
_arg4.y = (_arg4.y + ((_local31 * _local23) * ((_local18.y + _local21.y) + _local22.y)));
_local21 = _local22;
};
_arg4.x = (_arg4.x / _local20);
_arg4.y = (_arg4.y / _local20);
_arg4.SetV(b2Math.b2MulX(_arg3, _arg4));
return (_local20);
}
override public function ComputeSweptAABB(_arg1:b2AABB, _arg2:b2XForm, _arg3:b2XForm):void{
var _local4:b2AABB = s_sweptAABB1;
var _local5:b2AABB = s_sweptAABB2;
ComputeAABB(_local4, _arg2);
ComputeAABB(_local5, _arg3);
_arg1.lowerBound.Set(((_local4.lowerBound.x < _local5.lowerBound.x)) ? _local4.lowerBound.x : _local5.lowerBound.x, ((_local4.lowerBound.y < _local5.lowerBound.y)) ? _local4.lowerBound.y : _local5.lowerBound.y);
_arg1.upperBound.Set(((_local4.upperBound.x > _local5.upperBound.x)) ? _local4.upperBound.x : _local5.upperBound.x, ((_local4.upperBound.y > _local5.upperBound.y)) ? _local4.upperBound.y : _local5.upperBound.y);
}
public function GetVertices():Array{
return (m_vertices);
}
public function GetCoreVertices():Array{
return (m_coreVertices);
}
public function GetCentroid():b2Vec2{
return (m_centroid);
}
public function GetOBB():b2OBB{
return (m_obb);
}
public function GetFirstVertex(_arg1:b2XForm):b2Vec2{
return (b2Math.b2MulX(_arg1, m_coreVertices[0]));
}
public function Centroid(_arg1:b2XForm):b2Vec2{
return (b2Math.b2MulX(_arg1, m_centroid));
}
override public function TestSegment(_arg1:b2XForm, _arg2:Array, _arg3:b2Vec2, _arg4:b2Segment, _arg5:Number):Boolean{
var _local8:Number;
var _local9:Number;
var _local10:b2Mat22;
var _local11:b2Vec2;
var _local20:Number;
var _local21:Number;
var _local6:Number = 0;
var _local7:Number = _arg5;
_local8 = (_arg4.p1.x - _arg1.position.x);
_local9 = (_arg4.p1.y - _arg1.position.y);
_local10 = _arg1.R;
var _local12:Number = ((_local8 * _local10.col1.x) + (_local9 * _local10.col1.y));
var _local13:Number = ((_local8 * _local10.col2.x) + (_local9 * _local10.col2.y));
_local8 = (_arg4.p2.x - _arg1.position.x);
_local9 = (_arg4.p2.y - _arg1.position.y);
_local10 = _arg1.R;
var _local14:Number = ((_local8 * _local10.col1.x) + (_local9 * _local10.col1.y));
var _local15:Number = ((_local8 * _local10.col2.x) + (_local9 * _local10.col2.y));
var _local16:Number = (_local14 - _local12);
var _local17:Number = (_local15 - _local13);
var _local18 = -1;
var _local19:int;
while (_local19 < m_vertexCount) {
_local11 = m_vertices[_local19];
_local8 = (_local11.x - _local12);
_local9 = (_local11.y - _local13);
_local11 = m_normals[_local19];
_local20 = ((_local11.x * _local8) + (_local11.y * _local9));
_local21 = ((_local11.x * _local16) + (_local11.y * _local17));
if ((((_local21 < 0)) && ((_local20 < (_local6 * _local21))))){
_local6 = (_local20 / _local21);
_local18 = _local19;
} else {
if ((((_local21 > 0)) && ((_local20 < (_local7 * _local21))))){
_local7 = (_local20 / _local21);
};
};
if (_local7 < _local6){
return (false);
};
_local19++;
};
if (_local18 >= 0){
_arg2[0] = _local6;
_local10 = _arg1.R;
_local11 = m_normals[_local18];
_arg3.x = ((_local10.col1.x * _local11.x) + (_local10.col2.x * _local11.y));
_arg3.y = ((_local10.col1.y * _local11.x) + (_local10.col2.y * _local11.y));
return (true);
};
return (false);
}
override public function ComputeMass(_arg1:b2MassData):void{
var _local10:b2Vec2;
var _local11:b2Vec2;
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 _local2:Number = 0;
var _local3:Number = 0;
var _local4:Number = 0;
var _local5:Number = 0;
var _local6:Number = 0;
var _local7:Number = 0;
var _local8:Number = (1 / 3);
var _local9:int;
while (_local9 < m_vertexCount) {
_local10 = m_vertices[_local9];
_local11 = (((_local9 + 1) < m_vertexCount)) ? m_vertices[int((_local9 + 1))] : m_vertices[0];
_local12 = (_local10.x - _local6);
_local13 = (_local10.y - _local7);
_local14 = (_local11.x - _local6);
_local15 = (_local11.y - _local7);
_local16 = ((_local12 * _local15) - (_local13 * _local14));
_local17 = (0.5 * _local16);
_local4 = (_local4 + _local17);
_local2 = (_local2 + ((_local17 * _local8) * ((_local6 + _local10.x) + _local11.x)));
_local3 = (_local3 + ((_local17 * _local8) * ((_local7 + _local10.y) + _local11.y)));
_local18 = _local6;
_local19 = _local7;
_local20 = _local12;
_local21 = _local13;
_local22 = _local14;
_local23 = _local15;
_local24 = ((_local8 * ((0.25 * (((_local20 * _local20) + (_local22 * _local20)) + (_local22 * _local22))) + ((_local18 * _local20) + (_local18 * _local22)))) + ((0.5 * _local18) * _local18));
_local25 = ((_local8 * ((0.25 * (((_local21 * _local21) + (_local23 * _local21)) + (_local23 * _local23))) + ((_local19 * _local21) + (_local19 * _local23)))) + ((0.5 * _local19) * _local19));
_local5 = (_local5 + (_local16 * (_local24 + _local25)));
_local9++;
};
_arg1.mass = (m_density * _local4);
_local2 = (_local2 * (1 / _local4));
_local3 = (_local3 * (1 / _local4));
_arg1.center.Set(_local2, _local3);
_arg1.I = (m_density * _local5);
}
public function GetNormals():Array{
return (m_normals);
}
public function Support(_arg1:b2XForm, _arg2:Number, _arg3:Number):b2Vec2{
var _local4:b2Vec2;
var _local5:b2Mat22;
var _local11:Number;
_local5 = _arg1.R;
var _local6:Number = ((_arg2 * _local5.col1.x) + (_arg3 * _local5.col1.y));
var _local7:Number = ((_arg2 * _local5.col2.x) + (_arg3 * _local5.col2.y));
var _local8:int;
_local4 = m_coreVertices[0];
var _local9:Number = ((_local4.x * _local6) + (_local4.y * _local7));
var _local10 = 1;
while (_local10 < m_vertexCount) {
_local4 = m_coreVertices[_local10];
_local11 = ((_local4.x * _local6) + (_local4.y * _local7));
if (_local11 > _local9){
_local8 = _local10;
_local9 = _local11;
};
_local10++;
};
_local5 = _arg1.R;
_local4 = m_coreVertices[_local8];
s_supportVec.x = (_arg1.position.x + ((_local5.col1.x * _local4.x) + (_local5.col2.x * _local4.y)));
s_supportVec.y = (_arg1.position.y + ((_local5.col1.y * _local4.x) + (_local5.col2.y * _local4.y)));
return (s_supportVec);
}
public function GetVertexCount():int{
return (m_vertexCount);
}
override public function ComputeAABB(_arg1:b2AABB, _arg2:b2XForm):void{
var _local3:b2Mat22;
var _local4:b2Vec2;
var _local5:b2Mat22 = s_computeMat;
_local3 = _arg2.R;
_local4 = m_obb.R.col1;
_local5.col1.x = ((_local3.col1.x * _local4.x) + (_local3.col2.x * _local4.y));
_local5.col1.y = ((_local3.col1.y * _local4.x) + (_local3.col2.y * _local4.y));
_local4 = m_obb.R.col2;
_local5.col2.x = ((_local3.col1.x * _local4.x) + (_local3.col2.x * _local4.y));
_local5.col2.y = ((_local3.col1.y * _local4.x) + (_local3.col2.y * _local4.y));
_local5.Abs();
var _local6:b2Mat22 = _local5;
_local4 = m_obb.extents;
var _local7:Number = ((_local6.col1.x * _local4.x) + (_local6.col2.x * _local4.y));
var _local8:Number = ((_local6.col1.y * _local4.x) + (_local6.col2.y * _local4.y));
_local3 = _arg2.R;
_local4 = m_obb.center;
var _local9:Number = (_arg2.position.x + ((_local3.col1.x * _local4.x) + (_local3.col2.x * _local4.y)));
var _local10:Number = (_arg2.position.y + ((_local3.col1.y * _local4.x) + (_local3.col2.y * _local4.y)));
_arg1.lowerBound.Set((_local9 - _local7), (_local10 - _local8));
_arg1.upperBound.Set((_local9 + _local7), (_local10 + _local8));
}
override public function UpdateSweepRadius(_arg1:b2Vec2):void{
var _local2:b2Vec2;
var _local4:Number;
var _local5:Number;
m_sweepRadius = 0;
var _local3:int;
while (_local3 < m_vertexCount) {
_local2 = m_coreVertices[_local3];
_local4 = (_local2.x - _arg1.x);
_local5 = (_local2.y - _arg1.y);
_local4 = Math.sqrt(((_local4 * _local4) + (_local5 * _local5)));
if (_local4 > m_sweepRadius){
m_sweepRadius = _local4;
};
_local3++;
};
}
override public function TestPoint(_arg1:b2XForm, _arg2:b2Vec2):Boolean{
var _local3:b2Vec2;
var _local10:Number;
var _local4:b2Mat22 = _arg1.R;
var _local5:Number = (_arg2.x - _arg1.position.x);
var _local6:Number = (_arg2.y - _arg1.position.y);
var _local7:Number = ((_local5 * _local4.col1.x) + (_local6 * _local4.col1.y));
var _local8:Number = ((_local5 * _local4.col2.x) + (_local6 * _local4.col2.y));
var _local9:int;
while (_local9 < m_vertexCount) {
_local3 = m_vertices[_local9];
_local5 = (_local7 - _local3.x);
_local6 = (_local8 - _local3.y);
_local3 = m_normals[_local9];
_local10 = ((_local3.x * _local5) + (_local3.y * _local6));
if (_local10 > 0){
return (false);
};
_local9++;
};
return (true);
}
public static function ComputeCentroid(_arg1:Array, _arg2:int):b2Vec2{
var _local3:b2Vec2;
var _local7:Number;
var _local9:b2Vec2;
var _local10:b2Vec2;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
_local3 = new b2Vec2();
var _local4:Number = 0;
var _local5:Number = 0;
var _local6:Number = 0;
_local7 = (1 / 3);
var _local8:int;
while (_local8 < _arg2) {
_local9 = _arg1[_local8];
_local10 = (((_local8 + 1) < _arg2)) ? _arg1[int((_local8 + 1))] : _arg1[0];
_local11 = (_local9.x - _local5);
_local12 = (_local9.y - _local6);
_local13 = (_local10.x - _local5);
_local14 = (_local10.y - _local6);
_local15 = ((_local11 * _local14) - (_local12 * _local13));
_local16 = (0.5 * _local15);
_local4 = (_local4 + _local16);
_local3.x = (_local3.x + ((_local16 * _local7) * ((_local5 + _local9.x) + _local10.x)));
_local3.y = (_local3.y + ((_local16 * _local7) * ((_local6 + _local9.y) + _local10.y)));
_local8++;
};
_local3.x = (_local3.x * (1 / _local4));
_local3.y = (_local3.y * (1 / _local4));
return (_local3);
}
public static function ComputeOBB(_arg1:b2OBB, _arg2:Array, _arg3:int):void{
var _local4:int;
var _local7:b2Vec2;
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:int;
var _local18:Number;
var _local19:Number;
var _local20:Number;
var _local21:Number;
var _local22:Number;
var _local23:Number;
var _local24:Number;
var _local25:b2Mat22;
var _local5:Array = new Array((b2Settings.b2_maxPolygonVertices + 1));
_local4 = 0;
while (_local4 < _arg3) {
_local5[_local4] = _arg2[_local4];
_local4++;
};
_local5[_arg3] = _local5[0];
var _local6:Number = Number.MAX_VALUE;
_local4 = 1;
while (_local4 <= _arg3) {
_local7 = _local5[int((_local4 - 1))];
_local8 = (_local5[_local4].x - _local7.x);
_local9 = (_local5[_local4].y - _local7.y);
_local10 = Math.sqrt(((_local8 * _local8) + (_local9 * _local9)));
_local8 = (_local8 / _local10);
_local9 = (_local9 / _local10);
_local11 = -(_local9);
_local12 = _local8;
_local13 = Number.MAX_VALUE;
_local14 = Number.MAX_VALUE;
_local15 = -(Number.MAX_VALUE);
_local16 = -(Number.MAX_VALUE);
_local17 = 0;
while (_local17 < _arg3) {
_local19 = (_local5[_local17].x - _local7.x);
_local20 = (_local5[_local17].y - _local7.y);
_local21 = ((_local8 * _local19) + (_local9 * _local20));
_local22 = ((_local11 * _local19) + (_local12 * _local20));
if (_local21 < _local13){
_local13 = _local21;
};
if (_local22 < _local14){
_local14 = _local22;
};
if (_local21 > _local15){
_local15 = _local21;
};
if (_local22 > _local16){
_local16 = _local22;
};
_local17++;
};
_local18 = ((_local15 - _local13) * (_local16 - _local14));
if (_local18 < (0.95 * _local6)){
_local6 = _local18;
_arg1.R.col1.x = _local8;
_arg1.R.col1.y = _local9;
_arg1.R.col2.x = _local11;
_arg1.R.col2.y = _local12;
_local23 = (0.5 * (_local13 + _local15));
_local24 = (0.5 * (_local14 + _local16));
_local25 = _arg1.R;
_arg1.center.x = (_local7.x + ((_local25.col1.x * _local23) + (_local25.col2.x * _local24)));
_arg1.center.y = (_local7.y + ((_local25.col1.y * _local23) + (_local25.col2.y * _local24)));
_arg1.extents.x = (0.5 * (_local15 - _local13));
_arg1.extents.y = (0.5 * (_local16 - _local14));
};
_local4++;
};
}
}
}//package Box2D.Collision.Shapes
Section 8
//b2Shape (Box2D.Collision.Shapes.b2Shape)
package Box2D.Collision.Shapes {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Collision.*;
public class b2Shape {
public var m_next:b2Shape;
public var m_type:int;
public var m_sweepRadius:Number;
public var m_density:Number;
public var m_filter:b2FilterData;
public var m_friction:Number;
public var m_isSensor:Boolean;
public var m_restitution:Number;
public var m_userData;
public var m_proxyId:uint;
public var m_body:b2Body;
public static const e_polygonShape:int = 1;
public static const e_unknownShape:int = -1;
public static const e_circleShape:int = 0;
public static const e_shapeTypeCount:int = 2;
private static var s_resetAABB:b2AABB = new b2AABB();
private static var s_syncAABB:b2AABB = new b2AABB();
private static var s_proxyAABB:b2AABB = new b2AABB();
public function b2Shape(_arg1:b2ShapeDef){
m_userData = _arg1.userData;
m_friction = _arg1.friction;
m_restitution = _arg1.restitution;
m_density = _arg1.density;
m_body = null;
m_sweepRadius = 0;
m_next = null;
m_proxyId = b2Pair.b2_nullProxy;
m_filter = _arg1.filter.Copy();
m_isSensor = _arg1.isSensor;
}
public function ComputeSubmergedArea(_arg1:b2Vec2, _arg2:Number, _arg3:b2XForm, _arg4:b2Vec2):Number{
return (0);
}
public function SetUserData(_arg1):void{
m_userData = _arg1;
}
public function GetSweepRadius():Number{
return (m_sweepRadius);
}
public function GetNext():b2Shape{
return (m_next);
}
public function ComputeSweptAABB(_arg1:b2AABB, _arg2:b2XForm, _arg3:b2XForm):void{
}
public function GetType():int{
return (m_type);
}
public function GetRestitution():Number{
return (m_restitution);
}
public function GetFriction():Number{
return (m_friction);
}
public function GetFilterData():b2FilterData{
return (m_filter.Copy());
}
public function TestSegment(_arg1:b2XForm, _arg2:Array, _arg3:b2Vec2, _arg4:b2Segment, _arg5:Number):Boolean{
return (false);
}
public function RefilterProxy(_arg1:b2BroadPhase, _arg2:b2XForm):void{
if (m_proxyId == b2Pair.b2_nullProxy){
return;
};
_arg1.DestroyProxy(m_proxyId);
var _local3:b2AABB = s_resetAABB;
ComputeAABB(_local3, _arg2);
var _local4:Boolean = _arg1.InRange(_local3);
if (_local4){
m_proxyId = _arg1.CreateProxy(_local3, this);
} else {
m_proxyId = b2Pair.b2_nullProxy;
};
}
public function SetFilterData(_arg1:b2FilterData):void{
m_filter = _arg1.Copy();
}
public function GetUserData(){
return (m_userData);
}
public function Synchronize(_arg1:b2BroadPhase, _arg2:b2XForm, _arg3:b2XForm):Boolean{
if (m_proxyId == b2Pair.b2_nullProxy){
return (false);
};
var _local4:b2AABB = s_syncAABB;
ComputeSweptAABB(_local4, _arg2, _arg3);
if (_arg1.InRange(_local4)){
_arg1.MoveProxy(m_proxyId, _local4);
return (true);
};
return (false);
}
public function ComputeMass(_arg1:b2MassData):void{
}
public function IsSensor():Boolean{
return (m_isSensor);
}
public function DestroyProxy(_arg1:b2BroadPhase):void{
if (m_proxyId != b2Pair.b2_nullProxy){
_arg1.DestroyProxy(m_proxyId);
m_proxyId = b2Pair.b2_nullProxy;
};
}
public function UpdateSweepRadius(_arg1:b2Vec2):void{
}
public function ComputeAABB(_arg1:b2AABB, _arg2:b2XForm):void{
}
public function GetBody():b2Body{
return (m_body);
}
public function CreateProxy(_arg1:b2BroadPhase, _arg2:b2XForm):void{
var _local3:b2AABB = s_proxyAABB;
ComputeAABB(_local3, _arg2);
var _local4:Boolean = _arg1.InRange(_local3);
if (_local4){
m_proxyId = _arg1.CreateProxy(_local3, this);
} else {
m_proxyId = b2Pair.b2_nullProxy;
};
}
public function TestPoint(_arg1:b2XForm, _arg2:b2Vec2):Boolean{
return (false);
}
public static function Destroy(_arg1:b2Shape, _arg2):void{
}
public static function Create(_arg1:b2ShapeDef, _arg2):b2Shape{
switch (_arg1.type){
case e_circleShape:
return (new b2CircleShape(_arg1));
case e_polygonShape:
return (new b2PolygonShape(_arg1));
default:
return (null);
};
}
}
}//package Box2D.Collision.Shapes
Section 9
//b2ShapeDef (Box2D.Collision.Shapes.b2ShapeDef)
package Box2D.Collision.Shapes {
public class b2ShapeDef {
public var friction:Number;// = 0.2
public var isSensor:Boolean;// = false
public var density:Number;// = 0
public var restitution:Number;// = 0
public var userData;// = null
public var filter:b2FilterData;
public var type:int;// = -1
public function b2ShapeDef(){
filter = new b2FilterData();
super();
}
}
}//package Box2D.Collision.Shapes
Section 10
//b2AABB (Box2D.Collision.b2AABB)
package Box2D.Collision {
import Box2D.Common.Math.*;
public class b2AABB {
public var upperBound:b2Vec2;
public var lowerBound:b2Vec2;
public function b2AABB(){
lowerBound = new b2Vec2();
upperBound = new b2Vec2();
super();
}
public function IsValid():Boolean{
var _local1:Number = (upperBound.x - lowerBound.x);
var _local2:Number = (upperBound.y - lowerBound.y);
var _local3:Boolean = (((_local1 >= 0)) && ((_local2 >= 0)));
_local3 = ((((_local3) && (lowerBound.IsValid()))) && (upperBound.IsValid()));
return (_local3);
}
}
}//package Box2D.Collision
Section 11
//b2Bound (Box2D.Collision.b2Bound)
package Box2D.Collision {
public class b2Bound {
public var value:uint;
public var proxyId:uint;
public var stabbingCount:uint;
public function Swap(_arg1:b2Bound):void{
var _local2:uint = value;
var _local3:uint = proxyId;
var _local4:uint = stabbingCount;
value = _arg1.value;
proxyId = _arg1.proxyId;
stabbingCount = _arg1.stabbingCount;
_arg1.value = _local2;
_arg1.proxyId = _local3;
_arg1.stabbingCount = _local4;
}
public function IsLower():Boolean{
return (((value & 1) == 0));
}
public function IsUpper():Boolean{
return (((value & 1) == 1));
}
}
}//package Box2D.Collision
Section 12
//b2BoundValues (Box2D.Collision.b2BoundValues)
package Box2D.Collision {
public class b2BoundValues {
public var lowerValues:Array;
public var upperValues:Array;
public function b2BoundValues(){
lowerValues = [0, 0];
upperValues = [0, 0];
super();
}
}
}//package Box2D.Collision
Section 13
//b2BroadPhase (Box2D.Collision.b2BroadPhase)
package Box2D.Collision {
import Box2D.Common.Math.*;
import Box2D.Common.*;
public class b2BroadPhase {
public var m_bounds:Array;
public var m_quantizationFactor:b2Vec2;
public var m_worldAABB:b2AABB;
public var m_freeProxy:uint;
public var m_proxyCount:int;
public var m_proxyPool:Array;
public var m_queryResultCount:int;
public var m_pairManager:b2PairManager;
public var m_timeStamp:uint;
public var m_queryResults:Array;
public static const b2_nullEdge:uint = b2Settings.USHRT_MAX;
public static const b2_invalid:uint = b2Settings.USHRT_MAX;
public static var s_validate:Boolean = false;
public function b2BroadPhase(_arg1:b2AABB, _arg2:b2PairCallback){
var _local3:int;
var _local5:Number;
var _local6:b2Proxy;
var _local7:int;
m_pairManager = new b2PairManager();
m_proxyPool = new Array(b2Settings.b2_maxPairs);
m_bounds = new Array((2 * b2Settings.b2_maxProxies));
m_queryResults = new Array(b2Settings.b2_maxProxies);
m_quantizationFactor = new b2Vec2();
super();
m_pairManager.Initialize(this, _arg2);
m_worldAABB = _arg1;
m_proxyCount = 0;
_local3 = 0;
while (_local3 < b2Settings.b2_maxProxies) {
m_queryResults[_local3] = 0;
_local3++;
};
m_bounds = new Array(2);
_local3 = 0;
while (_local3 < 2) {
m_bounds[_local3] = new Array((2 * b2Settings.b2_maxProxies));
_local7 = 0;
while (_local7 < (2 * b2Settings.b2_maxProxies)) {
m_bounds[_local3][_local7] = new b2Bound();
_local7++;
};
_local3++;
};
var _local4:Number = (_arg1.upperBound.x - _arg1.lowerBound.x);
_local5 = (_arg1.upperBound.y - _arg1.lowerBound.y);
m_quantizationFactor.x = (b2Settings.USHRT_MAX / _local4);
m_quantizationFactor.y = (b2Settings.USHRT_MAX / _local5);
_local3 = 0;
while (_local3 < (b2Settings.b2_maxProxies - 1)) {
_local6 = new b2Proxy();
m_proxyPool[_local3] = _local6;
_local6.SetNext((_local3 + 1));
_local6.timeStamp = 0;
_local6.overlapCount = b2_invalid;
_local6.userData = null;
_local3++;
};
_local6 = new b2Proxy();
m_proxyPool[int((b2Settings.b2_maxProxies - 1))] = _local6;
_local6.SetNext(b2Pair.b2_nullProxy);
_local6.timeStamp = 0;
_local6.overlapCount = b2_invalid;
_local6.userData = null;
m_freeProxy = 0;
m_timeStamp = 1;
m_queryResultCount = 0;
}
public function QueryAABB(_arg1:b2AABB, _arg2, _arg3:int):int{
var _local6:uint;
var _local7:uint;
var _local12:b2Proxy;
var _local4:Array = new Array();
var _local5:Array = new Array();
ComputeBounds(_local4, _local5, _arg1);
var _local8:Array = [_local6];
var _local9:Array = [_local7];
Query(_local8, _local9, _local4[0], _local5[0], m_bounds[0], (2 * m_proxyCount), 0);
Query(_local8, _local9, _local4[1], _local5[1], m_bounds[1], (2 * m_proxyCount), 1);
var _local10:int;
var _local11:int;
while ((((_local11 < m_queryResultCount)) && ((_local10 < _arg3)))) {
_local12 = m_proxyPool[m_queryResults[_local11]];
_arg2[_local11] = _local12.userData;
_local11++;
_local10++;
};
m_queryResultCount = 0;
IncrementTimeStamp();
return (_local10);
}
public function Commit():void{
m_pairManager.Commit();
}
public function GetProxy(_arg1:int):b2Proxy{
var _local2:b2Proxy = m_proxyPool[_arg1];
if ((((_arg1 == b2Pair.b2_nullProxy)) || ((_local2.IsValid() == false)))){
return (null);
};
return (_local2);
}
private function IncrementTimeStamp():void{
var _local1:uint;
if (m_timeStamp == b2Settings.USHRT_MAX){
_local1 = 0;
while (_local1 < b2Settings.b2_maxProxies) {
(m_proxyPool[_local1] as b2Proxy).timeStamp = 0;
_local1++;
};
m_timeStamp = 1;
} else {
m_timeStamp++;
};
}
private function Query(_arg1:Array, _arg2:Array, _arg3:uint, _arg4:uint, _arg5:Array, _arg6:uint, _arg7:int):void{
var _local10:b2Bound;
var _local12:int;
var _local13:int;
var _local14:b2Proxy;
var _local8:uint = BinarySearch(_arg5, _arg6, _arg3);
var _local9:uint = BinarySearch(_arg5, _arg6, _arg4);
var _local11:uint = _local8;
while (_local11 < _local9) {
_local10 = _arg5[_local11];
if (_local10.IsLower()){
IncrementOverlapCount(_local10.proxyId);
};
_local11++;
};
if (_local8 > 0){
_local12 = (_local8 - 1);
_local10 = _arg5[_local12];
_local13 = _local10.stabbingCount;
while (_local13) {
_local10 = _arg5[_local12];
if (_local10.IsLower()){
_local14 = m_proxyPool[_local10.proxyId];
if (_local8 <= _local14.upperBounds[_arg7]){
IncrementOverlapCount(_local10.proxyId);
_local13--;
};
};
_local12--;
};
};
_arg1[0] = _local8;
_arg2[0] = _local9;
}
private function TestOverlapValidate(_arg1:b2Proxy, _arg2:b2Proxy):Boolean{
var _local4:Array;
var _local5:b2Bound;
var _local6:b2Bound;
var _local3:int;
while (_local3 < 2) {
_local4 = m_bounds[_local3];
_local5 = _local4[_arg1.lowerBounds[_local3]];
_local6 = _local4[_arg2.upperBounds[_local3]];
if (_local5.value > _local6.value){
return (false);
};
_local5 = _local4[_arg1.upperBounds[_local3]];
_local6 = _local4[_arg2.lowerBounds[_local3]];
if (_local5.value < _local6.value){
return (false);
};
_local3++;
};
return (true);
}
private function ComputeBounds(_arg1:Array, _arg2:Array, _arg3:b2AABB):void{
var _local4:Number = _arg3.lowerBound.x;
var _local5:Number = _arg3.lowerBound.y;
_local4 = b2Math.b2Min(_local4, m_worldAABB.upperBound.x);
_local5 = b2Math.b2Min(_local5, m_worldAABB.upperBound.y);
_local4 = b2Math.b2Max(_local4, m_worldAABB.lowerBound.x);
_local5 = b2Math.b2Max(_local5, m_worldAABB.lowerBound.y);
var _local6:Number = _arg3.upperBound.x;
var _local7:Number = _arg3.upperBound.y;
_local6 = b2Math.b2Min(_local6, m_worldAABB.upperBound.x);
_local7 = b2Math.b2Min(_local7, m_worldAABB.upperBound.y);
_local6 = b2Math.b2Max(_local6, m_worldAABB.lowerBound.x);
_local7 = b2Math.b2Max(_local7, m_worldAABB.lowerBound.y);
_arg1[0] = (uint((m_quantizationFactor.x * (_local4 - m_worldAABB.lowerBound.x))) & (b2Settings.USHRT_MAX - 1));
_arg2[0] = ((uint((m_quantizationFactor.x * (_local6 - m_worldAABB.lowerBound.x))) & 0xFFFF) | 1);
_arg1[1] = (uint((m_quantizationFactor.y * (_local5 - m_worldAABB.lowerBound.y))) & (b2Settings.USHRT_MAX - 1));
_arg2[1] = ((uint((m_quantizationFactor.y * (_local7 - m_worldAABB.lowerBound.y))) & 0xFFFF) | 1);
}
public function CreateProxy(_arg1:b2AABB, _arg2):uint{
var _local3:uint;
var _local4:b2Proxy;
var _local11:Array;
var _local12:uint;
var _local13:uint;
var _local14:Array;
var _local15:Array;
var _local16:Array;
var _local17:int;
var _local18:int;
var _local19:b2Bound;
var _local20:b2Bound;
var _local21:b2Bound;
var _local22:int;
var _local23:b2Proxy;
var _local5:uint = m_freeProxy;
_local4 = m_proxyPool[_local5];
m_freeProxy = _local4.GetNext();
_local4.overlapCount = 0;
_local4.userData = _arg2;
var _local6:uint = (2 * m_proxyCount);
var _local7:Array = new Array();
var _local8:Array = new Array();
ComputeBounds(_local7, _local8, _arg1);
var _local9:int;
while (_local9 < 2) {
_local11 = m_bounds[_local9];
_local14 = [_local12];
_local15 = [_local13];
Query(_local14, _local15, _local7[_local9], _local8[_local9], _local11, _local6, _local9);
_local12 = _local14[0];
_local13 = _local15[0];
_local16 = new Array();
_local18 = (_local6 - _local13);
_local17 = 0;
while (_local17 < _local18) {
_local16[_local17] = new b2Bound();
_local19 = _local16[_local17];
_local20 = _local11[int((_local13 + _local17))];
_local19.value = _local20.value;
_local19.proxyId = _local20.proxyId;
_local19.stabbingCount = _local20.stabbingCount;
_local17++;
};
_local18 = _local16.length;
_local22 = (_local13 + 2);
_local17 = 0;
while (_local17 < _local18) {
_local20 = _local16[_local17];
_local19 = _local11[int((_local22 + _local17))];
_local19.value = _local20.value;
_local19.proxyId = _local20.proxyId;
_local19.stabbingCount = _local20.stabbingCount;
_local17++;
};
_local16 = new Array();
_local18 = (_local13 - _local12);
_local17 = 0;
while (_local17 < _local18) {
_local16[_local17] = new b2Bound();
_local19 = _local16[_local17];
_local20 = _local11[int((_local12 + _local17))];
_local19.value = _local20.value;
_local19.proxyId = _local20.proxyId;
_local19.stabbingCount = _local20.stabbingCount;
_local17++;
};
_local18 = _local16.length;
_local22 = (_local12 + 1);
_local17 = 0;
while (_local17 < _local18) {
_local20 = _local16[_local17];
_local19 = _local11[int((_local22 + _local17))];
_local19.value = _local20.value;
_local19.proxyId = _local20.proxyId;
_local19.stabbingCount = _local20.stabbingCount;
_local17++;
};
_local13++;
_local19 = _local11[_local12];
_local20 = _local11[_local13];
_local19.value = _local7[_local9];
_local19.proxyId = _local5;
_local20.value = _local8[_local9];
_local20.proxyId = _local5;
_local21 = _local11[int((_local12 - 1))];
_local19.stabbingCount = ((_local12 == 0)) ? 0 : _local21.stabbingCount;
_local21 = _local11[int((_local13 - 1))];
_local20.stabbingCount = _local21.stabbingCount;
_local3 = _local12;
while (_local3 < _local13) {
_local21 = _local11[_local3];
_local21.stabbingCount++;
_local3++;
};
_local3 = _local12;
while (_local3 < (_local6 + 2)) {
_local19 = _local11[_local3];
_local23 = m_proxyPool[_local19.proxyId];
if (_local19.IsLower()){
_local23.lowerBounds[_local9] = _local3;
} else {
_local23.upperBounds[_local9] = _local3;
};
_local3++;
};
_local9++;
};
m_proxyCount++;
var _local10:int;
while (_local10 < m_queryResultCount) {
m_pairManager.AddBufferedPair(_local5, m_queryResults[_local10]);
_local10++;
};
m_pairManager.Commit();
m_queryResultCount = 0;
IncrementTimeStamp();
return (_local5);
}
public function DestroyProxy(_arg1:uint):void{
var _local2:b2Bound;
var _local3:b2Bound;
var _local8:Array;
var _local9:uint;
var _local10:uint;
var _local11:uint;
var _local12:uint;
var _local13:Array;
var _local14:int;
var _local15:int;
var _local16:int;
var _local17:uint;
var _local18:int;
var _local19:b2Proxy;
var _local4:b2Proxy = m_proxyPool[_arg1];
var _local5:int = (2 * m_proxyCount);
var _local6:int;
while (_local6 < 2) {
_local8 = m_bounds[_local6];
_local9 = _local4.lowerBounds[_local6];
_local10 = _local4.upperBounds[_local6];
_local2 = _local8[_local9];
_local11 = _local2.value;
_local3 = _local8[_local10];
_local12 = _local3.value;
_local13 = new Array();
_local15 = ((_local10 - _local9) - 1);
_local14 = 0;
while (_local14 < _local15) {
_local13[_local14] = new b2Bound();
_local2 = _local13[_local14];
_local3 = _local8[int(((_local9 + 1) + _local14))];
_local2.value = _local3.value;
_local2.proxyId = _local3.proxyId;
_local2.stabbingCount = _local3.stabbingCount;
_local14++;
};
_local15 = _local13.length;
_local16 = _local9;
_local14 = 0;
while (_local14 < _local15) {
_local3 = _local13[_local14];
_local2 = _local8[int((_local16 + _local14))];
_local2.value = _local3.value;
_local2.proxyId = _local3.proxyId;
_local2.stabbingCount = _local3.stabbingCount;
_local14++;
};
_local13 = new Array();
_local15 = ((_local5 - _local10) - 1);
_local14 = 0;
while (_local14 < _local15) {
_local13[_local14] = new b2Bound();
_local2 = _local13[_local14];
_local3 = _local8[int(((_local10 + 1) + _local14))];
_local2.value = _local3.value;
_local2.proxyId = _local3.proxyId;
_local2.stabbingCount = _local3.stabbingCount;
_local14++;
};
_local15 = _local13.length;
_local16 = (_local10 - 1);
_local14 = 0;
while (_local14 < _local15) {
_local3 = _local13[_local14];
_local2 = _local8[int((_local16 + _local14))];
_local2.value = _local3.value;
_local2.proxyId = _local3.proxyId;
_local2.stabbingCount = _local3.stabbingCount;
_local14++;
};
_local15 = (_local5 - 2);
_local17 = _local9;
while (_local17 < _local15) {
_local2 = _local8[_local17];
_local19 = m_proxyPool[_local2.proxyId];
if (_local2.IsLower()){
_local19.lowerBounds[_local6] = _local17;
} else {
_local19.upperBounds[_local6] = _local17;
};
_local17++;
};
_local15 = (_local10 - 1);
_local18 = _local9;
while (_local18 < _local15) {
_local2 = _local8[_local18];
_local2.stabbingCount--;
_local18++;
};
Query([0], [0], _local11, _local12, _local8, (_local5 - 2), _local6);
_local6++;
};
var _local7:int;
while (_local7 < m_queryResultCount) {
m_pairManager.RemoveBufferedPair(_arg1, m_queryResults[_local7]);
_local7++;
};
m_pairManager.Commit();
m_queryResultCount = 0;
IncrementTimeStamp();
_local4.userData = null;
_local4.overlapCount = b2_invalid;
_local4.lowerBounds[0] = b2_invalid;
_local4.lowerBounds[1] = b2_invalid;
_local4.upperBounds[0] = b2_invalid;
_local4.upperBounds[1] = b2_invalid;
_local4.SetNext(m_freeProxy);
m_freeProxy = _arg1;
m_proxyCount--;
}
public function TestOverlap(_arg1:b2BoundValues, _arg2:b2Proxy):Boolean{
var _local4:Array;
var _local5:b2Bound;
var _local3:int;
while (_local3 < 2) {
_local4 = m_bounds[_local3];
_local5 = _local4[_arg2.upperBounds[_local3]];
if (_arg1.lowerValues[_local3] > _local5.value){
return (false);
};
_local5 = _local4[_arg2.lowerBounds[_local3]];
if (_arg1.upperValues[_local3] < _local5.value){
return (false);
};
_local3++;
};
return (true);
}
public function Validate():void{
var _local1:b2Pair;
var _local2:b2Proxy;
var _local3:b2Proxy;
var _local4:Boolean;
var _local6:b2Bound;
var _local7:uint;
var _local8:uint;
var _local9:uint;
var _local10:b2Bound;
var _local5:int;
while (_local5 < 2) {
_local6 = m_bounds[_local5];
_local7 = (2 * m_proxyCount);
_local8 = 0;
_local9 = 0;
while (_local9 < _local7) {
_local10 = _local6[_local9];
if (_local10.IsLower() == true){
_local8++;
} else {
_local8--;
};
_local9++;
};
_local5++;
};
}
private function IncrementOverlapCount(_arg1:uint):void{
var _local2:b2Proxy = m_proxyPool[_arg1];
if (_local2.timeStamp < m_timeStamp){
_local2.timeStamp = m_timeStamp;
_local2.overlapCount = 1;
} else {
_local2.overlapCount = 2;
m_queryResults[m_queryResultCount] = _arg1;
m_queryResultCount++;
};
}
public function InRange(_arg1:b2AABB):Boolean{
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:Number;
_local2 = _arg1.lowerBound.x;
_local3 = _arg1.lowerBound.y;
_local2 = (_local2 - m_worldAABB.upperBound.x);
_local3 = (_local3 - m_worldAABB.upperBound.y);
_local4 = m_worldAABB.lowerBound.x;
_local5 = m_worldAABB.lowerBound.y;
_local4 = (_local4 - _arg1.upperBound.x);
_local5 = (_local5 - _arg1.upperBound.y);
_local2 = b2Math.b2Max(_local2, _local4);
_local3 = b2Math.b2Max(_local3, _local5);
return ((b2Math.b2Max(_local2, _local3) < 0));
}
public function MoveProxy(_arg1:uint, _arg2:b2AABB):void{
var _local3:Array;
var _local4:int;
var _local5:uint;
var _local6:uint;
var _local7:b2Bound;
var _local8:b2Bound;
var _local9:b2Bound;
var _local10:uint;
var _local11:b2Proxy;
var _local16:Array;
var _local17:uint;
var _local18:uint;
var _local19:uint;
var _local20:uint;
var _local21:int;
var _local22:int;
var _local23:uint;
var _local24:b2Proxy;
if ((((_arg1 == b2Pair.b2_nullProxy)) || ((b2Settings.b2_maxProxies <= _arg1)))){
return;
};
if (_arg2.IsValid() == false){
return;
};
var _local12:uint = (2 * m_proxyCount);
var _local13:b2Proxy = m_proxyPool[_arg1];
var _local14:b2BoundValues = new b2BoundValues();
ComputeBounds(_local14.lowerValues, _local14.upperValues, _arg2);
var _local15:b2BoundValues = new b2BoundValues();
_local5 = 0;
while (_local5 < 2) {
_local7 = m_bounds[_local5][_local13.lowerBounds[_local5]];
_local15.lowerValues[_local5] = _local7.value;
_local7 = m_bounds[_local5][_local13.upperBounds[_local5]];
_local15.upperValues[_local5] = _local7.value;
_local5++;
};
_local5 = 0;
while (_local5 < 2) {
_local16 = m_bounds[_local5];
_local17 = _local13.lowerBounds[_local5];
_local18 = _local13.upperBounds[_local5];
_local19 = _local14.lowerValues[_local5];
_local20 = _local14.upperValues[_local5];
_local7 = _local16[_local17];
_local21 = (_local19 - _local7.value);
_local7.value = _local19;
_local7 = _local16[_local18];
_local22 = (_local20 - _local7.value);
_local7.value = _local20;
if (_local21 < 0){
_local6 = _local17;
while ((((_local6 > 0)) && ((_local19 < (_local16[int((_local6 - 1))] as b2Bound).value)))) {
_local7 = _local16[_local6];
_local8 = _local16[int((_local6 - 1))];
_local23 = _local8.proxyId;
_local24 = m_proxyPool[_local8.proxyId];
_local8.stabbingCount++;
if (_local8.IsUpper() == true){
if (TestOverlap(_local14, _local24)){
m_pairManager.AddBufferedPair(_arg1, _local23);
};
_local3 = _local24.upperBounds;
_local4 = _local3[_local5];
_local4++;
_local3[_local5] = _local4;
_local7.stabbingCount++;
} else {
_local3 = _local24.lowerBounds;
_local4 = _local3[_local5];
_local4++;
_local3[_local5] = _local4;
_local7.stabbingCount--;
};
_local3 = _local13.lowerBounds;
_local4 = _local3[_local5];
_local4--;
_local3[_local5] = _local4;
_local7.Swap(_local8);
_local6--;
};
};
if (_local22 > 0){
_local6 = _local18;
while ((((_local6 < (_local12 - 1))) && (((_local16[int((_local6 + 1))] as b2Bound).value <= _local20)))) {
_local7 = _local16[_local6];
_local9 = _local16[int((_local6 + 1))];
_local10 = _local9.proxyId;
_local11 = m_proxyPool[_local10];
_local9.stabbingCount++;
if (_local9.IsLower() == true){
if (TestOverlap(_local14, _local11)){
m_pairManager.AddBufferedPair(_arg1, _local10);
};
_local3 = _local11.lowerBounds;
_local4 = _local3[_local5];
_local4--;
_local3[_local5] = _local4;
_local7.stabbingCount++;
} else {
_local3 = _local11.upperBounds;
_local4 = _local3[_local5];
_local4--;
_local3[_local5] = _local4;
_local7.stabbingCount--;
};
_local3 = _local13.upperBounds;
_local4 = _local3[_local5];
_local4++;
_local3[_local5] = _local4;
_local7.Swap(_local9);
_local6++;
};
};
if (_local21 > 0){
_local6 = _local17;
while ((((_local6 < (_local12 - 1))) && (((_local16[int((_local6 + 1))] as b2Bound).value <= _local19)))) {
_local7 = _local16[_local6];
_local9 = _local16[int((_local6 + 1))];
_local10 = _local9.proxyId;
_local11 = m_proxyPool[_local10];
_local9.stabbingCount--;
if (_local9.IsUpper()){
if (TestOverlap(_local15, _local11)){
m_pairManager.RemoveBufferedPair(_arg1, _local10);
};
_local3 = _local11.upperBounds;
_local4 = _local3[_local5];
_local4--;
_local3[_local5] = _local4;
_local7.stabbingCount--;
} else {
_local3 = _local11.lowerBounds;
_local4 = _local3[_local5];
_local4--;
_local3[_local5] = _local4;
_local7.stabbingCount++;
};
_local3 = _local13.lowerBounds;
_local4 = _local3[_local5];
_local4++;
_local3[_local5] = _local4;
_local7.Swap(_local9);
_local6++;
};
};
if (_local22 < 0){
_local6 = _local18;
while ((((_local6 > 0)) && ((_local20 < (_local16[int((_local6 - 1))] as b2Bound).value)))) {
_local7 = _local16[_local6];
_local8 = _local16[int((_local6 - 1))];
_local23 = _local8.proxyId;
_local24 = m_proxyPool[_local23];
_local8.stabbingCount--;
if (_local8.IsLower() == true){
if (TestOverlap(_local15, _local24)){
m_pairManager.RemoveBufferedPair(_arg1, _local23);
};
_local3 = _local24.lowerBounds;
_local4 = _local3[_local5];
_local4++;
_local3[_local5] = _local4;
_local7.stabbingCount--;
} else {
_local3 = _local24.upperBounds;
_local4 = _local3[_local5];
_local4++;
_local3[_local5] = _local4;
_local7.stabbingCount++;
};
_local3 = _local13.upperBounds;
_local4 = _local3[_local5];
_local4--;
_local3[_local5] = _local4;
_local7.Swap(_local8);
_local6--;
};
};
_local5++;
};
}
public static function BinarySearch(_arg1:Array, _arg2:int, _arg3:uint):uint{
var _local6:int;
var _local7:b2Bound;
var _local4:int;
var _local5:int = (_arg2 - 1);
while (_local4 <= _local5) {
_local6 = ((_local4 + _local5) / 2);
_local7 = _arg1[_local6];
if (_local7.value > _arg3){
_local5 = (_local6 - 1);
} else {
if (_local7.value < _arg3){
_local4 = (_local6 + 1);
} else {
return (uint(_local6));
};
};
};
return (uint(_local4));
}
}
}//package Box2D.Collision
Section 14
//b2BufferedPair (Box2D.Collision.b2BufferedPair)
package Box2D.Collision {
public class b2BufferedPair {
public var proxyId1:uint;
public var proxyId2:uint;
}
}//package Box2D.Collision
Section 15
//b2Collision (Box2D.Collision.b2Collision)
package Box2D.Collision {
import Box2D.Collision.Shapes.*;
import Box2D.Common.Math.*;
import Box2D.Common.*;
public class b2Collision {
public static const b2_nullFeature:uint = 0xFF;
private static var b2CollidePolyTempVec:b2Vec2 = new b2Vec2();
public static function EdgeSeparation(_arg1:b2PolygonShape, _arg2:b2XForm, _arg3:int, _arg4:b2PolygonShape, _arg5:b2XForm):Number{
var _local11:b2Mat22;
var _local12:b2Vec2;
var _local25:Number;
var _local6:int = _arg1.m_vertexCount;
var _local7:Array = _arg1.m_vertices;
var _local8:Array = _arg1.m_normals;
var _local9:int = _arg4.m_vertexCount;
var _local10:Array = _arg4.m_vertices;
_local11 = _arg2.R;
_local12 = _local8[_arg3];
var _local13:Number = ((_local11.col1.x * _local12.x) + (_local11.col2.x * _local12.y));
var _local14:Number = ((_local11.col1.y * _local12.x) + (_local11.col2.y * _local12.y));
_local11 = _arg5.R;
var _local15:Number = ((_local11.col1.x * _local13) + (_local11.col1.y * _local14));
var _local16:Number = ((_local11.col2.x * _local13) + (_local11.col2.y * _local14));
var _local17:int;
var _local18:Number = Number.MAX_VALUE;
var _local19:int;
while (_local19 < _local9) {
_local12 = _local10[_local19];
_local25 = ((_local12.x * _local15) + (_local12.y * _local16));
if (_local25 < _local18){
_local18 = _local25;
_local17 = _local19;
};
_local19++;
};
_local12 = _local7[_arg3];
_local11 = _arg2.R;
var _local20:Number = (_arg2.position.x + ((_local11.col1.x * _local12.x) + (_local11.col2.x * _local12.y)));
var _local21:Number = (_arg2.position.y + ((_local11.col1.y * _local12.x) + (_local11.col2.y * _local12.y)));
_local12 = _local10[_local17];
_local11 = _arg5.R;
var _local22:Number = (_arg5.position.x + ((_local11.col1.x * _local12.x) + (_local11.col2.x * _local12.y)));
var _local23:Number = (_arg5.position.y + ((_local11.col1.y * _local12.x) + (_local11.col2.y * _local12.y)));
_local22 = (_local22 - _local20);
_local23 = (_local23 - _local21);
var _local24:Number = ((_local22 * _local13) + (_local23 * _local14));
return (_local24);
}
public static function b2TestOverlap(_arg1:b2AABB, _arg2:b2AABB):Boolean{
var _local3:b2Vec2 = _arg2.lowerBound;
var _local4:b2Vec2 = _arg1.upperBound;
var _local5:Number = (_local3.x - _local4.x);
var _local6:Number = (_local3.y - _local4.y);
_local3 = _arg1.lowerBound;
_local4 = _arg2.upperBound;
var _local7:Number = (_local3.x - _local4.x);
var _local8:Number = (_local3.y - _local4.y);
if ((((_local5 > 0)) || ((_local6 > 0)))){
return (false);
};
if ((((_local7 > 0)) || ((_local8 > 0)))){
return (false);
};
return (true);
}
public static function FindIncidentEdge(_arg1:Array, _arg2:b2PolygonShape, _arg3:b2XForm, _arg4:int, _arg5:b2PolygonShape, _arg6:b2XForm):void{
var _local12:b2Mat22;
var _local13:b2Vec2;
var _local20:ClipVertex;
var _local23:Number;
var _local7:int = _arg2.m_vertexCount;
var _local8:Array = _arg2.m_normals;
var _local9:int = _arg5.m_vertexCount;
var _local10:Array = _arg5.m_vertices;
var _local11:Array = _arg5.m_normals;
_local12 = _arg3.R;
_local13 = _local8[_arg4];
var _local14:Number = ((_local12.col1.x * _local13.x) + (_local12.col2.x * _local13.y));
var _local15:Number = ((_local12.col1.y * _local13.x) + (_local12.col2.y * _local13.y));
_local12 = _arg6.R;
var _local16:Number = ((_local12.col1.x * _local14) + (_local12.col1.y * _local15));
_local15 = ((_local12.col2.x * _local14) + (_local12.col2.y * _local15));
_local14 = _local16;
var _local17:int;
var _local18:Number = Number.MAX_VALUE;
var _local19:int;
while (_local19 < _local9) {
_local13 = _local11[_local19];
_local23 = ((_local14 * _local13.x) + (_local15 * _local13.y));
if (_local23 < _local18){
_local18 = _local23;
_local17 = _local19;
};
_local19++;
};
var _local21:int = _local17;
var _local22:int = (((_local21 + 1) < _local9)) ? (_local21 + 1) : 0;
_local20 = _arg1[0];
_local13 = _local10[_local21];
_local12 = _arg6.R;
_local20.v.x = (_arg6.position.x + ((_local12.col1.x * _local13.x) + (_local12.col2.x * _local13.y)));
_local20.v.y = (_arg6.position.y + ((_local12.col1.y * _local13.x) + (_local12.col2.y * _local13.y)));
_local20.id.features.referenceEdge = _arg4;
_local20.id.features.incidentEdge = _local21;
_local20.id.features.incidentVertex = 0;
_local20 = _arg1[1];
_local13 = _local10[_local22];
_local12 = _arg6.R;
_local20.v.x = (_arg6.position.x + ((_local12.col1.x * _local13.x) + (_local12.col2.x * _local13.y)));
_local20.v.y = (_arg6.position.y + ((_local12.col1.y * _local13.x) + (_local12.col2.y * _local13.y)));
_local20.id.features.referenceEdge = _arg4;
_local20.id.features.incidentEdge = _local22;
_local20.id.features.incidentVertex = 1;
}
public static function b2CollidePolygons(_arg1:b2Manifold, _arg2:b2PolygonShape, _arg3:b2XForm, _arg4:b2PolygonShape, _arg5:b2XForm):void{
var _local6:ClipVertex;
var _local13:b2PolygonShape;
var _local14:b2PolygonShape;
var _local17:int;
var _local18:uint;
var _local34:int;
var _local37:b2Vec2;
var _local38:Number;
var _local39:b2ManifoldPoint;
_arg1.pointCount = 0;
var _local7:int;
var _local8:Array = [_local7];
var _local9:Number = FindMaxSeparation(_local8, _arg2, _arg3, _arg4, _arg5);
_local7 = _local8[0];
if (_local9 > 0){
return;
};
var _local10:int;
var _local11:Array = [_local10];
var _local12:Number = FindMaxSeparation(_local11, _arg4, _arg5, _arg2, _arg3);
_local10 = _local11[0];
if (_local12 > 0){
return;
};
var _local15:b2XForm = new b2XForm();
var _local16:b2XForm = new b2XForm();
var _local19:Number = 0.98;
var _local20:Number = 0.001;
if (_local12 > ((_local19 * _local9) + _local20)){
_local13 = _arg4;
_local14 = _arg2;
_local15.Set(_arg5);
_local16.Set(_arg3);
_local17 = _local10;
_local18 = 1;
} else {
_local13 = _arg2;
_local14 = _arg4;
_local15.Set(_arg3);
_local16.Set(_arg5);
_local17 = _local7;
_local18 = 0;
};
var _local21:Array = [new ClipVertex(), new ClipVertex()];
FindIncidentEdge(_local21, _local13, _local15, _local17, _local14, _local16);
var _local22:int = _local13.m_vertexCount;
var _local23:Array = _local13.m_vertices;
var _local24:b2Vec2 = _local23[_local17];
var _local25:b2Vec2 = _local24.Copy();
if ((_local17 + 1) < _local22){
_local24 = _local23[int((_local17 + 1))];
_local37 = _local24.Copy();
} else {
_local24 = _local23[0];
_local37 = _local24.Copy();
};
var _local26:b2Vec2 = b2Math.SubtractVV(_local37, _local25);
var _local27:b2Vec2 = b2Math.b2MulMV(_local15.R, b2Math.SubtractVV(_local37, _local25));
_local27.Normalize();
var _local28:b2Vec2 = b2Math.b2CrossVF(_local27, 1);
_local25 = b2Math.b2MulX(_local15, _local25);
_local37 = b2Math.b2MulX(_local15, _local37);
var _local29:Number = b2Math.b2Dot(_local28, _local25);
var _local30:Number = -(b2Math.b2Dot(_local27, _local25));
var _local31:Number = b2Math.b2Dot(_local27, _local37);
var _local32:Array = [new ClipVertex(), new ClipVertex()];
var _local33:Array = [new ClipVertex(), new ClipVertex()];
_local34 = ClipSegmentToLine(_local32, _local21, _local27.Negative(), _local30);
if (_local34 < 2){
return;
};
_local34 = ClipSegmentToLine(_local33, _local32, _local27, _local31);
if (_local34 < 2){
return;
};
_arg1.normal = (_local18) ? _local28.Negative() : _local28.Copy();
var _local35:int;
var _local36:int;
while (_local36 < b2Settings.b2_maxManifoldPoints) {
_local6 = _local33[_local36];
_local38 = (b2Math.b2Dot(_local28, _local6.v) - _local29);
if (_local38 <= 0){
_local39 = _arg1.points[_local35];
_local39.separation = _local38;
_local39.localPoint1 = b2Math.b2MulXT(_arg3, _local6.v);
_local39.localPoint2 = b2Math.b2MulXT(_arg5, _local6.v);
_local39.id.key = _local6.id._key;
_local39.id.features.flip = _local18;
_local35++;
};
_local36++;
};
_arg1.pointCount = _local35;
}
public static function FindMaxSeparation(_arg1:Array, _arg2:b2PolygonShape, _arg3:b2XForm, _arg4:b2PolygonShape, _arg5:b2XForm):Number{
var _local8:b2Vec2;
var _local9:b2Mat22;
var _local22:int;
var _local23:Number;
var _local24:int;
var _local25:Number;
var _local6:int = _arg2.m_vertexCount;
var _local7:Array = _arg2.m_normals;
_local9 = _arg5.R;
_local8 = _arg4.m_centroid;
var _local10:Number = (_arg5.position.x + ((_local9.col1.x * _local8.x) + (_local9.col2.x * _local8.y)));
var _local11:Number = (_arg5.position.y + ((_local9.col1.y * _local8.x) + (_local9.col2.y * _local8.y)));
_local9 = _arg3.R;
_local8 = _arg2.m_centroid;
_local10 = (_local10 - (_arg3.position.x + ((_local9.col1.x * _local8.x) + (_local9.col2.x * _local8.y))));
_local11 = (_local11 - (_arg3.position.y + ((_local9.col1.y * _local8.x) + (_local9.col2.y * _local8.y))));
var _local12:Number = ((_local10 * _arg3.R.col1.x) + (_local11 * _arg3.R.col1.y));
var _local13:Number = ((_local10 * _arg3.R.col2.x) + (_local11 * _arg3.R.col2.y));
var _local14:int;
var _local15:Number = -(Number.MAX_VALUE);
var _local16:int;
while (_local16 < _local6) {
_local8 = _local7[_local16];
_local25 = ((_local8.x * _local12) + (_local8.y * _local13));
if (_local25 > _local15){
_local15 = _local25;
_local14 = _local16;
};
_local16++;
};
var _local17:Number = EdgeSeparation(_arg2, _arg3, _local14, _arg4, _arg5);
if (_local17 > 0){
return (_local17);
};
var _local18:int = (((_local14 - 1) >= 0)) ? (_local14 - 1) : (_local6 - 1);
var _local19:Number = EdgeSeparation(_arg2, _arg3, _local18, _arg4, _arg5);
if (_local19 > 0){
return (_local19);
};
var _local20:int = (((_local14 + 1) < _local6)) ? (_local14 + 1) : 0;
var _local21:Number = EdgeSeparation(_arg2, _arg3, _local20, _arg4, _arg5);
if (_local21 > 0){
return (_local21);
};
if ((((_local19 > _local17)) && ((_local19 > _local21)))){
_local24 = -1;
_local22 = _local18;
_local23 = _local19;
} else {
if (_local21 > _local17){
_local24 = 1;
_local22 = _local20;
_local23 = _local21;
} else {
_arg1[0] = _local14;
return (_local17);
};
};
while (true) {
if (_local24 == -1){
_local14 = (((_local22 - 1) >= 0)) ? (_local22 - 1) : (_local6 - 1);
} else {
_local14 = (((_local22 + 1) < _local6)) ? (_local22 + 1) : 0;
};
_local17 = EdgeSeparation(_arg2, _arg3, _local14, _arg4, _arg5);
if (_local17 > 0){
return (_local17);
};
if (_local17 > _local23){
_local22 = _local14;
_local23 = _local17;
} else {
break;
};
};
_arg1[0] = _local22;
return (_local23);
}
public static function ClipSegmentToLine(_arg1:Array, _arg2:Array, _arg3:b2Vec2, _arg4:Number):int{
var _local5:ClipVertex;
var _local6:int;
var _local7:b2Vec2;
var _local8:b2Vec2;
var _local9:Number;
var _local11:Number;
var _local12:b2Vec2;
var _local13:ClipVertex;
_local6 = 0;
_local5 = _arg2[0];
_local7 = _local5.v;
_local5 = _arg2[1];
_local8 = _local5.v;
_local9 = (b2Math.b2Dot(_arg3, _local7) - _arg4);
var _local10:Number = (b2Math.b2Dot(_arg3, _local8) - _arg4);
if (_local9 <= 0){
var _temp1 = _local6;
_local6 = (_local6 + 1);
var _local14 = _temp1;
_arg1[_local14] = _arg2[0];
};
if (_local10 <= 0){
var _temp2 = _local6;
_local6 = (_local6 + 1);
_local14 = _temp2;
_arg1[_local14] = _arg2[1];
};
if ((_local9 * _local10) < 0){
_local11 = (_local9 / (_local9 - _local10));
_local5 = _arg1[_local6];
_local12 = _local5.v;
_local12.x = (_local7.x + (_local11 * (_local8.x - _local7.x)));
_local12.y = (_local7.y + (_local11 * (_local8.y - _local7.y)));
_local5 = _arg1[_local6];
if (_local9 > 0){
_local13 = _arg2[0];
_local5.id = _local13.id;
} else {
_local13 = _arg2[1];
_local5.id = _local13.id;
};
_local6++;
};
return (_local6);
}
public static function b2CollideCircles(_arg1:b2Manifold, _arg2:b2CircleShape, _arg3:b2XForm, _arg4:b2CircleShape, _arg5:b2XForm):void{
var _local6:b2Mat22;
var _local7:b2Vec2;
var _local18:Number;
var _local24:Number;
var _local25:Number;
_arg1.pointCount = 0;
_local6 = _arg3.R;
_local7 = _arg2.m_localPosition;
var _local8:Number = (_arg3.position.x + ((_local6.col1.x * _local7.x) + (_local6.col2.x * _local7.y)));
var _local9:Number = (_arg3.position.y + ((_local6.col1.y * _local7.x) + (_local6.col2.y * _local7.y)));
_local6 = _arg5.R;
_local7 = _arg4.m_localPosition;
var _local10:Number = (_arg5.position.x + ((_local6.col1.x * _local7.x) + (_local6.col2.x * _local7.y)));
var _local11:Number = (_arg5.position.y + ((_local6.col1.y * _local7.x) + (_local6.col2.y * _local7.y)));
var _local12:Number = (_local10 - _local8);
var _local13:Number = (_local11 - _local9);
var _local14:Number = ((_local12 * _local12) + (_local13 * _local13));
var _local15:Number = _arg2.m_radius;
var _local16:Number = _arg4.m_radius;
var _local17:Number = (_local15 + _local16);
if (_local14 > (_local17 * _local17)){
return;
};
if (_local14 < Number.MIN_VALUE){
_local18 = -(_local17);
_arg1.normal.Set(0, 1);
} else {
_local24 = Math.sqrt(_local14);
_local18 = (_local24 - _local17);
_local25 = (1 / _local24);
_arg1.normal.x = (_local25 * _local12);
_arg1.normal.y = (_local25 * _local13);
};
_arg1.pointCount = 1;
var _local19:b2ManifoldPoint = _arg1.points[0];
_local19.id.key = 0;
_local19.separation = _local18;
_local8 = (_local8 + (_local15 * _arg1.normal.x));
_local9 = (_local9 + (_local15 * _arg1.normal.y));
_local10 = (_local10 - (_local16 * _arg1.normal.x));
_local11 = (_local11 - (_local16 * _arg1.normal.y));
var _local20:Number = (0.5 * (_local8 + _local10));
var _local21:Number = (0.5 * (_local9 + _local11));
var _local22:Number = (_local20 - _arg3.position.x);
var _local23:Number = (_local21 - _arg3.position.y);
_local19.localPoint1.x = ((_local22 * _arg3.R.col1.x) + (_local23 * _arg3.R.col1.y));
_local19.localPoint1.y = ((_local22 * _arg3.R.col2.x) + (_local23 * _arg3.R.col2.y));
_local22 = (_local20 - _arg5.position.x);
_local23 = (_local21 - _arg5.position.y);
_local19.localPoint2.x = ((_local22 * _arg5.R.col1.x) + (_local23 * _arg5.R.col1.y));
_local19.localPoint2.y = ((_local22 * _arg5.R.col2.x) + (_local23 * _arg5.R.col2.y));
}
public static function b2CollidePolygonAndCircle(_arg1:b2Manifold, _arg2:b2PolygonShape, _arg3:b2XForm, _arg4:b2CircleShape, _arg5:b2XForm):void{
var _local6:b2ManifoldPoint;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:b2Vec2;
var _local12:b2Mat22;
var _local17:Number;
var _local32:Number;
var _local33:Number;
var _local34:Number;
_arg1.pointCount = 0;
_local12 = _arg5.R;
_local11 = _arg4.m_localPosition;
var _local13:Number = (_arg5.position.x + ((_local12.col1.x * _local11.x) + (_local12.col2.x * _local11.y)));
var _local14:Number = (_arg5.position.y + ((_local12.col1.y * _local11.x) + (_local12.col2.y * _local11.y)));
_local7 = (_local13 - _arg3.position.x);
_local8 = (_local14 - _arg3.position.y);
_local12 = _arg3.R;
var _local15:Number = ((_local7 * _local12.col1.x) + (_local8 * _local12.col1.y));
var _local16:Number = ((_local7 * _local12.col2.x) + (_local8 * _local12.col2.y));
var _local18:int;
var _local19:Number = -(Number.MAX_VALUE);
var _local20:Number = _arg4.m_radius;
var _local21:int = _arg2.m_vertexCount;
var _local22:Array = _arg2.m_vertices;
var _local23:Array = _arg2.m_normals;
var _local24:int;
while (_local24 < _local21) {
_local11 = _local22[_local24];
_local7 = (_local15 - _local11.x);
_local8 = (_local16 - _local11.y);
_local11 = _local23[_local24];
_local34 = ((_local11.x * _local7) + (_local11.y * _local8));
if (_local34 > _local20){
return;
};
if (_local34 > _local19){
_local19 = _local34;
_local18 = _local24;
};
_local24++;
};
if (_local19 < Number.MIN_VALUE){
_arg1.pointCount = 1;
_local11 = _local23[_local18];
_local12 = _arg3.R;
_arg1.normal.x = ((_local12.col1.x * _local11.x) + (_local12.col2.x * _local11.y));
_arg1.normal.y = ((_local12.col1.y * _local11.x) + (_local12.col2.y * _local11.y));
_local6 = _arg1.points[0];
_local6.id.features.incidentEdge = _local18;
_local6.id.features.incidentVertex = b2_nullFeature;
_local6.id.features.referenceEdge = 0;
_local6.id.features.flip = 0;
_local9 = (_local13 - (_local20 * _arg1.normal.x));
_local10 = (_local14 - (_local20 * _arg1.normal.y));
_local7 = (_local9 - _arg3.position.x);
_local8 = (_local10 - _arg3.position.y);
_local12 = _arg3.R;
_local6.localPoint1.x = ((_local7 * _local12.col1.x) + (_local8 * _local12.col1.y));
_local6.localPoint1.y = ((_local7 * _local12.col2.x) + (_local8 * _local12.col2.y));
_local7 = (_local9 - _arg5.position.x);
_local8 = (_local10 - _arg5.position.y);
_local12 = _arg5.R;
_local6.localPoint2.x = ((_local7 * _local12.col1.x) + (_local8 * _local12.col1.y));
_local6.localPoint2.y = ((_local7 * _local12.col2.x) + (_local8 * _local12.col2.y));
_local6.separation = (_local19 - _local20);
return;
};
var _local25:int = _local18;
var _local26:int = (((_local25 + 1) < _local21)) ? (_local25 + 1) : 0;
_local11 = _local22[_local25];
var _local27:b2Vec2 = _local22[_local26];
var _local28:Number = (_local27.x - _local11.x);
var _local29:Number = (_local27.y - _local11.y);
var _local30:Number = Math.sqrt(((_local28 * _local28) + (_local29 * _local29)));
_local28 = (_local28 / _local30);
_local29 = (_local29 / _local30);
_local7 = (_local15 - _local11.x);
_local8 = (_local16 - _local11.y);
var _local31:Number = ((_local7 * _local28) + (_local8 * _local29));
_local6 = _arg1.points[0];
if (_local31 <= 0){
_local32 = _local11.x;
_local33 = _local11.y;
_local6.id.features.incidentEdge = b2_nullFeature;
_local6.id.features.incidentVertex = _local25;
} else {
if (_local31 >= _local30){
_local32 = _local27.x;
_local33 = _local27.y;
_local6.id.features.incidentEdge = b2_nullFeature;
_local6.id.features.incidentVertex = _local26;
} else {
_local32 = ((_local28 * _local31) + _local11.x);
_local33 = ((_local29 * _local31) + _local11.y);
_local6.id.features.incidentEdge = _local18;
_local6.id.features.incidentVertex = 0;
};
};
_local7 = (_local15 - _local32);
_local8 = (_local16 - _local33);
_local17 = Math.sqrt(((_local7 * _local7) + (_local8 * _local8)));
_local7 = (_local7 / _local17);
_local8 = (_local8 / _local17);
if (_local17 > _local20){
return;
};
_arg1.pointCount = 1;
_local12 = _arg3.R;
_arg1.normal.x = ((_local12.col1.x * _local7) + (_local12.col2.x * _local8));
_arg1.normal.y = ((_local12.col1.y * _local7) + (_local12.col2.y * _local8));
_local9 = (_local13 - (_local20 * _arg1.normal.x));
_local10 = (_local14 - (_local20 * _arg1.normal.y));
_local7 = (_local9 - _arg3.position.x);
_local8 = (_local10 - _arg3.position.y);
_local12 = _arg3.R;
_local6.localPoint1.x = ((_local7 * _local12.col1.x) + (_local8 * _local12.col1.y));
_local6.localPoint1.y = ((_local7 * _local12.col2.x) + (_local8 * _local12.col2.y));
_local7 = (_local9 - _arg5.position.x);
_local8 = (_local10 - _arg5.position.y);
_local12 = _arg5.R;
_local6.localPoint2.x = ((_local7 * _local12.col1.x) + (_local8 * _local12.col1.y));
_local6.localPoint2.y = ((_local7 * _local12.col2.x) + (_local8 * _local12.col2.y));
_local6.separation = (_local17 - _local20);
_local6.id.features.referenceEdge = 0;
_local6.id.features.flip = 0;
}
}
}//package Box2D.Collision
Section 16
//b2ContactID (Box2D.Collision.b2ContactID)
package Box2D.Collision {
public class b2ContactID {
public var _key:uint;
public var features:Features;
public function b2ContactID(){
features = new Features();
super();
features._m_id = this;
}
public function Set(_arg1:b2ContactID):void{
key = _arg1._key;
}
public function Copy():b2ContactID{
var _local1:b2ContactID = new b2ContactID();
_local1.key = key;
return (_local1);
}
public function set key(_arg1:uint):void{
_key = _arg1;
features._referenceEdge = (_key & 0xFF);
features._incidentEdge = (((_key & 0xFF00) >> 8) & 0xFF);
features._incidentVertex = (((_key & 0xFF0000) >> 16) & 0xFF);
features._flip = (((_key & 4278190080) >> 24) & 0xFF);
}
public function get key():uint{
return (_key);
}
}
}//package Box2D.Collision
Section 17
//b2ContactPoint (Box2D.Collision.b2ContactPoint)
package Box2D.Collision {
import Box2D.Collision.Shapes.*;
import Box2D.Common.Math.*;
public class b2ContactPoint {
public var friction:Number;
public var separation:Number;
public var normal:b2Vec2;
public var position:b2Vec2;
public var restitution:Number;
public var shape1:b2Shape;
public var shape2:b2Shape;
public var id:b2ContactID;
public var velocity:b2Vec2;
public function b2ContactPoint(){
position = new b2Vec2();
velocity = new b2Vec2();
normal = new b2Vec2();
id = new b2ContactID();
super();
}
}
}//package Box2D.Collision
Section 18
//b2Distance (Box2D.Collision.b2Distance)
package Box2D.Collision {
import Box2D.Collision.Shapes.*;
import Box2D.Common.Math.*;
import Box2D.Common.*;
public class b2Distance {
private static var s_p2s:Array = [new b2Vec2(), new b2Vec2(), new b2Vec2()];
private static var s_p1s:Array = [new b2Vec2(), new b2Vec2(), new b2Vec2()];
private static var s_points:Array = [new b2Vec2(), new b2Vec2(), new b2Vec2()];
private static var gPoint:b2Point = new b2Point();
public static var g_GJK_Iterations:int = 0;
public static function InPoints(_arg1:b2Vec2, _arg2:Array, _arg3:int):Boolean{
var _local6:b2Vec2;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local4:Number = (100 * Number.MIN_VALUE);
var _local5:int;
while (_local5 < _arg3) {
_local6 = _arg2[_local5];
_local7 = Math.abs((_arg1.x - _local6.x));
_local8 = Math.abs((_arg1.y - _local6.y));
_local9 = Math.max(Math.abs(_arg1.x), Math.abs(_local6.x));
_local10 = Math.max(Math.abs(_arg1.y), Math.abs(_local6.y));
if ((((_local7 < (_local4 * (_local9 + 1)))) && ((_local8 < (_local4 * (_local10 + 1)))))){
return (true);
};
_local5++;
};
return (false);
}
public static function DistanceGeneric(_arg1:b2Vec2, _arg2:b2Vec2, _arg3, _arg4:b2XForm, _arg5, _arg6:b2XForm):Number{
var _local7:b2Vec2;
var _local15:Number;
var _local16:Number;
var _local17:b2Vec2;
var _local18:b2Vec2;
var _local19:Number;
var _local20:Number;
var _local21:Number;
var _local22:Number;
var _local23:int;
var _local8:Array = s_p1s;
var _local9:Array = s_p2s;
var _local10:Array = s_points;
var _local11:int;
_arg1.SetV(_arg3.GetFirstVertex(_arg4));
_arg2.SetV(_arg5.GetFirstVertex(_arg6));
var _local12:Number = 0;
var _local13 = 20;
var _local14:int;
while (_local14 < _local13) {
_local15 = (_arg2.x - _arg1.x);
_local16 = (_arg2.y - _arg1.y);
_local17 = _arg3.Support(_arg4, _local15, _local16);
_local18 = _arg5.Support(_arg6, -(_local15), -(_local16));
_local12 = ((_local15 * _local15) + (_local16 * _local16));
_local19 = (_local18.x - _local17.x);
_local20 = (_local18.y - _local17.y);
_local21 = ((_local15 * _local19) + (_local16 * _local20));
if ((_local12 - ((_local15 * _local19) + (_local16 * _local20))) <= (0.01 * _local12)){
if (_local11 == 0){
_arg1.SetV(_local17);
_arg2.SetV(_local18);
};
g_GJK_Iterations = _local14;
return (Math.sqrt(_local12));
};
switch (_local11){
case 0:
_local7 = _local8[0];
_local7.SetV(_local17);
_local7 = _local9[0];
_local7.SetV(_local18);
_local7 = _local10[0];
_local7.x = _local19;
_local7.y = _local20;
_arg1.SetV(_local8[0]);
_arg2.SetV(_local9[0]);
_local11++;
break;
case 1:
_local7 = _local8[1];
_local7.SetV(_local17);
_local7 = _local9[1];
_local7.SetV(_local18);
_local7 = _local10[1];
_local7.x = _local19;
_local7.y = _local20;
_local11 = ProcessTwo(_arg1, _arg2, _local8, _local9, _local10);
break;
case 2:
_local7 = _local8[2];
_local7.SetV(_local17);
_local7 = _local9[2];
_local7.SetV(_local18);
_local7 = _local10[2];
_local7.x = _local19;
_local7.y = _local20;
_local11 = ProcessThree(_arg1, _arg2, _local8, _local9, _local10);
break;
};
if (_local11 == 3){
g_GJK_Iterations = _local14;
return (0);
};
_local22 = -(Number.MAX_VALUE);
_local23 = 0;
while (_local23 < _local11) {
_local7 = _local10[_local23];
_local22 = b2Math.b2Max(_local22, ((_local7.x * _local7.x) + (_local7.y * _local7.y)));
_local23++;
};
if ((((_local11 == 3)) || ((_local12 <= ((100 * Number.MIN_VALUE) * _local22))))){
g_GJK_Iterations = _local14;
_local15 = (_arg2.x - _arg1.x);
_local16 = (_arg2.y - _arg1.y);
_local12 = ((_local15 * _local15) + (_local16 * _local16));
return (Math.sqrt(_local12));
};
_local14++;
};
g_GJK_Iterations = _local13;
return (Math.sqrt(_local12));
}
public static function DistanceCC(_arg1:b2Vec2, _arg2:b2Vec2, _arg3:b2CircleShape, _arg4:b2XForm, _arg5:b2CircleShape, _arg6:b2XForm):Number{
var _local7:b2Mat22;
var _local8:b2Vec2;
var _local19:Number;
var _local20:Number;
_local7 = _arg4.R;
_local8 = _arg3.m_localPosition;
var _local9:Number = (_arg4.position.x + ((_local7.col1.x * _local8.x) + (_local7.col2.x * _local8.y)));
var _local10:Number = (_arg4.position.y + ((_local7.col1.y * _local8.x) + (_local7.col2.y * _local8.y)));
_local7 = _arg6.R;
_local8 = _arg5.m_localPosition;
var _local11:Number = (_arg6.position.x + ((_local7.col1.x * _local8.x) + (_local7.col2.x * _local8.y)));
var _local12:Number = (_arg6.position.y + ((_local7.col1.y * _local8.x) + (_local7.col2.y * _local8.y)));
var _local13:Number = (_local11 - _local9);
var _local14:Number = (_local12 - _local10);
var _local15:Number = ((_local13 * _local13) + (_local14 * _local14));
var _local16:Number = (_arg3.m_radius - b2Settings.b2_toiSlop);
var _local17:Number = (_arg5.m_radius - b2Settings.b2_toiSlop);
var _local18:Number = (_local16 + _local17);
if (_local15 > (_local18 * _local18)){
_local19 = Math.sqrt(((_local13 * _local13) + (_local14 * _local14)));
_local13 = (_local13 / _local19);
_local14 = (_local14 / _local19);
_local20 = (_local19 - _local18);
_arg1.x = (_local9 + (_local16 * _local13));
_arg1.y = (_local10 + (_local16 * _local14));
_arg2.x = (_local11 - (_local17 * _local13));
_arg2.y = (_local12 - (_local17 * _local14));
return (_local20);
};
if (_local15 > (Number.MIN_VALUE * Number.MIN_VALUE)){
_local19 = Math.sqrt(((_local13 * _local13) + (_local14 * _local14)));
_local13 = (_local13 / _local19);
_local14 = (_local14 / _local19);
_arg1.x = (_local9 + (_local16 * _local13));
_arg1.y = (_local10 + (_local16 * _local14));
_arg2.x = _arg1.x;
_arg2.y = _arg1.y;
return (0);
};
_arg1.x = _local9;
_arg1.y = _local10;
_arg2.x = _arg1.x;
_arg2.y = _arg1.y;
return (0);
}
public static function ProcessThree(_arg1:b2Vec2, _arg2:b2Vec2, _arg3:Array, _arg4:Array, _arg5:Array):int{
var _local6:b2Vec2;
var _local7:b2Vec2;
var _local8:b2Vec2;
var _local9:b2Vec2;
var _local10:b2Vec2;
var _local11:b2Vec2;
var _local12:b2Vec2;
var _local13:b2Vec2;
var _local35:Number;
_local6 = _arg5[0];
_local7 = _arg5[1];
_local8 = _arg5[2];
_local9 = _arg3[0];
_local10 = _arg3[1];
_local11 = _arg3[2];
_local12 = _arg4[0];
_local13 = _arg4[1];
var _local14:b2Vec2 = _arg4[2];
var _local15:Number = _local6.x;
var _local16:Number = _local6.y;
var _local17:Number = _local7.x;
var _local18:Number = _local7.y;
var _local19:Number = _local8.x;
var _local20:Number = _local8.y;
var _local21:Number = (_local17 - _local15);
var _local22:Number = (_local18 - _local16);
var _local23:Number = (_local19 - _local15);
var _local24:Number = (_local20 - _local16);
var _local25:Number = (_local19 - _local17);
var _local26:Number = (_local20 - _local18);
var _local27:Number = -(((_local15 * _local21) + (_local16 * _local22)));
var _local28:Number = ((_local17 * _local21) + (_local18 * _local22));
var _local29:Number = -(((_local15 * _local23) + (_local16 * _local24)));
var _local30:Number = ((_local19 * _local23) + (_local20 * _local24));
var _local31:Number = -(((_local17 * _local25) + (_local18 * _local26)));
var _local32:Number = ((_local19 * _local25) + (_local20 * _local26));
if ((((_local30 <= 0)) && ((_local32 <= 0)))){
_arg1.SetV(_local11);
_arg2.SetV(_local14);
_local9.SetV(_local11);
_local12.SetV(_local14);
_local6.SetV(_local8);
return (1);
};
var _local33:Number = ((_local21 * _local24) - (_local22 * _local23));
var _local34:Number = (_local33 * ((_local15 * _local18) - (_local16 * _local17)));
var _local36:Number = (_local33 * ((_local17 * _local20) - (_local18 * _local19)));
if ((((((((_local36 <= 0)) && ((_local31 >= 0)))) && ((_local32 >= 0)))) && (((_local31 + _local32) > 0)))){
_local35 = (_local31 / (_local31 + _local32));
_arg1.x = (_local10.x + (_local35 * (_local11.x - _local10.x)));
_arg1.y = (_local10.y + (_local35 * (_local11.y - _local10.y)));
_arg2.x = (_local13.x + (_local35 * (_local14.x - _local13.x)));
_arg2.y = (_local13.y + (_local35 * (_local14.y - _local13.y)));
_local9.SetV(_local11);
_local12.SetV(_local14);
_local6.SetV(_local8);
return (2);
};
var _local37:Number = (_local33 * ((_local19 * _local16) - (_local20 * _local15)));
if ((((((((_local37 <= 0)) && ((_local29 >= 0)))) && ((_local30 >= 0)))) && (((_local29 + _local30) > 0)))){
_local35 = (_local29 / (_local29 + _local30));
_arg1.x = (_local9.x + (_local35 * (_local11.x - _local9.x)));
_arg1.y = (_local9.y + (_local35 * (_local11.y - _local9.y)));
_arg2.x = (_local12.x + (_local35 * (_local14.x - _local12.x)));
_arg2.y = (_local12.y + (_local35 * (_local14.y - _local12.y)));
_local10.SetV(_local11);
_local13.SetV(_local14);
_local7.SetV(_local8);
return (2);
};
var _local38:Number = ((_local36 + _local37) + _local34);
_local38 = (1 / _local38);
var _local39:Number = (_local36 * _local38);
var _local40:Number = (_local37 * _local38);
var _local41:Number = ((1 - _local39) - _local40);
_arg1.x = (((_local39 * _local9.x) + (_local40 * _local10.x)) + (_local41 * _local11.x));
_arg1.y = (((_local39 * _local9.y) + (_local40 * _local10.y)) + (_local41 * _local11.y));
_arg2.x = (((_local39 * _local12.x) + (_local40 * _local13.x)) + (_local41 * _local14.x));
_arg2.y = (((_local39 * _local12.y) + (_local40 * _local13.y)) + (_local41 * _local14.y));
return (3);
}
public static function DistancePC(_arg1:b2Vec2, _arg2:b2Vec2, _arg3:b2PolygonShape, _arg4:b2XForm, _arg5:b2CircleShape, _arg6:b2XForm):Number{
var _local7:b2Mat22;
var _local8:b2Vec2;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local9:b2Point = gPoint;
_local8 = _arg5.m_localPosition;
_local7 = _arg6.R;
_local9.p.x = (_arg6.position.x + ((_local7.col1.x * _local8.x) + (_local7.col2.x * _local8.y)));
_local9.p.y = (_arg6.position.y + ((_local7.col1.y * _local8.x) + (_local7.col2.y * _local8.y)));
var _local10:Number = DistanceGeneric(_arg1, _arg2, _arg3, _arg4, _local9, b2Math.b2XForm_identity);
var _local11:Number = (_arg5.m_radius - b2Settings.b2_toiSlop);
if (_local10 > _local11){
_local10 = (_local10 - _local11);
_local12 = (_arg2.x - _arg1.x);
_local13 = (_arg2.y - _arg1.y);
_local14 = Math.sqrt(((_local12 * _local12) + (_local13 * _local13)));
_local12 = (_local12 / _local14);
_local13 = (_local13 / _local14);
_arg2.x = (_arg2.x - (_local11 * _local12));
_arg2.y = (_arg2.y - (_local11 * _local13));
} else {
_local10 = 0;
_arg2.x = _arg1.x;
_arg2.y = _arg1.y;
};
return (_local10);
}
public static function Distance(_arg1:b2Vec2, _arg2:b2Vec2, _arg3:b2Shape, _arg4:b2XForm, _arg5:b2Shape, _arg6:b2XForm):Number{
var _local7:int = _arg3.m_type;
var _local8:int = _arg5.m_type;
if ((((_local7 == b2Shape.e_circleShape)) && ((_local8 == b2Shape.e_circleShape)))){
return (DistanceCC(_arg1, _arg2, (_arg3 as b2CircleShape), _arg4, (_arg5 as b2CircleShape), _arg6));
};
if ((((_local7 == b2Shape.e_polygonShape)) && ((_local8 == b2Shape.e_circleShape)))){
return (DistancePC(_arg1, _arg2, (_arg3 as b2PolygonShape), _arg4, (_arg5 as b2CircleShape), _arg6));
};
if ((((_local7 == b2Shape.e_circleShape)) && ((_local8 == b2Shape.e_polygonShape)))){
return (DistancePC(_arg2, _arg1, (_arg5 as b2PolygonShape), _arg6, (_arg3 as b2CircleShape), _arg4));
};
if ((((_local7 == b2Shape.e_polygonShape)) && ((_local8 == b2Shape.e_polygonShape)))){
return (DistanceGeneric(_arg1, _arg2, (_arg3 as b2PolygonShape), _arg4, (_arg5 as b2PolygonShape), _arg6));
};
return (0);
}
public static function ProcessTwo(_arg1:b2Vec2, _arg2:b2Vec2, _arg3:Array, _arg4:Array, _arg5:Array):int{
var _local9:b2Vec2;
var _local10:b2Vec2;
var _local11:b2Vec2;
var _local17:Number;
var _local6:b2Vec2 = _arg5[0];
var _local7:b2Vec2 = _arg5[1];
var _local8:b2Vec2 = _arg3[0];
_local9 = _arg3[1];
_local10 = _arg4[0];
_local11 = _arg4[1];
var _local12:Number = -(_local7.x);
var _local13:Number = -(_local7.y);
var _local14:Number = (_local6.x - _local7.x);
var _local15:Number = (_local6.y - _local7.y);
var _local16:Number = Math.sqrt(((_local14 * _local14) + (_local15 * _local15)));
_local14 = (_local14 / _local16);
_local15 = (_local15 / _local16);
_local17 = ((_local12 * _local14) + (_local13 * _local15));
if ((((_local17 <= 0)) || ((_local16 < Number.MIN_VALUE)))){
_arg1.SetV(_local9);
_arg2.SetV(_local11);
_local8.SetV(_local9);
_local10.SetV(_local11);
_local6.SetV(_local7);
return (1);
};
_local17 = (_local17 / _local16);
_arg1.x = (_local9.x + (_local17 * (_local8.x - _local9.x)));
_arg1.y = (_local9.y + (_local17 * (_local8.y - _local9.y)));
_arg2.x = (_local11.x + (_local17 * (_local10.x - _local11.x)));
_arg2.y = (_local11.y + (_local17 * (_local10.y - _local11.y)));
return (2);
}
}
}//package Box2D.Collision
Section 19
//b2Manifold (Box2D.Collision.b2Manifold)
package Box2D.Collision {
import Box2D.Common.Math.*;
import Box2D.Common.*;
public class b2Manifold {
public var pointCount:int;// = 0
public var normal:b2Vec2;
public var points:Array;
public function b2Manifold(){
points = new Array(b2Settings.b2_maxManifoldPoints);
var _local1:int;
while (_local1 < b2Settings.b2_maxManifoldPoints) {
points[_local1] = new b2ManifoldPoint();
_local1++;
};
normal = new b2Vec2();
}
public function Set(_arg1:b2Manifold):void{
pointCount = _arg1.pointCount;
var _local2:int;
while (_local2 < b2Settings.b2_maxManifoldPoints) {
(points[_local2] as b2ManifoldPoint).Set(_arg1.points[_local2]);
_local2++;
};
normal.SetV(_arg1.normal);
}
public function Reset():void{
var _local1:int;
while (_local1 < b2Settings.b2_maxManifoldPoints) {
(points[_local1] as b2ManifoldPoint).Reset();
_local1++;
};
normal.SetZero();
pointCount = 0;
}
}
}//package Box2D.Collision
Section 20
//b2ManifoldPoint (Box2D.Collision.b2ManifoldPoint)
package Box2D.Collision {
import Box2D.Common.Math.*;
public class b2ManifoldPoint {
public var separation:Number;
public var localPoint2:b2Vec2;
public var normalImpulse:Number;
public var tangentImpulse:Number;
public var localPoint1:b2Vec2;
public var id:b2ContactID;
public function b2ManifoldPoint(){
localPoint1 = new b2Vec2();
localPoint2 = new b2Vec2();
id = new b2ContactID();
super();
}
public function Set(_arg1:b2ManifoldPoint):void{
localPoint1.SetV(_arg1.localPoint1);
localPoint2.SetV(_arg1.localPoint2);
separation = _arg1.separation;
normalImpulse = _arg1.normalImpulse;
tangentImpulse = _arg1.tangentImpulse;
id.key = _arg1.id.key;
}
public function Reset():void{
localPoint1.SetZero();
localPoint2.SetZero();
separation = 0;
normalImpulse = 0;
tangentImpulse = 0;
id.key = 0;
}
}
}//package Box2D.Collision
Section 21
//b2OBB (Box2D.Collision.b2OBB)
package Box2D.Collision {
import Box2D.Common.Math.*;
public class b2OBB {
public var R:b2Mat22;
public var center:b2Vec2;
public var extents:b2Vec2;
public function b2OBB(){
R = new b2Mat22();
center = new b2Vec2();
extents = new b2Vec2();
super();
}
}
}//package Box2D.Collision
Section 22
//b2Pair (Box2D.Collision.b2Pair)
package Box2D.Collision {
import Box2D.Common.*;
public class b2Pair {
public var proxyId1:uint;
public var userData;// = null
public var proxyId2:uint;
public var status:uint;
public var next:uint;
public static var e_pairFinal:uint = 4;
public static var b2_tableMask:int = (b2_tableCapacity - 1);
public static var e_pairRemoved:uint = 2;
public static var b2_nullPair:uint = b2Settings.USHRT_MAX;
public static var e_pairBuffered:uint = 1;
public static var b2_nullProxy:uint = b2Settings.USHRT_MAX;
public static var b2_tableCapacity:int = b2Settings.b2_maxPairs;
public function SetBuffered():void{
status = (status | e_pairBuffered);
}
public function IsBuffered():Boolean{
return (((status & e_pairBuffered) == e_pairBuffered));
}
public function IsFinal():Boolean{
return (((status & e_pairFinal) == e_pairFinal));
}
public function ClearRemoved():void{
status = (status & ~(e_pairRemoved));
}
public function SetFinal():void{
status = (status | e_pairFinal);
}
public function IsRemoved():Boolean{
return (((status & e_pairRemoved) == e_pairRemoved));
}
public function ClearBuffered():void{
status = (status & ~(e_pairBuffered));
}
public function SetRemoved():void{
status = (status | e_pairRemoved);
}
}
}//package Box2D.Collision
Section 23
//b2PairCallback (Box2D.Collision.b2PairCallback)
package Box2D.Collision {
public class b2PairCallback {
public function PairRemoved(_arg1, _arg2, _arg3):void{
}
public function PairAdded(_arg1, _arg2){
return (null);
}
}
}//package Box2D.Collision
Section 24
//b2PairManager (Box2D.Collision.b2PairManager)
package Box2D.Collision {
import Box2D.Common.Math.*;
import Box2D.Common.*;
public class b2PairManager {
public var m_pairCount:int;
public var m_pairBuffer:Array;
public var m_hashTable:Array;
public var m_callback:b2PairCallback;
public var m_pairs:Array;
public var m_pairBufferCount:int;
public var m_broadPhase:b2BroadPhase;
public var m_freePair:uint;
public function b2PairManager(){
var _local1:uint;
super();
m_hashTable = new Array(b2Pair.b2_tableCapacity);
_local1 = 0;
while (_local1 < b2Pair.b2_tableCapacity) {
m_hashTable[_local1] = b2Pair.b2_nullPair;
_local1++;
};
m_pairs = new Array(b2Settings.b2_maxPairs);
_local1 = 0;
while (_local1 < b2Settings.b2_maxPairs) {
m_pairs[_local1] = new b2Pair();
_local1++;
};
m_pairBuffer = new Array(b2Settings.b2_maxPairs);
_local1 = 0;
while (_local1 < b2Settings.b2_maxPairs) {
m_pairBuffer[_local1] = new b2BufferedPair();
_local1++;
};
_local1 = 0;
while (_local1 < b2Settings.b2_maxPairs) {
m_pairs[_local1].proxyId1 = b2Pair.b2_nullProxy;
m_pairs[_local1].proxyId2 = b2Pair.b2_nullProxy;
m_pairs[_local1].userData = null;
m_pairs[_local1].status = 0;
m_pairs[_local1].next = (_local1 + 1);
_local1++;
};
m_pairs[int((b2Settings.b2_maxPairs - 1))].next = b2Pair.b2_nullPair;
m_pairCount = 0;
m_pairBufferCount = 0;
}
private function FindHash(_arg1:uint, _arg2:uint, _arg3:uint):b2Pair{
var _local4:b2Pair;
var _local5:uint = m_hashTable[_arg3];
_local4 = m_pairs[_local5];
while (((!((_local5 == b2Pair.b2_nullPair))) && ((Equals(_local4, _arg1, _arg2) == false)))) {
_local5 = _local4.next;
_local4 = m_pairs[_local5];
};
if (_local5 == b2Pair.b2_nullPair){
return (null);
};
return (_local4);
}
private function Find(_arg1:uint, _arg2:uint):b2Pair{
var _local4:uint;
if (_arg1 > _arg2){
_local4 = _arg1;
_arg1 = _arg2;
_arg2 = _local4;
};
var _local3:uint = (Hash(_arg1, _arg2) & b2Pair.b2_tableMask);
return (FindHash(_arg1, _arg2, _local3));
}
private function ValidateBuffer():void{
}
public function Commit():void{
var _local1:b2BufferedPair;
var _local2:int;
var _local5:b2Pair;
var _local6:b2Proxy;
var _local7:b2Proxy;
var _local3:int;
var _local4:Array = m_broadPhase.m_proxyPool;
_local2 = 0;
while (_local2 < m_pairBufferCount) {
_local1 = m_pairBuffer[_local2];
_local5 = Find(_local1.proxyId1, _local1.proxyId2);
_local5.ClearBuffered();
_local6 = _local4[_local5.proxyId1];
_local7 = _local4[_local5.proxyId2];
if (_local5.IsRemoved()){
if (_local5.IsFinal() == true){
m_callback.PairRemoved(_local6.userData, _local7.userData, _local5.userData);
};
_local1 = m_pairBuffer[_local3];
_local1.proxyId1 = _local5.proxyId1;
_local1.proxyId2 = _local5.proxyId2;
_local3++;
} else {
if (_local5.IsFinal() == false){
_local5.userData = m_callback.PairAdded(_local6.userData, _local7.userData);
_local5.SetFinal();
};
};
_local2++;
};
_local2 = 0;
while (_local2 < _local3) {
_local1 = m_pairBuffer[_local2];
RemovePair(_local1.proxyId1, _local1.proxyId2);
_local2++;
};
m_pairBufferCount = 0;
if (b2BroadPhase.s_validate){
ValidateTable();
};
}
public function RemoveBufferedPair(_arg1:int, _arg2:int):void{
var _local3:b2BufferedPair;
var _local4:b2Pair = Find(_arg1, _arg2);
if (_local4 == null){
return;
};
if (_local4.IsBuffered() == false){
_local4.SetBuffered();
_local3 = m_pairBuffer[m_pairBufferCount];
_local3.proxyId1 = _local4.proxyId1;
_local3.proxyId2 = _local4.proxyId2;
m_pairBufferCount++;
};
_local4.SetRemoved();
if (b2BroadPhase.s_validate){
ValidateBuffer();
};
}
private function RemovePair(_arg1:uint, _arg2:uint){
var _local3:b2Pair;
var _local7:uint;
var _local8:uint;
var _local9:*;
if (_arg1 > _arg2){
_local7 = _arg1;
_arg1 = _arg2;
_arg2 = _local7;
};
var _local4:uint = (Hash(_arg1, _arg2) & b2Pair.b2_tableMask);
var _local5:uint = m_hashTable[_local4];
var _local6:b2Pair;
while (_local5 != b2Pair.b2_nullPair) {
if (Equals(m_pairs[_local5], _arg1, _arg2)){
_local8 = _local5;
_local3 = m_pairs[_local5];
if (_local6){
_local6.next = _local3.next;
} else {
m_hashTable[_local4] = _local3.next;
};
_local3 = m_pairs[_local8];
_local9 = _local3.userData;
_local3.next = m_freePair;
_local3.proxyId1 = b2Pair.b2_nullProxy;
_local3.proxyId2 = b2Pair.b2_nullProxy;
_local3.userData = null;
_local3.status = 0;
m_freePair = _local8;
m_pairCount--;
return (_local9);
} else {
_local6 = m_pairs[_local5];
_local5 = _local6.next;
};
};
return (null);
}
public function Initialize(_arg1:b2BroadPhase, _arg2:b2PairCallback):void{
m_broadPhase = _arg1;
m_callback = _arg2;
}
public function AddBufferedPair(_arg1:int, _arg2:int):void{
var _local3:b2BufferedPair;
var _local4:b2Pair = AddPair(_arg1, _arg2);
if (_local4.IsBuffered() == false){
_local4.SetBuffered();
_local3 = m_pairBuffer[m_pairBufferCount];
_local3.proxyId1 = _local4.proxyId1;
_local3.proxyId2 = _local4.proxyId2;
m_pairBufferCount++;
};
_local4.ClearRemoved();
if (b2BroadPhase.s_validate){
ValidateBuffer();
};
}
private function AddPair(_arg1:uint, _arg2:uint):b2Pair{
var _local6:uint;
if (_arg1 > _arg2){
_local6 = _arg1;
_arg1 = _arg2;
_arg2 = _local6;
};
var _local3:uint = (Hash(_arg1, _arg2) & b2Pair.b2_tableMask);
var _local4 = FindHash(_arg1, _arg2, _local3);
if (_local4 != null){
return (_local4);
};
var _local5:uint = m_freePair;
_local4 = m_pairs[_local5];
m_freePair = _local4.next;
_local4.proxyId1 = _arg1;
_local4.proxyId2 = _arg2;
_local4.status = 0;
_local4.userData = null;
_local4.next = m_hashTable[_local3];
m_hashTable[_local3] = _local5;
m_pairCount++;
return (_local4);
}
private function ValidateTable():void{
}
public static function EqualsPair(_arg1:b2BufferedPair, _arg2:b2BufferedPair):Boolean{
return ((((_arg1.proxyId1 == _arg2.proxyId1)) && ((_arg1.proxyId2 == _arg2.proxyId2))));
}
public static function Hash(_arg1:uint, _arg2:uint):uint{
var _local3:uint = (((_arg2 << 16) & 4294901760) | _arg1);
_local3 = (~(_local3) + ((_local3 << 15) & 4294934528));
_local3 = (_local3 ^ ((_local3 >> 12) & 1048575));
_local3 = (_local3 + ((_local3 << 2) & 4294967292));
_local3 = (_local3 ^ ((_local3 >> 4) & 268435455));
_local3 = (_local3 * 2057);
_local3 = (_local3 ^ ((_local3 >> 16) & 0xFFFF));
return (_local3);
}
public static function Equals(_arg1:b2Pair, _arg2:uint, _arg3:uint):Boolean{
return ((((_arg1.proxyId1 == _arg2)) && ((_arg1.proxyId2 == _arg3))));
}
}
}//package Box2D.Collision
Section 25
//b2Point (Box2D.Collision.b2Point)
package Box2D.Collision {
import Box2D.Common.Math.*;
public class b2Point {
public var p:b2Vec2;
public function b2Point(){
p = new b2Vec2();
super();
}
public function GetFirstVertex(_arg1:b2XForm):b2Vec2{
return (p);
}
public function Support(_arg1:b2XForm, _arg2:Number, _arg3:Number):b2Vec2{
return (p);
}
}
}//package Box2D.Collision
Section 26
//b2Proxy (Box2D.Collision.b2Proxy)
package Box2D.Collision {
public class b2Proxy {
public var overlapCount:uint;
public var userData;// = null
public var lowerBounds:Array;
public var upperBounds:Array;
public var timeStamp:uint;
public function b2Proxy(){
lowerBounds = [uint(0), uint(0)];
upperBounds = [uint(0), uint(0)];
super();
}
public function GetNext():uint{
return (lowerBounds[0]);
}
public function IsValid():Boolean{
return (!((overlapCount == b2BroadPhase.b2_invalid)));
}
public function SetNext(_arg1:uint):void{
lowerBounds[0] = (_arg1 & 0xFFFF);
}
}
}//package Box2D.Collision
Section 27
//b2Segment (Box2D.Collision.b2Segment)
package Box2D.Collision {
import Box2D.Common.Math.*;
import Box2D.Common.*;
public class b2Segment {
public var p1:b2Vec2;
public var p2:b2Vec2;
public function b2Segment(){
p1 = new b2Vec2();
p2 = new b2Vec2();
super();
}
public function TestSegment(_arg1:Array, _arg2:b2Vec2, _arg3:b2Segment, _arg4:Number):Boolean{
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local5:b2Vec2 = _arg3.p1;
var _local6:Number = (_arg3.p2.x - _local5.x);
var _local7:Number = (_arg3.p2.y - _local5.y);
var _local8:Number = (p2.x - p1.x);
var _local9:Number = (p2.y - p1.y);
var _local10:Number = _local9;
var _local11:Number = -(_local8);
var _local12:Number = (100 * Number.MIN_VALUE);
var _local13:Number = -(((_local6 * _local10) + (_local7 * _local11)));
if (_local13 > _local12){
_local14 = (_local5.x - p1.x);
_local15 = (_local5.y - p1.y);
_local16 = ((_local14 * _local10) + (_local15 * _local11));
if ((((0 <= _local16)) && ((_local16 <= (_arg4 * _local13))))){
_local17 = ((-(_local7) * _local15) + (_local7 * _local14));
if (((((-(_local12) * _local13) <= _local17)) && ((_local17 <= (_local13 * (1 + _local12)))))){
_local16 = (_local16 / _local13);
_local18 = Math.sqrt(((_local10 * _local10) + (_local11 * _local11)));
_local10 = (_local10 / _local18);
_local11 = (_local11 / _local18);
_arg1[0] = _local16;
_arg2.Set(_local10, _local11);
return (true);
};
};
};
return (false);
}
}
}//package Box2D.Collision
Section 28
//b2TimeOfImpact (Box2D.Collision.b2TimeOfImpact)
package Box2D.Collision {
import Box2D.Collision.Shapes.*;
import Box2D.Common.Math.*;
import Box2D.Common.*;
public class b2TimeOfImpact {
public static var s_xf1:b2XForm = new b2XForm();
public static var s_xf2:b2XForm = new b2XForm();
public static var s_p1:b2Vec2 = new b2Vec2();
public static var s_p2:b2Vec2 = new b2Vec2();
public static function TimeOfImpact(_arg1:b2Shape, _arg2:b2Sweep, _arg3:b2Shape, _arg4:b2Sweep):Number{
var _local5:Number;
var _local6:Number;
var _local25:Number;
var _local26:b2XForm;
var _local27:b2XForm;
var _local28:Number;
var _local29:Number;
var _local30:Number;
var _local31:Number;
var _local7:Number = _arg1.m_sweepRadius;
var _local8:Number = _arg3.m_sweepRadius;
var _local9:Number = _arg2.t0;
var _local10:Number = (_arg2.c.x - _arg2.c0.x);
var _local11:Number = (_arg2.c.y - _arg2.c0.y);
var _local12:Number = (_arg4.c.x - _arg4.c0.x);
var _local13:Number = (_arg4.c.y - _arg4.c0.y);
var _local14:Number = (_arg2.a - _arg2.a0);
var _local15:Number = (_arg4.a - _arg4.a0);
var _local16:Number = 0;
var _local17:b2Vec2 = s_p1;
var _local18:b2Vec2 = s_p2;
var _local19 = 20;
var _local20:int;
var _local21:Number = 0;
var _local22:Number = 0;
var _local23:Number = 0;
var _local24:Number = 0;
while (true) {
_local25 = (((1 - _local16) * _local9) + _local16);
_local26 = s_xf1;
_local27 = s_xf2;
_arg2.GetXForm(_local26, _local25);
_arg4.GetXForm(_local27, _local25);
_local23 = b2Distance.Distance(_local17, _local18, _arg1, _local26, _arg3, _local27);
if (_local20 == 0){
if (_local23 > (2 * b2Settings.b2_toiSlop)){
_local24 = (1.5 * b2Settings.b2_toiSlop);
} else {
_local5 = (0.05 * b2Settings.b2_toiSlop);
_local6 = (_local23 - (0.5 * b2Settings.b2_toiSlop));
_local24 = ((_local5 > _local6)) ? _local5 : _local6;
};
};
if (((((_local23 - _local24) < (0.05 * b2Settings.b2_toiSlop))) || ((_local20 == _local19)))){
break;
};
_local21 = (_local18.x - _local17.x);
_local22 = (_local18.y - _local17.y);
_local28 = Math.sqrt(((_local21 * _local21) + (_local22 * _local22)));
_local21 = (_local21 / _local28);
_local22 = (_local22 / _local28);
_local29 = ((((_local21 * (_local10 - _local12)) + (_local22 * (_local11 - _local13))) + (((_local14 < 0)) ? -(_local14) : _local14 * _local7)) + (((_local15 < 0)) ? -(_local15) : _local15 * _local8));
if (_local29 == 0){
_local16 = 1;
break;
};
_local30 = ((_local23 - _local24) / _local29);
_local31 = (_local16 + _local30);
if ((((_local31 < 0)) || ((1 < _local31)))){
_local16 = 1;
break;
};
if (_local31 < ((1 + (100 * Number.MIN_VALUE)) * _local16)){
break;
};
_local16 = _local31;
_local20++;
};
return (_local16);
}
}
}//package Box2D.Collision
Section 29
//ClipVertex (Box2D.Collision.ClipVertex)
package Box2D.Collision {
import Box2D.Common.Math.*;
public class ClipVertex {
public var id:b2ContactID;
public var v:b2Vec2;
public function ClipVertex(){
v = new b2Vec2();
id = new b2ContactID();
super();
}
}
}//package Box2D.Collision
Section 30
//Features (Box2D.Collision.Features)
package Box2D.Collision {
public class Features {
public var _referenceEdge:int;
public var _incidentEdge:int;
public var _flip:int;
public var _incidentVertex:int;
public var _m_id:b2ContactID;
public function get referenceEdge():int{
return (_referenceEdge);
}
public function set incidentVertex(_arg1:int):void{
_incidentVertex = _arg1;
_m_id._key = ((_m_id._key & 4278255615) | ((_incidentVertex << 16) & 0xFF0000));
}
public function get flip():int{
return (_flip);
}
public function get incidentEdge():int{
return (_incidentEdge);
}
public function set referenceEdge(_arg1:int):void{
_referenceEdge = _arg1;
_m_id._key = ((_m_id._key & 4294967040) | (_referenceEdge & 0xFF));
}
public function get incidentVertex():int{
return (_incidentVertex);
}
public function set flip(_arg1:int):void{
_flip = _arg1;
_m_id._key = ((_m_id._key & 0xFFFFFF) | ((_flip << 24) & 4278190080));
}
public function set incidentEdge(_arg1:int):void{
_incidentEdge = _arg1;
_m_id._key = ((_m_id._key & 4294902015) | ((_incidentEdge << 8) & 0xFF00));
}
}
}//package Box2D.Collision
Section 31
//b2Mat22 (Box2D.Common.Math.b2Mat22)
package Box2D.Common.Math {
public class b2Mat22 {
public var col1:b2Vec2;
public var col2:b2Vec2;
public function b2Mat22(_arg1:Number=0, _arg2:b2Vec2=null, _arg3:b2Vec2=null){
var _local4:Number;
var _local5:Number;
col1 = new b2Vec2();
col2 = new b2Vec2();
super();
if (((!((_arg2 == null))) && (!((_arg3 == null))))){
col1.SetV(_arg2);
col2.SetV(_arg3);
} else {
_local4 = Math.cos(_arg1);
_local5 = Math.sin(_arg1);
col1.x = _local4;
col2.x = -(_local5);
col1.y = _local5;
col2.y = _local4;
};
}
public function SetIdentity():void{
col1.x = 1;
col2.x = 0;
col1.y = 0;
col2.y = 1;
}
public function SetVV(_arg1:b2Vec2, _arg2:b2Vec2):void{
col1.SetV(_arg1);
col2.SetV(_arg2);
}
public function Set(_arg1:Number):void{
var _local2:Number;
_local2 = Math.cos(_arg1);
var _local3:Number = Math.sin(_arg1);
col1.x = _local2;
col2.x = -(_local3);
col1.y = _local3;
col2.y = _local2;
}
public function SetZero():void{
col1.x = 0;
col2.x = 0;
col1.y = 0;
col2.y = 0;
}
public function SetM(_arg1:b2Mat22):void{
col1.SetV(_arg1.col1);
col2.SetV(_arg1.col2);
}
public function AddM(_arg1:b2Mat22):void{
col1.x = (col1.x + _arg1.col1.x);
col1.y = (col1.y + _arg1.col1.y);
col2.x = (col2.x + _arg1.col2.x);
col2.y = (col2.y + _arg1.col2.y);
}
public function Abs():void{
col1.Abs();
col2.Abs();
}
public function Copy():b2Mat22{
return (new b2Mat22(0, col1, col2));
}
public function Invert(_arg1:b2Mat22):b2Mat22{
var _local2:Number;
var _local4:Number;
var _local6:Number;
_local2 = col1.x;
var _local3:Number = col2.x;
_local4 = col1.y;
var _local5:Number = col2.y;
_local6 = ((_local2 * _local5) - (_local3 * _local4));
_local6 = (1 / _local6);
_arg1.col1.x = (_local6 * _local5);
_arg1.col2.x = (-(_local6) * _local3);
_arg1.col1.y = (-(_local6) * _local4);
_arg1.col2.y = (_local6 * _local2);
return (_arg1);
}
public function GetAngle():Number{
return (Math.atan2(col1.y, col1.x));
}
public function Solve(_arg1:b2Vec2, _arg2:Number, _arg3:Number):b2Vec2{
var _local4:Number = col1.x;
var _local5:Number = col2.x;
var _local6:Number = col1.y;
var _local7:Number = col2.y;
var _local8:Number = ((_local4 * _local7) - (_local5 * _local6));
_local8 = (1 / _local8);
_arg1.x = (_local8 * ((_local7 * _arg2) - (_local5 * _arg3)));
_arg1.y = (_local8 * ((_local4 * _arg3) - (_local6 * _arg2)));
return (_arg1);
}
}
}//package Box2D.Common.Math
Section 32
//b2Math (Box2D.Common.Math.b2Math)
package Box2D.Common.Math {
public class b2Math {
public static const b2Mat22_identity:b2Mat22 = new b2Mat22(0, new b2Vec2(1, 0), new b2Vec2(0, 1));
public static const b2XForm_identity:b2XForm = new b2XForm(b2Vec2_zero, b2Mat22_identity);
public static const b2Vec2_zero:b2Vec2 = new b2Vec2(0, 0);
public static function b2CrossVF(_arg1:b2Vec2, _arg2:Number):b2Vec2{
var _local3:b2Vec2 = new b2Vec2((_arg2 * _arg1.y), (-(_arg2) * _arg1.x));
return (_local3);
}
public static function AddVV(_arg1:b2Vec2, _arg2:b2Vec2):b2Vec2{
var _local3:b2Vec2 = new b2Vec2((_arg1.x + _arg2.x), (_arg1.y + _arg2.y));
return (_local3);
}
public static function b2IsValid(_arg1:Number):Boolean{
return (isFinite(_arg1));
}
public static function b2MinV(_arg1:b2Vec2, _arg2:b2Vec2):b2Vec2{
var _local3:b2Vec2 = new b2Vec2(b2Min(_arg1.x, _arg2.x), b2Min(_arg1.y, _arg2.y));
return (_local3);
}
public static function b2MulX(_arg1:b2XForm, _arg2:b2Vec2):b2Vec2{
var _local3:b2Vec2;
_local3 = b2MulMV(_arg1.R, _arg2);
_local3.x = (_local3.x + _arg1.position.x);
_local3.y = (_local3.y + _arg1.position.y);
return (_local3);
}
public static function b2DistanceSquared(_arg1:b2Vec2, _arg2:b2Vec2):Number{
var _local3:Number = (_arg1.x - _arg2.x);
var _local4:Number = (_arg1.y - _arg2.y);
return (((_local3 * _local3) + (_local4 * _local4)));
}
public static function b2Swap(_arg1:Array, _arg2:Array):void{
var _local3:* = _arg1[0];
_arg1[0] = _arg2[0];
_arg2[0] = _local3;
}
public static function b2AbsM(_arg1:b2Mat22):b2Mat22{
var _local2:b2Mat22 = new b2Mat22(0, b2AbsV(_arg1.col1), b2AbsV(_arg1.col2));
return (_local2);
}
public static function SubtractVV(_arg1:b2Vec2, _arg2:b2Vec2):b2Vec2{
var _local3:b2Vec2 = new b2Vec2((_arg1.x - _arg2.x), (_arg1.y - _arg2.y));
return (_local3);
}
public static function b2MulXT(_arg1:b2XForm, _arg2:b2Vec2):b2Vec2{
var _local3:b2Vec2;
var _local4:Number;
_local3 = SubtractVV(_arg2, _arg1.position);
_local4 = ((_local3.x * _arg1.R.col1.x) + (_local3.y * _arg1.R.col1.y));
_local3.y = ((_local3.x * _arg1.R.col2.x) + (_local3.y * _arg1.R.col2.y));
_local3.x = _local4;
return (_local3);
}
public static function b2Abs(_arg1:Number):Number{
return (((_arg1 > 0)) ? _arg1 : -(_arg1));
}
public static function b2Clamp(_arg1:Number, _arg2:Number, _arg3:Number):Number{
return (b2Max(_arg2, b2Min(_arg1, _arg3)));
}
public static function b2AbsV(_arg1:b2Vec2):b2Vec2{
var _local2:b2Vec2 = new b2Vec2(b2Abs(_arg1.x), b2Abs(_arg1.y));
return (_local2);
}
public static function MulFV(_arg1:Number, _arg2:b2Vec2):b2Vec2{
var _local3:b2Vec2 = new b2Vec2((_arg1 * _arg2.x), (_arg1 * _arg2.y));
return (_local3);
}
public static function b2CrossVV(_arg1:b2Vec2, _arg2:b2Vec2):Number{
return (((_arg1.x * _arg2.y) - (_arg1.y * _arg2.x)));
}
public static function b2Dot(_arg1:b2Vec2, _arg2:b2Vec2):Number{
return (((_arg1.x * _arg2.x) + (_arg1.y * _arg2.y)));
}
public static function b2CrossFV(_arg1:Number, _arg2:b2Vec2):b2Vec2{
var _local3:b2Vec2 = new b2Vec2((-(_arg1) * _arg2.y), (_arg1 * _arg2.x));
return (_local3);
}
public static function AddMM(_arg1:b2Mat22, _arg2:b2Mat22):b2Mat22{
var _local3:b2Mat22 = new b2Mat22(0, AddVV(_arg1.col1, _arg2.col1), AddVV(_arg1.col2, _arg2.col2));
return (_local3);
}
public static function b2Distance(_arg1:b2Vec2, _arg2:b2Vec2):Number{
var _local3:Number = (_arg1.x - _arg2.x);
var _local4:Number = (_arg1.y - _arg2.y);
return (Math.sqrt(((_local3 * _local3) + (_local4 * _local4))));
}
public static function b2MulTMM(_arg1:b2Mat22, _arg2:b2Mat22):b2Mat22{
var _local3:b2Vec2 = new b2Vec2(b2Dot(_arg1.col1, _arg2.col1), b2Dot(_arg1.col2, _arg2.col1));
var _local4:b2Vec2 = new b2Vec2(b2Dot(_arg1.col1, _arg2.col2), b2Dot(_arg1.col2, _arg2.col2));
var _local5:b2Mat22 = new b2Mat22(0, _local3, _local4);
return (_local5);
}
public static function b2MaxV(_arg1:b2Vec2, _arg2:b2Vec2):b2Vec2{
var _local3:b2Vec2 = new b2Vec2(b2Max(_arg1.x, _arg2.x), b2Max(_arg1.y, _arg2.y));
return (_local3);
}
public static function b2IsPowerOfTwo(_arg1:uint):Boolean{
var _local2:Boolean = (((_arg1 > 0)) && (((_arg1 & (_arg1 - 1)) == 0)));
return (_local2);
}
public static function b2ClampV(_arg1:b2Vec2, _arg2:b2Vec2, _arg3:b2Vec2):b2Vec2{
return (b2MaxV(_arg2, b2MinV(_arg1, _arg3)));
}
public static function b2RandomRange(_arg1:Number, _arg2:Number):Number{
var _local3:Number = Math.random();
_local3 = (((_arg2 - _arg1) * _local3) + _arg1);
return (_local3);
}
public static function b2MulTMV(_arg1:b2Mat22, _arg2:b2Vec2):b2Vec2{
var _local3:b2Vec2 = new b2Vec2(b2Dot(_arg2, _arg1.col1), b2Dot(_arg2, _arg1.col2));
return (_local3);
}
public static function b2Min(_arg1:Number, _arg2:Number):Number{
return (((_arg1 < _arg2)) ? _arg1 : _arg2);
}
public static function b2Random():Number{
return (((Math.random() * 2) - 1));
}
public static function b2MulMM(_arg1:b2Mat22, _arg2:b2Mat22):b2Mat22{
var _local3:b2Mat22 = new b2Mat22(0, b2MulMV(_arg1, _arg2.col1), b2MulMV(_arg1, _arg2.col2));
return (_local3);
}
public static function b2NextPowerOfTwo(_arg1:uint):uint{
_arg1 = (_arg1 | ((_arg1 >> 1) & 2147483647));
_arg1 = (_arg1 | ((_arg1 >> 2) & 1073741823));
_arg1 = (_arg1 | ((_arg1 >> 4) & 268435455));
_arg1 = (_arg1 | ((_arg1 >> 8) & 0xFFFFFF));
_arg1 = (_arg1 | ((_arg1 >> 16) & 0xFFFF));
return ((_arg1 + 1));
}
public static function b2Max(_arg1:Number, _arg2:Number):Number{
return (((_arg1 > _arg2)) ? _arg1 : _arg2);
}
public static function b2MulMV(_arg1:b2Mat22, _arg2:b2Vec2):b2Vec2{
var _local3:b2Vec2 = new b2Vec2(((_arg1.col1.x * _arg2.x) + (_arg1.col2.x * _arg2.y)), ((_arg1.col1.y * _arg2.x) + (_arg1.col2.y * _arg2.y)));
return (_local3);
}
}
}//package Box2D.Common.Math
Section 33
//b2Sweep (Box2D.Common.Math.b2Sweep)
package Box2D.Common.Math {
public class b2Sweep {
public var localCenter:b2Vec2;
public var a:Number;
public var c:b2Vec2;
public var a0:Number;
public var c0:b2Vec2;
public var t0:Number;
public function b2Sweep(){
localCenter = new b2Vec2();
c0 = new b2Vec2();
c = new b2Vec2();
super();
}
public function Advance(_arg1:Number):void{
var _local2:Number;
if ((((t0 < _arg1)) && (((1 - t0) > Number.MIN_VALUE)))){
_local2 = ((_arg1 - t0) / (1 - t0));
c0.x = (((1 - _local2) * c0.x) + (_local2 * c.x));
c0.y = (((1 - _local2) * c0.y) + (_local2 * c.y));
a0 = (((1 - _local2) * a0) + (_local2 * a));
t0 = _arg1;
};
}
public function GetXForm(_arg1:b2XForm, _arg2:Number):void{
var _local4:Number;
var _local5:Number;
if ((1 - t0) > Number.MIN_VALUE){
_local4 = ((_arg2 - t0) / (1 - t0));
_arg1.position.x = (((1 - _local4) * c0.x) + (_local4 * c.x));
_arg1.position.y = (((1 - _local4) * c0.y) + (_local4 * c.y));
_local5 = (((1 - _local4) * a0) + (_local4 * a));
_arg1.R.Set(_local5);
} else {
_arg1.position.SetV(c);
_arg1.R.Set(a);
};
var _local3:b2Mat22 = _arg1.R;
_arg1.position.x = (_arg1.position.x - ((_local3.col1.x * localCenter.x) + (_local3.col2.x * localCenter.y)));
_arg1.position.y = (_arg1.position.y - ((_local3.col1.y * localCenter.x) + (_local3.col2.y * localCenter.y)));
}
}
}//package Box2D.Common.Math
Section 34
//b2Vec2 (Box2D.Common.Math.b2Vec2)
package Box2D.Common.Math {
public class b2Vec2 {
public var y:Number;
public var x:Number;
public function b2Vec2(_arg1:Number=0, _arg2:Number=0):void{
x = _arg1;
y = _arg2;
}
public function Add(_arg1:b2Vec2):void{
x = (x + _arg1.x);
y = (y + _arg1.y);
}
public function Set(_arg1:Number=0, _arg2:Number=0):void{
x = _arg1;
y = _arg2;
}
public function Multiply(_arg1:Number):void{
x = (x * _arg1);
y = (y * _arg1);
}
public function Length():Number{
return (Math.sqrt(((x * x) + (y * y))));
}
public function LengthSquared():Number{
return (((x * x) + (y * y)));
}
public function MulM(_arg1:b2Mat22):void{
var _local2:Number = x;
x = ((_arg1.col1.x * _local2) + (_arg1.col2.x * y));
y = ((_arg1.col1.y * _local2) + (_arg1.col2.y * y));
}
public function SetZero():void{
x = 0;
y = 0;
}
public function MinV(_arg1:b2Vec2):void{
x = ((x < _arg1.x)) ? x : _arg1.x;
y = ((y < _arg1.y)) ? y : _arg1.y;
}
public function Normalize():Number{
var _local1:Number = Math.sqrt(((x * x) + (y * y)));
if (_local1 < Number.MIN_VALUE){
return (0);
};
var _local2:Number = (1 / _local1);
x = (x * _local2);
y = (y * _local2);
return (_local1);
}
public function CrossVF(_arg1:Number):void{
var _local2:Number = x;
x = (_arg1 * y);
y = (-(_arg1) * _local2);
}
public function MaxV(_arg1:b2Vec2):void{
x = ((x > _arg1.x)) ? x : _arg1.x;
y = ((y > _arg1.y)) ? y : _arg1.y;
}
public function SetV(_arg1:b2Vec2):void{
x = _arg1.x;
y = _arg1.y;
}
public function Negative():b2Vec2{
return (new b2Vec2(-(x), -(y)));
}
public function CrossFV(_arg1:Number):void{
var _local2:Number = x;
x = (-(_arg1) * y);
y = (_arg1 * _local2);
}
public function Abs():void{
if (x < 0){
x = -(x);
};
if (y < 0){
y = -(y);
};
}
public function Subtract(_arg1:b2Vec2):void{
x = (x - _arg1.x);
y = (y - _arg1.y);
}
public function Copy():b2Vec2{
return (new b2Vec2(x, y));
}
public function MulTM(_arg1:b2Mat22):void{
var _local2:Number = b2Math.b2Dot(this, _arg1.col1);
y = b2Math.b2Dot(this, _arg1.col2);
x = _local2;
}
public function IsValid():Boolean{
return (((b2Math.b2IsValid(x)) && (b2Math.b2IsValid(y))));
}
public static function Make(_arg1:Number, _arg2:Number):b2Vec2{
return (new b2Vec2(_arg1, _arg2));
}
}
}//package Box2D.Common.Math
Section 35
//b2XForm (Box2D.Common.Math.b2XForm)
package Box2D.Common.Math {
public class b2XForm {
public var position:b2Vec2;
public var R:b2Mat22;
public function b2XForm(_arg1:b2Vec2=null, _arg2:b2Mat22=null):void{
position = new b2Vec2();
R = new b2Mat22();
super();
if (_arg1){
position.SetV(_arg1);
R.SetM(_arg2);
};
}
public function Initialize(_arg1:b2Vec2, _arg2:b2Mat22):void{
position.SetV(_arg1);
R.SetM(_arg2);
}
public function Set(_arg1:b2XForm):void{
position.SetV(_arg1.position);
R.SetM(_arg1.R);
}
public function SetIdentity():void{
position.SetZero();
R.SetIdentity();
}
}
}//package Box2D.Common.Math
Section 36
//b2Color (Box2D.Common.b2Color)
package Box2D.Common {
import Box2D.Common.Math.*;
public class b2Color {
private var _r:uint;// = 0
private var _g:uint;// = 0
private var _b:uint;// = 0
public function b2Color(_arg1:Number, _arg2:Number, _arg3:Number){
_r = uint((0xFF * b2Math.b2Clamp(_arg1, 0, 1)));
_g = uint((0xFF * b2Math.b2Clamp(_arg2, 0, 1)));
_b = uint((0xFF * b2Math.b2Clamp(_arg3, 0, 1)));
}
public function Set(_arg1:Number, _arg2:Number, _arg3:Number):void{
_r = uint((0xFF * b2Math.b2Clamp(_arg1, 0, 1)));
_g = uint((0xFF * b2Math.b2Clamp(_arg2, 0, 1)));
_b = uint((0xFF * b2Math.b2Clamp(_arg3, 0, 1)));
}
public function set b(_arg1:Number):void{
_b = uint((0xFF * b2Math.b2Clamp(_arg1, 0, 1)));
}
public function get color():uint{
return (((_r | (_g << 8)) | (_b << 16)));
}
public function set r(_arg1:Number):void{
_r = uint((0xFF * b2Math.b2Clamp(_arg1, 0, 1)));
}
public function set g(_arg1:Number):void{
_g = uint((0xFF * b2Math.b2Clamp(_arg1, 0, 1)));
}
}
}//package Box2D.Common
Section 37
//b2Settings (Box2D.Common.b2Settings)
package Box2D.Common {
import Box2D.Common.Math.*;
public class b2Settings {
public static const b2_angularSleepTolerance:Number = 0.0111111111111111;
public static const b2_linearSleepTolerance:Number = 0.01;
public static const b2_angularSlop:Number = ((2 / 180) * b2_pi);
public static const b2_linearSlop:Number = 0.005;
public static const b2_pi:Number = Math.PI;
public static const b2_maxProxies:int = 0x0200;
public static const b2_maxAngularVelocitySquared:Number = 62500;
public static const b2_maxPolygonVertices:int = 8;
public static const b2_velocityThreshold:Number = 1;
public static const b2_contactBaumgarte:Number = 0.2;
public static const b2_maxPairs:int = 4096;
public static const b2_maxTOIContactsPerIsland:int = 32;
public static const b2_timeToSleep:Number = 0.5;
public static const b2_maxManifoldPoints:int = 2;
public static const b2_maxAngularVelocity:Number = 250;
public static const b2_maxAngularCorrection:Number = ((8 / 180) * b2_pi);
public static const USHRT_MAX:int = 0xFFFF;
public static const b2_maxLinearVelocity:Number = 200;
public static const b2_maxLinearCorrection:Number = 0.2;
public static const b2_toiSlop:Number = 0.04;
public static const b2_maxLinearVelocitySquared:Number = 40000;
public static function b2Assert(_arg1:Boolean):void{
var _local2:b2Vec2;
if (!_arg1){
_local2.x++;
};
}
}
}//package Box2D.Common
Section 38
//b2CircleContact (Box2D.Dynamics.Contacts.b2CircleContact)
package Box2D.Dynamics.Contacts {
import Box2D.Collision.Shapes.*;
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Collision.*;
import Box2D.Common.*;
public class b2CircleContact extends b2Contact {
private var m_manifolds:Array;
public var m_manifold:b2Manifold;
private var m0:b2Manifold;
private static const s_evalCP:b2ContactPoint = new b2ContactPoint();
public function b2CircleContact(_arg1:b2Shape, _arg2:b2Shape){
m_manifolds = [new b2Manifold()];
m0 = new b2Manifold();
super(_arg1, _arg2);
m_manifold = m_manifolds[0];
m_manifold.pointCount = 0;
var _local3:b2ManifoldPoint = m_manifold.points[0];
_local3.normalImpulse = 0;
_local3.tangentImpulse = 0;
}
override public function Evaluate(_arg1:b2ContactListener):void{
var _local2:b2Vec2;
var _local3:b2Vec2;
var _local4:b2ManifoldPoint;
var _local8:b2ManifoldPoint;
var _local5:b2Body = m_shape1.m_body;
var _local6:b2Body = m_shape2.m_body;
m0.Set(m_manifold);
b2Collision.b2CollideCircles(m_manifold, (m_shape1 as b2CircleShape), _local5.m_xf, (m_shape2 as b2CircleShape), _local6.m_xf);
var _local7:b2ContactPoint = s_evalCP;
_local7.shape1 = m_shape1;
_local7.shape2 = m_shape2;
_local7.friction = m_friction;
_local7.restitution = m_restitution;
if (m_manifold.pointCount > 0){
m_manifoldCount = 1;
_local8 = m_manifold.points[0];
if (m0.pointCount == 0){
_local8.normalImpulse = 0;
_local8.tangentImpulse = 0;
if (_arg1){
_local7.position = _local5.GetWorldPoint(_local8.localPoint1);
_local2 = _local5.GetLinearVelocityFromLocalPoint(_local8.localPoint1);
_local3 = _local6.GetLinearVelocityFromLocalPoint(_local8.localPoint2);
_local7.velocity.Set((_local3.x - _local2.x), (_local3.y - _local2.y));
_local7.normal.SetV(m_manifold.normal);
_local7.separation = _local8.separation;
_local7.id.key = _local8.id._key;
_arg1.Add(_local7);
};
} else {
_local4 = m0.points[0];
_local8.normalImpulse = _local4.normalImpulse;
_local8.tangentImpulse = _local4.tangentImpulse;
if (_arg1){
_local7.position = _local5.GetWorldPoint(_local8.localPoint1);
_local2 = _local5.GetLinearVelocityFromLocalPoint(_local8.localPoint1);
_local3 = _local6.GetLinearVelocityFromLocalPoint(_local8.localPoint2);
_local7.velocity.Set((_local3.x - _local2.x), (_local3.y - _local2.y));
_local7.normal.SetV(m_manifold.normal);
_local7.separation = _local8.separation;
_local7.id.key = _local8.id._key;
_arg1.Persist(_local7);
};
};
} else {
m_manifoldCount = 0;
if ((((m0.pointCount > 0)) && (_arg1))){
_local4 = m0.points[0];
_local7.position = _local5.GetWorldPoint(_local4.localPoint1);
_local2 = _local5.GetLinearVelocityFromLocalPoint(_local4.localPoint1);
_local3 = _local6.GetLinearVelocityFromLocalPoint(_local4.localPoint2);
_local7.velocity.Set((_local3.x - _local2.x), (_local3.y - _local2.y));
_local7.normal.SetV(m0.normal);
_local7.separation = _local4.separation;
_local7.id.key = _local4.id._key;
_arg1.Remove(_local7);
};
};
}
override public function GetManifolds():Array{
return (m_manifolds);
}
public static function Destroy(_arg1:b2Contact, _arg2):void{
}
public static function Create(_arg1:b2Shape, _arg2:b2Shape, _arg3):b2Contact{
return (new b2CircleContact(_arg1, _arg2));
}
}
}//package Box2D.Dynamics.Contacts
Section 39
//b2Contact (Box2D.Dynamics.Contacts.b2Contact)
package Box2D.Dynamics.Contacts {
import Box2D.Collision.Shapes.*;
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Collision.*;
import Box2D.Common.*;
public class b2Contact {
public var m_shape1:b2Shape;
public var m_shape2:b2Shape;
public var m_prev:b2Contact;
public var m_toi:Number;
public var m_next:b2Contact;
public var m_friction:Number;
public var m_manifoldCount:int;
public var m_node1:b2ContactEdge;
public var m_node2:b2ContactEdge;
public var m_restitution:Number;
public var m_flags:uint;
public static var e_toiFlag:uint = 8;
public static var e_nonSolidFlag:uint = 1;
public static var e_slowFlag:uint = 2;
public static var e_islandFlag:uint = 4;
public static var s_registers:Array;
public static var s_initialized:Boolean = false;
public function b2Contact(_arg1:b2Shape=null, _arg2:b2Shape=null){
m_node1 = new b2ContactEdge();
m_node2 = new b2ContactEdge();
super();
m_flags = 0;
if (((!(_arg1)) || (!(_arg2)))){
m_shape1 = null;
m_shape2 = null;
return;
};
if (((_arg1.IsSensor()) || (_arg2.IsSensor()))){
m_flags = (m_flags | e_nonSolidFlag);
};
m_shape1 = _arg1;
m_shape2 = _arg2;
m_manifoldCount = 0;
m_friction = Math.sqrt((m_shape1.m_friction * m_shape2.m_friction));
m_restitution = b2Math.b2Max(m_shape1.m_restitution, m_shape2.m_restitution);
m_prev = null;
m_next = null;
m_node1.contact = null;
m_node1.prev = null;
m_node1.next = null;
m_node1.other = null;
m_node2.contact = null;
m_node2.prev = null;
m_node2.next = null;
m_node2.other = null;
}
public function IsSolid():Boolean{
return (((m_flags & e_nonSolidFlag) == 0));
}
public function GetShape1():b2Shape{
return (m_shape1);
}
public function GetShape2():b2Shape{
return (m_shape2);
}
public function GetNext():b2Contact{
return (m_next);
}
public function GetManifoldCount():int{
return (m_manifoldCount);
}
public function GetManifolds():Array{
return (null);
}
public function Update(_arg1:b2ContactListener):void{
var _local2:int = m_manifoldCount;
Evaluate(_arg1);
var _local3:int = m_manifoldCount;
var _local4:b2Body = m_shape1.m_body;
var _local5:b2Body = m_shape2.m_body;
if ((((_local3 == 0)) && ((_local2 > 0)))){
_local4.WakeUp();
_local5.WakeUp();
};
if (((((((_local4.IsStatic()) || (_local4.IsBullet()))) || (_local5.IsStatic()))) || (_local5.IsBullet()))){
m_flags = (m_flags & ~(e_slowFlag));
} else {
m_flags = (m_flags | e_slowFlag);
};
}
public function Evaluate(_arg1:b2ContactListener):void{
}
public static function InitializeRegisters():void{
var _local2:int;
s_registers = new Array(b2Shape.e_shapeTypeCount);
var _local1:int;
while (_local1 < b2Shape.e_shapeTypeCount) {
s_registers[_local1] = new Array(b2Shape.e_shapeTypeCount);
_local2 = 0;
while (_local2 < b2Shape.e_shapeTypeCount) {
s_registers[_local1][_local2] = new b2ContactRegister();
_local2++;
};
_local1++;
};
AddType(b2CircleContact.Create, b2CircleContact.Destroy, b2Shape.e_circleShape, b2Shape.e_circleShape);
AddType(b2PolyAndCircleContact.Create, b2PolyAndCircleContact.Destroy, b2Shape.e_polygonShape, b2Shape.e_circleShape);
AddType(b2PolygonContact.Create, b2PolygonContact.Destroy, b2Shape.e_polygonShape, b2Shape.e_polygonShape);
}
public static function Destroy(_arg1:b2Contact, _arg2):void{
if (_arg1.m_manifoldCount > 0){
_arg1.m_shape1.m_body.WakeUp();
_arg1.m_shape2.m_body.WakeUp();
};
var _local3:int = _arg1.m_shape1.m_type;
var _local4:int = _arg1.m_shape2.m_type;
var _local5:b2ContactRegister = s_registers[_local3][_local4];
var _local6:Function = _local5.destroyFcn;
_local6(_arg1, _arg2);
}
public static function AddType(_arg1:Function, _arg2:Function, _arg3:int, _arg4:int):void{
s_registers[_arg3][_arg4].createFcn = _arg1;
s_registers[_arg3][_arg4].destroyFcn = _arg2;
s_registers[_arg3][_arg4].primary = true;
if (_arg3 != _arg4){
s_registers[_arg4][_arg3].createFcn = _arg1;
s_registers[_arg4][_arg3].destroyFcn = _arg2;
s_registers[_arg4][_arg3].primary = false;
};
}
public static function Create(_arg1:b2Shape, _arg2:b2Shape, _arg3):b2Contact{
var _local8:b2Contact;
var _local9:int;
var _local10:b2Manifold;
if (s_initialized == false){
InitializeRegisters();
s_initialized = true;
};
var _local4:int = _arg1.m_type;
var _local5:int = _arg2.m_type;
var _local6:b2ContactRegister = s_registers[_local4][_local5];
var _local7:Function = _local6.createFcn;
if (_local7 != null){
if (_local6.primary){
return (_local7(_arg1, _arg2, _arg3));
};
_local8 = _local7(_arg2, _arg1, _arg3);
_local9 = 0;
while (_local9 < _local8.m_manifoldCount) {
_local10 = _local8.GetManifolds()[_local9];
_local8.GetManifolds()[_local9].normal = _local10.normal.Negative();
_local9++;
};
return (_local8);
//unresolved jump
};
return (null);
}
}
}//package Box2D.Dynamics.Contacts
Section 40
//b2ContactConstraint (Box2D.Dynamics.Contacts.b2ContactConstraint)
package Box2D.Dynamics.Contacts {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Collision.*;
import Box2D.Common.*;
public class b2ContactConstraint {
public var points:Array;
public var normal:b2Vec2;
public var restitution:Number;
public var body1:b2Body;
public var manifold:b2Manifold;
public var body2:b2Body;
public var friction:Number;
public var pointCount:int;
public function b2ContactConstraint(){
normal = new b2Vec2();
super();
points = new Array(b2Settings.b2_maxManifoldPoints);
var _local1:int;
while (_local1 < b2Settings.b2_maxManifoldPoints) {
points[_local1] = new b2ContactConstraintPoint();
_local1++;
};
}
}
}//package Box2D.Dynamics.Contacts
Section 41
//b2ContactConstraintPoint (Box2D.Dynamics.Contacts.b2ContactConstraintPoint)
package Box2D.Dynamics.Contacts {
import Box2D.Common.Math.*;
public class b2ContactConstraintPoint {
public var r2:b2Vec2;
public var separation:Number;
public var positionImpulse:Number;
public var normalImpulse:Number;
public var tangentMass:Number;
public var equalizedMass:Number;
public var tangentImpulse:Number;
public var localAnchor1:b2Vec2;
public var localAnchor2:b2Vec2;
public var normalMass:Number;
public var velocityBias:Number;
public var r1:b2Vec2;
public function b2ContactConstraintPoint(){
localAnchor1 = new b2Vec2();
localAnchor2 = new b2Vec2();
r1 = new b2Vec2();
r2 = new b2Vec2();
super();
}
}
}//package Box2D.Dynamics.Contacts
Section 42
//b2ContactEdge (Box2D.Dynamics.Contacts.b2ContactEdge)
package Box2D.Dynamics.Contacts {
import Box2D.Dynamics.*;
public class b2ContactEdge {
public var other:b2Body;
public var prev:b2ContactEdge;
public var contact:b2Contact;
public var next:b2ContactEdge;
}
}//package Box2D.Dynamics.Contacts
Section 43
//b2ContactRegister (Box2D.Dynamics.Contacts.b2ContactRegister)
package Box2D.Dynamics.Contacts {
public class b2ContactRegister {
public var primary:Boolean;
public var createFcn:Function;
public var destroyFcn:Function;
}
}//package Box2D.Dynamics.Contacts
Section 44
//b2ContactResult (Box2D.Dynamics.Contacts.b2ContactResult)
package Box2D.Dynamics.Contacts {
import Box2D.Collision.Shapes.*;
import Box2D.Common.Math.*;
import Box2D.Collision.*;
public class b2ContactResult {
public var position:b2Vec2;
public var shape1:b2Shape;
public var shape2:b2Shape;
public var normalImpulse:Number;
public var normal:b2Vec2;
public var tangentImpulse:Number;
public var id:b2ContactID;
public function b2ContactResult(){
position = new b2Vec2();
normal = new b2Vec2();
id = new b2ContactID();
super();
}
}
}//package Box2D.Dynamics.Contacts
Section 45
//b2ContactSolver (Box2D.Dynamics.Contacts.b2ContactSolver)
package Box2D.Dynamics.Contacts {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Collision.*;
import Box2D.Common.*;
public class b2ContactSolver {
public var m_constraintCount:int;
public var m_constraints:Array;
public var m_allocator;
public var m_step:b2TimeStep;
public function b2ContactSolver(_arg1:b2TimeStep, _arg2:Array, _arg3:int, _arg4){
var _local5:b2Contact;
var _local6:int;
var _local7:b2Vec2;
var _local8:b2Mat22;
var _local10:b2Body;
var _local11:b2Body;
var _local12:int;
var _local13:Array;
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:int;
var _local23:b2Manifold;
var _local24:Number;
var _local25:Number;
var _local26:b2ContactConstraint;
var _local27:uint;
var _local28:b2ManifoldPoint;
var _local29:b2ContactConstraintPoint;
var _local30:Number;
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:Number;
var _local40:Number;
var _local41:Number;
var _local42:Number;
var _local43:Number;
var _local44:Number;
var _local45:Number;
var _local46:Number;
var _local47:Number;
m_step = new b2TimeStep();
m_constraints = new Array();
super();
m_step.dt = _arg1.dt;
m_step.inv_dt = _arg1.inv_dt;
m_step.maxIterations = _arg1.maxIterations;
m_allocator = _arg4;
m_constraintCount = 0;
_local6 = 0;
while (_local6 < _arg3) {
_local5 = _arg2[_local6];
m_constraintCount = (m_constraintCount + _local5.m_manifoldCount);
_local6++;
};
_local6 = 0;
while (_local6 < m_constraintCount) {
m_constraints[_local6] = new b2ContactConstraint();
_local6++;
};
var _local9:int;
_local6 = 0;
while (_local6 < _arg3) {
_local5 = _arg2[_local6];
_local10 = _local5.m_shape1.m_body;
_local11 = _local5.m_shape2.m_body;
_local12 = _local5.m_manifoldCount;
_local13 = _local5.GetManifolds();
_local14 = _local5.m_friction;
_local15 = _local5.m_restitution;
_local16 = _local10.m_linearVelocity.x;
_local17 = _local10.m_linearVelocity.y;
_local18 = _local11.m_linearVelocity.x;
_local19 = _local11.m_linearVelocity.y;
_local20 = _local10.m_angularVelocity;
_local21 = _local11.m_angularVelocity;
_local22 = 0;
while (_local22 < _local12) {
_local23 = _local13[_local22];
_local24 = _local23.normal.x;
_local25 = _local23.normal.y;
_local26 = m_constraints[_local9];
_local26.body1 = _local10;
_local26.body2 = _local11;
_local26.manifold = _local23;
_local26.normal.x = _local24;
_local26.normal.y = _local25;
_local26.pointCount = _local23.pointCount;
_local26.friction = _local14;
_local26.restitution = _local15;
_local27 = 0;
while (_local27 < _local26.pointCount) {
_local28 = _local23.points[_local27];
_local29 = _local26.points[_local27];
_local29.normalImpulse = _local28.normalImpulse;
_local29.tangentImpulse = _local28.tangentImpulse;
_local29.separation = _local28.separation;
_local29.positionImpulse = 0;
_local29.localAnchor1.SetV(_local28.localPoint1);
_local29.localAnchor2.SetV(_local28.localPoint2);
_local8 = _local10.m_xf.R;
_local32 = (_local28.localPoint1.x - _local10.m_sweep.localCenter.x);
_local33 = (_local28.localPoint1.y - _local10.m_sweep.localCenter.y);
_local30 = ((_local8.col1.x * _local32) + (_local8.col2.x * _local33));
_local33 = ((_local8.col1.y * _local32) + (_local8.col2.y * _local33));
_local32 = _local30;
_local29.r1.Set(_local32, _local33);
_local8 = _local11.m_xf.R;
_local34 = (_local28.localPoint2.x - _local11.m_sweep.localCenter.x);
_local35 = (_local28.localPoint2.y - _local11.m_sweep.localCenter.y);
_local30 = ((_local8.col1.x * _local34) + (_local8.col2.x * _local35));
_local35 = ((_local8.col1.y * _local34) + (_local8.col2.y * _local35));
_local34 = _local30;
_local29.r2.Set(_local34, _local35);
_local36 = ((_local32 * _local32) + (_local33 * _local33));
_local37 = ((_local34 * _local34) + (_local35 * _local35));
_local38 = ((_local32 * _local24) + (_local33 * _local25));
_local39 = ((_local34 * _local24) + (_local35 * _local25));
_local40 = (_local10.m_invMass + _local11.m_invMass);
_local40 = (_local40 + ((_local10.m_invI * (_local36 - (_local38 * _local38))) + (_local11.m_invI * (_local37 - (_local39 * _local39)))));
_local29.normalMass = (1 / _local40);
_local41 = ((_local10.m_mass * _local10.m_invMass) + (_local11.m_mass * _local11.m_invMass));
_local41 = (_local41 + (((_local10.m_mass * _local10.m_invI) * (_local36 - (_local38 * _local38))) + ((_local11.m_mass * _local11.m_invI) * (_local37 - (_local39 * _local39)))));
_local29.equalizedMass = (1 / _local41);
_local42 = _local25;
_local43 = -(_local24);
_local44 = ((_local32 * _local42) + (_local33 * _local43));
_local45 = ((_local34 * _local42) + (_local35 * _local43));
_local46 = (_local10.m_invMass + _local11.m_invMass);
_local46 = (_local46 + ((_local10.m_invI * (_local36 - (_local44 * _local44))) + (_local11.m_invI * (_local37 - (_local45 * _local45)))));
_local29.tangentMass = (1 / _local46);
_local29.velocityBias = 0;
if (_local29.separation > 0){
_local29.velocityBias = (-60 * _local29.separation);
};
_local30 = (((_local18 + (-(_local21) * _local35)) - _local16) - (-(_local20) * _local33));
_local31 = (((_local19 + (_local21 * _local34)) - _local17) - (_local20 * _local32));
_local47 = ((_local26.normal.x * _local30) + (_local26.normal.y * _local31));
if (_local47 < -(b2Settings.b2_velocityThreshold)){
_local29.velocityBias = (_local29.velocityBias + (-(_local26.restitution) * _local47));
};
_local27++;
};
_local9++;
_local22++;
};
_local6++;
};
}
public function InitVelocityConstraints(_arg1:b2TimeStep):void{
var _local2:b2Vec2;
var _local3:b2Vec2;
var _local4:b2Mat22;
var _local6:b2ContactConstraint;
var _local7:b2Body;
var _local8:b2Body;
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:int;
var _local19:int;
var _local20:b2ContactConstraintPoint;
var _local21:Number;
var _local22:Number;
var _local23:b2ContactConstraintPoint;
var _local5:int;
while (_local5 < m_constraintCount) {
_local6 = m_constraints[_local5];
_local7 = _local6.body1;
_local8 = _local6.body2;
_local9 = _local7.m_invMass;
_local10 = _local7.m_invI;
_local11 = _local8.m_invMass;
_local12 = _local8.m_invI;
_local13 = _local6.normal.x;
_local14 = _local6.normal.y;
_local15 = _local14;
_local16 = -(_local13);
if (_arg1.warmStarting){
_local19 = _local6.pointCount;
_local18 = 0;
while (_local18 < _local19) {
_local20 = _local6.points[_local18];
_local6.points[_local18].normalImpulse = (_local20.normalImpulse * _arg1.dtRatio);
_local20.tangentImpulse = (_local20.tangentImpulse * _arg1.dtRatio);
_local21 = ((_local20.normalImpulse * _local13) + (_local20.tangentImpulse * _local15));
_local22 = ((_local20.normalImpulse * _local14) + (_local20.tangentImpulse * _local16));
_local7.m_angularVelocity = (_local7.m_angularVelocity - (_local10 * ((_local20.r1.x * _local22) - (_local20.r1.y * _local21))));
_local7.m_linearVelocity.x = (_local7.m_linearVelocity.x - (_local9 * _local21));
_local7.m_linearVelocity.y = (_local7.m_linearVelocity.y - (_local9 * _local22));
_local8.m_angularVelocity = (_local8.m_angularVelocity + (_local12 * ((_local20.r2.x * _local22) - (_local20.r2.y * _local21))));
_local8.m_linearVelocity.x = (_local8.m_linearVelocity.x + (_local11 * _local21));
_local8.m_linearVelocity.y = (_local8.m_linearVelocity.y + (_local11 * _local22));
_local18++;
};
} else {
_local19 = _local6.pointCount;
_local18 = 0;
while (_local18 < _local19) {
_local23 = _local6.points[_local18];
_local23.normalImpulse = 0;
_local23.tangentImpulse = 0;
_local18++;
};
};
_local5++;
};
}
public function SolvePositionConstraints(_arg1:Number):Boolean{
var _local3:b2Mat22;
var _local4:b2Vec2;
var _local6:b2ContactConstraint;
var _local7:b2Body;
var _local8:b2Body;
var _local9:b2Vec2;
var _local10:Number;
var _local11:b2Vec2;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:int;
var _local20:int;
var _local21:b2ContactConstraintPoint;
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;
var _local35:Number;
var _local36:Number;
var _local37:Number;
var _local38:Number;
var _local2:Number = 0;
var _local5:int;
while (_local5 < m_constraintCount) {
_local6 = m_constraints[_local5];
_local7 = _local6.body1;
_local8 = _local6.body2;
_local9 = _local7.m_sweep.c;
_local10 = _local7.m_sweep.a;
_local11 = _local8.m_sweep.c;
_local12 = _local8.m_sweep.a;
_local13 = (_local7.m_mass * _local7.m_invMass);
_local14 = (_local7.m_mass * _local7.m_invI);
_local15 = (_local8.m_mass * _local8.m_invMass);
_local16 = (_local8.m_mass * _local8.m_invI);
_local17 = _local6.normal.x;
_local18 = _local6.normal.y;
_local19 = _local6.pointCount;
_local20 = 0;
while (_local20 < _local19) {
_local21 = _local6.points[_local20];
_local3 = _local7.m_xf.R;
_local4 = _local7.m_sweep.localCenter;
_local22 = (_local21.localAnchor1.x - _local4.x);
_local23 = (_local21.localAnchor1.y - _local4.y);
_local26 = ((_local3.col1.x * _local22) + (_local3.col2.x * _local23));
_local23 = ((_local3.col1.y * _local22) + (_local3.col2.y * _local23));
_local22 = _local26;
_local3 = _local8.m_xf.R;
_local4 = _local8.m_sweep.localCenter;
_local24 = (_local21.localAnchor2.x - _local4.x);
_local25 = (_local21.localAnchor2.y - _local4.y);
_local26 = ((_local3.col1.x * _local24) + (_local3.col2.x * _local25));
_local25 = ((_local3.col1.y * _local24) + (_local3.col2.y * _local25));
_local24 = _local26;
_local27 = (_local9.x + _local22);
_local28 = (_local9.y + _local23);
_local29 = (_local11.x + _local24);
_local30 = (_local11.y + _local25);
_local31 = (_local29 - _local27);
_local32 = (_local30 - _local28);
_local33 = (((_local31 * _local17) + (_local32 * _local18)) + _local21.separation);
_local2 = b2Math.b2Min(_local2, _local33);
_local34 = (_arg1 * b2Math.b2Clamp((_local33 + b2Settings.b2_linearSlop), -(b2Settings.b2_maxLinearCorrection), 0));
_local35 = (-(_local21.equalizedMass) * _local34);
_local36 = _local21.positionImpulse;
_local21.positionImpulse = b2Math.b2Max((_local36 + _local35), 0);
_local35 = (_local21.positionImpulse - _local36);
_local37 = (_local35 * _local17);
_local38 = (_local35 * _local18);
_local9.x = (_local9.x - (_local13 * _local37));
_local9.y = (_local9.y - (_local13 * _local38));
_local10 = (_local10 - (_local14 * ((_local22 * _local38) - (_local23 * _local37))));
_local7.m_sweep.a = _local10;
_local7.SynchronizeTransform();
_local11.x = (_local11.x + (_local15 * _local37));
_local11.y = (_local11.y + (_local15 * _local38));
_local12 = (_local12 + (_local16 * ((_local24 * _local38) - (_local25 * _local37))));
_local8.m_sweep.a = _local12;
_local8.SynchronizeTransform();
_local20++;
};
_local5++;
};
return ((_local2 >= (-1.5 * b2Settings.b2_linearSlop)));
}
public function SolveVelocityConstraints():void{
var _local1:int;
var _local2:b2ContactConstraintPoint;
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:b2Mat22;
var _local18:b2Vec2;
var _local20:b2ContactConstraint;
var _local21:b2Body;
var _local22:b2Body;
var _local23:Number;
var _local24:Number;
var _local25:b2Vec2;
var _local26:b2Vec2;
var _local27:Number;
var _local28:Number;
var _local29:Number;
var _local30:Number;
var _local31:Number;
var _local32:Number;
var _local33:Number;
var _local34:Number;
var _local35:Number;
var _local36:Number;
var _local37:int;
var _local38:Number;
var _local19:int;
while (_local19 < m_constraintCount) {
_local20 = m_constraints[_local19];
_local21 = _local20.body1;
_local22 = _local20.body2;
_local23 = _local21.m_angularVelocity;
_local24 = _local22.m_angularVelocity;
_local25 = _local21.m_linearVelocity;
_local26 = _local22.m_linearVelocity;
_local27 = _local21.m_invMass;
_local28 = _local21.m_invI;
_local29 = _local22.m_invMass;
_local30 = _local22.m_invI;
_local31 = _local20.normal.x;
_local32 = _local20.normal.y;
_local33 = _local32;
_local34 = -(_local31);
_local35 = _local20.friction;
_local37 = _local20.pointCount;
_local1 = 0;
while (_local1 < _local37) {
_local2 = _local20.points[_local1];
_local7 = (((_local26.x + (-(_local24) * _local2.r2.y)) - _local25.x) - (-(_local23) * _local2.r1.y));
_local8 = (((_local26.y + (_local24 * _local2.r2.x)) - _local25.y) - (_local23 * _local2.r1.x));
_local9 = ((_local7 * _local31) + (_local8 * _local32));
_local11 = (-(_local2.normalMass) * (_local9 - _local2.velocityBias));
_local10 = ((_local7 * _local33) + (_local8 * _local34));
_local12 = (_local2.tangentMass * -(_local10));
_local13 = b2Math.b2Max((_local2.normalImpulse + _local11), 0);
_local11 = (_local13 - _local2.normalImpulse);
_local38 = (_local35 * _local2.normalImpulse);
_local14 = b2Math.b2Clamp((_local2.tangentImpulse + _local12), -(_local38), _local38);
_local12 = (_local14 - _local2.tangentImpulse);
_local15 = ((_local11 * _local31) + (_local12 * _local33));
_local16 = ((_local11 * _local32) + (_local12 * _local34));
_local25.x = (_local25.x - (_local27 * _local15));
_local25.y = (_local25.y - (_local27 * _local16));
_local23 = (_local23 - (_local28 * ((_local2.r1.x * _local16) - (_local2.r1.y * _local15))));
_local26.x = (_local26.x + (_local29 * _local15));
_local26.y = (_local26.y + (_local29 * _local16));
_local24 = (_local24 + (_local30 * ((_local2.r2.x * _local16) - (_local2.r2.y * _local15))));
_local2.normalImpulse = _local13;
_local2.tangentImpulse = _local14;
_local1++;
};
_local21.m_angularVelocity = _local23;
_local22.m_angularVelocity = _local24;
_local19++;
};
}
public function FinalizeVelocityConstraints():void{
var _local2:b2ContactConstraint;
var _local3:b2Manifold;
var _local4:int;
var _local5:b2ManifoldPoint;
var _local6:b2ContactConstraintPoint;
var _local1:int;
while (_local1 < m_constraintCount) {
_local2 = m_constraints[_local1];
_local3 = _local2.manifold;
_local4 = 0;
while (_local4 < _local2.pointCount) {
_local5 = _local3.points[_local4];
_local6 = _local2.points[_local4];
_local5.normalImpulse = _local6.normalImpulse;
_local5.tangentImpulse = _local6.tangentImpulse;
_local4++;
};
_local1++;
};
}
}
}//package Box2D.Dynamics.Contacts
Section 46
//b2NullContact (Box2D.Dynamics.Contacts.b2NullContact)
package Box2D.Dynamics.Contacts {
import Box2D.Dynamics.*;
public class b2NullContact extends b2Contact {
override public function Evaluate(_arg1:b2ContactListener):void{
}
override public function GetManifolds():Array{
return (null);
}
}
}//package Box2D.Dynamics.Contacts
Section 47
//b2PolyAndCircleContact (Box2D.Dynamics.Contacts.b2PolyAndCircleContact)
package Box2D.Dynamics.Contacts {
import Box2D.Collision.Shapes.*;
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Collision.*;
import Box2D.Common.*;
public class b2PolyAndCircleContact extends b2Contact {
private var m_manifolds:Array;
public var m_manifold:b2Manifold;
private var m0:b2Manifold;
private static const s_evalCP:b2ContactPoint = new b2ContactPoint();
public function b2PolyAndCircleContact(_arg1:b2Shape, _arg2:b2Shape){
m_manifolds = [new b2Manifold()];
m0 = new b2Manifold();
super(_arg1, _arg2);
m_manifold = m_manifolds[0];
b2Settings.b2Assert((m_shape1.m_type == b2Shape.e_polygonShape));
b2Settings.b2Assert((m_shape2.m_type == b2Shape.e_circleShape));
m_manifold.pointCount = 0;
var _local3:b2ManifoldPoint = m_manifold.points[0];
_local3.normalImpulse = 0;
_local3.tangentImpulse = 0;
}
override public function Evaluate(_arg1:b2ContactListener):void{
var _local2:int;
var _local3:b2Vec2;
var _local4:b2Vec2;
var _local5:b2ManifoldPoint;
var _local10:b2ManifoldPoint;
var _local11:Boolean;
var _local12:uint;
var _local13:int;
var _local6:b2Body = m_shape1.m_body;
var _local7:b2Body = m_shape2.m_body;
m0.Set(m_manifold);
b2Collision.b2CollidePolygonAndCircle(m_manifold, (m_shape1 as b2PolygonShape), _local6.m_xf, (m_shape2 as b2CircleShape), _local7.m_xf);
var _local8:Array = [false, false];
var _local9:b2ContactPoint = s_evalCP;
_local9.shape1 = m_shape1;
_local9.shape2 = m_shape2;
_local9.friction = m_friction;
_local9.restitution = m_restitution;
if (m_manifold.pointCount > 0){
_local2 = 0;
while (_local2 < m_manifold.pointCount) {
_local10 = m_manifold.points[_local2];
_local10.normalImpulse = 0;
_local10.tangentImpulse = 0;
_local11 = false;
_local12 = _local10.id._key;
_local13 = 0;
while (_local13 < m0.pointCount) {
if (_local8[_local13] == true){
} else {
_local5 = m0.points[_local13];
if (_local5.id._key == _local12){
_local8[_local13] = true;
_local10.normalImpulse = _local5.normalImpulse;
_local10.tangentImpulse = _local5.tangentImpulse;
_local11 = true;
if (_arg1 != null){
_local9.position = _local6.GetWorldPoint(_local10.localPoint1);
_local3 = _local6.GetLinearVelocityFromLocalPoint(_local10.localPoint1);
_local4 = _local7.GetLinearVelocityFromLocalPoint(_local10.localPoint2);
_local9.velocity.Set((_local4.x - _local3.x), (_local4.y - _local3.y));
_local9.normal.SetV(m_manifold.normal);
_local9.separation = _local10.separation;
_local9.id.key = _local12;
_arg1.Persist(_local9);
};
break;
};
};
_local13++;
};
if ((((_local11 == false)) && (!((_arg1 == null))))){
_local9.position = _local6.GetWorldPoint(_local10.localPoint1);
_local3 = _local6.GetLinearVelocityFromLocalPoint(_local10.localPoint1);
_local4 = _local7.GetLinearVelocityFromLocalPoint(_local10.localPoint2);
_local9.velocity.Set((_local4.x - _local3.x), (_local4.y - _local3.y));
_local9.normal.SetV(m_manifold.normal);
_local9.separation = _local10.separation;
_local9.id.key = _local12;
_arg1.Add(_local9);
};
_local2++;
};
m_manifoldCount = 1;
} else {
m_manifoldCount = 0;
};
if (_arg1 == null){
return;
};
_local2 = 0;
while (_local2 < m0.pointCount) {
if (_local8[_local2]){
} else {
_local5 = m0.points[_local2];
_local9.position = _local6.GetWorldPoint(_local5.localPoint1);
_local3 = _local6.GetLinearVelocityFromLocalPoint(_local5.localPoint1);
_local4 = _local7.GetLinearVelocityFromLocalPoint(_local5.localPoint2);
_local9.velocity.Set((_local4.x - _local3.x), (_local4.y - _local3.y));
_local9.normal.SetV(m0.normal);
_local9.separation = _local5.separation;
_local9.id.key = _local5.id._key;
_arg1.Remove(_local9);
};
_local2++;
};
}
override public function GetManifolds():Array{
return (m_manifolds);
}
public static function Destroy(_arg1:b2Contact, _arg2):void{
}
public static function Create(_arg1:b2Shape, _arg2:b2Shape, _arg3):b2Contact{
return (new b2PolyAndCircleContact(_arg1, _arg2));
}
}
}//package Box2D.Dynamics.Contacts
Section 48
//b2PolygonContact (Box2D.Dynamics.Contacts.b2PolygonContact)
package Box2D.Dynamics.Contacts {
import Box2D.Collision.Shapes.*;
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Collision.*;
import Box2D.Common.*;
public class b2PolygonContact extends b2Contact {
private var m_manifolds:Array;
private var m0:b2Manifold;
public var m_manifold:b2Manifold;
private static const s_evalCP:b2ContactPoint = new b2ContactPoint();
public function b2PolygonContact(_arg1:b2Shape, _arg2:b2Shape):void{
m0 = new b2Manifold();
m_manifolds = [new b2Manifold()];
super(_arg1, _arg2);
m_manifold = m_manifolds[0];
m_manifold.pointCount = 0;
}
override public function Evaluate(_arg1:b2ContactListener):void{
var _local2:b2Vec2;
var _local3:b2Vec2;
var _local4:b2ManifoldPoint;
var _local7:b2ContactPoint;
var _local8:int;
var _local10:b2ManifoldPoint;
var _local11:Boolean;
var _local12:uint;
var _local13:int;
var _local5:b2Body = m_shape1.m_body;
var _local6:b2Body = m_shape2.m_body;
m0.Set(m_manifold);
b2Collision.b2CollidePolygons(m_manifold, (m_shape1 as b2PolygonShape), _local5.m_xf, (m_shape2 as b2PolygonShape), _local6.m_xf);
var _local9:Array = [false, false];
_local7 = s_evalCP;
_local7.shape1 = m_shape1;
_local7.shape2 = m_shape2;
_local7.friction = m_friction;
_local7.restitution = m_restitution;
if (m_manifold.pointCount > 0){
_local8 = 0;
while (_local8 < m_manifold.pointCount) {
_local10 = m_manifold.points[_local8];
_local10.normalImpulse = 0;
_local10.tangentImpulse = 0;
_local11 = false;
_local12 = _local10.id._key;
_local13 = 0;
while (_local13 < m0.pointCount) {
if (_local9[_local13] == true){
} else {
_local4 = m0.points[_local13];
if (_local4.id._key == _local12){
_local9[_local13] = true;
_local10.normalImpulse = _local4.normalImpulse;
_local10.tangentImpulse = _local4.tangentImpulse;
_local11 = true;
if (_arg1 != null){
_local7.position = _local5.GetWorldPoint(_local10.localPoint1);
_local2 = _local5.GetLinearVelocityFromLocalPoint(_local10.localPoint1);
_local3 = _local6.GetLinearVelocityFromLocalPoint(_local10.localPoint2);
_local7.velocity.Set((_local3.x - _local2.x), (_local3.y - _local2.y));
_local7.normal.SetV(m_manifold.normal);
_local7.separation = _local10.separation;
_local7.id.key = _local12;
_arg1.Persist(_local7);
};
break;
};
};
_local13++;
};
if ((((_local11 == false)) && (!((_arg1 == null))))){
_local7.position = _local5.GetWorldPoint(_local10.localPoint1);
_local2 = _local5.GetLinearVelocityFromLocalPoint(_local10.localPoint1);
_local3 = _local6.GetLinearVelocityFromLocalPoint(_local10.localPoint2);
_local7.velocity.Set((_local3.x - _local2.x), (_local3.y - _local2.y));
_local7.normal.SetV(m_manifold.normal);
_local7.separation = _local10.separation;
_local7.id.key = _local12;
_arg1.Add(_local7);
};
_local8++;
};
m_manifoldCount = 1;
} else {
m_manifoldCount = 0;
};
if (_arg1 == null){
return;
};
_local8 = 0;
while (_local8 < m0.pointCount) {
if (_local9[_local8]){
} else {
_local4 = m0.points[_local8];
_local7.position = _local5.GetWorldPoint(_local4.localPoint1);
_local2 = _local5.GetLinearVelocityFromLocalPoint(_local4.localPoint1);
_local3 = _local6.GetLinearVelocityFromLocalPoint(_local4.localPoint2);
_local7.velocity.Set((_local3.x - _local2.x), (_local3.y - _local2.y));
_local7.normal.SetV(m0.normal);
_local7.separation = _local4.separation;
_local7.id.key = _local4.id._key;
_arg1.Remove(_local7);
};
_local8++;
};
}
override public function GetManifolds():Array{
return (m_manifolds);
}
public static function Destroy(_arg1:b2Contact, _arg2):void{
}
public static function Create(_arg1:b2Shape, _arg2:b2Shape, _arg3):b2Contact{
return (new b2PolygonContact(_arg1, _arg2));
}
}
}//package Box2D.Dynamics.Contacts
Section 49
//b2DistanceJoint (Box2D.Dynamics.Joints.b2DistanceJoint)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Common.*;
public class b2DistanceJoint extends b2Joint {
public var m_localAnchor1:b2Vec2;
public var m_localAnchor2:b2Vec2;
public var m_bias:Number;
public var m_gamma:Number;
public var m_u:b2Vec2;
public var m_mass:Number;
public var m_impulse:Number;
public var m_dampingRatio:Number;
public var m_frequencyHz:Number;
public var m_length:Number;
public function b2DistanceJoint(_arg1:b2DistanceJointDef){
var _local2:b2Mat22;
var _local3:Number;
var _local4:Number;
m_localAnchor1 = new b2Vec2();
m_localAnchor2 = new b2Vec2();
m_u = new b2Vec2();
super(_arg1);
m_localAnchor1.SetV(_arg1.localAnchor1);
m_localAnchor2.SetV(_arg1.localAnchor2);
m_length = _arg1.length;
m_frequencyHz = _arg1.frequencyHz;
m_dampingRatio = _arg1.dampingRatio;
m_impulse = 0;
m_gamma = 0;
m_bias = 0;
m_inv_dt = 0;
}
override public function GetAnchor1():b2Vec2{
return (m_body1.GetWorldPoint(m_localAnchor1));
}
override public function GetAnchor2():b2Vec2{
return (m_body2.GetWorldPoint(m_localAnchor2));
}
override public function InitVelocityConstraints(_arg1:b2TimeStep):void{
var _local2:b2Mat22;
var _local3:Number;
var _local4:b2Body;
var _local5:b2Body;
var _local6:Number;
var _local8:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:Number;
m_inv_dt = _arg1.inv_dt;
_local4 = m_body1;
_local5 = m_body2;
_local2 = _local4.m_xf.R;
_local6 = (m_localAnchor1.x - _local4.m_sweep.localCenter.x);
var _local7:Number = (m_localAnchor1.y - _local4.m_sweep.localCenter.y);
_local3 = ((_local2.col1.x * _local6) + (_local2.col2.x * _local7));
_local7 = ((_local2.col1.y * _local6) + (_local2.col2.y * _local7));
_local6 = _local3;
_local2 = _local5.m_xf.R;
_local8 = (m_localAnchor2.x - _local5.m_sweep.localCenter.x);
var _local9:Number = (m_localAnchor2.y - _local5.m_sweep.localCenter.y);
_local3 = ((_local2.col1.x * _local8) + (_local2.col2.x * _local9));
_local9 = ((_local2.col1.y * _local8) + (_local2.col2.y * _local9));
_local8 = _local3;
m_u.x = (((_local5.m_sweep.c.x + _local8) - _local4.m_sweep.c.x) - _local6);
m_u.y = (((_local5.m_sweep.c.y + _local9) - _local4.m_sweep.c.y) - _local7);
var _local10:Number = Math.sqrt(((m_u.x * m_u.x) + (m_u.y * m_u.y)));
if (_local10 > b2Settings.b2_linearSlop){
m_u.Multiply((1 / _local10));
} else {
m_u.SetZero();
};
var _local11:Number = ((_local6 * m_u.y) - (_local7 * m_u.x));
var _local12:Number = ((_local8 * m_u.y) - (_local9 * m_u.x));
var _local13:Number = (((_local4.m_invMass + ((_local4.m_invI * _local11) * _local11)) + _local5.m_invMass) + ((_local5.m_invI * _local12) * _local12));
m_mass = (1 / _local13);
if (m_frequencyHz > 0){
_local14 = (_local10 - m_length);
_local15 = ((2 * Math.PI) * m_frequencyHz);
_local16 = (((2 * m_mass) * m_dampingRatio) * _local15);
_local17 = ((m_mass * _local15) * _local15);
m_gamma = (1 / (_arg1.dt * (_local16 + (_arg1.dt * _local17))));
m_bias = (((_local14 * _arg1.dt) * _local17) * m_gamma);
m_mass = (1 / (_local13 + m_gamma));
};
if (_arg1.warmStarting){
m_impulse = (m_impulse * _arg1.dtRatio);
_local18 = (m_impulse * m_u.x);
_local19 = (m_impulse * m_u.y);
_local4.m_linearVelocity.x = (_local4.m_linearVelocity.x - (_local4.m_invMass * _local18));
_local4.m_linearVelocity.y = (_local4.m_linearVelocity.y - (_local4.m_invMass * _local19));
_local4.m_angularVelocity = (_local4.m_angularVelocity - (_local4.m_invI * ((_local6 * _local19) - (_local7 * _local18))));
_local5.m_linearVelocity.x = (_local5.m_linearVelocity.x + (_local5.m_invMass * _local18));
_local5.m_linearVelocity.y = (_local5.m_linearVelocity.y + (_local5.m_invMass * _local19));
_local5.m_angularVelocity = (_local5.m_angularVelocity + (_local5.m_invI * ((_local8 * _local19) - (_local9 * _local18))));
} else {
m_impulse = 0;
};
}
override public function GetReactionTorque():Number{
return (0);
}
override public function GetReactionForce():b2Vec2{
var _local1:b2Vec2 = new b2Vec2();
_local1.SetV(m_u);
_local1.Multiply((m_inv_dt * m_impulse));
return (_local1);
}
override public function SolvePositionConstraints():Boolean{
var _local1:b2Mat22;
if (m_frequencyHz > 0){
return (true);
};
var _local2:b2Body = m_body1;
var _local3:b2Body = m_body2;
_local1 = _local2.m_xf.R;
var _local4:Number = (m_localAnchor1.x - _local2.m_sweep.localCenter.x);
var _local5:Number = (m_localAnchor1.y - _local2.m_sweep.localCenter.y);
var _local6:Number = ((_local1.col1.x * _local4) + (_local1.col2.x * _local5));
_local5 = ((_local1.col1.y * _local4) + (_local1.col2.y * _local5));
_local4 = _local6;
_local1 = _local3.m_xf.R;
var _local7:Number = (m_localAnchor2.x - _local3.m_sweep.localCenter.x);
var _local8:Number = (m_localAnchor2.y - _local3.m_sweep.localCenter.y);
_local6 = ((_local1.col1.x * _local7) + (_local1.col2.x * _local8));
_local8 = ((_local1.col1.y * _local7) + (_local1.col2.y * _local8));
_local7 = _local6;
var _local9:Number = (((_local3.m_sweep.c.x + _local7) - _local2.m_sweep.c.x) - _local4);
var _local10:Number = (((_local3.m_sweep.c.y + _local8) - _local2.m_sweep.c.y) - _local5);
var _local11:Number = Math.sqrt(((_local9 * _local9) + (_local10 * _local10)));
_local9 = (_local9 / _local11);
_local10 = (_local10 / _local11);
var _local12:Number = (_local11 - m_length);
_local12 = b2Math.b2Clamp(_local12, -(b2Settings.b2_maxLinearCorrection), b2Settings.b2_maxLinearCorrection);
var _local13:Number = (-(m_mass) * _local12);
m_u.Set(_local9, _local10);
var _local14:Number = (_local13 * m_u.x);
var _local15:Number = (_local13 * m_u.y);
_local2.m_sweep.c.x = (_local2.m_sweep.c.x - (_local2.m_invMass * _local14));
_local2.m_sweep.c.y = (_local2.m_sweep.c.y - (_local2.m_invMass * _local15));
_local2.m_sweep.a = (_local2.m_sweep.a - (_local2.m_invI * ((_local4 * _local15) - (_local5 * _local14))));
_local3.m_sweep.c.x = (_local3.m_sweep.c.x + (_local3.m_invMass * _local14));
_local3.m_sweep.c.y = (_local3.m_sweep.c.y + (_local3.m_invMass * _local15));
_local3.m_sweep.a = (_local3.m_sweep.a + (_local3.m_invI * ((_local7 * _local15) - (_local8 * _local14))));
_local2.SynchronizeTransform();
_local3.SynchronizeTransform();
return ((b2Math.b2Abs(_local12) < b2Settings.b2_linearSlop));
}
override public function SolveVelocityConstraints(_arg1:b2TimeStep):void{
var _local2:b2Mat22;
var _local3:b2Body = m_body1;
var _local4:b2Body = m_body2;
_local2 = _local3.m_xf.R;
var _local5:Number = (m_localAnchor1.x - _local3.m_sweep.localCenter.x);
var _local6:Number = (m_localAnchor1.y - _local3.m_sweep.localCenter.y);
var _local7:Number = ((_local2.col1.x * _local5) + (_local2.col2.x * _local6));
_local6 = ((_local2.col1.y * _local5) + (_local2.col2.y * _local6));
_local5 = _local7;
_local2 = _local4.m_xf.R;
var _local8:Number = (m_localAnchor2.x - _local4.m_sweep.localCenter.x);
var _local9:Number = (m_localAnchor2.y - _local4.m_sweep.localCenter.y);
_local7 = ((_local2.col1.x * _local8) + (_local2.col2.x * _local9));
_local9 = ((_local2.col1.y * _local8) + (_local2.col2.y * _local9));
_local8 = _local7;
var _local10:Number = (_local3.m_linearVelocity.x + (-(_local3.m_angularVelocity) * _local6));
var _local11:Number = (_local3.m_linearVelocity.y + (_local3.m_angularVelocity * _local5));
var _local12:Number = (_local4.m_linearVelocity.x + (-(_local4.m_angularVelocity) * _local9));
var _local13:Number = (_local4.m_linearVelocity.y + (_local4.m_angularVelocity * _local8));
var _local14:Number = ((m_u.x * (_local12 - _local10)) + (m_u.y * (_local13 - _local11)));
var _local15:Number = (-(m_mass) * ((_local14 + m_bias) + (m_gamma * m_impulse)));
m_impulse = (m_impulse + _local15);
var _local16:Number = (_local15 * m_u.x);
var _local17:Number = (_local15 * m_u.y);
_local3.m_linearVelocity.x = (_local3.m_linearVelocity.x - (_local3.m_invMass * _local16));
_local3.m_linearVelocity.y = (_local3.m_linearVelocity.y - (_local3.m_invMass * _local17));
_local3.m_angularVelocity = (_local3.m_angularVelocity - (_local3.m_invI * ((_local5 * _local17) - (_local6 * _local16))));
_local4.m_linearVelocity.x = (_local4.m_linearVelocity.x + (_local4.m_invMass * _local16));
_local4.m_linearVelocity.y = (_local4.m_linearVelocity.y + (_local4.m_invMass * _local17));
_local4.m_angularVelocity = (_local4.m_angularVelocity + (_local4.m_invI * ((_local8 * _local17) - (_local9 * _local16))));
}
}
}//package Box2D.Dynamics.Joints
Section 50
//b2DistanceJointDef (Box2D.Dynamics.Joints.b2DistanceJointDef)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
public class b2DistanceJointDef extends b2JointDef {
public var localAnchor1:b2Vec2;
public var length:Number;
public var dampingRatio:Number;
public var localAnchor2:b2Vec2;
public var frequencyHz:Number;
public function b2DistanceJointDef(){
localAnchor1 = new b2Vec2();
localAnchor2 = new b2Vec2();
super();
type = b2Joint.e_distanceJoint;
length = 1;
frequencyHz = 0;
dampingRatio = 0;
}
public function Initialize(_arg1:b2Body, _arg2:b2Body, _arg3:b2Vec2, _arg4:b2Vec2):void{
body1 = _arg1;
body2 = _arg2;
localAnchor1.SetV(body1.GetLocalPoint(_arg3));
localAnchor2.SetV(body2.GetLocalPoint(_arg4));
var _local5:Number = (_arg4.x - _arg3.x);
var _local6:Number = (_arg4.y - _arg3.y);
length = Math.sqrt(((_local5 * _local5) + (_local6 * _local6)));
frequencyHz = 0;
dampingRatio = 0;
}
}
}//package Box2D.Dynamics.Joints
Section 51
//b2GearJoint (Box2D.Dynamics.Joints.b2GearJoint)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Common.*;
public class b2GearJoint extends b2Joint {
public var m_ground2:b2Body;
public var m_groundAnchor1:b2Vec2;
public var m_groundAnchor2:b2Vec2;
public var m_localAnchor1:b2Vec2;
public var m_localAnchor2:b2Vec2;
public var m_ratio:Number;
public var m_revolute2:b2RevoluteJoint;
public var m_force:Number;
public var m_mass:Number;
public var m_prismatic2:b2PrismaticJoint;
public var m_ground1:b2Body;
public var m_revolute1:b2RevoluteJoint;
public var m_prismatic1:b2PrismaticJoint;
public var m_constant:Number;
public var m_J:b2Jacobian;
public function b2GearJoint(_arg1:b2GearJointDef){
var _local4:Number;
var _local5:Number;
m_groundAnchor1 = new b2Vec2();
m_groundAnchor2 = new b2Vec2();
m_localAnchor1 = new b2Vec2();
m_localAnchor2 = new b2Vec2();
m_J = new b2Jacobian();
super(_arg1);
var _local2:int = _arg1.joint1.m_type;
var _local3:int = _arg1.joint2.m_type;
m_revolute1 = null;
m_prismatic1 = null;
m_revolute2 = null;
m_prismatic2 = null;
m_ground1 = _arg1.joint1.m_body1;
m_body1 = _arg1.joint1.m_body2;
if (_local2 == b2Joint.e_revoluteJoint){
m_revolute1 = (_arg1.joint1 as b2RevoluteJoint);
m_groundAnchor1.SetV(m_revolute1.m_localAnchor1);
m_localAnchor1.SetV(m_revolute1.m_localAnchor2);
_local4 = m_revolute1.GetJointAngle();
} else {
m_prismatic1 = (_arg1.joint1 as b2PrismaticJoint);
m_groundAnchor1.SetV(m_prismatic1.m_localAnchor1);
m_localAnchor1.SetV(m_prismatic1.m_localAnchor2);
_local4 = m_prismatic1.GetJointTranslation();
};
m_ground2 = _arg1.joint2.m_body1;
m_body2 = _arg1.joint2.m_body2;
if (_local3 == b2Joint.e_revoluteJoint){
m_revolute2 = (_arg1.joint2 as b2RevoluteJoint);
m_groundAnchor2.SetV(m_revolute2.m_localAnchor1);
m_localAnchor2.SetV(m_revolute2.m_localAnchor2);
_local5 = m_revolute2.GetJointAngle();
} else {
m_prismatic2 = (_arg1.joint2 as b2PrismaticJoint);
m_groundAnchor2.SetV(m_prismatic2.m_localAnchor1);
m_localAnchor2.SetV(m_prismatic2.m_localAnchor2);
_local5 = m_prismatic2.GetJointTranslation();
};
m_ratio = _arg1.ratio;
m_constant = (_local4 + (m_ratio * _local5));
m_force = 0;
}
override public function GetAnchor1():b2Vec2{
return (m_body1.GetWorldPoint(m_localAnchor1));
}
override public function GetAnchor2():b2Vec2{
return (m_body2.GetWorldPoint(m_localAnchor2));
}
override public function InitVelocityConstraints(_arg1:b2TimeStep):void{
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:b2Mat22;
var _local11:b2Vec2;
var _local12:Number;
var _local13:Number;
var _local15:Number;
var _local2:b2Body = m_ground1;
var _local3:b2Body = m_ground2;
var _local4:b2Body = m_body1;
var _local5:b2Body = m_body2;
var _local14:Number = 0;
m_J.SetZero();
if (m_revolute1){
m_J.angular1 = -1;
_local14 = (_local14 + _local4.m_invI);
} else {
_local10 = _local2.m_xf.R;
_local11 = m_prismatic1.m_localXAxis1;
_local6 = ((_local10.col1.x * _local11.x) + (_local10.col2.x * _local11.y));
_local7 = ((_local10.col1.y * _local11.x) + (_local10.col2.y * _local11.y));
_local10 = _local4.m_xf.R;
_local8 = (m_localAnchor1.x - _local4.m_sweep.localCenter.x);
_local9 = (m_localAnchor1.y - _local4.m_sweep.localCenter.y);
_local13 = ((_local10.col1.x * _local8) + (_local10.col2.x * _local9));
_local9 = ((_local10.col1.y * _local8) + (_local10.col2.y * _local9));
_local8 = _local13;
_local12 = ((_local8 * _local7) - (_local9 * _local6));
m_J.linear1.Set(-(_local6), -(_local7));
m_J.angular1 = -(_local12);
_local14 = (_local14 + (_local4.m_invMass + ((_local4.m_invI * _local12) * _local12)));
};
if (m_revolute2){
m_J.angular2 = -(m_ratio);
_local14 = (_local14 + ((m_ratio * m_ratio) * _local5.m_invI));
} else {
_local10 = _local3.m_xf.R;
_local11 = m_prismatic2.m_localXAxis1;
_local6 = ((_local10.col1.x * _local11.x) + (_local10.col2.x * _local11.y));
_local7 = ((_local10.col1.y * _local11.x) + (_local10.col2.y * _local11.y));
_local10 = _local5.m_xf.R;
_local8 = (m_localAnchor2.x - _local5.m_sweep.localCenter.x);
_local9 = (m_localAnchor2.y - _local5.m_sweep.localCenter.y);
_local13 = ((_local10.col1.x * _local8) + (_local10.col2.x * _local9));
_local9 = ((_local10.col1.y * _local8) + (_local10.col2.y * _local9));
_local8 = _local13;
_local12 = ((_local8 * _local7) - (_local9 * _local6));
m_J.linear2.Set((-(m_ratio) * _local6), (-(m_ratio) * _local7));
m_J.angular2 = (-(m_ratio) * _local12);
_local14 = (_local14 + ((m_ratio * m_ratio) * (_local5.m_invMass + ((_local5.m_invI * _local12) * _local12))));
};
m_mass = (1 / _local14);
if (_arg1.warmStarting){
_local15 = (_arg1.dt * m_force);
_local4.m_linearVelocity.x = (_local4.m_linearVelocity.x + ((_local4.m_invMass * _local15) * m_J.linear1.x));
_local4.m_linearVelocity.y = (_local4.m_linearVelocity.y + ((_local4.m_invMass * _local15) * m_J.linear1.y));
_local4.m_angularVelocity = (_local4.m_angularVelocity + ((_local4.m_invI * _local15) * m_J.angular1));
_local5.m_linearVelocity.x = (_local5.m_linearVelocity.x + ((_local5.m_invMass * _local15) * m_J.linear2.x));
_local5.m_linearVelocity.y = (_local5.m_linearVelocity.y + ((_local5.m_invMass * _local15) * m_J.linear2.y));
_local5.m_angularVelocity = (_local5.m_angularVelocity + ((_local5.m_invI * _local15) * m_J.angular2));
} else {
m_force = 0;
};
}
override public function GetReactionTorque():Number{
var _local1:b2Mat22 = m_body2.m_xf.R;
var _local2:Number = (m_localAnchor1.x - m_body2.m_sweep.localCenter.x);
var _local3:Number = (m_localAnchor1.y - m_body2.m_sweep.localCenter.y);
var _local4:Number = ((_local1.col1.x * _local2) + (_local1.col2.x * _local3));
_local3 = ((_local1.col1.y * _local2) + (_local1.col2.y * _local3));
_local2 = _local4;
_local4 = ((m_force * m_J.angular2) - ((_local2 * (m_force * m_J.linear2.y)) - (_local3 * (m_force * m_J.linear2.x))));
return (_local4);
}
override public function GetReactionForce():b2Vec2{
var _local1:b2Vec2 = new b2Vec2((m_force * m_J.linear2.x), (m_force * m_J.linear2.y));
return (_local1);
}
override public function SolvePositionConstraints():Boolean{
var _local4:Number;
var _local5:Number;
var _local1:Number = 0;
var _local2:b2Body = m_body1;
var _local3:b2Body = m_body2;
if (m_revolute1){
_local4 = m_revolute1.GetJointAngle();
} else {
_local4 = m_prismatic1.GetJointTranslation();
};
if (m_revolute2){
_local5 = m_revolute2.GetJointAngle();
} else {
_local5 = m_prismatic2.GetJointTranslation();
};
var _local6:Number = (m_constant - (_local4 + (m_ratio * _local5)));
var _local7:Number = (-(m_mass) * _local6);
_local2.m_sweep.c.x = (_local2.m_sweep.c.x + ((_local2.m_invMass * _local7) * m_J.linear1.x));
_local2.m_sweep.c.y = (_local2.m_sweep.c.y + ((_local2.m_invMass * _local7) * m_J.linear1.y));
_local2.m_sweep.a = (_local2.m_sweep.a + ((_local2.m_invI * _local7) * m_J.angular1));
_local3.m_sweep.c.x = (_local3.m_sweep.c.x + ((_local3.m_invMass * _local7) * m_J.linear2.x));
_local3.m_sweep.c.y = (_local3.m_sweep.c.y + ((_local3.m_invMass * _local7) * m_J.linear2.y));
_local3.m_sweep.a = (_local3.m_sweep.a + ((_local3.m_invI * _local7) * m_J.angular2));
_local2.SynchronizeTransform();
_local3.SynchronizeTransform();
return ((_local1 < b2Settings.b2_linearSlop));
}
public function GetRatio():Number{
return (m_ratio);
}
override public function SolveVelocityConstraints(_arg1:b2TimeStep):void{
var _local2:b2Body = m_body1;
var _local3:b2Body = m_body2;
var _local4:Number = m_J.Compute(_local2.m_linearVelocity, _local2.m_angularVelocity, _local3.m_linearVelocity, _local3.m_angularVelocity);
var _local5:Number = ((-(_arg1.inv_dt) * m_mass) * _local4);
m_force = (m_force + _local5);
var _local6:Number = (_arg1.dt * _local5);
_local2.m_linearVelocity.x = (_local2.m_linearVelocity.x + ((_local2.m_invMass * _local6) * m_J.linear1.x));
_local2.m_linearVelocity.y = (_local2.m_linearVelocity.y + ((_local2.m_invMass * _local6) * m_J.linear1.y));
_local2.m_angularVelocity = (_local2.m_angularVelocity + ((_local2.m_invI * _local6) * m_J.angular1));
_local3.m_linearVelocity.x = (_local3.m_linearVelocity.x + ((_local3.m_invMass * _local6) * m_J.linear2.x));
_local3.m_linearVelocity.y = (_local3.m_linearVelocity.y + ((_local3.m_invMass * _local6) * m_J.linear2.y));
_local3.m_angularVelocity = (_local3.m_angularVelocity + ((_local3.m_invI * _local6) * m_J.angular2));
}
}
}//package Box2D.Dynamics.Joints
Section 52
//b2GearJointDef (Box2D.Dynamics.Joints.b2GearJointDef)
package Box2D.Dynamics.Joints {
public class b2GearJointDef extends b2JointDef {
public var joint1:b2Joint;
public var joint2:b2Joint;
public var ratio:Number;
public function b2GearJointDef(){
type = b2Joint.e_gearJoint;
joint1 = null;
joint2 = null;
ratio = 1;
}
}
}//package Box2D.Dynamics.Joints
Section 53
//b2Jacobian (Box2D.Dynamics.Joints.b2Jacobian)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
public class b2Jacobian {
public var linear1:b2Vec2;
public var linear2:b2Vec2;
public var angular1:Number;
public var angular2:Number;
public function b2Jacobian(){
linear1 = new b2Vec2();
linear2 = new b2Vec2();
super();
}
public function Set(_arg1:b2Vec2, _arg2:Number, _arg3:b2Vec2, _arg4:Number):void{
linear1.SetV(_arg1);
angular1 = _arg2;
linear2.SetV(_arg3);
angular2 = _arg4;
}
public function SetZero():void{
linear1.SetZero();
angular1 = 0;
linear2.SetZero();
angular2 = 0;
}
public function Compute(_arg1:b2Vec2, _arg2:Number, _arg3:b2Vec2, _arg4:Number):Number{
return ((((((linear1.x * _arg1.x) + (linear1.y * _arg1.y)) + (angular1 * _arg2)) + ((linear2.x * _arg3.x) + (linear2.y * _arg3.y))) + (angular2 * _arg4)));
}
}
}//package Box2D.Dynamics.Joints
Section 54
//b2Joint (Box2D.Dynamics.Joints.b2Joint)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
public class b2Joint {
public var m_islandFlag:Boolean;
public var m_body1:b2Body;
public var m_prev:b2Joint;
public var m_next:b2Joint;
public var m_type:int;
public var m_collideConnected:Boolean;
public var m_node1:b2JointEdge;
public var m_node2:b2JointEdge;
public var m_inv_dt:Number;
public var m_userData;
public var m_body2:b2Body;
public static const e_unknownJoint:int = 0;
public static const e_inactiveLimit:int = 0;
public static const e_atUpperLimit:int = 2;
public static const e_atLowerLimit:int = 1;
public static const e_gearJoint:int = 6;
public static const e_revoluteJoint:int = 1;
public static const e_equalLimits:int = 3;
public static const e_distanceJoint:int = 3;
public static const e_pulleyJoint:int = 4;
public static const e_prismaticJoint:int = 2;
public static const e_mouseJoint:int = 5;
public function b2Joint(_arg1:b2JointDef){
m_node1 = new b2JointEdge();
m_node2 = new b2JointEdge();
super();
m_type = _arg1.type;
m_prev = null;
m_next = null;
m_body1 = _arg1.body1;
m_body2 = _arg1.body2;
m_collideConnected = _arg1.collideConnected;
m_islandFlag = false;
m_userData = _arg1.userData;
}
public function GetBody2():b2Body{
return (m_body2);
}
public function GetAnchor1():b2Vec2{
return (null);
}
public function GetAnchor2():b2Vec2{
return (null);
}
public function GetNext():b2Joint{
return (m_next);
}
public function GetType():int{
return (m_type);
}
public function InitVelocityConstraints(_arg1:b2TimeStep):void{
}
public function GetReactionTorque():Number{
return (0);
}
public function GetUserData(){
return (m_userData);
}
public function GetReactionForce():b2Vec2{
return (null);
}
public function SolvePositionConstraints():Boolean{
return (false);
}
public function SetUserData(_arg1):void{
m_userData = _arg1;
}
public function GetBody1():b2Body{
return (m_body1);
}
public function SolveVelocityConstraints(_arg1:b2TimeStep):void{
}
public function InitPositionConstraints():void{
}
public static function Destroy(_arg1:b2Joint, _arg2):void{
}
public static function Create(_arg1:b2JointDef, _arg2):b2Joint{
var _local3:b2Joint;
switch (_arg1.type){
case e_distanceJoint:
_local3 = new b2DistanceJoint((_arg1 as b2DistanceJointDef));
break;
case e_mouseJoint:
_local3 = new b2MouseJoint((_arg1 as b2MouseJointDef));
break;
case e_prismaticJoint:
_local3 = new b2PrismaticJoint((_arg1 as b2PrismaticJointDef));
break;
case e_revoluteJoint:
_local3 = new b2RevoluteJoint((_arg1 as b2RevoluteJointDef));
break;
case e_pulleyJoint:
_local3 = new b2PulleyJoint((_arg1 as b2PulleyJointDef));
break;
case e_gearJoint:
_local3 = new b2GearJoint((_arg1 as b2GearJointDef));
break;
default:
break;
};
return (_local3);
}
}
}//package Box2D.Dynamics.Joints
Section 55
//b2JointDef (Box2D.Dynamics.Joints.b2JointDef)
package Box2D.Dynamics.Joints {
import Box2D.Dynamics.*;
public class b2JointDef {
public var body2:b2Body;
public var type:int;
public var userData;
public var collideConnected:Boolean;
public var body1:b2Body;
public function b2JointDef(){
type = b2Joint.e_unknownJoint;
userData = null;
body1 = null;
body2 = null;
collideConnected = false;
}
}
}//package Box2D.Dynamics.Joints
Section 56
//b2JointEdge (Box2D.Dynamics.Joints.b2JointEdge)
package Box2D.Dynamics.Joints {
import Box2D.Dynamics.*;
public class b2JointEdge {
public var other:b2Body;
public var next:b2JointEdge;
public var prev:b2JointEdge;
public var joint:b2Joint;
}
}//package Box2D.Dynamics.Joints
Section 57
//b2MouseJoint (Box2D.Dynamics.Joints.b2MouseJoint)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Common.*;
public class b2MouseJoint extends b2Joint {
private var K1:b2Mat22;
private var K:b2Mat22;
public var m_beta:Number;
public var m_mass:b2Mat22;
private var K2:b2Mat22;
public var m_target:b2Vec2;
public var m_gamma:Number;
public var m_impulse:b2Vec2;
public var m_C:b2Vec2;
public var m_localAnchor:b2Vec2;
public var m_maxForce:Number;
public function b2MouseJoint(_arg1:b2MouseJointDef){
var _local3:Number;
K = new b2Mat22();
K1 = new b2Mat22();
K2 = new b2Mat22();
m_localAnchor = new b2Vec2();
m_target = new b2Vec2();
m_impulse = new b2Vec2();
m_mass = new b2Mat22();
m_C = new b2Vec2();
super(_arg1);
m_target.SetV(_arg1.target);
var _local2:Number = (m_target.x - m_body2.m_xf.position.x);
_local3 = (m_target.y - m_body2.m_xf.position.y);
var _local4:b2Mat22 = m_body2.m_xf.R;
m_localAnchor.x = ((_local2 * _local4.col1.x) + (_local3 * _local4.col1.y));
m_localAnchor.y = ((_local2 * _local4.col2.x) + (_local3 * _local4.col2.y));
m_maxForce = _arg1.maxForce;
m_impulse.SetZero();
var _local5:Number = m_body2.m_mass;
var _local6:Number = ((2 * b2Settings.b2_pi) * _arg1.frequencyHz);
var _local7:Number = (((2 * _local5) * _arg1.dampingRatio) * _local6);
var _local8:Number = ((_arg1.timeStep * _local5) * (_local6 * _local6));
m_gamma = (1 / (_local7 + _local8));
m_beta = (_local8 / (_local7 + _local8));
}
public function SetTarget(_arg1:b2Vec2):void{
if (m_body2.IsSleeping()){
m_body2.WakeUp();
};
m_target = _arg1;
}
override public function GetAnchor2():b2Vec2{
return (m_body2.GetWorldPoint(m_localAnchor));
}
override public function InitVelocityConstraints(_arg1:b2TimeStep):void{
var _local2:b2Body;
var _local3:b2Mat22;
var _local4:Number;
var _local5:Number;
var _local7:Number;
var _local8:Number;
_local2 = m_body2;
_local3 = _local2.m_xf.R;
_local4 = (m_localAnchor.x - _local2.m_sweep.localCenter.x);
_local5 = (m_localAnchor.y - _local2.m_sweep.localCenter.y);
var _local6:Number = ((_local3.col1.x * _local4) + (_local3.col2.x * _local5));
_local5 = ((_local3.col1.y * _local4) + (_local3.col2.y * _local5));
_local4 = _local6;
_local7 = _local2.m_invMass;
_local8 = _local2.m_invI;
K1.col1.x = _local7;
K1.col2.x = 0;
K1.col1.y = 0;
K1.col2.y = _local7;
K2.col1.x = ((_local8 * _local5) * _local5);
K2.col2.x = ((-(_local8) * _local4) * _local5);
K2.col1.y = ((-(_local8) * _local4) * _local5);
K2.col2.y = ((_local8 * _local4) * _local4);
K.SetM(K1);
K.AddM(K2);
K.col1.x = (K.col1.x + m_gamma);
K.col2.y = (K.col2.y + m_gamma);
K.Invert(m_mass);
m_C.x = ((_local2.m_sweep.c.x + _local4) - m_target.x);
m_C.y = ((_local2.m_sweep.c.y + _local5) - m_target.y);
_local2.m_angularVelocity = (_local2.m_angularVelocity * 0.98);
var _local9:Number = (_arg1.dt * m_impulse.x);
var _local10:Number = (_arg1.dt * m_impulse.y);
_local2.m_linearVelocity.x = (_local2.m_linearVelocity.x + (_local7 * _local9));
_local2.m_linearVelocity.y = (_local2.m_linearVelocity.y + (_local7 * _local10));
_local2.m_angularVelocity = (_local2.m_angularVelocity + (_local8 * ((_local4 * _local10) - (_local5 * _local9))));
}
override public function GetAnchor1():b2Vec2{
return (m_target);
}
override public function GetReactionTorque():Number{
return (0);
}
override public function GetReactionForce():b2Vec2{
return (m_impulse);
}
override public function SolvePositionConstraints():Boolean{
return (true);
}
override public function SolveVelocityConstraints(_arg1:b2TimeStep):void{
var _local3:b2Mat22;
var _local4:Number;
var _local5:Number;
var _local2:b2Body = m_body2;
_local3 = _local2.m_xf.R;
var _local6:Number = (m_localAnchor.x - _local2.m_sweep.localCenter.x);
var _local7:Number = (m_localAnchor.y - _local2.m_sweep.localCenter.y);
_local4 = ((_local3.col1.x * _local6) + (_local3.col2.x * _local7));
_local7 = ((_local3.col1.y * _local6) + (_local3.col2.y * _local7));
_local6 = _local4;
var _local8:Number = (_local2.m_linearVelocity.x + (-(_local2.m_angularVelocity) * _local7));
var _local9:Number = (_local2.m_linearVelocity.y + (_local2.m_angularVelocity * _local6));
_local3 = m_mass;
_local4 = ((_local8 + ((m_beta * _arg1.inv_dt) * m_C.x)) + ((m_gamma * _arg1.dt) * m_impulse.x));
_local5 = ((_local9 + ((m_beta * _arg1.inv_dt) * m_C.y)) + ((m_gamma * _arg1.dt) * m_impulse.y));
var _local10:Number = (-(_arg1.inv_dt) * ((_local3.col1.x * _local4) + (_local3.col2.x * _local5)));
var _local11:Number = (-(_arg1.inv_dt) * ((_local3.col1.y * _local4) + (_local3.col2.y * _local5)));
var _local12:Number = m_impulse.x;
var _local13:Number = m_impulse.y;
m_impulse.x = (m_impulse.x + _local10);
m_impulse.y = (m_impulse.y + _local11);
var _local14:Number = m_impulse.Length();
if (_local14 > m_maxForce){
m_impulse.Multiply((m_maxForce / _local14));
};
_local10 = (m_impulse.x - _local12);
_local11 = (m_impulse.y - _local13);
var _local15:Number = (_arg1.dt * _local10);
var _local16:Number = (_arg1.dt * _local11);
_local2.m_linearVelocity.x = (_local2.m_linearVelocity.x + (_local2.m_invMass * _local15));
_local2.m_linearVelocity.y = (_local2.m_linearVelocity.y + (_local2.m_invMass * _local16));
_local2.m_angularVelocity = (_local2.m_angularVelocity + (_local2.m_invI * ((_local6 * _local16) - (_local7 * _local15))));
}
}
}//package Box2D.Dynamics.Joints
Section 58
//b2MouseJointDef (Box2D.Dynamics.Joints.b2MouseJointDef)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
public class b2MouseJointDef extends b2JointDef {
public var timeStep:Number;
public var target:b2Vec2;
public var maxForce:Number;
public var dampingRatio:Number;
public var frequencyHz:Number;
public function b2MouseJointDef(){
target = new b2Vec2();
super();
type = b2Joint.e_mouseJoint;
maxForce = 0;
frequencyHz = 5;
dampingRatio = 0.7;
timeStep = (1 / 60);
}
}
}//package Box2D.Dynamics.Joints
Section 59
//b2PrismaticJoint (Box2D.Dynamics.Joints.b2PrismaticJoint)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Common.*;
public class b2PrismaticJoint extends b2Joint {
public var m_limitForce:Number;
public var m_lowerTranslation:Number;
public var m_localXAxis1:b2Vec2;
public var m_refAngle:Number;
public var m_torque:Number;
public var m_motorForce:Number;
public var m_enableLimit:Boolean;
public var m_angularMass:Number;
public var m_maxMotorForce:Number;
public var m_localYAxis1:b2Vec2;
public var m_force:Number;
public var m_motorMass:Number;
public var m_upperTranslation:Number;
public var m_localAnchor1:b2Vec2;
public var m_localAnchor2:b2Vec2;
public var m_limitState:int;
public var m_linearMass:Number;
public var m_motorJacobian:b2Jacobian;
public var m_limitPositionImpulse:Number;
public var m_motorSpeed:Number;
public var m_enableMotor:Boolean;
public var m_linearJacobian:b2Jacobian;
public function b2PrismaticJoint(_arg1:b2PrismaticJointDef){
var _local2:b2Mat22;
var _local3:Number;
var _local4:Number;
m_localAnchor1 = new b2Vec2();
m_localAnchor2 = new b2Vec2();
m_localXAxis1 = new b2Vec2();
m_localYAxis1 = new b2Vec2();
m_linearJacobian = new b2Jacobian();
m_motorJacobian = new b2Jacobian();
super(_arg1);
m_localAnchor1.SetV(_arg1.localAnchor1);
m_localAnchor2.SetV(_arg1.localAnchor2);
m_localXAxis1.SetV(_arg1.localAxis1);
m_localYAxis1.x = -(m_localXAxis1.y);
m_localYAxis1.y = m_localXAxis1.x;
m_refAngle = _arg1.referenceAngle;
m_linearJacobian.SetZero();
m_linearMass = 0;
m_force = 0;
m_angularMass = 0;
m_torque = 0;
m_motorJacobian.SetZero();
m_motorMass = 0;
m_motorForce = 0;
m_limitForce = 0;
m_limitPositionImpulse = 0;
m_lowerTranslation = _arg1.lowerTranslation;
m_upperTranslation = _arg1.upperTranslation;
m_maxMotorForce = _arg1.maxMotorForce;
m_motorSpeed = _arg1.motorSpeed;
m_enableLimit = _arg1.enableLimit;
m_enableMotor = _arg1.enableMotor;
}
override public function SolveVelocityConstraints(_arg1:b2TimeStep):void{
var _local8:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:Number;
var _local2:b2Body = m_body1;
var _local3:b2Body = m_body2;
var _local4:Number = _local2.m_invMass;
var _local5:Number = _local3.m_invMass;
var _local6:Number = _local2.m_invI;
var _local7:Number = _local3.m_invI;
var _local9:Number = m_linearJacobian.Compute(_local2.m_linearVelocity, _local2.m_angularVelocity, _local3.m_linearVelocity, _local3.m_angularVelocity);
var _local10:Number = ((-(_arg1.inv_dt) * m_linearMass) * _local9);
m_force = (m_force + _local10);
var _local11:Number = (_arg1.dt * _local10);
_local2.m_linearVelocity.x = (_local2.m_linearVelocity.x + ((_local4 * _local11) * m_linearJacobian.linear1.x));
_local2.m_linearVelocity.y = (_local2.m_linearVelocity.y + ((_local4 * _local11) * m_linearJacobian.linear1.y));
_local2.m_angularVelocity = (_local2.m_angularVelocity + ((_local6 * _local11) * m_linearJacobian.angular1));
_local3.m_linearVelocity.x = (_local3.m_linearVelocity.x + ((_local5 * _local11) * m_linearJacobian.linear2.x));
_local3.m_linearVelocity.y = (_local3.m_linearVelocity.y + ((_local5 * _local11) * m_linearJacobian.linear2.y));
_local3.m_angularVelocity = (_local3.m_angularVelocity + ((_local7 * _local11) * m_linearJacobian.angular2));
var _local12:Number = (_local3.m_angularVelocity - _local2.m_angularVelocity);
var _local13:Number = ((-(_arg1.inv_dt) * m_angularMass) * _local12);
m_torque = (m_torque + _local13);
var _local14:Number = (_arg1.dt * _local13);
_local2.m_angularVelocity = (_local2.m_angularVelocity - (_local6 * _local14));
_local3.m_angularVelocity = (_local3.m_angularVelocity + (_local7 * _local14));
if (((m_enableMotor) && (!((m_limitState == e_equalLimits))))){
_local15 = (m_motorJacobian.Compute(_local2.m_linearVelocity, _local2.m_angularVelocity, _local3.m_linearVelocity, _local3.m_angularVelocity) - m_motorSpeed);
_local16 = ((-(_arg1.inv_dt) * m_motorMass) * _local15);
_local17 = m_motorForce;
m_motorForce = b2Math.b2Clamp((m_motorForce + _local16), -(m_maxMotorForce), m_maxMotorForce);
_local16 = (m_motorForce - _local17);
_local11 = (_arg1.dt * _local16);
_local2.m_linearVelocity.x = (_local2.m_linearVelocity.x + ((_local4 * _local11) * m_motorJacobian.linear1.x));
_local2.m_linearVelocity.y = (_local2.m_linearVelocity.y + ((_local4 * _local11) * m_motorJacobian.linear1.y));
_local2.m_angularVelocity = (_local2.m_angularVelocity + ((_local6 * _local11) * m_motorJacobian.angular1));
_local3.m_linearVelocity.x = (_local3.m_linearVelocity.x + ((_local5 * _local11) * m_motorJacobian.linear2.x));
_local3.m_linearVelocity.y = (_local3.m_linearVelocity.y + ((_local5 * _local11) * m_motorJacobian.linear2.y));
_local3.m_angularVelocity = (_local3.m_angularVelocity + ((_local7 * _local11) * m_motorJacobian.angular2));
};
if (((m_enableLimit) && (!((m_limitState == e_inactiveLimit))))){
_local18 = m_motorJacobian.Compute(_local2.m_linearVelocity, _local2.m_angularVelocity, _local3.m_linearVelocity, _local3.m_angularVelocity);
_local19 = ((-(_arg1.inv_dt) * m_motorMass) * _local18);
if (m_limitState == e_equalLimits){
m_limitForce = (m_limitForce + _local19);
} else {
if (m_limitState == e_atLowerLimit){
_local8 = m_limitForce;
m_limitForce = b2Math.b2Max((m_limitForce + _local19), 0);
_local19 = (m_limitForce - _local8);
} else {
if (m_limitState == e_atUpperLimit){
_local8 = m_limitForce;
m_limitForce = b2Math.b2Min((m_limitForce + _local19), 0);
_local19 = (m_limitForce - _local8);
};
};
};
_local11 = (_arg1.dt * _local19);
_local2.m_linearVelocity.x = (_local2.m_linearVelocity.x + ((_local4 * _local11) * m_motorJacobian.linear1.x));
_local2.m_linearVelocity.y = (_local2.m_linearVelocity.y + ((_local4 * _local11) * m_motorJacobian.linear1.y));
_local2.m_angularVelocity = (_local2.m_angularVelocity + ((_local6 * _local11) * m_motorJacobian.angular1));
_local3.m_linearVelocity.x = (_local3.m_linearVelocity.x + ((_local5 * _local11) * m_motorJacobian.linear2.x));
_local3.m_linearVelocity.y = (_local3.m_linearVelocity.y + ((_local5 * _local11) * m_motorJacobian.linear2.y));
_local3.m_angularVelocity = (_local3.m_angularVelocity + ((_local7 * _local11) * m_motorJacobian.angular2));
};
}
override public function GetAnchor1():b2Vec2{
return (m_body1.GetWorldPoint(m_localAnchor1));
}
override public function GetAnchor2():b2Vec2{
return (m_body2.GetWorldPoint(m_localAnchor2));
}
public function GetUpperLimit():Number{
return (m_upperTranslation);
}
public function GetLowerLimit():Number{
return (m_lowerTranslation);
}
public function EnableMotor(_arg1:Boolean):void{
m_enableMotor = _arg1;
}
public function GetJointTranslation():Number{
var _local3:b2Mat22;
var _local1:b2Body = m_body1;
var _local2:b2Body = m_body2;
var _local4:b2Vec2 = _local1.GetWorldPoint(m_localAnchor1);
var _local5:b2Vec2 = _local2.GetWorldPoint(m_localAnchor2);
var _local6:Number = (_local5.x - _local4.x);
var _local7:Number = (_local5.y - _local4.y);
var _local8:b2Vec2 = _local1.GetWorldVector(m_localXAxis1);
var _local9:Number = ((_local8.x * _local6) + (_local8.y * _local7));
return (_local9);
}
public function GetMotorSpeed():Number{
return (m_motorSpeed);
}
override public function GetReactionForce():b2Vec2{
var _local1:b2Mat22 = m_body1.m_xf.R;
var _local2:Number = (m_limitForce * ((_local1.col1.x * m_localXAxis1.x) + (_local1.col2.x * m_localXAxis1.y)));
var _local3:Number = (m_limitForce * ((_local1.col1.y * m_localXAxis1.x) + (_local1.col2.y * m_localXAxis1.y)));
var _local4:Number = (m_force * ((_local1.col1.x * m_localYAxis1.x) + (_local1.col2.x * m_localYAxis1.y)));
var _local5:Number = (m_force * ((_local1.col1.y * m_localYAxis1.x) + (_local1.col2.y * m_localYAxis1.y)));
return (new b2Vec2(((m_limitForce * _local2) + (m_force * _local4)), ((m_limitForce * _local3) + (m_force * _local5))));
}
override public function SolvePositionConstraints():Boolean{
var _local1:Number;
var _local2:Number;
var _local9:b2Mat22;
var _local10:Number;
var _local29:Number;
var _local30:Number;
var _local31:Number;
var _local32:Number;
var _local3:b2Body = m_body1;
var _local4:b2Body = m_body2;
var _local5:Number = _local3.m_invMass;
var _local6:Number = _local4.m_invMass;
var _local7:Number = _local3.m_invI;
var _local8:Number = _local4.m_invI;
_local9 = _local3.m_xf.R;
var _local11:Number = (m_localAnchor1.x - _local3.m_sweep.localCenter.x);
var _local12:Number = (m_localAnchor1.y - _local3.m_sweep.localCenter.y);
_local10 = ((_local9.col1.x * _local11) + (_local9.col2.x * _local12));
_local12 = ((_local9.col1.y * _local11) + (_local9.col2.y * _local12));
_local11 = _local10;
_local9 = _local4.m_xf.R;
var _local13:Number = (m_localAnchor2.x - _local4.m_sweep.localCenter.x);
var _local14:Number = (m_localAnchor2.y - _local4.m_sweep.localCenter.y);
_local10 = ((_local9.col1.x * _local13) + (_local9.col2.x * _local14));
_local14 = ((_local9.col1.y * _local13) + (_local9.col2.y * _local14));
_local13 = _local10;
var _local15:Number = (_local3.m_sweep.c.x + _local11);
var _local16:Number = (_local3.m_sweep.c.y + _local12);
var _local17:Number = (_local4.m_sweep.c.x + _local13);
var _local18:Number = (_local4.m_sweep.c.y + _local14);
var _local19:Number = (_local17 - _local15);
var _local20:Number = (_local18 - _local16);
_local9 = _local3.m_xf.R;
var _local21:Number = ((_local9.col1.x * m_localYAxis1.x) + (_local9.col2.x * m_localYAxis1.y));
var _local22:Number = ((_local9.col1.y * m_localYAxis1.x) + (_local9.col2.y * m_localYAxis1.y));
var _local23:Number = ((_local21 * _local19) + (_local22 * _local20));
_local23 = b2Math.b2Clamp(_local23, -(b2Settings.b2_maxLinearCorrection), b2Settings.b2_maxLinearCorrection);
var _local24:Number = (-(m_linearMass) * _local23);
_local3.m_sweep.c.x = (_local3.m_sweep.c.x + ((_local5 * _local24) * m_linearJacobian.linear1.x));
_local3.m_sweep.c.y = (_local3.m_sweep.c.y + ((_local5 * _local24) * m_linearJacobian.linear1.y));
_local3.m_sweep.a = (_local3.m_sweep.a + ((_local7 * _local24) * m_linearJacobian.angular1));
_local4.m_sweep.c.x = (_local4.m_sweep.c.x + ((_local6 * _local24) * m_linearJacobian.linear2.x));
_local4.m_sweep.c.y = (_local4.m_sweep.c.y + ((_local6 * _local24) * m_linearJacobian.linear2.y));
_local4.m_sweep.a = (_local4.m_sweep.a + ((_local8 * _local24) * m_linearJacobian.angular2));
var _local25:Number = b2Math.b2Abs(_local23);
var _local26:Number = ((_local4.m_sweep.a - _local3.m_sweep.a) - m_refAngle);
_local26 = b2Math.b2Clamp(_local26, -(b2Settings.b2_maxAngularCorrection), b2Settings.b2_maxAngularCorrection);
var _local27:Number = (-(m_angularMass) * _local26);
_local3.m_sweep.a = (_local3.m_sweep.a - (_local3.m_invI * _local27));
_local4.m_sweep.a = (_local4.m_sweep.a + (_local4.m_invI * _local27));
_local3.SynchronizeTransform();
_local4.SynchronizeTransform();
var _local28:Number = b2Math.b2Abs(_local26);
if (((m_enableLimit) && (!((m_limitState == e_inactiveLimit))))){
_local9 = _local3.m_xf.R;
_local11 = (m_localAnchor1.x - _local3.m_sweep.localCenter.x);
_local12 = (m_localAnchor1.y - _local3.m_sweep.localCenter.y);
_local10 = ((_local9.col1.x * _local11) + (_local9.col2.x * _local12));
_local12 = ((_local9.col1.y * _local11) + (_local9.col2.y * _local12));
_local11 = _local10;
_local9 = _local4.m_xf.R;
_local13 = (m_localAnchor2.x - _local4.m_sweep.localCenter.x);
_local14 = (m_localAnchor2.y - _local4.m_sweep.localCenter.y);
_local10 = ((_local9.col1.x * _local13) + (_local9.col2.x * _local14));
_local14 = ((_local9.col1.y * _local13) + (_local9.col2.y * _local14));
_local13 = _local10;
_local15 = (_local3.m_sweep.c.x + _local11);
_local16 = (_local3.m_sweep.c.y + _local12);
_local17 = (_local4.m_sweep.c.x + _local13);
_local18 = (_local4.m_sweep.c.y + _local14);
_local19 = (_local17 - _local15);
_local20 = (_local18 - _local16);
_local9 = _local3.m_xf.R;
_local29 = ((_local9.col1.x * m_localXAxis1.x) + (_local9.col2.x * m_localXAxis1.y));
_local30 = ((_local9.col1.y * m_localXAxis1.x) + (_local9.col2.y * m_localXAxis1.y));
_local31 = ((_local29 * _local19) + (_local30 * _local20));
_local32 = 0;
if (m_limitState == e_equalLimits){
_local1 = b2Math.b2Clamp(_local31, -(b2Settings.b2_maxLinearCorrection), b2Settings.b2_maxLinearCorrection);
_local32 = (-(m_motorMass) * _local1);
_local25 = b2Math.b2Max(_local25, b2Math.b2Abs(_local26));
} else {
if (m_limitState == e_atLowerLimit){
_local1 = (_local31 - m_lowerTranslation);
_local25 = b2Math.b2Max(_local25, -(_local1));
_local1 = b2Math.b2Clamp((_local1 + b2Settings.b2_linearSlop), -(b2Settings.b2_maxLinearCorrection), 0);
_local32 = (-(m_motorMass) * _local1);
_local2 = m_limitPositionImpulse;
m_limitPositionImpulse = b2Math.b2Max((m_limitPositionImpulse + _local32), 0);
_local32 = (m_limitPositionImpulse - _local2);
} else {
if (m_limitState == e_atUpperLimit){
_local1 = (_local31 - m_upperTranslation);
_local25 = b2Math.b2Max(_local25, _local1);
_local1 = b2Math.b2Clamp((_local1 - b2Settings.b2_linearSlop), 0, b2Settings.b2_maxLinearCorrection);
_local32 = (-(m_motorMass) * _local1);
_local2 = m_limitPositionImpulse;
m_limitPositionImpulse = b2Math.b2Min((m_limitPositionImpulse + _local32), 0);
_local32 = (m_limitPositionImpulse - _local2);
};
};
};
_local3.m_sweep.c.x = (_local3.m_sweep.c.x + ((_local5 * _local32) * m_motorJacobian.linear1.x));
_local3.m_sweep.c.y = (_local3.m_sweep.c.y + ((_local5 * _local32) * m_motorJacobian.linear1.y));
_local3.m_sweep.a = (_local3.m_sweep.a + ((_local7 * _local32) * m_motorJacobian.angular1));
_local4.m_sweep.c.x = (_local4.m_sweep.c.x + ((_local6 * _local32) * m_motorJacobian.linear2.x));
_local4.m_sweep.c.y = (_local4.m_sweep.c.y + ((_local6 * _local32) * m_motorJacobian.linear2.y));
_local4.m_sweep.a = (_local4.m_sweep.a + ((_local8 * _local32) * m_motorJacobian.angular2));
_local3.SynchronizeTransform();
_local4.SynchronizeTransform();
};
return ((((_local25 <= b2Settings.b2_linearSlop)) && ((_local28 <= b2Settings.b2_angularSlop))));
}
public function SetMotorSpeed(_arg1:Number):void{
m_motorSpeed = _arg1;
}
public function GetJointSpeed():Number{
var _local3:b2Mat22;
var _local1:b2Body = m_body1;
var _local2:b2Body = m_body2;
_local3 = _local1.m_xf.R;
var _local4:Number = (m_localAnchor1.x - _local1.m_sweep.localCenter.x);
var _local5:Number = (m_localAnchor1.y - _local1.m_sweep.localCenter.y);
var _local6:Number = ((_local3.col1.x * _local4) + (_local3.col2.x * _local5));
_local5 = ((_local3.col1.y * _local4) + (_local3.col2.y * _local5));
_local4 = _local6;
_local3 = _local2.m_xf.R;
var _local7:Number = (m_localAnchor2.x - _local2.m_sweep.localCenter.x);
var _local8:Number = (m_localAnchor2.y - _local2.m_sweep.localCenter.y);
_local6 = ((_local3.col1.x * _local7) + (_local3.col2.x * _local8));
_local8 = ((_local3.col1.y * _local7) + (_local3.col2.y * _local8));
_local7 = _local6;
var _local9:Number = (_local1.m_sweep.c.x + _local4);
var _local10:Number = (_local1.m_sweep.c.y + _local5);
var _local11:Number = (_local2.m_sweep.c.x + _local7);
var _local12:Number = (_local2.m_sweep.c.y + _local8);
var _local13:Number = (_local11 - _local9);
var _local14:Number = (_local12 - _local10);
var _local15:b2Vec2 = _local1.GetWorldVector(m_localXAxis1);
var _local16:b2Vec2 = _local1.m_linearVelocity;
var _local17:b2Vec2 = _local2.m_linearVelocity;
var _local18:Number = _local1.m_angularVelocity;
var _local19:Number = _local2.m_angularVelocity;
var _local20:Number = (((_local13 * (-(_local18) * _local15.y)) + (_local14 * (_local18 * _local15.x))) + ((_local15.x * (((_local17.x + (-(_local19) * _local8)) - _local16.x) - (-(_local18) * _local5))) + (_local15.y * (((_local17.y + (_local19 * _local7)) - _local16.y) - (_local18 * _local4)))));
return (_local20);
}
override public function InitVelocityConstraints(_arg1:b2TimeStep):void{
var _local4:b2Mat22;
var _local5: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 _local2:b2Body = m_body1;
var _local3:b2Body = m_body2;
_local4 = _local2.m_xf.R;
var _local6:Number = (m_localAnchor1.x - _local2.m_sweep.localCenter.x);
var _local7:Number = (m_localAnchor1.y - _local2.m_sweep.localCenter.y);
_local5 = ((_local4.col1.x * _local6) + (_local4.col2.x * _local7));
_local7 = ((_local4.col1.y * _local6) + (_local4.col2.y * _local7));
_local6 = _local5;
_local4 = _local3.m_xf.R;
var _local8:Number = (m_localAnchor2.x - _local3.m_sweep.localCenter.x);
var _local9:Number = (m_localAnchor2.y - _local3.m_sweep.localCenter.y);
_local5 = ((_local4.col1.x * _local8) + (_local4.col2.x * _local9));
_local9 = ((_local4.col1.y * _local8) + (_local4.col2.y * _local9));
_local8 = _local5;
var _local10:Number = _local2.m_invMass;
var _local11:Number = _local3.m_invMass;
var _local12:Number = _local2.m_invI;
var _local13:Number = _local3.m_invI;
_local4 = _local2.m_xf.R;
var _local14:Number = ((_local4.col1.x * m_localYAxis1.x) + (_local4.col2.x * m_localYAxis1.y));
var _local15:Number = ((_local4.col1.y * m_localYAxis1.x) + (_local4.col2.y * m_localYAxis1.y));
var _local16:Number = ((_local3.m_sweep.c.x + _local8) - _local2.m_sweep.c.x);
var _local17:Number = ((_local3.m_sweep.c.y + _local9) - _local2.m_sweep.c.y);
m_linearJacobian.linear1.x = -(_local14);
m_linearJacobian.linear1.y = -(_local15);
m_linearJacobian.linear2.x = _local14;
m_linearJacobian.linear2.y = _local15;
m_linearJacobian.angular1 = -(((_local16 * _local15) - (_local17 * _local14)));
m_linearJacobian.angular2 = ((_local8 * _local15) - (_local9 * _local14));
m_linearMass = (((_local10 + ((_local12 * m_linearJacobian.angular1) * m_linearJacobian.angular1)) + _local11) + ((_local13 * m_linearJacobian.angular2) * m_linearJacobian.angular2));
m_linearMass = (1 / m_linearMass);
m_angularMass = (_local12 + _local13);
if (m_angularMass > Number.MIN_VALUE){
m_angularMass = (1 / m_angularMass);
};
if (((m_enableLimit) || (m_enableMotor))){
_local4 = _local2.m_xf.R;
_local18 = ((_local4.col1.x * m_localXAxis1.x) + (_local4.col2.x * m_localXAxis1.y));
_local19 = ((_local4.col1.y * m_localXAxis1.x) + (_local4.col2.y * m_localXAxis1.y));
m_motorJacobian.linear1.x = -(_local18);
m_motorJacobian.linear1.y = -(_local19);
m_motorJacobian.linear2.x = _local18;
m_motorJacobian.linear2.y = _local19;
m_motorJacobian.angular1 = -(((_local16 * _local19) - (_local17 * _local18)));
m_motorJacobian.angular2 = ((_local8 * _local19) - (_local9 * _local18));
m_motorMass = (((_local10 + ((_local12 * m_motorJacobian.angular1) * m_motorJacobian.angular1)) + _local11) + ((_local13 * m_motorJacobian.angular2) * m_motorJacobian.angular2));
m_motorMass = (1 / m_motorMass);
if (m_enableLimit){
_local20 = (_local16 - _local6);
_local21 = (_local17 - _local7);
_local22 = ((_local18 * _local20) + (_local19 * _local21));
if (b2Math.b2Abs((m_upperTranslation - m_lowerTranslation)) < (2 * b2Settings.b2_linearSlop)){
m_limitState = e_equalLimits;
} else {
if (_local22 <= m_lowerTranslation){
if (m_limitState != e_atLowerLimit){
m_limitForce = 0;
};
m_limitState = e_atLowerLimit;
} else {
if (_local22 >= m_upperTranslation){
if (m_limitState != e_atUpperLimit){
m_limitForce = 0;
};
m_limitState = e_atUpperLimit;
} else {
m_limitState = e_inactiveLimit;
m_limitForce = 0;
};
};
};
};
};
if (m_enableMotor == false){
m_motorForce = 0;
};
if (m_enableLimit == false){
m_limitForce = 0;
};
if (_arg1.warmStarting){
_local23 = (_arg1.dt * ((m_force * m_linearJacobian.linear1.x) + ((m_motorForce + m_limitForce) * m_motorJacobian.linear1.x)));
_local24 = (_arg1.dt * ((m_force * m_linearJacobian.linear1.y) + ((m_motorForce + m_limitForce) * m_motorJacobian.linear1.y)));
_local25 = (_arg1.dt * ((m_force * m_linearJacobian.linear2.x) + ((m_motorForce + m_limitForce) * m_motorJacobian.linear2.x)));
_local26 = (_arg1.dt * ((m_force * m_linearJacobian.linear2.y) + ((m_motorForce + m_limitForce) * m_motorJacobian.linear2.y)));
_local27 = (_arg1.dt * (((m_force * m_linearJacobian.angular1) - m_torque) + ((m_motorForce + m_limitForce) * m_motorJacobian.angular1)));
_local28 = (_arg1.dt * (((m_force * m_linearJacobian.angular2) + m_torque) + ((m_motorForce + m_limitForce) * m_motorJacobian.angular2)));
_local2.m_linearVelocity.x = (_local2.m_linearVelocity.x + (_local10 * _local23));
_local2.m_linearVelocity.y = (_local2.m_linearVelocity.y + (_local10 * _local24));
_local2.m_angularVelocity = (_local2.m_angularVelocity + (_local12 * _local27));
_local3.m_linearVelocity.x = (_local3.m_linearVelocity.x + (_local11 * _local25));
_local3.m_linearVelocity.y = (_local3.m_linearVelocity.y + (_local11 * _local26));
_local3.m_angularVelocity = (_local3.m_angularVelocity + (_local13 * _local28));
} else {
m_force = 0;
m_torque = 0;
m_limitForce = 0;
m_motorForce = 0;
};
m_limitPositionImpulse = 0;
}
public function GetMotorForce():Number{
return (m_motorForce);
}
public function EnableLimit(_arg1:Boolean):void{
m_enableLimit = _arg1;
}
public function SetMaxMotorForce(_arg1:Number):void{
m_maxMotorForce = _arg1;
}
override public function GetReactionTorque():Number{
return (m_torque);
}
public function IsLimitEnabled():Boolean{
return (m_enableLimit);
}
public function IsMotorEnabled():Boolean{
return (m_enableMotor);
}
public function SetLimits(_arg1:Number, _arg2:Number):void{
m_lowerTranslation = _arg1;
m_upperTranslation = _arg2;
}
}
}//package Box2D.Dynamics.Joints
Section 60
//b2PrismaticJointDef (Box2D.Dynamics.Joints.b2PrismaticJointDef)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
public class b2PrismaticJointDef extends b2JointDef {
public var motorSpeed:Number;
public var localAxis1:b2Vec2;
public var referenceAngle:Number;
public var upperTranslation:Number;
public var localAnchor1:b2Vec2;
public var localAnchor2:b2Vec2;
public var enableLimit:Boolean;
public var enableMotor:Boolean;
public var maxMotorForce:Number;
public var lowerTranslation:Number;
public function b2PrismaticJointDef(){
localAnchor1 = new b2Vec2();
localAnchor2 = new b2Vec2();
localAxis1 = new b2Vec2();
super();
type = b2Joint.e_prismaticJoint;
localAxis1.Set(1, 0);
referenceAngle = 0;
enableLimit = false;
lowerTranslation = 0;
upperTranslation = 0;
enableMotor = false;
maxMotorForce = 0;
motorSpeed = 0;
}
public function Initialize(_arg1:b2Body, _arg2:b2Body, _arg3:b2Vec2, _arg4:b2Vec2):void{
body1 = _arg1;
body2 = _arg2;
localAnchor1 = body1.GetLocalPoint(_arg3);
localAnchor2 = body2.GetLocalPoint(_arg3);
localAxis1 = body1.GetLocalVector(_arg4);
referenceAngle = (body2.GetAngle() - body1.GetAngle());
}
}
}//package Box2D.Dynamics.Joints
Section 61
//b2PulleyJoint (Box2D.Dynamics.Joints.b2PulleyJoint)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Common.*;
public class b2PulleyJoint extends b2Joint {
public var m_limitState1:int;
public var m_limitState2:int;
public var m_ground:b2Body;
public var m_maxLength2:Number;
public var m_maxLength1:Number;
public var m_limitPositionImpulse1:Number;
public var m_limitPositionImpulse2:Number;
public var m_force:Number;
public var m_constant:Number;
public var m_positionImpulse:Number;
public var m_state:int;
public var m_ratio:Number;
public var m_groundAnchor1:b2Vec2;
public var m_groundAnchor2:b2Vec2;
public var m_localAnchor1:b2Vec2;
public var m_localAnchor2:b2Vec2;
public var m_limitMass1:Number;
public var m_limitMass2:Number;
public var m_pulleyMass:Number;
public var m_u1:b2Vec2;
public var m_limitForce1:Number;
public var m_limitForce2:Number;
public var m_u2:b2Vec2;
public static const b2_minPulleyLength:Number = 2;
public function b2PulleyJoint(_arg1:b2PulleyJointDef){
var _local2:b2Mat22;
var _local3:Number;
var _local4:Number;
m_groundAnchor1 = new b2Vec2();
m_groundAnchor2 = new b2Vec2();
m_localAnchor1 = new b2Vec2();
m_localAnchor2 = new b2Vec2();
m_u1 = new b2Vec2();
m_u2 = new b2Vec2();
super(_arg1);
m_ground = m_body1.m_world.m_groundBody;
m_groundAnchor1.x = (_arg1.groundAnchor1.x - m_ground.m_xf.position.x);
m_groundAnchor1.y = (_arg1.groundAnchor1.y - m_ground.m_xf.position.y);
m_groundAnchor2.x = (_arg1.groundAnchor2.x - m_ground.m_xf.position.x);
m_groundAnchor2.y = (_arg1.groundAnchor2.y - m_ground.m_xf.position.y);
m_localAnchor1.SetV(_arg1.localAnchor1);
m_localAnchor2.SetV(_arg1.localAnchor2);
m_ratio = _arg1.ratio;
m_constant = (_arg1.length1 + (m_ratio * _arg1.length2));
m_maxLength1 = b2Math.b2Min(_arg1.maxLength1, (m_constant - (m_ratio * b2_minPulleyLength)));
m_maxLength2 = b2Math.b2Min(_arg1.maxLength2, ((m_constant - b2_minPulleyLength) / m_ratio));
m_force = 0;
m_limitForce1 = 0;
m_limitForce2 = 0;
}
public function GetGroundAnchor2():b2Vec2{
var _local1:b2Vec2 = m_ground.m_xf.position.Copy();
_local1.Add(m_groundAnchor2);
return (_local1);
}
override public function GetAnchor1():b2Vec2{
return (m_body1.GetWorldPoint(m_localAnchor1));
}
override public function GetAnchor2():b2Vec2{
return (m_body2.GetWorldPoint(m_localAnchor2));
}
override public function GetReactionForce():b2Vec2{
var _local1:b2Vec2 = m_u2.Copy();
_local1.Multiply(m_force);
return (_local1);
}
override public function SolvePositionConstraints():Boolean{
var _local3:b2Mat22;
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 _local1:b2Body = m_body1;
var _local2:b2Body = m_body2;
var _local4:Number = (m_ground.m_xf.position.x + m_groundAnchor1.x);
var _local5:Number = (m_ground.m_xf.position.y + m_groundAnchor1.y);
var _local6:Number = (m_ground.m_xf.position.x + m_groundAnchor2.x);
var _local7:Number = (m_ground.m_xf.position.y + m_groundAnchor2.y);
var _local23:Number = 0;
if (m_state == e_atUpperLimit){
_local3 = _local1.m_xf.R;
_local8 = (m_localAnchor1.x - _local1.m_sweep.localCenter.x);
_local9 = (m_localAnchor1.y - _local1.m_sweep.localCenter.y);
_local22 = ((_local3.col1.x * _local8) + (_local3.col2.x * _local9));
_local9 = ((_local3.col1.y * _local8) + (_local3.col2.y * _local9));
_local8 = _local22;
_local3 = _local2.m_xf.R;
_local10 = (m_localAnchor2.x - _local2.m_sweep.localCenter.x);
_local11 = (m_localAnchor2.y - _local2.m_sweep.localCenter.y);
_local22 = ((_local3.col1.x * _local10) + (_local3.col2.x * _local11));
_local11 = ((_local3.col1.y * _local10) + (_local3.col2.y * _local11));
_local10 = _local22;
_local12 = (_local1.m_sweep.c.x + _local8);
_local13 = (_local1.m_sweep.c.y + _local9);
_local14 = (_local2.m_sweep.c.x + _local10);
_local15 = (_local2.m_sweep.c.y + _local11);
m_u1.Set((_local12 - _local4), (_local13 - _local5));
m_u2.Set((_local14 - _local6), (_local15 - _local7));
_local16 = m_u1.Length();
_local17 = m_u2.Length();
if (_local16 > b2Settings.b2_linearSlop){
m_u1.Multiply((1 / _local16));
} else {
m_u1.SetZero();
};
if (_local17 > b2Settings.b2_linearSlop){
m_u2.Multiply((1 / _local17));
} else {
m_u2.SetZero();
};
_local18 = ((m_constant - _local16) - (m_ratio * _local17));
_local23 = b2Math.b2Max(_local23, -(_local18));
_local18 = b2Math.b2Clamp((_local18 + b2Settings.b2_linearSlop), -(b2Settings.b2_maxLinearCorrection), 0);
_local19 = (-(m_pulleyMass) * _local18);
_local20 = m_positionImpulse;
m_positionImpulse = b2Math.b2Max(0, (m_positionImpulse + _local19));
_local19 = (m_positionImpulse - _local20);
_local12 = (-(_local19) * m_u1.x);
_local13 = (-(_local19) * m_u1.y);
_local14 = ((-(m_ratio) * _local19) * m_u2.x);
_local15 = ((-(m_ratio) * _local19) * m_u2.y);
_local1.m_sweep.c.x = (_local1.m_sweep.c.x + (_local1.m_invMass * _local12));
_local1.m_sweep.c.y = (_local1.m_sweep.c.y + (_local1.m_invMass * _local13));
_local1.m_sweep.a = (_local1.m_sweep.a + (_local1.m_invI * ((_local8 * _local13) - (_local9 * _local12))));
_local2.m_sweep.c.x = (_local2.m_sweep.c.x + (_local2.m_invMass * _local14));
_local2.m_sweep.c.y = (_local2.m_sweep.c.y + (_local2.m_invMass * _local15));
_local2.m_sweep.a = (_local2.m_sweep.a + (_local2.m_invI * ((_local10 * _local15) - (_local11 * _local14))));
_local1.SynchronizeTransform();
_local2.SynchronizeTransform();
};
if (m_limitState1 == e_atUpperLimit){
_local3 = _local1.m_xf.R;
_local8 = (m_localAnchor1.x - _local1.m_sweep.localCenter.x);
_local9 = (m_localAnchor1.y - _local1.m_sweep.localCenter.y);
_local22 = ((_local3.col1.x * _local8) + (_local3.col2.x * _local9));
_local9 = ((_local3.col1.y * _local8) + (_local3.col2.y * _local9));
_local8 = _local22;
_local12 = (_local1.m_sweep.c.x + _local8);
_local13 = (_local1.m_sweep.c.y + _local9);
m_u1.Set((_local12 - _local4), (_local13 - _local5));
_local16 = m_u1.Length();
if (_local16 > b2Settings.b2_linearSlop){
m_u1.x = (m_u1.x * (1 / _local16));
m_u1.y = (m_u1.y * (1 / _local16));
} else {
m_u1.SetZero();
};
_local18 = (m_maxLength1 - _local16);
_local23 = b2Math.b2Max(_local23, -(_local18));
_local18 = b2Math.b2Clamp((_local18 + b2Settings.b2_linearSlop), -(b2Settings.b2_maxLinearCorrection), 0);
_local19 = (-(m_limitMass1) * _local18);
_local21 = m_limitPositionImpulse1;
m_limitPositionImpulse1 = b2Math.b2Max(0, (m_limitPositionImpulse1 + _local19));
_local19 = (m_limitPositionImpulse1 - _local21);
_local12 = (-(_local19) * m_u1.x);
_local13 = (-(_local19) * m_u1.y);
_local1.m_sweep.c.x = (_local1.m_sweep.c.x + (_local1.m_invMass * _local12));
_local1.m_sweep.c.y = (_local1.m_sweep.c.y + (_local1.m_invMass * _local13));
_local1.m_sweep.a = (_local1.m_sweep.a + (_local1.m_invI * ((_local8 * _local13) - (_local9 * _local12))));
_local1.SynchronizeTransform();
};
if (m_limitState2 == e_atUpperLimit){
_local3 = _local2.m_xf.R;
_local10 = (m_localAnchor2.x - _local2.m_sweep.localCenter.x);
_local11 = (m_localAnchor2.y - _local2.m_sweep.localCenter.y);
_local22 = ((_local3.col1.x * _local10) + (_local3.col2.x * _local11));
_local11 = ((_local3.col1.y * _local10) + (_local3.col2.y * _local11));
_local10 = _local22;
_local14 = (_local2.m_sweep.c.x + _local10);
_local15 = (_local2.m_sweep.c.y + _local11);
m_u2.Set((_local14 - _local6), (_local15 - _local7));
_local17 = m_u2.Length();
if (_local17 > b2Settings.b2_linearSlop){
m_u2.x = (m_u2.x * (1 / _local17));
m_u2.y = (m_u2.y * (1 / _local17));
} else {
m_u2.SetZero();
};
_local18 = (m_maxLength2 - _local17);
_local23 = b2Math.b2Max(_local23, -(_local18));
_local18 = b2Math.b2Clamp((_local18 + b2Settings.b2_linearSlop), -(b2Settings.b2_maxLinearCorrection), 0);
_local19 = (-(m_limitMass2) * _local18);
_local21 = m_limitPositionImpulse2;
m_limitPositionImpulse2 = b2Math.b2Max(0, (m_limitPositionImpulse2 + _local19));
_local19 = (m_limitPositionImpulse2 - _local21);
_local14 = (-(_local19) * m_u2.x);
_local15 = (-(_local19) * m_u2.y);
_local2.m_sweep.c.x = (_local2.m_sweep.c.x + (_local2.m_invMass * _local14));
_local2.m_sweep.c.y = (_local2.m_sweep.c.y + (_local2.m_invMass * _local15));
_local2.m_sweep.a = (_local2.m_sweep.a + (_local2.m_invI * ((_local10 * _local15) - (_local11 * _local14))));
_local2.SynchronizeTransform();
};
return ((_local23 < b2Settings.b2_linearSlop));
}
override public function InitVelocityConstraints(_arg1:b2TimeStep):void{
var _local4:b2Mat22;
var _local23:Number;
var _local24:Number;
var _local25:Number;
var _local26:Number;
var _local2:b2Body = m_body1;
var _local3:b2Body = m_body2;
_local4 = _local2.m_xf.R;
var _local5:Number = (m_localAnchor1.x - _local2.m_sweep.localCenter.x);
var _local6:Number = (m_localAnchor1.y - _local2.m_sweep.localCenter.y);
var _local7:Number = ((_local4.col1.x * _local5) + (_local4.col2.x * _local6));
_local6 = ((_local4.col1.y * _local5) + (_local4.col2.y * _local6));
_local5 = _local7;
_local4 = _local3.m_xf.R;
var _local8:Number = (m_localAnchor2.x - _local3.m_sweep.localCenter.x);
var _local9:Number = (m_localAnchor2.y - _local3.m_sweep.localCenter.y);
_local7 = ((_local4.col1.x * _local8) + (_local4.col2.x * _local9));
_local9 = ((_local4.col1.y * _local8) + (_local4.col2.y * _local9));
_local8 = _local7;
var _local10:Number = (_local2.m_sweep.c.x + _local5);
var _local11:Number = (_local2.m_sweep.c.y + _local6);
var _local12:Number = (_local3.m_sweep.c.x + _local8);
var _local13:Number = (_local3.m_sweep.c.y + _local9);
var _local14:Number = (m_ground.m_xf.position.x + m_groundAnchor1.x);
var _local15:Number = (m_ground.m_xf.position.y + m_groundAnchor1.y);
var _local16:Number = (m_ground.m_xf.position.x + m_groundAnchor2.x);
var _local17:Number = (m_ground.m_xf.position.y + m_groundAnchor2.y);
m_u1.Set((_local10 - _local14), (_local11 - _local15));
m_u2.Set((_local12 - _local16), (_local13 - _local17));
var _local18:Number = m_u1.Length();
var _local19:Number = m_u2.Length();
if (_local18 > b2Settings.b2_linearSlop){
m_u1.Multiply((1 / _local18));
} else {
m_u1.SetZero();
};
if (_local19 > b2Settings.b2_linearSlop){
m_u2.Multiply((1 / _local19));
} else {
m_u2.SetZero();
};
var _local20:Number = ((m_constant - _local18) - (m_ratio * _local19));
if (_local20 > 0){
m_state = e_inactiveLimit;
m_force = 0;
} else {
m_state = e_atUpperLimit;
m_positionImpulse = 0;
};
if (_local18 < m_maxLength1){
m_limitState1 = e_inactiveLimit;
m_limitForce1 = 0;
} else {
m_limitState1 = e_atUpperLimit;
m_limitPositionImpulse1 = 0;
};
if (_local19 < m_maxLength2){
m_limitState2 = e_inactiveLimit;
m_limitForce2 = 0;
} else {
m_limitState2 = e_atUpperLimit;
m_limitPositionImpulse2 = 0;
};
var _local21:Number = ((_local5 * m_u1.y) - (_local6 * m_u1.x));
var _local22:Number = ((_local8 * m_u2.y) - (_local9 * m_u2.x));
m_limitMass1 = (_local2.m_invMass + ((_local2.m_invI * _local21) * _local21));
m_limitMass2 = (_local3.m_invMass + ((_local3.m_invI * _local22) * _local22));
m_pulleyMass = (m_limitMass1 + ((m_ratio * m_ratio) * m_limitMass2));
m_limitMass1 = (1 / m_limitMass1);
m_limitMass2 = (1 / m_limitMass2);
m_pulleyMass = (1 / m_pulleyMass);
if (_arg1.warmStarting){
_local23 = ((_arg1.dt * (-(m_force) - m_limitForce1)) * m_u1.x);
_local24 = ((_arg1.dt * (-(m_force) - m_limitForce1)) * m_u1.y);
_local25 = ((_arg1.dt * ((-(m_ratio) * m_force) - m_limitForce2)) * m_u2.x);
_local26 = ((_arg1.dt * ((-(m_ratio) * m_force) - m_limitForce2)) * m_u2.y);
_local2.m_linearVelocity.x = (_local2.m_linearVelocity.x + (_local2.m_invMass * _local23));
_local2.m_linearVelocity.y = (_local2.m_linearVelocity.y + (_local2.m_invMass * _local24));
_local2.m_angularVelocity = (_local2.m_angularVelocity + (_local2.m_invI * ((_local5 * _local24) - (_local6 * _local23))));
_local3.m_linearVelocity.x = (_local3.m_linearVelocity.x + (_local3.m_invMass * _local25));
_local3.m_linearVelocity.y = (_local3.m_linearVelocity.y + (_local3.m_invMass * _local26));
_local3.m_angularVelocity = (_local3.m_angularVelocity + (_local3.m_invI * ((_local8 * _local26) - (_local9 * _local25))));
} else {
m_force = 0;
m_limitForce1 = 0;
m_limitForce2 = 0;
};
}
override public function GetReactionTorque():Number{
return (0);
}
public function GetRatio():Number{
return (m_ratio);
}
override public function SolveVelocityConstraints(_arg1:b2TimeStep):void{
var _local4:b2Mat22;
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 _local2:b2Body = m_body1;
var _local3:b2Body = m_body2;
_local4 = _local2.m_xf.R;
var _local5:Number = (m_localAnchor1.x - _local2.m_sweep.localCenter.x);
var _local6:Number = (m_localAnchor1.y - _local2.m_sweep.localCenter.y);
var _local7:Number = ((_local4.col1.x * _local5) + (_local4.col2.x * _local6));
_local6 = ((_local4.col1.y * _local5) + (_local4.col2.y * _local6));
_local5 = _local7;
_local4 = _local3.m_xf.R;
var _local8:Number = (m_localAnchor2.x - _local3.m_sweep.localCenter.x);
var _local9:Number = (m_localAnchor2.y - _local3.m_sweep.localCenter.y);
_local7 = ((_local4.col1.x * _local8) + (_local4.col2.x * _local9));
_local9 = ((_local4.col1.y * _local8) + (_local4.col2.y * _local9));
_local8 = _local7;
if (m_state == e_atUpperLimit){
_local10 = (_local2.m_linearVelocity.x + (-(_local2.m_angularVelocity) * _local6));
_local11 = (_local2.m_linearVelocity.y + (_local2.m_angularVelocity * _local5));
_local12 = (_local3.m_linearVelocity.x + (-(_local3.m_angularVelocity) * _local9));
_local13 = (_local3.m_linearVelocity.y + (_local3.m_angularVelocity * _local8));
_local18 = (-(((m_u1.x * _local10) + (m_u1.y * _local11))) - (m_ratio * ((m_u2.x * _local12) + (m_u2.y * _local13))));
_local19 = ((-(_arg1.inv_dt) * m_pulleyMass) * _local18);
_local20 = m_force;
m_force = b2Math.b2Max(0, (m_force + _local19));
_local19 = (m_force - _local20);
_local14 = ((-(_arg1.dt) * _local19) * m_u1.x);
_local15 = ((-(_arg1.dt) * _local19) * m_u1.y);
_local16 = (((-(_arg1.dt) * m_ratio) * _local19) * m_u2.x);
_local17 = (((-(_arg1.dt) * m_ratio) * _local19) * m_u2.y);
_local2.m_linearVelocity.x = (_local2.m_linearVelocity.x + (_local2.m_invMass * _local14));
_local2.m_linearVelocity.y = (_local2.m_linearVelocity.y + (_local2.m_invMass * _local15));
_local2.m_angularVelocity = (_local2.m_angularVelocity + (_local2.m_invI * ((_local5 * _local15) - (_local6 * _local14))));
_local3.m_linearVelocity.x = (_local3.m_linearVelocity.x + (_local3.m_invMass * _local16));
_local3.m_linearVelocity.y = (_local3.m_linearVelocity.y + (_local3.m_invMass * _local17));
_local3.m_angularVelocity = (_local3.m_angularVelocity + (_local3.m_invI * ((_local8 * _local17) - (_local9 * _local16))));
};
if (m_limitState1 == e_atUpperLimit){
_local10 = (_local2.m_linearVelocity.x + (-(_local2.m_angularVelocity) * _local6));
_local11 = (_local2.m_linearVelocity.y + (_local2.m_angularVelocity * _local5));
_local18 = -(((m_u1.x * _local10) + (m_u1.y * _local11)));
_local19 = ((-(_arg1.inv_dt) * m_limitMass1) * _local18);
_local20 = m_limitForce1;
m_limitForce1 = b2Math.b2Max(0, (m_limitForce1 + _local19));
_local19 = (m_limitForce1 - _local20);
_local14 = ((-(_arg1.dt) * _local19) * m_u1.x);
_local15 = ((-(_arg1.dt) * _local19) * m_u1.y);
_local2.m_linearVelocity.x = (_local2.m_linearVelocity.x + (_local2.m_invMass * _local14));
_local2.m_linearVelocity.y = (_local2.m_linearVelocity.y + (_local2.m_invMass * _local15));
_local2.m_angularVelocity = (_local2.m_angularVelocity + (_local2.m_invI * ((_local5 * _local15) - (_local6 * _local14))));
};
if (m_limitState2 == e_atUpperLimit){
_local12 = (_local3.m_linearVelocity.x + (-(_local3.m_angularVelocity) * _local9));
_local13 = (_local3.m_linearVelocity.y + (_local3.m_angularVelocity * _local8));
_local18 = -(((m_u2.x * _local12) + (m_u2.y * _local13)));
_local19 = ((-(_arg1.inv_dt) * m_limitMass2) * _local18);
_local20 = m_limitForce2;
m_limitForce2 = b2Math.b2Max(0, (m_limitForce2 + _local19));
_local19 = (m_limitForce2 - _local20);
_local16 = ((-(_arg1.dt) * _local19) * m_u2.x);
_local17 = ((-(_arg1.dt) * _local19) * m_u2.y);
_local3.m_linearVelocity.x = (_local3.m_linearVelocity.x + (_local3.m_invMass * _local16));
_local3.m_linearVelocity.y = (_local3.m_linearVelocity.y + (_local3.m_invMass * _local17));
_local3.m_angularVelocity = (_local3.m_angularVelocity + (_local3.m_invI * ((_local8 * _local17) - (_local9 * _local16))));
};
}
public function GetLength1():Number{
var _local1:b2Vec2 = m_body1.GetWorldPoint(m_localAnchor1);
var _local2:Number = (m_ground.m_xf.position.x + m_groundAnchor1.x);
var _local3:Number = (m_ground.m_xf.position.y + m_groundAnchor1.y);
var _local4:Number = (_local1.x - _local2);
var _local5:Number = (_local1.y - _local3);
return (Math.sqrt(((_local4 * _local4) + (_local5 * _local5))));
}
public function GetLength2():Number{
var _local1:b2Vec2 = m_body2.GetWorldPoint(m_localAnchor2);
var _local2:Number = (m_ground.m_xf.position.x + m_groundAnchor2.x);
var _local3:Number = (m_ground.m_xf.position.y + m_groundAnchor2.y);
var _local4:Number = (_local1.x - _local2);
var _local5:Number = (_local1.y - _local3);
return (Math.sqrt(((_local4 * _local4) + (_local5 * _local5))));
}
public function GetGroundAnchor1():b2Vec2{
var _local1:b2Vec2 = m_ground.m_xf.position.Copy();
_local1.Add(m_groundAnchor1);
return (_local1);
}
}
}//package Box2D.Dynamics.Joints
Section 62
//b2PulleyJointDef (Box2D.Dynamics.Joints.b2PulleyJointDef)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
public class b2PulleyJointDef extends b2JointDef {
public var maxLength1:Number;
public var maxLength2:Number;
public var length1:Number;
public var localAnchor1:b2Vec2;
public var localAnchor2:b2Vec2;
public var groundAnchor1:b2Vec2;
public var groundAnchor2:b2Vec2;
public var ratio:Number;
public var length2:Number;
public function b2PulleyJointDef(){
groundAnchor1 = new b2Vec2();
groundAnchor2 = new b2Vec2();
localAnchor1 = new b2Vec2();
localAnchor2 = new b2Vec2();
super();
type = b2Joint.e_pulleyJoint;
groundAnchor1.Set(-1, 1);
groundAnchor2.Set(1, 1);
localAnchor1.Set(-1, 0);
localAnchor2.Set(1, 0);
length1 = 0;
maxLength1 = 0;
length2 = 0;
maxLength2 = 0;
ratio = 1;
collideConnected = true;
}
public function Initialize(_arg1:b2Body, _arg2:b2Body, _arg3:b2Vec2, _arg4:b2Vec2, _arg5:b2Vec2, _arg6:b2Vec2, _arg7:Number):void{
body1 = _arg1;
body2 = _arg2;
groundAnchor1.SetV(_arg3);
groundAnchor2.SetV(_arg4);
localAnchor1 = body1.GetLocalPoint(_arg5);
localAnchor2 = body2.GetLocalPoint(_arg6);
var _local8:Number = (_arg5.x - _arg3.x);
var _local9:Number = (_arg5.y - _arg3.y);
length1 = Math.sqrt(((_local8 * _local8) + (_local9 * _local9)));
var _local10:Number = (_arg6.x - _arg4.x);
var _local11:Number = (_arg6.y - _arg4.y);
length2 = Math.sqrt(((_local10 * _local10) + (_local11 * _local11)));
ratio = _arg7;
var _local12:Number = (length1 + (ratio * length2));
maxLength1 = (_local12 - (ratio * b2PulleyJoint.b2_minPulleyLength));
maxLength2 = ((_local12 - b2PulleyJoint.b2_minPulleyLength) / ratio);
}
}
}//package Box2D.Dynamics.Joints
Section 63
//b2RevoluteJoint (Box2D.Dynamics.Joints.b2RevoluteJoint)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Common.*;
public class b2RevoluteJoint extends b2Joint {
public var m_limitForce:Number;
public var m_pivotMass:b2Mat22;
public var m_motorForce:Number;
public var m_enableLimit:Boolean;
public var m_limitState:int;
public var m_motorMass:Number;
public var m_localAnchor1:b2Vec2;
public var m_localAnchor2:b2Vec2;
private var K1:b2Mat22;
private var K2:b2Mat22;
private var K3:b2Mat22;
private var K:b2Mat22;
public var m_pivotForce:b2Vec2;
public var m_enableMotor:Boolean;
public var m_referenceAngle:Number;
public var m_limitPositionImpulse:Number;
public var m_motorSpeed:Number;
public var m_upperAngle:Number;
public var m_lowerAngle:Number;
public var m_maxMotorTorque:Number;
public static var tImpulse:b2Vec2 = new b2Vec2();
public function b2RevoluteJoint(_arg1:b2RevoluteJointDef){
K = new b2Mat22();
K1 = new b2Mat22();
K2 = new b2Mat22();
K3 = new b2Mat22();
m_localAnchor1 = new b2Vec2();
m_localAnchor2 = new b2Vec2();
m_pivotForce = new b2Vec2();
m_pivotMass = new b2Mat22();
super(_arg1);
m_localAnchor1.SetV(_arg1.localAnchor1);
m_localAnchor2.SetV(_arg1.localAnchor2);
m_referenceAngle = _arg1.referenceAngle;
m_pivotForce.Set(0, 0);
m_motorForce = 0;
m_limitForce = 0;
m_limitPositionImpulse = 0;
m_lowerAngle = _arg1.lowerAngle;
m_upperAngle = _arg1.upperAngle;
m_maxMotorTorque = _arg1.maxMotorTorque;
m_motorSpeed = _arg1.motorSpeed;
m_enableLimit = _arg1.enableLimit;
m_enableMotor = _arg1.enableMotor;
}
override public function SolveVelocityConstraints(_arg1:b2TimeStep):void{
var _local4:b2Mat22;
var _local5:Number;
var _local10:Number;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:Number;
var _local20:Number;
var _local21:Number;
var _local2:b2Body = m_body1;
var _local3:b2Body = m_body2;
_local4 = _local2.m_xf.R;
var _local6:Number = (m_localAnchor1.x - _local2.m_sweep.localCenter.x);
var _local7:Number = (m_localAnchor1.y - _local2.m_sweep.localCenter.y);
_local5 = ((_local4.col1.x * _local6) + (_local4.col2.x * _local7));
_local7 = ((_local4.col1.y * _local6) + (_local4.col2.y * _local7));
_local6 = _local5;
_local4 = _local3.m_xf.R;
var _local8:Number = (m_localAnchor2.x - _local3.m_sweep.localCenter.x);
var _local9:Number = (m_localAnchor2.y - _local3.m_sweep.localCenter.y);
_local5 = ((_local4.col1.x * _local8) + (_local4.col2.x * _local9));
_local9 = ((_local4.col1.y * _local8) + (_local4.col2.y * _local9));
_local8 = _local5;
var _local11:Number = (((_local3.m_linearVelocity.x + (-(_local3.m_angularVelocity) * _local9)) - _local2.m_linearVelocity.x) - (-(_local2.m_angularVelocity) * _local7));
var _local12:Number = (((_local3.m_linearVelocity.y + (_local3.m_angularVelocity * _local8)) - _local2.m_linearVelocity.y) - (_local2.m_angularVelocity * _local6));
var _local13:Number = (-(_arg1.inv_dt) * ((m_pivotMass.col1.x * _local11) + (m_pivotMass.col2.x * _local12)));
var _local14:Number = (-(_arg1.inv_dt) * ((m_pivotMass.col1.y * _local11) + (m_pivotMass.col2.y * _local12)));
m_pivotForce.x = (m_pivotForce.x + _local13);
m_pivotForce.y = (m_pivotForce.y + _local14);
var _local15:Number = (_arg1.dt * _local13);
_local16 = (_arg1.dt * _local14);
_local2.m_linearVelocity.x = (_local2.m_linearVelocity.x - (_local2.m_invMass * _local15));
_local2.m_linearVelocity.y = (_local2.m_linearVelocity.y - (_local2.m_invMass * _local16));
_local2.m_angularVelocity = (_local2.m_angularVelocity - (_local2.m_invI * ((_local6 * _local16) - (_local7 * _local15))));
_local3.m_linearVelocity.x = (_local3.m_linearVelocity.x + (_local3.m_invMass * _local15));
_local3.m_linearVelocity.y = (_local3.m_linearVelocity.y + (_local3.m_invMass * _local16));
_local3.m_angularVelocity = (_local3.m_angularVelocity + (_local3.m_invI * ((_local8 * _local16) - (_local9 * _local15))));
if (((m_enableMotor) && (!((m_limitState == e_equalLimits))))){
_local17 = ((_local3.m_angularVelocity - _local2.m_angularVelocity) - m_motorSpeed);
_local18 = ((-(_arg1.inv_dt) * m_motorMass) * _local17);
_local19 = m_motorForce;
m_motorForce = b2Math.b2Clamp((m_motorForce + _local18), -(m_maxMotorTorque), m_maxMotorTorque);
_local18 = (m_motorForce - _local19);
_local2.m_angularVelocity = (_local2.m_angularVelocity - ((_local2.m_invI * _arg1.dt) * _local18));
_local3.m_angularVelocity = (_local3.m_angularVelocity + ((_local3.m_invI * _arg1.dt) * _local18));
};
if (((m_enableLimit) && (!((m_limitState == e_inactiveLimit))))){
_local20 = (_local3.m_angularVelocity - _local2.m_angularVelocity);
_local21 = ((-(_arg1.inv_dt) * m_motorMass) * _local20);
if (m_limitState == e_equalLimits){
m_limitForce = (m_limitForce + _local21);
} else {
if (m_limitState == e_atLowerLimit){
_local10 = m_limitForce;
m_limitForce = b2Math.b2Max((m_limitForce + _local21), 0);
_local21 = (m_limitForce - _local10);
} else {
if (m_limitState == e_atUpperLimit){
_local10 = m_limitForce;
m_limitForce = b2Math.b2Min((m_limitForce + _local21), 0);
_local21 = (m_limitForce - _local10);
};
};
};
_local2.m_angularVelocity = (_local2.m_angularVelocity - ((_local2.m_invI * _arg1.dt) * _local21));
_local3.m_angularVelocity = (_local3.m_angularVelocity + ((_local3.m_invI * _arg1.dt) * _local21));
};
}
override public function GetAnchor1():b2Vec2{
return (m_body1.GetWorldPoint(m_localAnchor1));
}
override public function GetAnchor2():b2Vec2{
return (m_body2.GetWorldPoint(m_localAnchor2));
}
public function GetUpperLimit():Number{
return (m_upperAngle);
}
public function GetLowerLimit():Number{
return (m_lowerAngle);
}
public function EnableMotor(_arg1:Boolean):void{
m_enableMotor = _arg1;
}
public function GetMotorSpeed():Number{
return (m_motorSpeed);
}
override public function GetReactionForce():b2Vec2{
return (m_pivotForce);
}
override public function SolvePositionConstraints():Boolean{
var _local1:Number;
var _local2:Number;
var _local6:b2Mat22;
var _local25:Number;
var _local26:Number;
var _local3:b2Body = m_body1;
var _local4:b2Body = m_body2;
var _local5:Number = 0;
_local6 = _local3.m_xf.R;
var _local7:Number = (m_localAnchor1.x - _local3.m_sweep.localCenter.x);
var _local8:Number = (m_localAnchor1.y - _local3.m_sweep.localCenter.y);
var _local9:Number = ((_local6.col1.x * _local7) + (_local6.col2.x * _local8));
_local8 = ((_local6.col1.y * _local7) + (_local6.col2.y * _local8));
_local7 = _local9;
_local6 = _local4.m_xf.R;
var _local10:Number = (m_localAnchor2.x - _local4.m_sweep.localCenter.x);
var _local11:Number = (m_localAnchor2.y - _local4.m_sweep.localCenter.y);
_local9 = ((_local6.col1.x * _local10) + (_local6.col2.x * _local11));
_local11 = ((_local6.col1.y * _local10) + (_local6.col2.y * _local11));
_local10 = _local9;
var _local12:Number = (_local3.m_sweep.c.x + _local7);
var _local13:Number = (_local3.m_sweep.c.y + _local8);
var _local14:Number = (_local4.m_sweep.c.x + _local10);
var _local15:Number = (_local4.m_sweep.c.y + _local11);
var _local16:Number = (_local14 - _local12);
var _local17:Number = (_local15 - _local13);
_local5 = Math.sqrt(((_local16 * _local16) + (_local17 * _local17)));
var _local18:Number = _local3.m_invMass;
var _local19:Number = _local4.m_invMass;
var _local20:Number = _local3.m_invI;
var _local21:Number = _local4.m_invI;
K1.col1.x = (_local18 + _local19);
K1.col2.x = 0;
K1.col1.y = 0;
K1.col2.y = (_local18 + _local19);
K2.col1.x = ((_local20 * _local8) * _local8);
K2.col2.x = ((-(_local20) * _local7) * _local8);
K2.col1.y = ((-(_local20) * _local7) * _local8);
K2.col2.y = ((_local20 * _local7) * _local7);
K3.col1.x = ((_local21 * _local11) * _local11);
K3.col2.x = ((-(_local21) * _local10) * _local11);
K3.col1.y = ((-(_local21) * _local10) * _local11);
K3.col2.y = ((_local21 * _local10) * _local10);
K.SetM(K1);
K.AddM(K2);
K.AddM(K3);
K.Solve(tImpulse, -(_local16), -(_local17));
var _local22:Number = tImpulse.x;
var _local23:Number = tImpulse.y;
_local3.m_sweep.c.x = (_local3.m_sweep.c.x - (_local3.m_invMass * _local22));
_local3.m_sweep.c.y = (_local3.m_sweep.c.y - (_local3.m_invMass * _local23));
_local3.m_sweep.a = (_local3.m_sweep.a - (_local3.m_invI * ((_local7 * _local23) - (_local8 * _local22))));
_local4.m_sweep.c.x = (_local4.m_sweep.c.x + (_local4.m_invMass * _local22));
_local4.m_sweep.c.y = (_local4.m_sweep.c.y + (_local4.m_invMass * _local23));
_local4.m_sweep.a = (_local4.m_sweep.a + (_local4.m_invI * ((_local10 * _local23) - (_local11 * _local22))));
_local3.SynchronizeTransform();
_local4.SynchronizeTransform();
var _local24:Number = 0;
if (((m_enableLimit) && (!((m_limitState == e_inactiveLimit))))){
_local25 = ((_local4.m_sweep.a - _local3.m_sweep.a) - m_referenceAngle);
_local26 = 0;
if (m_limitState == e_equalLimits){
_local2 = b2Math.b2Clamp(_local25, -(b2Settings.b2_maxAngularCorrection), b2Settings.b2_maxAngularCorrection);
_local26 = (-(m_motorMass) * _local2);
_local24 = b2Math.b2Abs(_local2);
} else {
if (m_limitState == e_atLowerLimit){
_local2 = (_local25 - m_lowerAngle);
_local24 = b2Math.b2Max(0, -(_local2));
_local2 = b2Math.b2Clamp((_local2 + b2Settings.b2_angularSlop), -(b2Settings.b2_maxAngularCorrection), 0);
_local26 = (-(m_motorMass) * _local2);
_local1 = m_limitPositionImpulse;
m_limitPositionImpulse = b2Math.b2Max((m_limitPositionImpulse + _local26), 0);
_local26 = (m_limitPositionImpulse - _local1);
} else {
if (m_limitState == e_atUpperLimit){
_local2 = (_local25 - m_upperAngle);
_local24 = b2Math.b2Max(0, _local2);
_local2 = b2Math.b2Clamp((_local2 - b2Settings.b2_angularSlop), 0, b2Settings.b2_maxAngularCorrection);
_local26 = (-(m_motorMass) * _local2);
_local1 = m_limitPositionImpulse;
m_limitPositionImpulse = b2Math.b2Min((m_limitPositionImpulse + _local26), 0);
_local26 = (m_limitPositionImpulse - _local1);
};
};
};
_local3.m_sweep.a = (_local3.m_sweep.a - (_local3.m_invI * _local26));
_local4.m_sweep.a = (_local4.m_sweep.a + (_local4.m_invI * _local26));
_local3.SynchronizeTransform();
_local4.SynchronizeTransform();
};
return ((((_local5 <= b2Settings.b2_linearSlop)) && ((_local24 <= b2Settings.b2_angularSlop))));
}
public function SetMotorSpeed(_arg1:Number):void{
m_motorSpeed = _arg1;
}
public function GetJointSpeed():Number{
return ((m_body2.m_angularVelocity - m_body1.m_angularVelocity));
}
public function SetMaxMotorTorque(_arg1:Number):void{
m_maxMotorTorque = _arg1;
}
public function GetJointAngle():Number{
return (((m_body2.m_sweep.a - m_body1.m_sweep.a) - m_referenceAngle));
}
public function GetMotorTorque():Number{
return (m_motorForce);
}
override public function InitVelocityConstraints(_arg1:b2TimeStep):void{
var _local2:b2Body;
var _local3:b2Body;
var _local4:b2Mat22;
var _local5:Number;
var _local7:Number;
var _local14:Number;
_local2 = m_body1;
_local3 = m_body2;
_local4 = _local2.m_xf.R;
var _local6:Number = (m_localAnchor1.x - _local2.m_sweep.localCenter.x);
_local7 = (m_localAnchor1.y - _local2.m_sweep.localCenter.y);
_local5 = ((_local4.col1.x * _local6) + (_local4.col2.x * _local7));
_local7 = ((_local4.col1.y * _local6) + (_local4.col2.y * _local7));
_local6 = _local5;
_local4 = _local3.m_xf.R;
var _local8:Number = (m_localAnchor2.x - _local3.m_sweep.localCenter.x);
var _local9:Number = (m_localAnchor2.y - _local3.m_sweep.localCenter.y);
_local5 = ((_local4.col1.x * _local8) + (_local4.col2.x * _local9));
_local9 = ((_local4.col1.y * _local8) + (_local4.col2.y * _local9));
_local8 = _local5;
var _local10:Number = _local2.m_invMass;
var _local11:Number = _local3.m_invMass;
var _local12:Number = _local2.m_invI;
var _local13:Number = _local3.m_invI;
K1.col1.x = (_local10 + _local11);
K1.col2.x = 0;
K1.col1.y = 0;
K1.col2.y = (_local10 + _local11);
K2.col1.x = ((_local12 * _local7) * _local7);
K2.col2.x = ((-(_local12) * _local6) * _local7);
K2.col1.y = ((-(_local12) * _local6) * _local7);
K2.col2.y = ((_local12 * _local6) * _local6);
K3.col1.x = ((_local13 * _local9) * _local9);
K3.col2.x = ((-(_local13) * _local8) * _local9);
K3.col1.y = ((-(_local13) * _local8) * _local9);
K3.col2.y = ((_local13 * _local8) * _local8);
K.SetM(K1);
K.AddM(K2);
K.AddM(K3);
K.Invert(m_pivotMass);
m_motorMass = (1 / (_local12 + _local13));
if (m_enableMotor == false){
m_motorForce = 0;
};
if (m_enableLimit){
_local14 = ((_local3.m_sweep.a - _local2.m_sweep.a) - m_referenceAngle);
if (b2Math.b2Abs((m_upperAngle - m_lowerAngle)) < (2 * b2Settings.b2_angularSlop)){
m_limitState = e_equalLimits;
} else {
if (_local14 <= m_lowerAngle){
if (m_limitState != e_atLowerLimit){
m_limitForce = 0;
};
m_limitState = e_atLowerLimit;
} else {
if (_local14 >= m_upperAngle){
if (m_limitState != e_atUpperLimit){
m_limitForce = 0;
};
m_limitState = e_atUpperLimit;
} else {
m_limitState = e_inactiveLimit;
m_limitForce = 0;
};
};
};
} else {
m_limitForce = 0;
};
if (_arg1.warmStarting){
_local2.m_linearVelocity.x = (_local2.m_linearVelocity.x - ((_arg1.dt * _local10) * m_pivotForce.x));
_local2.m_linearVelocity.y = (_local2.m_linearVelocity.y - ((_arg1.dt * _local10) * m_pivotForce.y));
_local2.m_angularVelocity = (_local2.m_angularVelocity - ((_arg1.dt * _local12) * ((((_local6 * m_pivotForce.y) - (_local7 * m_pivotForce.x)) + m_motorForce) + m_limitForce)));
_local3.m_linearVelocity.x = (_local3.m_linearVelocity.x + ((_arg1.dt * _local11) * m_pivotForce.x));
_local3.m_linearVelocity.y = (_local3.m_linearVelocity.y + ((_arg1.dt * _local11) * m_pivotForce.y));
_local3.m_angularVelocity = (_local3.m_angularVelocity + ((_arg1.dt * _local13) * ((((_local8 * m_pivotForce.y) - (_local9 * m_pivotForce.x)) + m_motorForce) + m_limitForce)));
} else {
m_pivotForce.SetZero();
m_motorForce = 0;
m_limitForce = 0;
};
m_limitPositionImpulse = 0;
}
public function EnableLimit(_arg1:Boolean):void{
m_enableLimit = _arg1;
}
override public function GetReactionTorque():Number{
return (m_limitForce);
}
public function IsLimitEnabled():Boolean{
return (m_enableLimit);
}
public function IsMotorEnabled():Boolean{
return (m_enableMotor);
}
public function SetLimits(_arg1:Number, _arg2:Number):void{
m_lowerAngle = _arg1;
m_upperAngle = _arg2;
}
}
}//package Box2D.Dynamics.Joints
Section 64
//b2RevoluteJointDef (Box2D.Dynamics.Joints.b2RevoluteJointDef)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
public class b2RevoluteJointDef extends b2JointDef {
public var upperAngle:Number;
public var enableMotor:Boolean;
public var referenceAngle:Number;
public var motorSpeed:Number;
public var localAnchor1:b2Vec2;
public var localAnchor2:b2Vec2;
public var enableLimit:Boolean;
public var lowerAngle:Number;
public var maxMotorTorque:Number;
public function b2RevoluteJointDef(){
localAnchor1 = new b2Vec2();
localAnchor2 = new b2Vec2();
super();
type = b2Joint.e_revoluteJoint;
localAnchor1.Set(0, 0);
localAnchor2.Set(0, 0);
referenceAngle = 0;
lowerAngle = 0;
upperAngle = 0;
maxMotorTorque = 0;
motorSpeed = 0;
enableLimit = false;
enableMotor = false;
}
public function Initialize(_arg1:b2Body, _arg2:b2Body, _arg3:b2Vec2):void{
body1 = _arg1;
body2 = _arg2;
localAnchor1 = body1.GetLocalPoint(_arg3);
localAnchor2 = body2.GetLocalPoint(_arg3);
referenceAngle = (body2.GetAngle() - body1.GetAngle());
}
}
}//package Box2D.Dynamics.Joints
Section 65
//b2Body (Box2D.Dynamics.b2Body)
package Box2D.Dynamics {
import Box2D.Collision.Shapes.*;
import Box2D.Common.Math.*;
import Box2D.Dynamics.Joints.*;
import Box2D.Dynamics.Contacts.*;
public class b2Body {
public var m_next:b2Body;
public var m_xf:b2XForm;
public var m_contactList:b2ContactEdge;
public var m_angularVelocity:Number;
public var m_shapeList:b2Shape;
public var m_force:b2Vec2;
public var m_mass:Number;
public var m_sweep:b2Sweep;
public var m_torque:Number;
public var m_userData;
public var m_flags:uint;
public var m_world:b2World;
public var m_prev:b2Body;
public var m_invMass:Number;
public var m_type:int;
public var m_linearDamping:Number;
public var m_shapeCount:int;
public var m_angularDamping:Number;
public var m_invI:Number;
public var m_linearVelocity:b2Vec2;
public var m_sleepTime:Number;
public var m_jointList:b2JointEdge;
public var m_I:Number;
public static var e_fixedRotationFlag:uint = 64;
public static var e_frozenFlag:uint = 2;
public static var e_maxTypes:uint = 3;
public static var e_sleepFlag:uint = 8;
private static var s_massData:b2MassData = new b2MassData();
public static var e_bulletFlag:uint = 32;
public static var e_staticType:uint = 1;
public static var e_islandFlag:uint = 4;
public static var e_allowSleepFlag:uint = 16;
private static var s_xf1:b2XForm = new b2XForm();
public static var e_dynamicType:uint = 2;
public function b2Body(_arg1:b2BodyDef, _arg2:b2World){
m_xf = new b2XForm();
m_sweep = new b2Sweep();
m_linearVelocity = new b2Vec2();
m_force = new b2Vec2();
super();
m_flags = 0;
if (_arg1.isBullet){
m_flags = (m_flags | e_bulletFlag);
};
if (_arg1.fixedRotation){
m_flags = (m_flags | e_fixedRotationFlag);
};
if (_arg1.allowSleep){
m_flags = (m_flags | e_allowSleepFlag);
};
if (_arg1.isSleeping){
m_flags = (m_flags | e_sleepFlag);
};
m_world = _arg2;
m_xf.position.SetV(_arg1.position);
m_xf.R.Set(_arg1.angle);
m_sweep.localCenter.SetV(_arg1.massData.center);
m_sweep.t0 = 1;
m_sweep.a0 = (m_sweep.a = _arg1.angle);
var _local3:b2Mat22 = m_xf.R;
var _local4:b2Vec2 = m_sweep.localCenter;
m_sweep.c.x = ((_local3.col1.x * _local4.x) + (_local3.col2.x * _local4.y));
m_sweep.c.y = ((_local3.col1.y * _local4.x) + (_local3.col2.y * _local4.y));
m_sweep.c.x = (m_sweep.c.x + m_xf.position.x);
m_sweep.c.y = (m_sweep.c.y + m_xf.position.y);
m_sweep.c0.SetV(m_sweep.c);
m_jointList = null;
m_contactList = null;
m_prev = null;
m_next = null;
m_linearDamping = _arg1.linearDamping;
m_angularDamping = _arg1.angularDamping;
m_force.Set(0, 0);
m_torque = 0;
m_linearVelocity.SetZero();
m_angularVelocity = 0;
m_sleepTime = 0;
m_invMass = 0;
m_I = 0;
m_invI = 0;
m_mass = _arg1.massData.mass;
if (m_mass > 0){
m_invMass = (1 / m_mass);
};
if ((m_flags & b2Body.e_fixedRotationFlag) == 0){
m_I = _arg1.massData.I;
};
if (m_I > 0){
m_invI = (1 / m_I);
};
if ((((m_invMass == 0)) && ((m_invI == 0)))){
m_type = e_staticType;
} else {
m_type = e_dynamicType;
};
m_userData = _arg1.userData;
m_shapeList = null;
m_shapeCount = 0;
}
public function GetLinearVelocityFromWorldPoint(_arg1:b2Vec2):b2Vec2{
return (new b2Vec2((m_linearVelocity.x - (m_angularVelocity * (_arg1.y - m_sweep.c.y))), (m_linearVelocity.y + (m_angularVelocity * (_arg1.x - m_sweep.c.x)))));
}
public function SetLinearVelocity(_arg1:b2Vec2):void{
m_linearVelocity.SetV(_arg1);
}
public function WakeUp():void{
m_flags = (m_flags & ~(e_sleepFlag));
m_sleepTime = 0;
}
public function GetLocalCenter():b2Vec2{
return (m_sweep.localCenter);
}
public function ApplyTorque(_arg1:Number):void{
if (IsSleeping()){
WakeUp();
};
m_torque = (m_torque + _arg1);
}
public function IsFrozen():Boolean{
return (((m_flags & e_frozenFlag) == e_frozenFlag));
}
public function IsDynamic():Boolean{
return ((m_type == e_dynamicType));
}
public function GetLinearVelocity():b2Vec2{
return (m_linearVelocity);
}
public function SynchronizeTransform():void{
m_xf.R.Set(m_sweep.a);
var _local1:b2Mat22 = m_xf.R;
var _local2:b2Vec2 = m_sweep.localCenter;
m_xf.position.x = (m_sweep.c.x - ((_local1.col1.x * _local2.x) + (_local1.col2.x * _local2.y)));
m_xf.position.y = (m_sweep.c.y - ((_local1.col1.y * _local2.x) + (_local1.col2.y * _local2.y)));
}
public function GetInertia():Number{
return (m_I);
}
public function IsSleeping():Boolean{
return (((m_flags & e_sleepFlag) == e_sleepFlag));
}
public function SetMassFromShapes():void{
var _local1:b2Shape;
if (m_world.m_lock == true){
return;
};
m_mass = 0;
m_invMass = 0;
m_I = 0;
m_invI = 0;
var _local2:Number = 0;
var _local3:Number = 0;
var _local4:b2MassData = s_massData;
_local1 = m_shapeList;
while (_local1) {
_local1.ComputeMass(_local4);
m_mass = (m_mass + _local4.mass);
_local2 = (_local2 + (_local4.mass * _local4.center.x));
_local3 = (_local3 + (_local4.mass * _local4.center.y));
m_I = (m_I + _local4.I);
_local1 = _local1.m_next;
};
if (m_mass > 0){
m_invMass = (1 / m_mass);
_local2 = (_local2 * m_invMass);
_local3 = (_local3 * m_invMass);
};
if ((((m_I > 0)) && (((m_flags & e_fixedRotationFlag) == 0)))){
m_I = (m_I - (m_mass * ((_local2 * _local2) + (_local3 * _local3))));
m_invI = (1 / m_I);
} else {
m_I = 0;
m_invI = 0;
};
m_sweep.localCenter.Set(_local2, _local3);
var _local5:b2Mat22 = m_xf.R;
var _local6:b2Vec2 = m_sweep.localCenter;
m_sweep.c.x = ((_local5.col1.x * _local6.x) + (_local5.col2.x * _local6.y));
m_sweep.c.y = ((_local5.col1.y * _local6.x) + (_local5.col2.y * _local6.y));
m_sweep.c.x = (m_sweep.c.x + m_xf.position.x);
m_sweep.c.y = (m_sweep.c.y + m_xf.position.y);
m_sweep.c0.SetV(m_sweep.c);
_local1 = m_shapeList;
while (_local1) {
_local1.UpdateSweepRadius(m_sweep.localCenter);
_local1 = _local1.m_next;
};
var _local7:int = m_type;
if ((((m_invMass == 0)) && ((m_invI == 0)))){
m_type = e_staticType;
} else {
m_type = e_dynamicType;
};
if (_local7 != m_type){
_local1 = m_shapeList;
while (_local1) {
_local1.RefilterProxy(m_world.m_broadPhase, m_xf);
_local1 = _local1.m_next;
};
};
}
public function PutToSleep():void{
m_flags = (m_flags | e_sleepFlag);
m_sleepTime = 0;
m_linearVelocity.SetZero();
m_angularVelocity = 0;
m_force.SetZero();
m_torque = 0;
}
public function GetJointList():b2JointEdge{
return (m_jointList);
}
public function SetXForm(_arg1:b2Vec2, _arg2:Number):Boolean{
var _local3:b2Shape;
var _local7:Boolean;
if (m_world.m_lock == true){
return (true);
};
if (IsFrozen()){
return (false);
};
m_xf.R.Set(_arg2);
m_xf.position.SetV(_arg1);
var _local4:b2Mat22 = m_xf.R;
var _local5:b2Vec2 = m_sweep.localCenter;
m_sweep.c.x = ((_local4.col1.x * _local5.x) + (_local4.col2.x * _local5.y));
m_sweep.c.y = ((_local4.col1.y * _local5.x) + (_local4.col2.y * _local5.y));
m_sweep.c.x = (m_sweep.c.x + m_xf.position.x);
m_sweep.c.y = (m_sweep.c.y + m_xf.position.y);
m_sweep.c0.SetV(m_sweep.c);
m_sweep.a0 = (m_sweep.a = _arg2);
var _local6:Boolean;
_local3 = m_shapeList;
while (_local3) {
_local7 = _local3.Synchronize(m_world.m_broadPhase, m_xf, m_xf);
if (_local7 == false){
_local6 = true;
break;
};
_local3 = _local3.m_next;
};
if (_local6 == true){
m_flags = (m_flags | e_frozenFlag);
m_linearVelocity.SetZero();
m_angularVelocity = 0;
_local3 = m_shapeList;
while (_local3) {
_local3.DestroyProxy(m_world.m_broadPhase);
_local3 = _local3.m_next;
};
return (false);
};
m_world.m_broadPhase.Commit();
return (true);
}
public function GetLocalPoint(_arg1:b2Vec2):b2Vec2{
return (b2Math.b2MulXT(m_xf, _arg1));
}
public function ApplyForce(_arg1:b2Vec2, _arg2:b2Vec2):void{
if (IsSleeping()){
WakeUp();
};
m_force.x = (m_force.x + _arg1.x);
m_force.y = (m_force.y + _arg1.y);
m_torque = (m_torque + (((_arg2.x - m_sweep.c.x) * _arg1.y) - ((_arg2.y - m_sweep.c.y) * _arg1.x)));
}
public function SynchronizeShapes():Boolean{
var _local4:b2Shape;
var _local1:b2XForm = s_xf1;
_local1.R.Set(m_sweep.a0);
var _local2:b2Mat22 = _local1.R;
var _local3:b2Vec2 = m_sweep.localCenter;
_local1.position.x = (m_sweep.c0.x - ((_local2.col1.x * _local3.x) + (_local2.col2.x * _local3.y)));
_local1.position.y = (m_sweep.c0.y - ((_local2.col1.y * _local3.x) + (_local2.col2.y * _local3.y)));
var _local5:Boolean;
_local4 = m_shapeList;
while (_local4) {
_local5 = _local4.Synchronize(m_world.m_broadPhase, _local1, m_xf);
if (_local5 == false){
break;
};
_local4 = _local4.m_next;
};
if (_local5 == false){
m_flags = (m_flags | e_frozenFlag);
m_linearVelocity.SetZero();
m_angularVelocity = 0;
_local4 = m_shapeList;
while (_local4) {
_local4.DestroyProxy(m_world.m_broadPhase);
_local4 = _local4.m_next;
};
return (false);
};
return (true);
}
public function GetAngle():Number{
return (m_sweep.a);
}
public function GetXForm():b2XForm{
return (m_xf);
}
public function GetLinearVelocityFromLocalPoint(_arg1:b2Vec2):b2Vec2{
var _local2:b2Mat22 = m_xf.R;
var _local3:b2Vec2 = new b2Vec2(((_local2.col1.x * _arg1.x) + (_local2.col2.x * _arg1.y)), ((_local2.col1.y * _arg1.x) + (_local2.col2.y * _arg1.y)));
_local3.x = (_local3.x + m_xf.position.x);
_local3.y = (_local3.y + m_xf.position.y);
return (new b2Vec2((m_linearVelocity.x + (m_angularVelocity * (_local3.y - m_sweep.c.y))), (m_linearVelocity.x - (m_angularVelocity * (_local3.x - m_sweep.c.x)))));
}
public function GetNext():b2Body{
return (m_next);
}
public function GetMass():Number{
return (m_mass);
}
public function ApplyImpulse(_arg1:b2Vec2, _arg2:b2Vec2):void{
if (IsSleeping()){
WakeUp();
};
m_linearVelocity.x = (m_linearVelocity.x + (m_invMass * _arg1.x));
m_linearVelocity.y = (m_linearVelocity.y + (m_invMass * _arg1.y));
m_angularVelocity = (m_angularVelocity + (m_invI * (((_arg2.x - m_sweep.c.x) * _arg1.y) - ((_arg2.y - m_sweep.c.y) * _arg1.x))));
}
public function GetAngularVelocity():Number{
return (m_angularVelocity);
}
public function SetAngularVelocity(_arg1:Number):void{
m_angularVelocity = _arg1;
}
public function SetMass(_arg1:b2MassData):void{
var _local2:b2Shape;
if (m_world.m_lock == true){
return;
};
m_invMass = 0;
m_I = 0;
m_invI = 0;
m_mass = _arg1.mass;
if (m_mass > 0){
m_invMass = (1 / m_mass);
};
if ((m_flags & b2Body.e_fixedRotationFlag) == 0){
m_I = _arg1.I;
};
if (m_I > 0){
m_invI = (1 / m_I);
};
m_sweep.localCenter.SetV(_arg1.center);
var _local3:b2Mat22 = m_xf.R;
var _local4:b2Vec2 = m_sweep.localCenter;
m_sweep.c.x = ((_local3.col1.x * _local4.x) + (_local3.col2.x * _local4.y));
m_sweep.c.y = ((_local3.col1.y * _local4.x) + (_local3.col2.y * _local4.y));
m_sweep.c.x = (m_sweep.c.x + m_xf.position.x);
m_sweep.c.y = (m_sweep.c.y + m_xf.position.y);
m_sweep.c0.SetV(m_sweep.c);
_local2 = m_shapeList;
while (_local2) {
_local2.UpdateSweepRadius(m_sweep.localCenter);
_local2 = _local2.m_next;
};
var _local5:int = m_type;
if ((((m_invMass == 0)) && ((m_invI == 0)))){
m_type = e_staticType;
} else {
m_type = e_dynamicType;
};
if (_local5 != m_type){
_local2 = m_shapeList;
while (_local2) {
_local2.RefilterProxy(m_world.m_broadPhase, m_xf);
_local2 = _local2.m_next;
};
};
}
public function IsStatic():Boolean{
return ((m_type == e_staticType));
}
public function GetWorldVector(_arg1:b2Vec2):b2Vec2{
return (b2Math.b2MulMV(m_xf.R, _arg1));
}
public function GetShapeList():b2Shape{
return (m_shapeList);
}
public function Advance(_arg1:Number):void{
m_sweep.Advance(_arg1);
m_sweep.c.SetV(m_sweep.c0);
m_sweep.a = m_sweep.a0;
SynchronizeTransform();
}
public function SetBullet(_arg1:Boolean):void{
if (_arg1){
m_flags = (m_flags | e_bulletFlag);
} else {
m_flags = (m_flags & ~(e_bulletFlag));
};
}
public function CreateShape(_arg1:b2ShapeDef):b2Shape{
var _local2:b2Shape;
if (m_world.m_lock == true){
return (null);
};
_local2 = b2Shape.Create(_arg1, m_world.m_blockAllocator);
_local2.m_next = m_shapeList;
m_shapeList = _local2;
m_shapeCount++;
_local2.m_body = this;
_local2.CreateProxy(m_world.m_broadPhase, m_xf);
_local2.UpdateSweepRadius(m_sweep.localCenter);
return (_local2);
}
public function IsConnected(_arg1:b2Body):Boolean{
var _local2:b2JointEdge = m_jointList;
while (_local2) {
if (_local2.other == _arg1){
return ((_local2.joint.m_collideConnected == false));
};
_local2 = _local2.next;
};
return (false);
}
public function DestroyShape(_arg1:b2Shape):void{
if (m_world.m_lock == true){
return;
};
_arg1.DestroyProxy(m_world.m_broadPhase);
var _local2:b2Shape = m_shapeList;
var _local3:b2Shape;
var _local4:Boolean;
while (_local2 != null) {
if (_local2 == _arg1){
if (_local3){
_local3.m_next = _arg1.m_next;
} else {
m_shapeList = _arg1.m_next;
};
_local4 = true;
break;
};
_local3 = _local2;
_local2 = _local2.m_next;
};
_arg1.m_body = null;
_arg1.m_next = null;
m_shapeCount--;
b2Shape.Destroy(_arg1, m_world.m_blockAllocator);
}
public function GetUserData(){
return (m_userData);
}
public function IsBullet():Boolean{
return (((m_flags & e_bulletFlag) == e_bulletFlag));
}
public function GetWorldCenter():b2Vec2{
return (m_sweep.c);
}
public function AllowSleeping(_arg1:Boolean):void{
if (_arg1){
m_flags = (m_flags | e_allowSleepFlag);
} else {
m_flags = (m_flags & ~(e_allowSleepFlag));
WakeUp();
};
}
public function SetUserData(_arg1):void{
m_userData = _arg1;
}
public function GetLocalVector(_arg1:b2Vec2):b2Vec2{
return (b2Math.b2MulTMV(m_xf.R, _arg1));
}
public function GetWorldPoint(_arg1:b2Vec2):b2Vec2{
var _local2:b2Mat22 = m_xf.R;
var _local3:b2Vec2 = new b2Vec2(((_local2.col1.x * _arg1.x) + (_local2.col2.x * _arg1.y)), ((_local2.col1.y * _arg1.x) + (_local2.col2.y * _arg1.y)));
_local3.x = (_local3.x + m_xf.position.x);
_local3.y = (_local3.y + m_xf.position.y);
return (_local3);
}
public function GetWorld():b2World{
return (m_world);
}
public function GetPosition():b2Vec2{
return (m_xf.position);
}
}
}//package Box2D.Dynamics
Section 66
//b2BodyDef (Box2D.Dynamics.b2BodyDef)
package Box2D.Dynamics {
import Box2D.Collision.Shapes.*;
import Box2D.Common.Math.*;
public class b2BodyDef {
public var angularDamping:Number;
public var angle:Number;
public var isSleeping:Boolean;
public var position:b2Vec2;
public var isBullet:Boolean;
public var allowSleep:Boolean;
public var userData;
public var fixedRotation:Boolean;
public var linearDamping:Number;
public var massData:b2MassData;
public function b2BodyDef(){
massData = new b2MassData();
position = new b2Vec2();
super();
massData.center.SetZero();
massData.mass = 0;
massData.I = 0;
userData = null;
position.Set(0, 0);
angle = 0;
linearDamping = 0;
angularDamping = 0;
allowSleep = true;
isSleeping = false;
fixedRotation = false;
isBullet = false;
}
}
}//package Box2D.Dynamics
Section 67
//b2BoundaryListener (Box2D.Dynamics.b2BoundaryListener)
package Box2D.Dynamics {
public class b2BoundaryListener {
public function Violation(_arg1:b2Body):void{
}
}
}//package Box2D.Dynamics
Section 68
//b2ContactFilter (Box2D.Dynamics.b2ContactFilter)
package Box2D.Dynamics {
import Box2D.Collision.Shapes.*;
public class b2ContactFilter {
public static var b2_defaultFilter:b2ContactFilter = new (b2ContactFilter);
;
public function ShouldCollide(_arg1:b2Shape, _arg2:b2Shape):Boolean{
var _local3:b2FilterData = _arg1.GetFilterData();
var _local4:b2FilterData = _arg2.GetFilterData();
if ((((_local3.groupIndex == _local4.groupIndex)) && (!((_local3.groupIndex == 0))))){
return ((_local3.groupIndex > 0));
};
var _local5:Boolean = ((!(((_local3.maskBits & _local4.categoryBits) == 0))) && (!(((_local3.categoryBits & _local4.maskBits) == 0))));
return (_local5);
}
}
}//package Box2D.Dynamics
Section 69
//b2ContactListener (Box2D.Dynamics.b2ContactListener)
package Box2D.Dynamics {
import Box2D.Collision.*;
import Box2D.Dynamics.Contacts.*;
public class b2ContactListener {
public function Add(_arg1:b2ContactPoint):void{
}
public function Remove(_arg1:b2ContactPoint):void{
}
public function Persist(_arg1:b2ContactPoint):void{
}
public function Result(_arg1:b2ContactResult):void{
}
}
}//package Box2D.Dynamics
Section 70
//b2ContactManager (Box2D.Dynamics.b2ContactManager)
package Box2D.Dynamics {
import Box2D.Collision.Shapes.*;
import Box2D.Common.Math.*;
import Box2D.Collision.*;
import Box2D.Common.*;
import Box2D.Dynamics.Contacts.*;
public class b2ContactManager extends b2PairCallback {
public var m_world:b2World;
public var m_destroyImmediate:Boolean;
public var m_nullContact:b2NullContact;
private static const s_evalCP:b2ContactPoint = new b2ContactPoint();
public function b2ContactManager(){
m_nullContact = new b2NullContact();
super();
m_world = null;
m_destroyImmediate = false;
}
override public function PairRemoved(_arg1, _arg2, _arg3):void{
if (_arg3 == null){
return;
};
var _local4:b2Contact = (_arg3 as b2Contact);
if (_local4 == m_nullContact){
return;
};
Destroy(_local4);
}
public function Destroy(_arg1:b2Contact):void{
var _local7:b2Body;
var _local8:b2Body;
var _local9:Array;
var _local10:b2ContactPoint;
var _local11:int;
var _local12:b2Manifold;
var _local13:int;
var _local14:b2ManifoldPoint;
var _local15:b2Vec2;
var _local16:b2Vec2;
var _local2:b2Shape = _arg1.m_shape1;
var _local3:b2Shape = _arg1.m_shape2;
var _local4:int = _arg1.m_manifoldCount;
if ((((_local4 > 0)) && (m_world.m_contactListener))){
_local7 = _local2.m_body;
_local8 = _local3.m_body;
_local9 = _arg1.GetManifolds();
_local10 = s_evalCP;
_local10.shape1 = _arg1.m_shape1;
_local10.shape2 = _arg1.m_shape1;
_local10.friction = _arg1.m_friction;
_local10.restitution = _arg1.m_restitution;
_local11 = 0;
while (_local11 < _local4) {
_local12 = _local9[_local11];
_local10.normal.SetV(_local12.normal);
_local13 = 0;
while (_local13 < _local12.pointCount) {
_local14 = _local12.points[_local13];
_local10.position = _local7.GetWorldPoint(_local14.localPoint1);
_local15 = _local7.GetLinearVelocityFromLocalPoint(_local14.localPoint1);
_local16 = _local8.GetLinearVelocityFromLocalPoint(_local14.localPoint2);
_local10.velocity.Set((_local16.x - _local15.x), (_local16.y - _local15.y));
_local10.separation = _local14.separation;
_local10.id.key = _local14.id._key;
m_world.m_contactListener.Remove(_local10);
_local13++;
};
_local11++;
};
};
if (_arg1.m_prev){
_arg1.m_prev.m_next = _arg1.m_next;
};
if (_arg1.m_next){
_arg1.m_next.m_prev = _arg1.m_prev;
};
if (_arg1 == m_world.m_contactList){
m_world.m_contactList = _arg1.m_next;
};
var _local5:b2Body = _local2.m_body;
var _local6:b2Body = _local3.m_body;
if (_arg1.m_node1.prev){
_arg1.m_node1.prev.next = _arg1.m_node1.next;
};
if (_arg1.m_node1.next){
_arg1.m_node1.next.prev = _arg1.m_node1.prev;
};
if (_arg1.m_node1 == _local5.m_contactList){
_local5.m_contactList = _arg1.m_node1.next;
};
if (_arg1.m_node2.prev){
_arg1.m_node2.prev.next = _arg1.m_node2.next;
};
if (_arg1.m_node2.next){
_arg1.m_node2.next.prev = _arg1.m_node2.prev;
};
if (_arg1.m_node2 == _local6.m_contactList){
_local6.m_contactList = _arg1.m_node2.next;
};
b2Contact.Destroy(_arg1, m_world.m_blockAllocator);
m_world.m_contactCount--;
}
override public function PairAdded(_arg1, _arg2){
var _local3:b2Shape = (_arg1 as b2Shape);
var _local4:b2Shape = (_arg2 as b2Shape);
var _local5:b2Body = _local3.m_body;
var _local6:b2Body = _local4.m_body;
if (((_local5.IsStatic()) && (_local6.IsStatic()))){
return (m_nullContact);
};
if (_local3.m_body == _local4.m_body){
return (m_nullContact);
};
if (_local6.IsConnected(_local5)){
return (m_nullContact);
};
if (((!((m_world.m_contactFilter == null))) && ((m_world.m_contactFilter.ShouldCollide(_local3, _local4) == false)))){
return (m_nullContact);
};
var _local7:b2Contact = b2Contact.Create(_local3, _local4, m_world.m_blockAllocator);
if (_local7 == null){
return (m_nullContact);
};
_local3 = _local7.m_shape1;
_local4 = _local7.m_shape2;
_local5 = _local3.m_body;
_local6 = _local4.m_body;
_local7.m_prev = null;
_local7.m_next = m_world.m_contactList;
if (m_world.m_contactList != null){
m_world.m_contactList.m_prev = _local7;
};
m_world.m_contactList = _local7;
_local7.m_node1.contact = _local7;
_local7.m_node1.other = _local6;
_local7.m_node1.prev = null;
_local7.m_node1.next = _local5.m_contactList;
if (_local5.m_contactList != null){
_local5.m_contactList.prev = _local7.m_node1;
};
_local5.m_contactList = _local7.m_node1;
_local7.m_node2.contact = _local7;
_local7.m_node2.other = _local5;
_local7.m_node2.prev = null;
_local7.m_node2.next = _local6.m_contactList;
if (_local6.m_contactList != null){
_local6.m_contactList.prev = _local7.m_node2;
};
_local6.m_contactList = _local7.m_node2;
m_world.m_contactCount++;
return (_local7);
}
public function Collide():void{
var _local2:b2Body;
var _local3:b2Body;
var _local1:b2Contact = m_world.m_contactList;
while (_local1) {
_local2 = _local1.m_shape1.m_body;
_local3 = _local1.m_shape2.m_body;
if (((_local2.IsSleeping()) && (_local3.IsSleeping()))){
} else {
_local1.Update(m_world.m_contactListener);
};
_local1 = _local1.m_next;
};
}
}
}//package Box2D.Dynamics
Section 71
//b2DebugDraw (Box2D.Dynamics.b2DebugDraw)
package Box2D.Dynamics {
import flash.display.*;
import Box2D.Collision.Shapes.*;
import Box2D.Common.Math.*;
import Box2D.Collision.*;
import Box2D.Common.*;
import Box2D.Dynamics.Contacts.*;
public class b2DebugDraw {
public var m_xformScale:Number;// = 1
public var m_fillAlpha:Number;// = 1
public var m_alpha:Number;// = 1
public var m_drawFlags:uint;
public var m_lineThickness:Number;// = 1
public var m_drawScale:Number;// = 1
public var m_sprite:Sprite;
public static var e_coreShapeBit:uint = 4;
public static var e_shapeBit:uint = 1;
public static var e_centerOfMassBit:uint = 64;
public static var e_aabbBit:uint = 8;
public static var e_obbBit:uint = 16;
public static var e_pairBit:uint = 32;
public static var e_jointBit:uint = 2;
public function b2DebugDraw(){
m_drawFlags = 0;
}
public function ClearFlags(_arg1:uint):void{
m_drawFlags = (m_drawFlags & ~(_arg1));
}
public function SetFlags(_arg1:uint):void{
m_drawFlags = _arg1;
}
public function AppendFlags(_arg1:uint):void{
m_drawFlags = (m_drawFlags | _arg1);
}
public function DrawSegment(_arg1:b2Vec2, _arg2:b2Vec2, _arg3:b2Color):void{
m_sprite.graphics.lineStyle(m_lineThickness, _arg3.color, m_alpha);
m_sprite.graphics.moveTo((_arg1.x * m_drawScale), (_arg1.y * m_drawScale));
m_sprite.graphics.lineTo((_arg2.x * m_drawScale), (_arg2.y * m_drawScale));
}
public function DrawSolidPolygon(_arg1:Array, _arg2:int, _arg3:b2Color):void{
m_sprite.graphics.lineStyle(m_lineThickness, _arg3.color, m_alpha);
m_sprite.graphics.moveTo((_arg1[0].x * m_drawScale), (_arg1[0].y * m_drawScale));
m_sprite.graphics.beginFill(_arg3.color, m_fillAlpha);
var _local4 = 1;
while (_local4 < _arg2) {
m_sprite.graphics.lineTo((_arg1[_local4].x * m_drawScale), (_arg1[_local4].y * m_drawScale));
_local4++;
};
m_sprite.graphics.lineTo((_arg1[0].x * m_drawScale), (_arg1[0].y * m_drawScale));
m_sprite.graphics.endFill();
}
public function DrawCircle(_arg1:b2Vec2, _arg2:Number, _arg3:b2Color):void{
m_sprite.graphics.lineStyle(m_lineThickness, _arg3.color, m_alpha);
m_sprite.graphics.drawCircle((_arg1.x * m_drawScale), (_arg1.y * m_drawScale), (_arg2 * m_drawScale));
}
public function DrawPolygon(_arg1:Array, _arg2:int, _arg3:b2Color):void{
m_sprite.graphics.lineStyle(m_lineThickness, _arg3.color, m_alpha);
m_sprite.graphics.moveTo((_arg1[0].x * m_drawScale), (_arg1[0].y * m_drawScale));
var _local4 = 1;
while (_local4 < _arg2) {
m_sprite.graphics.lineTo((_arg1[_local4].x * m_drawScale), (_arg1[_local4].y * m_drawScale));
_local4++;
};
m_sprite.graphics.lineTo((_arg1[0].x * m_drawScale), (_arg1[0].y * m_drawScale));
}
public function DrawSolidCircle(_arg1:b2Vec2, _arg2:Number, _arg3:b2Vec2, _arg4:b2Color):void{
m_sprite.graphics.lineStyle(m_lineThickness, _arg4.color, m_alpha);
m_sprite.graphics.moveTo(0, 0);
m_sprite.graphics.beginFill(_arg4.color, m_fillAlpha);
m_sprite.graphics.drawCircle((_arg1.x * m_drawScale), (_arg1.y * m_drawScale), (_arg2 * m_drawScale));
m_sprite.graphics.endFill();
m_sprite.graphics.moveTo((_arg1.x * m_drawScale), (_arg1.y * m_drawScale));
m_sprite.graphics.lineTo(((_arg1.x + (_arg3.x * _arg2)) * m_drawScale), ((_arg1.y + (_arg3.y * _arg2)) * m_drawScale));
}
public function GetFlags():uint{
return (m_drawFlags);
}
public function DrawXForm(_arg1:b2XForm):void{
m_sprite.graphics.lineStyle(m_lineThickness, 0xFF0000, m_alpha);
m_sprite.graphics.moveTo((_arg1.position.x * m_drawScale), (_arg1.position.y * m_drawScale));
m_sprite.graphics.lineTo(((_arg1.position.x + (m_xformScale * _arg1.R.col1.x)) * m_drawScale), ((_arg1.position.y + (m_xformScale * _arg1.R.col1.y)) * m_drawScale));
m_sprite.graphics.lineStyle(m_lineThickness, 0xFF00, m_alpha);
m_sprite.graphics.moveTo((_arg1.position.x * m_drawScale), (_arg1.position.y * m_drawScale));
m_sprite.graphics.lineTo(((_arg1.position.x + (m_xformScale * _arg1.R.col2.x)) * m_drawScale), ((_arg1.position.y + (m_xformScale * _arg1.R.col2.y)) * m_drawScale));
}
}
}//package Box2D.Dynamics
Section 72
//b2DestructionListener (Box2D.Dynamics.b2DestructionListener)
package Box2D.Dynamics {
import Box2D.Collision.Shapes.*;
import Box2D.Dynamics.Joints.*;
public class b2DestructionListener {
public function SayGoodbyeShape(_arg1:b2Shape):void{
}
public function SayGoodbyeJoint(_arg1:b2Joint):void{
}
}
}//package Box2D.Dynamics
Section 73
//b2Island (Box2D.Dynamics.b2Island)
package Box2D.Dynamics {
import Box2D.Common.Math.*;
import Box2D.Dynamics.Joints.*;
import Box2D.Collision.*;
import Box2D.Common.*;
import Box2D.Dynamics.Contacts.*;
public class b2Island {
public var m_listener:b2ContactListener;
public var m_positionIterationCount:int;
public var m_bodyCapacity:int;
public var m_bodies:Array;
public var m_joints:Array;
public var m_jointCapacity:int;
public var m_contactCount:int;
public var m_contacts:Array;
public var m_contactCapacity:int;
public var m_jointCount:int;
public var m_allocator;
public var m_bodyCount:int;
private static var s_reportCR:b2ContactResult = new b2ContactResult();
public function b2Island(_arg1:int, _arg2:int, _arg3:int, _arg4, _arg5:b2ContactListener){
var _local6:int;
super();
m_bodyCapacity = _arg1;
m_contactCapacity = _arg2;
m_jointCapacity = _arg3;
m_bodyCount = 0;
m_contactCount = 0;
m_jointCount = 0;
m_allocator = _arg4;
m_listener = _arg5;
m_bodies = new Array(_arg1);
_local6 = 0;
while (_local6 < _arg1) {
m_bodies[_local6] = null;
_local6++;
};
m_contacts = new Array(_arg2);
_local6 = 0;
while (_local6 < _arg2) {
m_contacts[_local6] = null;
_local6++;
};
m_joints = new Array(_arg3);
_local6 = 0;
while (_local6 < _arg3) {
m_joints[_local6] = null;
_local6++;
};
m_positionIterationCount = 0;
}
public function AddBody(_arg1:b2Body):void{
var _local2 = m_bodyCount++;
m_bodies[_local2] = _arg1;
}
public function AddJoint(_arg1:b2Joint):void{
var _local2 = m_jointCount++;
m_joints[_local2] = _arg1;
}
public function Report(_arg1:Array):void{
var _local2:b2Mat22;
var _local3:b2Vec2;
var _local5:b2Contact;
var _local6:b2ContactConstraint;
var _local7:b2ContactResult;
var _local8:b2Body;
var _local9:int;
var _local10:Array;
var _local11:int;
var _local12:b2Manifold;
var _local13:int;
var _local14:b2ManifoldPoint;
var _local15:b2ContactConstraintPoint;
if (m_listener == null){
return;
};
var _local4:int;
while (_local4 < m_contactCount) {
_local5 = m_contacts[_local4];
_local6 = _arg1[_local4];
_local7 = s_reportCR;
_local7.shape1 = _local5.m_shape1;
_local7.shape2 = _local5.m_shape2;
_local8 = _local7.shape1.m_body;
_local9 = _local5.m_manifoldCount;
_local10 = _local5.GetManifolds();
_local11 = 0;
while (_local11 < _local9) {
_local12 = _local10[_local11];
_local7.normal.SetV(_local12.normal);
_local13 = 0;
while (_local13 < _local12.pointCount) {
_local14 = _local12.points[_local13];
_local15 = _local6.points[_local13];
_local7.position = _local8.GetWorldPoint(_local14.localPoint1);
_local7.normalImpulse = _local15.normalImpulse;
_local7.tangentImpulse = _local15.tangentImpulse;
_local7.id.key = _local14.id.key;
m_listener.Result(_local7);
_local13++;
};
_local11++;
};
_local4++;
};
}
public function AddContact(_arg1:b2Contact):void{
var _local2 = m_contactCount++;
m_contacts[_local2] = _arg1;
}
public function Solve(_arg1:b2TimeStep, _arg2:b2Vec2, _arg3:Boolean, _arg4:Boolean):void{
var _local5:int;
var _local6:b2Body;
var _local7:b2Joint;
var _local9:int;
var _local10:Boolean;
var _local11:Boolean;
var _local12:Boolean;
var _local13:Number;
var _local14:Number;
var _local15:Number;
_local5 = 0;
while (_local5 < m_bodyCount) {
_local6 = m_bodies[_local5];
if (_local6.IsStatic()){
} else {
_local6.m_linearVelocity.x = (_local6.m_linearVelocity.x + (_arg1.dt * (_arg2.x + (_local6.m_invMass * _local6.m_force.x))));
_local6.m_linearVelocity.y = (_local6.m_linearVelocity.y + (_arg1.dt * (_arg2.y + (_local6.m_invMass * _local6.m_force.y))));
_local6.m_angularVelocity = (_local6.m_angularVelocity + ((_arg1.dt * _local6.m_invI) * _local6.m_torque));
_local6.m_force.SetZero();
_local6.m_torque = 0;
_local6.m_linearVelocity.Multiply(b2Math.b2Clamp((1 - (_arg1.dt * _local6.m_linearDamping)), 0, 1));
_local6.m_angularVelocity = (_local6.m_angularVelocity * b2Math.b2Clamp((1 - (_arg1.dt * _local6.m_angularDamping)), 0, 1));
if (_local6.m_linearVelocity.LengthSquared() > b2Settings.b2_maxLinearVelocitySquared){
_local6.m_linearVelocity.Normalize();
_local6.m_linearVelocity.x = (_local6.m_linearVelocity.x * b2Settings.b2_maxLinearVelocity);
_local6.m_linearVelocity.y = (_local6.m_linearVelocity.y * b2Settings.b2_maxLinearVelocity);
};
if ((_local6.m_angularVelocity * _local6.m_angularVelocity) > b2Settings.b2_maxAngularVelocitySquared){
if (_local6.m_angularVelocity < 0){
_local6.m_angularVelocity = -(b2Settings.b2_maxAngularVelocity);
} else {
_local6.m_angularVelocity = b2Settings.b2_maxAngularVelocity;
};
};
};
_local5++;
};
var _local8:b2ContactSolver = new b2ContactSolver(_arg1, m_contacts, m_contactCount, m_allocator);
_local8.InitVelocityConstraints(_arg1);
_local5 = 0;
while (_local5 < m_jointCount) {
_local7 = m_joints[_local5];
_local7.InitVelocityConstraints(_arg1);
_local5++;
};
_local5 = 0;
while (_local5 < _arg1.maxIterations) {
_local8.SolveVelocityConstraints();
_local9 = 0;
while (_local9 < m_jointCount) {
_local7 = m_joints[_local9];
_local7.SolveVelocityConstraints(_arg1);
_local9++;
};
_local5++;
};
_local8.FinalizeVelocityConstraints();
_local5 = 0;
while (_local5 < m_bodyCount) {
_local6 = m_bodies[_local5];
if (_local6.IsStatic()){
} else {
_local6.m_sweep.c0.SetV(_local6.m_sweep.c);
_local6.m_sweep.a0 = _local6.m_sweep.a;
_local6.m_sweep.c.x = (_local6.m_sweep.c.x + (_arg1.dt * _local6.m_linearVelocity.x));
_local6.m_sweep.c.y = (_local6.m_sweep.c.y + (_arg1.dt * _local6.m_linearVelocity.y));
_local6.m_sweep.a = (_local6.m_sweep.a + (_arg1.dt * _local6.m_angularVelocity));
_local6.SynchronizeTransform();
};
_local5++;
};
if (_arg3){
_local5 = 0;
while (_local5 < m_jointCount) {
_local7 = m_joints[_local5];
_local7.InitPositionConstraints();
_local5++;
};
m_positionIterationCount = 0;
while (m_positionIterationCount < _arg1.maxIterations) {
_local10 = _local8.SolvePositionConstraints(b2Settings.b2_contactBaumgarte);
_local11 = true;
_local5 = 0;
while (_local5 < m_jointCount) {
_local7 = m_joints[_local5];
_local12 = _local7.SolvePositionConstraints();
_local11 = ((_local11) && (_local12));
_local5++;
};
if (((_local10) && (_local11))){
break;
};
m_positionIterationCount++;
};
};
Report(_local8.m_constraints);
if (_arg4){
_local13 = Number.MAX_VALUE;
_local14 = (b2Settings.b2_linearSleepTolerance * b2Settings.b2_linearSleepTolerance);
_local15 = (b2Settings.b2_angularSleepTolerance * b2Settings.b2_angularSleepTolerance);
_local5 = 0;
while (_local5 < m_bodyCount) {
_local6 = m_bodies[_local5];
if (_local6.m_invMass == 0){
} else {
if ((_local6.m_flags & b2Body.e_allowSleepFlag) == 0){
_local6.m_sleepTime = 0;
_local13 = 0;
};
if (((((((_local6.m_flags & b2Body.e_allowSleepFlag) == 0)) || (((_local6.m_angularVelocity * _local6.m_angularVelocity) > _local15)))) || ((b2Math.b2Dot(_local6.m_linearVelocity, _local6.m_linearVelocity) > _local14)))){
_local6.m_sleepTime = 0;
_local13 = 0;
} else {
_local6.m_sleepTime = (_local6.m_sleepTime + _arg1.dt);
_local13 = b2Math.b2Min(_local13, _local6.m_sleepTime);
};
};
_local5++;
};
if (_local13 >= b2Settings.b2_timeToSleep){
_local5 = 0;
while (_local5 < m_bodyCount) {
_local6 = m_bodies[_local5];
m_bodies[_local5].m_flags = (_local6.m_flags | b2Body.e_sleepFlag);
_local6.m_linearVelocity.SetZero();
_local6.m_angularVelocity = 0;
_local5++;
};
};
};
}
public function Clear():void{
m_bodyCount = 0;
m_contactCount = 0;
m_jointCount = 0;
}
public function SolveTOI(_arg1:b2TimeStep):void{
var _local2:int;
var _local5:b2Body;
var _local6:Boolean;
var _local3:b2ContactSolver = new b2ContactSolver(_arg1, m_contacts, m_contactCount, m_allocator);
_local2 = 0;
while (_local2 < _arg1.maxIterations) {
_local3.SolveVelocityConstraints();
_local2++;
};
_local2 = 0;
while (_local2 < m_bodyCount) {
_local5 = m_bodies[_local2];
if (_local5.IsStatic()){
} else {
_local5.m_sweep.c0.SetV(_local5.m_sweep.c);
_local5.m_sweep.a0 = _local5.m_sweep.a;
_local5.m_sweep.c.x = (_local5.m_sweep.c.x + (_arg1.dt * _local5.m_linearVelocity.x));
_local5.m_sweep.c.y = (_local5.m_sweep.c.y + (_arg1.dt * _local5.m_linearVelocity.y));
_local5.m_sweep.a = (_local5.m_sweep.a + (_arg1.dt * _local5.m_angularVelocity));
_local5.SynchronizeTransform();
};
_local2++;
};
var _local4:Number = 0.75;
_local2 = 0;
while (_local2 < _arg1.maxIterations) {
_local6 = _local3.SolvePositionConstraints(_local4);
if (_local6){
break;
};
_local2++;
};
Report(_local3.m_constraints);
}
}
}//package Box2D.Dynamics
Section 74
//b2TimeStep (Box2D.Dynamics.b2TimeStep)
package Box2D.Dynamics {
public class b2TimeStep {
public var warmStarting:Boolean;
public var positionCorrection:Boolean;
public var dt:Number;
public var maxIterations:int;
public var dtRatio:Number;
public var inv_dt:Number;
}
}//package Box2D.Dynamics
Section 75
//b2World (Box2D.Dynamics.b2World)
package Box2D.Dynamics {
import Box2D.Collision.Shapes.*;
import Box2D.Common.Math.*;
import Box2D.Dynamics.Joints.*;
import Box2D.Collision.*;
import Box2D.Common.*;
import Box2D.Dynamics.Contacts.*;
public class b2World {
public var m_inv_dt0:Number;
public var m_boundaryListener:b2BoundaryListener;
public var m_contactList:b2Contact;
public var m_blockAllocator;
public var m_contactListener:b2ContactListener;
public var m_allowSleep:Boolean;
public var m_broadPhase:b2BroadPhase;
public var m_destructionListener:b2DestructionListener;
public var m_jointCount:int;
public var m_bodyCount:int;
public var m_lock:Boolean;
public var m_positionIterationCount:int;
public var m_groundBody:b2Body;
public var m_contactCount:int;
public var m_debugDraw:b2DebugDraw;
public var m_contactFilter:b2ContactFilter;
public var m_bodyList:b2Body;
public var m_stackAllocator;
public var m_jointList:b2Joint;
public var m_gravity:b2Vec2;
public var m_contactManager:b2ContactManager;
private static var s_jointColor:b2Color = new b2Color(0.5, 0.8, 0.8);
public static var m_continuousPhysics:Boolean;
public static var m_warmStarting:Boolean;
private static var s_coreColor:b2Color = new b2Color(0.9, 0.6, 0.6);
public static var m_positionCorrection:Boolean;
private static var s_xf:b2XForm = new b2XForm();
public function b2World(_arg1:b2AABB, _arg2:b2Vec2, _arg3:Boolean){
m_contactManager = new b2ContactManager();
super();
m_destructionListener = null;
m_boundaryListener = null;
m_contactFilter = b2ContactFilter.b2_defaultFilter;
m_contactListener = null;
m_debugDraw = null;
m_bodyList = null;
m_contactList = null;
m_jointList = null;
m_bodyCount = 0;
m_contactCount = 0;
m_jointCount = 0;
m_positionCorrection = true;
m_warmStarting = true;
m_continuousPhysics = true;
m_allowSleep = _arg3;
m_gravity = _arg2;
m_lock = false;
m_inv_dt0 = 0;
m_contactManager.m_world = this;
m_broadPhase = new b2BroadPhase(_arg1, m_contactManager);
var _local4:b2BodyDef = new b2BodyDef();
m_groundBody = CreateBody(_local4);
}
public function DrawJoint(_arg1:b2Joint):void{
var _local11:b2PulleyJoint;
var _local12:b2Vec2;
var _local13:b2Vec2;
var _local2:b2Body = _arg1.m_body1;
var _local3:b2Body = _arg1.m_body2;
var _local4:b2XForm = _local2.m_xf;
var _local5:b2XForm = _local3.m_xf;
var _local6:b2Vec2 = _local4.position;
var _local7:b2Vec2 = _local5.position;
var _local8:b2Vec2 = _arg1.GetAnchor1();
var _local9:b2Vec2 = _arg1.GetAnchor2();
var _local10:b2Color = s_jointColor;
switch (_arg1.m_type){
case b2Joint.e_distanceJoint:
m_debugDraw.DrawSegment(_local8, _local9, _local10);
break;
case b2Joint.e_pulleyJoint:
_local11 = (_arg1 as b2PulleyJoint);
_local12 = _local11.GetGroundAnchor1();
_local13 = _local11.GetGroundAnchor2();
m_debugDraw.DrawSegment(_local12, _local8, _local10);
m_debugDraw.DrawSegment(_local13, _local9, _local10);
m_debugDraw.DrawSegment(_local12, _local13, _local10);
break;
case b2Joint.e_mouseJoint:
m_debugDraw.DrawSegment(_local8, _local9, _local10);
break;
default:
if (_local2 != m_groundBody){
m_debugDraw.DrawSegment(_local6, _local8, _local10);
};
m_debugDraw.DrawSegment(_local8, _local9, _local10);
if (_local3 != m_groundBody){
m_debugDraw.DrawSegment(_local7, _local9, _local10);
};
};
}
public function Refilter(_arg1:b2Shape):void{
_arg1.RefilterProxy(m_broadPhase, _arg1.m_body.m_xf);
}
public function SetDebugDraw(_arg1:b2DebugDraw):void{
m_debugDraw = _arg1;
}
public function SetContinuousPhysics(_arg1:Boolean):void{
m_continuousPhysics = _arg1;
}
public function GetProxyCount():int{
return (m_broadPhase.m_proxyCount);
}
public function DrawDebugData():void{
var _local2:int;
var _local3:b2Body;
var _local4:b2Shape;
var _local5:b2Joint;
var _local6:b2BroadPhase;
var _local11:b2XForm;
var _local15:Boolean;
var _local16:uint;
var _local17:b2Pair;
var _local18:b2Proxy;
var _local19:b2Proxy;
var _local20:b2Vec2;
var _local21:b2Vec2;
var _local22:b2Proxy;
var _local23:b2PolygonShape;
var _local24:b2OBB;
var _local25:b2Vec2;
var _local26:b2Mat22;
var _local27:b2Vec2;
var _local28:Number;
if (m_debugDraw == null){
return;
};
m_debugDraw.m_sprite.graphics.clear();
var _local1:uint = m_debugDraw.GetFlags();
var _local7:b2Vec2 = new b2Vec2();
var _local8:b2Vec2 = new b2Vec2();
var _local9:b2Vec2 = new b2Vec2();
var _local10:b2Color = new b2Color(0, 0, 0);
var _local12:b2AABB = new b2AABB();
var _local13:b2AABB = new b2AABB();
var _local14:Array = [new b2Vec2(), new b2Vec2(), new b2Vec2(), new b2Vec2()];
if ((_local1 & b2DebugDraw.e_shapeBit)){
_local15 = ((_local1 & b2DebugDraw.e_coreShapeBit) == b2DebugDraw.e_coreShapeBit);
_local3 = m_bodyList;
while (_local3) {
_local11 = _local3.m_xf;
_local4 = _local3.GetShapeList();
while (_local4) {
if (_local3.IsStatic()){
DrawShape(_local4, _local11, new b2Color(0.5, 0.9, 0.5), _local15);
} else {
if (_local3.IsSleeping()){
DrawShape(_local4, _local11, new b2Color(0.5, 0.5, 0.9), _local15);
} else {
DrawShape(_local4, _local11, new b2Color(0.9, 0.9, 0.9), _local15);
};
};
_local4 = _local4.m_next;
};
_local3 = _local3.m_next;
};
};
if ((_local1 & b2DebugDraw.e_jointBit)){
_local5 = m_jointList;
while (_local5) {
DrawJoint(_local5);
_local5 = _local5.m_next;
};
};
if ((_local1 & b2DebugDraw.e_pairBit)){
_local6 = m_broadPhase;
_local7.Set((1 / _local6.m_quantizationFactor.x), (1 / _local6.m_quantizationFactor.y));
_local10.Set(0.9, 0.9, 0.3);
_local2 = 0;
while (_local2 < b2Pair.b2_tableCapacity) {
_local16 = _local6.m_pairManager.m_hashTable[_local2];
while (_local16 != b2Pair.b2_nullPair) {
_local17 = _local6.m_pairManager.m_pairs[_local16];
_local18 = _local6.m_proxyPool[_local17.proxyId1];
_local19 = _local6.m_proxyPool[_local17.proxyId2];
_local12.lowerBound.x = (_local6.m_worldAABB.lowerBound.x + (_local7.x * _local6.m_bounds[0][_local18.lowerBounds[0]].value));
_local12.lowerBound.y = (_local6.m_worldAABB.lowerBound.y + (_local7.y * _local6.m_bounds[1][_local18.lowerBounds[1]].value));
_local12.upperBound.x = (_local6.m_worldAABB.lowerBound.x + (_local7.x * _local6.m_bounds[0][_local18.upperBounds[0]].value));
_local12.upperBound.y = (_local6.m_worldAABB.lowerBound.y + (_local7.y * _local6.m_bounds[1][_local18.upperBounds[1]].value));
_local13.lowerBound.x = (_local6.m_worldAABB.lowerBound.x + (_local7.x * _local6.m_bounds[0][_local19.lowerBounds[0]].value));
_local13.lowerBound.y = (_local6.m_worldAABB.lowerBound.y + (_local7.y * _local6.m_bounds[1][_local19.lowerBounds[1]].value));
_local13.upperBound.x = (_local6.m_worldAABB.lowerBound.x + (_local7.x * _local6.m_bounds[0][_local19.upperBounds[0]].value));
_local13.upperBound.y = (_local6.m_worldAABB.lowerBound.y + (_local7.y * _local6.m_bounds[1][_local19.upperBounds[1]].value));
_local8.x = (0.5 * (_local12.lowerBound.x + _local12.upperBound.x));
_local8.y = (0.5 * (_local12.lowerBound.y + _local12.upperBound.y));
_local9.x = (0.5 * (_local13.lowerBound.x + _local13.upperBound.x));
_local9.y = (0.5 * (_local13.lowerBound.y + _local13.upperBound.y));
m_debugDraw.DrawSegment(_local8, _local9, _local10);
_local16 = _local17.next;
};
_local2++;
};
};
if ((_local1 & b2DebugDraw.e_aabbBit)){
_local6 = m_broadPhase;
_local20 = _local6.m_worldAABB.lowerBound;
_local21 = _local6.m_worldAABB.upperBound;
_local7.Set((1 / _local6.m_quantizationFactor.x), (1 / _local6.m_quantizationFactor.y));
_local10.Set(0.9, 0.3, 0.9);
_local2 = 0;
while (_local2 < b2Settings.b2_maxProxies) {
_local22 = _local6.m_proxyPool[_local2];
if (_local22.IsValid() == false){
} else {
_local12.lowerBound.x = (_local20.x + (_local7.x * _local6.m_bounds[0][_local22.lowerBounds[0]].value));
_local12.lowerBound.y = (_local20.y + (_local7.y * _local6.m_bounds[1][_local22.lowerBounds[1]].value));
_local12.upperBound.x = (_local20.x + (_local7.x * _local6.m_bounds[0][_local22.upperBounds[0]].value));
_local12.upperBound.y = (_local20.y + (_local7.y * _local6.m_bounds[1][_local22.upperBounds[1]].value));
_local14[0].Set(_local12.lowerBound.x, _local12.lowerBound.y);
_local14[1].Set(_local12.upperBound.x, _local12.lowerBound.y);
_local14[2].Set(_local12.upperBound.x, _local12.upperBound.y);
_local14[3].Set(_local12.lowerBound.x, _local12.upperBound.y);
m_debugDraw.DrawPolygon(_local14, 4, _local10);
};
_local2++;
};
_local14[0].Set(_local20.x, _local20.y);
_local14[1].Set(_local21.x, _local20.y);
_local14[2].Set(_local21.x, _local21.y);
_local14[3].Set(_local20.x, _local21.y);
m_debugDraw.DrawPolygon(_local14, 4, new b2Color(0.3, 0.9, 0.9));
};
if ((_local1 & b2DebugDraw.e_obbBit)){
_local10.Set(0.5, 0.3, 0.5);
_local3 = m_bodyList;
while (_local3) {
_local11 = _local3.m_xf;
_local4 = _local3.GetShapeList();
while (_local4) {
if (_local4.m_type != b2Shape.e_polygonShape){
} else {
_local23 = (_local4 as b2PolygonShape);
_local24 = _local23.GetOBB();
_local25 = _local24.extents;
_local14[0].Set(-(_local25.x), -(_local25.y));
_local14[1].Set(_local25.x, -(_local25.y));
_local14[2].Set(_local25.x, _local25.y);
_local14[3].Set(-(_local25.x), _local25.y);
_local2 = 0;
while (_local2 < 4) {
_local26 = _local24.R;
_local27 = _local14[_local2];
_local28 = (_local24.center.x + ((_local26.col1.x * _local27.x) + (_local26.col2.x * _local27.y)));
_local14[_local2].y = (_local24.center.y + ((_local26.col1.y * _local27.x) + (_local26.col2.y * _local27.y)));
_local14[_local2].x = _local28;
_local26 = _local11.R;
_local28 = (_local11.position.x + ((_local26.col1.x * _local27.x) + (_local26.col2.x * _local27.y)));
_local14[_local2].y = (_local11.position.y + ((_local26.col1.y * _local27.x) + (_local26.col2.y * _local27.y)));
_local14[_local2].x = _local28;
_local2++;
};
m_debugDraw.DrawPolygon(_local14, 4, _local10);
};
_local4 = _local4.m_next;
};
_local3 = _local3.m_next;
};
};
if ((_local1 & b2DebugDraw.e_centerOfMassBit)){
_local3 = m_bodyList;
while (_local3) {
_local11 = s_xf;
_local11.R = _local3.m_xf.R;
_local11.position = _local3.GetWorldCenter();
m_debugDraw.DrawXForm(_local11);
_local3 = _local3.m_next;
};
};
}
public function DestroyBody(_arg1:b2Body):void{
var _local4:b2JointEdge;
var _local5:b2Shape;
if (m_lock == true){
return;
};
var _local2:b2JointEdge = _arg1.m_jointList;
while (_local2) {
_local4 = _local2;
_local2 = _local2.next;
if (m_destructionListener){
m_destructionListener.SayGoodbyeJoint(_local4.joint);
};
DestroyJoint(_local4.joint);
};
var _local3:b2Shape = _arg1.m_shapeList;
while (_local3) {
_local5 = _local3;
_local3 = _local3.m_next;
if (m_destructionListener){
m_destructionListener.SayGoodbyeShape(_local5);
};
_local5.DestroyProxy(m_broadPhase);
b2Shape.Destroy(_local5, m_blockAllocator);
};
if (_arg1.m_prev){
_arg1.m_prev.m_next = _arg1.m_next;
};
if (_arg1.m_next){
_arg1.m_next.m_prev = _arg1.m_prev;
};
if (_arg1 == m_bodyList){
m_bodyList = _arg1.m_next;
};
m_bodyCount--;
}
public function SetContactFilter(_arg1:b2ContactFilter):void{
m_contactFilter = _arg1;
}
public function GetGroundBody():b2Body{
return (m_groundBody);
}
public function DrawShape(_arg1:b2Shape, _arg2:b2XForm, _arg3:b2Color, _arg4:Boolean):void{
var _local6:b2CircleShape;
var _local7:b2Vec2;
var _local8:Number;
var _local9:b2Vec2;
var _local10:int;
var _local11:b2PolygonShape;
var _local12:int;
var _local13:Array;
var _local14:Array;
var _local15:Array;
var _local5:b2Color = s_coreColor;
switch (_arg1.m_type){
case b2Shape.e_circleShape:
_local6 = (_arg1 as b2CircleShape);
_local7 = b2Math.b2MulX(_arg2, _local6.m_localPosition);
_local8 = _local6.m_radius;
_local9 = _arg2.R.col1;
m_debugDraw.DrawSolidCircle(_local7, _local8, _local9, _arg3);
if (_arg4){
m_debugDraw.DrawCircle(_local7, (_local8 - b2Settings.b2_toiSlop), _local5);
};
break;
case b2Shape.e_polygonShape:
_local11 = (_arg1 as b2PolygonShape);
_local12 = _local11.GetVertexCount();
_local13 = _local11.GetVertices();
_local14 = new Array(b2Settings.b2_maxPolygonVertices);
_local10 = 0;
while (_local10 < _local12) {
_local14[_local10] = b2Math.b2MulX(_arg2, _local13[_local10]);
_local10++;
};
m_debugDraw.DrawSolidPolygon(_local14, _local12, _arg3);
if (_arg4){
_local15 = _local11.GetCoreVertices();
_local10 = 0;
while (_local10 < _local12) {
_local14[_local10] = b2Math.b2MulX(_arg2, _local15[_local10]);
_local10++;
};
m_debugDraw.DrawPolygon(_local14, _local12, _local5);
};
break;
};
}
public function GetContactCount():int{
return (m_contactCount);
}
public function Solve(_arg1:b2TimeStep):void{
var _local2:b2Body;
var _local9:int;
var _local10:int;
var _local11:b2Body;
var _local12:b2ContactEdge;
var _local13:b2JointEdge;
var _local14:Boolean;
m_positionIterationCount = 0;
var _local3:b2Island = new b2Island(m_bodyCount, m_contactCount, m_jointCount, m_stackAllocator, m_contactListener);
_local2 = m_bodyList;
while (_local2) {
_local2.m_flags = (_local2.m_flags & ~(b2Body.e_islandFlag));
_local2 = _local2.m_next;
};
var _local4:b2Contact = m_contactList;
while (_local4) {
_local4.m_flags = (_local4.m_flags & ~(b2Contact.e_islandFlag));
_local4 = _local4.m_next;
};
var _local5:b2Joint = m_jointList;
while (_local5) {
_local5.m_islandFlag = false;
_local5 = _local5.m_next;
};
var _local6:int = m_bodyCount;
var _local7:Array = new Array(_local6);
var _local8:b2Body = m_bodyList;
while (_local8) {
if ((_local8.m_flags & ((b2Body.e_islandFlag | b2Body.e_sleepFlag) | b2Body.e_frozenFlag))){
} else {
if (_local8.IsStatic()){
} else {
_local3.Clear();
_local9 = 0;
var _temp1 = _local9;
_local9 = (_local9 + 1);
var _local15 = _temp1;
_local7[_local15] = _local8;
_local8.m_flags = (_local8.m_flags | b2Body.e_islandFlag);
while (_local9 > 0) {
--_local9;
_local2 = _local7[_local9];
_local3.AddBody(_local2);
_local2.m_flags = (_local2.m_flags & ~(b2Body.e_sleepFlag));
if (_local2.IsStatic()){
} else {
_local12 = _local2.m_contactList;
while (_local12) {
if ((_local12.contact.m_flags & (b2Contact.e_islandFlag | b2Contact.e_nonSolidFlag))){
} else {
if (_local12.contact.m_manifoldCount == 0){
} else {
_local3.AddContact(_local12.contact);
_local12.contact.m_flags = (_local12.contact.m_flags | b2Contact.e_islandFlag);
_local11 = _local12.other;
if ((_local11.m_flags & b2Body.e_islandFlag)){
} else {
var _temp2 = _local9;
_local9 = (_local9 + 1);
var _local16 = _temp2;
_local7[_local16] = _local11;
_local11.m_flags = (_local11.m_flags | b2Body.e_islandFlag);
};
};
};
_local12 = _local12.next;
};
_local13 = _local2.m_jointList;
while (_local13) {
if (_local13.joint.m_islandFlag == true){
} else {
_local3.AddJoint(_local13.joint);
_local13.joint.m_islandFlag = true;
_local11 = _local13.other;
if ((_local11.m_flags & b2Body.e_islandFlag)){
} else {
var _temp3 = _local9;
_local9 = (_local9 + 1);
_local16 = _temp3;
_local7[_local16] = _local11;
_local11.m_flags = (_local11.m_flags | b2Body.e_islandFlag);
};
};
_local13 = _local13.next;
};
};
};
_local3.Solve(_arg1, m_gravity, m_positionCorrection, m_allowSleep);
if (_local3.m_positionIterationCount > m_positionIterationCount){
m_positionIterationCount = _local3.m_positionIterationCount;
};
_local10 = 0;
while (_local10 < _local3.m_bodyCount) {
_local2 = _local3.m_bodies[_local10];
if (_local2.IsStatic()){
_local2.m_flags = (_local2.m_flags & ~(b2Body.e_islandFlag));
};
_local10++;
};
};
};
_local8 = _local8.m_next;
};
_local2 = m_bodyList;
while (_local2) {
if ((_local2.m_flags & (b2Body.e_sleepFlag | b2Body.e_frozenFlag))){
} else {
if (_local2.IsStatic()){
} else {
_local14 = _local2.SynchronizeShapes();
if ((((_local14 == false)) && (!((m_boundaryListener == null))))){
m_boundaryListener.Violation(_local2);
};
};
};
_local2 = _local2.m_next;
};
m_broadPhase.Commit();
}
public function Query(_arg1:b2AABB, _arg2:Array, _arg3:int):int{
var _local4:Array = new Array(_arg3);
var _local5:int = m_broadPhase.QueryAABB(_arg1, _local4, _arg3);
var _local6:int;
while (_local6 < _local5) {
_arg2[_local6] = _local4[_local6];
_local6++;
};
return (_local5);
}
public function SetGravity(_arg1:b2Vec2):void{
m_gravity = _arg1;
}
public function SolveTOI(_arg1:b2TimeStep):void{
var _local2:b2Body;
var _local3:b2Shape;
var _local4:b2Shape;
var _local5:b2Body;
var _local6:b2Body;
var _local7:b2ContactEdge;
var _local11:b2Contact;
var _local12:b2Contact;
var _local13:Number;
var _local14:b2Body;
var _local15:int;
var _local16:b2TimeStep;
var _local17:int;
var _local18:Number;
var _local19:Number;
var _local20:b2Body;
var _local21:Boolean;
var _local8:b2Island = new b2Island(m_bodyCount, b2Settings.b2_maxTOIContactsPerIsland, 0, m_stackAllocator, m_contactListener);
var _local9:int = m_bodyCount;
var _local10:Array = new Array(_local9);
_local2 = m_bodyList;
while (_local2) {
_local2.m_flags = (_local2.m_flags & ~(b2Body.e_islandFlag));
_local2.m_sweep.t0 = 0;
_local2 = _local2.m_next;
};
_local11 = m_contactList;
while (_local11) {
_local11.m_flags = (_local11.m_flags & ~((b2Contact.e_toiFlag | b2Contact.e_islandFlag)));
_local11 = _local11.m_next;
};
while (true) {
_local12 = null;
_local13 = 1;
_local11 = m_contactList;
for (;_local11;(_local11 = _local11.m_next)) {
if ((_local11.m_flags & (b2Contact.e_slowFlag | b2Contact.e_nonSolidFlag))){
} else {
_local18 = 1;
if ((_local11.m_flags & b2Contact.e_toiFlag)){
_local18 = _local11.m_toi;
} else {
_local3 = _local11.m_shape1;
_local4 = _local11.m_shape2;
_local5 = _local3.m_body;
_local6 = _local4.m_body;
if (((((_local5.IsStatic()) || (_local5.IsSleeping()))) && (((_local6.IsStatic()) || (_local6.IsSleeping()))))){
continue;
};
_local19 = _local5.m_sweep.t0;
if (_local5.m_sweep.t0 < _local6.m_sweep.t0){
_local19 = _local6.m_sweep.t0;
_local5.m_sweep.Advance(_local19);
} else {
if (_local6.m_sweep.t0 < _local5.m_sweep.t0){
_local19 = _local5.m_sweep.t0;
_local6.m_sweep.Advance(_local19);
};
};
_local18 = b2TimeOfImpact.TimeOfImpact(_local11.m_shape1, _local5.m_sweep, _local11.m_shape2, _local6.m_sweep);
if ((((_local18 > 0)) && ((_local18 < 1)))){
_local18 = (((1 - _local18) * _local19) + _local18);
if (_local18 > 1){
_local18 = 1;
};
};
_local11.m_toi = _local18;
_local11.m_flags = (_local11.m_flags | b2Contact.e_toiFlag);
};
if ((((Number.MIN_VALUE < _local18)) && ((_local18 < _local13)))){
_local12 = _local11;
_local13 = _local18;
};
};
};
if ((((_local12 == null)) || (((1 - (100 * Number.MIN_VALUE)) < _local13)))){
break;
};
_local3 = _local12.m_shape1;
_local4 = _local12.m_shape2;
_local5 = _local3.m_body;
_local6 = _local4.m_body;
_local5.Advance(_local13);
_local6.Advance(_local13);
_local12.Update(m_contactListener);
_local12.m_flags = (_local12.m_flags & ~(b2Contact.e_toiFlag));
if (_local12.m_manifoldCount == 0){
} else {
_local14 = _local5;
if (_local14.IsStatic()){
_local14 = _local6;
};
_local8.Clear();
_local15 = 0;
var _temp1 = _local15;
_local15 = (_local15 + 1);
var _local22 = _temp1;
_local10[_local22] = _local14;
_local14.m_flags = (_local14.m_flags | b2Body.e_islandFlag);
while (_local15 > 0) {
--_local15;
_local2 = _local10[_local15];
_local8.AddBody(_local2);
_local2.m_flags = (_local2.m_flags & ~(b2Body.e_sleepFlag));
if (_local2.IsStatic()){
} else {
_local7 = _local2.m_contactList;
while (_local7) {
if (_local8.m_contactCount == _local8.m_contactCapacity){
} else {
if ((_local7.contact.m_flags & ((b2Contact.e_islandFlag | b2Contact.e_slowFlag) | b2Contact.e_nonSolidFlag))){
} else {
if (_local7.contact.m_manifoldCount == 0){
} else {
_local8.AddContact(_local7.contact);
_local7.contact.m_flags = (_local7.contact.m_flags | b2Contact.e_islandFlag);
_local20 = _local7.other;
if ((_local20.m_flags & b2Body.e_islandFlag)){
} else {
if (_local20.IsStatic() == false){
_local20.Advance(_local13);
_local20.WakeUp();
};
var _temp2 = _local15;
_local15 = (_local15 + 1);
var _local23 = _temp2;
_local10[_local23] = _local20;
_local20.m_flags = (_local20.m_flags | b2Body.e_islandFlag);
};
};
};
};
_local7 = _local7.next;
};
};
};
_local16 = new b2TimeStep();
_local16.dt = ((1 - _local13) * _arg1.dt);
_local16.inv_dt = (1 / _local16.dt);
_local16.maxIterations = _arg1.maxIterations;
_local8.SolveTOI(_local16);
_local17 = 0;
while (_local17 < _local8.m_bodyCount) {
_local2 = _local8.m_bodies[_local17];
_local2.m_flags = (_local2.m_flags & ~(b2Body.e_islandFlag));
if ((_local2.m_flags & (b2Body.e_sleepFlag | b2Body.e_frozenFlag))){
} else {
if (_local2.IsStatic()){
} else {
_local21 = _local2.SynchronizeShapes();
if ((((_local21 == false)) && (!((m_boundaryListener == null))))){
m_boundaryListener.Violation(_local2);
};
_local7 = _local2.m_contactList;
while (_local7) {
_local7.contact.m_flags = (_local7.contact.m_flags & ~(b2Contact.e_toiFlag));
_local7 = _local7.next;
};
};
};
_local17++;
};
_local17 = 0;
while (_local17 < _local8.m_contactCount) {
_local11 = _local8.m_contacts[_local17];
_local8.m_contacts[_local17].m_flags = (_local11.m_flags & ~((b2Contact.e_toiFlag | b2Contact.e_islandFlag)));
_local17++;
};
m_broadPhase.Commit();
};
};
}
public function GetJointList():b2Joint{
return (m_jointList);
}
public function Validate():void{
m_broadPhase.Validate();
}
public function GetGravity():b2Vec2{
return (m_gravity);
}
public function GetPairCount():int{
return (m_broadPhase.m_pairManager.m_pairCount);
}
public function GetBodyList():b2Body{
return (m_bodyList);
}
public function SetWarmStarting(_arg1:Boolean):void{
m_warmStarting = _arg1;
}
public function SetPositionCorrection(_arg1:Boolean):void{
m_positionCorrection = _arg1;
}
public function CreateJoint(_arg1:b2JointDef):b2Joint{
var _local3:b2Body;
var _local4:b2Shape;
var _local2:b2Joint = b2Joint.Create(_arg1, m_blockAllocator);
_local2.m_prev = null;
_local2.m_next = m_jointList;
if (m_jointList){
m_jointList.m_prev = _local2;
};
m_jointList = _local2;
m_jointCount++;
_local2.m_node1.joint = _local2;
_local2.m_node1.other = _local2.m_body2;
_local2.m_node1.prev = null;
_local2.m_node1.next = _local2.m_body1.m_jointList;
if (_local2.m_body1.m_jointList){
_local2.m_body1.m_jointList.prev = _local2.m_node1;
};
_local2.m_body1.m_jointList = _local2.m_node1;
_local2.m_node2.joint = _local2;
_local2.m_node2.other = _local2.m_body1;
_local2.m_node2.prev = null;
_local2.m_node2.next = _local2.m_body2.m_jointList;
if (_local2.m_body2.m_jointList){
_local2.m_body2.m_jointList.prev = _local2.m_node2;
};
_local2.m_body2.m_jointList = _local2.m_node2;
if (_arg1.collideConnected == false){
_local3 = ((_arg1.body1.m_shapeCount < _arg1.body2.m_shapeCount)) ? _arg1.body1 : _arg1.body2;
_local4 = _local3.m_shapeList;
while (_local4) {
_local4.RefilterProxy(m_broadPhase, _local3.m_xf);
_local4 = _local4.m_next;
};
};
return (_local2);
}
public function DestroyJoint(_arg1:b2Joint):void{
var _local5:b2Body;
var _local6:b2Shape;
var _local2:Boolean = _arg1.m_collideConnected;
if (_arg1.m_prev){
_arg1.m_prev.m_next = _arg1.m_next;
};
if (_arg1.m_next){
_arg1.m_next.m_prev = _arg1.m_prev;
};
if (_arg1 == m_jointList){
m_jointList = _arg1.m_next;
};
var _local3:b2Body = _arg1.m_body1;
var _local4:b2Body = _arg1.m_body2;
_local3.WakeUp();
_local4.WakeUp();
if (_arg1.m_node1.prev){
_arg1.m_node1.prev.next = _arg1.m_node1.next;
};
if (_arg1.m_node1.next){
_arg1.m_node1.next.prev = _arg1.m_node1.prev;
};
if (_arg1.m_node1 == _local3.m_jointList){
_local3.m_jointList = _arg1.m_node1.next;
};
_arg1.m_node1.prev = null;
_arg1.m_node1.next = null;
if (_arg1.m_node2.prev){
_arg1.m_node2.prev.next = _arg1.m_node2.next;
};
if (_arg1.m_node2.next){
_arg1.m_node2.next.prev = _arg1.m_node2.prev;
};
if (_arg1.m_node2 == _local4.m_jointList){
_local4.m_jointList = _arg1.m_node2.next;
};
_arg1.m_node2.prev = null;
_arg1.m_node2.next = null;
b2Joint.Destroy(_arg1, m_blockAllocator);
m_jointCount--;
if (_local2 == false){
_local5 = ((_local3.m_shapeCount < _local4.m_shapeCount)) ? _local3 : _local4;
_local6 = _local5.m_shapeList;
while (_local6) {
_local6.RefilterProxy(m_broadPhase, _local5.m_xf);
_local6 = _local6.m_next;
};
};
}
public function SetContactListener(_arg1:b2ContactListener):void{
m_contactListener = _arg1;
}
public function CreateBody(_arg1:b2BodyDef):b2Body{
if (m_lock == true){
return (null);
};
var _local2:b2Body = new b2Body(_arg1, this);
_local2.m_prev = null;
_local2.m_next = m_bodyList;
if (m_bodyList){
m_bodyList.m_prev = _local2;
};
m_bodyList = _local2;
m_bodyCount++;
return (_local2);
}
public function SetBoundaryListener(_arg1:b2BoundaryListener):void{
m_boundaryListener = _arg1;
}
public function SetDestructionListener(_arg1:b2DestructionListener):void{
m_destructionListener = _arg1;
}
public function Step(_arg1:Number, _arg2:int):void{
m_lock = true;
var _local3:b2TimeStep = new b2TimeStep();
_local3.dt = _arg1;
_local3.maxIterations = _arg2;
if (_arg1 > 0){
_local3.inv_dt = (1 / _arg1);
} else {
_local3.inv_dt = 0;
};
_local3.dtRatio = (m_inv_dt0 * _arg1);
_local3.positionCorrection = m_positionCorrection;
_local3.warmStarting = m_warmStarting;
m_contactManager.Collide();
if (_local3.dt > 0){
Solve(_local3);
};
if (((m_continuousPhysics) && ((_local3.dt > 0)))){
SolveTOI(_local3);
};
DrawDebugData();
m_inv_dt0 = _local3.inv_dt;
m_lock = false;
}
public function GetBodyCount():int{
return (m_bodyCount);
}
public function GetJointCount():int{
return (m_jointCount);
}
}
}//package Box2D.Dynamics
Section 76
//BGAnimation_2 (CannonBG_fla.BGAnimation_2)
package CannonBG_fla {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import flash.geom.*;
import flash.filters.*;
import flash.text.*;
import flash.net.*;
import flash.media.*;
import flash.ui.*;
import flash.system.*;
import adobe.utils.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.printing.*;
import flash.xml.*;
public dynamic class BGAnimation_2 extends MovieClip {
public var count:uint;
public var i:uint;
public var particle:MovieClip;
public var particleInst1:BGElement;
public var particleInst2:BGElement;
public function BGAnimation_2(){
addFrameScript(0, frame1);
}
function frame1(){
particleInst1.visible = false;
particleInst2.visible = false;
count = 100;
i = 0;
while (i < count) {
particle = new BGElement();
var _local2 = particle;
with (_local2) {
x = (Math.random() * 700);
y = (Math.random() * 480);
rotation = (Math.random() * 360);
scaleX = (scaleY = Math.random());
alpha = Math.random();
gotoAndStop(int((Math.random() * 6)));
};
addChild(particle);
i++;
};
}
}
}//package CannonBG_fla
Section 77
//BGAnimation_2 (ColumnsBG_fla.BGAnimation_2)
package ColumnsBG_fla {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import flash.geom.*;
import flash.filters.*;
import flash.text.*;
import flash.net.*;
import flash.media.*;
import flash.ui.*;
import flash.system.*;
import adobe.utils.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.printing.*;
import flash.xml.*;
public dynamic class BGAnimation_2 extends MovieClip {
public var count:uint;
public var i:uint;
public var particle:MovieClip;
public var particleInst1:BGElement;
public var particleInst2:BGElement;
public function BGAnimation_2(){
addFrameScript(0, frame1);
}
function frame1(){
particleInst1.visible = false;
particleInst2.visible = false;
count = 100;
i = 0;
while (i < count) {
particle = new BGElement();
var _local2 = particle;
with (_local2) {
x = (Math.random() * 700);
y = (Math.random() * 480);
rotation = (Math.random() * 360);
scaleX = (scaleY = Math.random());
alpha = Math.random();
gotoAndStop(int((Math.random() * 6)));
};
addChild(particle);
i++;
};
}
}
}//package ColumnsBG_fla
Section 78
//b2Controller (com.boristhebrave.Box2D.Controllers.b2Controller)
package com.boristhebrave.Box2D.Controllers {
import Box2D.Dynamics.*;
public class b2Controller {
public var m_prev:b2Controller;
public var m_next:b2Controller;
public function GetPrev():b2Controller{
return (m_prev);
}
public function Step(_arg1:Number):void{
}
public function Draw(_arg1:b2DebugDraw):void{
}
public function GetNext():b2Controller{
return (m_next);
}
}
}//package com.boristhebrave.Box2D.Controllers
Section 79
//b2MultiController (com.boristhebrave.Box2D.Controllers.b2MultiController)
package com.boristhebrave.Box2D.Controllers {
import Box2D.Dynamics.*;
public class b2MultiController extends b2Controller {
var m_bodies:Array;
public function b2MultiController(){
m_bodies = [];
super();
}
public function AddBodies(_arg1:Array):void{
var _local2:* = 0;
while (_local2 < _arg1.length) {
AddBody(_arg1[_local2]);
_local2++;
};
}
public function AddBody(_arg1:b2Body):void{
m_bodies.push(_arg1);
}
public function WakeBodies():void{
var _local1:int;
while (_local1 < m_bodies.length) {
m_bodies[_local1].WakeUp();
_local1++;
};
}
public function RemoveBody(_arg1:b2Body):void{
var body = _arg1;
m_bodies = m_bodies.filter(function (_arg1){
return (!((_arg1 == body)));
});
}
public function removeAllBodies():void{
m_bodies = new Array();
}
public function GetBodies():Array{
return (m_bodies);
}
public static function FromBodies(_arg1:Array):b2MultiController{
var _local2:b2MultiController = new (b2MultiController);
var _local3:* = 0;
while (_local3 < _arg1.length) {
_local2.AddBody(_arg1[_local3]);
_local3++;
};
return (_local2);
}
}
}//package com.boristhebrave.Box2D.Controllers
Section 80
//BContactListener (core.engine.BContactListener)
package core.engine {
import flash.events.*;
import Box2D.Dynamics.*;
import Box2D.Collision.*;
import Box2D.Dynamics.Contacts.*;
public class BContactListener extends b2ContactListener {
public var dispatcher:EventDispatcher;
public static const COLLIDE_ADD:String = "CollideAdd";
public static const COLLIDE_PERSIST:String = "CollidePersist";
public static const COLLIDE_REMOVE:String = "CollideRemove";
public static const COLLIDE_RESULT:String = "CollideResult";
public function BContactListener():void{
dispatcher = new EventDispatcher();
}
override public function Add(_arg1:b2ContactPoint):void{
dispatcher.dispatchEvent(new CoreEvent(COLLIDE_ADD, _arg1));
}
override public function Persist(_arg1:b2ContactPoint):void{
dispatcher.dispatchEvent(new CoreEvent(COLLIDE_PERSIST, _arg1));
}
public function collideExist(_arg1:b2Body, _arg2:b2Body):Boolean{
var _local3:b2ContactEdge = _arg1.m_contactList;
while (_local3) {
if (_local3.other == _arg2){
return (true);
};
_local3 = _local3.next;
};
return (false);
}
override public function Remove(_arg1:b2ContactPoint):void{
dispatcher.dispatchEvent(new CoreEvent(COLLIDE_REMOVE, _arg1));
}
override public function Result(_arg1:b2ContactResult):void{
dispatcher.dispatchEvent(new CoreEvent(COLLIDE_RESULT, _arg1));
}
}
}//package core.engine
Section 81
//CoreEngine (core.engine.CoreEngine)
package core.engine {
import flash.events.*;
import flash.display.*;
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import core.renderer.*;
import Box2D.Collision.*;
import com.boristhebrave.Box2D.Controllers.*;
public class CoreEngine extends Sprite {
public var debugDrawContainer:Sprite;
public var gravity:b2Vec2;
private var _renderers:Array;
public var world:b2World;
public var contactListener:BContactListener;
public var controller:b2MultiController;
private static var _instance:CoreEngine;
public function CoreEngine(_arg1:SingletonEnforcer){
gravity = new b2Vec2(0, 10);
_renderers = new Array();
contactListener = new BContactListener();
super();
createWorld();
}
public function explode(_arg1:b2Vec2):void{
var aabb:*;
var vMin:*;
var vMax:*;
var shapes:*;
var i:*;
var b:*;
var fv:*;
var position = _arg1;
var _local3 = world;
with (_local3) {
aabb = new b2AABB();
vMin = position.Copy();
vMin.Subtract(new b2Vec2(3, 3));
vMax = position.Copy();
vMax.Add(new b2Vec2(3, 3));
aabb.lowerBound = vMin;
aabb.upperBound = vMax;
shapes = new Array();
Query(aabb, shapes, 100);
i = 0;
while (i < shapes.length) {
b = shapes[i].GetBody();
fv = b.GetPosition().Copy();
fv.Subtract(position);
fv.Normalize();
fv.Multiply(65);
b.WakeUp();
b.ApplyForce(fv, b.GetPosition());
i++;
};
};
}
public function addRenderer(_arg1:BaseRenderer):void{
_renderers.push(_arg1);
}
private function onEnterFrame(_arg1:Event):void{
var _local2:BaseRenderer;
world.Step(0.0333, 5);
if (controller){
controller.Step(0.0333);
};
for each (_local2 in _renderers) {
_local2.render();
};
}
public function createWorld():void{
var _local2:b2DebugDraw;
var _local3:Sprite;
if (controller){
controller.removeAllBodies();
};
_renderers = new Array();
var _local1:b2AABB = new b2AABB();
_local1.lowerBound.Set(-1000, -1000);
_local1.upperBound.Set(1000, 1000);
world = new b2World(_local1, gravity, true);
if (debugDrawContainer){
_local2 = new b2DebugDraw();
_local3 = debugDrawContainer;
_local3.mouseEnabled = false;
_local3.mouseChildren = false;
_local2.m_sprite = _local3;
_local2.m_drawScale = 30;
_local2.m_fillAlpha = 0.7;
_local2.m_lineThickness = 1;
_local2.m_drawFlags = (b2DebugDraw.e_shapeBit | b2DebugDraw.e_jointBit);
world.SetDebugDraw(_local2);
};
world.SetContactListener(contactListener);
removeEventListener(Event.ENTER_FRAME, onEnterFrame);
addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
public static function getInstance():CoreEngine{
if (_instance == null){
_instance = new CoreEngine(new SingletonEnforcer());
};
return (_instance);
}
}
}//package core.engine
class SingletonEnforcer {
private function SingletonEnforcer(){
}
}
Section 82
//CoreEvent (core.engine.CoreEvent)
package core.engine {
import flash.events.*;
public class CoreEvent extends Event {
public var data:Object;
public static const COMPLETE_LEVEL:String = "COMPLETE_LEVEL";
public static const RESET:String = "RESET";
public function CoreEvent(_arg1:String, _arg2:Object=null, _arg3:Boolean=false, _arg4:Boolean=false){
this.data = _arg2;
super(_arg1, _arg3, _arg4);
}
}
}//package core.engine
Section 83
//BaseRenderer (core.renderer.BaseRenderer)
package core.renderer {
import flash.display.*;
import Box2D.Dynamics.*;
public class BaseRenderer {
protected var _skins:Array;
protected var _bodies:Array;
public function BaseRenderer(_arg1:Array, _arg2:Array, _arg3:Boolean=true):void{
if (_arg1.length != _arg2.length){
throw (new Error("BaseRenderer was not initialized properly. shapes count should be = skins count"));
};
_bodies = _arg1;
_skins = _arg2;
addSkins();
}
public function addSkins():void{
var _local2:Sprite;
var _local1:Sprite = Scene2DReference.getInstance().scene;
for each (_local2 in _skins) {
_local1.addChild(_local2);
};
}
public function render():void{
var i:uint;
var body:b2Body;
var skin:Sprite;
i = 0;
while (i < _bodies.length) {
body = _bodies[i];
skin = _skins[i];
var _local2 = skin;
with (_local2) {
x = (body.GetPosition().x * 30);
y = (body.GetPosition().y * 30);
rotation = ((body.GetAngle() * 180) / Math.PI);
};
i = (i + 1);
};
}
}
}//package core.renderer
Section 84
//Render3d (core.renderer.Render3d)
package core.renderer {
import Box2D.Dynamics.*;
import org.papervision3d.objects.*;
public class Render3d extends BaseRenderer {
public function Render3d(_arg1:Array, _arg2:Array){
var _local3:DisplayObject3D;
for each (_local3 in _arg2) {
Scene3DReference.getInstance().scene.addChild(_local3);
};
super(_arg1, _arg2, false);
}
override public function addSkins():void{
}
override public function render():void{
var i:uint;
var body:b2Body;
var skin:DisplayObject3D;
i = 0;
while (i < _bodies.length) {
body = _bodies[i];
skin = _skins[i];
var _local2 = skin;
with (_local2) {
x = Number(((body.GetPosition().x * 30) - 320));
y = Number(((-(body.GetPosition().y) * 30) + 200));
rotationZ = Number(((-(body.GetAngle()) * 180) / Math.PI));
};
i = (i + 1);
};
}
}
}//package core.renderer
Section 85
//Scene2DReference (core.renderer.Scene2DReference)
package core.renderer {
import flash.display.*;
public class Scene2DReference {
public var scene:Sprite;
private static var _instance:Scene2DReference;
public function Scene2DReference(_arg1:SingletonEnforcer){
}
public static function getInstance():Scene2DReference{
if (_instance == null){
_instance = new Scene2DReference(new SingletonEnforcer());
};
return (_instance);
}
}
}//package core.renderer
class SingletonEnforcer {
private function SingletonEnforcer(){
}
}
Section 86
//Scene3DReference (core.renderer.Scene3DReference)
package core.renderer {
import org.papervision3d.scenes.*;
public class Scene3DReference {
public var scene:Scene3D;
private static var _instance:Scene3DReference;
public function Scene3DReference(_arg1:SingletonEnforcer){
}
public static function getInstance():Scene3DReference{
if (_instance == null){
_instance = new Scene3DReference(new SingletonEnforcer());
};
return (_instance);
}
}
}//package core.renderer
class SingletonEnforcer {
private function SingletonEnforcer(){
}
}
Section 87
//JumpBox (core.shape.complex.JumpBox)
package core.shape.complex {
import flash.events.*;
import core.engine.*;
import flash.display.*;
import Box2D.Collision.Shapes.*;
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import flash.utils.*;
import core.*;
import Box2D.Collision.*;
import core.shape.shapeProps.*;
import core.shape.*;
public class JumpBox extends Sprite {
private var _box:BoxShape;
private var _maxMovePower:Number;// = 2.5
private var _hit:b2Body;
private var _hitPoint:b2Vec2;
private var _allowJump:Boolean;// = true
private var _key:KeyboardListener;
private var _isActive:Boolean;
private var _actionHandler:Function;
private var _movePower:Number;// = 0.5
private var _jumpPower:Number;
public function JumpBox(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:DefaultShapeProps=null, _arg7:Function=null){
_actionHandler = _arg7;
_jumpPower = _arg5;
var _local8:DefaultShapeProps = (_arg6) ? _arg6 : new DefaultDynamicShapeProps();
_local8.restitution = 0.15;
_box = new BoxShape(_arg1, _arg2, _arg3, _arg4, false, _local8);
_key = KeyboardListener.getInstance();
}
private function GetBodyAtPoint(_arg1:b2Vec2, _arg2:Boolean=false):b2Body{
var _local9:b2Shape;
var _local10:Boolean;
var _local3:b2AABB = new b2AABB();
_local3.lowerBound.Set((_arg1.x - 0.001), (_arg1.y - 0.001));
_local3.upperBound.Set((_arg1.x + 0.001), (_arg1.y + 0.001));
var _local4 = 5;
var _local5:Array = new Array();
var _local6:int = CoreEngine.getInstance().world.Query(_local3, _local5, _local4);
var _local7:b2Body;
var _local8:int;
while (_local8 < _local6) {
if ((((_local5[_local8].m_body.IsStatic() == false)) || (_arg2))){
_local9 = (_local5[_local8] as b2Shape);
_local10 = (_local5[_local8] as b2Shape).TestPoint(_local9.m_body.GetXForm(), _arg1);
if (_local10){
_local7 = _local9.m_body;
break;
};
};
_local8++;
};
return (_local7);
}
protected function onLeft():void{
body.WakeUp();
if (body.m_linearVelocity.x > -(_maxMovePower)){
body.m_linearVelocity.x = (body.m_linearVelocity.x + -(_movePower));
};
if (_actionHandler){
_actionHandler("left");
};
}
public function set movePower(_arg1:Number):void{
_movePower = _arg1;
}
public function get body():b2Body{
return (_box.body);
}
public function set maxMovePower(_arg1:Number):void{
_maxMovePower = _arg1;
}
protected function onJump():void{
var _local1:Number;
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:b2Vec2;
var _local6:b2Vec2;
var _local7:b2Vec2;
var _local8:b2Body;
var _local9:b2Body;
var _local10:b2Body;
if ((((body.GetLinearVelocity().y > -1)) && (_allowJump))){
_allowJump = false;
_local1 = (body.GetPosition().x * 30);
_local2 = (body.GetPosition().y * 30);
_local3 = ((body.GetUserData() as UserData).w / 2);
_local4 = ((body.GetUserData() as UserData).h / 2);
_local5 = new b2Vec2((_local1 / 30), (((_local2 + _local4) + 2) / 30));
_local6 = new b2Vec2((((_local1 - _local3) + 2) / 30), (((_local2 + _local4) + 2) / 30));
_local7 = new b2Vec2((((_local1 + _local3) - 2) / 30), (((_local2 + _local4) + 2) / 30));
_local8 = GetBodyAtPoint(_local5, true);
_local9 = GetBodyAtPoint(_local6, true);
_local10 = GetBodyAtPoint(_local7, true);
_hit = null;
_hitPoint = null;
if (_local8 != null){
_hit = _local8;
_hitPoint = _local5;
setTimeout(jump, 10);
} else {
if (_local9 != null){
_hit = _local9;
_hitPoint = _local6;
setTimeout(jump, 10);
} else {
if (_local10 != null){
_hit = _local10;
_hitPoint = _local7;
setTimeout(jump, 10);
} else {
_allowJump = true;
};
};
};
if (_actionHandler){
_actionHandler("jump");
};
};
}
private function jump():void{
body.ApplyImpulse(new b2Vec2(0, -(_jumpPower)), body.GetWorldCenter());
_allowJump = true;
}
public function activate():void{
addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
private function onEnterFrame(_arg1:Event):void{
body.m_sweep.a = 0;
if (_key.left){
onLeft();
};
if (_key.right){
onRight();
};
if (_key.up){
onJump();
};
if (((((!(_key.up)) && (!(_key.left)))) && (!(_key.right)))){
if (_actionHandler){
_actionHandler("none");
};
};
}
public function deactivate():void{
removeEventListener(Event.ENTER_FRAME, onEnterFrame);
}
protected function onRight():void{
body.WakeUp();
if (body.m_linearVelocity.x < _maxMovePower){
body.m_linearVelocity.x = (body.m_linearVelocity.x + _movePower);
};
if (_actionHandler){
_actionHandler("right");
};
}
}
}//package core.shape.complex
Section 88
//DefaultDynamicShapeProps (core.shape.shapeProps.DefaultDynamicShapeProps)
package core.shape.shapeProps {
public class DefaultDynamicShapeProps extends DefaultShapeProps {
public function DefaultDynamicShapeProps(){
friction = 0.3;
restitution = 0.3;
density = 0.4;
angularDamping = 0;
linearDamping = 0;
}
}
}//package core.shape.shapeProps
Section 89
//DefaultShapeProps (core.shape.shapeProps.DefaultShapeProps)
package core.shape.shapeProps {
public class DefaultShapeProps {
public var angularDamping:uint;
public var categoryBits:uint;
public var density:Number;
public var restitution:Number;
public var maskBits:uint;
public var groupIndex:int;
public var friction:Number;
public var linearDamping:uint;
}
}//package core.shape.shapeProps
Section 90
//DefaultStaticShapeProps (core.shape.shapeProps.DefaultStaticShapeProps)
package core.shape.shapeProps {
public class DefaultStaticShapeProps extends DefaultShapeProps {
public function DefaultStaticShapeProps(){
friction = 0.3;
restitution = 0;
density = 0;
}
}
}//package core.shape.shapeProps
Section 91
//UserData (core.shape.shapeProps.UserData)
package core.shape.shapeProps {
public class UserData {
public var type:String;// = "none"
public var w:Number;// = 0
public var h:Number;// = 0
public var subtype:String;// = ""
}
}//package core.shape.shapeProps
Section 92
//BaseShape (core.shape.BaseShape)
package core.shape {
import Box2D.Dynamics.*;
public class BaseShape {
private var _body:b2Body;
protected var _physScale:uint;// = 30
public function BaseShape(){
_body = createBody();
}
public function get body():b2Body{
return (_body);
}
protected function createBody():b2Body{
return (null);
}
}
}//package core.shape
Section 93
//BoxShape (core.shape.BoxShape)
package core.shape {
import core.engine.*;
import Box2D.Collision.Shapes.*;
import Box2D.Dynamics.*;
import core.shape.shapeProps.*;
public class BoxShape extends BaseShape {
private var _height:Number;
private var _width:Number;
private var _isStatic:Boolean;
private var _x:Number;
private var _y:Number;
private var _customShapeProps:DefaultShapeProps;
public function BoxShape(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Boolean, _arg6:DefaultShapeProps=null){
_x = _arg1;
_y = _arg2;
_width = _arg3;
_height = _arg4;
_isStatic = _arg5;
_customShapeProps = _arg6;
super();
}
override protected function createBody():b2Body{
var _local1:b2BodyDef;
var _local3:DefaultShapeProps;
_local1 = new b2BodyDef();
_local1.position.x = (_x / _physScale);
_local1.position.y = (_y / _physScale);
var _local2:b2PolygonDef = new b2PolygonDef();
_local2.SetAsBox((_width / 60), (_height / 60));
if (_customShapeProps){
_local3 = _customShapeProps;
} else {
_local3 = (_isStatic) ? new DefaultStaticShapeProps() : new DefaultDynamicShapeProps();
};
_local2.friction = _local3.friction;
_local2.restitution = _local3.restitution;
_local2.density = _local3.density;
_local1.angularDamping = _local3.angularDamping;
_local1.linearDamping = _local3.linearDamping;
if (_local3.categoryBits){
_local2.filter.categoryBits = _local3.categoryBits;
};
if (_local3.maskBits){
_local2.filter.maskBits = _local3.maskBits;
};
if (_local3.groupIndex){
_local2.filter.groupIndex = _local3.groupIndex;
};
var _local4:b2Body = CoreEngine.getInstance().world.CreateBody(_local1);
_local4.CreateShape(_local2);
_local4.SetMassFromShapes();
var _local5:UserData = new UserData();
_local5.w = _width;
_local5.h = _height;
_local4.m_userData = _local5;
return (_local4);
}
}
}//package core.shape
Section 94
//CircleShape (core.shape.CircleShape)
package core.shape {
import core.engine.*;
import Box2D.Collision.Shapes.*;
import Box2D.Dynamics.*;
import core.shape.shapeProps.*;
public class CircleShape extends BaseShape {
private var _radius:Number;
private var _customShapeProps:DefaultShapeProps;
private var _isStatic:Boolean;
private var _x:Number;
private var _y:Number;
public function CircleShape(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Boolean=false, _arg5:DefaultShapeProps=null){
_x = _arg1;
_y = _arg2;
_radius = _arg3;
_isStatic = _arg4;
_customShapeProps = _arg5;
super();
}
override protected function createBody():b2Body{
var _local3:DefaultShapeProps;
var _local1:b2BodyDef = new b2BodyDef();
_local1.position.x = (_x / _physScale);
_local1.position.y = (_y / _physScale);
var _local2:b2CircleDef = new b2CircleDef();
_local2.radius = (_radius / _physScale);
if (_customShapeProps){
_local3 = _customShapeProps;
} else {
_local3 = (_isStatic) ? new DefaultStaticShapeProps() : new DefaultDynamicShapeProps();
};
_local2.friction = _local3.friction;
_local2.restitution = _local3.restitution;
_local2.density = _local3.density;
if (_local3.categoryBits){
_local2.filter.categoryBits = _local3.categoryBits;
};
if (_local3.maskBits){
_local2.filter.maskBits = _local3.maskBits;
};
if (_local3.groupIndex){
_local2.filter.groupIndex = _local3.groupIndex;
};
var _local4:b2Body = CoreEngine.getInstance().world.CreateBody(_local1);
_local4.CreateShape(_local2);
_local4.SetMassFromShapes();
_local4.m_userData = new UserData();
return (_local4);
}
}
}//package core.shape
Section 95
//KeyboardListener (core.KeyboardListener)
package core {
import flash.events.*;
import flash.display.*;
public class KeyboardListener {
public var left:Boolean;// = false
public var up:Boolean;// = false
public var right:Boolean;// = false
private static var _instance:KeyboardListener;
public function KeyboardListener(_arg1:SingletonEnforcer){
}
public function onKeyDown(_arg1:KeyboardEvent):void{
switch (_arg1.keyCode){
case 37:
left = true;
break;
case 38:
up = true;
break;
case 39:
right = true;
break;
case 65:
left = true;
break;
case 87:
up = true;
break;
case 68:
right = true;
break;
case 32:
up = true;
break;
};
}
public function onKeyUp(_arg1:KeyboardEvent):void{
switch (_arg1.keyCode){
case 37:
left = false;
break;
case 38:
up = false;
break;
case 39:
right = false;
break;
case 65:
left = false;
break;
case 87:
up = false;
break;
case 68:
right = false;
break;
case 32:
up = false;
break;
};
}
public function listen(_arg1:Stage):void{
_arg1.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
_arg1.addEventListener(KeyboardEvent.KEY_UP, onKeyUp);
}
public static function getInstance():KeyboardListener{
if (_instance == null){
_instance = new KeyboardListener(new SingletonEnforcer());
};
return (_instance);
}
}
}//package core
class SingletonEnforcer {
private function SingletonEnforcer(){
}
}
Section 96
//AdLoader (CPMStar.AdLoader)
package CPMStar {
import flash.events.*;
import flash.display.*;
import flash.net.*;
import flash.system.*;
public class AdLoader extends Sprite {
private var cpmstarLoader:Loader;
private var contentspotid:String;
public function AdLoader(_arg1:String){
this.contentspotid = _arg1;
addEventListener(Event.ADDED, addedHandler);
}
private function dispatchHandler(_arg1:Event):void{
dispatchEvent(_arg1);
}
private function addedHandler(_arg1:Event):void{
removeEventListener(Event.ADDED, addedHandler);
Security.allowDomain("server.cpmstar.com");
var _local2 = "http://server.cpmstar.com/adviewas3.swf";
var _local3:DisplayObjectContainer = 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);
}
}
}//package CPMStar
Section 97
//BGAnimation_2 (DominoesBG_fla.BGAnimation_2)
package DominoesBG_fla {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import flash.geom.*;
import flash.filters.*;
import flash.text.*;
import flash.net.*;
import flash.media.*;
import flash.ui.*;
import flash.system.*;
import adobe.utils.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.printing.*;
import flash.xml.*;
public dynamic class BGAnimation_2 extends MovieClip {
public var count:uint;
public var i:uint;
public var particle:MovieClip;
public var particleInst1:BGElement;
public var particleInst2:BGElement;
public function BGAnimation_2(){
addFrameScript(0, frame1);
}
function frame1(){
particleInst1.visible = false;
particleInst2.visible = false;
count = 100;
i = 0;
while (i < count) {
particle = new BGElement();
var _local2 = particle;
with (_local2) {
x = (Math.random() * 700);
y = (Math.random() * 480);
rotation = (Math.random() * 360);
scaleX = (scaleY = Math.random());
alpha = Math.random();
gotoAndStop(int((Math.random() * 6)));
};
addChild(particle);
i++;
};
}
}
}//package DominoesBG_fla
Section 98
//BGAnimation_2 (DonttouchBG_fla.BGAnimation_2)
package DonttouchBG_fla {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import flash.geom.*;
import flash.filters.*;
import flash.text.*;
import flash.net.*;
import flash.media.*;
import flash.ui.*;
import flash.system.*;
import adobe.utils.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.printing.*;
import flash.xml.*;
public dynamic class BGAnimation_2 extends MovieClip {
public var count:uint;
public var i:uint;
public var particle:MovieClip;
public var particleInst1:BGElement;
public var particleInst2:BGElement;
public function BGAnimation_2(){
addFrameScript(0, frame1);
}
function frame1(){
particleInst1.visible = false;
particleInst2.visible = false;
count = 100;
i = 0;
while (i < count) {
particle = new BGElement();
var _local2 = particle;
with (_local2) {
x = (Math.random() * 700);
y = (Math.random() * 480);
rotation = (Math.random() * 360);
scaleX = (scaleY = Math.random());
alpha = Math.random();
gotoAndStop(int((Math.random() * 6)));
};
addChild(particle);
i++;
};
}
}
}//package DonttouchBG_fla
Section 99
//BGAnimation_2 (DungeonBG_fla.BGAnimation_2)
package DungeonBG_fla {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import flash.geom.*;
import flash.filters.*;
import flash.text.*;
import flash.net.*;
import flash.media.*;
import flash.ui.*;
import flash.system.*;
import adobe.utils.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.printing.*;
import flash.xml.*;
public dynamic class BGAnimation_2 extends MovieClip {
public var count:uint;
public var i:uint;
public var particle:MovieClip;
public var particleInst1:BGElement;
public var particleInst2:BGElement;
public function BGAnimation_2(){
addFrameScript(0, frame1);
}
function frame1(){
particleInst1.visible = false;
particleInst2.visible = false;
count = 100;
i = 0;
while (i < count) {
particle = new BGElement();
var _local2 = particle;
with (_local2) {
x = (Math.random() * 700);
y = (Math.random() * 480);
rotation = (Math.random() * 360);
scaleX = (scaleY = Math.random());
alpha = Math.random();
gotoAndStop(int((Math.random() * 6)));
};
addChild(particle);
i++;
};
}
}
}//package DungeonBG_fla
Section 100
//BGAnimation_2 (EasyFerryBG_fla.BGAnimation_2)
package EasyFerryBG_fla {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import flash.geom.*;
import flash.filters.*;
import flash.text.*;
import flash.net.*;
import flash.media.*;
import flash.ui.*;
import flash.system.*;
import adobe.utils.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.printing.*;
import flash.xml.*;
public dynamic class BGAnimation_2 extends MovieClip {
public var count:uint;
public var i:uint;
public var particle:MovieClip;
public var particleInst1:BGElement;
public var particleInst2:BGElement;
public function BGAnimation_2(){
addFrameScript(0, frame1);
}
function frame1(){
particleInst1.visible = false;
particleInst2.visible = false;
count = 100;
i = 0;
while (i < count) {
particle = new BGElement();
var _local2 = particle;
with (_local2) {
x = (Math.random() * 700);
y = (Math.random() * 480);
rotation = (Math.random() * 360);
scaleX = (scaleY = Math.random());
alpha = Math.random();
gotoAndStop(int((Math.random() * 6)));
};
addChild(particle);
i++;
};
}
}
}//package EasyFerryBG_fla
Section 101
//BGAnimation_2 (FallBG_fla.BGAnimation_2)
package FallBG_fla {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import flash.geom.*;
import flash.filters.*;
import flash.text.*;
import flash.net.*;
import flash.media.*;
import flash.ui.*;
import flash.system.*;
import adobe.utils.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.printing.*;
import flash.xml.*;
public dynamic class BGAnimation_2 extends MovieClip {
public var count:uint;
public var i:uint;
public var particle:MovieClip;
public var particleInst1:BGElement;
public var particleInst2:BGElement;
public function BGAnimation_2(){
addFrameScript(0, frame1);
}
function frame1(){
particleInst1.visible = false;
particleInst2.visible = false;
count = 100;
i = 0;
while (i < count) {
particle = new BGElement();
var _local2 = particle;
with (_local2) {
x = (Math.random() * 700);
y = (Math.random() * 480);
rotation = (Math.random() * 360);
scaleX = (scaleY = Math.random());
alpha = Math.random();
gotoAndStop(int((Math.random() * 6)));
};
addChild(particle);
i++;
};
}
}
}//package FallBG_fla
Section 102
//lightning_4 (FastGamesIntro_fla.lightning_4)
package FastGamesIntro_fla {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import flash.geom.*;
import flash.filters.*;
import flash.text.*;
import flash.net.*;
import flash.media.*;
import flash.ui.*;
import flash.system.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
public dynamic class lightning_4 extends MovieClip {
public function lightning_4(){
addFrameScript(9, frame10);
}
function frame10(){
stop();
}
}
}//package FastGamesIntro_fla
Section 103
//title_3 (FastGamesIntro_fla.title_3)
package FastGamesIntro_fla {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import flash.geom.*;
import flash.filters.*;
import flash.text.*;
import flash.net.*;
import flash.media.*;
import flash.ui.*;
import flash.system.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
public dynamic class title_3 extends MovieClip {
public function title_3(){
addFrameScript(11, frame12);
}
function frame12(){
parent.play();
stop();
}
}
}//package FastGamesIntro_fla
Section 104
//AnalogTimer_2 (GameTimer_fla.AnalogTimer_2)
package GameTimer_fla {
import flash.display.*;
public dynamic class AnalogTimer_2 extends MovieClip {
public function AnalogTimer_2(){
addFrameScript(49, frame50);
}
function frame50(){
gotoAndPlay(2);
}
}
}//package GameTimer_fla
Section 105
//BGAnimation_2 (GarageBG_fla.BGAnimation_2)
package GarageBG_fla {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import flash.geom.*;
import flash.filters.*;
import flash.text.*;
import flash.net.*;
import flash.media.*;
import flash.ui.*;
import flash.system.*;
import adobe.utils.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.printing.*;
import flash.xml.*;
public dynamic class BGAnimation_2 extends MovieClip {
public var count:uint;
public var i:uint;
public var particle:MovieClip;
public var particleInst1:BGElement;
public var particleInst2:BGElement;
public function BGAnimation_2(){
addFrameScript(0, frame1);
}
function frame1(){
particleInst1.visible = false;
particleInst2.visible = false;
count = 100;
i = 0;
while (i < count) {
particle = new BGElement();
var _local2 = particle;
with (_local2) {
x = (Math.random() * 700);
y = (Math.random() * 480);
rotation = (Math.random() * 360);
scaleX = (scaleY = Math.random());
alpha = Math.random();
gotoAndStop(int((Math.random() * 6)));
};
addChild(particle);
i++;
};
}
}
}//package GarageBG_fla
Section 106
//BGAnimation_2 (HardFerryBG_fla.BGAnimation_2)
package HardFerryBG_fla {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import flash.geom.*;
import flash.filters.*;
import flash.text.*;
import flash.net.*;
import flash.media.*;
import flash.ui.*;
import flash.system.*;
import adobe.utils.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.printing.*;
import flash.xml.*;
public dynamic class BGAnimation_2 extends MovieClip {
public var count:uint;
public var i:uint;
public var particle:MovieClip;
public var particleInst1:BGElement;
public var particleInst2:BGElement;
public function BGAnimation_2(){
addFrameScript(0, frame1);
}
function frame1(){
particleInst1.visible = false;
particleInst2.visible = false;
count = 100;
i = 0;
while (i < count) {
particle = new BGElement();
var _local2 = particle;
with (_local2) {
x = (Math.random() * 700);
y = (Math.random() * 480);
rotation = (Math.random() * 360);
scaleX = (scaleY = Math.random());
alpha = Math.random();
gotoAndStop(int((Math.random() * 6)));
};
addChild(particle);
i++;
};
}
}
}//package HardFerryBG_fla
Section 107
//AcviveCube_71 (HelpMenu_fla.AcviveCube_71)
package HelpMenu_fla {
import flash.display.*;
public dynamic class AcviveCube_71 extends MovieClip {
public function AcviveCube_71(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package HelpMenu_fla
Section 108
//FastGamesLogo_11 (HelpMenu_fla.FastGamesLogo_11)
package HelpMenu_fla {
import flash.events.*;
import flash.display.*;
import flash.net.*;
public dynamic class FastGamesLogo_11 extends MovieClip {
public var btn:SimpleButton;
public function FastGamesLogo_11(){
addFrameScript(0, frame1);
}
function frame1(){
btn.addEventListener(MouseEvent.CLICK, onPlayMoreGames);
}
public function onPlayMoreGames(_arg1:MouseEvent):void{
var _local2:URLRequest;
_local2 = new URLRequest("http://www.fastgames.com/");
navigateToURL(_local2, "_blank");
}
}
}//package HelpMenu_fla
Section 109
//HelpContent_3 (HelpMenu_fla.HelpContent_3)
package HelpMenu_fla {
import flash.events.*;
import flash.display.*;
import flash.net.*;
public dynamic class HelpContent_3 extends MovieClip {
public var btnDownload:SimpleButton;
public function HelpContent_3(){
addFrameScript(0, frame1, 19, frame20);
}
function frame1(){
stop();
}
function frame20(){
btnDownload.addEventListener(MouseEvent.CLICK, onDownload);
}
public function onDownload(_arg1:MouseEvent):void{
var _local2:URLRequest;
_local2 = new URLRequest("http://www.fastgames.com/cubed.zip");
navigateToURL(_local2, "_blank");
}
}
}//package HelpMenu_fla
Section 110
//MuteControl_64 (HelpMenu_fla.MuteControl_64)
package HelpMenu_fla {
import flash.events.*;
import flash.display.*;
public dynamic class MuteControl_64 extends MovieClip {
public var btnMute:SimpleButton;
public var mcWaves:MovieClip;
public function MuteControl_64(){
addFrameScript(0, frame1);
}
function frame1(){
btnMute.addEventListener(MouseEvent.CLICK, onClick);
}
public function onClick(_arg1:MouseEvent):void{
mcWaves.visible = !(mcWaves.visible);
dispatchEvent(new Event("Mute", true));
}
}
}//package HelpMenu_fla
Section 111
//Symbol44_55 (HelpMenu_fla.Symbol44_55)
package HelpMenu_fla {
import flash.display.*;
public dynamic class Symbol44_55 extends MovieClip {
public function Symbol44_55(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package HelpMenu_fla
Section 112
//BGAnimation_2 (HighJumpBG_fla.BGAnimation_2)
package HighJumpBG_fla {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import flash.geom.*;
import flash.filters.*;
import flash.text.*;
import flash.net.*;
import flash.media.*;
import flash.ui.*;
import flash.system.*;
import adobe.utils.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.printing.*;
import flash.xml.*;
public dynamic class BGAnimation_2 extends MovieClip {
public var count:uint;
public var i:uint;
public var particle:MovieClip;
public var particleInst1:BGElement;
public var particleInst2:BGElement;
public function BGAnimation_2(){
addFrameScript(0, frame1);
}
function frame1(){
particleInst1.visible = false;
particleInst2.visible = false;
count = 100;
i = 0;
while (i < count) {
particle = new BGElement();
var _local2 = particle;
with (_local2) {
x = (Math.random() * 700);
y = (Math.random() * 480);
rotation = (Math.random() * 360);
scaleX = (scaleY = Math.random());
alpha = Math.random();
gotoAndStop(int((Math.random() * 6)));
};
addChild(particle);
i++;
};
}
}
}//package HighJumpBG_fla
Section 113
//BGAnimation_2 (HurryBG_fla.BGAnimation_2)
package HurryBG_fla {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import flash.geom.*;
import flash.filters.*;
import flash.text.*;
import flash.net.*;
import flash.media.*;
import flash.ui.*;
import flash.system.*;
import adobe.utils.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.printing.*;
import flash.xml.*;
public dynamic class BGAnimation_2 extends MovieClip {
public var count:uint;
public var i:uint;
public var particle:MovieClip;
public var particleInst1:BGElement;
public var particleInst2:BGElement;
public function BGAnimation_2(){
addFrameScript(0, frame1);
}
function frame1(){
particleInst1.visible = false;
particleInst2.visible = false;
count = 100;
i = 0;
while (i < count) {
particle = new BGElement();
var _local2 = particle;
with (_local2) {
x = (Math.random() * 700);
y = (Math.random() * 480);
rotation = (Math.random() * 360);
scaleX = (scaleY = Math.random());
alpha = Math.random();
gotoAndStop(int((Math.random() * 6)));
};
addChild(particle);
i++;
};
}
}
}//package HurryBG_fla
Section 114
//BGAnimation_2 (JumpsBG_fla.BGAnimation_2)
package JumpsBG_fla {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import flash.geom.*;
import flash.filters.*;
import flash.text.*;
import flash.net.*;
import flash.media.*;
import flash.ui.*;
import flash.system.*;
import adobe.utils.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.printing.*;
import flash.xml.*;
public dynamic class BGAnimation_2 extends MovieClip {
public var count:uint;
public var i:uint;
public var particle:MovieClip;
public var particleInst1:BGElement;
public var particleInst2:BGElement;
public function BGAnimation_2(){
addFrameScript(0, frame1);
}
function frame1(){
particleInst1.visible = false;
particleInst2.visible = false;
count = 100;
i = 0;
while (i < count) {
particle = new BGElement();
var _local2 = particle;
with (_local2) {
x = (Math.random() * 700);
y = (Math.random() * 480);
rotation = (Math.random() * 360);
scaleX = (scaleY = Math.random());
alpha = Math.random();
gotoAndStop(int((Math.random() * 6)));
};
addChild(particle);
i++;
};
}
}
}//package JumpsBG_fla
Section 115
//ItemDesc (levels.ItemDesc)
package levels {
public class ItemDesc {
public var props:Object;
public var className:Class;
public function ItemDesc(_arg1:Class, _arg2:Object=null){
className = _arg1;
props = _arg2;
}
}
}//package levels
Section 116
//LevelDesc (levels.LevelDesc)
package levels {
public class LevelDesc {
public var bgSkin:Class;
public var others:Array;
public var boxes:Array;
public function LevelDesc(){
boxes = new Array();
others = new Array();
}
}
}//package levels
Section 117
//Levels (levels.Levels)
package levels {
import flash.events.*;
import memory.*;
import sceneElements.*;
public class Levels {
private var _levels:Array;
public var levelsCount:uint;// = 20
private var _curLevelNo:uint;
private static var _instance:Levels;
public function Levels(_arg1:SingletonEnforcer){
_levels = ["", "stairs", "tower", "columns", "swing", "cannon", "rotator", "donttouch", "garage", "board", "easyFerry", "dominoes", "lift", "rotors", "jumps", "highJump", "hardFerry", "dungeon", "fall", "threeWays", "hurry"];
super();
MouseEvent.ROLL_OVER;
_curLevelNo = 1;
}
public function get curLevelNo():uint{
return (_curLevelNo);
}
public function get lastLoadedLevel():LevelDesc{
return (getLevelByNo(_curLevelNo));
}
public function get stairs():LevelDesc{
var levelDesc:LevelDesc = new LevelDesc();
levelDesc.bgSkin = StairsBG;
var _local2 = levelDesc.boxes;
with (_local2) {
push(new ItemDesc(Box1, {x:100, y:200}));
};
_local2 = levelDesc.others;
with (_local2) {
push(new ItemDesc(Walls));
push(new ItemDesc(Target, {x:605, y:40}));
push(new ItemDesc(VoluntaryBox, {x:80, y:325, w:160, h:100, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:395, y:329, w:50, h:90, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:445, y:300, w:50, h:150, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:495, y:275, w:50, h:200, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:580, y:244, w:120, h:260, isStatic:true}));
push(new ItemDesc(Bomb, {x:445, y:200}));
};
return (levelDesc);
}
public function get lift():LevelDesc{
var levelDesc:LevelDesc = new LevelDesc();
levelDesc.bgSkin = LiftBG;
var _local2 = levelDesc.boxes;
with (_local2) {
push(new ItemDesc(Box1, {x:320, y:300}));
push(new ItemDesc(Box2, {x:150, y:150}));
push(new ItemDesc(Box3, {x:500, y:150}));
};
_local2 = levelDesc.others;
with (_local2) {
push(new ItemDesc(Walls));
push(new ItemDesc(Target, {x:320, y:90}));
push(new ItemDesc(VoluntaryBox, {x:50, y:335, w:100, h:80, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:590, y:335, w:100, h:80, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:150, y:220, w:80, h:20, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:500, y:220, w:80, h:20, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:250, y:335, w:20, h:80, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:400, y:335, w:20, h:80, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:250, y:230, w:20, h:80, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:400, y:230, w:20, h:80, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:250, y:125, w:20, h:80, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:400, y:125, w:20, h:80, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:325, y:50, w:170, h:20, isStatic:true}));
push(new ItemDesc(MovablePlate, {x:40, y:276, w:80, h:8}));
push(new ItemDesc(MovablePlate, {x:600, y:180, w:80, h:8}));
};
return (levelDesc);
}
public function get jumps():LevelDesc{
var levelDesc:LevelDesc = new LevelDesc();
levelDesc.bgSkin = JumpsBG;
var _local2 = levelDesc.boxes;
with (_local2) {
push(new ItemDesc(Box1, {x:500, y:320}));
push(new ItemDesc(Box2, {x:0xFF, y:320}));
};
_local2 = levelDesc.others;
with (_local2) {
push(new ItemDesc(Walls));
push(new ItemDesc(Target, {x:605, y:150}));
push(new ItemDesc(VoluntaryBox, {x:70, y:340, w:140, h:70, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:25, y:244, w:50, h:120, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:590, y:274, w:100, h:200, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:555, y:120, w:30, h:110, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:600, y:-4, w:80, h:20, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:40, y:-4, w:80, h:20, isStatic:true}));
push(new ItemDesc(SleepBox, {x:130, y:180, w:40, h:40, angularDamping:5, linearDamping:3}));
push(new ItemDesc(SleepBox, {x:250, y:160, w:40, h:40, angularDamping:15, linearDamping:4}));
push(new ItemDesc(SleepBox, {x:370, y:135, w:40, h:40, angularDamping:15, linearDamping:3}));
push(new ItemDesc(SleepBox, {x:470, y:110, w:40, h:40, angularDamping:15, linearDamping:5}));
push(new ItemDesc(Bomb, {x:195, y:325}));
push(new ItemDesc(Bomb, {x:315, y:325}));
};
return (levelDesc);
}
public function get tower():LevelDesc{
var levelDesc:LevelDesc = new LevelDesc();
levelDesc.bgSkin = TowerBG;
var _local2 = levelDesc.boxes;
with (_local2) {
push(new ItemDesc(Box1, {x:450, y:290}));
push(new ItemDesc(Box2, {x:150, y:200}));
push(new ItemDesc(Box3, {x:500, y:250}));
};
_local2 = levelDesc.others;
with (_local2) {
push(new ItemDesc(Walls));
push(new ItemDesc(Target, {x:220, y:155}));
push(new ItemDesc(VoluntaryBox, {x:220, y:260, w:70, h:140, isStatic:true}));
};
return (levelDesc);
}
public function get nextLevel():LevelDesc{
if (_curLevelNo < levelsCount){
Memory.getInstance().updateProgress((_curLevelNo + 1));
return (getLevelByNo((_curLevelNo + 1)));
};
return (null);
}
public function get hurry():LevelDesc{
var levelDesc:LevelDesc = new LevelDesc();
levelDesc.bgSkin = HurryBG;
var _local2 = levelDesc.boxes;
with (_local2) {
push(new ItemDesc(Box1, {x:25, y:250}));
push(new ItemDesc(Box2, {x:500, y:200}));
push(new ItemDesc(Box3, {x:140, y:340}));
};
_local2 = levelDesc.others;
with (_local2) {
push(new ItemDesc(Walls));
push(new ItemDesc(Target, {x:40, y:60}));
push(new ItemDesc(VoluntaryBox, {x:25, y:335, w:50, h:80, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:100, y:127, w:200, h:50, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:219, y:177, w:130, h:50, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:297, y:208, w:26, h:113, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:378, y:247, w:140, h:35, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:500, y:0xFF, w:100, h:50, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:572, y:265, w:30, h:70, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:580, y:160, w:40, h:16, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:500, y:160, w:102, h:16, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:399, y:172, w:100, h:40, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:295, y:145, w:130, h:6, isStatic:false}));
push(new ItemDesc(VoluntaryBox, {x:95, y:-32, w:10, h:200, isStatic:true}));
push(new ItemDesc(SleepBox, {x:136, y:33, w:50, h:50}));
push(new ItemDesc(SleepBox, {x:555, y:210, w:6, h:120}));
push(new ItemDesc(Bomb, {x:80, y:345}));
push(new ItemDesc(Wheel, {x:220, y:50, r:30}));
};
return (levelDesc);
}
public function get donttouch():LevelDesc{
var levelDesc:LevelDesc = new LevelDesc();
levelDesc.bgSkin = DonttouchBG;
var _local2 = levelDesc.boxes;
with (_local2) {
push(new ItemDesc(Box1, {x:580, y:150}));
};
_local2 = levelDesc.others;
with (_local2) {
push(new ItemDesc(Walls));
push(new ItemDesc(Target, {x:150, y:335}));
push(new ItemDesc(VoluntaryBox, {x:148, y:269, w:200, h:40, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:590, y:275, w:100, h:200, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:380, y:315, w:20, h:120, isStatic:false}));
push(new ItemDesc(VoluntaryBox, {x:470, y:275, w:20, h:200, isStatic:false}));
push(new ItemDesc(VoluntaryBox, {x:470, y:172, w:60, h:8, isStatic:false}));
push(new ItemDesc(Autoreset, {x:264, y:270}));
push(new ItemDesc(Autoreset, {x:344, y:270}));
push(new ItemDesc(Autoreset, {x:150, y:230}));
};
return (levelDesc);
}
public function get dominoes():LevelDesc{
var levelDesc:LevelDesc = new LevelDesc();
levelDesc.bgSkin = DominoesBG;
var _local2 = levelDesc.boxes;
with (_local2) {
push(new ItemDesc(Box1, {x:300, y:300}));
};
_local2 = levelDesc.others;
with (_local2) {
push(new ItemDesc(Walls));
push(new ItemDesc(Target, {x:0x0100, y:130}));
push(new ItemDesc(VoluntaryBox, {x:150, y:360, w:30, h:30, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:150, y:340, w:250, h:10, isStatic:false}));
push(new ItemDesc(VoluntaryBox, {x:240, y:100, w:300, h:20, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:190, y:55, w:10, h:70, isStatic:false}));
push(new ItemDesc(VoluntaryBox, {x:240, y:55, w:10, h:70, isStatic:false}));
push(new ItemDesc(VoluntaryBox, {x:290, y:55, w:10, h:70, isStatic:false}));
push(new ItemDesc(VoluntaryBox, {x:340, y:55, w:10, h:70, isStatic:false}));
push(new ItemDesc(VoluntaryBox, {x:387, y:55, w:10, h:70, isStatic:false}));
push(new ItemDesc(VoluntaryBox, {x:350, y:160, w:80, h:120, isStatic:true}));
push(new ItemDesc(Bomb, {x:550, y:60}));
push(new ItemDesc(Bomb, {x:550, y:300}));
push(new ItemDesc(Wheel, {x:134, y:60, r:30}));
};
return (levelDesc);
}
public function get columns():LevelDesc{
var levelDesc:LevelDesc = new LevelDesc();
levelDesc.bgSkin = ColumnsBG;
var _local2 = levelDesc.boxes;
with (_local2) {
push(new ItemDesc(Box1, {x:35, y:160}));
push(new ItemDesc(Box2, {x:40, y:160}));
push(new ItemDesc(Box3, {x:30, y:100}));
};
_local2 = levelDesc.others;
with (_local2) {
push(new ItemDesc(Walls));
push(new ItemDesc(Target, {x:540, y:60}));
push(new ItemDesc(VoluntaryBox, {x:47, y:272, w:94, h:156, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:195, y:272, w:30, h:156, isStatic:false}));
push(new ItemDesc(VoluntaryBox, {x:367, y:272, w:30, h:156, isStatic:false}));
push(new ItemDesc(VoluntaryBox, {x:400, y:300, w:20, h:20, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:368, y:180, w:135, h:20, isStatic:false}));
push(new ItemDesc(VoluntaryBox, {x:195, y:180, w:80, h:18, isStatic:false}));
};
return (levelDesc);
}
public function get threeWays():LevelDesc{
var levelDesc:LevelDesc = new LevelDesc();
levelDesc.bgSkin = ThreeWaysBG;
var _local2 = levelDesc.boxes;
with (_local2) {
push(new ItemDesc(Box1, {x:60, y:200}));
push(new ItemDesc(Box2, {x:80, y:240}));
push(new ItemDesc(Box3, {x:50, y:100}));
};
_local2 = levelDesc.others;
with (_local2) {
push(new ItemDesc(Walls));
push(new ItemDesc(Target, {x:610, y:50}));
push(new ItemDesc(VoluntaryBox, {x:160, y:324, w:30, h:101, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:310, y:267, w:30, h:214, isStatic:false}));
push(new ItemDesc(VoluntaryBox, {x:430, y:254, w:30, h:240, isStatic:false}));
push(new ItemDesc(VoluntaryBox, {x:615, y:115, w:50, h:50, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:230, y:360, w:80, h:30, isStatic:true}));
push(new ItemDesc(Bomb, {x:280, y:325}));
};
return (levelDesc);
}
public function getLevelByNo(_arg1:uint):LevelDesc{
_curLevelNo = _arg1;
trace(("Opening level: " + _levels[_curLevelNo]));
return (this[_levels[_curLevelNo]]);
}
public function get garage():LevelDesc{
var levelDesc:LevelDesc = new LevelDesc();
levelDesc.bgSkin = GarageBG;
var _local2 = levelDesc.boxes;
with (_local2) {
push(new ItemDesc(Box1, {x:50, y:100}));
push(new ItemDesc(Box2, {x:500, y:100}));
};
_local2 = levelDesc.others;
with (_local2) {
push(new ItemDesc(Walls));
push(new ItemDesc(Target, {x:570, y:330}));
push(new ItemDesc(Autoreset, {x:370, y:343}));
push(new ItemDesc(VoluntaryBox, {x:60, y:295, w:120, h:160, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:320, y:250, w:40, h:250, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:465, y:135, w:250, h:20, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:526, y:190, w:228, h:20, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:454, y:339, w:20, h:70, isStatic:true}));
push(new ItemDesc(MovablePlate, {x:370, y:100, w:100, h:8}));
};
return (levelDesc);
}
public function get rotator():LevelDesc{
var levelDesc:LevelDesc = new LevelDesc();
levelDesc.bgSkin = RotatorBG;
var _local2 = levelDesc.boxes;
with (_local2) {
push(new ItemDesc(Box1, {x:110, y:130}));
push(new ItemDesc(Box2, {x:560, y:170}));
push(new ItemDesc(Box3, {x:50, y:110}));
};
_local2 = levelDesc.others;
with (_local2) {
push(new ItemDesc(Walls));
push(new ItemDesc(Target, {x:325, y:35}));
push(new ItemDesc(VoluntaryBox, {x:60, y:297, w:180, h:156, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:580, y:297, w:120, h:156, isStatic:true}));
push(new ItemDesc(Rotator, {x:325, y:260, w:160, h:20, speed:1, torque:3}));
};
return (levelDesc);
}
public function get levelNo4():LevelDesc{
var levelDesc:LevelDesc = new LevelDesc();
var _local2 = levelDesc.boxes;
with (_local2) {
push(new ItemDesc(Box1, {x:95, y:190}));
};
_local2 = levelDesc.others;
with (_local2) {
push(new ItemDesc(Walls));
push(new ItemDesc(VoluntaryBox, {x:50, y:290, w:100, h:170, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:590, y:234, w:100, h:280, isStatic:true}));
push(new ItemDesc(Rotator, {x:175, y:195, w:70, h:10, speed:0.5, torque:5}));
push(new ItemDesc(Rotator, {x:310, y:160, w:10, h:120, speed:0.4, torque:5}));
push(new ItemDesc(Rotator, {x:450, y:130, w:80, h:10, speed:2, torque:5}));
push(new ItemDesc(Target, {x:600, y:20}));
push(new ItemDesc(Bomb, {x:445, y:300}));
};
return (levelDesc);
}
public function get highJump():LevelDesc{
var levelDesc:LevelDesc = new LevelDesc();
levelDesc.bgSkin = HighJumpBG;
var _local2 = levelDesc.boxes;
with (_local2) {
push(new ItemDesc(Box1, {x:600, y:300}));
push(new ItemDesc(Box2, {x:150, y:250}));
};
_local2 = levelDesc.others;
with (_local2) {
push(new ItemDesc(Target, {x:100, y:175}));
push(new ItemDesc(Walls));
push(new ItemDesc(VoluntaryBox, {x:515, y:10, w:250, h:30, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:195, y:10, w:390, h:30, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:490, y:250, w:30, h:250, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:405, y:125, w:30, h:250, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:285, y:250, w:30, h:250, isStatic:true}));
push(new ItemDesc(Bomb, {x:560, y:340}));
push(new ItemDesc(Bomb, {x:330, y:340}));
push(new ItemDesc(SleepBox, {x:355, y:30, w:30, h:30}));
push(new ItemDesc(SleepBox, {x:325, y:30, w:30, h:30}));
};
return (levelDesc);
}
public function get board():LevelDesc{
var levelDesc:LevelDesc = new LevelDesc();
levelDesc.bgSkin = BoardBG;
var _local2 = levelDesc.boxes;
with (_local2) {
push(new ItemDesc(Box1, {x:95, y:190}));
push(new ItemDesc(Box2, {x:46, y:190}));
push(new ItemDesc(Box3, {x:310, y:180}));
};
_local2 = levelDesc.others;
with (_local2) {
push(new ItemDesc(Walls));
push(new ItemDesc(Target, {x:565, y:55}));
push(new ItemDesc(VoluntaryBox, {x:160, y:297, w:320, h:156, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:300, y:209, w:0x0100, h:19, isStatic:false}));
};
return (levelDesc);
}
public function get hardFerry():LevelDesc{
var levelDesc:LevelDesc = new LevelDesc();
levelDesc.bgSkin = HardFerryBG;
var _local2 = levelDesc.boxes;
with (_local2) {
push(new ItemDesc(Box1, {x:500, y:200}));
};
_local2 = levelDesc.others;
with (_local2) {
push(new ItemDesc(Walls));
push(new ItemDesc(Target, {x:610, y:5}));
push(new ItemDesc(MovablePlate, {x:55, y:300, w:100, h:8}));
push(new ItemDesc(MovablePlate, {x:580, y:205, w:100, h:8}));
push(new ItemDesc(MovablePlate, {x:55, y:105, w:100, h:8}));
push(new ItemDesc(VoluntaryBox, {x:610, y:35, w:60, h:6, isStatic:true}));
push(new ItemDesc(Rotator, {x:320, y:155, w:16, h:110, speed:1, torque:10}));
push(new ItemDesc(Rotator, {x:320, y:266, w:80, h:16, speed:1.2, torque:10}));
};
return (levelDesc);
}
public function get easyFerry():LevelDesc{
var levelDesc:LevelDesc = new LevelDesc();
levelDesc.bgSkin = EasyFerryBG;
var _local2 = levelDesc.boxes;
with (_local2) {
push(new ItemDesc(Box1, {x:560, y:200}));
};
_local2 = levelDesc.others;
with (_local2) {
push(new ItemDesc(Walls));
push(new ItemDesc(Target, {x:34, y:25}));
push(new ItemDesc(MovablePlate, {x:450, y:300, w:100, h:8}));
push(new ItemDesc(MovablePlate, {x:160, y:205, w:100, h:8}));
push(new ItemDesc(MovablePlate, {x:420, y:70, w:100, h:8}));
push(new ItemDesc(VoluntaryBox, {x:420, y:170, w:20, h:40, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:200, y:170, w:20, h:40, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:30, y:50, w:60, h:6, isStatic:true}));
};
return (levelDesc);
}
public function get rotors():LevelDesc{
var levelDesc:LevelDesc = new LevelDesc();
levelDesc.bgSkin = RotorsBG;
var _local2 = levelDesc.boxes;
with (_local2) {
push(new ItemDesc(Box1, {x:600, y:290}));
push(new ItemDesc(Box2, {x:400, y:220}));
push(new ItemDesc(Box3, {x:500, y:350}));
};
_local2 = levelDesc.others;
with (_local2) {
push(new ItemDesc(Walls));
push(new ItemDesc(Crank, {x:0xFF, y:100}));
push(new ItemDesc(Crank, {x:400, y:120}));
push(new ItemDesc(Rotator, {x:60, y:165, w:100, h:6, speed:0, torque:9}));
push(new ItemDesc(Rotator, {x:190, y:175, w:90, h:15, speed:0.3, torque:9}));
push(new ItemDesc(Rotator, {x:320, y:155, w:100, h:10, speed:0, torque:9}));
push(new ItemDesc(Rotator, {x:450, y:210, w:70, h:70, speed:0.2, torque:2}));
push(new ItemDesc(Target, {x:25, y:50}));
};
return (levelDesc);
}
public function get dungeon():LevelDesc{
var levelDesc:LevelDesc = new LevelDesc();
levelDesc.bgSkin = DungeonBG;
var _local2 = levelDesc.boxes;
with (_local2) {
push(new ItemDesc(Box1, {x:615, y:330}));
push(new ItemDesc(Box2, {x:602, y:100}));
};
_local2 = levelDesc.others;
with (_local2) {
push(new ItemDesc(Walls));
push(new ItemDesc(Target, {x:63, y:74}));
push(new ItemDesc(VoluntaryBox, {x:75, y:274, w:150, h:200, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:135, y:50, w:30, h:130, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:385, y:274, w:20, h:200, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:435, y:164, w:120, h:20, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:590, y:164, w:100, h:20, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:436, y:107, w:60, h:20, isStatic:true}));
push(new ItemDesc(MovablePlate, {x:520, y:70, w:100, h:8, isStatic:true}));
push(new ItemDesc(Rotator, {x:300, y:30, w:100, h:10, speed:2, torque:8}));
push(new ItemDesc(Bomb, {x:520, y:340}));
push(new ItemDesc(Bomb, {x:456, y:135}));
};
return (levelDesc);
}
public function get fall():LevelDesc{
var levelDesc:LevelDesc = new LevelDesc();
levelDesc.bgSkin = FallBG;
var _local2 = levelDesc.boxes;
with (_local2) {
push(new ItemDesc(Box1, {x:100, y:30}));
push(new ItemDesc(Box2, {x:200, y:350}));
};
_local2 = levelDesc.others;
with (_local2) {
push(new ItemDesc(Walls));
push(new ItemDesc(Target, {x:425, y:20}));
push(new ItemDesc(VoluntaryBox, {x:75, y:223, w:150, h:300, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:210, y:310, w:120, h:20, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:435, y:310, w:250, h:20, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:545, y:275, w:30, h:50, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:542, y:192, w:30, h:50, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:480, y:120, w:60, h:20, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:420, y:60, w:60, h:20, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:380, y:-15.5, w:20, h:171, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:440, y:100, w:20, h:60, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:520, y:160, w:20, h:60, isStatic:true}));
push(new ItemDesc(MovablePlate, {x:480, y:233, w:100, h:8}));
push(new ItemDesc(Rotator, {x:310, y:75, w:100, h:10, speed:2, torque:8}));
push(new ItemDesc(Bomb, {x:0xFF, y:270}));
push(new ItemDesc(Bomb, {x:325, y:270}));
push(new ItemDesc(Autoreset, {x:190, y:200}));
};
return (levelDesc);
}
public function get cannon():LevelDesc{
var levelDesc:LevelDesc = new LevelDesc();
levelDesc.bgSkin = CannonBG;
var _local2 = levelDesc.boxes;
with (_local2) {
push(new ItemDesc(Box1, {x:80, y:200}));
push(new ItemDesc(Box2, {x:120, y:200}));
};
_local2 = levelDesc.others;
with (_local2) {
push(new ItemDesc(Walls));
push(new ItemDesc(Target, {x:600, y:100}));
push(new ItemDesc(VoluntaryBox, {x:75, y:299, w:150, h:150, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:565, y:274, w:150, h:200, isStatic:false}));
push(new ItemDesc(VoluntaryBox, {x:35, y:159, w:70, h:130, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:35, y:20, w:70, h:50, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:515, y:60, w:30, h:100, isStatic:true}));
push(new ItemDesc(SleepBox, {x:250, y:170, w:40, h:40, angularDamping:10, linearDamping:1}));
push(new ItemDesc(SleepBox, {x:370, y:155, w:40, h:40, angularDamping:10, linearDamping:1}));
push(new ItemDesc(Bomb, {x:16, y:70}));
};
return (levelDesc);
}
public function get swing():LevelDesc{
var levelDesc:LevelDesc = new LevelDesc();
levelDesc.bgSkin = SwingBG;
var _local2 = levelDesc.boxes;
with (_local2) {
push(new ItemDesc(Box1, {x:450, y:300}));
push(new ItemDesc(Box2, {x:520, y:50}));
push(new ItemDesc(Box3, {x:20, y:300}));
push(new ItemDesc(Box4, {x:600, y:50}));
};
_local2 = levelDesc.others;
with (_local2) {
push(new ItemDesc(Walls));
push(new ItemDesc(Target, {x:100, y:80}));
push(new ItemDesc(VoluntaryBox, {x:560, y:244, w:160, h:260, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:220, y:350, w:20, h:50, isStatic:false}));
push(new ItemDesc(VoluntaryBox, {x:220, y:325, w:300, h:4, isStatic:false}));
};
return (levelDesc);
}
public function get maze():LevelDesc{
var levelDesc:LevelDesc = new LevelDesc();
var _local2 = levelDesc.boxes;
with (_local2) {
push(new ItemDesc(Box1, {x:75, y:10}));
};
_local2 = levelDesc.others;
with (_local2) {
push(new ItemDesc(Walls));
push(new ItemDesc(Target, {x:590, y:325}));
push(new ItemDesc(VoluntaryBox, {x:75, y:100, w:50, h:50, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:75, y:200, w:50, h:50, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:75, y:300, w:50, h:50, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:175, y:100, w:50, h:50, isStatic:true}));
push(new ItemDesc(SleepBox, {x:175, y:200, w:50, h:50}));
push(new ItemDesc(VoluntaryBox, {x:175, y:300, w:50, h:50, isStatic:true}));
push(new ItemDesc(SleepBox, {x:275, y:100, w:50, h:50}));
push(new ItemDesc(VoluntaryBox, {x:275, y:200, w:50, h:50, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:275, y:300, w:50, h:50, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:375, y:100, w:50, h:50, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:375, y:200, w:50, h:50, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:375, y:300, w:50, h:50, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:475, y:100, w:50, h:50, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:475, y:200, w:50, h:50, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:475, y:300, w:50, h:50, isStatic:true}));
push(new ItemDesc(VoluntaryBox, {x:590, y:285, w:80, h:20, isStatic:true}));
push(new ItemDesc(Bomb, {x:373, y:-12}));
push(new ItemDesc(Bomb, {x:373, y:43}));
push(new ItemDesc(Bomb, {x:22, y:150}));
push(new ItemDesc(Bomb, {x:225, y:250}));
push(new ItemDesc(Autoreset, {x:125, y:100}));
push(new ItemDesc(Autoreset, {x:420, y:150}));
push(new ItemDesc(Autoreset, {x:325, y:250}));
push(new ItemDesc(Autoreset, {x:25, y:350}));
push(new ItemDesc(Autoreset, {x:475, y:350}));
};
return (levelDesc);
}
public static function getInstance():Levels{
if (_instance == null){
_instance = new Levels(new SingletonEnforcer());
};
return (_instance);
}
}
}//package levels
class SingletonEnforcer {
private function SingletonEnforcer(){
}
}
Section 118
//BGAnimation_2 (LiftBG_fla.BGAnimation_2)
package LiftBG_fla {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import flash.geom.*;
import flash.filters.*;
import flash.text.*;
import flash.net.*;
import flash.media.*;
import flash.ui.*;
import flash.system.*;
import adobe.utils.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.printing.*;
import flash.xml.*;
public dynamic class BGAnimation_2 extends MovieClip {
public var count:uint;
public var i:uint;
public var particle:MovieClip;
public var particleInst1:BGElement;
public var particleInst2:BGElement;
public function BGAnimation_2(){
addFrameScript(0, frame1);
}
function frame1(){
particleInst1.visible = false;
particleInst2.visible = false;
count = 100;
i = 0;
while (i < count) {
particle = new BGElement();
var _local2 = particle;
with (_local2) {
x = (Math.random() * 700);
y = (Math.random() * 480);
rotation = (Math.random() * 360);
scaleX = (scaleY = Math.random());
alpha = Math.random();
gotoAndStop(int((Math.random() * 6)));
};
addChild(particle);
i++;
};
}
}
}//package LiftBG_fla
Section 119
//Memory (memory.Memory)
package memory {
import flash.net.*;
public class Memory {
public var arrRecords:Array;
public var allowSound:Boolean;// = true
public var soundVolume:Number;// = 50
public var numUnlockedLevels:uint;// = 1
private var _so:SharedObject;
private static var _instance:Memory;
public function Memory(_arg1:SingletonEnforcer){
arrRecords = new Array();
super();
init();
}
private function init():void{
_so = SharedObject.getLocal("cubedGameData");
if (_so.data.allowSound != undefined){
allowSound = _so.data.allowSound;
};
if (_so.data.soundVolume != undefined){
soundVolume = _so.data.soundVolume;
};
if (_so.data.numUnlockedLevels != undefined){
numUnlockedLevels = _so.data.numUnlockedLevels;
} else {
updateProgress(1);
};
if (_so.data.arrRecords != undefined){
arrRecords = _so.data.arrRecords;
};
}
public function updateRecords(_arg1:uint, _arg2:uint):void{
_arg1--;
if (_arg2 < 300000){
if (arrRecords[_arg1]){
if (_arg2 < arrRecords[_arg1]){
arrRecords[_arg1] = _arg2;
};
} else {
arrRecords[_arg1] = _arg2;
};
_so.data.arrRecords = arrRecords;
_so.flush();
};
}
public function clearProgress():void{
numUnlockedLevels = 1;
arrRecords = new Array();
_so.data.numUnlockedLevels = numUnlockedLevels;
_so.data.arrRecords = arrRecords;
_so.flush();
}
public function updateProgress(_arg1:uint):void{
if (_arg1 > numUnlockedLevels){
numUnlockedLevels = _arg1;
_so.data.numUnlockedLevels = numUnlockedLevels;
_so.flush();
};
}
public static function getInstance():Memory{
if (_instance == null){
_instance = new Memory(new SingletonEnforcer());
};
return (_instance);
}
}
}//package memory
class SingletonEnforcer {
private function SingletonEnforcer(){
}
}
Section 120
//Records (memory.Records)
package memory {
import flash.utils.*;
public class Records {
private var _startTime:Number;
private static var _instance:Records;
public function Records(_arg1:SingletonEnforcer){
init();
}
private function init():void{
}
public function stopRec():Number{
return ((getTimer() - _startTime));
}
public function startRec():void{
_startTime = getTimer();
}
public static function getInstance():Records{
if (_instance == null){
_instance = new Records(new SingletonEnforcer());
};
return (_instance);
}
}
}//package memory
class SingletonEnforcer {
private function SingletonEnforcer(){
}
}
Section 121
//MochiCoins (mochi.as3.MochiCoins)
package mochi.as3 {
public class MochiCoins {
public static const STORE_HIDE:String = "StoreHide";
public static const LOGGED_IN:String = "LoggedIn";
public static const STORE_ITEMS:String = "StoreItems";
public static const NO_USER:String = "NoUser";
public static const PROPERTIES_SIZE:String = "PropertiesSize";
public static const ITEM_NEW:String = "ItemNew";
public static const USER_INFO:String = "UserInfo";
public static const IO_ERROR:String = "IOError";
public static const ITEM_OWNED:String = "ItemOwned";
public static const PROPERTIES_SAVED:String = "PropertySaved";
public static const WIDGET_LOADED:String = "WidgetLoaded";
public static const ERROR:String = "Error";
public static const LOGGED_OUT:String = "LoggedOut";
public static const PROFILE_SHOW:String = "ProfileShow";
public static const LOGIN_HIDE:String = "LoginHide";
public static const LOGIN_SHOW:String = "LoginShow";
public static const STORE_SHOW:String = "StoreShow";
public static const PROFILE_HIDE:String = "ProfileHide";
private static var _dispatcher:MochiEventDispatcher = new MochiEventDispatcher();
public static function showItem(_arg1:Object=null):void{
if (((!(_arg1)) || (!((typeof(_arg1.item) == "string"))))){
trace("ERROR: showItem call must pass an Object with an item key");
return;
};
MochiServices.bringToTop();
MochiServices.send("coins_showItem", {options:_arg1}, null, null);
}
public static function saveUserProperties(_arg1:Object):void{
MochiServices.send("coins_saveUserProperties", _arg1);
}
public static function triggerEvent(_arg1:String, _arg2:Object):void{
_dispatcher.triggerEvent(_arg1, _arg2);
}
public static function showLoginWidget(_arg1:Object=null):void{
MochiServices.setContainer();
MochiServices.bringToTop();
MochiServices.send("coins_showLoginWidget", {options:_arg1});
}
public static function getStoreItems():void{
MochiServices.send("coins_getStoreItems");
}
public static function getVersion():String{
return (MochiServices.getVersion());
}
public static function showStore(_arg1:Object=null):void{
MochiServices.bringToTop();
MochiServices.send("coins_showStore", {options:_arg1}, null, null);
}
public static function addEventListener(_arg1:String, _arg2:Function):void{
_dispatcher.addEventListener(_arg1, _arg2);
}
public static function getUserInfo():void{
MochiServices.send("coins_getUserInfo");
}
public static function hideLoginWidget():void{
MochiServices.send("coins_hideLoginWidget");
}
public static function removeEventListener(_arg1:String, _arg2:Function):void{
_dispatcher.removeEventListener(_arg1, _arg2);
}
public static function showVideo(_arg1:Object=null):void{
if (((!(_arg1)) || (!((typeof(_arg1.item) == "string"))))){
trace("ERROR: showVideo call must pass an Object with an item key");
return;
};
MochiServices.bringToTop();
MochiServices.send("coins_showVideo", {options:_arg1}, null, null);
}
}
}//package mochi.as3
Section 122
//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 reencode():void{
var _local1:uint = int((2147483647 * Math.random()));
Fragment = (Fragment ^ (_local1 ^ Encoder));
Encoder = _local1;
}
public function set value(_arg1:Number):void{
setValue(_arg1);
}
public function toString():String{
var _local1:String = String.fromCharCode((Fragment ^ Encoder));
if (Sibling != null){
_local1 = (_local1 + Sibling.toString());
};
return (_local1);
}
public function setValue(_arg1:Number=0, _arg2:uint=0):void{
var _local3:String = _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 get value():Number{
return (Number(this.toString()));
}
public function addValue(_arg1:Number):void{
value = (value + _arg1);
}
}
}//package mochi.as3
Section 123
//MochiEventDispatcher (mochi.as3.MochiEventDispatcher)
package mochi.as3 {
public class MochiEventDispatcher {
private var eventTable:Object;
public function MochiEventDispatcher():void{
eventTable = {};
}
public function triggerEvent(_arg1:String, _arg2:Object):void{
var _local3:Object;
if (eventTable[_arg1] == undefined){
return;
};
for (_local3 in eventTable[_arg1]) {
var _local6 = eventTable[_arg1];
_local6[_local3](_arg2);
};
}
public function removeEventListener(_arg1:String, _arg2:Function):void{
var _local3:Object;
if (eventTable[_arg1] == undefined){
eventTable[_arg1] = [];
return;
};
for (_local3 in eventTable[_arg1]) {
if (eventTable[_arg1][_local3] != _arg2){
} else {
eventTable[_arg1].splice(Number(_local3), 1);
};
};
}
public function addEventListener(_arg1:String, _arg2:Function):void{
removeEventListener(_arg1, _arg2);
eventTable[_arg1].push(_arg2);
}
}
}//package mochi.as3
Section 124
//MochiEvents (mochi.as3.MochiEvents)
package mochi.as3 {
import flash.display.*;
public class MochiEvents {
public static const ALIGN_BOTTOM_LEFT:String = "ALIGN_BL";
public static const FORMAT_LONG:String = "LongForm";
public static const ALIGN_BOTTOM:String = "ALIGN_B";
public static const ACHIEVEMENT_RECEIVED:String = "AchievementReceived";
public static const FORMAT_SHORT:String = "ShortForm";
public static const ALIGN_TOP_RIGHT:String = "ALIGN_TR";
public static const ALIGN_BOTTOM_RIGHT:String = "ALIGN_BR";
public static const ALIGN_TOP:String = "ALIGN_T";
public static const ALIGN_LEFT:String = "ALIGN_L";
public static const ALIGN_RIGHT:String = "ALIGN_R";
public static const ALIGN_TOP_LEFT:String = "ALIGN_TL";
public static const ALIGN_CENTER:String = "ALIGN_C";
private static var _dispatcher:MochiEventDispatcher = new MochiEventDispatcher();
private static var gameStart:Number;
private static var levelStart:Number;
public static function addEventListener(_arg1:String, _arg2:Function):void{
_dispatcher.addEventListener(_arg1, _arg2);
}
public static function removeEventListener(_arg1:String, _arg2:Function):void{
_dispatcher.removeEventListener(_arg1, _arg2);
}
public static function startSession(_arg1:String):void{
MochiServices.send("events_beginSession", {achievementID:_arg1}, null, null);
}
public static function triggerEvent(_arg1:String, _arg2:Object):void{
_dispatcher.triggerEvent(_arg1, _arg2);
}
public static function setNotifications(_arg1:MovieClip, _arg2:Object):void{
var _local4:Object;
var _local3:Object = {};
for (_local4 in _arg2) {
_local3[_local4] = _arg2[_local4];
};
_local3.clip = _arg1;
MochiServices.send("events_setNotifications", _local3, null, null);
}
public static function endGame():void{
var _local1:Number = (new Date().time - gameStart);
trigger("end_game", {time:_local1});
}
public static function startGame():void{
gameStart = new Date().time;
trigger("start_game");
}
public static function trigger(_arg1:String, _arg2:Object=null):void{
if (_arg2 == null){
_arg2 = {};
} else {
if (_arg2["kind"] != undefined){
trace("WARNING: optional arguements package contains key 'id', it will be overwritten");
_arg2["kind"] = _arg1;
};
};
MochiServices.send("events_triggerEvent", {eventObject:_arg2}, null, null);
}
public static function getVersion():String{
return (MochiServices.getVersion());
}
public static function startLevel():void{
levelStart = new Date().time;
trigger("start_level");
}
public static function endLevel():void{
var _local1:Number = (new Date().time - levelStart);
trigger("end_level", {time:_local1});
}
}
}//package mochi.as3
Section 125
//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){
delete options.clip;
MochiServices.setContainer();
MochiServices.bringToTop();
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)){
MochiServices.clip.play();
} 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 (_slot1.boardID != null){
options.boardID = _slot1.boardID;
};
};
MochiServices.warnID(options.boardID, true);
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 _local3:Number;
var _local4:Number;
var _local5:Object;
var _local6:Object;
var _local7:String;
var _local8:String;
var _local2:Object = {};
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) && ((_arg1.error == true)))) && (onErrorHandler))){
if (_arg1.errorCode == null){
_arg1.errorCode = "IOError";
};
onErrorHandler(_arg1.errorCode);
MochiServices.doClose();
return;
};
onCloseHandler();
MochiServices.doClose();
}
public static function setBoardID(_arg1:String):void{
MochiServices.warnID(_arg1, true);
_slot1.boardID = _arg1;
MochiServices.send("scores_setBoardID", {boardID:_arg1});
}
}
}//package mochi.as3
Section 126
//MochiServices (mochi.as3.MochiServices)
package mochi.as3 {
import flash.events.*;
import flash.display.*;
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;
private static var _preserved:Object;
public static var netupAttempted:Boolean = false;
private static var _sendChannel:LocalConnection;
public static var servicesSync:MochiSync = new MochiSync();
private static var _clip:MovieClip;
private static var _id:String;
private static var _services:String = "services.swf";
private static var _servURL:String = "http://www.mochiads.com/static/lib/services/";
public static var widget:Boolean = false;
private static var _timer:Timer;
private static var _sendChannelName:String;
private static var _loader:Loader;
private static var _connecting:Boolean = false;
private static var _mochiLocalConnection:MovieClip;
private static var _listenChannelName:String = "__ms_";
public static var onError:Object;
public static var netup:Boolean = true;
private static var _mochiLC:String = "MochiLC.swf";
public static function isNetworkAvailable():Boolean{
return (!((Security.sandboxType == "localWithFile")));
}
public static function get connected():Boolean{
return (_connected);
}
private static function onReceive(_arg1:Object):void{
var methodName:String;
var pkg = _arg1;
var cb:String = pkg.callbackID;
var cblst:Object = _clip._callbacks[cb];
if (!cblst){
return;
};
var method:* = cblst.callbackMethod;
methodName = "";
var obj:Object = 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 _clip._callbacks[cb];
}
public static function get childClip():Object{
return (_clip);
}
public static function send(_arg1:String, _arg2:Object=null, _arg3:Object=null, _arg4:Object=null):void{
if (_connected){
_mochiLocalConnection.send(_sendChannelName, "onReceive", {methodName:_arg1, args:_arg2, callbackID:_clip._nextcallbackID});
} else {
if ((((_clip == null)) || (!(_connecting)))){
trace(("Error: MochiServices not connected. Please call MochiServices.connect(). Function: " + _arg1));
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);
};
}
private static function clickMovie(_arg1:String, _arg2:Function):MovieClip{
var _local4:int;
var _local14:Loader;
var _local3:Array = [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];
var _local5:Array = [104, 0, 31, 64, 0, 7, 208, 0, 0, 12, 1, 0, 67, 2, 0xFF, 0xFF, 0xFF, 63, 3];
var _local6:Array = [0, 64, 0, 0, 0];
var _local7:MovieClip = new MovieClip();
var _local8:LocalConnection = new LocalConnection();
var _local9:String = ((("_click_" + Math.floor((Math.random() * 999999))) + "_") + Math.floor(new Date().time));
_local8 = new LocalConnection();
_local7.lc = _local8;
_local7.click = _arg2;
_local8.client = _local7;
_local8.connect(_local9);
var _local10:ByteArray = new ByteArray();
var _local11:ByteArray = new ByteArray();
_local11.endian = Endian.LITTLE_ENDIAN;
_local11.writeShort(1);
_local11.writeUTFBytes(((_arg1 + " ") + _local9));
_local11.writeByte(0);
var _local12:uint = ((_local3.length + _local11.length) + 4);
var _local13:uint = (_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 avm1Click:DisplayObject;
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;
var vars:Object = 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);
var s = "?";
var i:Number = 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{
if (avm1Click){
btn.removeChild(avm1Click);
};
avm1Click = clickMovie(_arg1, onClick);
var _local2:Rectangle = 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 warnID(_arg1:String, _arg2:Boolean):void{
_arg1 = _arg1.toLowerCase();
if (_arg1.length != 16){
trace((("WARNING: " + (_arg2) ? "board" : "game") + " ID is not the appropriate length"));
return;
} else {
if (_arg1 == "1e113c7239048b3f"){
if (_arg2){
trace("WARNING: Using testing board ID");
} else {
trace("WARNING: Using testing board ID as game ID");
};
return;
} else {
if (_arg1 == "84993a1de4031cd8"){
if (_arg2){
trace("WARNING: Using testing game ID as board ID");
} else {
trace("WARNING: Using testing game ID");
};
return;
};
};
};
var _local3:Number = 0;
while (_local3 < _arg1.length) {
switch (_arg1.charAt(_local3)){
case "0":
case "1":
case "2":
case "3":
case "4":
case "5":
case "6":
case "7":
case "8":
case "9":
case "a":
case "b":
case "c":
case "d":
case "e":
case "f":
break;
default:
trace(("WARNING: Board ID contains illegal characters: " + _arg1));
return;
};
_local3++;
};
}
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 {
_mochiLocalConnection.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.3 as3");
}
public static function doClose():void{
_container.removeEventListener(Event.ENTER_FRAME, MochiServices.bringToTop);
}
private static function flush(_arg1:Boolean):void{
var _local2:Object;
var _local3:Object;
if (((_clip) && (_clip._queue))){
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 get id():String{
return (_id);
}
private static function onEvent(_arg1:Object):void{
var _local2:String = _arg1.target;
var _local3:String = _arg1.event;
switch (_local2){
case "events":
MochiEvents.triggerEvent(_arg1.event, _arg1.args);
break;
case "coins":
MochiCoins.triggerEvent(_arg1.event, _arg1.args);
break;
case "sync":
servicesSync.triggerEvent(_arg1.event, _arg1.args);
break;
};
}
private static function urlOptions(_arg1:Object):Object{
var _local3:String;
var _local4:Array;
var _local5:Number;
var _local6:Array;
var _local2:Object = {};
if (_arg1.stage){
_local3 = _arg1.stage.loaderInfo.parameters.mochiad_options;
} else {
_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 loadError(_arg1:Object):void{
_clip._mochiad_ctr_failed = true;
trace("MochiServices could not load.");
MochiServices.disconnect();
MochiServices.onError("IOError");
}
private static function initComChannels():void{
if (!_connected){
trace("[SERVICES_API] connected!");
_connecting = false;
_connected = true;
_mochiLocalConnection.send(_sendChannelName, "onReceive", {methodName:"handshakeDone"});
_mochiLocalConnection.send(_sendChannelName, "onReceive", {methodName:"registerGame", preserved:_preserved, id:_id, clip:_container, version:getVersion(), parentURL:_container.loaderInfo.loaderURL});
_clip.onReceive = onReceive;
_clip.onEvent = onEvent;
_clip.onError = function ():void{
MochiServices.onError("IOError");
};
while (_clip._queue.length > 0) {
_mochiLocalConnection.send(_sendChannelName, "onReceive", _clip._queue.shift());
};
};
}
private static function loadLCBridge(_arg1:Object):void{
var loader:Loader;
var clip = _arg1;
loader = new Loader();
var mochiLCURL:String = (_servURL + _mochiLC);
var req:URLRequest = new URLRequest(mochiLCURL);
var complete:Function = function (_arg1:Object):void{
_mochiLocalConnection = MovieClip(loader.content);
listen();
};
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, complete);
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, loadError);
loader.load(req);
clip.addChild(loader);
}
private static function listen():void{
_mochiLocalConnection.connect(_listenChannelName);
_clip.handshake = function (_arg1:Object):void{
MochiServices.comChannelName = _arg1.newChannel;
};
trace("Waiting for MochiAds services to connect...");
}
public static function get clip():Object{
return (_container);
}
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 _local3:String = ("_mochiservices_com_" + _arg1);
if (_clip != null){
return (_clip);
};
if (!MochiServices.isNetworkAvailable()){
return (null);
};
if (urlOptions(_arg2).servURL){
_servURL = urlOptions(_arg2).servURL;
};
var _local4:String = (_servURL + _services);
if (urlOptions(_arg2).servicesURL){
_local4 = urlOptions(_arg2).servicesURL;
};
_listenChannelName = (_listenChannelName + ((Math.floor(new Date().time) + "_") + Math.floor((Math.random() * 99999))));
MochiServices.allowDomains(_local4);
_clip = createEmptyMovieClip(_arg2, _local3, 10336, false);
loadLCBridge(_clip);
_loader = new Loader();
_loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, loadError);
var _local5:URLRequest = new URLRequest(_local4);
var _local6:URLVariables = new URLVariables();
_local6.listenLC = _listenChannelName;
_local6.mochiad_options = _arg2.loaderInfo.parameters.mochiad_options;
_local6.api_version = getVersion();
if (widget){
_local6.widget = true;
};
_local5.data = _local6;
_loader.load(_local5);
_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 connect(_arg1:String, _arg2:Object, _arg3:Object=null):void{
var id = _arg1;
var clip = _arg2;
var onError = _arg3;
warnID(id, false);
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 parent = _arg1;
var name = _arg2;
var depth = _arg3;
var doAdd = _arg4;
var mc:MovieClip = 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 bringToTop(_arg1:Event=null):void{
var e = _arg1;
if (((!((MochiServices.clip == null))) && (!((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 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 127
//MochiSync (mochi.as3.MochiSync)
package mochi.as3 {
import flash.utils.*;
public dynamic class MochiSync extends Proxy {
private var _syncContainer:Object;
public static var SYNC_PROPERTY:String = "UpdateProperty";
public static var SYNC_REQUEST:String = "SyncRequest";
public function MochiSync():void{
_syncContainer = {};
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function setProperty(_arg1, _arg2):void{
if (_syncContainer[_arg1] == _arg2){
return;
};
var _local3:String = _arg1.toString();
_syncContainer[_local3] = _arg2;
MochiServices.send("sync_propUpdate", {name:_local3, value:_arg2});
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function getProperty(_arg1){
return (_syncContainer[_arg1]);
}
public function triggerEvent(_arg1:String, _arg2:Object):void{
switch (_arg1){
case SYNC_REQUEST:
MochiServices.send("sync_syncronize", _syncContainer);
break;
case SYNC_PROPERTY:
_syncContainer[_arg2.name] = _arg2.value;
break;
};
}
}
}//package mochi.as3
Section 128
//IFlexAsset (mx.core.IFlexAsset)
package mx.core {
public interface IFlexAsset {
}
}//package mx.core
Section 129
//mx_internal (mx.core.mx_internal)
package mx.core {
public namespace mx_internal = "http://www.adobe.com/2006/flex/mx/internal";
}//package mx.core
Section 130
//SoundAsset (mx.core.SoundAsset)
package mx.core {
import flash.media.*;
public class SoundAsset extends Sound implements IFlexAsset {
mx_internal static const VERSION:String = "3.2.0.3958";
}
}//package mx.core
Section 131
//Destroyable (org.casalib.core.Destroyable)
package org.casalib.core {
public class Destroyable implements IDestroyable {
protected var _isDestroyed:Boolean;
public function get destroyed():Boolean{
return (this._isDestroyed);
}
public function destroy():void{
this._isDestroyed = true;
}
}
}//package org.casalib.core
Section 132
//IDestroyable (org.casalib.core.IDestroyable)
package org.casalib.core {
public interface IDestroyable {
function get destroyed():Boolean;
function destroy():void;
}
}//package org.casalib.core
Section 133
//ArrayContentsError (org.casalib.errors.ArrayContentsError)
package org.casalib.errors {
public class ArrayContentsError extends Error {
public function ArrayContentsError(){
super("The Array is composed of an incorrect number of values, or values of an incorrect type.");
}
}
}//package org.casalib.errors
Section 134
//IRemovableEventDispatcher (org.casalib.events.IRemovableEventDispatcher)
package org.casalib.events {
import flash.events.*;
public interface IRemovableEventDispatcher extends IEventDispatcher {
function removeEventsForListener(_arg1:Function):void;
function removeEventListeners():void;
function removeEventsForType(_arg1:String):void;
}
}//package org.casalib.events
Section 135
//KeyComboEvent (org.casalib.events.KeyComboEvent)
package org.casalib.events {
import flash.events.*;
import org.casalib.ui.*;
public class KeyComboEvent extends Event {
protected var _keyCombo:KeyCombo;
public static const SEQUENCE:String = "sequence";
public static const DOWN:String = "down";
public static const RELEASE:String = "release";
public function KeyComboEvent(_arg1:String, _arg2:Boolean=false, _arg3:Boolean=false){
super(_arg1, _arg2, _arg3);
}
override public function toString():String{
return (formatToString("VideoInfoEvent", "type", "bubbles", "cancelable", "keyCombo"));
}
override public function clone():Event{
var _local1:KeyComboEvent = new KeyComboEvent(this.type, this.bubbles, this.cancelable);
_local1.keyCombo = this.keyCombo;
return (_local1);
}
public function set keyCombo(_arg1:KeyCombo):void{
this._keyCombo = _arg1;
}
public function get keyCombo():KeyCombo{
return (this._keyCombo);
}
}
}//package org.casalib.events
Section 136
//ListenerManager (org.casalib.events.ListenerManager)
package org.casalib.events {
import flash.events.*;
import flash.utils.*;
import org.casalib.core.*;
public class ListenerManager extends Destroyable implements IRemovableEventDispatcher {
protected var _blockRequest:Boolean;
protected var _eventDispatcher:IEventDispatcher;
protected var _events:Array;
protected static var _proxyMap:Dictionary;
public function ListenerManager(_arg1:EventInfo, _arg2:IEventDispatcher){
this._eventDispatcher = _arg2;
this._events = new Array();
}
public function dispatchEvent(_arg1:Event):Boolean{
return (this._eventDispatcher.dispatchEvent(_arg1));
}
public function willTrigger(_arg1:String):Boolean{
return (this._eventDispatcher.willTrigger(_arg1));
}
public function removeEventListener(_arg1:String, _arg2:Function, _arg3:Boolean=false):void{
if (this._blockRequest){
return;
};
var _local4:EventInfo = new EventInfo(_arg1, _arg2, _arg3);
var _local5:int = this._events.length;
while (_local5--) {
if (this._events[_local5].equals(_local4)){
this._events.splice(_local5, 1);
};
};
}
public function removeEventListeners():void{
var _local2:EventInfo;
this._blockRequest = true;
var _local1:int = this._events.length;
while (_local1--) {
_local2 = this._events.splice(_local1, 1)[0];
this._eventDispatcher.removeEventListener(_local2.type, _local2.listener, _local2.useCapture);
};
this._blockRequest = false;
}
public function removeEventsForListener(_arg1:Function):void{
var _local3:EventInfo;
this._blockRequest = true;
var _local2:int = this._events.length;
while (_local2--) {
_local3 = this._events[_local2];
if (_local3.listener == _arg1){
this._events.splice(_local2, 1);
this._eventDispatcher.removeEventListener(_local3.type, _local3.listener, _local3.useCapture);
};
};
this._blockRequest = false;
}
public function hasEventListener(_arg1:String):Boolean{
return (this._eventDispatcher.hasEventListener(_arg1));
}
override public function destroy():void{
this.removeEventListeners();
delete ListenerManager._proxyMap[this._eventDispatcher];
this._eventDispatcher = null;
super.destroy();
}
public function addEventListener(_arg1:String, _arg2:Function, _arg3:Boolean=false, _arg4:int=0, _arg5:Boolean=false):void{
var _local6:EventInfo = new EventInfo(_arg1, _arg2, _arg3);
var _local7:int = this._events.length;
while (_local7--) {
if (this._events[_local7].equals(_local6)){
return;
};
};
this._events.push(_local6);
}
public function removeEventsForType(_arg1:String):void{
var _local3:EventInfo;
this._blockRequest = true;
var _local2:int = this._events.length;
while (_local2--) {
_local3 = this._events[_local2];
if (_local3.type == _arg1){
this._events.splice(_local2, 1);
this._eventDispatcher.removeEventListener(_local3.type, _local3.listener, _local3.useCapture);
};
};
this._blockRequest = false;
}
public static function getManager(_arg1:IEventDispatcher):ListenerManager{
if (ListenerManager._proxyMap == null){
ListenerManager._proxyMap = new Dictionary();
};
if (!(_arg1 in ListenerManager._proxyMap)){
ListenerManager._proxyMap[_arg1] = new ListenerManager(new EventInfo(null, null, false), _arg1);
};
return (ListenerManager._proxyMap[_arg1]);
}
}
}//package org.casalib.events
class EventInfo {
public var listener:Function;
public var type:String;
public var useCapture:Boolean;
private function EventInfo(_arg1:String, _arg2:Function, _arg3:Boolean){
this.type = _arg1;
this.listener = _arg2;
this.useCapture = _arg3;
}
public function equals(_arg1:EventInfo):Boolean{
return ((((((this.type == _arg1.type)) && ((this.listener == _arg1.listener)))) && ((this.useCapture == _arg1.useCapture))));
}
}
Section 137
//RemovableEventDispatcher (org.casalib.events.RemovableEventDispatcher)
package org.casalib.events {
import flash.events.*;
import org.casalib.core.*;
public class RemovableEventDispatcher extends EventDispatcher implements IRemovableEventDispatcher, IDestroyable {
protected var _isDestroyed:Boolean;
protected var _listenerManager:ListenerManager;
public function RemovableEventDispatcher(_arg1:IEventDispatcher=null){
super(_arg1);
this._listenerManager = ListenerManager.getManager(this);
}
override public function dispatchEvent(_arg1:Event):Boolean{
if (this.willTrigger(_arg1.type)){
return (super.dispatchEvent(_arg1));
};
return (true);
}
public function removeEventsForType(_arg1:String):void{
this._listenerManager.removeEventsForType(_arg1);
}
public function removeEventListeners():void{
this._listenerManager.removeEventListeners();
}
override public function removeEventListener(_arg1:String, _arg2:Function, _arg3:Boolean=false):void{
super.removeEventListener(_arg1, _arg2, _arg3);
this._listenerManager.removeEventListener(_arg1, _arg2, _arg3);
}
public function destroy():void{
this.removeEventListeners();
this._listenerManager.destroy();
this._isDestroyed = true;
}
public function removeEventsForListener(_arg1:Function):void{
this._listenerManager.removeEventsForListener(_arg1);
}
public function get destroyed():Boolean{
return (this._isDestroyed);
}
override public function addEventListener(_arg1:String, _arg2:Function, _arg3:Boolean=false, _arg4:int=0, _arg5:Boolean=false):void{
super.addEventListener(_arg1, _arg2, _arg3, _arg4, _arg5);
this._listenerManager.addEventListener(_arg1, _arg2, _arg3, _arg4, _arg5);
}
}
}//package org.casalib.events
Section 138
//Percent (org.casalib.math.Percent)
package org.casalib.math {
public class Percent {
protected var _percent:Number;
public function Percent(_arg1:Number=0, _arg2:Boolean=true){
if (_arg2){
this.decimalPercentage = _arg1;
} else {
this.percentage = _arg1;
};
}
public function set percentage(_arg1:Number):void{
this._percent = (_arg1 * 0.01);
}
public function clone():Percent{
return (new Percent(this.decimalPercentage));
}
public function get percentage():Number{
return ((100 * this._percent));
}
public function get decimalPercentage():Number{
return (this._percent);
}
public function set decimalPercentage(_arg1:Number):void{
this._percent = _arg1;
}
public function toString():String{
return (this.decimalPercentage.toString());
}
public function equals(_arg1:Percent):Boolean{
return ((this.decimalPercentage == _arg1.decimalPercentage));
}
}
}//package org.casalib.math
Section 139
//Key (org.casalib.ui.Key)
package org.casalib.ui {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import org.casalib.events.*;
import org.casalib.util.*;
public class Key extends RemovableEventDispatcher {
protected var _longestCombo:uint;
protected var _combosDown:Array;
protected var _combinations:Array;
protected var _keysDown:Dictionary;
protected var _keysTyped:Array;
protected static var _instance:Key;
public function Key(_arg1:SingletonEnforcer){
var _local2:Stage = StageReference.getStage();
_local2.addEventListener(KeyboardEvent.KEY_DOWN, this._onKeyDown);
_local2.addEventListener(KeyboardEvent.KEY_UP, this._onKeyUp);
_local2.addEventListener(Event.DEACTIVATE, this._onDeactivate);
this._keysDown = new Dictionary();
this._keysTyped = new Array();
this._combosDown = new Array();
this._combinations = new Array();
this._longestCombo = 0;
}
override public function destroy():void{
throw (new Error("Cannot destroy a singleton."));
}
public function isDown(_arg1:uint):Boolean{
return (this._keysDown[_arg1]);
}
public function addKeyCombo(_arg1:KeyCombo):void{
var _local2:uint = this._combinations.length;
while (_local2--) {
if (this._combinations[_local2].equals(_arg1)){
return;
};
};
this._longestCombo = Math.max(this._longestCombo, _arg1.keyCodes.length);
this._combinations.push(_arg1);
}
protected function _onKeyDown(_arg1:KeyboardEvent):void{
var _local2:Boolean = this._keysDown[_arg1.keyCode];
this._keysDown[_arg1.keyCode] = true;
this._keysTyped.push(_arg1.keyCode);
if (this._keysTyped.length > this._longestCombo){
this._keysTyped.splice(0, 1);
};
var _local3:uint = this._combinations.length;
while (_local3--) {
this._checkedTypedKeys(this._combinations[_local3]);
if (!_local2){
this._checkDownKeys(this._combinations[_local3]);
};
};
this.dispatchEvent(_arg1.clone());
}
protected function _checkedTypedKeys(_arg1:KeyCombo):void{
var _local2:KeyComboEvent;
if (ArrayUtil.equals(_arg1.keyCodes, this._keysTyped.slice(-(_arg1.keyCodes.length)))){
_local2 = new KeyComboEvent(KeyComboEvent.SEQUENCE);
_local2.keyCombo = _arg1;
this.dispatchEvent(_local2);
};
}
protected function _onDeactivate(_arg1:Event):void{
var _local3:KeyComboEvent;
var _local2:uint = this._combosDown.length;
while (_local2--) {
_local3 = new KeyComboEvent(KeyComboEvent.RELEASE);
_local3.keyCombo = this._combosDown[_local2];
this.dispatchEvent(_local3);
};
this._combosDown = new Array();
this._keysDown = new Dictionary();
}
public function removeKeyCombo(_arg1:KeyCombo):void{
var _local4:uint;
var _local2 = -1;
var _local3:uint = this._combinations.length;
while (_local3--) {
if (this._combinations[_local3].equals(_arg1)){
_local2 = int(_local3);
break;
};
};
if (_local2 == -1){
return;
};
this._combinations.splice(_local2, 1);
if (_arg1.keyCodes.length == this._longestCombo){
_local4 = 0;
_local3 = this._combinations.length;
while (_local3--) {
_local4 = Math.max(_local4, this._combinations[_local3].keyCodes.length);
};
this._longestCombo = _local4;
};
}
protected function _onKeyUp(_arg1:KeyboardEvent):void{
var _local3:KeyComboEvent;
var _local2:uint = this._combosDown.length;
while (_local2--) {
if (this._combosDown[_local2].keyCodes.indexOf(_arg1.keyCode) != -1){
_local3 = new KeyComboEvent(KeyComboEvent.RELEASE);
_local3.keyCombo = this._combosDown[_local2];
this._combosDown.splice(_local2, 1);
this.dispatchEvent(_local3);
};
};
delete this._keysDown[_arg1.keyCode];
this.dispatchEvent(_arg1.clone());
}
protected function _checkDownKeys(_arg1:KeyCombo):void{
var _local2:Array = ArrayUtil.removeDuplicates(_arg1.keyCodes);
var _local3:uint = _local2.length;
while (_local3--) {
if (!this.isDown(_local2[_local3])){
return;
};
};
var _local4:KeyComboEvent = new KeyComboEvent(KeyComboEvent.DOWN);
_local4.keyCombo = _arg1;
this._combosDown.push(_arg1);
this.dispatchEvent(_local4);
}
public static function getInstance():Key{
if (_slot1._instance == null){
_slot1._instance = new Key(new SingletonEnforcer());
};
return (_slot1._instance);
}
}
}//package org.casalib.ui
class SingletonEnforcer {
private function SingletonEnforcer(){
}
}
Section 140
//KeyCombo (org.casalib.ui.KeyCombo)
package org.casalib.ui {
import org.casalib.util.*;
import org.casalib.errors.*;
public class KeyCombo {
protected var _keyCodes:Array;
public function KeyCombo(_arg1:Array){
if (_arg1.length < 2){
throw (new ArrayContentsError());
};
var _local2:uint = _arg1.length;
while (_local2--) {
if (!(_arg1[_local2] is uint)){
throw (new ArrayContentsError());
};
};
this._keyCodes = _arg1.concat();
}
public function equals(_arg1:KeyCombo):Boolean{
if (_arg1 == this){
return (true);
};
return (ArrayUtil.equals(this.keyCodes, _arg1.keyCodes));
}
public function get keyCodes():Array{
return (this._keyCodes.concat());
}
}
}//package org.casalib.ui
Section 141
//ArrayUtil (org.casalib.util.ArrayUtil)
package org.casalib.util {
public class ArrayUtil {
protected static function _sortRandom(_arg1, _arg2):int{
return ((NumberUtil.randomIntegerWithinRange(0, 1)) ? 1 : -1);
}
public static function containsAll(_arg1:Array, _arg2:Array):Boolean{
var _local3:uint = _arg2.length;
while (_local3--) {
if (_arg1.indexOf(_arg2[_local3]) == -1){
return (false);
};
};
return (true);
}
protected static function _removeDuplicatesFilter(_arg1, _arg2:int, _arg3:Array):Boolean{
return (((_arg2)==0) ? true : (_arg3.lastIndexOf(_arg1, (_arg2 - 1)) == -1));
}
public static function equals(_arg1:Array, _arg2:Array):Boolean{
var _local3:uint = _arg1.length;
if (_local3 != _arg2.length){
return (false);
};
while (_local3--) {
if (_arg1[_local3] != _arg2[_local3]){
return (false);
};
};
return (true);
}
public static function getHighestValue(_arg1:Array):Number{
return (_arg1[_arg1.sort((16 | 8))[(_arg1.length - 1)]]);
}
public static function sum(_arg1:Array):Number{
var _local2:Number = 0;
var _local3:uint = _arg1.length;
while (_local3--) {
_local2 = (_local2 + _arg1[_local3]);
};
return (_local2);
}
public static function removeDuplicates(_arg1:Array):Array{
return (_arg1.filter(ArrayUtil._removeDuplicatesFilter));
}
public static function containsAny(_arg1:Array, _arg2:Array):Boolean{
var _local3:uint = _arg2.length;
while (_local3--) {
if (_arg1.indexOf(_arg2[_local3]) != -1){
return (true);
};
};
return (false);
}
public static function getIndexOfDifference(_arg1:Array, _arg2:Array, _arg3:uint=0):int{
var _local4:int = (_arg3 - 1);
while (++_local4 < _arg1.length) {
if (_arg1[_local4] != _arg2[_local4]){
return (_local4);
};
};
return (-1);
}
public static function randomize(_arg1:Array):Array{
var _local2:Array = new Array();
var _local3:Array = _arg1.sort(ArrayUtil._sortRandom, Array.RETURNINDEXEDARRAY);
var _local4 = -1;
while (++_local4 < _arg1.length) {
_local2.push(_arg1[_local3[_local4]]);
};
return (_local2);
}
public static function addItemsAt(_arg1:Array, _arg2:Array, _arg3:int=2147483647):Boolean{
if (_arg2.length == 0){
return (false);
};
var _local4:Array = _arg2.concat();
_local4.splice(0, 0, _arg3, 0);
_arg1.splice.apply(null, _local4);
return (true);
}
public static function removeItem(_arg1:Array, _arg2):uint{
var _local3:int = _arg1.indexOf(_arg2);
var _local4:uint;
while (_local3 != -1) {
_arg1.splice(_local3, 1);
_local3 = _arg1.indexOf(_arg2, _local3);
_local4++;
};
return (_local4);
}
public static function getLowestValue(_arg1:Array):Number{
return (_arg1[_arg1.sort((16 | 8))[0]]);
}
public static function retainItems(_arg1:Array, _arg2:Array):Boolean{
var _local3:Boolean;
var _local4:uint = _arg1.length;
while (_local4--) {
if (_arg2.indexOf(_arg1[_local4]) == -1){
_arg1.splice(_local4, 1);
_local3 = true;
};
};
return (_local3);
}
public static function removeItems(_arg1:Array, _arg2:Array):Boolean{
var _local3:Boolean;
var _local4:uint = _arg1.length;
while (_local4--) {
if (_arg2.indexOf(_arg1[_local4]) != -1){
_arg1.splice(_local4, 1);
_local3 = true;
};
};
return (_local3);
}
public static function average(_arg1:Array):Number{
if (_arg1.length == 0){
return (0);
};
return ((ArrayUtil.sum(_arg1) / _arg1.length));
}
public static function contains(_arg1:Array, _arg2):uint{
var _local3:int = _arg1.indexOf(_arg2, 0);
var _local4:uint;
while (_local3 != -1) {
_local3 = _arg1.indexOf(_arg2, (_local3 + 1));
_local4++;
};
return (_local4);
}
}
}//package org.casalib.util
Section 142
//NumberUtil (org.casalib.util.NumberUtil)
package org.casalib.util {
import org.casalib.math.*;
public class NumberUtil {
public static function interpolate(_arg1:Percent, _arg2:Number, _arg3:Number):Number{
return ((_arg2 + ((_arg3 - _arg2) * _arg1.decimalPercentage)));
}
public static function max(_arg1, _arg2):Number{
if (((((isNaN(_arg1)) && (isNaN(_arg2)))) || ((((_arg1 == null)) && ((_arg2 == null)))))){
return (NaN);
};
if ((((_arg1 == null)) || ((_arg2 == null)))){
return (((_arg2)==null) ? _arg1 : _arg2);
};
if (((isNaN(_arg1)) || (isNaN(_arg2)))){
return ((isNaN(_arg2)) ? _arg1 : _arg2);
};
return (Math.max(_arg1, _arg2));
}
public static function isOdd(_arg1:Number):Boolean{
return (!(NumberUtil.isEven(_arg1)));
}
public static function constrain(_arg1:Number, _arg2:Number, _arg3:Number):Number{
return (Math.min(Math.max(_arg1, Math.min(_arg2, _arg3)), Math.max(_arg2, _arg3)));
}
public static function roundDecimalToPlace(_arg1:Number, _arg2:uint):Number{
var _local3:Number = Math.pow(10, _arg2);
return ((Math.round((_arg1 * _local3)) / _local3));
}
public static function isEqual(_arg1:Number, _arg2:Number, _arg3:Number=0):Boolean{
return ((Math.abs((_arg1 - _arg2)) <= Math.abs(_arg3)));
}
public static function isEven(_arg1:Number):Boolean{
return (((_arg1 & 1) == 0));
}
public static function getOrdinalSuffix(_arg1:int):String{
if ((((_arg1 >= 10)) && ((_arg1 <= 20)))){
return ("th");
};
switch ((_arg1 % 10)){
case 0:
case 4:
case 5:
case 6:
case 7:
case 8:
case 9:
return ("th");
case 3:
return ("rd");
case 2:
return ("nd");
case 1:
return ("st");
default:
return ("");
};
}
public static function normalize(_arg1:Number, _arg2:Number, _arg3:Number):Percent{
return (new Percent(((_arg1 - _arg2) / (_arg3 - _arg2))));
}
public static function loopIndex(_arg1:int, _arg2:uint):uint{
if (_arg1 < 0){
_arg1 = (_arg2 + (_arg1 % _arg2));
};
if (_arg1 >= _arg2){
return ((_arg1 % _arg2));
};
return (_arg1);
}
public static function randomWithinRange(_arg1:Number, _arg2:Number):Number{
return ((_arg1 + (Math.random() * (_arg2 - _arg1))));
}
public static function min(_arg1, _arg2):Number{
if (((((isNaN(_arg1)) && (isNaN(_arg2)))) || ((((_arg1 == null)) && ((_arg2 == null)))))){
return (NaN);
};
if ((((_arg1 == null)) || ((_arg2 == null)))){
return (((_arg2)==null) ? _arg1 : _arg2);
};
if (((isNaN(_arg1)) || (isNaN(_arg2)))){
return ((isNaN(_arg2)) ? _arg1 : _arg2);
};
return (Math.min(_arg1, _arg2));
}
public static function isInteger(_arg1:Number):Boolean{
return (((_arg1 % 1) == 0));
}
public static function isPrime(_arg1:Number):Boolean{
if ((((_arg1 == 1)) || ((_arg1 == 2)))){
return (true);
};
if (NumberUtil.isEven(_arg1)){
return (false);
};
var _local2:Number = Math.sqrt(_arg1);
var _local3:Number = 3;
while (_local3 <= _local2) {
if ((_arg1 % _local3) == 0){
return (false);
};
_local3++;
};
return (true);
}
public static function randomIntegerWithinRange(_arg1:int, _arg2:int):int{
return (Math.round(NumberUtil.randomWithinRange(_arg1, _arg2)));
}
public static function format(_arg1:Number, _arg2:uint, _arg3:String=null, _arg4:String=null):String{
var _local7:Array;
var _local8:uint;
var _local9:uint;
var _local10:String;
var _local5:String = _arg1.toString();
var _local6:uint = _local5.length;
if (_arg3 != null){
_local7 = _local5.split("");
_local8 = 3;
_local9 = _local7.length;
while (--_local9 > 0) {
--_local8;
if (_local8 == 0){
_local8 = 3;
_local7.splice(_local9, 0, _arg3);
};
};
_local5 = _local7.join("");
};
if (_arg2 != 0){
if (_local6 < _arg2){
_arg2 = (_arg2 - _local6);
_local10 = ((_arg4)==null) ? "0" : _arg4;
while (_arg2--) {
_local5 = (_local10 + _local5);
};
};
};
return (_local5);
}
public static function addLeadingZero(_arg1:Number):String{
return (((_arg1)<10) ? ("0" + _arg1) : _arg1.toString());
}
public static function map(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number):Number{
return (NumberUtil.interpolate(NumberUtil.normalize(_arg1, _arg2, _arg3), _arg4, _arg5));
}
public static function createStepsBetween(_arg1:Number, _arg2:Number, _arg3:Number):Array{
_arg3++;
var _local4:uint;
var _local5:Array = new Array();
var _local6:Number = ((_arg2 - _arg1) / _arg3);
while (++_local4 < _arg3) {
_local5.push(((_local4 * _local6) + _arg1));
};
return (_local5);
}
public static function isBetween(_arg1:Number, _arg2:Number, _arg3:Number):Boolean{
return (!((((_arg1 < Math.min(_arg2, _arg3))) || ((_arg1 > Math.max(_arg2, _arg3))))));
}
}
}//package org.casalib.util
Section 143
//ObjectUtil (org.casalib.util.ObjectUtil)
package org.casalib.util {
import flash.utils.*;
public class ObjectUtil {
public static function isNull(_arg1:Object):Boolean{
return ((_arg1 === null));
}
public static function isEmpty(_arg1):Boolean{
var _local2:String;
if (_arg1 == undefined){
return (true);
};
if ((_arg1 is Number)){
return (isNaN(_arg1));
};
if ((((_arg1 is Array)) || ((_arg1 is String)))){
return ((_arg1.length == 0));
};
if ((_arg1 is Object)){
for (_local2 in _arg1) {
return (false);
};
return (true);
};
return (false);
}
public static function isUndefined(_arg1:Object):Boolean{
return ((_arg1 is undefined));
}
public static function getKeys(_arg1:Object):Array{
var _local3:String;
var _local2:Array = new Array();
for (_local3 in _arg1) {
_local2.push(_local3);
};
return (_local2);
}
public static function clone(_arg1:Object):Object{
var _local2:ByteArray = new ByteArray();
_local2.writeObject(_arg1);
_local2.position = 0;
return (_local2.readObject());
}
public static function contains(_arg1:Object, _arg2:Object):Boolean{
var _local3:String;
for (_local3 in _arg1) {
if (_arg1[_local3] == _arg2){
return (true);
};
};
return (false);
}
}
}//package org.casalib.util
Section 144
//StageReference (org.casalib.util.StageReference)
package org.casalib.util {
import flash.display.*;
import flash.utils.*;
public class StageReference {
public static const STAGE_DEFAULT:String = "stageDefault";
protected static var _stageMap:Dictionary;
public static function removeStage(_arg1:String="stageDefault"):Boolean{
if (!(_arg1 in StageReference._getMap())){
return (false);
};
StageReference.setStage(null, _arg1);
return (true);
}
public static function getStageId(_arg1:Stage):String{
var _local3:String;
var _local2:Dictionary = StageReference._getMap();
for (_local3 in _local2) {
if (_local2[_local3] == _arg1){
return (_local3);
};
};
return (null);
}
protected static function _getMap():Dictionary{
if (StageReference._stageMap == null){
StageReference._stageMap = new Dictionary();
};
return (StageReference._stageMap);
}
public static function getStage(_arg1:String="stageDefault"):Stage{
if (!(_arg1 in StageReference._getMap())){
throw (new Error((("Cannot get Stage (\"" + _arg1) + "\") before it has been set.")));
};
return (StageReference._getMap()[_arg1]);
}
public static function getIds():Array{
return (ObjectUtil.getKeys(StageReference._getMap()));
}
public static function setStage(_arg1:Stage, _arg2:String="stageDefault"):void{
StageReference._getMap()[_arg2] = _arg1;
}
}
}//package org.casalib.util
Section 145
//Action (org.flintparticles.common.actions.Action)
package org.flintparticles.common.actions {
import org.flintparticles.common.particles.*;
import org.flintparticles.common.emitters.*;
public interface Action {
function addedToEmitter(_arg1:Emitter):void;
function removedFromEmitter(_arg1:Emitter):void;
function update(_arg1:Emitter, _arg2:Particle, _arg3:Number):void;
function getDefaultPriority():Number;
}
}//package org.flintparticles.common.actions
Section 146
//ActionBase (org.flintparticles.common.actions.ActionBase)
package org.flintparticles.common.actions {
import org.flintparticles.common.particles.*;
import org.flintparticles.common.emitters.*;
public class ActionBase implements Action {
public function removedFromEmitter(_arg1:Emitter):void{
}
public function getDefaultPriority():Number{
return (0);
}
public function update(_arg1:Emitter, _arg2:Particle, _arg3:Number):void{
}
public function addedToEmitter(_arg1:Emitter):void{
}
}
}//package org.flintparticles.common.actions
Section 147
//Age (org.flintparticles.common.actions.Age)
package org.flintparticles.common.actions {
import org.flintparticles.common.particles.*;
import org.flintparticles.common.emitters.*;
import org.flintparticles.common.energyEasing.*;
public class Age extends ActionBase {
private var _easing:Function;
public function Age(_arg1:Function=null){
if (_arg1 == null){
_easing = Linear.easeNone;
} else {
_easing = _arg1;
};
}
override public function update(_arg1:Emitter, _arg2:Particle, _arg3:Number):void{
_arg2.age = (_arg2.age + _arg3);
if (_arg2.age >= _arg2.lifetime){
_arg2.energy = 0;
_arg2.isDead = true;
} else {
_arg2.energy = _easing(_arg2.age, _arg2.lifetime);
};
}
public function get easing():Function{
return (_easing);
}
public function set easing(_arg1:Function):void{
_easing = _arg1;
}
}
}//package org.flintparticles.common.actions
Section 148
//Fade (org.flintparticles.common.actions.Fade)
package org.flintparticles.common.actions {
import org.flintparticles.common.particles.*;
import org.flintparticles.common.emitters.*;
public class Fade extends ActionBase {
private var _endAlpha:Number;
private var _diffAlpha:Number;
public function Fade(_arg1:Number=1, _arg2:Number=0){
_diffAlpha = (_arg1 - _arg2);
_endAlpha = _arg2;
}
public function get startAlpha():Number{
return ((_endAlpha + _diffAlpha));
}
public function set endAlpha(_arg1:Number):void{
_diffAlpha = ((_endAlpha + _diffAlpha) - _arg1);
_endAlpha = _arg1;
}
override public function update(_arg1:Emitter, _arg2:Particle, _arg3:Number):void{
var _local4:Number;
_local4 = (_endAlpha + (_diffAlpha * _arg2.energy));
_arg2.color = ((_arg2.color & 0xFFFFFF) | (Math.round((_local4 * 0xFF)) << 24));
}
public function get endAlpha():Number{
return (_endAlpha);
}
public function set startAlpha(_arg1:Number):void{
_diffAlpha = (_arg1 - _endAlpha);
}
override public function getDefaultPriority():Number{
return (-5);
}
}
}//package org.flintparticles.common.actions
Section 149
//Activity (org.flintparticles.common.activities.Activity)
package org.flintparticles.common.activities {
import org.flintparticles.common.emitters.*;
public interface Activity {
function initialize(_arg1:Emitter):void;
function addedToEmitter(_arg1:Emitter):void;
function removedFromEmitter(_arg1:Emitter):void;
function update(_arg1:Emitter, _arg2:Number):void;
function getDefaultPriority():Number;
}
}//package org.flintparticles.common.activities
Section 150
//ActivityBase (org.flintparticles.common.activities.ActivityBase)
package org.flintparticles.common.activities {
import org.flintparticles.common.emitters.*;
public class ActivityBase implements Activity {
public function addedToEmitter(_arg1:Emitter):void{
}
public function removedFromEmitter(_arg1:Emitter):void{
}
public function update(_arg1:Emitter, _arg2:Number):void{
}
public function getDefaultPriority():Number{
return (0);
}
public function initialize(_arg1:Emitter):void{
}
}
}//package org.flintparticles.common.activities
Section 151
//Blast (org.flintparticles.common.counters.Blast)
package org.flintparticles.common.counters {
import org.flintparticles.common.emitters.*;
public class Blast implements Counter {
private var _startCount:uint;
public function Blast(_arg1:uint){
_startCount = _arg1;
}
public function stop():void{
}
public function updateEmitter(_arg1:Emitter, _arg2:Number):uint{
return (0);
}
public function resume():void{
}
public function set startCount(_arg1:Number):void{
_startCount = _arg1;
}
public function startEmitter(_arg1:Emitter):uint{
return (_startCount);
}
public function get startCount():Number{
return (_startCount);
}
}
}//package org.flintparticles.common.counters
Section 152
//Counter (org.flintparticles.common.counters.Counter)
package org.flintparticles.common.counters {
import org.flintparticles.common.emitters.*;
public interface Counter {
function stop():void;
function updateEmitter(_arg1:Emitter, _arg2:Number):uint;
function startEmitter(_arg1:Emitter):uint;
function resume():void;
}
}//package org.flintparticles.common.counters
Section 153
//Steady (org.flintparticles.common.counters.Steady)
package org.flintparticles.common.counters {
import org.flintparticles.common.emitters.*;
public class Steady implements Counter {
private var _stop:Boolean;
private var _rateInv:Number;
private var _timeToNext:Number;
private var _rate:Number;
public function Steady(_arg1:Number){
_stop = false;
_rate = _arg1;
_rateInv = (1 / _rate);
}
public function get rate():Number{
return (_rate);
}
public function updateEmitter(_arg1:Emitter, _arg2:Number):uint{
var _local3:uint;
if (_stop){
return (0);
};
_local3 = 0;
_timeToNext = (_timeToNext - _arg2);
while (_timeToNext <= 0) {
_local3++;
_timeToNext = (_timeToNext + _rateInv);
};
return (_local3);
}
public function stop():void{
_stop = true;
}
public function startEmitter(_arg1:Emitter):uint{
_timeToNext = _rateInv;
return (0);
}
public function resume():void{
_stop = false;
}
public function set rate(_arg1:Number):void{
_rate = _arg1;
_rateInv = (1 / _arg1);
}
}
}//package org.flintparticles.common.counters
Section 154
//ZeroCounter (org.flintparticles.common.counters.ZeroCounter)
package org.flintparticles.common.counters {
import org.flintparticles.common.emitters.*;
public class ZeroCounter implements Counter {
public function stop():void{
}
public function updateEmitter(_arg1:Emitter, _arg2:Number):uint{
return (0);
}
public function startEmitter(_arg1:Emitter):uint{
return (0);
}
public function resume():void{
}
}
}//package org.flintparticles.common.counters
Section 155
//Dot (org.flintparticles.common.displayObjects.Dot)
package org.flintparticles.common.displayObjects {
import flash.display.*;
public class Dot extends Shape {
public function Dot(_arg1:Number, _arg2:uint=0xFFFFFF, _arg3:String="normal"){
graphics.beginFill(_arg2);
graphics.drawCircle(0, 0, _arg1);
graphics.endFill();
blendMode = _arg3;
}
}
}//package org.flintparticles.common.displayObjects
Section 156
//Line (org.flintparticles.common.displayObjects.Line)
package org.flintparticles.common.displayObjects {
import flash.display.*;
public class Line extends Shape {
public function Line(_arg1:Number, _arg2:uint=0xFFFFFF, _arg3:String="normal"){
graphics.lineStyle(1, _arg2);
graphics.moveTo((-(_arg1) * 0.5), 0);
graphics.lineTo((_arg1 * 0.5), 0);
blendMode = _arg3;
}
}
}//package org.flintparticles.common.displayObjects
Section 157
//Emitter (org.flintparticles.common.emitters.Emitter)
package org.flintparticles.common.emitters {
import flash.events.*;
import org.flintparticles.common.initializers.*;
import org.flintparticles.common.actions.*;
import org.flintparticles.common.activities.*;
import org.flintparticles.common.counters.*;
import org.flintparticles.common.particles.*;
import org.flintparticles.common.events.*;
import org.flintparticles.common.utils.*;
public class Emitter extends EventDispatcher {
protected var _running:Boolean;// = false
protected var _activities:PriorityArray;
protected var _particles:Array;
protected var _initializers:PriorityArray;
protected var _counter:Counter;
protected var _started:Boolean;// = false
protected var _actions:PriorityArray;
protected var _useInternalTick:Boolean;// = true
protected var _fixedFrameTime:Number;// = 0
protected var _particleFactory:ParticleFactory;
protected var _maximumFrameTime:Number;// = 0.1
public function Emitter(){
_useInternalTick = true;
_fixedFrameTime = 0;
_running = false;
_started = false;
_maximumFrameTime = 0.1;
super();
_particles = new Array();
_actions = new PriorityArray();
_initializers = new PriorityArray();
_activities = new PriorityArray();
_counter = new ZeroCounter();
}
public function stop():void{
if (_useInternalTick){
FrameUpdater.instance.removeEventListener(UpdateEvent.UPDATE, updateEventListener);
};
_started = false;
killAllParticles();
}
public function get counter():Counter{
return (_counter);
}
public function addInitializer(_arg1:Initializer, _arg2:Number=NaN):void{
if (isNaN(_arg2)){
_arg2 = _arg1.getDefaultPriority();
};
_initializers.add(_arg1, _arg2);
_arg1.addedToEmitter(this);
}
public function killAllParticles():void{
var _local1:int;
var _local2:int;
_local1 = _particles.length;
_local2 = 0;
while (_local2 < _local1) {
dispatchEvent(new ParticleEvent(ParticleEvent.PARTICLE_DEAD, _particles[_local2]));
_particleFactory.disposeParticle(_particles[_local2]);
_local2++;
};
_particles.length = 0;
}
public function set fixedFrameTime(_arg1:Number):void{
_fixedFrameTime = _arg1;
}
public function get maximumFrameTime():Number{
return (_maximumFrameTime);
}
public function get useInternalTick():Boolean{
return (_useInternalTick);
}
public function get particleFactory():ParticleFactory{
return (_particleFactory);
}
private function updateEventListener(_arg1:UpdateEvent):void{
if (_fixedFrameTime){
update(_fixedFrameTime);
} else {
update(_arg1.time);
};
}
protected function createParticle():Particle{
var _local1:Particle;
var _local2:int;
var _local3:int;
_local1 = _particleFactory.createParticle();
_local2 = _initializers.length;
initParticle(_local1);
_local3 = 0;
while (_local3 < _local2) {
_initializers[_local3].initialize(this, _local1);
_local3++;
};
_particles.push(_local1);
dispatchEvent(new ParticleEvent(ParticleEvent.PARTICLE_CREATED, _local1));
return (_local1);
}
public function get particles():Array{
return (_particles);
}
protected function sortParticles():void{
}
public function removeActivity(_arg1:Activity):void{
if (_activities.remove(_arg1)){
_arg1.removedFromEmitter(this);
};
}
public function set maximumFrameTime(_arg1:Number):void{
_maximumFrameTime = _arg1;
}
protected function initParticle(_arg1:Particle):void{
}
public function addAction(_arg1:Action, _arg2:Number=NaN):void{
if (isNaN(_arg2)){
_arg2 = _arg1.getDefaultPriority();
};
_actions.add(_arg1, _arg2);
_arg1.addedToEmitter(this);
}
public function hasInitializerOfType(_arg1:Class):Boolean{
var _local2:uint;
var _local3:uint;
_local2 = _initializers.length;
_local3 = 0;
while (_local3 < _local2) {
if ((_initializers[_local3] is _arg1)){
return (true);
};
_local3++;
};
return (false);
}
public function resume():void{
_running = true;
}
public function removeInitializer(_arg1:Initializer):void{
if (_initializers.remove(_arg1)){
_arg1.removedFromEmitter(this);
};
}
public function get running():Boolean{
return (_running);
}
public function hasActionOfType(_arg1:Class):Boolean{
var _local2:uint;
var _local3:uint;
_local2 = _actions.length;
_local3 = 0;
while (_local3 < _local2) {
if ((_actions[_local3] is _arg1)){
return (true);
};
_local3++;
};
return (false);
}
public function get fixedFrameTime():Number{
return (_fixedFrameTime);
}
public function set particleFactory(_arg1:ParticleFactory):void{
_particleFactory = _arg1;
}
public function hasActivity(_arg1:Activity):Boolean{
return (_activities.contains(_arg1));
}
public function addActivity(_arg1:Activity, _arg2:Number=NaN):void{
if (isNaN(_arg2)){
_arg2 = _arg1.getDefaultPriority();
};
_activities.add(_arg1, _arg2);
_arg1.addedToEmitter(this);
}
public function update(_arg1:Number):void{
var _local2:int;
var _local3:Particle;
var _local4:int;
var _local5:Action;
var _local6:int;
var _local7:int;
if (!_running){
return;
};
if (_arg1 > _maximumFrameTime){
_arg1 = _maximumFrameTime;
};
_local4 = _counter.updateEmitter(this, _arg1);
_local2 = 0;
while (_local2 < _local4) {
createParticle();
_local2++;
};
sortParticles();
_local4 = _activities.length;
_local2 = 0;
while (_local2 < _local4) {
_activities[_local2].update(this, _arg1);
_local2++;
};
if (_particles.length > 0){
_local4 = _actions.length;
_local6 = _particles.length;
_local7 = 0;
while (_local7 < _local4) {
_local5 = _actions[_local7];
_local2 = 0;
while (_local2 < _local6) {
_local3 = _particles[_local2];
_local5.update(this, _local3, _arg1);
_local2++;
};
_local7++;
};
_local2 = _local6;
while (_local2--) {
_local3 = _particles[_local2];
if (_local3.isDead){
dispatchEvent(new ParticleEvent(ParticleEvent.PARTICLE_DEAD, _local3));
_particleFactory.disposeParticle(_local3);
_particles.splice(_local2, 1);
};
};
} else {
dispatchEvent(new EmitterEvent(EmitterEvent.EMITTER_EMPTY));
};
dispatchEvent(new EmitterEvent(EmitterEvent.EMITTER_UPDATED));
}
public function removeAction(_arg1:Action):void{
if (_actions.remove(_arg1)){
_arg1.removedFromEmitter(this);
};
}
public function hasActivityOfType(_arg1:Class):Boolean{
var _local2:uint;
var _local3:uint;
_local2 = _activities.length;
_local3 = 0;
while (_local3 < _local2) {
if ((_activities[_local3] is _arg1)){
return (true);
};
_local3++;
};
return (false);
}
public function addExistingParticles(_arg1:Array, _arg2:Boolean=false):void{
var _local3:int;
var _local4:int;
var _local5:int;
var _local6:int;
_local3 = _arg1.length;
if (_arg2){
_local5 = _initializers.length;
_local6 = 0;
while (_local6 < _local5) {
_local4 = 0;
while (_local4 < _local3) {
_initializers[_local6].initialize(this, _arg1[_local4]);
_local4++;
};
_local6++;
};
};
_local4 = 0;
while (_local4 < _local3) {
_particles.push(_arg1[_local4]);
dispatchEvent(new ParticleEvent(ParticleEvent.PARTICLE_ADDED, _arg1[_local4]));
_local4++;
};
}
public function set useInternalTick(_arg1:Boolean):void{
if (_useInternalTick != _arg1){
_useInternalTick = _arg1;
if (_started){
if (_useInternalTick){
FrameUpdater.instance.addEventListener(UpdateEvent.UPDATE, updateEventListener, false, 0, true);
} else {
FrameUpdater.instance.removeEventListener(UpdateEvent.UPDATE, updateEventListener);
};
};
};
}
public function hasInitializer(_arg1:Initializer):Boolean{
return (_initializers.contains(_arg1));
}
public function start():void{
var _local1:int;
var _local2:int;
if (_useInternalTick){
FrameUpdater.instance.addEventListener(UpdateEvent.UPDATE, updateEventListener, false, 0, true);
};
_started = true;
_running = true;
_local1 = _activities.length;
_local2 = 0;
while (_local2 < _local1) {
_activities[_local2].initialize(this);
_local2++;
};
_local1 = _counter.startEmitter(this);
_local2 = 0;
while (_local2 < _local1) {
createParticle();
_local2++;
};
}
public function hasAction(_arg1:Action):Boolean{
return (_actions.contains(_arg1));
}
public function pause():void{
_running = false;
}
public function set counter(_arg1:Counter):void{
_counter = _arg1;
if (running){
_counter.startEmitter(this);
};
}
public function runAhead(_arg1:Number, _arg2:Number=10):void{
var _local3:Number;
var _local4:Number;
_local3 = _maximumFrameTime;
_local4 = (1 / _arg2);
_maximumFrameTime = _local4;
while (_arg1 > 0) {
_arg1 = (_arg1 - _local4);
update(_local4);
};
_maximumFrameTime = _local3;
}
}
}//package org.flintparticles.common.emitters
Section 158
//Linear (org.flintparticles.common.energyEasing.Linear)
package org.flintparticles.common.energyEasing {
public class Linear {
public static function easeOut(_arg1:Number, _arg2:Number):Number{
return ((1 - (_arg1 / _arg2)));
}
public static function easeIn(_arg1:Number, _arg2:Number):Number{
return ((1 - (_arg1 / _arg2)));
}
public static function easeInOut(_arg1:Number, _arg2:Number):Number{
return ((1 - (_arg1 / _arg2)));
}
public static function easeNone(_arg1:Number, _arg2:Number):Number{
return ((1 - (_arg1 / _arg2)));
}
}
}//package org.flintparticles.common.energyEasing
Section 159
//Quadratic (org.flintparticles.common.energyEasing.Quadratic)
package org.flintparticles.common.energyEasing {
public class Quadratic {
public static function easeOut(_arg1:Number, _arg2:Number):Number{
_arg1 = (1 - (_arg1 / _arg2));
return ((_arg1 * _arg1));
}
public static function easeIn(_arg1:Number, _arg2:Number):Number{
_arg1 = (_arg1 / _arg2);
return ((1 - (_arg1 * _arg1)));
}
public static function easeInOut(_arg1:Number, _arg2:Number):Number{
_arg1 = (_arg1 / (_arg2 * 0.5));
if (_arg1 < 1){
return ((1 - ((_arg1 * _arg1) * 0.5)));
};
_arg1 = (_arg1 - 2);
return (((_arg1 * _arg1) * 0.5));
}
}
}//package org.flintparticles.common.energyEasing
Section 160
//EmitterEvent (org.flintparticles.common.events.EmitterEvent)
package org.flintparticles.common.events {
import flash.events.*;
public class EmitterEvent extends Event {
public static var EMITTER_UPDATED:String = "emitterUpdated";
public static var EMITTER_EMPTY:String = "emitterEmpty";
public function EmitterEvent(_arg1:String, _arg2:Boolean=false, _arg3:Boolean=false){
super(_arg1, _arg2, _arg3);
}
}
}//package org.flintparticles.common.events
Section 161
//ParticleEvent (org.flintparticles.common.events.ParticleEvent)
package org.flintparticles.common.events {
import flash.events.*;
import org.flintparticles.common.particles.*;
public class ParticleEvent extends Event {
public var particle:Particle;
public var otherObject;
public static var PARTICLES_COLLISION:String = "particlesCollision";
public static var PARTICLE_ADDED:String = "particleAdded";
public static var PARTICLE_DEAD:String = "particleDead";
public static var PARTICLE_CREATED:String = "particleCreated";
public function ParticleEvent(_arg1:String, _arg2:Particle=null, _arg3:Boolean=false, _arg4:Boolean=false){
super(_arg1, _arg3, _arg4);
this.particle = _arg2;
}
}
}//package org.flintparticles.common.events
Section 162
//UpdateEvent (org.flintparticles.common.events.UpdateEvent)
package org.flintparticles.common.events {
import flash.events.*;
public class UpdateEvent extends Event {
public var time:Number;
public static var UPDATE:String = "update";
public function UpdateEvent(_arg1:String, _arg2:Number=NaN, _arg3:Boolean=false, _arg4:Boolean=false){
super(_arg1, _arg3, _arg4);
this.time = _arg2;
}
}
}//package org.flintparticles.common.events
Section 163
//ColorInit (org.flintparticles.common.initializers.ColorInit)
package org.flintparticles.common.initializers {
import org.flintparticles.common.particles.*;
import org.flintparticles.common.emitters.*;
import org.flintparticles.common.utils.*;
public class ColorInit extends InitializerBase {
private var _max:uint;
private var _min:uint;
public function ColorInit(_arg1:uint, _arg2:uint){
_min = _arg1;
_max = _arg2;
}
public function get color():uint{
return (((_min == _max)) ? _min : interpolateColors(_max, _min, 0.5));
}
public function set color(_arg1:uint):void{
_max = (_min = _arg1);
}
public function set minColor(_arg1:uint):void{
_min = _arg1;
}
public function set maxColor(_arg1:uint):void{
_max = _arg1;
}
override public function initialize(_arg1:Emitter, _arg2:Particle):void{
if (_max == _min){
_arg2.color = _min;
} else {
_arg2.color = interpolateColors(_min, _max, Math.random());
};
}
public function get minColor():uint{
return (_min);
}
public function get maxColor():uint{
return (_max);
}
}
}//package org.flintparticles.common.initializers
Section 164
//Initializer (org.flintparticles.common.initializers.Initializer)
package org.flintparticles.common.initializers {
import org.flintparticles.common.particles.*;
import org.flintparticles.common.emitters.*;
public interface Initializer {
function initialize(_arg1:Emitter, _arg2:Particle):void;
function addedToEmitter(_arg1:Emitter):void;
function removedFromEmitter(_arg1:Emitter):void;
function getDefaultPriority():Number;
}
}//package org.flintparticles.common.initializers
Section 165
//InitializerBase (org.flintparticles.common.initializers.InitializerBase)
package org.flintparticles.common.initializers {
import org.flintparticles.common.particles.*;
import org.flintparticles.common.emitters.*;
public class InitializerBase implements Initializer {
public function initialize(_arg1:Emitter, _arg2:Particle):void{
}
public function removedFromEmitter(_arg1:Emitter):void{
}
public function getDefaultPriority():Number{
return (0);
}
public function addedToEmitter(_arg1:Emitter):void{
}
}
}//package org.flintparticles.common.initializers
Section 166
//Lifetime (org.flintparticles.common.initializers.Lifetime)
package org.flintparticles.common.initializers {
import org.flintparticles.common.particles.*;
import org.flintparticles.common.emitters.*;
public class Lifetime extends InitializerBase {
private var _min:Number;
private var _max:Number;
public function Lifetime(_arg1:Number, _arg2:Number=NaN){
_max = _arg2;
_min = _arg1;
}
public function set maxLifetime(_arg1:Number):void{
_max = _arg1;
}
public function get maxLifetime():Number{
return (_max);
}
override public function initialize(_arg1:Emitter, _arg2:Particle):void{
if (isNaN(_max)){
_arg2.lifetime = _min;
} else {
_arg2.lifetime = (_min + (Math.random() * (_max - _min)));
};
}
public function set lifetime(_arg1:Number):void{
_max = (_min = _arg1);
}
public function get lifetime():Number{
return (((_min == _max)) ? _min : ((_max + _min) * 0.5));
}
public function get minLifetime():Number{
return (_min);
}
public function set minLifetime(_arg1:Number):void{
_min = _arg1;
}
}
}//package org.flintparticles.common.initializers
Section 167
//SharedImage (org.flintparticles.common.initializers.SharedImage)
package org.flintparticles.common.initializers {
import flash.display.*;
import org.flintparticles.common.particles.*;
import org.flintparticles.common.emitters.*;
public class SharedImage extends InitializerBase {
private var _image:DisplayObject;
public function SharedImage(_arg1:DisplayObject){
_image = _arg1;
}
override public function initialize(_arg1:Emitter, _arg2:Particle):void{
_arg2.image = _image;
}
public function get image():DisplayObject{
return (_image);
}
public function set image(_arg1:DisplayObject):void{
_image = _arg1;
}
}
}//package org.flintparticles.common.initializers
Section 168
//Particle (org.flintparticles.common.particles.Particle)
package org.flintparticles.common.particles {
import flash.geom.*;
import flash.utils.*;
public class Particle {
public var lifetime:Number;// = 0
public var scale:Number;// = 1
public var energy:Number;// = 1
public var image;// = null
public var color:uint;// = 4294967295
public var collisionRadius:Number;// = 1
private var _colorTransform:ColorTransform;// = null
private var _previousColor:uint;
public var isDead:Boolean;// = false
public var mass:Number;// = 1
private var _dictionary:Dictionary;// = null
public var age:Number;// = 0
public function Particle(){
color = 4294967295;
_colorTransform = null;
scale = 1;
mass = 1;
collisionRadius = 1;
image = null;
lifetime = 0;
age = 0;
energy = 1;
isDead = false;
_dictionary = null;
super();
}
public function get dictionary():Dictionary{
if (_dictionary == null){
_dictionary = new Dictionary(true);
};
return (_dictionary);
}
public function get colorTransform():ColorTransform{
if (((!(_colorTransform)) || (!((_previousColor == color))))){
_colorTransform = new ColorTransform((((color >>> 16) & 0xFF) / 0xFF), (((color >>> 8) & 0xFF) / 0xFF), ((color & 0xFF) / 0xFF), (((color >>> 24) & 0xFF) / 0xFF), 0, 0, 0, 0);
_previousColor = color;
};
return (_colorTransform);
}
protected function cloneInto(_arg1:Particle):Particle{
var _local2:Object;
_arg1.color = color;
_arg1.scale = scale;
_arg1.mass = mass;
_arg1.collisionRadius = collisionRadius;
_arg1.lifetime = lifetime;
_arg1.age = age;
_arg1.energy = energy;
_arg1.isDead = isDead;
_arg1.image = image;
if (_dictionary){
_arg1._dictionary = new Dictionary(true);
for (_local2 in _dictionary) {
_arg1._dictionary[_local2] = _dictionary[_local2];
};
};
return (_arg1);
}
public function get alpha():Number{
return ((((color & 4278190080) >>> 24) / 0xFF));
}
public function clone(_arg1:ParticleFactory=null):Particle{
var _local2:Particle;
if (_arg1){
_local2 = _arg1.createParticle();
} else {
_local2 = new Particle();
};
return (cloneInto(_local2));
}
public function initialize():void{
color = 4294967295;
scale = 1;
mass = 1;
collisionRadius = 1;
lifetime = 0;
age = 0;
energy = 1;
isDead = false;
image = null;
_dictionary = null;
_colorTransform = null;
}
}
}//package org.flintparticles.common.particles
Section 169
//ParticleFactory (org.flintparticles.common.particles.ParticleFactory)
package org.flintparticles.common.particles {
public interface ParticleFactory {
function createParticle():Particle;
function disposeParticle(_arg1:Particle):void;
}
}//package org.flintparticles.common.particles
Section 170
//Renderer (org.flintparticles.common.renderers.Renderer)
package org.flintparticles.common.renderers {
import org.flintparticles.common.emitters.*;
public interface Renderer {
function removeEmitter(_arg1:Emitter):void;
function addEmitter(_arg1:Emitter):void;
}
}//package org.flintparticles.common.renderers
Section 171
//SpriteRendererBase (org.flintparticles.common.renderers.SpriteRendererBase)
package org.flintparticles.common.renderers {
import flash.events.*;
import flash.display.*;
import org.flintparticles.common.particles.*;
import org.flintparticles.common.events.*;
import org.flintparticles.common.emitters.*;
public class SpriteRendererBase extends Sprite implements Renderer {
protected var _emitters:Array;
public function SpriteRendererBase(){
_emitters = new Array();
mouseEnabled = false;
mouseChildren = false;
addEventListener(Event.ADDED_TO_STAGE, addedToStage, false, 0, true);
}
private function particleAdded(_arg1:ParticleEvent):void{
addParticle(_arg1.particle);
if (stage){
stage.invalidate();
};
}
private function addedToStage(_arg1:Event):void{
if (stage){
stage.invalidate();
};
}
protected function removeParticle(_arg1:Particle):void{
}
protected function addParticle(_arg1:Particle):void{
}
public function removeEmitter(_arg1:Emitter):void{
var _local2:int;
var _local3:Particle;
_local2 = 0;
while (_local2 < _emitters.length) {
if (_emitters[_local2] == _arg1){
_emitters.splice(_local2, 1);
_arg1.removeEventListener(EmitterEvent.EMITTER_UPDATED, emitterUpdated);
_arg1.removeEventListener(ParticleEvent.PARTICLE_CREATED, particleAdded);
_arg1.removeEventListener(ParticleEvent.PARTICLE_ADDED, particleAdded);
_arg1.removeEventListener(ParticleEvent.PARTICLE_DEAD, particleRemoved);
for each (_local3 in _arg1.particles) {
removeParticle(_local3);
};
if (_emitters.length == 0){
removeEventListener(Event.RENDER, updateParticles);
renderParticles([]);
} else {
stage.invalidate();
};
return;
};
_local2++;
};
}
private function emitterUpdated(_arg1:EmitterEvent):void{
if (stage){
stage.invalidate();
};
}
public function addEmitter(_arg1:Emitter):void{
var _local2:Particle;
_emitters.push(_arg1);
if (stage){
stage.invalidate();
};
_arg1.addEventListener(EmitterEvent.EMITTER_UPDATED, emitterUpdated, false, 0, true);
_arg1.addEventListener(ParticleEvent.PARTICLE_CREATED, particleAdded, false, 0, true);
_arg1.addEventListener(ParticleEvent.PARTICLE_ADDED, particleAdded, false, 0, true);
_arg1.addEventListener(ParticleEvent.PARTICLE_DEAD, particleRemoved, false, 0, true);
for each (_local2 in _arg1.particles) {
addParticle(_local2);
};
if (_emitters.length == 1){
addEventListener(Event.RENDER, updateParticles, false, 0, true);
};
}
protected function renderParticles(_arg1:Array):void{
}
public function get emitters():Array{
return (_emitters);
}
private function updateParticles(_arg1:Event):void{
var _local2:Array;
var _local3:int;
_local2 = new Array();
_local3 = 0;
while (_local3 < _emitters.length) {
_local2 = _local2.concat(_emitters[_local3].particles);
_local3++;
};
renderParticles(_local2);
}
private function particleRemoved(_arg1:ParticleEvent):void{
removeParticle(_arg1.particle);
if (stage){
stage.invalidate();
};
}
}
}//package org.flintparticles.common.renderers
Section 172
//FrameUpdater (org.flintparticles.common.utils.FrameUpdater)
package org.flintparticles.common.utils {
import flash.events.*;
import flash.display.*;
import org.flintparticles.common.events.*;
import flash.utils.*;
public class FrameUpdater extends EventDispatcher {
private var _shape:Shape;
private var _time:Number;
private static var _instance:FrameUpdater;
public function FrameUpdater(){
_shape = new Shape();
_shape.addEventListener(Event.ENTER_FRAME, frameUpdate, false, 0, true);
_time = getTimer();
}
private function frameUpdate(_arg1:Event):void{
var _local2:int;
var _local3:Number;
_local2 = _time;
_time = getTimer();
_local3 = ((_time - _local2) * 0.001);
dispatchEvent(new UpdateEvent(UpdateEvent.UPDATE, _local3));
}
public static function get instance():FrameUpdater{
if (_instance == null){
_instance = new (FrameUpdater);
};
return (_instance);
}
}
}//package org.flintparticles.common.utils
Section 173
//interpolateColors (org.flintparticles.common.utils.interpolateColors)
package org.flintparticles.common.utils {
public function interpolateColors(_arg1:uint, _arg2:uint, _arg3:Number):uint{
var _local4:Number;
var _local5:uint;
var _local6:uint;
var _local7:uint;
var _local8:uint;
_local4 = (1 - _arg3);
_local5 = Math.round(((((_arg1 >>> 16) & 0xFF) * _arg3) + (((_arg2 >>> 16) & 0xFF) * _local4)));
_local6 = Math.round(((((_arg1 >>> 8) & 0xFF) * _arg3) + (((_arg2 >>> 8) & 0xFF) * _local4)));
_local7 = Math.round((((_arg1 & 0xFF) * _arg3) + ((_arg2 & 0xFF) * _local4)));
_local8 = Math.round(((((_arg1 >>> 24) & 0xFF) * _arg3) + (((_arg2 >>> 24) & 0xFF) * _local4)));
return (((((_local8 << 24) | (_local5 << 16)) | (_local6 << 8)) | _local7));
}
}//package org.flintparticles.common.utils
Section 174
//Maths (org.flintparticles.common.utils.Maths)
package org.flintparticles.common.utils {
public class Maths {
private static const DEGTORAD:Number = 0.0174532925199433;
private static const RADTODEG:Number = 57.2957795130823;
public static function asRadians(_arg1:Number):Number{
return ((_arg1 * DEGTORAD));
}
public static function asDegrees(_arg1:Number):Number{
return ((_arg1 * RADTODEG));
}
}
}//package org.flintparticles.common.utils
Section 175
//PriorityArray (org.flintparticles.common.utils.PriorityArray)
package org.flintparticles.common.utils {
import flash.utils.*;
public class PriorityArray extends Proxy {
private var _values:Array;
public function PriorityArray(){
_values = new Array();
}
public function remove(_arg1):Boolean{
var _local2:uint;
_local2 = _values.length;
while (_local2--) {
if (_values[_local2].value == _arg1){
_values.splice(_local2, 1);
return (true);
};
};
return (false);
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function nextName(_arg1:int):String{
return ((_arg1 - 1).toString());
}
public function removeAt(_arg1:uint){
var _local2:*;
_local2 = _values[_arg1].value;
_values.splice(_arg1, 1);
return (_local2);
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function getProperty(_arg1){
var _local2:int;
_local2 = int(_arg1);
if ((((((_local2 == _arg1)) && ((_local2 < _values.length)))) && (_values[_local2]))){
return (_values[_local2].value);
};
return (undefined);
}
public function clear():void{
_values.length = 0;
}
public function add(_arg1, _arg2:Number):uint{
var _local3:uint;
var _local4:uint;
_local3 = _values.length;
_local4 = 0;
while (_local4 < _local3) {
if (_values[_local4].priority < _arg2){
break;
};
_local4++;
};
_values.splice(_local4, 0, new Pair(_arg2, _arg1));
return (_values.length);
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function nextNameIndex(_arg1:int):int{
if (_arg1 < _values.length){
return ((_arg1 + 1));
};
return (0);
}
public function get length():uint{
return (_values.length);
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function setProperty(_arg1, _arg2):void{
var _local3:uint;
_local3 = uint(_arg1);
if ((((_local3 == _arg1)) && ((_local3 < _values.length)))){
_values[_local3].value = _arg2;
};
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function nextValue(_arg1:int){
return (_values[(_arg1 - 1)].value);
}
public function contains(_arg1):Boolean{
var _local2:uint;
_local2 = _values.length;
while (_local2--) {
if (_values[_local2].value == _arg1){
return (true);
};
};
return (false);
}
}
}//package org.flintparticles.common.utils
class Pair {
private var value;
private var priority:Number;
private function Pair(_arg1:Number, _arg2){
this.priority = _arg1;
this.value = _arg2;
}
}
Section 176
//Accelerate (org.flintparticles.twoD.actions.Accelerate)
package org.flintparticles.twoD.actions {
import org.flintparticles.common.actions.*;
import org.flintparticles.common.particles.*;
import org.flintparticles.common.emitters.*;
import org.flintparticles.twoD.particles.*;
public class Accelerate extends ActionBase {
private var _x:Number;
private var _y:Number;
public function Accelerate(_arg1:Number, _arg2:Number){
_x = _arg1;
_y = _arg2;
}
public function get y():Number{
return (_y);
}
override public function update(_arg1:Emitter, _arg2:Particle, _arg3:Number):void{
var _local4:Particle2D;
_local4 = Particle2D(_arg2);
Particle2D(_arg2).velX = (_local4.velX + (_x * _arg3));
_local4.velY = (_local4.velY + (_y * _arg3));
}
public function set y(_arg1:Number):void{
_y = _arg1;
}
public function set x(_arg1:Number):void{
_x = _arg1;
}
public function get x():Number{
return (_x);
}
}
}//package org.flintparticles.twoD.actions
Section 177
//LinearDrag (org.flintparticles.twoD.actions.LinearDrag)
package org.flintparticles.twoD.actions {
import org.flintparticles.common.actions.*;
import org.flintparticles.common.particles.*;
import org.flintparticles.common.emitters.*;
import org.flintparticles.twoD.particles.*;
public class LinearDrag extends ActionBase {
private var _drag:Number;
public function LinearDrag(_arg1:Number){
_drag = _arg1;
}
public function set drag(_arg1:Number):void{
_drag = _arg1;
}
override public function update(_arg1:Emitter, _arg2:Particle, _arg3:Number):void{
var _local4:Particle2D;
var _local5:Number;
_local4 = Particle2D(_arg2);
_local5 = (1 - ((_drag * _arg3) / _local4.mass));
if (_local5 < 0){
_local4.velX = 0;
_local4.velY = 0;
} else {
_local4.velX = (_local4.velX * _local5);
_local4.velY = (_local4.velY * _local5);
};
}
public function get drag():Number{
return (_drag);
}
}
}//package org.flintparticles.twoD.actions
Section 178
//Move (org.flintparticles.twoD.actions.Move)
package org.flintparticles.twoD.actions {
import org.flintparticles.common.actions.*;
import org.flintparticles.common.particles.*;
import org.flintparticles.common.emitters.*;
import org.flintparticles.twoD.particles.*;
public class Move extends ActionBase {
private var p:Particle2D;
override public function update(_arg1:Emitter, _arg2:Particle, _arg3:Number):void{
p = Particle2D(_arg2);
p.x = (p.x + (p.velX * _arg3));
p.y = (p.y + (p.velY * _arg3));
}
override public function getDefaultPriority():Number{
return (-10);
}
}
}//package org.flintparticles.twoD.actions
Section 179
//RotateEmitter (org.flintparticles.twoD.activities.RotateEmitter)
package org.flintparticles.twoD.activities {
import org.flintparticles.common.activities.*;
import org.flintparticles.common.emitters.*;
import org.flintparticles.twoD.emitters.*;
public class RotateEmitter extends ActivityBase {
private var _angularVelocity:Number;
public function RotateEmitter(_arg1:Number){
_angularVelocity = _arg1;
}
public function set angularVelocity(_arg1:Number):void{
_angularVelocity = _arg1;
}
override public function update(_arg1:Emitter, _arg2:Number):void{
var _local3:Emitter2D;
_local3 = Emitter2D(_arg1);
_local3.rotRadians = (_local3.rotRadians + (_angularVelocity * _arg2));
}
public function get angularVelocity():Number{
return (_angularVelocity);
}
}
}//package org.flintparticles.twoD.activities
Section 180
//Emitter2D (org.flintparticles.twoD.emitters.Emitter2D)
package org.flintparticles.twoD.emitters {
import org.flintparticles.common.particles.*;
import org.flintparticles.common.emitters.*;
import org.flintparticles.twoD.particles.*;
import org.flintparticles.common.utils.*;
public class Emitter2D extends Emitter {
protected var _y:Number;// = 0
protected var _x:Number;// = 0
public var spaceSort:Boolean;// = false
public var spaceSortedX:Array;
protected var _rotation:Number;// = 0
protected static var _creator:ParticleCreator2D = new ParticleCreator2D();
public function Emitter2D(){
_x = 0;
_y = 0;
_rotation = 0;
spaceSort = false;
super();
_particleFactory = _creator;
}
public function set rotation(_arg1:Number):void{
_rotation = Maths.asRadians(_arg1);
}
public function get y():Number{
return (_y);
}
public function set y(_arg1:Number):void{
_y = _arg1;
}
override protected function sortParticles():void{
var _local1:int;
var _local2:int;
if (spaceSort){
spaceSortedX = _particles.sortOn("x", (Array.NUMERIC | Array.RETURNINDEXEDARRAY));
_local1 = _particles.length;
_local2 = 0;
while (_local2 < _local1) {
_particles[spaceSortedX[_local2]].sortID = _local2;
_local2++;
};
};
}
override protected function initParticle(_arg1:Particle):void{
var _local2:Particle2D;
_local2 = Particle2D(_arg1);
_local2.x = _x;
_local2.y = _y;
_local2.rotation = _rotation;
}
public function set rotRadians(_arg1:Number):void{
_rotation = _arg1;
}
public function get rotRadians():Number{
return (_rotation);
}
public function set x(_arg1:Number):void{
_x = _arg1;
}
public function get rotation():Number{
return (Maths.asDegrees(_rotation));
}
public function get x():Number{
return (_x);
}
public static function get defaultParticleFactory():ParticleFactory{
return (_creator);
}
}
}//package org.flintparticles.twoD.emitters
Section 181
//Velocity (org.flintparticles.twoD.initializers.Velocity)
package org.flintparticles.twoD.initializers {
import org.flintparticles.common.initializers.*;
import org.flintparticles.common.particles.*;
import org.flintparticles.common.emitters.*;
import flash.geom.*;
import org.flintparticles.twoD.particles.*;
import org.flintparticles.twoD.zones.*;
public class Velocity extends InitializerBase {
private var _zone:Zone2D;
public function Velocity(_arg1:Zone2D){
_zone = _arg1;
}
public function get zone():Zone2D{
return (_zone);
}
override public function initialize(_arg1:Emitter, _arg2:Particle):void{
var _local3:Particle2D;
var _local4:Point;
var _local5:Number;
var _local6:Number;
_local3 = Particle2D(_arg2);
_local4 = _zone.getLocation();
if (_local3.rotation == 0){
_local3.velX = _local4.x;
_local3.velY = _local4.y;
} else {
_local5 = Math.sin(_local3.rotation);
_local6 = Math.cos(_local3.rotation);
_local3.velX = ((_local6 * _local4.x) - (_local5 * _local4.y));
_local3.velY = ((_local6 * _local4.y) + (_local5 * _local4.x));
};
}
public function set zone(_arg1:Zone2D):void{
_zone = _arg1;
}
}
}//package org.flintparticles.twoD.initializers
Section 182
//Particle2D (org.flintparticles.twoD.particles.Particle2D)
package org.flintparticles.twoD.particles {
import org.flintparticles.common.particles.*;
import flash.geom.*;
public class Particle2D extends Particle {
public var sortID:int;// = -1
public var rotation:Number;// = 0
private var _previousRadius:Number;
public var velX:Number;// = 0
public var angVelocity:Number;// = 0
private var _previousMass:Number;
public var velY:Number;// = 0
public var x:Number;// = 0
public var y:Number;// = 0
private var _inertia:Number;
public function Particle2D(){
x = 0;
y = 0;
velX = 0;
velY = 0;
rotation = 0;
angVelocity = 0;
sortID = -1;
super();
}
public function get matrixTransform():Matrix{
var _local1:Number;
var _local2:Number;
_local1 = (scale * Math.cos(rotation));
_local2 = (scale * Math.sin(rotation));
return (new Matrix(_local1, _local2, -(_local2), _local1, x, y));
}
override public function initialize():void{
super.initialize();
x = 0;
y = 0;
velX = 0;
velY = 0;
rotation = 0;
angVelocity = 0;
sortID = -1;
}
override public function clone(_arg1:ParticleFactory=null):Particle{
var _local2:Particle2D;
if (_arg1){
_local2 = (_arg1.createParticle() as Particle2D);
} else {
_local2 = new Particle2D();
};
cloneInto(_local2);
_local2.x = x;
_local2.y = y;
_local2.velX = velX;
_local2.velY = velY;
_local2.rotation = rotation;
_local2.angVelocity = angVelocity;
return (_local2);
}
public function get inertia():Number{
if (((!((mass == _previousMass))) || (!((collisionRadius == _previousRadius))))){
_inertia = (((mass * collisionRadius) * collisionRadius) * 0.5);
_previousMass = mass;
_previousRadius = collisionRadius;
};
return (_inertia);
}
}
}//package org.flintparticles.twoD.particles
Section 183
//ParticleCreator2D (org.flintparticles.twoD.particles.ParticleCreator2D)
package org.flintparticles.twoD.particles {
import org.flintparticles.common.particles.*;
public class ParticleCreator2D implements ParticleFactory {
private var _particles:Array;
public function ParticleCreator2D(){
_particles = new Array();
}
public function clearAllParticles():void{
_particles = new Array();
}
public function createParticle():Particle{
if (_particles.length){
return (_particles.pop());
};
return (new Particle2D());
}
public function disposeParticle(_arg1:Particle):void{
if ((_arg1 is Particle2D)){
_arg1.initialize();
_particles.push(_arg1);
};
}
}
}//package org.flintparticles.twoD.particles
Section 184
//BitmapRenderer (org.flintparticles.twoD.renderers.BitmapRenderer)
package org.flintparticles.twoD.renderers {
import flash.display.*;
import flash.geom.*;
import flash.filters.*;
import org.flintparticles.twoD.particles.*;
import org.flintparticles.common.renderers.*;
public class BitmapRenderer extends SpriteRendererBase {
protected var _smoothing:Boolean;
protected var _bitmapData:BitmapData;
protected var _colorMap:Array;
protected var _bitmap:Bitmap;
protected var _postFilters:Array;
protected var _preFilters:Array;
protected var _canvas:Rectangle;
protected static var ZERO_POINT:Point = new Point(0, 0);
public function BitmapRenderer(_arg1:Rectangle, _arg2:Boolean=false){
mouseEnabled = false;
mouseChildren = false;
_smoothing = _arg2;
_preFilters = new Array();
_postFilters = new Array();
_canvas = _arg1;
createBitmap();
}
public function setPaletteMap(_arg1:Array=null, _arg2:Array=null, _arg3:Array=null, _arg4:Array=null):void{
_colorMap = new Array(4);
_colorMap[0] = _arg4;
_colorMap[1] = _arg1;
_colorMap[2] = _arg2;
_colorMap[3] = _arg3;
}
public function clearPaletteMap():void{
_colorMap = null;
}
public function removeFilter(_arg1:BitmapFilter):void{
var _local2:int;
_local2 = 0;
while (_local2 < _preFilters.length) {
if (_preFilters[_local2] == _arg1){
_preFilters.splice(_local2, 1);
return;
};
_local2++;
};
_local2 = 0;
while (_local2 < _postFilters.length) {
if (_postFilters[_local2] == _arg1){
_postFilters.splice(_local2, 1);
return;
};
_local2++;
};
}
protected function createBitmap():void{
if (!_canvas){
return;
};
if (((_bitmap) && (_bitmapData))){
_bitmapData.dispose();
_bitmapData = null;
};
if (_bitmap){
removeChild(_bitmap);
};
_bitmap = new Bitmap(null, "auto", _smoothing);
_bitmapData = new BitmapData(_canvas.width, _canvas.height, true, 0);
_bitmap.bitmapData = _bitmapData;
addChild(_bitmap);
_bitmap.x = _canvas.x;
_bitmap.y = _canvas.y;
}
public function get canvas():Rectangle{
return (_canvas);
}
public function addFilter(_arg1:BitmapFilter, _arg2:Boolean=false):void{
if (_arg2){
_postFilters.push(_arg1);
} else {
_preFilters.push(_arg1);
};
}
public function get bitmapData():BitmapData{
return (_bitmapData);
}
override protected function renderParticles(_arg1:Array):void{
var _local2:int;
var _local3:int;
if (!_bitmap){
return;
};
_bitmapData.lock();
_local3 = _preFilters.length;
_local2 = 0;
while (_local2 < _local3) {
_bitmapData.applyFilter(_bitmapData, _bitmapData.rect, BitmapRenderer.ZERO_POINT, _preFilters[_local2]);
_local2++;
};
if ((((_local3 == 0)) && ((_postFilters.length == 0)))){
_bitmapData.fillRect(_bitmap.bitmapData.rect, 0);
};
_local3 = _arg1.length;
if (_local3){
_local2 = _local3;
while (_local2--) {
drawParticle(_arg1[_local2]);
};
};
_local3 = _postFilters.length;
_local2 = 0;
while (_local2 < _local3) {
_bitmapData.applyFilter(_bitmapData, _bitmapData.rect, BitmapRenderer.ZERO_POINT, _postFilters[_local2]);
_local2++;
};
if (_colorMap){
_bitmapData.paletteMap(_bitmapData, _bitmapData.rect, ZERO_POINT, _colorMap[1], _colorMap[2], _colorMap[3], _colorMap[0]);
};
_bitmapData.unlock();
}
public function set canvas(_arg1:Rectangle):void{
_canvas = _arg1;
createBitmap();
}
protected function drawParticle(_arg1:Particle2D):void{
var _local2:Matrix;
_local2 = _arg1.matrixTransform;
_local2.translate(-(_canvas.x), -(_canvas.y));
_bitmapData.draw(_arg1.image, _local2, _arg1.colorTransform, DisplayObject(_arg1.image).blendMode, null, _smoothing);
}
}
}//package org.flintparticles.twoD.renderers
Section 185
//DiscSectorZone (org.flintparticles.twoD.zones.DiscSectorZone)
package org.flintparticles.twoD.zones {
import flash.geom.*;
public class DiscSectorZone implements Zone2D {
private var _minAngle:Number;
private var _innerRadius:Number;
private var _minAllowed:Number;
private var _innerSq:Number;
private var _outerRadius:Number;
private var _center:Point;
private var _maxAngle:Number;
private var _outerSq:Number;
private static var TWOPI:Number = 6.28318530717959;
public function DiscSectorZone(_arg1:Point, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number){
if (_arg2 < _arg3){
throw (new Error((((("The outerRadius (" + _arg2) + ") can't be smaller than the innerRadius (") + _arg3) + ") in your DiscSectorZone. N.B. the outerRadius is the second argument in the constructor and the innerRadius is the third argument.")));
};
_center = _arg1;
_innerRadius = _arg3;
_outerRadius = _arg2;
_innerSq = (_innerRadius * _innerRadius);
_outerSq = (_outerRadius * _outerRadius);
_minAngle = _arg4;
_maxAngle = _arg5;
while (_maxAngle > TWOPI) {
_maxAngle = (_maxAngle - TWOPI);
};
while (_maxAngle < 0) {
_maxAngle = (_maxAngle + TWOPI);
};
_minAllowed = (_maxAngle - TWOPI);
if (_arg4 == _arg5){
_minAngle = _maxAngle;
} else {
_minAngle = clamp(_minAngle);
};
}
public function set minAngle(_arg1:Number):void{
_minAngle = clamp(_arg1);
}
public function get innerRadius():Number{
return (_innerRadius);
}
public function getArea():Number{
return (((Math.PI * _outerSq) - (Math.PI * _innerSq)));
}
public function set innerRadius(_arg1:Number):void{
_innerRadius = _arg1;
_innerSq = (_innerRadius * _innerRadius);
}
public function get maxAngle():Number{
return (_maxAngle);
}
public function set outerRadius(_arg1:Number):void{
_outerRadius = _arg1;
_outerSq = (_outerRadius * _outerRadius);
}
public function set maxAngle(_arg1:Number):void{
_maxAngle = _arg1;
while (_maxAngle > TWOPI) {
_maxAngle = (_maxAngle - TWOPI);
};
while (_maxAngle < 0) {
_maxAngle = (_maxAngle + TWOPI);
};
_minAllowed = (_maxAngle - TWOPI);
}
public function contains(_arg1:Number, _arg2:Number):Boolean{
var _local3:Number;
var _local4:Number;
_arg1 = (_arg1 - _center.x);
_arg2 = (_arg2 - _center.y);
_local3 = ((_arg1 * _arg1) + (_arg2 * _arg2));
if ((((_local3 > _outerSq)) || ((_local3 < _innerSq)))){
return (false);
};
_local4 = Math.atan2(_arg2, _arg1);
_local4 = clamp(_local4);
return ((_local4 >= _minAngle));
}
public function get minAngle():Number{
return (_minAngle);
}
public function get center():Point{
return (_center);
}
public function getLocation():Point{
var _local1:Number;
var _local2:Point;
_local1 = Math.random();
_local2 = Point.polar((_innerRadius + ((1 - (_local1 * _local1)) * (_outerRadius - _innerRadius))), (_minAngle + (Math.random() * (_maxAngle - _minAngle))));
_local2.x = (_local2.x + _center.x);
_local2.y = (_local2.y + _center.y);
return (_local2);
}
public function set center(_arg1:Point):void{
_center = _arg1;
}
private function clamp(_arg1:Number):Number{
while (_arg1 > _maxAngle) {
_arg1 = (_arg1 - TWOPI);
};
while (_arg1 < _minAllowed) {
_arg1 = (_arg1 + TWOPI);
};
return (_arg1);
}
public function get outerRadius():Number{
return (_outerRadius);
}
}
}//package org.flintparticles.twoD.zones
Section 186
//DiscZone (org.flintparticles.twoD.zones.DiscZone)
package org.flintparticles.twoD.zones {
import flash.geom.*;
public class DiscZone implements Zone2D {
private var _innerRadius:Number;
private var _innerSq:Number;
private var _outerRadius:Number;
private var _center:Point;
private var _outerSq:Number;
private static const TWOPI:Number = 6.28318530717959;
public function DiscZone(_arg1:Point, _arg2:Number, _arg3:Number=0){
if (_arg2 < _arg3){
throw (new Error((((("The outerRadius (" + _arg2) + ") can't be smaller than the innerRadius (") + _arg3) + ") in your DiscZone. N.B. the outerRadius is the second argument in the constructor and the innerRadius is the third argument.")));
};
_center = _arg1;
_innerRadius = _arg3;
_outerRadius = _arg2;
_innerSq = (_innerRadius * _innerRadius);
_outerSq = (_outerRadius * _outerRadius);
}
public function getArea():Number{
return ((Math.PI * (_outerSq - _innerSq)));
}
public function get innerRadius():Number{
return (_innerRadius);
}
public function set innerRadius(_arg1:Number):void{
_innerRadius = _arg1;
_innerSq = (_innerRadius * _innerRadius);
}
public function get center():Point{
return (_center);
}
public function set outerRadius(_arg1:Number):void{
_outerRadius = _arg1;
_outerSq = (_outerRadius * _outerRadius);
}
public function contains(_arg1:Number, _arg2:Number):Boolean{
var _local3:Number;
_arg1 = (_arg1 - _center.x);
_arg2 = (_arg2 - _center.y);
_local3 = ((_arg1 * _arg1) + (_arg2 * _arg2));
return ((((_local3 <= _outerSq)) && ((_local3 >= _innerSq))));
}
public function get outerRadius():Number{
return (_outerRadius);
}
public function set center(_arg1:Point):void{
_center = _arg1;
}
public function getLocation():Point{
var _local1:Number;
var _local2:Point;
_local1 = Math.random();
_local2 = Point.polar((_innerRadius + ((1 - (_local1 * _local1)) * (_outerRadius - _innerRadius))), (Math.random() * TWOPI));
_local2.x = (_local2.x + _center.x);
_local2.y = (_local2.y + _center.y);
return (_local2);
}
}
}//package org.flintparticles.twoD.zones
Section 187
//Zone2D (org.flintparticles.twoD.zones.Zone2D)
package org.flintparticles.twoD.zones {
import flash.geom.*;
public interface Zone2D {
function getArea():Number;
function getLocation():Point;
function contains(_arg1:Number, _arg2:Number):Boolean;
}
}//package org.flintparticles.twoD.zones
Section 188
//Camera3D (org.papervision3d.cameras.Camera3D)
package org.papervision3d.cameras {
import flash.utils.*;
import org.papervision3d.core.render.data.*;
import flash.geom.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.math.*;
import org.papervision3d.core.culling.*;
public class Camera3D extends CameraObject3D {
protected var _focusFix:Matrix3D;
protected var _prevUseProjection:Boolean;
protected var _prevZoom:Number;
protected var _prevOrtho:Boolean;
protected var _prevWidth:Number;
protected var _prevHeight:Number;
protected var _prevFocus:Number;
protected var _prevOrthoProjection:Boolean;
protected var _projection:Matrix3D;
public function Camera3D(_arg1:Number=60, _arg2:Number=10, _arg3:Number=5000, _arg4:Boolean=false, _arg5:Boolean=false){
super(_arg2, 40);
this.fov = _arg1;
_prevFocus = 0;
_prevZoom = 0;
_prevOrtho = false;
_prevUseProjection = false;
_useCulling = _arg4;
_useProjectionMatrix = _arg5;
_far = _arg3;
_focusFix = Matrix3D.IDENTITY;
}
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 near(_arg1:Number):void{
if (_arg1 > 0){
this.focus = _arg1;
this.update(this.viewport);
};
}
override public function orbit(_arg1:Number, _arg2:Number, _arg3:Boolean=true, _arg4:DisplayObject3D=null):void{
var _local8:Number;
_arg4 = ((_arg4) || (_target));
_arg4 = ((_arg4) || (DisplayObject3D.ZERO));
if (_arg3){
_arg1 = (_arg1 * (Math.PI / 180));
_arg2 = (_arg2 * (Math.PI / 180));
};
var _local5:Number = (_arg4.world.n14 - this.x);
var _local6:Number = (_arg4.world.n24 - this.y);
var _local7:Number = (_arg4.world.n34 - this.z);
_local8 = Math.sqrt((((_local5 * _local5) + (_local6 * _local6)) + (_local7 * _local7)));
var _local9:Number = (Math.cos(_arg2) * Math.sin(_arg1));
var _local10:Number = (Math.sin(_arg2) * Math.sin(_arg1));
var _local11:Number = 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 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;
};
}
override public function projectFaces(_arg1:Array, _arg2:DisplayObject3D, _arg3:RenderSessionData):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 _local34:Array;
var _local36:Triangle3D;
var _local4:Matrix3D = _arg2.view;
var _local5:Number = _local4.n11;
var _local6:Number = _local4.n12;
var _local7:Number = _local4.n13;
var _local8:Number = _local4.n21;
var _local9:Number = _local4.n22;
var _local10:Number = _local4.n23;
var _local11:Number = _local4.n31;
var _local12:Number = _local4.n32;
var _local13:Number = _local4.n33;
var _local14:Number = _local4.n41;
var _local15:Number = _local4.n42;
var _local16:Number = _local4.n43;
var _local27:int;
var _local28:Number = _arg3.camera.focus;
var _local29:Number = (_local28 * _arg3.camera.zoom);
var _local30:Number = (viewport.width / 2);
var _local31:Number = (viewport.height / 2);
var _local32:Number = _arg3.camera.far;
var _local33:Number = (_local32 - _local28);
var _local35:Number = getTimer();
for each (_local36 in _arg1) {
_local34 = _local36.vertices;
_local27 = _local34.length;
while ((_local24 = _local34[--_local27])) {
if (_local24.timestamp == _local35){
} else {
_local24.timestamp = _local35;
_local17 = _local24.x;
_local18 = _local24.y;
_local19 = _local24.z;
_local22 = ((((_local17 * _local11) + (_local18 * _local12)) + (_local19 * _local13)) + _local4.n34);
_local25 = _local24.vertex3DInstance;
if (_useProjectionMatrix){
_local23 = ((((_local17 * _local14) + (_local18 * _local15)) + (_local19 * _local16)) + _local4.n44);
_local22 = (_local22 / _local23);
if ((_local25.visible = (((_local22 > 0)) && ((_local22 < 1))))){
_local20 = (((((_local17 * _local5) + (_local18 * _local6)) + (_local19 * _local7)) + _local4.n14) / _local23);
_local21 = (((((_local17 * _local8) + (_local18 * _local9)) + (_local19 * _local10)) + _local4.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)) + _local4.n14);
_local21 = ((((_local17 * _local8) + (_local18 * _local9)) + (_local19 * _local10)) + _local4.n24);
_local26 = (_local29 / (_local28 + _local22));
_local25.x = (_local20 * _local26);
_local25.y = (_local21 * _local26);
_local25.z = _local22;
};
};
};
};
};
return (0);
}
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 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 set far(_arg1:Number):void{
if (_arg1 > this.focus){
_far = _arg1;
this.update(this.viewport);
};
}
override public function projectVertices(_arg1:Array, _arg2:DisplayObject3D, _arg3:RenderSessionData):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 _local4:Matrix3D = _arg2.view;
var _local5:Number = _local4.n11;
var _local6:Number = _local4.n12;
var _local7:Number = _local4.n13;
var _local8:Number = _local4.n21;
var _local9:Number = _local4.n22;
var _local10:Number = _local4.n23;
var _local11:Number = _local4.n31;
var _local12:Number = _local4.n32;
var _local13:Number = _local4.n33;
var _local14:Number = _local4.n41;
var _local15:Number = _local4.n42;
var _local16:Number = _local4.n43;
var _local27:int = _arg1.length;
var _local28:Number = _arg3.camera.focus;
var _local29:Number = (_local28 * _arg3.camera.zoom);
var _local30:Number = (viewport.width / 2);
var _local31:Number = (viewport.height / 2);
var _local32:Number = _arg3.camera.far;
var _local33:Number = (_local32 - _local28);
while ((_local24 = _arg1[--_local27])) {
_local17 = _local24.x;
_local18 = _local24.y;
_local19 = _local24.z;
_local22 = ((((_local17 * _local11) + (_local18 * _local12)) + (_local19 * _local13)) + _local4.n34);
_local25 = _local24.vertex3DInstance;
if (_useProjectionMatrix){
_local23 = ((((_local17 * _local14) + (_local18 * _local15)) + (_local19 * _local16)) + _local4.n44);
_local22 = (_local22 / _local23);
if ((_local25.visible = (((_local22 > 0)) && ((_local22 < 1))))){
_local20 = (((((_local17 * _local5) + (_local18 * _local6)) + (_local19 * _local7)) + _local4.n14) / _local23);
_local21 = (((((_local17 * _local8) + (_local18 * _local9)) + (_local19 * _local10)) + _local4.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)) + _local4.n14);
_local21 = ((((_local17 * _local8) + (_local18 * _local9)) + (_local19 * _local10)) + _local4.n24);
_local26 = (_local29 / (_local28 + _local22));
_local25.x = (_local20 * _local26);
_local25.y = (_local21 * _local26);
_local25.z = _local22;
};
};
};
return (0);
}
public static function createPerspectiveMatrix(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Matrix3D{
var _local5:Number = ((_arg1 / 2) * (Math.PI / 180));
var _local6:Number = Math.tan(_local5);
var _local7:Number = (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 = ((_arg2 + _arg1) / (_arg2 - _arg1));
var _local8:Number = ((_arg4 + _arg3) / (_arg4 - _arg3));
var _local9:Number = ((_arg6 + _arg5) / (_arg6 - _arg5));
var _local10:Matrix3D = 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 189
//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";
public static var SPRING:String = "Spring";
}
}//package org.papervision3d.cameras
Section 190
//DebugCamera3D (org.papervision3d.cameras.DebugCamera3D)
package org.papervision3d.cameras {
import flash.events.*;
import flash.display.*;
import flash.geom.*;
import org.papervision3d.view.*;
import flash.text.*;
import flash.ui.*;
public class DebugCamera3D extends Camera3D {
protected var keyLeft:Boolean;// = false
protected var targetRotationX:Number;// = 0
protected var targetRotationY:Number;// = 0
protected var sideFactor:Number;// = 0
protected var _propertiesDisplay:Sprite;
protected var viewport3D:Viewport3D;
protected var fovText:TextField;
protected var xText:TextField;
protected var yText:TextField;
protected var zText:TextField;
protected var startPoint:Point;
protected var startRotationX:Number;
protected var startRotationY:Number;
protected var keyBackward:Boolean;// = false
protected var farText:TextField;
protected var keyForward:Boolean;// = false
protected var rotationXText:TextField;
protected var rotationZText:TextField;
protected var rotationYText:TextField;
protected var forwardFactor:Number;// = 0
protected var nearText:TextField;
protected var viewportStage:Stage;
protected var _inertia:Number;// = 3
protected var keyRight:Boolean;// = false
public function DebugCamera3D(_arg1:Viewport3D, _arg2:Number=90, _arg3:Number=10, _arg4:Number=5000){
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 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;
};
}
public function set inertia(_arg1:Number):void{
_inertia = _arg1;
}
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);
}
protected function displayProperties():void{
_propertiesDisplay = new Sprite();
_propertiesDisplay.graphics.beginFill(0);
_propertiesDisplay.graphics.drawRect(0, 0, 100, 100);
_propertiesDisplay.graphics.endFill();
_propertiesDisplay.x = 0;
_propertiesDisplay.y = 0;
var _local1:TextFormat = 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();
var _local2:Array = [xText, yText, zText, rotationXText, rotationYText, rotationZText, fovText, nearText, farText];
var _local3 = 10;
var _local4:Number = 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 onEnterFrameHandler(_arg1:Event):void{
if (keyForward){
forwardFactor = (forwardFactor + 50);
};
if (keyBackward){
forwardFactor = (forwardFactor + -50);
};
if (keyLeft){
sideFactor = (sideFactor + -50);
};
if (keyRight){
sideFactor = (sideFactor + 50);
};
var _local2:Number = (this.rotationX + ((targetRotationX - this.rotationX) / _inertia));
var _local3:Number = (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 mouseUpHandler(_arg1:MouseEvent):void{
viewportStage.removeEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
}
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 propsDisplay():Sprite{
return (_propertiesDisplay);
}
public function get inertia():Number{
return (_inertia);
}
protected function onAddedToStageHandler(_arg1:Event):void{
setupEvents();
}
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;
}
public function set propsDisplay(_arg1:Sprite):void{
_propertiesDisplay = _arg1;
}
private function checkStageReady():void{
if (viewport3D.containerSprite.stage == null){
viewport3D.containerSprite.addEventListener(Event.ADDED_TO_STAGE, onAddedToStageHandler);
} else {
setupEvents();
};
}
}
}//package org.papervision3d.cameras
Section 191
//SpringCamera3D (org.papervision3d.cameras.SpringCamera3D)
package org.papervision3d.cameras {
import org.papervision3d.objects.*;
import org.papervision3d.core.math.*;
public class SpringCamera3D extends Camera3D {
public var _camTarget:DisplayObject3D;
private var _velocity:Number3D;
private var _stretch:Number3D;
public var damping:Number;// = 4
public var stiffness:Number;// = 1
public var lookOffset:Number3D;
private var _lookAtPosition:Number3D;
public var positionOffset:Number3D;
private var _acceleration:Number3D;
private var _targetTransform:Matrix3D;
private var _desiredPosition:Number3D;
private var _force:Number3D;
private var _xPosition:Number3D;
private var _dv:Number3D;
private var _xLookOffset:Number3D;
public var mass:Number;// = 40
private var _xPositionOffset:Number3D;
private var _xLookAtObject:DisplayObject3D;
private var _zrot:Number;// = 0
public function SpringCamera3D(_arg1:Number=60, _arg2:Number=10, _arg3:Number=5000, _arg4:Boolean=false, _arg5:Boolean=false){
positionOffset = new Number3D(0, 5, -50);
lookOffset = new Number3D(0, 2, 10);
_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;
};
};
super.transformView(_arg1);
}
override public function get target():DisplayObject3D{
return (_camTarget);
}
public function get zrot():Number{
return (_zrot);
}
override public function set target(_arg1:DisplayObject3D):void{
_camTarget = _arg1;
}
public function set zrot(_arg1:Number):void{
_zrot = _arg1;
if (_zrot < 0.001){
_arg1 = 0;
};
}
}
}//package org.papervision3d.cameras
Section 192
//Clipping (org.papervision3d.core.clipping.draw.Clipping)
package org.papervision3d.core.clipping.draw {
import flash.display.*;
import org.papervision3d.core.render.command.*;
import flash.geom.*;
public class Clipping {
public var minX:Number;// = -1000000
public var minY:Number;// = -1000000
private var zeroPoint:Point;
private var globalPoint:Point;
private var rectangleClipping:RectangleClipping;
public var maxX:Number;// = 1000000
public var maxY:Number;// = 1000000
public function Clipping(){
zeroPoint = new Point(0, 0);
super();
}
public function rect(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Boolean{
return (true);
}
public function screen(_arg1:Sprite):Clipping{
if (!rectangleClipping){
rectangleClipping = new RectangleClipping();
};
switch (_arg1.stage.align){
case StageAlign.TOP_LEFT:
zeroPoint.x = 0;
zeroPoint.y = 0;
globalPoint = _arg1.globalToLocal(zeroPoint);
rectangleClipping.maxX = ((rectangleClipping.minX = globalPoint.x) + _arg1.stage.stageWidth);
rectangleClipping.maxY = ((rectangleClipping.minY = globalPoint.y) + _arg1.stage.stageHeight);
break;
case StageAlign.TOP_RIGHT:
zeroPoint.x = _arg1.stage.stageWidth;
zeroPoint.y = 0;
globalPoint = _arg1.globalToLocal(zeroPoint);
rectangleClipping.minX = ((rectangleClipping.maxX = globalPoint.x) - _arg1.stage.stageWidth);
rectangleClipping.maxY = ((rectangleClipping.minY = globalPoint.y) + _arg1.stage.stageHeight);
break;
case StageAlign.BOTTOM_LEFT:
zeroPoint.x = 0;
zeroPoint.y = _arg1.stage.stageHeight;
globalPoint = _arg1.globalToLocal(zeroPoint);
rectangleClipping.maxX = ((rectangleClipping.minX = globalPoint.x) + _arg1.stage.stageWidth);
rectangleClipping.minY = ((rectangleClipping.maxY = globalPoint.y) - _arg1.stage.stageHeight);
break;
case StageAlign.BOTTOM_RIGHT:
zeroPoint.x = _arg1.stage.stageWidth;
zeroPoint.y = _arg1.stage.stageHeight;
globalPoint = _arg1.globalToLocal(zeroPoint);
rectangleClipping.minX = ((rectangleClipping.maxX = globalPoint.x) - _arg1.stage.stageWidth);
rectangleClipping.minY = ((rectangleClipping.maxY = globalPoint.y) - _arg1.stage.stageHeight);
break;
case StageAlign.TOP:
zeroPoint.x = (_arg1.stage.stageWidth / 2);
zeroPoint.y = 0;
globalPoint = _arg1.globalToLocal(zeroPoint);
rectangleClipping.minX = (globalPoint.x - (_arg1.stage.stageWidth / 2));
rectangleClipping.maxX = (globalPoint.x + (_arg1.stage.stageWidth / 2));
rectangleClipping.maxY = ((rectangleClipping.minY = globalPoint.y) + _arg1.stage.stageHeight);
break;
case StageAlign.BOTTOM:
zeroPoint.x = (_arg1.stage.stageWidth / 2);
zeroPoint.y = _arg1.stage.stageHeight;
globalPoint = _arg1.globalToLocal(zeroPoint);
rectangleClipping.minX = (globalPoint.x - (_arg1.stage.stageWidth / 2));
rectangleClipping.maxX = (globalPoint.x + (_arg1.stage.stageWidth / 2));
rectangleClipping.minY = ((rectangleClipping.maxY = globalPoint.y) - _arg1.stage.stageHeight);
break;
case StageAlign.LEFT:
zeroPoint.x = 0;
zeroPoint.y = (_arg1.stage.stageHeight / 2);
globalPoint = _arg1.globalToLocal(zeroPoint);
rectangleClipping.maxX = ((rectangleClipping.minX = globalPoint.x) + _arg1.stage.stageWidth);
rectangleClipping.minY = (globalPoint.y - (_arg1.stage.stageHeight / 2));
rectangleClipping.maxY = (globalPoint.y + (_arg1.stage.stageHeight / 2));
break;
case StageAlign.RIGHT:
zeroPoint.x = _arg1.stage.stageWidth;
zeroPoint.y = (_arg1.stage.stageHeight / 2);
globalPoint = _arg1.globalToLocal(zeroPoint);
rectangleClipping.minX = ((rectangleClipping.maxX = globalPoint.x) - _arg1.stage.stageWidth);
rectangleClipping.minY = (globalPoint.y - (_arg1.stage.stageHeight / 2));
rectangleClipping.maxY = (globalPoint.y + (_arg1.stage.stageHeight / 2));
break;
default:
zeroPoint.x = (_arg1.stage.stageWidth / 2);
zeroPoint.y = (_arg1.stage.stageHeight / 2);
globalPoint = _arg1.globalToLocal(zeroPoint);
rectangleClipping.minX = (globalPoint.x - (_arg1.stage.stageWidth / 2));
rectangleClipping.maxX = (globalPoint.x + (_arg1.stage.stageWidth / 2));
rectangleClipping.minY = (globalPoint.y - (_arg1.stage.stageHeight / 2));
rectangleClipping.maxY = (globalPoint.y + (_arg1.stage.stageHeight / 2));
};
return (rectangleClipping);
}
public function check(_arg1:RenderableListItem):Boolean{
return (true);
}
public function asRectangleClipping():RectangleClipping{
if (!rectangleClipping){
rectangleClipping = new RectangleClipping();
};
rectangleClipping.minX = -1000000;
rectangleClipping.minY = -1000000;
rectangleClipping.maxX = 1000000;
rectangleClipping.maxY = 1000000;
return (rectangleClipping);
}
}
}//package org.papervision3d.core.clipping.draw
Section 193
//RectangleClipping (org.papervision3d.core.clipping.draw.RectangleClipping)
package org.papervision3d.core.clipping.draw {
import org.papervision3d.core.render.command.*;
public class RectangleClipping extends Clipping {
public function RectangleClipping(_arg1:Number=-1000000, _arg2:Number=-1000000, _arg3:Number=1000000, _arg4:Number=1000000){
this.minX = _arg1;
this.maxX = _arg3;
this.minY = _arg2;
this.maxY = _arg4;
}
override public function check(_arg1:RenderableListItem):Boolean{
if (_arg1.maxX < minX){
return (false);
};
if (_arg1.minX > maxX){
return (false);
};
if (_arg1.maxY < minY){
return (false);
};
if (_arg1.minY > maxY){
return (false);
};
return (true);
}
override public function rect(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Boolean{
if (this.maxX < _arg1){
return (false);
};
if (this.minX > _arg3){
return (false);
};
if (this.maxY < _arg2){
return (false);
};
if (this.minY > _arg4){
return (false);
};
return (true);
}
public function toString():String{
return ((((((((("{minX:" + minX) + " maxX:") + maxX) + " minY:") + minY) + " maxY:") + maxY) + "}"));
}
override public function asRectangleClipping():RectangleClipping{
return (this);
}
}
}//package org.papervision3d.core.clipping.draw
Section 194
//DefaultClipping (org.papervision3d.core.clipping.DefaultClipping)
package org.papervision3d.core.clipping {
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.geom.renderables.*;
public class DefaultClipping {
public function testFace(_arg1:Triangle3D, _arg2:DisplayObject3D, _arg3:RenderSessionData):Boolean{
return (false);
}
public function clipFace(_arg1:Triangle3D, _arg2:DisplayObject3D, _arg3:MaterialObject3D, _arg4:RenderSessionData, _arg5:Array):Number{
return (0);
}
public function setDisplayObject(_arg1:DisplayObject3D, _arg2:RenderSessionData):void{
}
public function reset(_arg1:RenderSessionData):void{
}
}
}//package org.papervision3d.core.clipping
Section 195
//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 196
//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 197
//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 198
//FrustumCuller (org.papervision3d.core.culling.FrustumCuller)
package org.papervision3d.core.culling {
import org.papervision3d.objects.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.math.*;
public class FrustumCuller implements IObjectCuller {
private var _tang:Number;
private var _near:Number;
private var _ratio:Number;
private var _fov:Number;
private var _far:Number;
private var _nh:Number;
private var _fh:Number;
private var _nw:Number;
public var transform:Matrix3D;
private var _sphereY: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 = this.transform;
var _local5:Number = (_arg1 - _local4.n14);
var _local6:Number = (_arg2 - _local4.n24);
var _local7:Number = (_arg3 - _local4.n34);
var _local8:Number = (((_local5 * _local4.n13) + (_local6 * _local4.n23)) + (_local7 * _local4.n33));
if ((((_local8 > _far)) || ((_local8 < _near)))){
return (OUTSIDE);
};
var _local9:Number = (((_local5 * _local4.n12) + (_local6 * _local4.n22)) + (_local7 * _local4.n32));
var _local10:Number = (_local8 * _tang);
if ((((_local9 > _local10)) || ((_local9 < -(_local10))))){
return (OUTSIDE);
};
var _local11:Number = (((_local5 * _local4.n11) + (_local6 * _local4.n21)) + (_local7 * _local4.n31));
_local10 = (_local10 * _ratio);
if ((((_local11 > _local10)) || ((_local11 < -(_local10))))){
return (OUTSIDE);
};
return (INSIDE);
}
public function get fov():Number{
return (_fov);
}
public function set ratio(_arg1:Number):void{
this.initialize(_fov, _arg1, _near, _far);
}
public function set near(_arg1:Number):void{
this.initialize(_fov, _ratio, _arg1, _far);
}
public function set fov(_arg1:Number):void{
this.initialize(_arg1, _ratio, _near, _far);
}
public function get far():Number{
return (_far);
}
public function initialize(_arg1:Number=60, _arg2:Number=1.333, _arg3:Number=1, _arg4:Number=5000):void{
_fov = _arg1;
_ratio = _arg2;
_near = _arg3;
_far = _arg4;
var _local5:Number = (((Math.PI / 180) * _fov) * 0.5);
_tang = Math.tan(_local5);
_nh = (_near * _tang);
_nw = (_nh * _ratio);
_fh = (_far * _tang);
_fw = (_fh * _ratio);
var _local6:Number = Math.atan((_tang * _ratio));
_sphereX = (1 / Math.cos(_local6));
_sphereY = (1 / Math.cos(_local5));
}
public function set far(_arg1:Number):void{
this.initialize(_fov, _ratio, _near, _arg1);
}
public function get near():Number{
return (_near);
}
public function sphereInFrustum(_arg1:DisplayObject3D, _arg2:BoundingSphere):int{
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local3:Number = (_arg2.radius * Math.max(_arg1.scaleX, Math.max(_arg1.scaleY, _arg1.scaleZ)));
var _local8:int = INSIDE;
var _local9:Matrix3D = this.transform;
var _local10:Number = (_arg1.world.n14 - _local9.n14);
var _local11:Number = (_arg1.world.n24 - _local9.n24);
var _local12:Number = (_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 = 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 = _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 199
//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 200
//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 201
//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 202
//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 203
//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 204
//RectangleLineCuller (org.papervision3d.core.culling.RectangleLineCuller)
package org.papervision3d.core.culling {
import flash.geom.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.math.util.*;
public class RectangleLineCuller implements ILineCuller {
private var lineBoundsRect:Rectangle;
private var rectIntersection: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{
if (((!(_arg1.v0.vertex3DInstance.visible)) || (!(_arg1.v1.vertex3DInstance.visible)))){
return (false);
};
var _local2:Number = _arg1.v0.vertex3DInstance.x;
var _local3:Number = _arg1.v0.vertex3DInstance.y;
var _local4:Number = _arg1.v1.vertex3DInstance.x;
var _local5:Number = _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);
var _local6:Number = ((_local5 - _local3) / (_local4 - _local2));
var _local7:Number = (_local3 - (_local6 * _local2));
var _local8:Number = ((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);
};
var _local9:Number = ((_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 205
//RectangleParticleCuller (org.papervision3d.core.culling.RectangleParticleCuller)
package org.papervision3d.core.culling {
import flash.geom.*;
import org.papervision3d.core.geom.renderables.*;
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 206
//RectangleTriangleCuller (org.papervision3d.core.culling.RectangleTriangleCuller)
package org.papervision3d.core.culling {
import flash.geom.*;
import org.papervision3d.core.geom.renderables.*;
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 207
//ViewportObjectFilter (org.papervision3d.core.culling.ViewportObjectFilter)
package org.papervision3d.core.culling {
import flash.utils.*;
import org.papervision3d.objects.*;
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 get mode():int{
return (_mode);
}
public function set mode(_arg1:int):void{
_mode = _arg1;
}
public function removeObject(_arg1:DisplayObject3D):void{
delete objects[_arg1];
}
private function init():void{
objects = new Dictionary(true);
}
public function testObject(_arg1:DisplayObject3D):int{
if (objects[_arg1]){
return ((1 - _mode));
};
return (mode);
}
public function destroy():void{
objects = null;
}
}
}//package org.papervision3d.core.culling
Section 208
//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 209
//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 set userData(_arg1:UserData):void{
_userData = _arg1;
}
public function get userData():UserData{
return (_userData);
}
public function getRenderListItem():IRenderListItem{
return (null);
}
}
}//package org.papervision3d.core.geom.renderables
Section 210
//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 211
//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 material:LineMaterial;
public var cV:Vertex3D;
public var renderCommand:RenderLine;
public var v0:Vertex3D;
public var v1:Vertex3D;
public function Line3D(_arg1:Lines3D, _arg2:LineMaterial, _arg3:Number, _arg4:Vertex3D, _arg5:Vertex3D){
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);
};
renderCommand.cV = cV.vertex3DInstance;
}
override public function getRenderListItem():IRenderListItem{
return (this.renderCommand);
}
}
}//package org.papervision3d.core.geom.renderables
Section 212
//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 rotationZ:Number;// = 0
public var renderCommand:RenderParticle;
public var drawMatrix:Matrix;
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);
drawMatrix = new Matrix();
}
public function updateRenderRect():void{
material.updateRenderRect(this);
}
public function set x(_arg1:Number):void{
vertex3D.x = _arg1;
}
public function set y(_arg1:Number):void{
vertex3D.y = _arg1;
}
public function set z(_arg1:Number):void{
vertex3D.z = _arg1;
}
public function get y():Number{
return (vertex3D.y);
}
public function get z():Number{
return (vertex3D.z);
}
override public function getRenderListItem():IRenderListItem{
return (renderCommand);
}
public function get x():Number{
return (vertex3D.x);
}
}
}//package org.papervision3d.core.geom.renderables
Section 213
//Triangle3D (org.papervision3d.core.geom.renderables.Triangle3D)
package org.papervision3d.core.geom.renderables {
import org.papervision3d.materials.*;
import org.papervision3d.core.render.command.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.math.*;
import org.papervision3d.materials.special.*;
public class Triangle3D extends AbstractRenderable implements IRenderable {
public var _uvArray:Array;
public var renderCommand:RenderTriangle;
public var id:Number;
public var material:MaterialObject3D;
public var faceNormal:Number3D;
public var screenZ:Number;
public var uv0:NumberUV;
public var uv1:NumberUV;
public var _materialName:String;
public var visible:Boolean;
public var uv2:NumberUV;
public var vertices:Array;
public var v0:Vertex3D;
public var v1: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;
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++;
this.renderCommand = new RenderTriangle(this);
}
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 = v0.getPosition();
var _local2:Number3D = v1.getPosition();
var _local3:Number3D = v2.getPosition();
_local2.minusEq(_local1);
_local3.minusEq(_local1);
faceNormal = Number3D.cross(_local2, _local3, faceNormal);
faceNormal.normalize();
}
override public function getRenderListItem():IRenderListItem{
return (renderCommand);
}
public function reset(_arg1:DisplayObject3D, _arg2:Array, _arg3:MaterialObject3D, _arg4:Array):void{
var _local5:MaterialObject3D;
this.instance = _arg1;
this.renderCommand.instance = _arg1;
this.renderCommand.renderer = _arg3;
this.vertices = _arg2;
updateVertices();
this.material = _arg3;
this.uv = _arg4;
if ((_arg3 is BitmapMaterial)){
BitmapMaterial(_arg3).uvMatrices[this.renderCommand] = null;
};
if ((_arg3 is CompositeMaterial)){
for each (_local5 in CompositeMaterial(_arg3).materials) {
if ((_local5 is BitmapMaterial)){
BitmapMaterial(_local5).uvMatrices[this.renderCommand] = null;
};
};
};
}
public function get uv():Array{
return (_uvArray);
}
public function updateVertices():void{
v0 = vertices[0];
v1 = vertices[1];
v2 = vertices[2];
}
}
}//package org.papervision3d.core.geom.renderables
Section 214
//Triangle3DInstance (org.papervision3d.core.geom.renderables.Triangle3DInstance)
package org.papervision3d.core.geom.renderables {
import flash.display.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.math.*;
public class Triangle3DInstance {
public var container:Sprite;
public var instance:DisplayObject3D;
public var visible:Boolean;// = false
public var faceNormal:Number3D;
public var screenZ:Number;
public function Triangle3DInstance(_arg1:Triangle3D, _arg2:DisplayObject3D){
this.instance = _arg2;
faceNormal = new Number3D();
}
}
}//package org.papervision3d.core.geom.renderables
Section 215
//Vertex3D (org.papervision3d.core.geom.renderables.Vertex3D)
package org.papervision3d.core.geom.renderables {
import flash.utils.*;
import org.papervision3d.core.render.command.*;
import org.papervision3d.core.math.*;
public class Vertex3D extends AbstractRenderable implements IRenderable {
public var z:Number;
public var vertex3DInstance:Vertex3DInstance;
public var extra:Object;
public var timestamp:Number;
public var normal:Number3D;
protected var position:Number3D;
public var connectedFaces:Dictionary;
public var x:Number;
public var y:Number;
private var persp:Number;// = 0
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 perspective(_arg1:Number):Vertex3DInstance{
persp = (1 / (1 + (z / _arg1)));
return (new Vertex3DInstance((x * persp), (y * persp), z));
}
public function toNumber3D():Number3D{
return (new Number3D(x, y, z));
}
public function clone():Vertex3D{
var _local1:Vertex3D = 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 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);
}
public static function weighted(_arg1:Vertex3D, _arg2:Vertex3D, _arg3:Number, _arg4:Number):Vertex3D{
var _local5:Number = (_arg3 + _arg4);
var _local6:Number = (_arg3 / _local5);
var _local7:Number = (_arg4 / _local5);
return (new Vertex3D(((_arg1.x * _local6) + (_arg2.x * _local7)), ((_arg1.y * _local6) + (_arg2.y * _local7)), ((_arg1.z * _local6) + (_arg2.z * _local7))));
}
}
}//package org.papervision3d.core.geom.renderables
Section 216
//Vertex3DInstance (org.papervision3d.core.geom.renderables.Vertex3DInstance)
package org.papervision3d.core.geom.renderables {
import org.papervision3d.core.math.*;
public class Vertex3DInstance {
public var y:Number;
private var persp:Number;// = 0
public var normal:Number3D;
public var visible:Boolean;
public var extra:Object;
public var x: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 deperspective(_arg1:Number):Vertex3D{
persp = (1 + (z / _arg1));
return (new Vertex3D((x * persp), (y * persp), z));
}
public function distance(_arg1:Vertex3DInstance):Number{
return (Math.sqrt((((x - _arg1.x) * (x - _arg1.x)) + ((y - _arg1.y) * (y - _arg1.y)))));
}
public function clone():Vertex3DInstance{
var _local1:Vertex3DInstance = new Vertex3DInstance(x, y, z);
_local1.visible = visible;
_local1.extra = extra;
return (_local1);
}
public function distanceSqr(_arg1:Vertex3DInstance):Number{
return ((((x - _arg1.x) * (x - _arg1.x)) + ((y - _arg1.y) * (y - _arg1.y))));
}
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 median(_arg1:Vertex3DInstance, _arg2:Vertex3DInstance, _arg3:Number):Vertex3DInstance{
var _local4:Number = ((_arg1.z + _arg2.z) / 2);
var _local5:Number = (_arg3 + _arg1.z);
var _local6:Number = (_arg3 + _arg2.z);
var _local7:Number = ((1 / (_arg3 + _local4)) / 2);
return (new Vertex3DInstance((((_arg1.x * _local5) + (_arg2.x * _local6)) * _local7), (((_arg1.y * _local5) + (_arg2.y * _local6)) * _local7), _local4));
}
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 217
//Lines3D (org.papervision3d.core.geom.Lines3D)
package org.papervision3d.core.geom {
import org.papervision3d.core.render.command.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.log.*;
import org.papervision3d.materials.special.*;
import org.papervision3d.core.render.draw.*;
public class Lines3D extends Vertices3D {
private var _material:ILineDrawer;
public var lines:Array;
public function Lines3D(_arg1:LineMaterial=null, _arg2:String=null){
super(null, _arg2);
if (!_arg1){
this.material = new LineMaterial();
} else {
this.material = _arg1;
};
init();
}
private function init():void{
this.lines = new Array();
}
public function removeAllLines():void{
while (lines.length > 0) {
removeLine(lines[0]);
};
}
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):Array{
var _local13:Line3D;
var _local15:Vertex3D;
var _local9:Number = ((_arg6 - _arg3) / _arg2);
var _local10:Number = ((_arg7 - _arg4) / _arg2);
var _local11:Number = ((_arg8 - _arg5) / _arg2);
var _local12:Array = new Array();
var _local14:Vertex3D = new Vertex3D(_arg3, _arg4, _arg5);
var _local16:Number = 0;
while (_local16 <= _arg2) {
_local15 = new Vertex3D((_arg3 + (_local9 * _local16)), (_arg4 + (_local10 * _local16)), (_arg5 + (_local11 * _local16)));
_local13 = new Line3D(this, (material as LineMaterial), _arg1, _local14, _local15);
addLine(_local13);
_local12.push(_local13);
_local14 = _local15;
_local16++;
};
return (_local12);
}
public function removeLine(_arg1:Line3D):void{
var _local2:int = lines.indexOf(_arg1);
if (_local2 > -1){
lines.splice(_local2, 1);
} else {
PaperLogger.warning("Papervision3D Lines3D.removeLine : WARNING removal of non-existant line attempted. ");
};
}
override public function project(_arg1:DisplayObject3D, _arg2:RenderSessionData):Number{
var _local3:Line3D;
var _local4:Number;
var _local5:RenderLine;
super.project(_arg1, _arg2);
for each (_local3 in lines) {
if (_arg2.viewPort.lineCuller.testLine(_local3)){
_local5 = _local3.renderCommand;
_local5.renderer = _local3.material;
_local5.size = _local3.size;
_local4 = (_local4 + (_local5.screenZ = ((_local3.v0.vertex3DInstance.z + _local3.v1.vertex3DInstance.z) / 2)));
_local5.v0 = _local3.v0.vertex3DInstance;
_local5.v1 = _local3.v1.vertex3DInstance;
_arg2.renderer.addToRenderList(_local5);
};
};
return ((_local4 / (lines.length + 1)));
}
public function addNewLine(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:Number, _arg7:Number):Line3D{
var _local8:Line3D = 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 218
//TriangleMesh3D (org.papervision3d.core.geom.TriangleMesh3D)
package org.papervision3d.core.geom {
import flash.utils.*;
import org.papervision3d.core.render.command.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.math.*;
import org.papervision3d.core.culling.*;
import org.papervision3d.core.render.draw.*;
public class TriangleMesh3D extends Vertices3D {
private var _tri:RenderTriangle;
private var _dtStore:Array;
private var _dtActive:Array;
public function TriangleMesh3D(_arg1:MaterialObject3D, _arg2:Array, _arg3:Array, _arg4:String=null){
_dtStore = new Array();
_dtActive = new Array();
super(_arg2, _arg4);
this.geometry.faces = ((_arg3) || (new Array()));
this.material = ((_arg1) || (MaterialObject3D.DEFAULT));
}
public function projectTexture(_arg1:String="x", _arg2:String="y"):void{
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;
var _local3:Array = this.geometry.faces;
var _local4:Object = this.boundingBox();
var _local5:Number = _local4.min[_arg1];
var _local6:Number = _local4.size[_arg1];
var _local7:Number = _local4.min[_arg2];
var _local8:Number = _local4.size[_arg2];
var _local9:MaterialObject3D = 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];
};
}
public function quarterFaces():void{
var _local4:Triangle3D;
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;
var _local1:Array = new Array();
var _local2:Array = new Array();
var _local3:Array = this.geometry.faces;
var _local5:int = _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;
}
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 mergeVertices():void{
var _local3:Vertex3D;
var _local4:Triangle3D;
var _local5:Vertex3D;
var _local1:Dictionary = new Dictionary();
var _local2:Array = 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 = (_local4.vertices[0] = _local1[_local4.v0]);
_local4.v1 = (_local4.vertices[1] = _local1[_local4.v1]);
_local4.v2 = (_local4.vertices[2] = _local1[_local4.v2]);
};
}
override public function project(_arg1:DisplayObject3D, _arg2:RenderSessionData):Number{
var _local5:Triangle3D;
var _local6:Array;
var _local7:Number;
var _local8:Number;
var _local9:ITriangleCuller;
var _local10:Vertex3DInstance;
var _local11:Vertex3DInstance;
var _local12:Vertex3DInstance;
var _local13:Triangle3DInstance;
var _local14:Triangle3D;
var _local15:MaterialObject3D;
var _local16:RenderTriangle;
_dtStore = [];
_dtActive = new Array();
var _local3:int = this.geometry.vertices.length;
var _local4:Array = [];
if (((((((_arg2.clipping) && (this.useClipping))) && (!(this.culled)))) && ((_arg2.camera.useCulling) ? (cullTest == 0) : true))){
super.projectEmpty(_arg1, _arg2);
_arg2.clipping.setDisplayObject(this, _arg2);
for each (_local5 in this.geometry.faces) {
if (_arg2.clipping.testFace(_local5, this, _arg2)){
_arg2.clipping.clipFace(_local5, this, _local15, _arg2, _local4);
} else {
_local4.push(_local5);
};
};
super.project(_arg1, _arg2);
_arg2.camera.projectFaces(_local4, this, _arg2);
} else {
super.project(_arg1, _arg2);
_local4 = this.geometry.faces;
};
if (!this.culled){
_local6 = this.geometry.faces;
_local7 = 0;
_local8 = 0;
_local9 = _arg2.triangleCuller;
for each (_local14 in _local4) {
_local15 = (_local14.material) ? _local14.material : material;
_local10 = _local14.v0.vertex3DInstance;
_local11 = _local14.v1.vertex3DInstance;
_local12 = _local14.v2.vertex3DInstance;
if (_local9.testFace(_local14, _local10, _local11, _local12)){
_local16 = _local14.renderCommand;
_local7 = (_local7 + (_local16.screenZ = setScreenZ(meshSort, _local10, _local11, _local12)));
_local8++;
_local16.renderer = (_local15 as ITriangleDrawer);
_local16.v0 = _local10;
_local16.v1 = _local11;
_local16.v2 = _local12;
_local16.uv0 = _local14.uv0;
_local16.uv1 = _local14.uv1;
_local16.uv2 = _local14.uv2;
if (_arg2.quadrantTree){
if (_local16.create == null){
_local16.create = createRenderTriangle;
};
_local16.update();
if ((((_local16.area < 0)) && (((_local14.material.doubleSided) || (((_local14.material.oneSide) && (_local14.material.opposite))))))){
_local16.area = -(_local16.area);
};
};
_arg2.renderer.addToRenderList(_local16);
} else {
_arg2.renderStatistics.culledTriangles++;
};
};
if (_local3){
while (this.geometry.vertices.length > _local3) {
this.geometry.vertices.pop();
};
};
return ((this.screenZ = (_local7 / _local8)));
//unresolved jump
};
_arg2.renderStatistics.culledObjects++;
return (0);
}
public function createRenderTriangle(_arg1:Triangle3D, _arg2:MaterialObject3D, _arg3:Vertex3DInstance, _arg4:Vertex3DInstance, _arg5:Vertex3DInstance, _arg6:NumberUV, _arg7:NumberUV, _arg8:NumberUV):RenderTriangle{
if (_dtStore.length){
_dtActive.push((_tri = _dtStore.pop()));
} else {
_dtActive.push((_tri = new RenderTriangle(_arg1)));
};
_tri.instance = this;
_tri.triangle = _arg1;
_tri.renderableInstance = _arg1;
_tri.renderer = _arg2;
_tri.create = createRenderTriangle;
_tri.v0 = _arg3;
_tri.v1 = _arg4;
_tri.v2 = _arg5;
_tri.uv0 = _arg6;
_tri.uv1 = _arg7;
_tri.uv2 = _arg8;
_tri.update();
return (_tri);
}
protected function setScreenZ(_arg1:uint, _arg2:Vertex3DInstance, _arg3:Vertex3DInstance, _arg4:Vertex3DInstance):Number{
switch (_arg1){
case DisplayObject3D.MESH_SORT_CENTER:
return ((((_arg2.z + _arg3.z) + _arg4.z) / 3));
case DisplayObject3D.MESH_SORT_FAR:
return (Math.max(_arg2.z, _arg3.z, _arg4.z));
case DisplayObject3D.MESH_SORT_CLOSE:
return (Math.min(_arg2.z, _arg3.z, _arg4.z));
};
return (0);
}
override public function clone():DisplayObject3D{
var _local1:DisplayObject3D = super.clone();
var _local2:TriangleMesh3D = 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);
}
}
}//package org.papervision3d.core.geom
Section 219
//Vertices3D (org.papervision3d.core.geom.Vertices3D)
package org.papervision3d.core.geom {
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.math.*;
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()));
}
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));
};
if (((!(this.geometry)) || (!(this.geometry.vertices)))){
return (0);
};
return (_arg2.camera.projectVertices(this.geometry.vertices, this, _arg2));
}
public function projectEmpty(_arg1:DisplayObject3D, _arg2:RenderSessionData):Number{
return (super.project(_arg1, _arg2));
}
public function worldBoundingBox():Object{
var _local3:Number3D;
var _local4:Vertex3D;
var _local1:Array = this.geometry.vertices;
var _local2:Object = 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 (_local4 in _local1) {
_local3 = _local4.getPosition();
Matrix3D.multiplyVector(this.world, _local3);
_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);
}
public function boundingBox():Object{
var _local3:Vertex3D;
var _local1:Array = this.geometry.vertices;
var _local2:Object = 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);
}
public function projectFrustum(_arg1:DisplayObject3D, _arg2:RenderSessionData):Number{
return (0);
}
public function transformVertices(_arg1:Matrix3D):void{
geometry.transformVertices(_arg1);
}
override public function clone():DisplayObject3D{
var _local1:DisplayObject3D = super.clone();
var _local2:Vertices3D = 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);
}
}
}//package org.papervision3d.core.geom
Section 220
//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 221
//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 warning(_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 = _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 info(_arg1:String, _arg2:Object=null, _arg3:Array=null):void{
}
}
}//package org.papervision3d.core.log
Section 222
//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 223
//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 224
//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 _debug(_arg1:String, _arg2:Object=null, ... _args):void{
var _local4:PaperLogVO = new PaperLogVO(LogLevel.DEBUG, _arg1, _arg2, _args);
var _local5:PaperLoggerEvent = new PaperLoggerEvent(_local4);
dispatchEvent(_local5);
}
public function _log(_arg1:String, _arg2:Object=null, ... _args):void{
var _local4:PaperLogVO = new PaperLogVO(LogLevel.LOG, _arg1, _arg2, _args);
var _local5:PaperLoggerEvent = new PaperLoggerEvent(_local4);
dispatchEvent(_local5);
}
public function _error(_arg1:String, _arg2:Object=null, ... _args):void{
var _local4:PaperLogVO = new PaperLogVO(LogLevel.ERROR, _arg1, _arg2, _args);
var _local5:PaperLoggerEvent = new PaperLoggerEvent(_local4);
dispatchEvent(_local5);
}
public function unregisterLogger(_arg1:AbstractPaperLogger):void{
_arg1.unregisterFromPaperLogger(this);
}
public function _info(_arg1:String, _arg2:Object=null, ... _args):void{
var _local4:PaperLogVO = new PaperLogVO(LogLevel.INFO, _arg1, _arg2, _args);
var _local5:PaperLoggerEvent = new PaperLoggerEvent(_local4);
dispatchEvent(_local5);
}
public function _warning(_arg1:String, _arg2:Object=null, ... _args):void{
var _local4:PaperLogVO = new PaperLogVO(LogLevel.WARNING, _arg1, _arg2, _args);
var _local5:PaperLoggerEvent = 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 225
//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 226
//PaperTraceLogger (org.papervision3d.core.log.PaperTraceLogger)
package org.papervision3d.core.log {
public class PaperTraceLogger extends AbstractPaperLogger implements IPaperLogger {
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 error(_arg1:String, _arg2:Object=null, _arg3:Array=null):void{
trace("ERROR:", _arg1, _arg3);
}
override public function fatal(_arg1:String, _arg2:Object=null, _arg3:Array=null):void{
trace("FATAL:", _arg1, _arg3);
}
override public function info(_arg1:String, _arg2:Object=null, _arg3:Array=null):void{
trace("INFO:", _arg1, _arg3);
}
override public function debug(_arg1:String, _arg2:Object=null, _arg3:Array=null):void{
trace("DEBUG:", _arg1, _arg3);
}
}
}//package org.papervision3d.core.log
Section 227
//AbstractLightShadeMaterial (org.papervision3d.core.material.AbstractLightShadeMaterial)
package org.papervision3d.core.material {
import flash.utils.*;
import org.papervision3d.materials.utils.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.math.*;
import org.papervision3d.core.render.material.*;
import org.papervision3d.core.render.draw.*;
public class AbstractLightShadeMaterial extends TriangleMaterial implements ITriangleDrawer, IUpdateBeforeMaterial {
public var lightMatrices:Dictionary;
private var _light:LightObject3D;
protected static var lightMatrix:Matrix3D;
public function AbstractLightShadeMaterial(){
init();
}
public function updateBeforeRender(_arg1:RenderSessionData):void{
var _local2:Object;
var _local3:DisplayObject3D;
for (_local2 in objects) {
_local3 = (_local2 as DisplayObject3D);
lightMatrices[_local2] = LightMatrix.getLightMatrix(light, _local3, _arg1, lightMatrices[_local2]);
};
}
protected function init():void{
lightMatrices = new Dictionary();
}
public function get light():LightObject3D{
return (_light);
}
public function set light(_arg1:LightObject3D):void{
_light = _arg1;
}
}
}//package org.papervision3d.core.material
Section 228
//TriangleMaterial (org.papervision3d.core.material.TriangleMaterial)
package org.papervision3d.core.material {
import flash.display.*;
import org.papervision3d.core.render.command.*;
import org.papervision3d.core.render.data.*;
import flash.geom.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.core.render.draw.*;
public class TriangleMaterial extends MaterialObject3D implements ITriangleDrawer {
override public function drawTriangle(_arg1:RenderTriangle, _arg2:Graphics, _arg3:RenderSessionData, _arg4:BitmapData=null, _arg5:Matrix=null):void{
}
override public function drawRT(_arg1:RenderTriangle, _arg2:Graphics, _arg3:RenderSessionData):void{
}
}
}//package org.papervision3d.core.material
Section 229
//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 230
//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;
public var maxZ:Number;
protected var _vertices:Array;
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 _local8:Vertex3D;
var _local2:Number = Number.MAX_VALUE;
var _local3:Number = Number.MAX_VALUE;
var _local4:Number = Number.MAX_VALUE;
var _local5:Number = -(_local2);
var _local6:Number = -(_local3);
var _local7:Number = -(_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 231
//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 _local3:Number;
var _local4:Vertex3D;
var _local2:Number = 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 232
//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 n34:Number;
public var n13:Number;
public var n14:Number;
public var n33:Number;
public var n12:Number;
public var n41:Number;
public var n42:Number;
public var n21:Number;
public var n22:Number;
public var n23:Number;
public var n24:Number;
public var n44:Number;
public var n43: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 = (180 / Math.PI);
private static var toRADIANS:Number = (Math.PI / 180);
public function Matrix3D(_arg1:Array=null){
reset(_arg1);
}
public function calculateMultiply3x3(_arg1:Matrix3D, _arg2:Matrix3D):void{
var _local3:Number = _arg1.n11;
var _local4:Number = _arg2.n11;
var _local5:Number = _arg1.n21;
var _local6:Number = _arg2.n21;
var _local7:Number = _arg1.n31;
var _local8:Number = _arg2.n31;
var _local9:Number = _arg1.n12;
var _local10:Number = _arg2.n12;
var _local11:Number = _arg1.n22;
var _local12:Number = _arg2.n22;
var _local13:Number = _arg1.n32;
var _local14:Number = _arg2.n32;
var _local15:Number = _arg1.n13;
var _local16:Number = _arg2.n13;
var _local17:Number = _arg1.n23;
var _local18:Number = _arg2.n23;
var _local19:Number = _arg1.n33;
var _local20:Number = _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 = _arg1.n11;
var _local4:Number = _arg2.n11;
var _local5:Number = _arg1.n21;
var _local6:Number = _arg2.n21;
var _local7:Number = _arg1.n31;
var _local8:Number = _arg2.n31;
var _local9:Number = _arg1.n41;
var _local10:Number = _arg2.n41;
var _local11:Number = _arg1.n12;
var _local12:Number = _arg2.n12;
var _local13:Number = _arg1.n22;
var _local14:Number = _arg2.n22;
var _local15:Number = _arg1.n32;
var _local16:Number = _arg2.n32;
var _local17:Number = _arg1.n42;
var _local18:Number = _arg2.n42;
var _local19:Number = _arg1.n13;
var _local20:Number = _arg2.n13;
var _local21:Number = _arg1.n23;
var _local22:Number = _arg2.n23;
var _local23:Number = _arg1.n33;
var _local24:Number = _arg2.n33;
var _local25:Number = _arg1.n43;
var _local26:Number = _arg2.n43;
var _local27:Number = _arg1.n14;
var _local28:Number = _arg2.n14;
var _local29:Number = _arg1.n24;
var _local30:Number = _arg2.n24;
var _local31:Number = _arg1.n34;
var _local32:Number = _arg2.n34;
var _local33:Number = _arg1.n44;
var _local34:Number = _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 calculateSkewSymmetric(_arg1:Number3D):void{
this.n11 = 0;
this.n12 = -(_arg1.z);
this.n13 = _arg1.y;
this.n21 = _arg1.z;
this.n22 = 0;
this.n23 = -(_arg1.x);
this.n31 = -(_arg1.y);
this.n32 = _arg1.x;
this.n33 = 0;
}
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 = _arg1.n11;
var _local4:Number = _arg2.n11;
var _local5:Number = _arg1.n21;
var _local6:Number = _arg2.n21;
var _local7:Number = _arg1.n31;
var _local8:Number = _arg2.n31;
var _local9:Number = _arg1.n12;
var _local10:Number = _arg2.n12;
var _local11:Number = _arg1.n22;
var _local12:Number = _arg2.n22;
var _local13:Number = _arg1.n32;
var _local14:Number = _arg2.n32;
var _local15:Number = _arg1.n13;
var _local16:Number = _arg2.n13;
var _local17:Number = _arg1.n23;
var _local18:Number = _arg2.n23;
var _local19:Number = _arg1.n33;
var _local20:Number = _arg2.n33;
var _local21:Number = _arg1.n14;
var _local22:Number = _arg2.n14;
var _local23:Number = _arg1.n24;
var _local24:Number = _arg2.n24;
var _local25:Number = _arg1.n34;
var _local26:Number = _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 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 function invert():void{
temp.copy(this);
calculateInverse(temp);
}
public function calculateInverse(_arg1: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 _local2:Number = _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 = this.n11;
var _local2:Number = this.n21;
var _local3:Number = this.n31;
var _local4:Number = this.n41;
var _local5:Number = this.n12;
var _local6:Number = this.n22;
var _local7:Number = this.n32;
var _local8:Number = this.n42;
var _local9:Number = this.n13;
var _local10:Number = this.n23;
var _local11:Number = this.n33;
var _local12:Number = this.n43;
var _local13:Number = this.n14;
var _local14:Number = this.n24;
var _local15:Number = this.n34;
var _local16:Number = 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 = "";
_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 static function rotationMatrixWithReference(_arg1:Number3D, _arg2:Number, _arg3:Number3D):Matrix3D{
var _local4:Matrix3D = 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 _local4:Number;
var _local5:Number;
var _local3:Number = _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 _local6:Number;
_local3 = _arg2.x;
_local4 = _arg2.y;
var _local5:Number = _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 = new (Matrix3D);
_local3.calculateMultiply3x3(_arg1, _arg2);
return (_local3);
}
public static function normalizeQuaternion(_arg1:Object):Object{
var _local2:Number = 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 = _arg2.x;
var _local4:Number = _arg2.y;
var _local5:Number = _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 = Math.sin((_arg4 / 2));
var _local6:Number = Math.cos((_arg4 / 2));
var _local7:Object = 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 = 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 = IDENTITY;
var _local3:Number = Math.cos(_arg1);
var _local4:Number = 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 = IDENTITY;
var _local3:Number = Math.cos(_arg1);
var _local4:Number = 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 = IDENTITY;
var _local3:Number = Math.cos(_arg1);
var _local4:Number = 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;
if (!_arg5){
_local6 = IDENTITY;
} else {
_local6 = _arg5;
};
var _local7:Number = Math.cos(_arg4);
var _local8:Number = Math.sin(_arg4);
var _local9:Number = (1 - _local7);
var _local10:Number = ((_arg1 * _arg2) * _local9);
var _local11:Number = ((_arg2 * _arg3) * _local9);
var _local12:Number = ((_arg1 * _arg3) * _local9);
var _local13:Number = (_local8 * _arg3);
var _local14:Number = (_local8 * _arg2);
var _local15:Number = (_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 = new (Matrix3D);
_local3.calculateAdd(_arg1, _arg2);
return (_local3);
}
public static function multiply(_arg1:Matrix3D, _arg2:Matrix3D):Matrix3D{
var _local3:Matrix3D = new (Matrix3D);
_local3.calculateMultiply(_arg1, _arg2);
return (_local3);
}
public static function euler2quaternion(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Quaternion=null):Quaternion{
var _local13:Quaternion;
var _local5:Number = Math.sin((_arg1 * 0.5));
var _local6:Number = Math.cos((_arg1 * 0.5));
var _local7:Number = Math.sin((_arg2 * 0.5));
var _local8:Number = Math.cos((_arg2 * 0.5));
var _local9:Number = Math.sin((_arg3 * 0.5));
var _local10:Number = Math.cos((_arg3 * 0.5));
var _local11:Number = (_local6 * _local8);
var _local12:Number = (_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 _local15:Matrix3D;
var _local6:Number = (_arg1 * _arg1);
var _local7:Number = (_arg1 * _arg2);
var _local8:Number = (_arg1 * _arg3);
var _local9:Number = (_arg1 * _arg4);
var _local10:Number = (_arg2 * _arg2);
var _local11:Number = (_arg2 * _arg3);
var _local12:Number = (_arg2 * _arg4);
var _local13:Number = (_arg3 * _arg3);
var _local14:Number = (_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 = new (Matrix3D);
_local2.calculateInverse(_arg1);
return (_local2);
}
public static function euler2matrix(_arg1:Number3D):Matrix3D{
temp.reset();
var _local2:Matrix3D = temp;
_local2 = temp;
var _local3:Number = (_arg1.x * toRADIANS);
var _local4:Number = (_arg1.y * toRADIANS);
var _local5:Number = (_arg1.z * toRADIANS);
var _local6:Number = Math.cos(_local3);
var _local7:Number = Math.sin(_local3);
var _local8:Number = Math.cos(_local4);
var _local9:Number = Math.sin(_local4);
var _local10:Number = Math.cos(_local5);
var _local11:Number = Math.sin(_local5);
var _local12:Number = (_local6 * _local9);
var _local13:Number = (_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 = IDENTITY;
_local4.n11 = _arg1;
_local4.n22 = _arg2;
_local4.n33 = _arg3;
return (_local4);
}
public static function rotateAxis(_arg1:Matrix3D, _arg2:Number3D):void{
var _local3:Number = _arg2.x;
var _local4:Number = _arg2.y;
var _local5:Number = _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{
_arg2 = ((_arg2) || (new Number3D()));
var _local4:Number = (((_arg3) && ((_arg3.x == 1)))) ? 1 : Math.sqrt((((_arg1.n11 * _arg1.n11) + (_arg1.n21 * _arg1.n21)) + (_arg1.n31 * _arg1.n31)));
var _local5:Number = (((_arg3) && ((_arg3.y == 1)))) ? 1 : Math.sqrt((((_arg1.n12 * _arg1.n12) + (_arg1.n22 * _arg1.n22)) + (_arg1.n32 * _arg1.n32)));
var _local6:Number = (((_arg3) && ((_arg3.z == 1)))) ? 1 : Math.sqrt((((_arg1.n13 * _arg1.n13) + (_arg1.n23 * _arg1.n23)) + (_arg1.n33 * _arg1.n33)));
var _local7:Number = (_arg1.n11 / _local4);
var _local8:Number = (_arg1.n21 / _local5);
var _local9:Number = (_arg1.n31 / _local6);
var _local10:Number = (_arg1.n32 / _local6);
var _local11:Number = (_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 = _arg1.x;
var _local4:Number = _arg1.y;
var _local5:Number = _arg1.z;
var _local6:Number = _arg1.w;
var _local7:Number = _arg2.x;
var _local8:Number = _arg2.y;
var _local9:Number = _arg2.z;
var _local10:Number = _arg2.w;
var _local11:Object = 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 233
//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 = (Math.PI / 180);
public static const RADTODEG:Number = (180 / Math.PI);
public function Number2D(_arg1:Number=0, _arg2:Number=0){
this.x = _arg1;
this.y = _arg2;
}
public function isModuloLessThan(_arg1:Number):Boolean{
return ((moduloSquared < (_arg1 * _arg1)));
}
public function reverse():void{
this.x = -(this.x);
this.y = -(this.y);
}
public function divideEq(_arg1:Number):void{
x = (x / _arg1);
y = (y / _arg1);
}
public function plusEq(_arg1:Number2D):void{
x = (x + _arg1.x);
y = (y + _arg1.y);
}
public function multiplyEq(_arg1:Number):void{
x = (x * _arg1);
y = (y * _arg1);
}
public function isModuloGreaterThan(_arg1:Number):Boolean{
return ((moduloSquared > (_arg1 * _arg1)));
}
public function toString():String{
var _local1:Number = (Math.round((this.x * 1000)) / 1000);
var _local2:Number = (Math.round((this.y * 1000)) / 1000);
return ((((("[" + _local1) + ", ") + _local2) + "]"));
}
public function reset(_arg1:Number=0, _arg2:Number=0):void{
this.x = _arg1;
this.y = _arg2;
}
public function get moduloSquared():Number{
return (((this.x * this.x) + (this.y * this.y)));
}
public function normalise():void{
var _local1:Number = 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 copyTo(_arg1:Number2D):void{
_arg1.x = this.x;
_arg1.y = this.y;
}
public function angle():Number{
if (Papervision3D.useDEGREES){
return ((RADTODEG * Math.atan2(y, x)));
};
return (Math.atan2(y, x));
}
public function rotate(_arg1:Number):void{
var _local4:Number2D;
if (Papervision3D.useDEGREES){
_arg1 = (_arg1 * DEGTORAD);
};
var _local2:Number = Math.cos(_arg1);
var _local3:Number = Math.sin(_arg1);
_local4 = clone();
this.x = ((_local4.x * _local2) - (_local4.y * _local3));
this.y = ((_local4.x * _local3) + (_local4.y * _local2));
}
public function minusEq(_arg1:Number2D):void{
x = (x - _arg1.x);
y = (y - _arg1.y);
}
public function clone():Number2D{
return (new Number2D(this.x, this.y));
}
public function isModuloEqualTo(_arg1:Number):Boolean{
return ((moduloSquared == (_arg1 * _arg1)));
}
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 234
//Number3D (org.papervision3d.core.math.Number3D)
package org.papervision3d.core.math {
import org.papervision3d.*;
public class Number3D {
public var x:Number;
public var y:Number;
public var z: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 isModuloLessThan(_arg1:Number):Boolean{
return ((moduloSquared < (_arg1 * _arg1)));
}
public function rotateX(_arg1:Number):void{
if (Papervision3D.useDEGREES){
_arg1 = (_arg1 * toRADIANS);
};
var _local2:Number = Math.cos(_arg1);
var _local3:Number = 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{
if (Papervision3D.useDEGREES){
_arg1 = (_arg1 * toRADIANS);
};
var _local2:Number = Math.cos(_arg1);
var _local3:Number = Math.sin(_arg1);
temp.copyFrom(this);
this.x = ((temp.x * _local2) + (temp.z * _local3));
this.z = ((temp.x * -(_local3)) + (temp.z * _local2));
}
public function plusEq(_arg1:Number3D):void{
x = (x + _arg1.x);
y = (y + _arg1.y);
z = (z + _arg1.z);
}
public function multiplyEq(_arg1:Number):void{
x = (x * _arg1);
y = (y * _arg1);
z = (z * _arg1);
}
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 normalize():void{
var _local1:Number = Math.sqrt((((this.x * this.x) + (this.y * this.y)) + (this.z * this.z)));
if (((!((_local1 == 0))) && (!((_local1 == 1))))){
_local1 = (1 / _local1);
this.x = (this.x * _local1);
this.y = (this.y * _local1);
this.z = (this.z * _local1);
};
}
public function rotateZ(_arg1:Number):void{
if (Papervision3D.useDEGREES){
_arg1 = (_arg1 * toRADIANS);
};
var _local2:Number = Math.cos(_arg1);
var _local3:Number = Math.sin(_arg1);
temp.copyFrom(this);
this.x = ((temp.x * _local2) - (temp.y * _local3));
this.y = ((temp.x * _local3) + (temp.y * _local2));
}
public function reset(_arg1:Number=0, _arg2:Number=0, _arg3:Number=0):void{
x = _arg1;
y = _arg2;
z = _arg3;
}
public function get moduloSquared():Number{
return ((((this.x * this.x) + (this.y * this.y)) + (this.z * this.z)));
}
public function get modulo():Number{
return (Math.sqrt((((this.x * this.x) + (this.y * this.y)) + (this.z * this.z))));
}
public function copyTo(_arg1:Number3D):void{
_arg1.x = x;
_arg1.y = y;
_arg1.z = z;
}
public function isModuloGreaterThan(_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 clone():Number3D{
return (new Number3D(this.x, this.y, this.z));
}
public function isModuloEqualTo(_arg1:Number):Boolean{
return ((moduloSquared == (_arg1 * _arg1)));
}
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 235
//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));
}
public static function median(_arg1:NumberUV, _arg2:NumberUV):NumberUV{
if (_arg1 == null){
return (null);
};
if (_arg2 == null){
return (null);
};
return (new NumberUV(((_arg1.u + _arg2.u) / 2), ((_arg1.v + _arg2.v) / 2)));
}
public static function weighted(_arg1:NumberUV, _arg2:NumberUV, _arg3:Number, _arg4:Number):NumberUV{
if (_arg1 == null){
return (null);
};
if (_arg2 == null){
return (null);
};
var _local5:Number = (_arg3 + _arg4);
var _local6:Number = (_arg3 / _local5);
var _local7:Number = (_arg4 / _local5);
return (new NumberUV(((_arg1.u * _local6) + (_arg2.u * _local7)), ((_arg1.v * _local6) + (_arg2.v * _local7))));
}
}
}//package org.papervision3d.core.math
Section 236
//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 = (Math.PI / 180);
public static const RADTODEG:Number = (180 / Math.PI);
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 get matrix():Matrix3D{
var _local1:Number = (x * x);
var _local2:Number = (x * y);
var _local3:Number = (x * z);
var _local4:Number = (x * w);
var _local5:Number = (y * y);
var _local6:Number = (y * z);
var _local7:Number = (y * w);
var _local8:Number = (z * z);
var _local9:Number = (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 setFromEuler(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Boolean=false):void{
if (_arg4){
_arg1 = (_arg1 * DEGTORAD);
_arg2 = (_arg2 * DEGTORAD);
_arg3 = (_arg3 * DEGTORAD);
};
var _local5:Number = Math.sin((_arg1 * 0.5));
var _local6:Number = Math.cos((_arg1 * 0.5));
var _local7:Number = Math.sin((_arg2 * 0.5));
var _local8:Number = Math.cos((_arg2 * 0.5));
var _local9:Number = Math.sin((_arg3 * 0.5));
var _local10:Number = Math.cos((_arg3 * 0.5));
var _local11:Number = (_local6 * _local8);
var _local12:Number = (_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 = Math.sin((_arg4 / 2));
var _local6:Number = Math.cos((_arg4 / 2));
this.x = (_arg1 * _local5);
this.y = (_arg2 * _local5);
this.z = (_arg3 * _local5);
this.w = _local6;
this.normalize();
}
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 _local2:Number;
var _local1:Number = 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 toEuler():Number3D{
var _local1:Number3D = new Number3D();
var _local2:Quaternion = this;
var _local3:Number = ((_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);
};
var _local4:Number = (_local2.x * _local2.x);
var _local5:Number = (_local2.y * _local2.y);
var _local6:Number = (_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 get modulo():Number{
return (Math.sqrt(((((x * x) + (y * y)) + (z * z)) + (w * w))));
}
public function clone():Quaternion{
return (new Quaternion(this.x, this.y, this.z, this.w));
}
public function mult(_arg1:Quaternion):void{
var _local2:Number = this.w;
var _local3:Number = this.x;
var _local4:Number = this.y;
var _local5:Number = 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{
if (_arg4){
_arg1 = (_arg1 * DEGTORAD);
_arg2 = (_arg2 * DEGTORAD);
_arg3 = (_arg3 * DEGTORAD);
};
var _local5:Number = Math.sin((_arg1 * 0.5));
var _local6:Number = Math.cos((_arg1 * 0.5));
var _local7:Number = Math.sin((_arg2 * 0.5));
var _local8:Number = Math.cos((_arg2 * 0.5));
var _local9:Number = Math.sin((_arg3 * 0.5));
var _local10:Number = Math.cos((_arg3 * 0.5));
var _local11:Number = (_local6 * _local8);
var _local12:Number = (_local5 * _local7);
var _local13:Quaternion = 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 _local3:Number;
var _local5:int;
var _local6:int;
var _local7:int;
var _local9:Array;
var _local10:Array;
var _local2:Quaternion = new (Quaternion);
var _local4:Array = new Array(4);
var _local8:Number = ((_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 = 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 = new (Quaternion);
_local5.setFromAxisAngle(_arg1, _arg2, _arg3, _arg4);
return (_local5);
}
public static function slerp(_arg1:Quaternion, _arg2:Quaternion, _arg3:Number):Quaternion{
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local4:Number = ((((_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 = 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 = 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 = new (Quaternion);
var _local5:Number = ((((_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);
};
var _local6:Number = Math.acos(_local5);
var _local7:Number = 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);
};
var _local8:Number = (Math.sin(((1 - _arg3) * _local6)) / _local7);
var _local9:Number = (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 237
//pv3dview (org.papervision3d.core.ns.pv3dview)
package org.papervision3d.core.ns {
public namespace pv3dview;
}//package org.papervision3d.core.ns
Section 238
//CameraObject3D (org.papervision3d.core.proto.CameraObject3D)
package org.papervision3d.core.proto {
import org.papervision3d.core.render.data.*;
import flash.geom.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.math.*;
import org.papervision3d.core.log.*;
import org.papervision3d.core.culling.*;
import org.papervision3d.*;
public class CameraObject3D extends DisplayObject3D {
protected var _orthoScale:Number;// = 1
public var culler:IObjectCuller;
public var sort:Boolean;
public var viewport:Rectangle;
protected var _target:DisplayObject3D;
protected var _orthoScaleMatrix:Matrix3D;
public var eye:Matrix3D;
protected var _ortho:Boolean;
protected var _useCulling:Boolean;
public var zoom:Number;
public var yUP:Boolean;
public var focus:Number;
protected var _useProjectionMatrix:Boolean;
protected var _far:Number;
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){
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 target():DisplayObject3D{
return (_target);
}
public function get useProjectionMatrix():Boolean{
return (_useProjectionMatrix);
}
public function set fov(_arg1:Number):void{
if (((!(viewport)) || (viewport.isEmpty()))){
PaperLogger.warning("CameraObject3D#viewport not set, can't set fov!");
return;
};
var _local2:Number = 0;
var _local3:Number = 0;
var _local4:Number = 0;
if (_target){
_local2 = _target.world.n14;
_local3 = _target.world.n24;
_local4 = _target.world.n34;
};
var _local5:Number = (viewport.height / 2);
var _local6:Number = ((_arg1 / 2) * (Math.PI / 180));
this.focus = ((_local5 / Math.tan(_local6)) / this.zoom);
}
public function pan(_arg1:Number):void{
}
public function get far():Number{
return (_far);
}
public function set target(_arg1:DisplayObject3D):void{
_target = _arg1;
}
public function projectFaces(_arg1:Array, _arg2:DisplayObject3D, _arg3:RenderSessionData):Number{
return (0);
}
public function get useCulling():Boolean{
return (_useCulling);
}
public function set far(_arg1:Number):void{
if (_arg1 > this.focus){
_far = _arg1;
};
}
public function get near():Number{
return (this.focus);
}
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 set useProjectionMatrix(_arg1:Boolean):void{
_useProjectionMatrix = _arg1;
}
public function tilt(_arg1:Number):void{
}
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 get ortho():Boolean{
return (_ortho);
}
public function orbit(_arg1:Number, _arg2:Number, _arg3:Boolean=true, _arg4:DisplayObject3D=null):void{
}
public function get fov():Number{
if (((!(viewport)) || (viewport.isEmpty()))){
PaperLogger.warning("CameraObject3D#viewport not set, can't calculate fov!");
return (NaN);
};
var _local1:Number = 0;
var _local2:Number = 0;
var _local3:Number = 0;
if (_target){
_local1 = _target.world.n14;
_local2 = _target.world.n24;
_local3 = _target.world.n34;
};
var _local4:Number = (this.x - _local1);
var _local5:Number = (this.y - _local2);
var _local6:Number = (this.z - _local3);
var _local7:Number = this.focus;
var _local8:Number = this.zoom;
var _local9:Number = (Math.sqrt((((_local4 * _local4) + (_local5 * _local5)) + (_local6 * _local6))) + _local7);
var _local10:Number = (viewport.height / 2);
var _local11:Number = (180 / Math.PI);
return (((Math.atan(((((_local9 / _local7) / _local8) * _local10) / _local9)) * _local11) * 2));
}
public function set near(_arg1:Number):void{
if (_arg1 > 0){
this.focus = _arg1;
};
}
public function set useCulling(_arg1:Boolean):void{
_useCulling = _arg1;
}
public function set orthoScale(_arg1:Number):void{
_orthoScale = ((_arg1 > 0)) ? _arg1 : 0.0001;
_orthoScaleMatrix.n11 = _orthoScale;
_orthoScaleMatrix.n22 = _orthoScale;
_orthoScaleMatrix.n33 = _orthoScale;
}
public function unproject(_arg1:Number, _arg2:Number):Number3D{
var _local3:Number = ((focus * zoom) / focus);
var _local4:Number3D = new Number3D((_arg1 / _local3), (-(_arg2) / _local3), focus);
Matrix3D.multiplyVector3x3(transform, _local4);
return (_local4);
}
public function set ortho(_arg1:Boolean):void{
_ortho = _arg1;
}
public function projectVertices(_arg1:Array, _arg2:DisplayObject3D, _arg3:RenderSessionData):Number{
return (0);
}
public function get orthoScale():Number{
return (_orthoScale);
}
}
}//package org.papervision3d.core.proto
Section 239
//DisplayObjectContainer3D (org.papervision3d.core.proto.DisplayObjectContainer3D)
package org.papervision3d.core.proto {
import flash.events.*;
import flash.utils.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.log.*;
public class DisplayObjectContainer3D extends EventDispatcher {
protected var _childrenByName:Object;
public var root:DisplayObjectContainer3D;
private var _childrenTotal:int;
protected var _children:Dictionary;
public function DisplayObjectContainer3D():void{
this._children = new Dictionary(false);
this._childrenByName = new Dictionary(true);
this._childrenTotal = 0;
}
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]);
}
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 get numChildren():int{
return (this._childrenTotal);
}
public function removeChild(_arg1:DisplayObject3D):DisplayObject3D{
if (((_arg1) && (_children[_arg1]))){
delete _childrenByName[this._children[_arg1]];
delete _children[_arg1];
_arg1.parent = null;
_arg1.root = null;
_childrenTotal--;
return (_arg1);
};
return (null);
}
public function removeChildByName(_arg1:String):DisplayObject3D{
return (removeChild(getChildByName(_arg1)));
}
public function addChild(_arg1:DisplayObject3D, _arg2:String=null):DisplayObject3D{
if (_arg1.parent){
PaperLogger.error("DisplayObjectContainer.addChild : DisplayObject3D already has a parent, ie is already added to scene.");
};
_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);
}
public function childrenList():String{
var _local2:String;
var _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 240
//GeometryObject3D (org.papervision3d.core.proto.GeometryObject3D)
package org.papervision3d.core.proto {
import flash.events.*;
import flash.utils.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.math.*;
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{
dirty = true;
}
public function transformVertices(_arg1:Matrix3D):void{
var _local15:Vertex3D;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:Number;
var _local20:Number;
var _local21:Number;
var _local2:Number = _arg1.n11;
var _local3:Number = _arg1.n12;
var _local4:Number = _arg1.n13;
var _local5:Number = _arg1.n21;
var _local6:Number = _arg1.n22;
var _local7:Number = _arg1.n23;
var _local8:Number = _arg1.n31;
var _local9:Number = _arg1.n32;
var _local10:Number = _arg1.n33;
var _local11:Number = _arg1.n14;
var _local12:Number = _arg1.n24;
var _local13:Number = _arg1.n34;
var _local14:int = 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 set ready(_arg1:Boolean):void{
if (_arg1){
createVertexNormals();
this.dirty = false;
};
_ready = _arg1;
}
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 _local2:Triangle3D;
var _local3:Vertex3D;
var _local1:Dictionary = 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 get boundingSphere():BoundingSphere{
if (_boundingSphereDirty){
_boundingSphere = BoundingSphere.getFromVertices(vertices);
_boundingSphereDirty = false;
};
return (_boundingSphere);
}
public function clone(_arg1:DisplayObject3D=null):GeometryObject3D{
var _local5:int;
var _local6:MaterialObject3D;
var _local7:Vertex3D;
var _local8:Triangle3D;
var _local9:Vertex3D;
var _local10:Vertex3D;
var _local11:Vertex3D;
var _local2:Dictionary = new Dictionary(true);
var _local3:Dictionary = new Dictionary(true);
var _local4:GeometryObject3D = 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) {
if (_local6){
_local6.registerObject(_arg1);
};
};
return (_local4);
}
public function get ready():Boolean{
return (_ready);
}
public function get aabb():AxisAlignedBoundingBox{
if (_aabbDirty){
_aabb = AxisAlignedBoundingBox.createFromVertices(vertices);
_aabbDirty = false;
};
return (_aabb);
}
}
}//package org.papervision3d.core.proto
Section 241
//LightObject3D (org.papervision3d.core.proto.LightObject3D)
package org.papervision3d.core.proto {
import org.papervision3d.materials.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.math.*;
import org.papervision3d.objects.primitives.*;
public class LightObject3D extends DisplayObject3D {
public var flipped:Boolean;
public var lightMatrix:Matrix3D;
private var _showLight:Boolean;
private var displaySphere:Sphere;
public function LightObject3D(_arg1:Boolean=false, _arg2:Boolean=false){
this.lightMatrix = Matrix3D.IDENTITY;
this.showLight = _arg1;
this.flipped = _arg2;
}
public function get showLight():Boolean{
return (_showLight);
}
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;
}
}
}//package org.papervision3d.core.proto
Section 242
//MaterialObject3D (org.papervision3d.core.proto.MaterialObject3D)
package org.papervision3d.core.proto {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import org.papervision3d.materials.*;
import org.papervision3d.core.render.command.*;
import org.papervision3d.core.render.data.*;
import flash.geom.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.render.material.*;
import org.papervision3d.core.render.draw.*;
public class MaterialObject3D extends EventDispatcher implements ITriangleDrawer {
public var widthOffset:Number;// = 0
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 baked:Boolean;// = false
public var invisible:Boolean;// = false
public var smooth:Boolean;// = false
public var bitmap:BitmapData;
public var lineAlpha:Number;// = 0
public var lineColor:Number;
public var lineThickness:Number;// = 1
public var interactive:Boolean;// = false
public var oneSide:Boolean;// = true
public var opposite:Boolean;// = false
public var maxU:Number;
public var tiled:Boolean;// = false
public var maxV:Number;
public static var DEFAULT_COLOR:int = 0;
public static var DEBUG_COLOR:int = 0xFF00FF;
private static var _totalMaterialObjects:Number = 0;
public function MaterialObject3D(){
lineColor = DEFAULT_COLOR;
fillColor = DEFAULT_COLOR;
super();
this.id = _totalMaterialObjects++;
MaterialManager.registerMaterial(this);
objects = new Dictionary(true);
}
public function getObjectList():Dictionary{
return (objects);
}
override public function toString():String{
return (((((("[MaterialObject3D] bitmap:" + this.bitmap) + " lineColor:") + this.lineColor) + " fillColor:") + fillColor));
}
public function drawRT(_arg1:RenderTriangle, _arg2:Graphics, _arg3:RenderSessionData):void{
}
public function get doubleSided():Boolean{
return (!(this.oneSide));
}
public function unregisterObject(_arg1:DisplayObject3D):void{
if (((objects) && (objects[_arg1]))){
objects[_arg1] = null;
};
}
public function set doubleSided(_arg1:Boolean):void{
this.oneSide = !(_arg1);
}
public function registerObject(_arg1:DisplayObject3D):void{
objects[_arg1] = true;
}
public function updateBitmap():void{
}
public function clone():MaterialObject3D{
var _local1:MaterialObject3D = new MaterialObject3D();
_local1.copy(this);
return (_local1);
}
public function isUpdateable():Boolean{
return (!(baked));
}
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 drawTriangle(_arg1:RenderTriangle, _arg2:Graphics, _arg3:RenderSessionData, _arg4:BitmapData=null, _arg5:Matrix=null):void{
}
public static function get DEFAULT():MaterialObject3D{
var _local1:MaterialObject3D = 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 = 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 243
//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{
super.removeChild(_arg1);
var _local2:int;
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 = 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 244
//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 screenZ:Number;
public function render(_arg1:RenderSessionData, _arg2:Graphics):void{
}
}
}//package org.papervision3d.core.render.command
Section 245
//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 246
//RenderableListItem (org.papervision3d.core.render.command.RenderableListItem)
package org.papervision3d.core.render.command {
import org.papervision3d.core.render.data.*;
import flash.geom.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.geom.renderables.*;
public class RenderableListItem extends AbstractRenderListItem {
public var minX:Number;
public var minY:Number;
public var minZ:Number;
public var area:Number;
public var instance:DisplayObject3D;
public var renderableInstance:AbstractRenderable;
public var renderable:Class;
public var maxX:Number;
public var maxY:Number;
public var maxZ:Number;
public var quadrant:QuadTreeNode;
public function getZ(_arg1:Number, _arg2:Number, _arg3:Number):Number{
return (screenZ);
}
public function update():void{
}
public function hitTestPoint2D(_arg1:Point, _arg2:RenderHitData):RenderHitData{
return (_arg2);
}
public function quarter(_arg1:Number):Array{
return ([]);
}
}
}//package org.papervision3d.core.render.command
Section 247
//RenderLine (org.papervision3d.core.render.command.RenderLine)
package org.papervision3d.core.render.command {
import flash.display.*;
import org.papervision3d.core.render.data.*;
import flash.geom.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.math.*;
import org.papervision3d.materials.special.*;
public class RenderLine extends RenderableListItem implements IRenderListItem {
public var size:Number;
private var fbz:Number;
private var db:Number;
private var bzf:Number;
private var axf:Number;
public var v1:Vertex3DInstance;
private var dx:Number;
private var dy:Number;
private var faz:Number;
private var det:Number;
private var ayf:Number;
private var da:Number;
private var ax:Number;
private var ay:Number;
private var az:Number;
public var renderer:LineMaterial;
private var l1:Number2D;
private var l2:Number2D;
private var azf:Number;
private var bxf:Number;
public var cV:Vertex3DInstance;
private var bx:Number;
private var by:Number;
private var bz:Number;
public var length:Number;
private var xfocus:Number;
private var cp3d:Number3D;
private var byf:Number;
private var p:Number2D;
private var v:Number2D;
public var v0:Vertex3DInstance;
public var line:Line3D;
private var yfocus:Number;
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;
this.instance = _arg1.instance;
v0 = _arg1.v0.vertex3DInstance;
v1 = _arg1.v1.vertex3DInstance;
cV = _arg1.cV.vertex3DInstance;
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(this, _arg2, _arg1);
}
override public function getZ(_arg1:Number, _arg2:Number, _arg3:Number):Number{
ax = v0.x;
ay = v0.y;
az = v0.z;
bx = v1.x;
by = v1.y;
bz = v1.z;
if ((((ax == _arg1)) && ((ay == _arg2)))){
return (az);
};
if ((((bx == _arg1)) && ((by == _arg2)))){
return (bz);
};
dx = (bx - ax);
dy = (by - ay);
azf = (az / _arg3);
bzf = (bz / _arg3);
faz = (1 + azf);
fbz = (1 + bzf);
xfocus = _arg1;
yfocus = _arg2;
axf = ((ax * faz) - (_arg1 * azf));
bxf = ((bx * fbz) - (_arg1 * bzf));
ayf = ((ay * faz) - (_arg2 * azf));
byf = ((by * fbz) - (_arg2 * bzf));
det = ((dx * (axf - bxf)) + (dy * (ayf - byf)));
db = ((dx * (axf - _arg1)) + (dy * (ayf - _arg2)));
da = ((dx * (_arg1 - bxf)) + (dy * (_arg2 - byf)));
return ((((da * az) + (db * bz)) / det));
}
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 248
//RenderParticle (org.papervision3d.core.render.command.RenderParticle)
package org.papervision3d.core.render.command {
import flash.display.*;
import org.papervision3d.core.render.data.*;
import flash.geom.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.materials.special.*;
public class RenderParticle extends RenderableListItem implements IRenderListItem {
public var renderMat:ParticleMaterial;
public var particle:Particle;
public function RenderParticle(_arg1:Particle){
this.particle = _arg1;
this.renderableInstance = _arg1;
this.renderable = Particle;
this.instance = _arg1.instance;
}
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 249
//RenderTriangle (org.papervision3d.core.render.command.RenderTriangle)
package org.papervision3d.core.render.command {
import flash.display.*;
import org.papervision3d.materials.*;
import org.papervision3d.core.render.data.*;
import flash.geom.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.math.*;
import org.papervision3d.core.render.draw.*;
public class RenderTriangle extends RenderableListItem implements IRenderListItem {
public var triangle:Triangle3D;
private var bzf:Number;
private var axf:Number;
private var det:Number;
private var v12:Vertex3DInstance;
private var faz:Number;
private var position:Number3D;
private var ayf:Number;
private var au:Number;
private var av:Number;
private var ax:Number;
private var ay:Number;
private var az:Number;
private var v20:Vertex3DInstance;
private var fbz:Number;
private var azf:Number;
private var bu:Number;
private var bv:Number;
private var bx:Number;
private var by:Number;
private var bz:Number;
private var fcz:Number;
private var uv01:NumberUV;
private var cu:Number;
private var cv:Number;
private var cx:Number;
private var cy:Number;
private var cz:Number;
public var v0:Vertex3DInstance;
public var v1:Vertex3DInstance;
private var da:Number;
private var db:Number;
private var dc:Number;
public var container:Sprite;
private var uv12:NumberUV;
public var v2:Vertex3DInstance;
private var cxf:Number;
private var uv20:NumberUV;
protected var vx0:Vertex3DInstance;
public var uv0:NumberUV;
public var uv1:NumberUV;
public var uv2:NumberUV;
protected var vx1:Vertex3DInstance;
protected var vx2:Vertex3DInstance;
public var renderer:ITriangleDrawer;
private var cyf:Number;
private var czf:Number;
private var bxf:Number;
protected var vPointL:Vertex3DInstance;
public var renderMat:MaterialObject3D;
private var byf:Number;
private var v01:Vertex3DInstance;
public var create:Function;
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;
this.instance = _arg1.instance;
renderableInstance = _arg1;
renderable = Triangle3D;
this.v0 = _arg1.v0.vertex3DInstance;
this.v1 = _arg1.v1.vertex3DInstance;
this.v2 = _arg1.v2.vertex3DInstance;
this.uv0 = _arg1.uv0;
this.uv1 = _arg1.uv1;
this.uv2 = _arg1.uv2;
this.renderer = _arg1.material;
update();
}
private function deepHitTest(_arg1:Triangle3D, _arg2:Vertex3DInstance, _arg3:RenderHitData):RenderHitData{
var _local44:MovieMaterial;
var _local45:Rectangle;
var _local4:Vertex3DInstance = _arg1.v0.vertex3DInstance;
var _local5:Vertex3DInstance = _arg1.v1.vertex3DInstance;
var _local6:Vertex3DInstance = _arg1.v2.vertex3DInstance;
var _local7:Number = (_local6.x - _local4.x);
var _local8:Number = (_local6.y - _local4.y);
var _local9:Number = (_local5.x - _local4.x);
var _local10:Number = (_local5.y - _local4.y);
var _local11:Number = (_arg2.x - _local4.x);
var _local12:Number = (_arg2.y - _local4.y);
var _local13:Number = ((_local7 * _local7) + (_local8 * _local8));
var _local14:Number = ((_local7 * _local9) + (_local8 * _local10));
var _local15:Number = ((_local7 * _local11) + (_local8 * _local12));
var _local16:Number = ((_local9 * _local9) + (_local10 * _local10));
var _local17:Number = ((_local9 * _local11) + (_local10 * _local12));
var _local18:Number = (1 / ((_local13 * _local16) - (_local14 * _local14)));
var _local19:Number = (((_local16 * _local15) - (_local14 * _local17)) * _local18);
var _local20:Number = (((_local13 * _local17) - (_local14 * _local15)) * _local18);
var _local21:Number = (_arg1.v2.x - _arg1.v0.x);
var _local22:Number = (_arg1.v2.y - _arg1.v0.y);
var _local23:Number = (_arg1.v2.z - _arg1.v0.z);
var _local24:Number = (_arg1.v1.x - _arg1.v0.x);
var _local25:Number = (_arg1.v1.y - _arg1.v0.y);
var _local26:Number = (_arg1.v1.z - _arg1.v0.z);
var _local27:Number = ((_arg1.v0.x + (_local21 * _local19)) + (_local24 * _local20));
var _local28:Number = ((_arg1.v0.y + (_local22 * _local19)) + (_local25 * _local20));
var _local29:Number = ((_arg1.v0.z + (_local23 * _local19)) + (_local26 * _local20));
var _local30:Array = _arg1.uv;
var _local31:Number = _local30[0].u;
var _local32:Number = _local30[1].u;
var _local33:Number = _local30[2].u;
var _local34:Number = _local30[0].v;
var _local35:Number = _local30[1].v;
var _local36:Number = _local30[2].v;
var _local37:Number = ((((_local32 - _local31) * _local20) + ((_local33 - _local31) * _local19)) + _local31);
var _local38:Number = ((((_local35 - _local34) * _local20) + ((_local36 - _local34) * _local19)) + _local34);
if (triangle.material){
renderMat = _arg1.material;
} else {
renderMat = _arg1.instance.material;
};
var _local39:BitmapData = renderMat.bitmap;
var _local40:Number = 1;
var _local41:Number = 1;
var _local42:Number = 0;
var _local43:Number = 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);
}
override public function hitTestPoint2D(_arg1:Point, _arg2:RenderHitData):RenderHitData{
renderMat = triangle.material;
if (!renderMat){
renderMat = triangle.instance.material;
};
if (((renderMat) && (renderMat.interactive))){
vPointL = RenderTriangle.vPoint;
vPointL.x = _arg1.x;
vPointL.y = _arg1.y;
vx0 = triangle.v0.vertex3DInstance;
vx1 = triangle.v1.vertex3DInstance;
vx2 = triangle.v2.vertex3DInstance;
if (sameSide(vPointL, vx0, vx1, vx2)){
if (sameSide(vPointL, vx1, vx0, vx2)){
if (sameSide(vPointL, vx2, vx0, vx1)){
return (deepHitTest(triangle, vPointL, _arg2));
};
};
};
};
return (_arg2);
}
public function fivepointcut(_arg1:Vertex3DInstance, _arg2:Vertex3DInstance, _arg3:Vertex3DInstance, _arg4:Vertex3DInstance, _arg5:Vertex3DInstance, _arg6:NumberUV, _arg7:NumberUV, _arg8:NumberUV, _arg9:NumberUV, _arg10:NumberUV):Array{
if (_arg1.distanceSqr(_arg4) < _arg2.distanceSqr(_arg5)){
return ([create(renderableInstance, renderer, _arg1, _arg2, _arg4, _arg6, _arg7, _arg9), create(renderableInstance, renderer, _arg2, _arg3, _arg4, _arg7, _arg8, _arg9), create(renderableInstance, renderer, _arg1, _arg4, _arg5, _arg6, _arg9, _arg10)]);
};
return ([create(renderableInstance, renderer, _arg1, _arg2, _arg5, _arg6, _arg7, _arg10), create(renderableInstance, renderer, _arg2, _arg3, _arg4, _arg7, _arg8, _arg9), create(renderableInstance, renderer, _arg2, _arg4, _arg5, _arg7, _arg9, _arg10)]);
}
override public function render(_arg1:RenderSessionData, _arg2:Graphics):void{
renderer.drawTriangle(this, _arg2, _arg1);
}
final override public function quarter(_arg1:Number):Array{
if (area < 20){
return (null);
};
v01 = Vertex3DInstance.median(v0, v1, _arg1);
v12 = Vertex3DInstance.median(v1, v2, _arg1);
v20 = Vertex3DInstance.median(v2, v0, _arg1);
uv01 = NumberUV.median(uv0, uv1);
uv12 = NumberUV.median(uv1, uv2);
uv20 = NumberUV.median(uv2, uv0);
return ([create(renderableInstance, renderer, v0, v01, v20, uv0, uv01, uv20), create(renderableInstance, renderer, v1, v12, v01, uv1, uv12, uv01), create(renderableInstance, renderer, v2, v20, v12, uv2, uv20, uv12), create(renderableInstance, renderer, v01, v12, v20, uv01, uv12, uv20)]);
}
final override public function getZ(_arg1:Number, _arg2:Number, _arg3:Number):Number{
ax = v0.x;
ay = v0.y;
az = v0.z;
bx = v1.x;
by = v1.y;
bz = v1.z;
cx = v2.x;
cy = v2.y;
cz = v2.z;
if ((((ax == _arg1)) && ((ay == _arg2)))){
return (az);
};
if ((((bx == _arg1)) && ((by == _arg2)))){
return (bz);
};
if ((((cx == _arg1)) && ((cy == _arg2)))){
return (cz);
};
azf = (az / _arg3);
bzf = (bz / _arg3);
czf = (cz / _arg3);
faz = (1 + azf);
fbz = (1 + bzf);
fcz = (1 + czf);
axf = ((ax * faz) - (_arg1 * azf));
bxf = ((bx * fbz) - (_arg1 * bzf));
cxf = ((cx * fcz) - (_arg1 * czf));
ayf = ((ay * faz) - (_arg2 * azf));
byf = ((by * fbz) - (_arg2 * bzf));
cyf = ((cy * fcz) - (_arg2 * czf));
det = (((axf * (byf - cyf)) + (bxf * (cyf - ayf))) + (cxf * (ayf - byf)));
da = (((_arg1 * (byf - cyf)) + (bxf * (cyf - _arg2))) + (cxf * (_arg2 - byf)));
db = (((axf * (_arg2 - cyf)) + (_arg1 * (cyf - ayf))) + (cxf * (ayf - _arg2)));
dc = (((axf * (byf - _arg2)) + (bxf * (_arg2 - ayf))) + (_arg1 * (ayf - byf)));
return (((((da * az) + (db * bz)) + (dc * cz)) / det));
}
override public function update():void{
if (v0.x > v1.x){
if (v0.x > v2.x){
maxX = v0.x;
} else {
maxX = v2.x;
};
} else {
if (v1.x > v2.x){
maxX = v1.x;
} else {
maxX = v2.x;
};
};
if (v0.x < v1.x){
if (v0.x < v2.x){
minX = v0.x;
} else {
minX = v2.x;
};
} else {
if (v1.x < v2.x){
minX = v1.x;
} else {
minX = v2.x;
};
};
if (v0.y > v1.y){
if (v0.y > v2.y){
maxY = v0.y;
} else {
maxY = v2.y;
};
} else {
if (v1.y > v2.y){
maxY = v1.y;
} else {
maxY = v2.y;
};
};
if (v0.y < v1.y){
if (v0.y < v2.y){
minY = v0.y;
} else {
minY = v2.y;
};
} else {
if (v1.y < v2.y){
minY = v1.y;
} else {
minY = v2.y;
};
};
if (v0.z > v1.z){
if (v0.z > v2.z){
maxZ = v0.z;
} else {
maxZ = v2.z;
};
} else {
if (v1.z > v2.z){
maxZ = v1.z;
} else {
maxZ = v2.z;
};
};
if (v0.z < v1.z){
if (v0.z < v2.z){
minZ = v0.z;
} else {
minZ = v2.z;
};
} else {
if (v1.z < v2.z){
minZ = v1.z;
} else {
minZ = v2.z;
};
};
screenZ = (((v0.z + v1.z) + v2.z) / 3);
area = (0.5 * (((v0.x * (v2.y - v1.y)) + (v1.x * (v0.y - v2.y))) + (v2.x * (v1.y - v0.y))));
}
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));
}
}
}//package org.papervision3d.core.render.command
Section 250
//QuadTree (org.papervision3d.core.render.data.QuadTree)
package org.papervision3d.core.render.data {
import flash.display.*;
import org.papervision3d.core.render.command.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.clipping.draw.*;
public final class QuadTree {
private var _root:QuadTreeNode;
private var _rect:RectangleClipping;
private var _result:Array;
private var _maxlevel:uint;// = 4
private var _maxX:Number;
private var _maxY:Number;
private var _child:RenderableListItem;
private var _children:Array;
private var _minX:Number;
private var _minY:Number;
private var i:int;
private var _clip:Clipping;
private var _center:Array;
private var _except:DisplayObject3D;
public function get maxLevel():uint{
return (_maxlevel);
}
public function remove(_arg1:RenderableListItem):void{
_center = _arg1.quadrant.center;
_center.splice(_center.indexOf(_arg1), 1);
}
public function set maxLevel(_arg1:uint):void{
_maxlevel = _arg1;
if (_root){
_root.maxlevel = _maxlevel;
};
}
public function getOverlaps(_arg1:RenderableListItem, _arg2:DisplayObject3D=null):Array{
_result = [];
_minX = _arg1.minX;
_minY = _arg1.minY;
_maxX = _arg1.maxX;
_maxY = _arg1.maxY;
_except = _arg2;
getList(_arg1.quadrant);
getParent(_arg1.quadrant);
return (_result);
}
public function get clip():Clipping{
return (_clip);
}
public function render(_arg1:RenderSessionData, _arg2:Graphics):void{
_root.render(-(Infinity), _arg1, _arg2);
}
public function list():Array{
_result = [];
_minX = -1000000;
_minY = -1000000;
_maxX = 1000000;
_maxY = 1000000;
_except = null;
getList(_root);
return (_result);
}
public function getRoot():QuadTreeNode{
return (_root);
}
private function getList(_arg1:QuadTreeNode):void{
if (!_arg1){
return;
};
if (((_arg1.onlysourceFlag) && ((_except == _arg1.onlysource)))){
return;
};
if (_minX < _arg1.xdiv){
if (((_arg1.lefttopFlag) && ((_minY < _arg1.ydiv)))){
getList(_arg1.lefttop);
};
if (((_arg1.leftbottomFlag) && ((_maxY > _arg1.ydiv)))){
getList(_arg1.leftbottom);
};
};
if (_maxX > _arg1.xdiv){
if (((_arg1.righttopFlag) && ((_minY < _arg1.ydiv)))){
getList(_arg1.righttop);
};
if (((_arg1.rightbottomFlag) && ((_maxY > _arg1.ydiv)))){
getList(_arg1.rightbottom);
};
};
_children = _arg1.center;
if (_children != null){
i = _children.length;
while (i--) {
_child = _children[i];
if ((((((((((((_except == null)) || (!((_child.instance == _except))))) && ((_child.maxX > _minX)))) && ((_child.minX < _maxX)))) && ((_child.maxY > _minY)))) && ((_child.minY < _maxY)))){
_result.push(_child);
};
};
};
}
private function getParent(_arg1:QuadTreeNode=null):void{
if (!_arg1){
return;
};
_arg1 = _arg1.parent;
if ((((_arg1 == null)) || (((_arg1.onlysourceFlag) && ((_except == _arg1.onlysource)))))){
return;
};
_children = _arg1.center;
if (_children != null){
i = _children.length;
while (i--) {
_child = _children[i];
if ((((((((((((_except == null)) || (!((_child.instance == _except))))) && ((_child.maxX > _minX)))) && ((_child.minX < _maxX)))) && ((_child.maxY > _minY)))) && ((_child.minY < _maxY)))){
_result.push(_child);
};
};
};
getParent(_arg1);
}
public function add(_arg1:RenderableListItem):void{
if (_clip.check(_arg1)){
_root.push(_arg1);
};
}
public function set clip(_arg1:Clipping):void{
_clip = _arg1;
_rect = _clip.asRectangleClipping();
if (!_root){
_root = new QuadTreeNode(((_rect.minX + _rect.maxX) / 2), ((_rect.minY + _rect.maxY) / 2), (_rect.maxX - _rect.minX), (_rect.maxY - _rect.minY), 0, null, _maxlevel);
} else {
_root.reset(((_rect.minX + _rect.maxX) / 2), ((_rect.minY + _rect.maxY) / 2), (_rect.maxX - _rect.minX), (_rect.maxY - _rect.minY), _maxlevel);
};
}
}
}//package org.papervision3d.core.render.data
Section 251
//QuadTreeNode (org.papervision3d.core.render.data.QuadTreeNode)
package org.papervision3d.core.render.data {
import flash.display.*;
import org.papervision3d.core.render.command.*;
import flash.geom.*;
import org.papervision3d.objects.*;
public final class QuadTreeNode {
public var parent:QuadTreeNode;
public var create:Function;
private var level:int;
public var righttopFlag:Boolean;
public var hasContent:Boolean;// = false
public var rightbottom:QuadTreeNode;
public var righttop:QuadTreeNode;
public var rightbottomFlag:Boolean;
public var onlysource:DisplayObject3D;
public var xdiv:Number;
private var halfheight:Number;
public var center:Array;
public var maxlevel:int;// = 4
private var render_center_length:int;// = -1
public var onlysourceFlag:Boolean;// = true
private var render_center_index:int;// = -1
private var halfwidth:Number;
public var lefttop:QuadTreeNode;
public var ydiv:Number;
public var leftbottom:QuadTreeNode;
public var lefttopFlag:Boolean;
public var leftbottomFlag:Boolean;
public function QuadTreeNode(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:int, _arg6:QuadTreeNode=null, _arg7:uint=4){
this.level = _arg5;
this.xdiv = _arg1;
this.ydiv = _arg2;
halfwidth = (_arg3 / 2);
halfheight = (_arg4 / 2);
this.parent = _arg6;
this.maxlevel = _arg7;
}
public function reset(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:uint):void{
this.xdiv = _arg1;
this.ydiv = _arg2;
halfwidth = (_arg3 / 2);
halfheight = (_arg4 / 2);
lefttopFlag = false;
leftbottomFlag = false;
righttopFlag = false;
rightbottomFlag = false;
onlysourceFlag = true;
onlysource = null;
render_center_length = -1;
render_center_index = -1;
hasContent = false;
maxlevel = _arg5;
}
public function push(_arg1:RenderableListItem):void{
hasContent = true;
if (onlysourceFlag){
if (((!((onlysource == null))) && (!((onlysource == _arg1.instance))))){
onlysourceFlag = false;
};
onlysource = _arg1.instance;
};
if (level < maxlevel){
if (_arg1.maxX <= xdiv){
if (_arg1.maxY <= ydiv){
if (lefttop == null){
lefttopFlag = true;
lefttop = new QuadTreeNode((xdiv - (halfwidth / 2)), (ydiv - (halfheight / 2)), halfwidth, halfheight, (level + 1), this, maxlevel);
} else {
if (!lefttopFlag){
lefttopFlag = true;
lefttop.reset((xdiv - (halfwidth / 2)), (ydiv - (halfheight / 2)), halfwidth, halfheight, maxlevel);
};
};
lefttop.push(_arg1);
return;
} else {
if (_arg1.minY >= ydiv){
if (leftbottom == null){
leftbottomFlag = true;
leftbottom = new QuadTreeNode((xdiv - (halfwidth / 2)), (ydiv + (halfheight / 2)), halfwidth, halfheight, (level + 1), this, maxlevel);
} else {
if (!leftbottomFlag){
leftbottomFlag = true;
leftbottom.reset((xdiv - (halfwidth / 2)), (ydiv + (halfheight / 2)), halfwidth, halfheight, maxlevel);
};
};
leftbottom.push(_arg1);
return;
};
};
} else {
if (_arg1.minX >= xdiv){
if (_arg1.maxY <= ydiv){
if (righttop == null){
righttopFlag = true;
righttop = new QuadTreeNode((xdiv + (halfwidth / 2)), (ydiv - (halfheight / 2)), halfwidth, halfheight, (level + 1), this, maxlevel);
} else {
if (!righttopFlag){
righttopFlag = true;
righttop.reset((xdiv + (halfwidth / 2)), (ydiv - (halfheight / 2)), halfwidth, halfheight, maxlevel);
};
};
righttop.push(_arg1);
return;
} else {
if (_arg1.minY >= ydiv){
if (rightbottom == null){
rightbottomFlag = true;
rightbottom = new QuadTreeNode((xdiv + (halfwidth / 2)), (ydiv + (halfheight / 2)), halfwidth, halfheight, (level + 1), this, maxlevel);
} else {
if (!rightbottomFlag){
rightbottomFlag = true;
rightbottom.reset((xdiv + (halfwidth / 2)), (ydiv + (halfheight / 2)), halfwidth, halfheight, maxlevel);
};
};
rightbottom.push(_arg1);
return;
};
};
};
};
};
if (center == null){
center = new Array();
};
center.push(_arg1);
_arg1.quadrant = this;
}
public function render(_arg1:Number, _arg2:RenderSessionData, _arg3:Graphics):void{
var _local4:RenderableListItem;
if (render_center_length == -1){
if (center != null){
render_center_length = center.length;
if (render_center_length > 1){
center.sortOn("screenZ", (Array.DESCENDING | Array.NUMERIC));
};
} else {
render_center_length = 0;
};
render_center_index = 0;
};
while (render_center_index < render_center_length) {
_local4 = center[render_center_index];
if (_local4.screenZ < _arg1){
break;
};
render_other(_local4.screenZ, _arg2, _arg3);
_local4.render(_arg2, _arg3);
_arg2.viewPort.lastRenderList.push(_local4);
render_center_index++;
};
if (render_center_index == render_center_length){
center = null;
};
render_other(_arg1, _arg2, _arg3);
}
public function getRect():Rectangle{
return (new Rectangle(xdiv, ydiv, (halfwidth * 2), (halfheight * 2)));
}
private function render_other(_arg1:Number, _arg2:RenderSessionData, _arg3:Graphics):void{
if (lefttopFlag){
lefttop.render(_arg1, _arg2, _arg3);
};
if (leftbottomFlag){
leftbottom.render(_arg1, _arg2, _arg3);
};
if (righttopFlag){
righttop.render(_arg1, _arg2, _arg3);
};
if (rightbottomFlag){
rightbottom.render(_arg1, _arg2, _arg3);
};
}
}
}//package org.papervision3d.core.render.data
Section 252
//RenderHitData (org.papervision3d.core.render.data.RenderHitData)
package org.papervision3d.core.render.data {
import org.papervision3d.core.proto.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.geom.renderables.*;
public class RenderHitData {
public var y:Number;
public var z:Number;
public var endTime:int;// = 0
public var startTime:int;// = 0
public var displayObject3D:DisplayObject3D;
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 function RenderHitData():void{
}
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 = 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 253
//RenderSessionData (org.papervision3d.core.render.data.RenderSessionData)
package org.papervision3d.core.render.data {
import flash.display.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.view.*;
import org.papervision3d.core.culling.*;
import org.papervision3d.core.render.*;
import org.papervision3d.core.clipping.*;
public class RenderSessionData {
public var container:Sprite;
public var renderer:IRenderEngine;
public var particleCuller:IParticleCuller;
public var viewPort:Viewport3D;
public var triangleCuller:ITriangleCuller;
public var clipping:DefaultClipping;
public var scene:SceneObject3D;
public var renderStatistics:RenderStatistics;
public var renderObjects:Array;
public var camera:CameraObject3D;
public var renderLayers:Array;
public var quadrantTree:QuadTree;
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;
clipping = null;
quadrantTree = null;
}
public function clone():RenderSessionData{
var _local1:RenderSessionData = 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();
_local1.clipping = clipping;
_local1.quadrantTree = quadrantTree;
return (_local1);
}
}
}//package org.papervision3d.core.render.data
Section 254
//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 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 clone():RenderStatistics{
var _local1:RenderStatistics = 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 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 255
//ILineDrawer (org.papervision3d.core.render.draw.ILineDrawer)
package org.papervision3d.core.render.draw {
import flash.display.*;
import org.papervision3d.core.render.command.*;
import org.papervision3d.core.render.data.*;
public interface ILineDrawer {
function drawLine(_arg1:RenderLine, _arg2:Graphics, _arg3:RenderSessionData):void;
}
}//package org.papervision3d.core.render.draw
Section 256
//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 drawParticle(_arg1:Particle, _arg2:Graphics, _arg3:RenderSessionData):void;
function updateRenderRect(_arg1:Particle):void;
}
}//package org.papervision3d.core.render.draw
Section 257
//ITriangleDrawer (org.papervision3d.core.render.draw.ITriangleDrawer)
package org.papervision3d.core.render.draw {
import flash.display.*;
import org.papervision3d.core.render.command.*;
import org.papervision3d.core.render.data.*;
import flash.geom.*;
public interface ITriangleDrawer {
function drawTriangle(_arg1:RenderTriangle, _arg2:Graphics, _arg3:RenderSessionData, _arg4:BitmapData=null, _arg5:Matrix=null):void;
function drawRT(_arg1:RenderTriangle, _arg2:Graphics, _arg3:RenderSessionData):void;
}
}//package org.papervision3d.core.render.draw
Section 258
//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 259
//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 260
//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 261
//IUpdateBeforeMaterial (org.papervision3d.core.render.material.IUpdateBeforeMaterial)
package org.papervision3d.core.render.material {
import org.papervision3d.core.render.data.*;
public interface IUpdateBeforeMaterial {
function isUpdateable():Boolean;
function updateBeforeRender(_arg1:RenderSessionData):void;
}
}//package org.papervision3d.core.render.material
Section 262
//MaterialManager (org.papervision3d.core.render.material.MaterialManager)
package org.papervision3d.core.render.material {
import flash.utils.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.proto.*;
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:*;
for (_local3 in materials) {
if ((_local3 is IUpdateAfterMaterial)){
_local2 = (_local3 as IUpdateAfterMaterial);
_local2.updateAfterRender(_arg1);
};
};
}
private function _registerMaterial(_arg1:MaterialObject3D):void{
materials[_arg1] = true;
}
public function updateMaterialsBeforeRender(_arg1:RenderSessionData):void{
var _local2:IUpdateBeforeMaterial;
var _local3:*;
for (_local3 in materials) {
if ((_local3 is IUpdateBeforeMaterial)){
_local2 = (_local3 as IUpdateBeforeMaterial);
if (_local2.isUpdateable()){
_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 263
//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{
}
override public function project(_arg1:RenderSessionData):void{
var _local3:DisplayObject3D;
var _local5:Number;
_arg1.camera.transformView();
var _local2:Array = _arg1.renderObjects;
var _local4:Number = _local2.length;
if (_arg1.camera.useProjectionMatrix){
for each (_local3 in _local2) {
if (_local3.visible){
if (_arg1.viewPort.viewportObjectFilter){
_local5 = _arg1.viewPort.viewportObjectFilter.testObject(_local3);
if (_local5){
projectObject(_local3, _arg1, _local5);
} else {
_arg1.renderStatistics.filteredObjects++;
};
} else {
projectObject(_local3, _arg1, 1);
};
};
};
} else {
for each (_local3 in _local2) {
if (_local3.visible){
if (_arg1.viewPort.viewportObjectFilter){
_local5 = _arg1.viewPort.viewportObjectFilter.testObject(_local3);
if (_local5){
projectObject(_local3, _arg1, _local5);
} else {
_arg1.renderStatistics.filteredObjects++;
};
} else {
projectObject(_local3, _arg1, 1);
};
};
};
};
}
protected function projectObject(_arg1:DisplayObject3D, _arg2:RenderSessionData, _arg3:Number):void{
_arg1.cullTest = _arg3;
if (_arg1.parent){
_arg1.project((_arg1.parent as DisplayObject3D), _arg2);
} else {
_arg1.project(_arg2.camera, _arg2);
};
}
}
}//package org.papervision3d.core.render.project
Section 264
//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 265
//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 destroy():void;
function getLayerForShader(_arg1:Shader):Sprite;
function clear():void;
function render(_arg1:RenderSessionData):void;
}
}//package org.papervision3d.core.render.shader
Section 266
//ShaderObjectData (org.papervision3d.core.render.shader.ShaderObjectData)
package org.papervision3d.core.render.shader {
import flash.display.*;
import flash.utils.*;
import org.papervision3d.materials.*;
import flash.geom.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.materials.shaders.*;
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 material:BitmapMaterial;
public var triangleRects:Dictionary;
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 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 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 = material.bitmap.width;
var _local5:Number = material.bitmap.height;
var _local6:Number = _arg2.uv[0].u;
var _local7:Number = (1 - _arg2.uv[0].v);
var _local8:Number = _arg2.uv[1].u;
var _local9:Number = (1 - _arg2.uv[1].v);
var _local10:Number = _arg2.uv[2].u;
var _local11:Number = (1 - _arg2.uv[2].v);
var _local12:Number = (_local6 * _local4);
var _local13:Number = (_local7 * _local5);
var _local14:Number = (_local8 * _local4);
var _local15:Number = (_local9 * _local5);
var _local16:Number = (_local10 * _local4);
var _local17:Number = (_local11 * _local5);
var _local18:Number = (((_local10 + _local8) + _local6) / 3);
var _local19:Number = (((_local11 + _local9) + _local7) / 3);
var _local20:Number = (_local6 - _local18);
var _local21:Number = (_local7 - _local19);
var _local22:Number = (_local8 - _local18);
var _local23:Number = (_local9 - _local19);
var _local24:Number = (_local10 - _local18);
var _local25:Number = (_local11 - _local19);
var _local26:Number = ((_local20)<0) ? -(_local20) : _local20;
var _local27:Number = ((_local21)<0) ? -(_local21) : _local21;
var _local28:Number = ((_local22)<0) ? -(_local22) : _local22;
var _local29:Number = ((_local23)<0) ? -(_local23) : _local23;
var _local30:Number = ((_local24)<0) ? -(_local24) : _local24;
var _local31:Number = ((_local25)<0) ? -(_local25) : _local25;
var _local32:Number = ((_local26)>_local27) ? (1 / _local26) : (1 / _local27);
var _local33:Number = ((_local28)>_local29) ? (1 / _local28) : (1 / _local29);
var _local34:Number = ((_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 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 267
//ShaderRenderer (org.papervision3d.core.render.shader.ShaderRenderer)
package org.papervision3d.core.render.shader {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import org.papervision3d.core.render.data.*;
import flash.geom.*;
import org.papervision3d.materials.shaders.*;
public class ShaderRenderer extends EventDispatcher implements IShaderRenderer {
public var container:Sprite;
public var shadeLayers:Dictionary;
public var outputBitmap:BitmapData;
public var bitmapContainer:Bitmap;
public var resizedInput:Boolean;// = false
public var bitmapLayer:Sprite;
private var _inputBitmapData:BitmapData;
public function ShaderRenderer(){
container = new Sprite();
bitmapLayer = new Sprite();
bitmapContainer = new Bitmap();
bitmapLayer.addChild(bitmapContainer);
bitmapLayer.blendMode = BlendMode.NORMAL;
shadeLayers = new Dictionary();
container.addChild(bitmapLayer);
}
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 get inputBitmap():BitmapData{
return (_inputBitmapData);
}
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();
};
};
};
}
public function getLayerForShader(_arg1:Shader):Sprite{
var _local2:Sprite = new Sprite();
shadeLayers[_arg1] = _local2;
var _local3:Sprite = 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 destroy():void{
bitmapLayer = null;
outputBitmap.dispose();
}
}
}//package org.papervision3d.core.render.shader
Section 268
//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("screenZ", Array.NUMERIC);
}
}
}//package org.papervision3d.core.render.sort
Section 269
//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 270
//AbstractRenderEngine (org.papervision3d.core.render.AbstractRenderEngine)
package org.papervision3d.core.render {
import flash.events.*;
import org.papervision3d.core.render.command.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.view.*;
public class AbstractRenderEngine extends EventDispatcher implements IRenderEngine {
public function AbstractRenderEngine(_arg1:IEventDispatcher=null){
super(_arg1);
}
public function addToRenderList(_arg1:RenderableListItem):int{
return (0);
}
public function removeFromRenderList(_arg1:IRenderListItem):int{
return (0);
}
public function renderScene(_arg1:SceneObject3D, _arg2:CameraObject3D, _arg3:Viewport3D):RenderStatistics{
return (null);
}
}
}//package org.papervision3d.core.render
Section 271
//IRenderEngine (org.papervision3d.core.render.IRenderEngine)
package org.papervision3d.core.render {
import org.papervision3d.core.render.command.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.view.*;
public interface IRenderEngine {
function addToRenderList(_arg1:RenderableListItem):int;
function removeFromRenderList(_arg1:IRenderListItem):int;
function renderScene(_arg1:SceneObject3D, _arg2:CameraObject3D, _arg3:Viewport3D):RenderStatistics;
}
}//package org.papervision3d.core.render
Section 272
//IVirtualMouseEvent (org.papervision3d.core.utils.virtualmouse.IVirtualMouseEvent)
package org.papervision3d.core.utils.virtualmouse {
public interface IVirtualMouseEvent {
}
}//package org.papervision3d.core.utils.virtualmouse
Section 273
//VirtualMouse (org.papervision3d.core.utils.virtualmouse.VirtualMouse)
package org.papervision3d.core.utils.virtualmouse {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import flash.geom.*;
import org.papervision3d.core.log.*;
public class VirtualMouse extends EventDispatcher {
private var _container:Sprite;
private var _stage:Stage;
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 ctrlKey:Boolean;// = false
private var altKey:Boolean;// = false
private var _useNativeEvents:Boolean;// = false
private var shiftKey:Boolean;// = false
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){
disabledEvents = new Object();
ignoredInstances = new Dictionary(true);
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 container():Sprite{
return (_container);
}
public function exitContainer():void{
if (!container){
return;
};
var _local1:Point = 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();
};
}
private function keyHandler(_arg1:KeyboardEvent):void{
altKey = _arg1.altKey;
ctrlKey = _arg1.ctrlKey;
shiftKey = _arg1.shiftKey;
}
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 lastEvent():Event{
return (_lastEvent);
}
private function handleUpdate(_arg1:Event):void{
var _local4:InteractiveObject;
var _local5:DisplayObject;
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");
};
var _local2:Point = new Point();
_local2.x = container.x;
_local2.y = container.y;
container.x = (container.y = 0);
var _local3 = container.getObjectsUnderPoint(location);
container.x = _local2.x;
container.y = _local2.y;
var _local6:int = _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 = container;
};
var _local7:Point = target.globalToLocal(location);
var _local8:Point = _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 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();
};
}
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 x(_arg1:Number):void{
location.x = _arg1;
if (!isLocked){
update();
};
}
public function set y(_arg1:Number):void{
location.y = _arg1;
if (!isLocked){
update();
};
}
public function get y():Number{
return (location.y);
}
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();
};
};
}
public function get stage():Stage{
return (_stage);
}
public function get x():Number{
return (location.x);
}
}
}//package org.papervision3d.core.utils.virtualmouse
Section 274
//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 275
//VirtualMouseMouseEvent (org.papervision3d.core.utils.virtualmouse.VirtualMouseMouseEvent)
package org.papervision3d.core.utils.virtualmouse {
import flash.events.*;
import flash.display.*;
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 276
//InteractiveSceneManager (org.papervision3d.core.utils.InteractiveSceneManager)
package org.papervision3d.core.utils {
import flash.events.*;
import flash.display.*;
import org.papervision3d.materials.*;
import org.papervision3d.core.render.data.*;
import flash.geom.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.view.*;
import org.papervision3d.events.*;
import org.papervision3d.core.utils.virtualmouse.*;
public class InteractiveSceneManager extends EventDispatcher {
public var currentMaterial:MaterialObject3D;
public var container:Sprite;
public var currentMousePos:Point;
public var debug:Boolean;// = false
public var mouse3D:Mouse3D;
public var enableOverOut:Boolean;// = true
public var currentDisplayObject3D:DisplayObject3D;
public var _viewportRendered:Boolean;// = false
public var virtualMouse:VirtualMouse;
public var lastMousePos:Point;
public var viewport:Viewport3D;
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();
currentMousePos = new Point();
lastMousePos = new Point();
super();
this.viewport = _arg1;
this.container = _arg1.containerSprite;
init();
}
protected function handleMouseClick(_arg1:MouseEvent):void{
if ((_arg1 is IVirtualMouseEvent)){
return;
};
if (((renderHitData) && (renderHitData.hasHit))){
dispatchObjectEvent(InteractiveScene3DEvent.OBJECT_CLICK, currentDisplayObject3D);
};
}
protected function handleEnterFrame(_arg1:Event):void{
var _local3:MovieMaterial;
var _local2:Boolean = hasMouseMoved();
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;
}
public function updateAfterRender():void{
_viewportRendered = true;
}
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, false, 0, true);
};
}
protected function initVirtualMouse():void{
virtualMouse.stage = container.stage;
virtualMouse.container = container;
}
protected function handleMouseOver(_arg1:DisplayObject3D):void{
if (hasMouseMoved()){
dispatchObjectEvent(InteractiveScene3DEvent.OBJECT_OVER, _arg1);
};
}
protected function resolveRenderHitData():void{
renderHitData = (viewport.hitTestPoint2D(currentMousePos) as RenderHitData);
}
public function updateRenderHitData():void{
resolveRenderHitData();
currentDisplayObject3D = renderHitData.displayObject3D;
currentMaterial = renderHitData.material;
manageOverOut();
}
protected function hasMouseMoved():Boolean{
currentMousePos.x = container.mouseX;
currentMousePos.y = container.mouseY;
return (!(currentMousePos.equals(lastMousePos)));
}
protected function dispatchObjectEvent(_arg1:String, _arg2:DisplayObject3D):void{
var _local3:Number;
var _local4:Number;
var _local5:InteractiveScene3DEvent;
if (((renderHitData) && (renderHitData.hasHit))){
_local3 = (renderHitData.u) ? renderHitData.u : 0;
_local4 = (renderHitData.v) ? renderHitData.v : 0;
_local5 = new InteractiveScene3DEvent(_arg1, _arg2, container, (renderHitData.renderable as Triangle3D), _local3, _local4, renderHitData);
_local5.renderHitData = renderHitData;
dispatchEvent(_local5);
_arg2.dispatchEvent(_local5);
} else {
dispatchEvent(new InteractiveScene3DEvent(_arg1, _arg2, container));
if (_arg2){
_arg2.dispatchEvent(new InteractiveScene3DEvent(_arg1, _arg2, container));
};
};
}
protected function handleMouseDoubleClick(_arg1:MouseEvent):void{
if ((_arg1 is IVirtualMouseEvent)){
return;
};
if (((renderHitData) && (renderHitData.hasHit))){
dispatchObjectEvent(InteractiveScene3DEvent.OBJECT_DOUBLE_CLICK, 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{
container.removeEventListener(Event.ADDED_TO_STAGE, handleAddedToStage);
initVirtualMouse();
initListeners();
}
protected function handleMouseOut(_arg1:DisplayObject3D):void{
var _local2:MovieMaterial;
if (!hasMouseMoved()){
return;
};
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;
};
};
}
public function destroy():void{
viewport = null;
renderHitData = null;
currentDisplayObject3D = null;
currentMaterial = null;
currentMouseDO3D = null;
virtualMouse.stage = null;
virtualMouse.container = 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;
}
public function init():void{
if (container){
if (container.stage){
initVirtualMouse();
initListeners();
} else {
container.addEventListener(Event.ADDED_TO_STAGE, handleAddedToStage, false, 0, true);
};
};
}
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);
};
}
}
}//package org.papervision3d.core.utils
Section 277
//Mouse3D (org.papervision3d.core.utils.Mouse3D)
package org.papervision3d.core.utils {
import org.papervision3d.core.render.data.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.math.*;
public class Mouse3D extends DisplayObject3D {
private var target:Number3D;
public static var enabled:Boolean = false;
private static var UP:Number3D = new Number3D(0, 1, 0);
public function Mouse3D():void{
target = new Number3D();
super();
}
public function updatePosition(_arg1:RenderHitData):void{
var _local5:Number3D;
var _local6:Number3D;
var _local7:Matrix3D;
var _local2:Triangle3D = (_arg1.renderable as Triangle3D);
target.x = _local2.faceNormal.x;
target.y = _local2.faceNormal.y;
target.z = _local2.faceNormal.z;
var _local3:Number3D = 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;
};
var _local4:Matrix3D = 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 278
//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 isRunning:Boolean;
private var stopTime:int;
public function start():void{
if (!isRunning){
startTime = getTimer();
isRunning = true;
};
}
public function stop():int{
if (isRunning){
stopTime = getTimer();
elapsedTime = (stopTime - startTime);
isRunning = false;
return (elapsedTime);
};
return (0);
}
public function reset():void{
isRunning = false;
}
}
}//package org.papervision3d.core.utils
Section 279
//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 280
//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 281
//InteractiveScene3DEvent (org.papervision3d.events.InteractiveScene3DEvent)
package org.papervision3d.events {
import flash.events.*;
import flash.display.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.geom.renderables.*;
public class InteractiveScene3DEvent extends Event {
public var y:Number;// = 0
public var sprite:Sprite;// = null
public var renderHitData:RenderHitData;
public var face3d:Triangle3D;// = null
public var x:Number;// = 0
public var displayObject3D:DisplayObject3D;// = null
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){
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 282
//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 283
//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 284
//FlatShadeMaterial (org.papervision3d.materials.shadematerials.FlatShadeMaterial)
package org.papervision3d.materials.shadematerials {
import flash.display.*;
import org.papervision3d.materials.utils.*;
import org.papervision3d.core.render.command.*;
import org.papervision3d.core.render.data.*;
import flash.geom.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.math.*;
import org.papervision3d.core.render.draw.*;
import org.papervision3d.core.material.*;
public class FlatShadeMaterial extends AbstractLightShadeMaterial implements ITriangleDrawer {
protected var _colors:Array;
private static var zd:Number;
private static var y0:Number;
private static var x0:Number;
private static var zAngle:int;
private static var currentColor:int;
public function FlatShadeMaterial(_arg1:LightObject3D, _arg2:uint=0xFFFFFF, _arg3:uint=0, _arg4:uint=0){
this.fillAlpha = 1;
this.light = _arg1;
_colors = LightMaps.getFlatMapArray(_arg2, _arg3, _arg4);
}
override public function drawTriangle(_arg1:RenderTriangle, _arg2:Graphics, _arg3:RenderSessionData, _arg4:BitmapData=null, _arg5:Matrix=null):void{
var _local6:Triangle3D;
_local6 = _arg1.triangle;
lightMatrix = Matrix3D(lightMatrices[_local6.instance]);
zd = (((_local6.faceNormal.x * lightMatrix.n31) + (_local6.faceNormal.y * lightMatrix.n32)) + (_local6.faceNormal.z * lightMatrix.n33));
if (zd < 0){
if (doubleSided == false){
zd = 0;
} else {
zd = Math.abs(zd);
};
};
x0 = _arg1.v0.x;
y0 = _arg1.v0.y;
zAngle = (zd * 0xFF);
currentColor = _colors[zAngle];
_arg2.beginFill(currentColor, fillAlpha);
_arg2.moveTo(x0, y0);
_arg2.lineTo(_arg1.v1.x, _arg1.v1.y);
_arg2.lineTo(_arg1.v2.x, _arg1.v2.y);
_arg2.lineTo(x0, y0);
_arg2.endFill();
_arg3.renderStatistics.shadedTriangles++;
}
}
}//package org.papervision3d.materials.shadematerials
Section 285
//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 286
//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 updateAfterRender(_arg1:RenderSessionData, _arg2:ShaderObjectData):void;
function destroy():void;
function renderLayer(_arg1:Triangle3D, _arg2:RenderSessionData, _arg3:ShaderObjectData):void;
function renderTri(_arg1:Triangle3D, _arg2:RenderSessionData, _arg3:ShaderObjectData, _arg4:BitmapData):void;
}
}//package org.papervision3d.materials.shaders
Section 287
//ShadedMaterial (org.papervision3d.materials.shaders.ShadedMaterial)
package org.papervision3d.materials.shaders {
import flash.display.*;
import flash.utils.*;
import org.papervision3d.materials.*;
import org.papervision3d.core.render.command.*;
import org.papervision3d.core.render.data.*;
import flash.geom.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.render.material.*;
import org.papervision3d.core.log.*;
import org.papervision3d.core.render.shader.*;
import org.papervision3d.core.render.draw.*;
import org.papervision3d.core.material.*;
public class ShadedMaterial extends TriangleMaterial implements ITriangleDrawer, IUpdateBeforeMaterial, IUpdateAfterMaterial {
public var shader:Shader;
private var _shaderCompositeMode:int;
public var material:BitmapMaterial;
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();
}
override public function registerObject(_arg1:DisplayObject3D):void{
super.registerObject(_arg1);
var _local2:ShaderObjectData = (shaderObjectData[_arg1] = new ShaderObjectData(_arg1, material, this));
_local2.shaderRenderer.inputBitmap = material.bitmap;
shader.setContainerForObject(_arg1, _local2.shaderRenderer.getLayerForShader(shader));
}
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);
};
};
}
override public function drawTriangle(_arg1:RenderTriangle, _arg2:Graphics, _arg3:RenderSessionData, _arg4:BitmapData=null, _arg5:Matrix=null):void{
var _local6:ShaderObjectData = ShaderObjectData(shaderObjectData[_arg1.renderableInstance.instance]);
if (shaderCompositeMode == ShaderCompositeModes.PER_LAYER){
material.drawTriangle(_arg1, _arg2, _arg3, _local6.shaderRenderer.outputBitmap);
shader.renderLayer(_arg1.triangle, _arg3, _local6);
} else {
if (shaderCompositeMode == ShaderCompositeModes.PER_TRIANGLE_IN_BITMAP){
bmp = _local6.getOutputBitmapFor(_arg1.triangle);
material.drawTriangle(_arg1, _arg2, _arg3, bmp, (_local6.triangleUVS[_arg1.triangle]) ? _local6.triangleUVS[_arg1.triangle] : _local6.getPerTriUVForDraw(_arg1.triangle));
shader.renderTri(_arg1.triangle, _arg3, _local6, bmp);
};
};
}
private function init():void{
shaderObjectData = new Dictionary();
}
public function set shaderCompositeMode(_arg1:int):void{
_shaderCompositeMode = _arg1;
}
public function get shaderCompositeMode():int{
return (_shaderCompositeMode);
}
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 unregisterObject(_arg1:DisplayObject3D):void{
super.unregisterObject(_arg1);
var _local2:ShaderObjectData = shaderObjectData[_arg1];
_local2.destroy();
delete shaderObjectData[_arg1];
}
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);
};
};
}
}
}//package org.papervision3d.materials.shaders
Section 288
//Shader (org.papervision3d.materials.shaders.Shader)
package org.papervision3d.materials.shaders {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.render.shader.*;
import flash.filters.*;
public class Shader extends EventDispatcher implements IShader {
protected var layers:Dictionary;
protected var _blendMode:String;// = "multiply"
protected var _filter:BitmapFilter;
protected var _object:DisplayObject3D;
public function Shader(){
this.layers = new Dictionary(true);
}
public function set layerBlendMode(_arg1:String):void{
_blendMode = _arg1;
}
public function setContainerForObject(_arg1:DisplayObject3D, _arg2:Sprite):void{
layers[_arg1] = _arg2;
}
public function updateAfterRender(_arg1:RenderSessionData, _arg2:ShaderObjectData):void{
}
public function set filter(_arg1:BitmapFilter):void{
_filter = _arg1;
}
public function get layerBlendMode():String{
return (_blendMode);
}
public function get filter():BitmapFilter{
return (_filter);
}
public function destroy():void{
}
public function renderTri(_arg1:Triangle3D, _arg2:RenderSessionData, _arg3:ShaderObjectData, _arg4:BitmapData):void{
}
public function renderLayer(_arg1:Triangle3D, _arg2:RenderSessionData, _arg3:ShaderObjectData):void{
}
}
}//package org.papervision3d.materials.shaders
Section 289
//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 290
//CompositeMaterial (org.papervision3d.materials.special.CompositeMaterial)
package org.papervision3d.materials.special {
import flash.display.*;
import org.papervision3d.core.render.command.*;
import org.papervision3d.core.render.data.*;
import flash.geom.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.render.draw.*;
import org.papervision3d.core.material.*;
public class CompositeMaterial extends TriangleMaterial implements ITriangleDrawer {
public var materials:Array;
public function CompositeMaterial(){
init();
}
private function init():void{
materials = new Array();
}
override public function registerObject(_arg1:DisplayObject3D):void{
var _local2:MaterialObject3D;
super.registerObject(_arg1);
for each (_local2 in materials) {
_local2.registerObject(_arg1);
};
}
override public function drawTriangle(_arg1:RenderTriangle, _arg2:Graphics, _arg3:RenderSessionData, _arg4:BitmapData=null, _arg5:Matrix=null):void{
var _local6:MaterialObject3D;
for each (_local6 in materials) {
if (!_local6.invisible){
_local6.drawTriangle(_arg1, _arg2, _arg3);
};
};
}
public function removeAllMaterials():void{
materials = new Array();
}
override public function unregisterObject(_arg1:DisplayObject3D):void{
var _local2:MaterialObject3D;
super.unregisterObject(_arg1);
for each (_local2 in materials) {
_local2.unregisterObject(_arg1);
};
}
public function removeMaterial(_arg1:MaterialObject3D):void{
materials.splice(materials.indexOf(_arg1), 1);
}
public function addMaterial(_arg1:MaterialObject3D):void{
var _local2:Object;
var _local3:DisplayObject3D;
materials.push(_arg1);
for (_local2 in objects) {
_local3 = (_local2 as DisplayObject3D);
_arg1.registerObject(_local3);
};
}
}
}//package org.papervision3d.materials.special
Section 291
//LineMaterial (org.papervision3d.materials.special.LineMaterial)
package org.papervision3d.materials.special {
import flash.display.*;
import org.papervision3d.core.render.command.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.proto.*;
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:RenderLine, _arg2:Graphics, _arg3:RenderSessionData):void{
_arg2.lineStyle(_arg1.size, lineColor, lineAlpha);
_arg2.moveTo(_arg1.v0.x, _arg1.v0.y);
if (_arg1.cV){
_arg2.curveTo(_arg1.cV.x, _arg1.cV.y, _arg1.v1.x, _arg1.v1.y);
} else {
_arg2.lineTo(_arg1.v1.x, _arg1.v1.y);
};
_arg2.moveTo(0, 0);
_arg2.lineStyle();
}
}
}//package org.papervision3d.materials.special
Section 292
//ParticleMaterial (org.papervision3d.materials.special.ParticleMaterial)
package org.papervision3d.materials.special {
import flash.display.*;
import org.papervision3d.core.render.data.*;
import flash.geom.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.log.*;
import org.papervision3d.core.render.draw.*;
public class ParticleMaterial extends MaterialObject3D implements IParticleDrawer {
public var shape:int;
public var scale:Number;
public static var SHAPE_SQUARE:int = 0;
public static var SHAPE_CIRCLE:int = 1;
public function ParticleMaterial(_arg1:Number, _arg2:Number, _arg3:int=0, _arg4:Number=1){
this.shape = _arg3;
this.fillAlpha = _arg2;
this.fillColor = _arg1;
this.scale = _arg4;
}
public function drawParticle(_arg1:Particle, _arg2:Graphics, _arg3:RenderSessionData):void{
_arg2.beginFill(fillColor, fillAlpha);
var _local4:Rectangle = _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++;
}
public function updateRenderRect(_arg1:Particle):void{
var _local2:Rectangle = _arg1.renderRect;
if (_arg1.size == 0){
_local2.width = 1;
_local2.height = 1;
} else {
_local2.width = ((_arg1.renderScale * _arg1.size) * scale);
_local2.height = ((_arg1.renderScale * _arg1.size) * scale);
};
_local2.x = (_arg1.vertex3D.vertex3DInstance.x - (_local2.width / 2));
_local2.y = (_arg1.vertex3D.vertex3DInstance.y - (_local2.width / 2));
}
}
}//package org.papervision3d.materials.special
Section 293
//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:uint, _arg2:uint, _arg3:uint):BitmapData{
var _local4:BitmapData = new BitmapData(0x0100, 3, false, 0xFFFFFF);
var _local5:Sprite = new Sprite();
var _local6:Matrix = new Matrix();
_local6.createGradientBox(0x0100, 3, 0, 0, 0);
_local5.graphics.beginGradientFill(GradientType.LINEAR, [_arg2, _arg2, _arg1], [1, 1, 1], [0, _arg3, 0xFF], _local6);
_local5.graphics.drawRect(0, 0, 0x0100, 3);
_local5.graphics.endFill();
_local4.draw(_local5);
return (_local4);
}
public static function getPhongMap(_arg1:uint, _arg2:uint, _arg3:uint, _arg4:int=0xFF, _arg5:int=0xFF):BitmapData{
var _local6:Number = _arg4;
var _local7:Number = _arg5;
var _local8:Sprite = new Sprite();
var _local9:Matrix = 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();
var _local10:BitmapData = new BitmapData(_local6, _local6, false, 0xFF);
_local10.draw(_local8);
return (_local10);
}
public static function getCellMap(_arg1:uint, _arg2:uint, _arg3:int):BitmapData{
var _local4:BitmapData = LightMaps.getPhongMap(_arg1, _arg2, 0, 0xFF, 0xFF);
var _local5:Number = 0;
var _local6 = ((_arg1 & 0xFF0000) >> 16);
var _local7 = ((_arg2 & 0xFF0000) >> 16);
var _local8:int = (_local7 - _local6);
var _local9:Array = new Array();
var _local10:Array = new Array();
var _local11:Array = new Array();
var _local12:int;
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:uint, _arg2:uint, _arg3:uint):BitmapData{
var _local4:BitmapData = new BitmapData(0xFF, 3, false, 0xFFFFFF);
var _local5:Sprite = new Sprite();
var _local6:Matrix = new Matrix();
_local6.createGradientBox(0xFF, 3, 0, 0, 0);
_local5.graphics.beginGradientFill(GradientType.LINEAR, [_arg2, _arg2, _arg1], [1, 1, 1], [0, _arg3, 0xFF], _local6);
_local5.graphics.drawRect(0, 0, 0xFF, 3);
_local5.graphics.endFill();
_local4.draw(_local5);
return (_local4);
}
public static function getFlatMapArray(_arg1:uint, _arg2:uint, _arg3:uint):Array{
var _local4:Array = new Array();
var _local5:BitmapData = new BitmapData(0x0100, 1, false, 0);
var _local6:Sprite = new Sprite();
var _local7:Matrix = new Matrix();
_local7.createGradientBox(0x0100, 1, 0, 0, 0);
_local6.graphics.beginGradientFill(GradientType.LINEAR, [_arg1, _arg2, _arg2], [1, 1, 1], [0, (0xFF - _arg3), 0xFF], _local7);
_local6.graphics.drawRect(0, 0, 0x0100, 1);
_local6.graphics.endFill();
_local5.draw(_local6);
var _local8 = 0x0100;
while (_local8--) {
_local4.push(_local5.getPixel(_local8, 0));
};
_local5.dispose();
return (_local4);
}
public static function getFlatMap(_arg1:uint, _arg2:uint, _arg3:uint):BitmapData{
var _local4:BitmapData = new BitmapData(0xFF, 1, false, 0);
var _local5:Sprite = new Sprite();
var _local6:Matrix = new Matrix();
_local6.createGradientBox(0xFF, 1, 0, 0, 0);
_local5.graphics.beginGradientFill(GradientType.LINEAR, [_arg2, _arg2, _arg1], [1, 1, 1], [0, (0xFF - _arg3), 0xFF], _local6);
_local5.graphics.drawRect(0, 0, 0xFF, 1);
_local5.graphics.endFill();
_local4.draw(_local5);
return (_local4);
}
}
}//package org.papervision3d.materials.utils
Section 294
//LightMatrix (org.papervision3d.materials.utils.LightMatrix)
package org.papervision3d.materials.utils {
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.math.*;
import org.papervision3d.lights.*;
import org.papervision3d.*;
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 _local6:Matrix3D;
var _local7:Matrix3D;
var _local5:Matrix3D = (_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 295
//MaterialsList (org.papervision3d.materials.utils.MaterialsList)
package org.papervision3d.materials.utils {
import flash.utils.*;
import org.papervision3d.core.proto.*;
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 _local2:MaterialObject3D;
var _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 _local2:MaterialObject3D;
var _local1:MaterialsList = 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 296
//PrecisionMode (org.papervision3d.materials.utils.PrecisionMode)
package org.papervision3d.materials.utils {
public class PrecisionMode {
public static var ORIGINAL:int = 0;
public static var STABLE:int = 1;
}
}//package org.papervision3d.materials.utils
Section 297
//RenderRecStorage (org.papervision3d.materials.utils.RenderRecStorage)
package org.papervision3d.materials.utils {
import flash.geom.*;
import org.papervision3d.core.geom.renderables.*;
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 298
//BitmapMaterial (org.papervision3d.materials.BitmapMaterial)
package org.papervision3d.materials {
import flash.display.*;
import flash.utils.*;
import org.papervision3d.materials.utils.*;
import org.papervision3d.core.render.command.*;
import org.papervision3d.core.render.data.*;
import flash.geom.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.log.*;
import org.papervision3d.core.render.draw.*;
import org.papervision3d.core.material.*;
import org.papervision3d.*;
public class BitmapMaterial extends TriangleMaterial implements ITriangleDrawer {
protected var renderRecStorage:Array;
protected var dsbc:Number;
private var d2bc:Number;
private var b2:Number;
public var uvMatrices:Dictionary;
protected var _precise:Boolean;
protected var faz:Number;
protected var dsca:Number;
protected var ax:Number;
protected var ay:Number;
protected var az:Number;
private var d2ca:Number;
protected var tempPreGrp:Graphics;
public var precisionMode:int;
protected var fbz:Number;
private var c2:Number;
protected var mcax:Number;
protected var mcay:Number;
protected var mcaz:Number;
private var d2:Number;
protected var bx:Number;
protected var by:Number;
protected var bz:Number;
protected var fcz:Number;
public var minimumRenderSize:Number;// = 4
protected var dbcx:Number;
protected var dbcy:Number;
protected var cx:Number;
protected var cullRect:Rectangle;
protected var cz:Number;
protected var cy:Number;
protected var dmax:Number;
protected var dabx:Number;
private var dy:Number;
protected var _perPixelPrecision:int;// = 8
protected var daby:Number;
protected var tempPreRSD:RenderSessionData;
private var dx:Number;
private var x0:Number;
private var x1:Number;
private var x2:Number;
protected var mbcy:Number;
protected var mbcz:Number;
protected var mbcx:Number;
private var y0:Number;
protected var focus:Number;// = 200
private var y2:Number;
protected var _texture:Object;
protected var tempPreBmp:BitmapData;
private var y1:Number;
protected var tempTriangleMatrix:Matrix;
protected var maby:Number;
protected var mabz:Number;
private var d2ab:Number;
protected var dsab:Number;
protected var mabx:Number;
protected var dcax:Number;
protected var dcay: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){
precisionMode = PrecisionMode.ORIGINAL;
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] = _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);
}
public function transformUVRT(_arg1:RenderTriangle):Matrix{
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:Matrix;
var _local15:Matrix;
if (bitmap){
_local2 = (bitmap.width * maxU);
_local3 = (bitmap.height * maxV);
_local4 = (_local2 * _arg1.uv0.u);
_local5 = (_local3 * (1 - _arg1.uv0.v));
_local6 = (_local2 * _arg1.uv1.u);
_local7 = (_local3 * (1 - _arg1.uv1.v));
_local8 = (_local2 * _arg1.uv2.u);
_local9 = (_local3 * (1 - _arg1.uv2.v));
if ((((((_local4 == _local6)) && ((_local5 == _local7)))) || ((((_local4 == _local8)) && ((_local5 == _local9)))))){
_local4 = (_local4 - ((_local4)>0.05) ? 0.05 : -0.05);
_local5 = (_local5 - ((_local5)>0.07) ? 0.07 : -0.07);
};
if ((((_local8 == _local6)) && ((_local9 == _local7)))){
_local8 = (_local8 - ((_local8)>0.05) ? 0.04 : -0.04);
_local9 = (_local9 - ((_local9)>0.06) ? 0.06 : -0.06);
};
_local10 = (_local6 - _local4);
_local11 = (_local7 - _local5);
_local12 = (_local8 - _local4);
_local13 = (_local9 - _local5);
_local14 = new Matrix(_local10, _local11, _local12, _local13, _local4, _local5);
if (Papervision3D.useRIGHTHANDED){
_local14.scale(-1, 1);
_local14.translate(_local2, 0);
};
_local14.invert();
_local15 = (uvMatrices[_arg1] = _local14.clone());
_local15.a = _local14.a;
_local15.b = _local14.b;
_local15.c = _local14.c;
_local15.d = _local14.d;
_local15.tx = _local14.tx;
_local15.ty = _local14.ty;
} else {
PaperLogger.error("MaterialObject3D: transformUV() material.bitmap not found!");
};
return (_local15);
}
protected function renderRec(_arg1:Matrix, _arg2:Vertex3DInstance, _arg3:Vertex3DInstance, _arg4:Vertex3DInstance, _arg5:Number):void{
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));
var _local6:int = (_arg5 + 1);
var _local7:RenderRecStorage = RenderRecStorage(renderRecStorage[int(_arg5)]);
var _local8:Matrix = _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;
};
if (precisionMode == PrecisionMode.ORIGINAL){
d2ab = dsab;
d2bc = dsbc;
d2ca = dsca;
dmax = ((dsca > dsbc)) ? ((dsca > dsab)) ? dsca : dsab : ((dsbc > dsab)) ? dsbc : dsab;
} else {
dx = (_arg2.x - _arg3.x);
dy = (_arg2.y - _arg3.y);
d2ab = ((dx * dx) + (dy * dy));
dx = (_arg3.x - _arg4.x);
dy = (_arg3.y - _arg4.y);
d2bc = ((dx * dx) + (dy * dy));
dx = (_arg4.x - _arg2.x);
dy = (_arg4.y - _arg2.y);
d2ca = ((dx * dx) + (dy * dy));
dmax = ((d2ca > d2bc)) ? ((d2ca > d2ab)) ? d2ca : d2ab : ((d2bc > d2ab)) ? d2bc : d2ab;
};
if (d2ab == 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 (d2ca == 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{
this.renderRecStorage = new Array();
var _local1:int;
while (_local1 <= 100) {
this.renderRecStorage[_local1] = new RenderRecStorage();
_local1++;
};
}
public function get texture():Object{
return (this._texture);
}
public function resetUVS():void{
uvMatrices = new Dictionary(false);
}
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 = (1 << MIP_MAP_DEPTH);
var _local4:Number = (_arg1.width / _local3);
_local4 = ((_local4 == uint(_local4))) ? _local4 : (uint(_local4) + 1);
var _local5:Number = (_arg1.height / _local3);
_local5 = ((_local5 == uint(_local5))) ? _local5 : (uint(_local5) + 1);
var _local6:Number = (_local3 * _local4);
var _local7:Number = (_local3 * _local5);
var _local8:Boolean;
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);
}
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;
}
override public function clone():MaterialObject3D{
var _local1:MaterialObject3D = super.clone();
_local1.maxU = this.maxU;
_local1.maxV = this.maxV;
return (_local1);
}
override public function drawTriangle(_arg1:RenderTriangle, _arg2:Graphics, _arg3:RenderSessionData, _arg4:BitmapData=null, _arg5:Matrix=null):void{
_triMap = (_arg5) ? _arg5 : ((uvMatrices[_arg1]) || (transformUVRT(_arg1)));
if (((!(_precise)) || (!(_triMap)))){
if (lineAlpha){
_arg2.lineStyle(lineThickness, lineColor, lineAlpha);
};
if (bitmap){
x0 = _arg1.v0.x;
y0 = _arg1.v0.y;
x1 = _arg1.v1.x;
y1 = _arg1.v1.y;
x2 = _arg1.v2.x;
y2 = _arg1.v2.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){
focus = _arg3.camera.focus;
tempPreBmp = (_arg4) ? _arg4 : bitmap;
tempPreRSD = _arg3;
tempPreGrp = _arg2;
cullRect = _arg3.viewPort.cullingRectangle;
renderRec(_triMap, _arg1.v0, _arg1.v1, _arg1.v2, 0);
};
};
}
public function get precision():int{
return (_precision);
}
public function resetMapping():void{
uvMatrices = new Dictionary();
}
override public function copy(_arg1:MaterialObject3D):void{
super.copy(_arg1);
this.maxU = _arg1.maxU;
this.maxV = _arg1.maxV;
}
override public function toString():String{
return (((((("Texture:" + this.texture) + " lineColor:") + this.lineColor) + " lineAlpha:") + this.lineAlpha));
}
public function get pixelPrecision():int{
return (_perPixelPrecision);
}
public function set precise(_arg1:Boolean):void{
_precise = _arg1;
}
protected function extendBitmapEdges(_arg1:BitmapData, _arg2:Number, _arg3:Number):void{
var _local6:int;
var _local4:Rectangle = new Rectangle();
var _local5:Point = 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 299
//MovieMaterial (org.papervision3d.materials.MovieMaterial)
package org.papervision3d.materials {
import flash.display.*;
import org.papervision3d.core.render.command.*;
import org.papervision3d.core.render.data.*;
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 quality:String;
private var materialIsUsed:Boolean;// = false
private var stage:Stage;
private var autoClipRect:Rectangle;
public var allowAutoResize:Boolean;// = false
public var movie:DisplayObject;
private var movieAnimated:Boolean;
protected var recreateBitmapInSuper:Boolean;
private var userClipRect:Rectangle;
public function MovieMaterial(_arg1:DisplayObject=null, _arg2:Boolean=false, _arg3:Boolean=false, _arg4:Boolean=false, _arg5:Rectangle=null){
movieTransparent = _arg2;
this.animated = _arg3;
this.precise = _arg4;
userClipRect = _arg5;
if (_arg1){
texture = _arg1;
};
}
protected function createBitmapFromSprite(_arg1:DisplayObject):BitmapData{
movie = _arg1;
initBitmap(movie);
drawBitmap();
bitmap = super.createBitmap(bitmap);
return (bitmap);
}
public function set rect(_arg1:Rectangle):void{
userClipRect = _arg1;
createBitmapFromSprite(movie);
}
public function updateAfterRender(_arg1:RenderSessionData):void{
if ((((movieAnimated == true)) && ((materialIsUsed == true)))){
drawBitmap();
if (recreateBitmapInSuper){
bitmap = super.createBitmap(bitmap);
recreateBitmapInSuper = false;
};
};
}
public function set animated(_arg1:Boolean):void{
movieAnimated = _arg1;
}
public function drawBitmap():void{
var _local3:String;
bitmap.fillRect(bitmap.rect, fillColor);
if (((stage) && (quality))){
_local3 = stage.quality;
stage.quality = quality;
};
var _local1:Rectangle = rect;
var _local2:Matrix = 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 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;
};
};
}
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 get rect():Rectangle{
var _local1:Rectangle = ((userClipRect) || (autoClipRect));
if (((!(_local1)) && (movie))){
_local1 = movie.getBounds(movie);
};
return (_local1);
}
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;
}
override public function drawTriangle(_arg1:RenderTriangle, _arg2:Graphics, _arg3:RenderSessionData, _arg4:BitmapData=null, _arg5:Matrix=null):void{
materialIsUsed = true;
super.drawTriangle(_arg1, _arg2, _arg3, _arg4, _arg5);
}
public function setQuality(_arg1:String, _arg2:Stage, _arg3:Boolean=true):void{
this.quality = _arg1;
this.stage = _arg2;
if (_arg3){
createBitmapFromSprite(movie);
};
}
}
}//package org.papervision3d.materials
Section 300
//WireframeMaterial (org.papervision3d.materials.WireframeMaterial)
package org.papervision3d.materials {
import flash.display.*;
import org.papervision3d.core.render.command.*;
import org.papervision3d.core.render.data.*;
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:RenderTriangle, _arg2:Graphics, _arg3:RenderSessionData, _arg4:BitmapData=null, _arg5:Matrix=null):void{
var _local6:Number = _arg1.v0.x;
var _local7:Number = _arg1.v0.y;
if (lineAlpha){
_arg2.lineStyle(lineThickness, lineColor, lineAlpha);
_arg2.moveTo(_local6, _local7);
_arg2.lineTo(_arg1.v1.x, _arg1.v1.y);
_arg2.lineTo(_arg1.v2.x, _arg1.v2.y);
_arg2.lineTo(_local6, _local7);
_arg2.lineStyle();
_arg3.renderStatistics.triangles++;
};
}
}
}//package org.papervision3d.materials
Section 301
//Cube (org.papervision3d.objects.primitives.Cube)
package org.papervision3d.objects.primitives {
import org.papervision3d.materials.utils.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.math.*;
import org.papervision3d.core.log.*;
import org.papervision3d.core.geom.*;
import org.papervision3d.*;
public class Cube extends TriangleMesh3D {
public var segments:Number3D;
private var insideFaces:int;
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);
}
public function destroy():void{
var _local1:MaterialObject3D;
for each (_local1 in materials) {
_local1.unregisterObject(this);
};
}
protected function buildCube(_arg1:Number, _arg2:Number, _arg3:Number):void{
var _local7:Triangle3D;
var _local4:Number = (_arg1 / 2);
var _local5:Number = (_arg2 / 2);
var _local6:Number = (_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();
for each (_local7 in this.geometry.faces) {
_local7.renderCommand.create = createRenderTriangle;
};
this.geometry.ready = true;
if (Papervision3D.useRIGHTHANDED){
this.geometry.flipFaces();
};
}
protected 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 _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";
};
};
};
var _local10:Number = (_arg7) ? -1 : 1;
var _local11:Number = this.segments[_arg2];
var _local12:Number = this.segments[_arg3];
var _local13:Number = (_local11 + 1);
var _local14:Number = (_local12 + 1);
var _local15:Array = this.geometry.vertices;
var _local16:Array = this.geometry.faces;
var _local17:Array = new Array();
var _local18:Number = (_arg4 / 2);
var _local19:Number = (_arg5 / 2);
var _local20:Number = (_arg4 / _local11);
var _local21:Number = (_arg5 / _local12);
var _local22:int;
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++;
};
}
}
}//package org.papervision3d.objects.primitives
Section 302
//Plane (org.papervision3d.objects.primitives.Plane)
package org.papervision3d.objects.primitives {
import org.papervision3d.core.proto.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.math.*;
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){
super(_arg1, new Array(), new Array(), null);
this.segmentsW = ((_arg4) || (DEFAULT_SEGMENTS));
this.segmentsH = ((_arg5) || (this.segmentsW));
var _local6:Number = 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 _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;
var _local3:Number = this.segmentsW;
var _local4:Number = this.segmentsH;
var _local5:Number = (_local3 + 1);
var _local6:Number = (_local4 + 1);
var _local7:Array = this.geometry.vertices;
var _local8:Array = this.geometry.faces;
var _local9:Number = (_arg1 / 2);
var _local10:Number = (_arg2 / 2);
var _local11:Number = (_arg1 / _local3);
var _local12:Number = (_arg2 / _local4);
var _local13:int;
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 303
//Sphere (org.papervision3d.objects.primitives.Sphere)
package org.papervision3d.objects.primitives {
import org.papervision3d.core.proto.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.math.*;
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){
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;
};
var _local5:Number = DEFAULT_SCALE;
buildSphere(_arg2);
}
private function buildSphere(_arg1:Number):void{
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local11:Triangle3D;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Array;
var _local16:Vertex3D;
var _local17:Number;
var _local18:Number;
var _local19:Number;
var _local20:int;
var _local21:Boolean;
var _local22:Vertex3D;
var _local23:Vertex3D;
var _local24:Vertex3D;
var _local25:Vertex3D;
var _local26:Number;
var _local27:Number;
var _local28:Number;
var _local29:Number;
var _local30:NumberUV;
var _local31:NumberUV;
var _local32:NumberUV;
var _local33:NumberUV;
var _local5:Number = Math.max(3, this.segmentsW);
var _local6:Number = Math.max(2, this.segmentsH);
var _local7:Array = this.geometry.vertices;
var _local8:Array = this.geometry.faces;
var _local9:Array = new Array();
_local3 = 0;
while (_local3 < (_local6 + 1)) {
_local12 = Number((_local3 / _local6));
_local13 = (-(_arg1) * Math.cos((_local12 * Math.PI)));
_local14 = (_arg1 * Math.sin((_local12 * Math.PI)));
_local15 = new Array();
_local2 = 0;
while (_local2 < _local5) {
_local17 = Number(((2 * _local2) / _local5));
_local18 = (_local14 * Math.sin((_local17 * Math.PI)));
_local19 = (_local14 * Math.cos((_local17 * Math.PI)));
if (!(((((_local3 == 0)) || ((_local3 == _local6)))) && ((_local2 > 0)))){
_local16 = new Vertex3D(_local19, _local13, _local18);
_local7.push(_local16);
};
_local15.push(_local16);
_local2++;
};
_local9.push(_local15);
_local3++;
};
var _local10:int = _local9.length;
_local3 = 0;
while (_local3 < _local10) {
_local20 = _local9[_local3].length;
if (_local3 > 0){
_local2 = 0;
while (_local2 < _local20) {
_local21 = (_local2 == (_local20 - 1));
_local22 = _local9[_local3][(_local21) ? 0 : (_local2 + 1)];
_local23 = _local9[_local3][(_local21) ? (_local20 - 1) : _local2];
_local24 = _local9[(_local3 - 1)][(_local21) ? (_local20 - 1) : _local2];
_local25 = _local9[(_local3 - 1)][(_local21) ? 0 : (_local2 + 1)];
_local26 = (_local3 / (_local10 - 1));
_local27 = ((_local3 - 1) / (_local10 - 1));
_local28 = ((_local2 + 1) / _local20);
_local29 = (_local2 / _local20);
_local30 = new NumberUV(_local28, _local27);
_local31 = new NumberUV(_local28, _local26);
_local32 = new NumberUV(_local29, _local26);
_local33 = new NumberUV(_local29, _local27);
if (_local3 < (_local9.length - 1)){
_local8.push(new Triangle3D(this, new Array(_local22, _local23, _local24), material, new Array(_local31, _local32, _local33)));
};
if (_local3 > 1){
_local8.push(new Triangle3D(this, new Array(_local22, _local24, _local25), material, new Array(_local31, _local33, _local30)));
};
_local2++;
};
};
_local3++;
};
for each (_local11 in _local8) {
_local11.renderCommand.create = createRenderTriangle;
};
this.geometry.ready = true;
if (Papervision3D.useRIGHTHANDED){
this.geometry.flipFaces();
};
}
}
}//package org.papervision3d.objects.primitives
Section 304
//DisplayObject3D (org.papervision3d.objects.DisplayObject3D)
package org.papervision3d.objects {
import org.papervision3d.materials.utils.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.data.*;
import org.papervision3d.core.math.*;
import org.papervision3d.view.layer.*;
import org.papervision3d.view.*;
import org.papervision3d.core.log.*;
import org.papervision3d.materials.shaders.*;
import org.papervision3d.core.material.*;
import org.papervision3d.*;
public class DisplayObject3D extends DisplayObjectContainer3D {
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 cullTest:Number;// = 0
private var _lookatTarget:Number3D;
public var materials:MaterialsList;
public var meshSort:uint;// = 1
private var _rotationX:Number;
private var _qYaw:Quaternion;
private var _xAxis:Number3D;
private var _zAxis:Number3D;
private var _scaleDirty:Boolean;// = false
private var _autoCalcScreenCoords:Boolean;// = false
private var _tempScale:Number3D;
private var _numClones:uint;// = 0
public var alpha:Number;// = 1
public var useClipping:Boolean;// = true
public var screen:Number3D;
private var _scaleX:Number;
private var _scaleY:Number;
private var _scaleZ:Number;
public var geometry:GeometryObject3D;
private var _qPitch:Quaternion;
public var visible:Boolean;
protected var _userData:UserData;
public var screenZ:Number;
public var container:ViewportLayer;
protected var _useOwnContainer:Boolean;// = false
public var transform:Matrix3D;
private var _material:MaterialObject3D;
private var _position:Number3D;
public var name:String;
protected var _scene:SceneObject3D;// = null
private var _qRoll:Quaternion;
private var _localRotationZ:Number;// = 0
public var culled:Boolean;
public var world:Matrix3D;
public var blendMode:String;// = "normal"
private var _localRotationX:Number;// = 0
private var _localRotationY:Number;// = 0
public var view:Matrix3D;
public var parent:DisplayObjectContainer3D;
public var faces:Array;
private var _yAxis:Number3D;
public var flipLightDirection:Boolean;// = false
private var _rotation:Number3D;
protected var _transformDirty:Boolean;// = false
protected var _sorted:Array;
private var _rotationDirty:Boolean;// = false
public var parentContainer:DisplayObject3D;
public var testQuad:Boolean;// = true
public var filters:Array;
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{
faces = new Array();
filters = [];
screen = new Number3D();
_position = Number3D.ZERO;
_lookatTarget = Number3D.ZERO;
_zAxis = Number3D.ZERO;
_xAxis = Number3D.ZERO;
_yAxis = Number3D.ZERO;
_rotation = Number3D.ZERO;
_rot = new Quaternion();
_qPitch = new Quaternion();
_qYaw = new Quaternion();
_qRoll = new Quaternion();
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));
var _local3:Number = (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 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 y(_arg1:Number):void{
this.transform.n24 = _arg1;
}
public function set z(_arg1:Number):void{
this.transform.n34 = _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 setChildMaterialByName(_arg1:String, _arg2:MaterialObject3D):void{
setChildMaterial(getChildByName(_arg1, true), _arg2);
}
public function moveDown(_arg1:Number):void{
translate(_arg1, DOWN);
}
public function project(_arg1:DisplayObject3D, _arg2:RenderSessionData):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);
};
} else {
this.culled = false;
};
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);
};
var _local3:Number = 0;
var _local4:Number = 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 setChildMaterial(_arg1:DisplayObject3D, _arg2:MaterialObject3D, _arg3:MaterialObject3D=null):void{
var _local4:Triangle3D;
if (!_arg1){
return;
};
if (((!(_arg3)) || ((_arg1.material === _arg3)))){
_arg1.material = _arg2;
};
if (((_arg1.geometry) && (_arg1.geometry.faces))){
for each (_local4 in _arg1.geometry.faces) {
if (((!(_arg3)) || ((_local4.material === _arg3)))){
_local4.material = _arg2;
};
};
};
}
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 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 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)){
_lookatTarget.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);
};
_lookatTarget.reset(_arg1.world.n14, _arg1.world.n24, _arg1.world.n34);
};
_zAxis.copyFrom(_lookatTarget);
_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 rotationZ(_arg1:Number):void{
this._rotationZ = (Papervision3D.useDEGREES) ? (_arg1 * toRADIANS) : _arg1;
this._transformDirty = true;
}
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 function set rotationY(_arg1:Number):void{
this._rotationY = (Papervision3D.useDEGREES) ? (_arg1 * toRADIANS) : _arg1;
this._transformDirty = true;
}
public function get position():Number3D{
_position.reset(this.x, this.y, this.z);
return (_position);
}
public function get sceneX():Number{
return (this.world.n14);
}
public function get scaleX():Number{
if (Papervision3D.usePERCENT){
return ((this._scaleX * 100));
};
return (this._scaleX);
}
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 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 position(_arg1:Number3D):void{
this.x = _arg1.x;
this.y = _arg1.y;
this.z = _arg1.z;
}
public function moveUp(_arg1:Number):void{
translate(_arg1, UP);
}
public function get sceneZ():Number{
return (this.world.n34);
}
public function get sceneY():Number{
return (this.world.n24);
}
public function distanceTo(_arg1:DisplayObject3D):Number{
var _local2:Number = (this.x - _arg1.x);
var _local3:Number = (this.y - _arg1.y);
var _local4:Number = (this.z - _arg1.z);
return (Math.sqrt((((_local2 * _local2) + (_local3 * _local3)) + (_local4 * _local4))));
}
public function addGeometry(_arg1:GeometryObject3D=null):void{
if (_arg1){
this.geometry = _arg1;
};
}
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);
};
}
private function updateMaterials(_arg1:DisplayObject3D, _arg2:MaterialObject3D, _arg3:MaterialObject3D):void{
var _local4:DisplayObject3D;
var _local5:Triangle3D;
_arg2.unregisterObject(_arg1);
if ((((_arg3 is AbstractLightShadeMaterial)) || ((_arg3 is ShadedMaterial)))){
_arg3.registerObject(_arg1);
};
if (_arg1.material === _arg2){
_arg1.material = _arg3;
};
if (((((_arg1.geometry) && (_arg1.geometry.faces))) && (_arg1.geometry.faces.length))){
for each (_local5 in _arg1.geometry.faces) {
if (_local5.material === _arg2){
_local5.material = _arg3;
};
};
};
for each (_local4 in _arg1.children) {
updateMaterials(_local4, _arg2, _arg3);
};
}
public function clone():DisplayObject3D{
var _local3:DisplayObject3D;
var _local1:String = ((this.name + "_") + _numClones++);
var _local2:DisplayObject3D = 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 set material(_arg1:MaterialObject3D):void{
if (_material){
_material.unregisterObject(this);
};
_material = _arg1;
if (_material){
_material.registerObject(this);
};
}
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 = (this.x - _arg1.x);
var _local4:Number = (this.y - _arg1.y);
var _local5:Number = (this.z - _arg1.z);
var _local6:Number = (((_local3 * _local3) + (_local4 * _local4)) + (_local5 * _local5));
var _local7:Number = (this.geometry) ? this.geometry.boundingSphere.maxDistance : 0;
var _local8:Number = (_arg1.geometry) ? _arg1.geometry.boundingSphere.maxDistance : 0;
_local7 = (_local7 * _arg2);
return (((_local7 + _local8) > _local6));
}
public function translate(_arg1:Number, _arg2:Number3D):void{
var _local3:Number3D = _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 get localRotationZ():Number{
return ((Papervision3D.useDEGREES) ? (_localRotationZ * toDEGREES) : _localRotationZ);
}
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 get y():Number{
return (this.transform.n24);
}
public function moveLeft(_arg1:Number):void{
translate(_arg1, LEFT);
}
public function replaceMaterialByName(_arg1:MaterialObject3D, _arg2:String):void{
if (!this.materials){
return;
};
var _local3:MaterialObject3D = this.materials.getMaterialByName(_arg2);
if (!_local3){
return;
};
if (this.material === _local3){
this.material = _arg1;
};
_local3 = this.materials.removeMaterial(_local3);
_arg1 = this.materials.addMaterial(_arg1, _arg2);
updateMaterials(this, _local3, _arg1);
}
public function get scene():SceneObject3D{
return (_scene);
}
public function set useOwnContainer(_arg1:Boolean):void{
_useOwnContainer = _arg1;
setParentContainer(this, true);
}
public function getMaterialByName(_arg1:String):MaterialObject3D{
var _local3:DisplayObject3D;
var _local2:MaterialObject3D = (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 copyTransform(_arg1):void{
var _local4:DisplayObject3D;
if ((_arg1 is DisplayObject3D)){
_local4 = DisplayObject3D(_arg1);
if (_local4._transformDirty){
_local4.updateTransform();
};
};
var _local2:Matrix3D = this.transform;
var _local3:Matrix3D = ((_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 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 set scaleY(_arg1:Number):void{
if (this._rotationDirty){
updateRotation();
};
if (Papervision3D.usePERCENT){
this._scaleY = (_arg1 / 100);
} else {
this._scaleY = _arg1;
};
this._transformDirty = true;
}
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 (this._rotationDirty){
updateRotation();
};
if (Papervision3D.usePERCENT){
this._scaleZ = (_arg1 / 100);
} else {
this._scaleZ = _arg1;
};
this._transformDirty = true;
}
public function get rotationX():Number{
if (this._rotationDirty){
updateRotation();
};
return ((Papervision3D.useDEGREES) ? (this._rotationX * toDEGREES) : this._rotationX);
}
public function set scale(_arg1:Number):void{
if (this._rotationDirty){
updateRotation();
};
if (Papervision3D.usePERCENT){
_arg1 = (_arg1 / 100);
};
this._scaleX = (this._scaleY = (this._scaleZ = _arg1));
this._transformDirty = true;
}
public function get autoCalcScreenCoords():Boolean{
return (_autoCalcScreenCoords);
}
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 set scaleX(_arg1:Number):void{
if (this._rotationDirty){
updateRotation();
};
if (Papervision3D.usePERCENT){
this._scaleX = (_arg1 / 100);
} else {
this._scaleX = _arg1;
};
this._transformDirty = true;
}
public function createViewportLayer(_arg1:Viewport3D, _arg2:Boolean=true):ViewportLayer{
var _local3:ViewportLayer = _arg1.getChildLayer(this, true);
if (_arg2){
addChildrenToLayer(this, _local3);
};
return (_local3);
}
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 moveForward(_arg1:Number):void{
translate(_arg1, FORWARD);
}
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 = this.transform;
var _local3:Matrix3D = ((_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 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 hitTestPoint(_arg1:Number, _arg2:Number, _arg3:Number):Boolean{
var _local4:Number = (this.x - _arg1);
var _local5:Number = (this.y - _arg2);
var _local6:Number = (this.z - _arg3);
var _local7:Number = (((_local4 * _local4) + (_local5 * _local5)) + (_local6 * _local6));
var _local8:Number = (this.geometry) ? this.geometry.boundingSphere.maxDistance : 0;
return ((_local8 > _local7));
}
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 moveRight(_arg1:Number):void{
translate(_arg1, RIGHT);
}
public function set x(_arg1:Number):void{
this.transform.n14 = _arg1;
}
public function materialsList():String{
var _local2:String;
var _local3:DisplayObject3D;
var _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 autoCalcScreenCoords(_arg1:Boolean):void{
_autoCalcScreenCoords = _arg1;
}
public static function get ZERO():DisplayObject3D{
return (new (DisplayObject3D));
}
}
}//package org.papervision3d.objects
Section 305
//BasicRenderEngine (org.papervision3d.render.BasicRenderEngine)
package org.papervision3d.render {
import org.papervision3d.core.render.command.*;
import org.papervision3d.core.render.data.*;
import flash.geom.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.view.layer.*;
import org.papervision3d.view.*;
import org.papervision3d.core.render.material.*;
import org.papervision3d.core.render.*;
import org.papervision3d.core.clipping.*;
import org.papervision3d.core.utils.*;
import org.papervision3d.events.*;
import org.papervision3d.core.render.sort.*;
import org.papervision3d.core.render.project.*;
import org.papervision3d.core.render.filter.*;
public class BasicRenderEngine extends AbstractRenderEngine implements IRenderEngine {
public var clipping:DefaultClipping;
protected var renderDoneEvent:RendererEvent;
public var sorter:IRenderSorter;
public var projectionPipeline:ProjectionPipeline;
protected var renderList:Array;
protected var renderStatistics:RenderStatistics;
protected var cleanRHD:RenderHitData;
protected var projectionDoneEvent:RendererEvent;
protected var renderSessionData:RenderSessionData;
protected var stopWatch:StopWatch;
public var filter:IRenderFilter;
public function BasicRenderEngine():void{
cleanRHD = new RenderHitData();
super();
init();
}
protected function doRender(_arg1:RenderSessionData, _arg2:Array=null):RenderStatistics{
var _local3:RenderableListItem;
var _local5:ViewportLayer;
stopWatch.reset();
stopWatch.start();
MaterialManager.getInstance().updateMaterialsBeforeRender(_arg1);
filter.filter(renderList);
sorter.sort(renderList);
var _local4:Viewport3D = _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();
clipping = null;
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):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();
renderSessionData.clipping = clipping;
if (clipping){
clipping.reset(renderSessionData);
};
_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 removeFromRenderList(_arg1:IRenderListItem):int{
return (renderList.splice(renderList.indexOf(_arg1), 1));
}
override public function addToRenderList(_arg1:RenderableListItem):int{
return (renderList.push(_arg1));
}
private function getLayerObjects(_arg1:Array):Array{
var _local3:ViewportLayer;
var _local2:Array = 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;
clipping = null;
}
public function renderLayers(_arg1:SceneObject3D, _arg2:CameraObject3D, _arg3:Viewport3D, _arg4:Array=null):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();
renderSessionData.clipping = clipping;
_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);
}
}
}//package org.papervision3d.render
Section 306
//Scene3D (org.papervision3d.scenes.Scene3D)
package org.papervision3d.scenes {
import org.papervision3d.core.proto.*;
public class Scene3D extends SceneObject3D {
}
}//package org.papervision3d.scenes
Section 307
//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 ORIGIN_SORT:String = "origin";
public static var INDEX_SORT:String = "index";
}
}//package org.papervision3d.view.layer.util
Section 308
//ViewportBaseLayer (org.papervision3d.view.layer.ViewportBaseLayer)
package org.papervision3d.view.layer {
import org.papervision3d.objects.*;
import org.papervision3d.view.*;
public class ViewportBaseLayer extends ViewportLayer {
public function ViewportBaseLayer(_arg1:Viewport3D){
super(_arg1, null);
}
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);
}
override public function updateBeforeRender():void{
clear();
var _local1:int = (childLayers.length - 1);
while (_local1 >= 0) {
if (childLayers[_local1].dynamicLayer){
removeLayerAt(_local1);
};
_local1--;
};
super.updateBeforeRender();
}
}
}//package org.papervision3d.view.layer
Section 309
//ViewportLayer (org.papervision3d.view.layer.ViewportLayer)
package org.papervision3d.view.layer {
import flash.display.*;
import flash.utils.*;
import org.papervision3d.core.render.command.*;
import org.papervision3d.objects.*;
import org.papervision3d.view.*;
import org.papervision3d.core.log.*;
import org.papervision3d.view.layer.util.*;
public class ViewportLayer extends Sprite {
public var layerIndex:Number;
public var layers:Dictionary;
public var childLayers:Array;
public var weight:Number;// = 0
public var dynamicLayer:Boolean;// = false
public var forceDepth:Boolean;// = false
public var displayObject3D:DisplayObject3D;
public var sortMode:String;
protected var viewport:Viewport3D;
public var displayObjects:Dictionary;
public var graphicsChannel:Graphics;
public var originDepth:Number;// = 0
public var screenDepth:Number;// = 0
public function ViewportLayer(_arg1:Viewport3D, _arg2:DisplayObject3D, _arg3:Boolean=false){
layers = new Dictionary(true);
displayObjects = new Dictionary(true);
sortMode = ViewportLayerSortMode.Z_SORT;
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);
_arg2.container = this;
};
init();
}
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);
}
private function onChildAdded(_arg1:ViewportLayerEvent):void{
if (_arg1.do3d){
linkChild(_arg1.do3d, _arg1.layer, _arg1);
};
}
public function addLayer(_arg1:ViewportLayer):void{
var _local2:DisplayObject3D;
var _local3:ViewportLayer;
if (childLayers.indexOf(_arg1) != -1){
PaperLogger.warning("Child layer already exists in ViewportLayer");
return;
};
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);
};
};
}
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 updateAfterRender():void{
var _local1:ViewportLayer;
for each (_local1 in childLayers) {
_local1.updateAfterRender();
};
}
protected function init():void{
childLayers = new Array();
}
public function clear():void{
graphicsChannel.clear();
reset();
}
public function childLayerIndex(_arg1:DisplayObject3D):Number{
_arg1 = (_arg1.parentContainer) ? _arg1.parentContainer : _arg1;
var _local2:int;
while (_local2 < childLayers.length) {
if (childLayers[_local2].hasDisplayObject3D(_arg1)){
return (_local2);
};
_local2++;
};
return (-1);
}
protected function reset():void{
if (!forceDepth){
screenDepth = 0;
originDepth = 0;
};
this.weight = 0;
}
public function updateInfo():void{
var _local1:ViewportLayer;
for each (_local1 in childLayers) {
_local1.updateInfo();
if (!forceDepth){
if (!isNaN(_local1.screenDepth)){
this.weight = (this.weight + _local1.weight);
this.screenDepth = (this.screenDepth + (_local1.screenDepth * _local1.weight));
this.originDepth = (this.originDepth + (_local1.originDepth * _local1.weight));
};
};
};
if (!forceDepth){
this.screenDepth = (this.screenDepth / this.weight);
this.originDepth = (this.originDepth / this.weight);
};
}
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);
}
protected function orderLayers():void{
var _local2:ViewportLayer;
var _local1:int;
while (_local1 < childLayers.length) {
_local2 = childLayers[_local1];
if (this.getChildIndex(_local2) != _local1){
this.setChildIndex(_local2, _local1);
};
_local2.sortChildLayers();
_local1++;
};
}
public function updateBeforeRender():void{
var _local1:ViewportLayer;
clear();
for each (_local1 in childLayers) {
_local1.updateBeforeRender();
};
}
public function hasDisplayObject3D(_arg1:DisplayObject3D):Boolean{
return (!((displayObjects[_arg1] == null)));
}
public function sortChildLayers():void{
switch (sortMode){
case ViewportLayerSortMode.Z_SORT:
childLayers.sortOn("screenDepth", (Array.DESCENDING | Array.NUMERIC));
break;
case ViewportLayerSortMode.INDEX_SORT:
childLayers.sortOn("layerIndex", Array.NUMERIC);
break;
case ViewportLayerSortMode.ORIGIN_SORT:
childLayers.sortOn(["originDepth", "screenDepth"], [(Array.DESCENDING | Array.NUMERIC), (Array.DESCENDING | Array.NUMERIC)]);
break;
};
orderLayers();
}
private function onChildRemoved(_arg1:ViewportLayerEvent):void{
if (_arg1.do3d){
unlinkChild(_arg1.do3d, _arg1);
};
}
public function removeAllLayers():void{
var _local1:int = (childLayers.length - 1);
while (_local1 >= 0) {
removeLayerAt(_local1);
_local1--;
};
}
public function processRenderItem(_arg1:RenderableListItem):void{
if (!forceDepth){
if (!isNaN(_arg1.screenZ)){
this.screenDepth = (this.screenDepth + _arg1.screenZ);
if (_arg1.instance){
this.originDepth = (this.originDepth + _arg1.instance.world.n34);
this.originDepth = (this.originDepth + _arg1.instance.screen.z);
};
this.weight++;
};
};
}
public function removeLayer(_arg1:ViewportLayer):void{
var _local2:int = getChildIndex(_arg1);
if (_local2 > -1){
removeLayerAt(_local2);
} else {
PaperLogger.error("Layer not found for removal.");
};
}
private function linkChild(_arg1:DisplayObject3D, _arg2:ViewportLayer, _arg3:ViewportLayerEvent=null):void{
layers[_arg1] = _arg2;
dispatchEvent(new ViewportLayerEvent(ViewportLayerEvent.CHILD_ADDED, _arg1, _arg2));
}
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 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 getLayerObjects(_arg1:Array=null):Array{
var _local2:DisplayObject3D;
var _local3:ViewportLayer;
if (!_arg1){
_arg1 = new Array();
};
for each (_local2 in this.displayObjects) {
if (_local2){
_arg1.push(_local2);
};
};
for each (_local3 in childLayers) {
_local3.getLayerObjects(_arg1);
};
return (_arg1);
}
}
}//package org.papervision3d.view.layer
Section 310
//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 311
//AbstractView (org.papervision3d.view.AbstractView)
package org.papervision3d.view {
import flash.events.*;
import flash.display.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.scenes.*;
import org.papervision3d.core.view.*;
import org.papervision3d.render.*;
public class AbstractView extends Sprite implements IView {
public var renderer:BasicRenderEngine;
protected var _camera:CameraObject3D;
protected var _width:Number;
public var scene:Scene3D;
protected var _height:Number;
public var viewport:Viewport3D;
public function set viewportWidth(_arg1:Number):void{
_width = _arg1;
viewport.width = _arg1;
}
public function singleRender():void{
onRenderTick();
}
public function startRendering():void{
addEventListener(Event.ENTER_FRAME, onRenderTick);
viewport.containerSprite.cacheAsBitmap = false;
}
public function get viewportWidth():Number{
return (_width);
}
protected function onRenderTick(_arg1:Event=null):void{
renderer.renderScene(scene, _camera, viewport);
}
public function set viewportHeight(_arg1:Number):void{
_height = _arg1;
viewport.height = _arg1;
}
public function get camera():CameraObject3D{
return (_camera);
}
public function get viewportHeight():Number{
return (_height);
}
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;
};
}
}
}//package org.papervision3d.view
Section 312
//BasicView (org.papervision3d.view.BasicView)
package org.papervision3d.view {
import org.papervision3d.objects.*;
import org.papervision3d.cameras.*;
import org.papervision3d.scenes.*;
import org.papervision3d.core.view.*;
import org.papervision3d.render.*;
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.SPRING:
_camera = new SpringCamera3D();
_camera.target = DisplayObject3D.ZERO;
break;
case CameraType.FREE:
default:
_camera = new Camera3D(60);
break;
};
cameraAsCamera3D.update(viewport.sizeRectangle);
}
public function get cameraAsDebugCamera3D():DebugCamera3D{
return ((_camera as DebugCamera3D));
}
public function get cameraAsCamera3D():Camera3D{
return ((_camera as Camera3D));
}
}
}//package org.papervision3d.view
Section 313
//Viewport3D (org.papervision3d.view.Viewport3D)
package org.papervision3d.view {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import org.papervision3d.core.render.command.*;
import org.papervision3d.core.render.data.*;
import flash.geom.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.view.layer.*;
import org.papervision3d.core.log.*;
import org.papervision3d.core.culling.*;
import org.papervision3d.core.view.*;
import org.papervision3d.core.render.*;
import org.papervision3d.core.utils.*;
public class Viewport3D extends Sprite implements IViewport3D {
public var interactiveSceneManager:InteractiveSceneManager;
public var lastRenderList:Array;
public var cullingRectangle:Rectangle;
protected var _interactive:Boolean;
private var stageScaleModeSet:Boolean;// = false
protected var _autoCulling:Boolean;
protected var _viewportObjectFilter:ViewportObjectFilter;
public var particleCuller:IParticleCuller;
protected var _height:Number;
protected var _width:Number;
public var lineCuller:ILineCuller;
protected var _layerInstances:Dictionary;
protected var _autoScaleToStage:Boolean;
public var triangleCuller:ITriangleCuller;
protected var _lastRenderer:IRenderEngine;
protected var _hWidth:Number;
protected var _containerSprite:ViewportBaseLayer;
protected var _hHeight:Number;
public var sizeRectangle:Rectangle;
protected var renderHitData:RenderHitData;
protected var _autoClipping:Boolean;
public function Viewport3D(_arg1:Number=640, _arg2:Number=480, _arg3:Boolean=false, _arg4:Boolean=false, _arg5:Boolean=true, _arg6:Boolean=true){
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 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 autoCulling():Boolean{
return (_autoCulling);
}
protected function onStageResize(_arg1:Event=null):void{
if (_autoScaleToStage){
viewportWidth = stage.stageWidth;
viewportHeight = stage.stageHeight;
};
}
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;
}
public function getChildLayer(_arg1:DisplayObject3D, _arg2:Boolean=true, _arg3:Boolean=true):ViewportLayer{
return (containerSprite.getChildLayer(_arg1, _arg2, _arg3));
}
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);
}
public function get autoClipping():Boolean{
return (_autoClipping);
}
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();
}
protected function onAddedToStage(_arg1:Event):void{
if (_autoScaleToStage){
setStageScaleMode();
};
stage.addEventListener(Event.RESIZE, onStageResize);
onStageResize();
}
public function get containerSprite():ViewportLayer{
return (_containerSprite);
}
public function set autoClipping(_arg1:Boolean):void{
if (_arg1){
scrollRect = sizeRectangle;
} else {
scrollRect = null;
};
_autoClipping = _arg1;
}
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 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 viewportWidth():Number{
return (_width);
}
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 viewportObjectFilter(_arg1:ViewportObjectFilter):void{
_viewportObjectFilter = _arg1;
}
public function set autoScaleToStage(_arg1:Boolean):void{
_autoScaleToStage = _arg1;
if (((_arg1) && (!((stage == null))))){
setStageScaleMode();
onStageResize();
};
}
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 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);
}
public function hitTestMouse():RenderHitData{
var _local1:Point = new Point(containerSprite.mouseX, containerSprite.mouseY);
return (hitTestPoint2D(_local1));
}
public function get interactive():Boolean{
return (_interactive);
}
public function get autoScaleToStage():Boolean{
return (_autoScaleToStage);
}
public function hitTestPointObject(_arg1:Point, _arg2:DisplayObject3D):RenderHitData{
var _local3:RenderableListItem;
var _local4:RenderHitData;
var _local5:IRenderListItem;
var _local6:uint;
if (interactive){
_local4 = new RenderHitData();
_local6 = lastRenderList.length;
while ((_local5 = lastRenderList[--_local6])) {
if ((_local5 is RenderableListItem)){
_local3 = (_local5 as RenderableListItem);
if ((_local3.renderableInstance is Triangle3D)){
if (Triangle3D(_local3.renderableInstance).instance != _arg2){
continue;
};
} else {
continue;
};
_local4 = _local3.hitTestPoint2D(_arg1, _local4);
if (_local4.hasHit){
return (_local4);
};
};
};
};
return (new RenderHitData());
}
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);
}
protected function onRemovedFromStage(_arg1:Event):void{
stage.removeEventListener(Event.RESIZE, onStageResize);
}
public function get viewportHeight():Number{
return (_height);
}
public function destroy():void{
if (interactiveSceneManager){
interactiveSceneManager.destroy();
interactiveSceneManager = null;
};
lastRenderList = null;
}
public function get viewportObjectFilter():ViewportObjectFilter{
return (_viewportObjectFilter);
}
}
}//package org.papervision3d.view
Section 314
//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 PAPERLOGGER:PaperLogger = PaperLogger.getInstance();
public static var NAME:String = "Papervision3D";
public static var DATE:String = "December 3rd, 2008";
public static var AUTHOR:String = "(c) 2006-2008 Copyright by Carlos Ulloa | John Grden | Ralph Hauwert | Tim Knip | Andy Zupko";
public static var VERSION:String = "Public Beta 2.0 - Great White";
public static var usePERCENT:Boolean = false;
}
}//package org.papervision3d
Section 315
//FastGamesLogo_3 (PreloaderScreen_fla.FastGamesLogo_3)
package PreloaderScreen_fla {
import flash.events.*;
import flash.display.*;
import flash.net.*;
public dynamic class FastGamesLogo_3 extends MovieClip {
public var btn:SimpleButton;
public function FastGamesLogo_3(){
addFrameScript(0, frame1);
}
function frame1(){
btn.addEventListener(MouseEvent.CLICK, onPlayMoreGames);
}
public function onPlayMoreGames(_arg1:MouseEvent):void{
var _local2:URLRequest;
_local2 = new URLRequest("http://www.fastgames.com/");
navigateToURL(_local2, "_blank");
}
}
}//package PreloaderScreen_fla
Section 316
//PreloaderSkin_7 (PreloaderScreen_fla.PreloaderSkin_7)
package PreloaderScreen_fla {
import flash.display.*;
public dynamic class PreloaderSkin_7 extends MovieClip {
public var rotator:MovieClip;
}
}//package PreloaderScreen_fla
Section 317
//BGAnimation_2 (RotatorBG_fla.BGAnimation_2)
package RotatorBG_fla {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import flash.geom.*;
import flash.filters.*;
import flash.text.*;
import flash.net.*;
import flash.media.*;
import flash.ui.*;
import flash.system.*;
import adobe.utils.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.printing.*;
import flash.xml.*;
public dynamic class BGAnimation_2 extends MovieClip {
public var count:uint;
public var i:uint;
public var particle:MovieClip;
public var particleInst1:BGElement;
public var particleInst2:BGElement;
public function BGAnimation_2(){
addFrameScript(0, frame1);
}
function frame1(){
particleInst1.visible = false;
particleInst2.visible = false;
count = 100;
i = 0;
while (i < count) {
particle = new BGElement();
var _local2 = particle;
with (_local2) {
x = (Math.random() * 700);
y = (Math.random() * 480);
rotation = (Math.random() * 360);
scaleX = (scaleY = Math.random());
alpha = Math.random();
gotoAndStop(int((Math.random() * 6)));
};
addChild(particle);
i++;
};
}
}
}//package RotatorBG_fla
Section 318
//BGAnimation_2 (RotorsBG_fla.BGAnimation_2)
package RotorsBG_fla {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import flash.geom.*;
import flash.filters.*;
import flash.text.*;
import flash.net.*;
import flash.media.*;
import flash.ui.*;
import flash.system.*;
import adobe.utils.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.printing.*;
import flash.xml.*;
public dynamic class BGAnimation_2 extends MovieClip {
public var count:uint;
public var i:uint;
public var particle:MovieClip;
public var particleInst1:BGElement;
public var particleInst2:BGElement;
public function BGAnimation_2(){
addFrameScript(0, frame1);
}
function frame1(){
particleInst1.visible = false;
particleInst2.visible = false;
count = 100;
i = 0;
while (i < count) {
particle = new BGElement();
var _local2 = particle;
with (_local2) {
x = (Math.random() * 700);
y = (Math.random() * 480);
rotation = (Math.random() * 360);
scaleX = (scaleY = Math.random());
alpha = Math.random();
gotoAndStop(int((Math.random() * 6)));
};
addChild(particle);
i++;
};
}
}
}//package RotorsBG_fla
Section 319
//Autoreset (sceneElements.Autoreset)
package sceneElements {
import core.shape.shapeProps.*;
import org.papervision3d.objects.primitives.*;
import core.shape.*;
public class Autoreset extends BaseSceneElement {
public function Autoreset(_arg1:Object){
super(_arg1);
}
override protected function createSkins():Array{
var _local1:Plane = new Plane(MaterialListReference.getInstance().autoresetMaterial(), 50, 50);
return ([_local1]);
}
override protected function createBodies():Array{
var _local1:CircleShape = new CircleShape(_x, _y, 15);
UserData(_local1.body.m_userData).type = "autoreset";
_local1.body.PutToSleep();
return ([_local1.body]);
}
}
}//package sceneElements
Section 320
//BaseJumpBoxElement (sceneElements.BaseJumpBoxElement)
package sceneElements {
import Box2D.Dynamics.*;
import core.shape.shapeProps.*;
import core.shape.complex.*;
public class BaseJumpBoxElement extends BaseSceneElement {
private var _power:Number;
private var _jumpBox:JumpBox;
public function BaseJumpBoxElement(_arg1:Object){
_power = _arg1.power;
super(_arg1);
}
public function deactivate():void{
_jumpBox.deactivate();
}
public function activate():void{
_jumpBox.activate();
}
public function get body():b2Body{
return (_jumpBox.body);
}
override protected function createSkins():Array{
return ([_skin]);
}
override protected function createBodies():Array{
var _local1:DefaultShapeProps = new DefaultDynamicShapeProps();
_local1.density = 0.3;
_local1.restitution = 0.1;
_jumpBox = new JumpBox(_x, _y, _w, _h, _power, _local1);
UserData(_jumpBox.body.m_userData).type = "box";
return ([_jumpBox.body]);
}
}
}//package sceneElements
Section 321
//BaseSceneElement (sceneElements.BaseSceneElement)
package sceneElements {
import core.engine.*;
import flash.display.*;
import Box2D.Dynamics.*;
import core.renderer.*;
import org.papervision3d.objects.*;
public class BaseSceneElement {
private var _skinContainer:Sprite;
protected var _h:Number;
protected var _bodies:Array;
protected var _r:Number;
protected var _isStatic:Boolean;
protected var _w:Number;
protected var _x:Number;
protected var _y:Number;
protected var _skin:DisplayObject3D;
public function BaseSceneElement(_arg1:Object):void{
if (_arg1){
if (_arg1.x){
_x = _arg1.x;
};
if (_arg1.y){
_y = _arg1.y;
};
if (_arg1.r){
_r = _arg1.r;
};
if (_arg1.w){
_w = _arg1.w;
};
if (_arg1.h){
_h = _arg1.h;
};
if (_arg1.skin){
_skin = _arg1.skin;
};
if (_arg1.isStatic){
_isStatic = _arg1.isStatic;
};
};
createChildren();
}
protected function createBodies():Array{
return (new Array());
}
protected function createSkins():Array{
return (new Array());
}
public function destruct():void{
var _local1:b2Body;
for each (_local1 in _bodies) {
CoreEngine.getInstance().world.DestroyBody(_local1);
};
}
private function createChildren():void{
_bodies = createBodies();
var _local1:Array = createSkins();
CoreEngine.getInstance().addRenderer(new Render3d(_bodies, _local1));
}
public function get skin():DisplayObject3D{
return (_skin);
}
}
}//package sceneElements
Section 322
//Bomb (sceneElements.Bomb)
package sceneElements {
import core.shape.shapeProps.*;
import org.papervision3d.objects.primitives.*;
import core.shape.*;
public class Bomb extends BaseSceneElement {
private var _radius:Number;
public function Bomb(_arg1:Object){
super(_arg1);
}
override protected function createBodies():Array{
var _local1:DefaultShapeProps = new DefaultDynamicShapeProps();
_local1.categoryBits = 0x1000;
_local1.maskBits = 61695;
var _local2:CircleShape = new CircleShape(_x, _y, 4, false, _local1);
UserData(_local2.body.m_userData).type = "bomb";
_local2.body.PutToSleep();
var _local3:CircleShape = new CircleShape((_x + 8), _y, 4, false, _local1);
_local3.body.PutToSleep();
var _local4:CircleShape = new CircleShape(_x, (_y + 8), 4, false, _local1);
_local4.body.PutToSleep();
var _local5:CircleShape = new CircleShape((_x - 8), _y, 4, false, _local1);
_local5.body.PutToSleep();
var _local6:CircleShape = new CircleShape(_x, (_y - 8), 4, false, _local1);
_local6.body.PutToSleep();
var _local7:CircleShape = new CircleShape((_x + 7), (_y + 7), 3, false, _local1);
_local7.body.PutToSleep();
var _local8:CircleShape = new CircleShape((_x - 7), (_y - 7), 3, false, _local1);
_local8.body.PutToSleep();
var _local9:CircleShape = new CircleShape((_x + 7), (_y - 7), 3, false, _local1);
_local9.body.PutToSleep();
var _local10:CircleShape = new CircleShape((_x - 7), (_y + 7), 3, false, _local1);
_local10.body.PutToSleep();
return ([_local2.body, _local3.body, _local4.body, _local5.body, _local6.body, _local7.body, _local8.body, _local9.body, _local10.body]);
}
override protected function createSkins():Array{
var _local1:uint = 8;
var _local2:uint = 6;
var _local3:Cube = new Cube(MaterialListReference.getInstance().list, _local1, 30, _local1);
var _local4:Cube = new Cube(MaterialListReference.getInstance().list, _local1, 14, _local1);
var _local5:Cube = new Cube(MaterialListReference.getInstance().list, _local1, 14, _local1);
var _local6:Cube = new Cube(MaterialListReference.getInstance().list, _local1, 14, _local1);
var _local7:Cube = new Cube(MaterialListReference.getInstance().list, _local1, 14, _local1);
var _local8:Cube = new Cube(MaterialListReference.getInstance().list, _local2, 6, _local2);
var _local9:Cube = new Cube(MaterialListReference.getInstance().list, _local2, 6, _local2);
var _local10:Cube = new Cube(MaterialListReference.getInstance().list, _local2, 6, _local2);
var _local11:Cube = new Cube(MaterialListReference.getInstance().list, _local2, 6, _local2);
return ([_local3, _local4, _local5, _local6, _local7, _local8, _local9, _local10, _local11]);
}
}
}//package sceneElements
Section 323
//Box1 (sceneElements.Box1)
package sceneElements {
import org.papervision3d.objects.primitives.*;
public class Box1 extends BaseJumpBoxElement {
public var size:uint;// = 30
public function Box1(_arg1:Object){
var _local2:Number = 2.7;
var _local3:Cube = new Cube(MaterialListReference.getInstance().boxMaterial(5676095, Box1Skin), size, size, size);
_arg1.skin = _local3;
_arg1.w = (_arg1.h = size);
_arg1.power = _local2;
super(_arg1);
}
}
}//package sceneElements
Section 324
//Box2 (sceneElements.Box2)
package sceneElements {
import org.papervision3d.objects.primitives.*;
public class Box2 extends BaseJumpBoxElement {
public function Box2(_arg1:Object){
var _local2:uint = 40;
var _local3:Number = 4.6;
var _local4:Cube = new Cube(MaterialListReference.getInstance().boxMaterial(3899800, Box2Skin), _local2, _local2, _local2);
_arg1.skin = _local4;
_arg1.w = (_arg1.h = _local2);
_arg1.power = _local3;
super(_arg1);
}
}
}//package sceneElements
Section 325
//Box3 (sceneElements.Box3)
package sceneElements {
import org.papervision3d.objects.primitives.*;
public class Box3 extends BaseJumpBoxElement {
public function Box3(_arg1:Object){
var _local2:uint = 50;
var _local3:Number = 6.8;
var _local4:Cube = new Cube(MaterialListReference.getInstance().boxMaterial(10108034, Box3Skin), _local2, _local2, _local2);
_arg1.skin = _local4;
_arg1.w = (_arg1.h = _local2);
_arg1.power = _local3;
super(_arg1);
}
}
}//package sceneElements
Section 326
//Box4 (sceneElements.Box4)
package sceneElements {
import org.papervision3d.objects.primitives.*;
public class Box4 extends BaseJumpBoxElement {
public function Box4(_arg1:Object){
var _local2:uint = 60;
var _local3:Number = 9.3;
var _local4:Cube = new Cube(MaterialListReference.getInstance().boxMaterial(4602262, Box4Skin), _local2, _local2, _local2);
_arg1.skin = _local4;
_arg1.w = (_arg1.h = _local2);
_arg1.power = _local3;
super(_arg1);
}
}
}//package sceneElements
Section 327
//Crank (sceneElements.Crank)
package sceneElements {
import core.engine.*;
import Box2D.Common.Math.*;
import Box2D.Dynamics.Joints.*;
import Box2D.Dynamics.*;
import org.papervision3d.objects.primitives.*;
import core.shape.*;
public class Crank extends BaseSceneElement {
public function Crank(_arg1:Object){
super(_arg1);
}
override protected function createSkins():Array{
var _local1:Cube = new Cube(MaterialListReference.getInstance().list, 7.5, 15, 40);
var _local2:Cube = new Cube(MaterialListReference.getInstance().list, 7.5, 15, 100);
var _local3:Cube = new Cube(MaterialListReference.getInstance().list, 50, 100, 15);
return ([_local1, _local2, _local3]);
}
override protected function createBodies():Array{
var _local1:CoreEngine = CoreEngine.getInstance();
var _local2:b2Body = _local1.world.GetGroundBody();
var _local3:BoxShape = new BoxShape(_x, (_y - 110), 7.5, 40, false);
var _local4:BoxShape = new BoxShape(_x, (_y - 50), 7.5, 100, false);
var _local5:BoxShape = new BoxShape(_x, _y, 50, 15, false);
var _local6:b2RevoluteJointDef = new b2RevoluteJointDef();
var _local7:b2PrismaticJointDef = new b2PrismaticJointDef();
_local6.motorSpeed = (-2.14 - Math.random());
_local6.maxMotorTorque = 5000;
_local6.enableMotor = true;
_local6.Initialize(_local2, _local3.body, new b2Vec2((_x / 30), ((_y - 130) / 30)));
(_local1.world.CreateJoint(_local6) as b2RevoluteJoint);
_local6.enableMotor = false;
_local6.Initialize(_local3.body, _local4.body, new b2Vec2((_x / 30), ((_y - 95) / 30)));
_local1.world.CreateJoint(_local6);
_local6.Initialize(_local4.body, _local5.body, new b2Vec2((_x / 30), (_y / 30)));
_local1.world.CreateJoint(_local6);
_local7.Initialize(_local2, _local5.body, new b2Vec2((_x / 30), (_y / 30)), new b2Vec2(0, 1));
(_local1.world.CreateJoint(_local7) as b2PrismaticJoint);
return ([_local3.body, _local4.body, _local5.body]);
}
}
}//package sceneElements
Section 328
//MovablePlate (sceneElements.MovablePlate)
package sceneElements {
import core.engine.*;
import Box2D.Common.Math.*;
import Box2D.Dynamics.Joints.*;
import core.shape.shapeProps.*;
import org.papervision3d.objects.primitives.*;
import core.shape.*;
public class MovablePlate extends BaseSceneElement {
public function MovablePlate(_arg1:Object){
super(_arg1);
}
override protected function createSkins():Array{
var _local1:Cube = new Cube(MaterialListReference.getInstance().boxMaterial(0xD54000, MovablePlateSkin), _w, 100, _h);
return ([_local1]);
}
override protected function createBodies():Array{
var _local1:DefaultShapeProps = new DefaultDynamicShapeProps();
_local1.friction = 0.7;
var _local2:BoxShape = new BoxShape(_x, _y, _w, _h, false, _local1);
var _local3:b2PrismaticJointDef = new b2PrismaticJointDef();
_local3.Initialize(_local2.body, CoreEngine.getInstance().world.m_groundBody, _local2.body.GetWorldCenter(), new b2Vec2(1, 0));
_local3.enableLimit = false;
_local3.enableMotor = false;
CoreEngine.getInstance().world.CreateJoint(_local3);
return ([_local2.body]);
}
}
}//package sceneElements
Section 329
//Rotator (sceneElements.Rotator)
package sceneElements {
import core.engine.*;
import Box2D.Common.Math.*;
import Box2D.Dynamics.Joints.*;
import org.papervision3d.objects.primitives.*;
import core.shape.*;
public class Rotator extends BaseSceneElement {
private var _speed:Number;
private var _torque:Number;
public function Rotator(_arg1:Object){
_speed = _arg1.speed;
_torque = _arg1.torque;
super(_arg1);
}
override protected function createSkins():Array{
var _local1:Cube = new Cube(MaterialListReference.getInstance().list, _w, 100, _h);
return ([_local1]);
}
override protected function createBodies():Array{
var _local1:BoxShape = new BoxShape(_x, _y, _w, _h, false);
var _local2:b2RevoluteJointDef = new b2RevoluteJointDef();
_local2.upperAngle = 0;
_local2.lowerAngle = 0;
_local2.Initialize(_local1.body, CoreEngine.getInstance().world.GetGroundBody(), new b2Vec2((_x / 30), (_y / 30)));
_local2.enableMotor = true;
_local2.motorSpeed = _speed;
_local2.maxMotorTorque = _torque;
CoreEngine.getInstance().world.CreateJoint(_local2);
return ([_local1.body]);
}
}
}//package sceneElements
Section 330
//SleepBox (sceneElements.SleepBox)
package sceneElements {
import core.shape.shapeProps.*;
import org.papervision3d.objects.primitives.*;
import core.shape.*;
public class SleepBox extends BaseSceneElement {
private var _linearDamping:uint;// = 0
private var _angularDamping:uint;// = 0
public function SleepBox(_arg1:Object){
if (_arg1.angularDamping){
_angularDamping = _arg1.angularDamping;
};
if (_arg1.linearDamping){
_linearDamping = _arg1.linearDamping;
};
super(_arg1);
}
override protected function createSkins():Array{
var _local1:Cube = new Cube(MaterialListReference.getInstance().boxMaterial(7518204, SleepBoxSkin), _w, 70, _h);
return ([_local1]);
}
override protected function createBodies():Array{
var _local1:DefaultShapeProps = new DefaultDynamicShapeProps();
_local1.angularDamping = _angularDamping;
_local1.linearDamping = _linearDamping;
var _local2:BoxShape = new BoxShape(_x, _y, _w, _h, false, _local1);
_local2.body.PutToSleep();
return ([_local2.body]);
}
}
}//package sceneElements
Section 331
//Target (sceneElements.Target)
package sceneElements {
import core.shape.shapeProps.*;
import org.papervision3d.objects.primitives.*;
import core.shape.*;
public class Target extends BaseSceneElement {
public function Target(_arg1:Object){
super(_arg1);
}
override protected function createSkins():Array{
var _local1:Plane = new Plane(MaterialListReference.getInstance().targetMaterial(), 50, 50);
return ([_local1]);
}
override protected function createBodies():Array{
var _local1:DefaultShapeProps = new DefaultDynamicShapeProps();
_local1.categoryBits = 0x0100;
_local1.maskBits = 4095;
var _local2:CircleShape = new CircleShape(_x, _y, 15, false, _local1);
UserData(_local2.body.m_userData).type = "target";
_local2.body.PutToSleep();
return ([_local2.body]);
}
}
}//package sceneElements
Section 332
//Walls (sceneElements.Walls)
package sceneElements {
import org.papervision3d.objects.primitives.*;
import core.shape.*;
public class Walls extends BaseSceneElement {
public function Walls(_arg1:Object){
super(_arg1);
}
override protected function createSkins():Array{
var _local1:Cube = new Cube(MaterialListReference.getInstance().list, 50, 100, 1400);
var _local2:Cube = new Cube(MaterialListReference.getInstance().list, 50, 100, 1400);
var _local3:Cube = new Cube(MaterialListReference.getInstance().list, 640, 100, 25);
return ([_local1, _local2, _local3]);
}
override protected function createBodies():Array{
var _local1:BoxShape = new BoxShape(-25, -300, 50, 1400, true);
var _local2:BoxShape = new BoxShape(665, -300, 50, 1400, true);
var _local3:BoxShape = new BoxShape(320, 387, 640, 25, true);
return ([_local1.body, _local2.body, _local3.body]);
}
}
}//package sceneElements
Section 333
//Wheel (sceneElements.Wheel)
package sceneElements {
import org.papervision3d.objects.primitives.*;
import core.shape.*;
public class Wheel extends BaseSceneElement {
public function Wheel(_arg1:Object){
super(_arg1);
}
override protected function createSkins():Array{
var _local1:Plane = new Plane(MaterialListReference.getInstance().wheelMaterial(), 60, 60);
return ([_local1]);
}
override protected function createBodies():Array{
var _local1:CircleShape = new CircleShape(_x, _y, _r);
return ([_local1.body]);
}
}
}//package sceneElements
Section 334
//VoluntaryBox (sceneElements.VoluntaryBox)
package sceneElements {
import org.papervision3d.objects.primitives.*;
import core.shape.*;
public class VoluntaryBox extends BaseSceneElement {
public function VoluntaryBox(_arg1:Object){
super(_arg1);
}
override protected function createSkins():Array{
var _local1:Cube = new Cube(MaterialListReference.getInstance().list, _w, 100, _h);
return ([_local1]);
}
override protected function createBodies():Array{
var _local1:BoxShape = new BoxShape(_x, _y, _w, _h, _isStatic);
return ([_local1.body]);
}
}
}//package sceneElements
Section 335
//BaseInstrument (sound.BaseInstrument)
package sound {
import flash.media.*;
public class BaseInstrument {
private var _c:Class;
private var _sound:Sound;
private var _soundChannel:SoundChannel;
private var _volume:Number;
private var _playTimes:Number;// = 1
private var _soundTransform:SoundTransform;
public function BaseInstrument(_arg1:Class, _arg2:Number=1, _arg3:Boolean=false, _arg4:Boolean=false){
_c = _arg1;
_sound = (new _c() as Sound);
_volume = _arg2;
_playTimes = (_arg3) ? 9999 : 1;
_soundTransform = new SoundTransform();
_soundTransform.volume = _volume;
if (_arg4){
mute();
};
}
public function unmute():void{
_soundTransform.volume = _volume;
if (_soundChannel){
_soundChannel.soundTransform = _soundTransform;
};
}
public function stop():void{
if (_soundChannel){
_soundChannel.stop();
};
}
public function mute():void{
_soundTransform.volume = 0;
if (_soundChannel){
_soundChannel.soundTransform = _soundTransform;
};
}
public function play():void{
stop();
_soundChannel = _sound.play(0, _playTimes);
_soundChannel.soundTransform = _soundTransform;
}
}
}//package sound
Section 336
//Samples (sound.Samples)
package sound {
public class Samples {
public var LevelLoopClass1:Class;
public var LevelLoopClass3:Class;
public var BombSndClass:Class;
public var LevelLoopClass2:Class;
public var MenuLoopSndClass:Class;
private static var _instance:Samples;
public function Samples(_arg1:SingletonEnforcer){
LevelLoopClass1 = Samples_LevelLoopClass1;
LevelLoopClass2 = Samples_LevelLoopClass2;
LevelLoopClass3 = Samples_LevelLoopClass3;
BombSndClass = Samples_BombSndClass;
MenuLoopSndClass = Samples_MenuLoopSndClass;
super();
}
public static function getInstance():Samples{
if (_instance == null){
_instance = new Samples(new SingletonEnforcer());
};
return (_instance);
}
}
}//package sound
class SingletonEnforcer {
private function SingletonEnforcer(){
}
}
Section 337
//Samples_BombSndClass (sound.Samples_BombSndClass)
package sound {
import mx.core.*;
public class Samples_BombSndClass extends SoundAsset {
}
}//package sound
Section 338
//Samples_LevelLoopClass1 (sound.Samples_LevelLoopClass1)
package sound {
import mx.core.*;
public class Samples_LevelLoopClass1 extends SoundAsset {
}
}//package sound
Section 339
//Samples_LevelLoopClass2 (sound.Samples_LevelLoopClass2)
package sound {
import mx.core.*;
public class Samples_LevelLoopClass2 extends SoundAsset {
}
}//package sound
Section 340
//Samples_LevelLoopClass3 (sound.Samples_LevelLoopClass3)
package sound {
import mx.core.*;
public class Samples_LevelLoopClass3 extends SoundAsset {
}
}//package sound
Section 341
//Samples_MenuLoopSndClass (sound.Samples_MenuLoopSndClass)
package sound {
import mx.core.*;
public class Samples_MenuLoopSndClass extends SoundAsset {
}
}//package sound
Section 342
//SoundPlayer (sound.SoundPlayer)
package sound {
public class SoundPlayer {
private var _menuSndInstr:BaseInstrument;
private var _isMuted:Boolean;// = false
private var _bomdSndInstr:BaseInstrument;
private var _levelSndInstr:BaseInstrument;
private var _lvlSoundIdx:uint;// = 1
private var _targetSndInstr:BaseInstrument;
private var _resetSndInstr:BaseInstrument;
private static var _instance:SoundPlayer;
public function SoundPlayer(_arg1:SingletonEnforcer){
}
public function playMenuSound():void{
if (!_menuSndInstr){
_menuSndInstr = new BaseInstrument(Samples.getInstance().MenuLoopSndClass, 1, true, _isMuted);
};
_menuSndInstr.play();
}
public function playTargetSound():void{
}
public function stopMenuSound():void{
if (_menuSndInstr){
_menuSndInstr.stop();
};
}
public function muteSwitch():void{
if (!_isMuted){
if (_levelSndInstr){
_levelSndInstr.mute();
};
if (_menuSndInstr){
_menuSndInstr.mute();
};
if (_targetSndInstr){
_targetSndInstr.mute();
};
if (_resetSndInstr){
_resetSndInstr.mute();
};
if (_bomdSndInstr){
_bomdSndInstr.mute();
};
} else {
if (_levelSndInstr){
_levelSndInstr.unmute();
};
if (_menuSndInstr){
_menuSndInstr.unmute();
};
if (_targetSndInstr){
_targetSndInstr.unmute();
};
if (_resetSndInstr){
_resetSndInstr.unmute();
};
if (_bomdSndInstr){
_bomdSndInstr.unmute();
};
};
_isMuted = !(_isMuted);
}
public function playBombSound():void{
if (!_bomdSndInstr){
_bomdSndInstr = new BaseInstrument(Samples.getInstance().BombSndClass, 1, false, _isMuted);
};
_bomdSndInstr.play();
}
public function playResetSound():void{
}
public function stopLevelSound():void{
if (_levelSndInstr){
_levelSndInstr.stop();
};
}
public function playLevelSound():void{
stopLevelSound();
_lvlSoundIdx = ((_lvlSoundIdx)<3) ? (_lvlSoundIdx + 1) : 1;
_levelSndInstr = new BaseInstrument(Samples.getInstance()[("LevelLoopClass" + _lvlSoundIdx)], 0.7, true, _isMuted);
_levelSndInstr.play();
}
public static function getInstance():SoundPlayer{
if (_instance == null){
_instance = new SoundPlayer(new SingletonEnforcer());
};
return (_instance);
}
}
}//package sound
class SingletonEnforcer {
private function SingletonEnforcer(){
}
}
Section 343
//BGAnimation_2 (StairsBG_fla.BGAnimation_2)
package StairsBG_fla {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import flash.geom.*;
import flash.filters.*;
import flash.text.*;
import flash.net.*;
import flash.media.*;
import flash.ui.*;
import flash.system.*;
import adobe.utils.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.printing.*;
import flash.xml.*;
public dynamic class BGAnimation_2 extends MovieClip {
public var count:uint;
public var i:uint;
public var particle:MovieClip;
public var particleInst1:BGElement;
public var particleInst2:BGElement;
public function BGAnimation_2(){
addFrameScript(0, frame1);
}
function frame1(){
particleInst1.visible = false;
particleInst2.visible = false;
count = 100;
i = 0;
while (i < count) {
particle = new BGElement();
var _local2 = particle;
with (_local2) {
x = (Math.random() * 700);
y = (Math.random() * 480);
rotation = (Math.random() * 360);
scaleX = (scaleY = Math.random());
alpha = Math.random();
gotoAndStop(int((Math.random() * 6)));
};
addChild(particle);
i++;
};
}
}
}//package StairsBG_fla
Section 344
//Symbol50_4 (StairsBG_fla.Symbol50_4)
package StairsBG_fla {
import flash.display.*;
public dynamic class Symbol50_4 extends MovieClip {
public function Symbol50_4(){
addFrameScript(120, frame121);
}
function frame121(){
stop();
}
}
}//package StairsBG_fla
Section 345
//BGAnimation_2 (SwingBG_fla.BGAnimation_2)
package SwingBG_fla {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import flash.geom.*;
import flash.filters.*;
import flash.text.*;
import flash.net.*;
import flash.media.*;
import flash.ui.*;
import flash.system.*;
import adobe.utils.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.printing.*;
import flash.xml.*;
public dynamic class BGAnimation_2 extends MovieClip {
public var count:uint;
public var i:uint;
public var particle:MovieClip;
public var particleInst1:BGElement;
public var particleInst2:BGElement;
public function BGAnimation_2(){
addFrameScript(0, frame1);
}
function frame1(){
particleInst1.visible = false;
particleInst2.visible = false;
count = 100;
i = 0;
while (i < count) {
particle = new BGElement();
var _local2 = particle;
with (_local2) {
x = (Math.random() * 700);
y = (Math.random() * 480);
rotation = (Math.random() * 360);
scaleX = (scaleY = Math.random());
alpha = Math.random();
gotoAndStop(int((Math.random() * 6)));
};
addChild(particle);
i++;
};
}
}
}//package SwingBG_fla
Section 346
//BGAnimation_2 (ThreeWaysBG_fla.BGAnimation_2)
package ThreeWaysBG_fla {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import flash.geom.*;
import flash.filters.*;
import flash.text.*;
import flash.net.*;
import flash.media.*;
import flash.ui.*;
import flash.system.*;
import adobe.utils.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.printing.*;
import flash.xml.*;
public dynamic class BGAnimation_2 extends MovieClip {
public var count:uint;
public var i:uint;
public var particle:MovieClip;
public var particleInst1:BGElement;
public var particleInst2:BGElement;
public function BGAnimation_2(){
addFrameScript(0, frame1);
}
function frame1(){
particleInst1.visible = false;
particleInst2.visible = false;
count = 100;
i = 0;
while (i < count) {
particle = new BGElement();
var _local2 = particle;
with (_local2) {
x = (Math.random() * 700);
y = (Math.random() * 480);
rotation = (Math.random() * 360);
scaleX = (scaleY = Math.random());
alpha = Math.random();
gotoAndStop(int((Math.random() * 6)));
};
addChild(particle);
i++;
};
}
}
}//package ThreeWaysBG_fla
Section 347
//BGAnimation_2 (TowerBG_fla.BGAnimation_2)
package TowerBG_fla {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import flash.geom.*;
import flash.filters.*;
import flash.text.*;
import flash.net.*;
import flash.media.*;
import flash.ui.*;
import flash.system.*;
import adobe.utils.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.printing.*;
import flash.xml.*;
public dynamic class BGAnimation_2 extends MovieClip {
public var count:uint;
public var i:uint;
public var particle:MovieClip;
public var particleInst1:BGElement;
public var particleInst2:BGElement;
public function BGAnimation_2(){
addFrameScript(0, frame1);
}
function frame1(){
particleInst1.visible = false;
particleInst2.visible = false;
count = 100;
i = 0;
while (i < count) {
particle = new BGElement();
var _local2 = particle;
with (_local2) {
x = (Math.random() * 700);
y = (Math.random() * 480);
rotation = (Math.random() * 360);
scaleX = (scaleY = Math.random());
alpha = Math.random();
gotoAndStop(int((Math.random() * 6)));
};
addChild(particle);
i++;
};
}
}
}//package TowerBG_fla
Section 348
//OpenLevelEvent (ui.events.OpenLevelEvent)
package ui.events {
import flash.events.*;
public class OpenLevelEvent extends Event {
public var levelNo:uint;
public static var TYPE:String = "selectLevel";
public function OpenLevelEvent(_arg1:String, _arg2:Boolean=false){
super(_arg1, _arg2);
}
}
}//package ui.events
Section 349
//SubmitScoreEvent (ui.events.SubmitScoreEvent)
package ui.events {
import flash.events.*;
public class SubmitScoreEvent extends Event {
public var score:uint;
public var name:String;
public static var TYPE:String = "SubmitScore";
public function SubmitScoreEvent(_arg1:String){
super(_arg1);
}
}
}//package ui.events
Section 350
//Performance (utils.Performance)
package utils {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import flash.text.*;
import flash.system.*;
public class Performance extends Sprite {
private const GRAPHIC_HEIGHT:Number = 25;
private const GRAPHIC_WIDTH:Number = 100;
private const MEGABYTE:uint = 1048576;
private var _fpsCount:uint;
private var _back:Shape;
private var _memoryStack:Array;
private var _timer:Timer;
private var _maxMemoryLabel:TextField;
private var _graph:Shape;
private var _memoryTimerCount:uint;
private var _minMemoryLabel:TextField;
private var _color:uint;
private var _totalMemory:String;
private var _fpsLabel:TextField;
private var _fpsStack:Array;
public function Performance(_arg1:uint=0){
_color = _arg1;
_fpsStack = [0, 0, 0, 0];
_memoryStack = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
_memoryTimerCount = 0;
_fpsCount = 0;
_timer = new Timer(250);
_fpsLabel = new TextField();
_minMemoryLabel = new TextField();
_maxMemoryLabel = new TextField();
_back = new Shape();
_graph = new Shape();
addEventListener(Event.ADDED_TO_STAGE, onAdded);
}
private function onRemoved(_arg1:Event):void{
removeEventListener(Event.REMOVED_FROM_STAGE, onRemoved);
removeEventListener(Event.ENTER_FRAME, onEnter);
_timer.removeEventListener(TimerEvent.TIMER, onTimer);
_timer.stop();
removeChild(_back);
removeChild(_graph);
removeChild(_maxMemoryLabel);
removeChild(_minMemoryLabel);
removeChild(_fpsLabel);
_back = null;
_graph = null;
_maxMemoryLabel = null;
_minMemoryLabel = null;
_fpsLabel = null;
_fpsStack = null;
_memoryStack = null;
}
private function onAdded(_arg1:Event):void{
var i:uint;
var evt = _arg1;
removeEventListener(Event.ADDED_TO_STAGE, onAdded);
var _local3 = _fpsLabel;
with (_local3) {
defaultTextFormat = new TextFormat("Lucida", 10);
selectable = false;
autoSize = TextFieldAutoSize.LEFT;
textColor = _color;
antiAliasType = AntiAliasType.NORMAL;
text = "Fps: Null\nMem: Null";
};
_local3 = _minMemoryLabel;
with (_local3) {
defaultTextFormat = new TextFormat("Lucida", 8);
selectable = false;
autoSize = TextFieldAutoSize.LEFT;
textColor = _color;
antiAliasType = AntiAliasType.NORMAL;
text = "Null";
};
_local3 = _maxMemoryLabel;
with (_local3) {
defaultTextFormat = new TextFormat("Lucida", 8);
selectable = false;
autoSize = TextFieldAutoSize.LEFT;
textColor = _color;
antiAliasType = AntiAliasType.NORMAL;
text = "Null";
};
_fpsLabel.mouseEnabled = false;
_maxMemoryLabel.mouseEnabled = false;
_minMemoryLabel.mouseEnabled = false;
var widthStep:Number = (GRAPHIC_WIDTH / 10);
var heightStep:Number = (GRAPHIC_HEIGHT / 5);
_back.graphics.lineStyle(0, _color, 0.2);
i = 0;
while (i < 10) {
_back.graphics.moveTo((widthStep * i), 0);
_back.graphics.lineTo((widthStep * i), GRAPHIC_HEIGHT);
i = (i + 1);
};
i = 0;
while (i <= 5) {
_back.graphics.moveTo(0, (heightStep * i));
_back.graphics.lineTo((GRAPHIC_WIDTH - widthStep), (heightStep * i));
i = (i + 1);
};
_fpsLabel.x = 0;
_fpsLabel.y = 0;
_back.x = 0;
_back.y = ((_fpsLabel.y + _fpsLabel.textHeight) + 2);
_graph.x = _back.x;
_graph.y = _back.y;
_maxMemoryLabel.x = ((_back.x + _back.width) + 2);
_maxMemoryLabel.y = (_back.y - 2);
_minMemoryLabel.x = ((_back.x + _back.width) + 2);
_minMemoryLabel.y = ((_back.y + _back.height) - _minMemoryLabel.textHeight);
addChild(_back);
addChild(_graph);
addChild(_fpsLabel);
addChild(_maxMemoryLabel);
addChild(_minMemoryLabel);
_timer.start();
_timer.addEventListener(TimerEvent.TIMER, onTimer);
addEventListener(Event.ENTER_FRAME, onEnter);
addEventListener(Event.REMOVED_FROM_STAGE, onRemoved);
}
private function onTimer(_arg1:TimerEvent):void{
var _local4:uint;
var _local5:uint;
var _local6:uint;
var _local7:uint;
var _local8:uint;
var _local2:uint;
if (_memoryTimerCount == 4){
_memoryTimerCount = 0;
_local4 = System.totalMemory;
_totalMemory = ((Math.floor(((_local4 / MEGABYTE) * 100)) / 100).toString() + "Mb");
_local2 = 0;
while (_local2 < 9) {
_memoryStack[_local2] = _memoryStack[(_local2 + 1)];
_local2++;
};
_memoryStack[9] = _local4;
_local5 = 100000000000;
_local6 = 0;
_local7 = 0;
_local2 = 0;
while (_local2 < 10) {
if (_memoryStack[_local2] > _local6){
_local6 = _memoryStack[_local2];
};
if (_memoryStack[_local2] < _local5){
_local5 = _memoryStack[_local2];
};
_local2++;
};
_local7 = (_local6 - _local5);
_maxMemoryLabel.text = ((Math.floor(((_local6 / MEGABYTE) * 1000)) / 1000).toString() + "Mb");
_minMemoryLabel.text = ((Math.floor(((_local5 / MEGABYTE) * 1000)) / 1000).toString() + "Mb");
_local8 = uint((GRAPHIC_WIDTH / 10));
_graph.graphics.clear();
_graph.graphics.lineStyle(0, _color);
_graph.graphics.moveTo(0, ((GRAPHIC_HEIGHT * (_local6 - _memoryStack[0])) / _local7));
_local2 = 1;
while (_local2 < 10) {
_graph.graphics.lineTo((_local8 * _local2), ((GRAPHIC_HEIGHT * (_local6 - _memoryStack[_local2])) / _local7));
_local2++;
};
} else {
_memoryTimerCount++;
};
while (_local2 < 3) {
_fpsStack[_local2] = _fpsStack[(_local2 + 1)];
_local2++;
};
_fpsStack[3] = _fpsCount;
_fpsCount = 0;
var _local3:uint = (((_fpsStack[0] + _fpsStack[1]) + _fpsStack[2]) + _fpsStack[3]);
_fpsLabel.text = ((("Fps: " + _local3) + "\nMem: ") + _totalMemory);
}
private function onEnter(_arg1:Event):void{
_fpsCount++;
}
}
}//package utils
Section 351
//FastGamesLogo_5 (WinMenu_fla.FastGamesLogo_5)
package WinMenu_fla {
import flash.events.*;
import flash.display.*;
import flash.net.*;
public dynamic class FastGamesLogo_5 extends MovieClip {
public var btn:SimpleButton;
public function FastGamesLogo_5(){
addFrameScript(0, frame1);
}
function frame1(){
btn.addEventListener(MouseEvent.CLICK, onPlayMoreGames);
}
public function onPlayMoreGames(_arg1:MouseEvent):void{
var _local2:URLRequest;
_local2 = new URLRequest("http://www.fastgames.com/");
navigateToURL(_local2, "_blank");
}
}
}//package WinMenu_fla
Section 352
//AdBox (AdBox)
package {
import flash.display.*;
public dynamic class AdBox extends MovieClip {
}
}//package
Section 353
//AutoresetSkin (AutoresetSkin)
package {
import flash.display.*;
public dynamic class AutoresetSkin extends MovieClip {
}
}//package
Section 354
//BGAnimation (BGAnimation)
package {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import flash.geom.*;
import flash.filters.*;
import flash.text.*;
import flash.net.*;
import flash.media.*;
import flash.ui.*;
import flash.system.*;
import adobe.utils.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.printing.*;
import flash.xml.*;
public dynamic class BGAnimation extends MovieClip {
public var count:uint;
public var i:uint;
public var particle:MovieClip;
public var particleInst1:BGElement;
public var particleInst2:BGElement;
public function BGAnimation(){
addFrameScript(0, frame1);
}
function frame1(){
particleInst1.visible = false;
particleInst2.visible = false;
count = 100;
i = 0;
while (i < count) {
particle = new BGElement();
var _local2 = particle;
with (_local2) {
x = (Math.random() * 700);
y = (Math.random() * 480);
rotation = (Math.random() * 360);
scaleX = (scaleY = Math.random());
alpha = Math.random();
gotoAndStop(int((Math.random() * 6)));
};
addChild(particle);
i++;
};
}
}
}//package
Section 355
//BGElement (BGElement)
package {
import flash.display.*;
public dynamic class BGElement extends MovieClip {
}
}//package
Section 356
//BoardBG (BoardBG)
package {
import flash.display.*;
public dynamic class BoardBG extends MovieClip {
}
}//package
Section 357
//BombSkin (BombSkin)
package {
import flash.display.*;
public dynamic class BombSkin extends MovieClip {
}
}//package
Section 358
//Box1Skin (Box1Skin)
package {
import flash.display.*;
public dynamic class Box1Skin extends MovieClip {
}
}//package
Section 359
//Box2Skin (Box2Skin)
package {
import flash.display.*;
public dynamic class Box2Skin extends MovieClip {
}
}//package
Section 360
//Box3Skin (Box3Skin)
package {
import flash.display.*;
public dynamic class Box3Skin extends MovieClip {
}
}//package
Section 361
//Box4Skin (Box4Skin)
package {
import flash.display.*;
public dynamic class Box4Skin extends MovieClip {
}
}//package
Section 362
//BoxTeam (BoxTeam)
package {
import flash.events.*;
import ui.events.*;
import core.engine.*;
import levels.*;
import flash.display.*;
import memory.*;
import Box2D.Dynamics.*;
import core.renderer.*;
import flash.utils.*;
import org.papervision3d.materials.*;
import sound.*;
import org.papervision3d.view.*;
import org.casalib.ui.*;
import core.*;
import org.papervision3d.cameras.*;
import utils.*;
import org.casalib.util.*;
import org.papervision3d.objects.primitives.*;
import sceneElements.*;
import mochi.as3.*;
import com.pixelfumes.reflect.*;
import flash.ui.*;
public class BoxTeam extends Sprite {
public var levelMenu:LevelMenu;
private var _isDebug:Boolean;// = false
private var _highscoresID:String;// = "0a71ca4eb3efdd6c"
private var _curActiveBoxBody:b2Body;
private var _isAllowReset:Boolean;// = true
public var controls:Controls;
public var helpMenu:HelpMenu;
private var _boxes:Array;
public var timer:GameTimer;
public var sponsorsIntro:MovieClip;
public var winMenu:WinMenu;
public var startMenu:StartMenu;
private var _foreground:BasicView;
public var profiler:Performance;
private function onHighscores(_arg1:Event):void{
MochiScores.showLeaderboard({boardID:_highscoresID});
}
private function onWin():void{
var _local1:uint;
var _local3:uint;
var _local4:uint;
var _local2:Array = Memory.getInstance().arrRecords;
for each (_local3 in _local2) {
_local1 = (_local1 + _local3);
};
_local1 = NumberUtil.roundDecimalToPlace((_local1 / 1000), 1);
_local4 = (1000000 / _local1);
winMenu = new WinMenu();
winMenu.addEventListener(SubmitScoreEvent.TYPE, onSubmitScore);
winMenu.setText(_local1, _local4);
addChild(winMenu);
}
private function createProfiler():void{
profiler = new Performance(15661567);
profiler.x = 500;
profiler.name = "profilerName";
}
private function createMask():void{
var _local1:MainMask = new MainMask();
addChild(_local1);
}
private function onKeyPressed(_arg1:KeyboardEvent):void{
switch (_arg1.keyCode){
case 49:
activateBox(0);
break;
case 50:
activateBox(1);
break;
case 51:
activateBox(2);
break;
case 52:
activateBox(3);
break;
case 53:
activateBox(4);
break;
case 82:
onReset();
break;
case Keyboard.ENTER:
onReset();
break;
case 77:
onMenu();
break;
case 123:
showProfiler();
break;
};
}
private function startGame():void{
sponsorsIntro.stop();
removeChild(sponsorsIntro);
sponsorsIntro = null;
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.frameRate = 50;
StageReference.setStage(stage);
var _local1:ContactsManager = new ContactsManager();
_local1.addEventListener(CoreEvent.COMPLETE_LEVEL, onCompleteLevel);
_local1.addEventListener(CoreEvent.RESET, onReset);
var _local2:Key = Key.getInstance();
_local2.addEventListener(KeyboardEvent.KEY_DOWN, onKeyPressed);
KeyboardListener.getInstance().listen(stage);
createChildren();
addEventListener(Event.ENTER_FRAME, onEnterFrame);
SoundPlayer.getInstance().playMenuSound();
}
private function allowReset():void{
controls.enableReset();
_isAllowReset = true;
}
private function generateLevel(_arg1:LevelDesc, _arg2:Boolean=false):void{
var item:ItemDesc;
var sceneElement:BaseSceneElement;
var bgSkin:Class;
var bg:Plane;
var levelDesc = _arg1;
var isReset = _arg2;
SoundPlayer.getInstance().stopMenuSound();
if (isReset){
SoundPlayer.getInstance().playResetSound();
} else {
SoundPlayer.getInstance().playLevelSound();
};
if (Levels.getInstance().curLevelNo != 10){
timer.x = 8;
} else {
timer.x = 575;
};
timer.y = 8;
timer.visible = true;
timer.startTimer();
Records.getInstance().startRec();
CoreEngine.getInstance().createWorld();
createRenderer();
_boxes = new Array();
for each (item in levelDesc.boxes) {
sceneElement = new item.className(item.props);
_boxes.push(sceneElement);
};
for each (item in levelDesc.others) {
sceneElement = new item.className(item.props);
};
activateBox(0);
bgSkin = (levelDesc.bgSkin) ? levelDesc.bgSkin : BGAnimation;
var mm:MovieMaterial = MaterialListReference.getInstance().bgMaterial(bgSkin);
bg = new Plane(mm, 640, 480);
var _local4 = bg;
with (_local4) {
x = 0;
y = 0;
z = 100;
};
Scene3DReference.getInstance().scene.addChild(bg);
}
public function init(_arg1:Boolean):void{
MochiBot.track(this, "f3c0184b");
if (_arg1){
showSponsorsIntro();
};
}
private function onMute(_arg1:Event):void{
SoundPlayer.getInstance().muteSwitch();
}
private function createChildren():void{
createRenderer();
createControls();
createProfiler();
createMask();
}
private function showProfiler():void{
trace(("showProfiler:" + getChildByName("profilerName")));
if (getChildByName("profilerName")){
removeChild(profiler);
profiler = null;
} else {
createProfiler();
addChild(profiler);
};
}
private function onCompleteLevel(_arg1:CoreEvent):void{
var _local2:Number = Records.getInstance().stopRec();
Memory.getInstance().updateRecords(Levels.getInstance().curLevelNo, _local2);
setTimeout(generateNextLevel, 1000);
}
private function onReset(_arg1:Event=null):void{
if (_isAllowReset){
generateLevel(Levels.getInstance().lastLoadedLevel, true);
setTimeout(allowReset, 500);
controls.disableReset();
_isAllowReset = false;
};
}
private function onPlay(_arg1:Event):void{
removeStartMenu();
onMenu(null, true);
}
private function onEnterFrame(_arg1:Event):void{
updateCamera();
}
private function onOpenLevel(_arg1:OpenLevelEvent):void{
levelMenu.visible = false;
generateLevel(Levels.getInstance().getLevelByNo(_arg1.levelNo));
}
private function removeStartMenu():void{
startMenu.removeEventListener("Play", onPlay);
startMenu.removeEventListener("Help", onHelp);
removeChild(startMenu);
startMenu = null;
}
private function onHelp(_arg1:Event):void{
if (!helpMenu){
helpMenu = new HelpMenu();
addChild(helpMenu);
};
helpMenu.showDialog();
}
private function createStartMenu():void{
startMenu = new StartMenu();
startMenu.addEventListener("Play", onPlay);
startMenu.addEventListener("Help", onHelp);
startMenu.addEventListener("Highscores", onHighscores);
startMenu.visible = true;
addChild(startMenu);
}
public function updateCamera():void{
if (!_curActiveBoxBody){
return;
};
var _local2 = _foreground;
with (_local2) {
camera.x = (camera.x - (((camera.x - (_curActiveBoxBody.GetPosition().x * 30)) + 320) / 100));
camera.y = (camera.y - (((camera.y - (_curActiveBoxBody.GetPosition().y * 5)) - 250) / 10));
};
}
private function showSponsorsIntro():void{
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.frameRate = 24;
sponsorsIntro = (new FastGamesIntro() as MovieClip);
sponsorsIntro.x = 320;
sponsorsIntro.y = 240;
addChild(sponsorsIntro);
setTimeout(startGame, 3000);
}
private function activateBox(_arg1:uint):void{
var _local2:uint;
if (_arg1 >= _boxes.length){
return;
};
controls.changeActiveCube(_arg1);
_local2 = 0;
while (_local2 < _boxes.length) {
if (_local2 != _arg1){
BaseJumpBoxElement(_boxes[_local2]).deactivate();
} else {
BaseJumpBoxElement(_boxes[_local2]).activate();
_curActiveBoxBody = BaseJumpBoxElement(_boxes[_local2]).body;
};
_local2++;
};
}
private function createControls():void{
controls = new Controls();
controls.y = 400;
controls.addEventListener("menu", onMenu);
controls.addEventListener("reset", onReset);
controls.addEventListener("Help", onHelp);
controls.addEventListener("Mute", onMute);
addChild(controls);
levelMenu = new LevelMenu();
levelMenu.addEventListener(OpenLevelEvent.TYPE, onOpenLevel);
levelMenu.addEventListener("resetProgress", onResetProgress);
levelMenu.visible = false;
addChild(levelMenu);
createStartMenu();
timer = new GameTimer();
timer.visible = false;
addChild(timer);
}
private function generateNextLevel():void{
var _local1:LevelDesc = Levels.getInstance().nextLevel;
if (_local1){
generateLevel(_local1);
} else {
timer.visible = false;
timer.stopTimer();
onWin();
};
}
private function createRenderer():void{
if (_foreground){
_foreground.stopRendering();
removeChild(_foreground);
_foreground = null;
};
_foreground = new BasicView(640, 400, false, false, CameraType.TARGET);
var _local2 = _foreground.camera;
with (_local2) {
focus = 100;
zoom = 10;
x = -200;
y = 500;
};
addChildAt(_foreground, 0);
_foreground.startRendering();
Scene3DReference.getInstance().scene = _foreground.scene;
}
private function onMenu(_arg1:Event=null, _arg2:Boolean=false):void{
var _local6:uint;
SoundPlayer.getInstance().stopLevelSound();
if (!_arg2){
SoundPlayer.getInstance().playMenuSound();
};
timer.visible = false;
timer.stopTimer();
var _local3:Memory = Memory.getInstance();
levelMenu.unlock(_local3.numUnlockedLevels);
var _local4:Array = _local3.arrRecords;
var _local5:Array = new Array();
_local6 = 0;
while (_local6 < _local4.length) {
_local5[_local6] = NumberUtil.roundDecimalToPlace((_local4[_local6] / 1000), 1);
_local6++;
};
levelMenu.arrRecords = _local5;
levelMenu.showDialog();
if (_isDebug){
levelMenu.unlock(20);
};
}
private function onSubmitScore(_arg1:SubmitScoreEvent):void{
winMenu.removeEventListener(SubmitScoreEvent.TYPE, onSubmitScore);
removeChild(winMenu);
winMenu = null;
createStartMenu();
trace(((("Submit score: " + _arg1.name) + " , ") + _arg1.score));
MochiScores.showLeaderboard({boardID:_highscoresID, name:_arg1.name, score:_arg1.score});
}
private function onResetProgress(_arg1:Event):void{
Memory.getInstance().clearProgress();
levelMenu.arrRecords = new Array();
levelMenu.unlock(1);
}
}
}//package
Section 363
//CannonBG (CannonBG)
package {
import flash.display.*;
public dynamic class CannonBG extends MovieClip {
}
}//package
Section 364
//CatherineWheel (CatherineWheel)
package {
import org.flintparticles.common.initializers.*;
import org.flintparticles.common.actions.*;
import org.flintparticles.common.counters.*;
import flash.geom.*;
import org.flintparticles.twoD.zones.*;
import org.flintparticles.twoD.emitters.*;
import org.flintparticles.twoD.actions.*;
import org.flintparticles.twoD.activities.*;
import org.flintparticles.common.displayObjects.*;
import org.flintparticles.twoD.initializers.*;
import org.flintparticles.common.energyEasing.*;
public class CatherineWheel extends Emitter2D {
public function CatherineWheel(){
counter = new Steady(150);
addActivity(new RotateEmitter(-7));
addInitializer(new SharedImage(new Line(3)));
addInitializer(new ColorInit(4278229503, 4294967295));
addInitializer(new Velocity(new DiscSectorZone(new Point(0, 0), 350, 200, 0, 0.2)));
addInitializer(new Lifetime(2));
addAction(new Age(Quadratic.easeIn));
addAction(new Move());
addAction(new Fade());
addAction(new Accelerate(0, 50));
addAction(new LinearDrag(0.5));
}
}
}//package
Section 365
//ColumnsBG (ColumnsBG)
package {
import flash.display.*;
public dynamic class ColumnsBG extends MovieClip {
}
}//package
Section 366
//ContactsManager (ContactsManager)
package {
import flash.events.*;
import core.engine.*;
import Box2D.Collision.Shapes.*;
import Box2D.Dynamics.*;
import flash.utils.*;
import sound.*;
import Box2D.Collision.*;
import core.shape.shapeProps.*;
public class ContactsManager extends EventDispatcher {
public function ContactsManager():void{
init();
}
private function init():void{
var _local1:BContactListener = CoreEngine.getInstance().contactListener;
_local1.dispatcher.addEventListener(BContactListener.COLLIDE_ADD, collideAddHandler);
}
private function onBomb(_arg1:b2Body):void{
UserData(_arg1.GetUserData()).type = "";
CoreEngine.getInstance().explode(_arg1.GetPosition());
SoundPlayer.getInstance().playBombSound();
}
private function collideAddHandler(_arg1:CoreEvent):void{
var _local2:b2ContactPoint = (_arg1.data as b2ContactPoint);
var _local3:b2Shape = _local2.shape1;
var _local4:b2Shape = _local2.shape2;
var _local5:String = UserData(_local3.m_body.GetUserData()).type;
var _local6:String = UserData(_local4.m_body.GetUserData()).type;
if ((((_local5 == "none")) && ((_local6 == "none")))){
return;
};
if (_local5 == "bomb"){
onBomb(_local3.m_body);
return;
};
if (_local6 == "bomb"){
onBomb(_local4.m_body);
return;
};
if (_local5 == "autoreset"){
onAutoreset(_local3.m_body);
return;
};
if (_local6 == "autoreset"){
onAutoreset(_local4.m_body);
return;
};
if ((((_local5 == "target")) || ((_local6 == "target")))){
UserData(_local3.m_body.GetUserData()).type = "";
UserData(_local4.m_body.GetUserData()).type = "";
onTarget();
};
}
private function onAutoreset(_arg1:b2Body):void{
UserData(_arg1.GetUserData()).type = "";
setTimeout(resetWithDelay, 500);
}
private function resetWithDelay():void{
dispatchEvent(new CoreEvent(CoreEvent.RESET));
}
private function onTarget():void{
dispatchEvent(new CoreEvent(CoreEvent.COMPLETE_LEVEL));
}
}
}//package
Section 367
//Controls (Controls)
package {
import flash.events.*;
import flash.display.*;
import flash.net.*;
public dynamic class Controls extends MovieClip {
public var activeCube:MovieClip;
public var btnReset:SimpleButton;
public var btnHelp:SimpleButton;
public var btnPlayMoreGames:SimpleButton;
public var btnMenu:SimpleButton;
public function Controls(){
addFrameScript(0, frame1);
}
public function changeActiveCube(_arg1:uint):void{
activeCube.gotoAndStop(("no" + String(_arg1)));
}
public function disableReset():void{
btnReset.enabled = false;
}
function frame1(){
btnMenu.addEventListener(MouseEvent.CLICK, onClickMenu);
btnReset.addEventListener(MouseEvent.CLICK, onClickReset);
btnHelp.addEventListener(MouseEvent.CLICK, onClickHelp);
btnPlayMoreGames.addEventListener(MouseEvent.CLICK, onPlayMoreGames);
}
public function enableReset():void{
btnReset.enabled = true;
}
public function onClickHelp(_arg1:MouseEvent):void{
var _local2:Event;
_local2 = new Event("Help", true);
dispatchEvent(_local2);
}
public function onClickReset(_arg1:MouseEvent):void{
var _local2:Event;
_local2 = new Event("reset", true);
dispatchEvent(_local2);
}
public function onClickMenu(_arg1:MouseEvent):void{
var _local2:Event;
_local2 = new Event("menu", true);
dispatchEvent(_local2);
}
public function onPlayMoreGames(_arg1:MouseEvent):void{
var _local2:URLRequest;
_local2 = new URLRequest("http://www.fastgames.com/");
navigateToURL(_local2, "_blank");
}
}
}//package
Section 368
//DominoesBG (DominoesBG)
package {
import flash.display.*;
public dynamic class DominoesBG extends MovieClip {
}
}//package
Section 369
//DonttouchBG (DonttouchBG)
package {
import flash.display.*;
public dynamic class DonttouchBG extends MovieClip {
}
}//package
Section 370
//DungeonBG (DungeonBG)
package {
import flash.display.*;
public dynamic class DungeonBG extends MovieClip {
}
}//package
Section 371
//EasyFerryBG (EasyFerryBG)
package {
import flash.display.*;
public dynamic class EasyFerryBG extends MovieClip {
}
}//package
Section 372
//FallBG (FallBG)
package {
import flash.display.*;
public dynamic class FallBG extends MovieClip {
}
}//package
Section 373
//FastGamesIntro (FastGamesIntro)
package {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import flash.geom.*;
import flash.filters.*;
import flash.text.*;
import flash.net.*;
import flash.media.*;
import flash.ui.*;
import flash.system.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
public dynamic class FastGamesIntro extends MovieClip {
public var btn:SimpleButton;
public function FastGamesIntro(){
addFrameScript(1, frame2, 6, frame7);
}
function frame7(){
stop();
btn.addEventListener(MouseEvent.CLICK, onClick);
}
function frame2(){
stop();
}
public function onClick(_arg1:MouseEvent):void{
var _local2:URLRequest;
_local2 = new URLRequest("http://www.fastgames.com/");
navigateToURL(_local2, "_blank");
}
}
}//package
Section 374
//GameTimer (GameTimer)
package {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import flash.text.*;
public dynamic class GameTimer extends MovieClip {
public var startTime:Number;
public var tf:TextField;
public function GameTimer(){
addFrameScript(0, frame1);
}
public function updateTimer():void{
var _local1:Number;
var _local2:String;
_local1 = roundDecimalToPlace(((getTimer() - startTime) / 1000), 1);
_local2 = (((_local1 % 1))!=0) ? String(_local1) : (String(_local1) + ".0");
tf.text = (_local2 + "s");
}
public function startTimer():void{
stopTimer();
startTime = getTimer();
addEventListener(Event.ENTER_FRAME, enterFrameHandler);
}
public function enterFrameHandler(_arg1:Event):void{
updateTimer();
}
public function stopTimer():void{
removeEventListener(Event.ENTER_FRAME, enterFrameHandler);
}
function frame1(){
tf.text = "";
}
public function roundDecimalToPlace(_arg1:Number, _arg2:uint):Number{
var _local3:Number;
_local3 = Math.pow(10, _arg2);
return ((Math.round((_arg1 * _local3)) / _local3));
}
}
}//package
Section 375
//GarageBG (GarageBG)
package {
import flash.display.*;
public dynamic class GarageBG extends MovieClip {
}
}//package
Section 376
//HardFerryBG (HardFerryBG)
package {
import flash.display.*;
public dynamic class HardFerryBG extends MovieClip {
}
}//package
Section 377
//HelpMenu (HelpMenu)
package {
import flash.events.*;
import flash.display.*;
public dynamic class HelpMenu extends MovieClip {
public var btnDownload:SimpleButton;
public var btnClose:SimpleButton;
public var btnControls:SimpleButton;
public var _content:MovieClip;
public var btnSettings:SimpleButton;
public var btnCredits:SimpleButton;
public function HelpMenu(){
addFrameScript(0, frame1);
}
public function onSettings(_arg1:MouseEvent=null):void{
_content.gotoAndStop("settings");
}
public function onClose(_arg1:MouseEvent=null):void{
visible = false;
}
function frame1(){
btnControls.addEventListener(MouseEvent.CLICK, onControls);
btnCredits.addEventListener(MouseEvent.CLICK, onCredits);
btnSettings.addEventListener(MouseEvent.CLICK, onSettings);
btnDownload.addEventListener(MouseEvent.CLICK, onDownload);
btnClose.addEventListener(MouseEvent.CLICK, onClose);
}
public function onDownload(_arg1:MouseEvent=null):void{
_content.gotoAndStop("download");
}
public function showDialog():void{
visible = true;
onControls();
}
public function onControls(_arg1:MouseEvent=null):void{
_content.gotoAndStop("controls");
}
public function onCredits(_arg1:MouseEvent=null):void{
_content.gotoAndStop("credits");
}
}
}//package
Section 378
//HighJumpBG (HighJumpBG)
package {
import flash.display.*;
public dynamic class HighJumpBG extends MovieClip {
}
}//package
Section 379
//HurryBG (HurryBG)
package {
import flash.display.*;
public dynamic class HurryBG extends MovieClip {
}
}//package
Section 380
//JumpsBG (JumpsBG)
package {
import flash.display.*;
public dynamic class JumpsBG extends MovieClip {
}
}//package
Section 381
//LevelMenu (LevelMenu)
package {
import flash.events.*;
import ui.events.*;
import flash.display.*;
import flash.utils.*;
import flash.geom.*;
import flash.filters.*;
import flash.text.*;
import flash.net.*;
import flash.media.*;
import flash.ui.*;
import flash.system.*;
import adobe.utils.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.printing.*;
import flash.xml.*;
public dynamic class LevelMenu extends MovieClip {
public var mcAreYouSure:MovieClip;
public var btnReset:SimpleButton;
public var lock1:MovieClip;
public var lock2:MovieClip;
public var lock3:MovieClip;
public var lock4:MovieClip;
public var lock5:MovieClip;
public var lock6:MovieClip;
public var lock8:MovieClip;
public var lock9:MovieClip;
public var b:SimpleButton;
public var lock7:MovieClip;
public var lock10:MovieClip;
public var lock12:MovieClip;
public var lock15:MovieClip;
public var lock16:MovieClip;
public var lock17:MovieClip;
public var lock13:MovieClip;
public var lock14:MovieClip;
public var lock18:MovieClip;
public var lock11:MovieClip;
public var arrRecords:Array;
public var lock20:MovieClip;
public var lock19:MovieClip;
public var arrLocks:Array;
public var btnYes:SimpleButton;
public var btnNo:SimpleButton;
public var arrLevels:Array;
public var mcPreview:MovieClip;
public var btn1:SimpleButton;
public var btn2:SimpleButton;
public var btn3:SimpleButton;
public var btn4:SimpleButton;
public var btn6:SimpleButton;
public var btn7:SimpleButton;
public var btn9:SimpleButton;
public var btn8:SimpleButton;
public var btn5:SimpleButton;
public var tfBestTime:TextField;
public var btn10:SimpleButton;
public var btn11:SimpleButton;
public var btn12:SimpleButton;
public var btn14:SimpleButton;
public var btn16:SimpleButton;
public var btn17:SimpleButton;
public var btn18:SimpleButton;
public var btn19:SimpleButton;
public var btn13:SimpleButton;
public var btn15:SimpleButton;
public var arrBtns:Array;
public var btn20:SimpleButton;
public function LevelMenu(){
addFrameScript(0, frame1);
}
public function onNo(_arg1:MouseEvent):void{
hideResetConfirmation();
}
public function hideResetConfirmation():void{
mcAreYouSure.visible = false;
btnYes.visible = false;
btnNo.visible = false;
}
function frame1(){
arrBtns = [btn1, btn2, btn3, btn4, btn5, btn6, btn7, btn8, btn9, btn10, btn11, btn12, btn13, btn14, btn15, btn16, btn17, btn18, btn19, btn20];
for each (b in arrBtns) {
b.addEventListener(MouseEvent.CLICK, onClick);
b.addEventListener(MouseEvent.ROLL_OVER, onRollover);
b.addEventListener(MouseEvent.ROLL_OUT, onRollout);
};
arrLevels = ["stairs", "tower", "columns", "swing", "cannon", "rotator", "donttouch", "garage", "board", "easyFerry", "dominoes", "lift", "rotors", "jumps", "highJump", "hardFerry", "dungeon", "fall", "threeWays", "hurry"];
arrRecords = new Array();
tfBestTime.visible = false;
arrLocks = [lock1, lock2, lock3, lock4, lock5, lock6, lock7, lock8, lock9, lock10, lock11, lock12, lock13, lock14, lock15, lock16, lock17, lock18, lock19, lock20];
btnReset.addEventListener(MouseEvent.CLICK, onReset);
btnYes.addEventListener(MouseEvent.CLICK, onYes);
btnNo.addEventListener(MouseEvent.CLICK, onNo);
}
public function onYes(_arg1:MouseEvent):void{
var _local2:Event;
_local2 = new Event("resetProgress");
dispatchEvent(_local2);
hideResetConfirmation();
}
public function showDialog():void{
hideResetConfirmation();
visible = true;
}
public function onReset(_arg1:MouseEvent):void{
mcAreYouSure.visible = true;
btnYes.visible = true;
btnNo.visible = true;
}
public function onRollout(_arg1:MouseEvent):void{
mcPreview.gotoAndStop("default");
tfBestTime.visible = false;
}
public function onClick(_arg1:MouseEvent):void{
var _local2:uint;
var _local3:OpenLevelEvent;
if (_arg1.target.enabled == false){
return;
};
_local2 = 0;
while (_local2 < 20) {
if (arrBtns[_local2] == _arg1.target){
_local3 = new OpenLevelEvent(OpenLevelEvent.TYPE);
_local3.levelNo = (_local2 + 1);
dispatchEvent(_local3);
return;
};
_local2++;
};
}
public function unlock(_arg1:uint):void{
var _local2:uint;
_local2 = 0;
while (_local2 < _arg1) {
arrLocks[_local2].visible = false;
arrBtns[_local2].enabled = true;
_local2++;
};
_local2 = _arg1;
while (_local2 < 20) {
arrLocks[_local2].visible = true;
arrBtns[_local2].enabled = false;
_local2++;
};
}
public function onRollover(_arg1:MouseEvent):void{
var _local2:uint;
_local2 = 0;
while (_local2 < 20) {
if (arrBtns[_local2] == _arg1.target){
mcPreview.gotoAndStop(arrLevels[_local2]);
tfBestTime.visible = true;
if (arrRecords[_local2]){
tfBestTime.text = (("Best time: " + arrRecords[_local2]) + " sec");
} else {
tfBestTime.text = "";
};
return;
};
_local2++;
};
mcPreview.gotoAndStop("default");
}
}
}//package
Section 382
//LiftBG (LiftBG)
package {
import flash.display.*;
public dynamic class LiftBG extends MovieClip {
}
}//package
Section 383
//MainMask (MainMask)
package {
import flash.display.*;
public dynamic class MainMask extends MovieClip {
}
}//package
Section 384
//MaterialListReference (MaterialListReference)
package {
import org.papervision3d.materials.utils.*;
import org.papervision3d.materials.*;
import org.papervision3d.lights.*;
import org.papervision3d.materials.shadematerials.*;
public class MaterialListReference {
private var _colors:Array;
private var _light:PointLight3D;
private static var _instance:MaterialListReference;
public function MaterialListReference(_arg1:SingletonEnforcer){
var enforcer = _arg1;
_colors = [0xF77B00, 0xFF0000, 11860222, 8964993, 7504124, 16742277, 12706749, 16767300, 10354492, 10978300];
super();
_light = new PointLight3D(true, false);
var _local3 = _light;
with (_local3) {
x = 200;
y = 500;
z = -300;
};
}
public function wheelMaterial():MovieMaterial{
var _local1:MovieMaterial = new MovieMaterial(new WheelSkin(), true);
_local1.interactive = false;
_local1.doubleSided = false;
_local1.smooth = true;
_local1.allowAutoResize = false;
return (_local1);
}
public function autoresetMaterial():MovieMaterial{
var _local1:MovieMaterial = new MovieMaterial(new AutoresetSkin(), true);
_local1.interactive = false;
_local1.doubleSided = false;
_local1.smooth = true;
_local1.allowAutoResize = false;
return (_local1);
}
public function bombMaterial():MovieMaterial{
var _local1:MovieMaterial = new MovieMaterial(new BombSkin(), true);
_local1.interactive = false;
_local1.doubleSided = false;
_local1.smooth = true;
_local1.allowAutoResize = false;
return (_local1);
}
public function get staticCubeMaterial():MaterialsList{
var _local1:uint = 0x333333;
var _local2:FlatShadeMaterial = new FlatShadeMaterial(_light, _local1, 16773495);
_local2.interactive = false;
var _local3:MaterialsList = new MaterialsList();
_local3.addMaterial(_local2, "all");
return (_local3);
}
public function bgMaterial(_arg1:Class):MovieMaterial{
var _local2:MovieMaterial = new MovieMaterial(new (_arg1), true);
_local2.interactive = false;
_local2.doubleSided = false;
_local2.smooth = true;
_local2.animated = true;
_local2.allowAutoResize = false;
return (_local2);
}
public function boxMaterial(_arg1:uint, _arg2:Class):MaterialsList{
var _local3:MaterialsList = new MaterialsList();
var _local4:FlatShadeMaterial = new FlatShadeMaterial(_light, _arg1, 16773495);
_local4.interactive = false;
_local4.fillAlpha = 0.5;
var _local5:MovieMaterial = new MovieMaterial(new (_arg2), true);
_local5.interactive = false;
_local5.doubleSided = false;
_local5.smooth = true;
_local3.addMaterial(_local4, "top");
_local3.addMaterial(_local4, "bottom");
_local3.addMaterial(_local4, "front");
_local3.addMaterial(_local5, "back");
_local3.addMaterial(_local4, "left");
_local3.addMaterial(_local4, "right");
return (_local3);
}
public function targetMaterial():MovieMaterial{
var _local1:MovieMaterial = new MovieMaterial(new TargetSkin(), true);
_local1.interactive = false;
_local1.doubleSided = false;
_local1.smooth = true;
_local1.allowAutoResize = false;
return (_local1);
}
public function get list():MaterialsList{
var _local1:uint = _colors[Math.floor((Math.random() * 10))];
var _local2:FlatShadeMaterial = new FlatShadeMaterial(_light, _local1, 16773495);
_local2.interactive = false;
_local2.fillAlpha = 0.5;
var _local3:MaterialsList = new MaterialsList();
_local3.addMaterial(_local2, "all");
return (_local3);
}
public static function getInstance():MaterialListReference{
if (_instance == null){
_instance = new MaterialListReference(new SingletonEnforcer());
};
return (_instance);
}
}
}//package
class SingletonEnforcer {
private function SingletonEnforcer(){
}
}
Section 385
//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{
if (Security.sandboxType == "localWithFile"){
return (null);
};
var _local3:MochiBot = new (MochiBot);
_arg1.addChild(_local3);
Security.allowDomain("*");
Security.allowInsecureDomain("*");
var _local4 = "http://core.mochibot.com/my/core.swf";
var _local5:URLVariables = new URLVariables();
_local5["sb"] = Security.sandboxType;
_local5["v"] = Capabilities.version;
_local5["swfid"] = _arg2;
_local5["mv"] = "8";
_local5["fv"] = "9";
var _local6:String = _local3.root.loaderInfo.loaderURL;
if (_local6.indexOf("http") == 0){
_local5["url"] = _local6;
} else {
_local5["url"] = "local";
};
var _local7:URLRequest = new URLRequest(_local4);
_local7.contentType = "application/x-www-form-urlencoded";
_local7.method = URLRequestMethod.POST;
_local7.data = _local5;
var _local8:Loader = new Loader();
_local3.addChild(_local8);
_local8.load(_local7);
return (_local3);
}
}
}//package
Section 386
//MovablePlateSkin (MovablePlateSkin)
package {
import flash.display.*;
public dynamic class MovablePlateSkin extends MovieClip {
}
}//package
Section 387
//MovieBtnContinue (MovieBtnContinue)
package {
import flash.events.*;
import flash.display.*;
public dynamic class MovieBtnContinue extends MovieClip {
public var btnContinue:SimpleButton;
public function MovieBtnContinue(){
addFrameScript(0, frame1);
}
function frame1(){
btnContinue.addEventListener(MouseEvent.CLICK, onClick);
}
public function onClick(_arg1:MouseEvent):void{
dispatchEvent(new Event("continue"));
}
}
}//package
Section 388
//Preloader (Preloader)
package {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import CPMStar.*;
import mochi.as3.*;
public dynamic class Preloader extends MovieClip {
public var loadConditionsFulfilled:uint;// = 0
public var preloaderScreen:PreloaderScreen;
public var btnContinue:MovieClip;
private var did_load:Boolean;
public var adBox:AdBox;
private var _preloaderAdded:Boolean;// = false
public var loadConditionsTotal:uint;// = 2
public static var GAME_OPTIONS:Object = {id:"90956642179ede7d", res:"640x480", background:11784665, color:2053474, outline:7180441, no_bg:true};
public static var MAIN_CLASS:String = "BoxTeam";
public function Preloader(){
MochiServices.connect(GAME_OPTIONS.id, this);
showPreloader();
showAD();
addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
private function showAD():void{
adBox = new AdBox();
adBox.x = 170;
adBox.y = 115;
addChild(adBox);
var _local1:DisplayObject = new AdLoader("1027QBBC92A01");
adBox.addChild(_local1);
setTimeout(init, 10000);
}
private function isOnK():Boolean{
var _local1:String = root.stage.loaderInfo.loaderURL;
if (_local1.indexOf("www.kongregate.com") == -1){
return (false);
};
return (true);
}
private function onEnterFrame(_arg1:Event):void{
if (framesLoaded == totalFrames){
removeEventListener(Event.ENTER_FRAME, onEnterFrame);
init();
};
}
private function init():void{
loadConditionsFulfilled++;
if (loadConditionsFulfilled == loadConditionsTotal){
showContinueBtn();
};
}
private function isOnFLG():Boolean{
var _local1:String = root.stage.loaderInfo.loaderURL;
if (_local1.indexOf("flashgamelicense") == -1){
return (false);
};
return (true);
}
private function showPreloader():void{
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
preloaderScreen = new PreloaderScreen();
addChild(preloaderScreen);
}
private function gotoNextFrame(_arg1:Event=null):void{
removeChild(btnContinue);
removeChild(adBox);
adBox = null;
var _local2:Class = Class(getDefinitionByName(MAIN_CLASS));
var _local3:Object = new (_local2);
addChild((_local3 as DisplayObject));
if (_local3.init){
removeChild(preloaderScreen);
preloaderScreen = null;
_local3.init(true);
};
}
private function showContinueBtn():void{
btnContinue = new MovieBtnContinue();
btnContinue.addEventListener("continue", gotoNextFrame);
btnContinue.x = 320;
btnContinue.y = 400;
addChild(btnContinue);
}
}
}//package
Section 389
//PreloaderScreen (PreloaderScreen)
package {
import flash.events.*;
import flash.display.*;
import flash.geom.*;
import flash.filters.*;
import flash.utils.*;
import org.flintparticles.twoD.emitters.*;
import org.flintparticles.twoD.renderers.*;
import flash.net.*;
import adobe.utils.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.media.*;
import flash.printing.*;
import flash.system.*;
import flash.text.*;
import flash.ui.*;
import flash.xml.*;
public dynamic class PreloaderScreen extends MovieClip {
public var emitter:Emitter2D;
public var circle:MovieClip;
public function PreloaderScreen(){
addFrameScript(0, frame1);
}
function frame1(){
startEffect();
addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
public function startEffect(){
var _local1:BitmapRenderer;
emitter = new CatherineWheel();
_local1 = new BitmapRenderer(new Rectangle(0, 0, 640, 480));
_local1.addFilter(new BlurFilter(2, 2, 1));
_local1.addFilter(new ColorMatrixFilter([1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0.97, 0]));
_local1.addEmitter(emitter);
addChildAt(_local1, 2);
emitter.x = 320;
emitter.y = 240;
emitter.start();
}
public function onEnterFrame(_arg1:Event):void{
circle.rotator.rotation = (circle.rotator.rotation + 10);
}
}
}//package
Section 390
//RotatorBG (RotatorBG)
package {
import flash.display.*;
public dynamic class RotatorBG extends MovieClip {
}
}//package
Section 391
//RotorsBG (RotorsBG)
package {
import flash.display.*;
public dynamic class RotorsBG extends MovieClip {
}
}//package
Section 392
//SleepBoxSkin (SleepBoxSkin)
package {
import flash.display.*;
public dynamic class SleepBoxSkin extends MovieClip {
}
}//package
Section 393
//StairsBG (StairsBG)
package {
import flash.display.*;
public dynamic class StairsBG extends MovieClip {
}
}//package
Section 394
//StartMenu (StartMenu)
package {
import flash.events.*;
import flash.display.*;
import flash.net.*;
public dynamic class StartMenu extends MovieClip {
public var btnPlay:SimpleButton;
public var btnHelp:SimpleButton;
public var btnPlayMoreGames:SimpleButton;
public var btnHighscores:SimpleButton;
public function StartMenu(){
addFrameScript(0, frame1);
}
function frame1(){
btnPlay.addEventListener(MouseEvent.CLICK, onPlay);
btnHelp.addEventListener(MouseEvent.CLICK, onHelp);
btnHighscores.addEventListener(MouseEvent.CLICK, onHighscores);
btnPlayMoreGames.addEventListener(MouseEvent.CLICK, onPlayMoreGames);
}
public function onHighscores(_arg1:MouseEvent):void{
var _local2:Event;
_local2 = new Event("Highscores");
dispatchEvent(_local2);
}
public function onPlay(_arg1:MouseEvent):void{
var _local2:Event;
_local2 = new Event("Play");
dispatchEvent(_local2);
}
public function onHelp(_arg1:MouseEvent):void{
var _local2:Event;
_local2 = new Event("Help");
dispatchEvent(_local2);
}
public function onPlayMoreGames(_arg1:MouseEvent):void{
var _local2:URLRequest;
_local2 = new URLRequest("http://www.fastgames.com/");
navigateToURL(_local2, "_blank");
}
}
}//package
Section 395
//SwingBG (SwingBG)
package {
import flash.display.*;
public dynamic class SwingBG extends MovieClip {
}
}//package
Section 396
//TargetSkin (TargetSkin)
package {
import flash.display.*;
public dynamic class TargetSkin extends MovieClip {
}
}//package
Section 397
//ThreeWaysBG (ThreeWaysBG)
package {
import flash.display.*;
public dynamic class ThreeWaysBG extends MovieClip {
}
}//package
Section 398
//TowerBG (TowerBG)
package {
import flash.display.*;
public dynamic class TowerBG extends MovieClip {
}
}//package
Section 399
//WheelSkin (WheelSkin)
package {
import flash.display.*;
public dynamic class WheelSkin extends MovieClip {
}
}//package
Section 400
//WinMenu (WinMenu)
package {
import flash.events.*;
import ui.events.*;
import flash.display.*;
import org.flintparticles.common.events.*;
import flash.geom.*;
import flash.filters.*;
import flash.text.*;
import org.flintparticles.twoD.emitters.*;
import org.flintparticles.twoD.renderers.*;
import org.flintparticles.common.displayObjects.*;
import org.flintparticles.twoD.zones.*;
import org.flintparticles.common.counters.*;
import flash.ui.*;
import org.flintparticles.common.initializers.*;
import org.flintparticles.twoD.initializers.*;
import org.flintparticles.common.actions.*;
import org.flintparticles.common.energyEasing.*;
import org.flintparticles.twoD.actions.*;
public dynamic class WinMenu extends MovieClip {
public var tfName:TextField;
public var tfScore:TextField;
public var emitter:Emitter2D;
public var btnSubmitScore:SimpleButton;
public var _score:uint;
public var renderer:BitmapRenderer;
public function WinMenu(){
addFrameScript(0, frame1);
}
public function onKeyDowmName(_arg1:KeyboardEvent):void{
if (_arg1.keyCode == Keyboard.ENTER){
submitScore();
};
}
public function restart(_arg1:EmitterEvent):void{
Emitter2D(_arg1.target).start();
}
public function submitScore(_arg1:MouseEvent=null):void{
var _local2:SubmitScoreEvent;
if (((!((tfName.text == ""))) && (!((tfName.text == "Enter your name"))))){
_local2 = new SubmitScoreEvent(SubmitScoreEvent.TYPE);
_local2.name = tfName.text;
_local2.score = _score;
dispatchEvent(_local2);
return;
};
}
public function onFocusName(_arg1:FocusEvent):void{
tfName.text = "";
}
function frame1(){
tfName.addEventListener(FocusEvent.FOCUS_IN, onFocusName);
tfName.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDowmName);
btnSubmitScore.addEventListener(MouseEvent.CLICK, submitScore);
emitter = new Emitter2D();
emitter.counter = new Blast(300);
emitter.addInitializer(new SharedImage(new Dot(2)));
emitter.addInitializer(new ColorInit(4290048254, 4278208366));
emitter.addInitializer(new Velocity(new DiscZone(new Point(0, 0), 320, 0)));
emitter.addInitializer(new Lifetime(4));
emitter.addAction(new Age(Quadratic.easeIn));
emitter.addAction(new Move());
emitter.addAction(new Fade());
emitter.addAction(new Accelerate(0, 50));
emitter.addAction(new LinearDrag(0.5));
emitter.addEventListener(EmitterEvent.EMITTER_EMPTY, restart, false, 0, true);
renderer = new BitmapRenderer(new Rectangle(0, 0, 640, 480));
renderer.addFilter(new BlurFilter(2, 2, 1));
renderer.addFilter(new ColorMatrixFilter([1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0.95, 0]));
renderer.addEmitter(emitter);
addChildAt(renderer, 3);
emitter.x = 320;
emitter.y = 150;
emitter.start();
}
public function setText(_arg1:uint, _arg2:uint):void{
tfScore.text = (((("Final score: " + _arg2) + " (total time: ") + _arg1) + "s)");
_score = _arg2;
}
}
}//package