Section 1
//DebugDispatcher (com.blitzagency.xray.logger.events.DebugDispatcher)
package com.blitzagency.xray.logger.events {
import flash.events.*;
public class DebugDispatcher extends EventDispatcher {
public static var TRACE:String = "trace";
public function sendEvent(_arg1:String, _arg2:Object):void{
dispatchEvent(new DebugEvent(DebugDispatcher.TRACE, false, false, _arg2));
}
}
}//package com.blitzagency.xray.logger.events
Section 2
//DebugEvent (com.blitzagency.xray.logger.events.DebugEvent)
package com.blitzagency.xray.logger.events {
import flash.events.*;
public class DebugEvent extends Event {
public var obj:Object;
public function DebugEvent(_arg1:String, _arg2:Boolean, _arg3:Boolean, _arg4:Object):void{
obj = new Object();
super(_arg1, _arg2, _arg3);
obj = _arg4;
}
}
}//package com.blitzagency.xray.logger.events
Section 3
//ObjectTools (com.blitzagency.xray.logger.util.ObjectTools)
package com.blitzagency.xray.logger.util {
import com.blitzagency.xray.logger.*;
import flash.utils.*;
public class ObjectTools {
private static var log:XrayLog = new XrayLog();
public function resolveBaseType(_arg1:Object):String{
return ("");
}
public static function getImmediateClassPath(_arg1:Object):String{
var _local2:String;
var _local3:String;
_local2 = getQualifiedClassName(_arg1);
_local3 = getQualifiedSuperclassName(_arg1);
_local2 = ((_local2.indexOf("::") > -1)) ? _local2.split("::").join(".") : _local2;
if (_local3 == null){
return (_local2);
};
_local3 = ((_local3.indexOf("::") > -1)) ? _local3.split("::").join(".") : _local3;
return (((_local3 + ".") + _local2));
}
public static function getFullClassPath(_arg1:Object):String{
var _local2:XML;
var _local3:Array;
var _local4:String;
var _local5:XML;
var _local6:String;
_local2 = describeType(_arg1);
_local3 = [];
_local4 = getQualifiedClassName(_arg1);
_local4 = ((_local4.indexOf("::") > -1)) ? _local4.split("::").join(".") : _local4;
_local3.push(_local4);
for each (_local5 in _local2.extendsClass) {
_local6 = ((_local5.@type.toString().indexOf("::") > -1)) ? _local5.@type.toString().split("::")[1] : _local5.@type.toString();
_local3.push(_local6);
};
return (_local3.join("."));
}
}
}//package com.blitzagency.xray.logger.util
Section 4
//PropertyTools (com.blitzagency.xray.logger.util.PropertyTools)
package com.blitzagency.xray.logger.util {
import flash.utils.*;
public class PropertyTools {
private static function getVariables():void{
}
public static function getProperties(_arg1:Object):Array{
var ary:Array;
var xmlDoc:XML;
var item:XML;
var name:String;
var type:String;
var value:Object;
var obj = _arg1;
ary = [];
try {
xmlDoc = describeType(obj);
for each (item in xmlDoc.variable) {
name = item.@name.toString();
type = item.@type.toString();
value = ((obj[name])!=null) ? obj[name] : "";
ary.push({name:name, type:type, value:value});
};
} catch(e:Error) {
};
return (ary);
}
private static function getMethods():void{
}
}
}//package com.blitzagency.xray.logger.util
Section 5
//Debug (com.blitzagency.xray.logger.Debug)
package com.blitzagency.xray.logger {
import flash.events.*;
import flash.utils.*;
import com.blitzagency.xray.logger.events.*;
import flash.net.*;
public class Debug {
private static var connected:Boolean = false;
private static var xrayLC:LocalConnection;
private static var ed:DebugDispatcher = new DebugDispatcher();
public static function traceObject(_arg1:Object, _arg2:Number=254, _arg3:Number=0, _arg4:String="", _arg5:Number=0):void{
var recurseDepth:Number;
var indent:Number;
var prop:String;
var lead:String;
var i:Number;
var obj:String;
var o = _arg1;
var pRecurseDepth = _arg2;
var pIndent = _arg3;
var pPackage = _arg4;
var pLevel = _arg5;
try {
recurseDepth = pRecurseDepth;
indent = pIndent;
for (prop in o) {
lead = "";
i = 0;
while (i < indent) {
lead = (lead + " ");
i = (i + 1);
};
obj = o[prop].toString();
if ((o[prop] is Array)){
obj = "[Array]";
};
if (obj == "[object Object]"){
obj = "[Object]";
};
Debug.trace((((lead + prop) + ": ") + obj), pPackage, pLevel);
if (recurseDepth > 0){
Debug.traceObject(o[prop], (recurseDepth - 1), (indent + 1), pPackage, pLevel);
};
};
} catch(e:Error) {
};
}
public static function trace(_arg1:Object, _arg2:String="", _arg3:Number=0):void{
var msg:String;
var pMsg = _arg1;
var pPackage = _arg2;
var pLevel = _arg3;
ed.sendEvent(DebugDispatcher.TRACE, {message:pMsg, classPackage:pPackage});
if (!connected){
makeConnection();
};
if (connected){
try {
msg = ((String(pMsg).length >= 39995)) ? (String(pMsg).substr(0, 39995) + "...") : String(pMsg);
xrayLC.send("_xray_view_conn", "setTrace", msg, pLevel, pPackage);
} catch(e:LogError) {
LogError("No Xray Interface running");
};
};
}
private static function makeConnection():void{
var err:LogError;
xrayLC = new LocalConnection();
xrayLC.addEventListener("status", statusHandler);
xrayLC.allowDomain("*");
try {
xrayLC.connect(("_xray_standAlone_debug" + getTimer()));
connected = true;
} catch(e:Error) {
err = new LogError("log");
setTimeout(makeConnection, 1000);
};
}
public static function addEventListener(_arg1:String, _arg2:Function):void{
ed.addEventListener(_arg1, _arg2);
}
private static function initialize():Boolean{
ed = new DebugDispatcher();
return (true);
}
private static function statusHandler(_arg1:StatusEvent):void{
if ((((((_arg1.code == null)) && ((_arg1.level == "error")))) && (connected))){
connected = false;
} else {
if ((((_arg1.level == "status")) && ((_arg1.code == null)))){
connected = true;
};
};
}
}
}//package com.blitzagency.xray.logger
class LogError extends Error {
private function LogError(_arg1:String){
super(_arg1);
}
}
Section 6
//Log (com.blitzagency.xray.logger.Log)
package com.blitzagency.xray.logger {
import com.blitzagency.xray.logger.util.*;
public class Log {
private var level:Number;
private var caller:String;// = ""
private var classPackage:String;
private var dump:Object;
private var message:String;
public function Log(_arg1:String, _arg2:Object, _arg3:Number, ... _args){
var err:LogError;
var nullArray:Array;
var str:String;
var p_message = _arg1;
var p_dump = _arg2;
var p_level = _arg3;
var rest = _args;
caller = "";
super();
try {
nullArray.push("bogus");
} catch(e:Error) {
err = new LogError("log");
} finally {
if (err.hasOwnProperty("getStackTrace")){
str = err.getStackTrace();
setCaller(resolveCaller(str));
} else {
setCaller("");
};
setMessage(p_message);
setDump(p_dump);
setLevel(p_level);
setClassPackage(p_dump);
};
}
public function setLevel(_arg1:Number):void{
level = _arg1;
}
public function getCaller():String{
return (caller);
}
public function setMessage(_arg1:String):void{
message = _arg1;
}
public function getLevel():Number{
return (level);
}
public function getDump():Object{
return (dump);
}
public function setCaller(_arg1:String):void{
caller = _arg1;
}
public function setClassPackage(_arg1:Object):void{
classPackage = ObjectTools.getImmediateClassPath(_arg1);
}
public function getMessage():String{
return (message);
}
public function getClassPackage():String{
return (classPackage);
}
public function setDump(_arg1:Object):void{
dump = _arg1;
}
private function resolveCaller(_arg1:String):String{
var ary:Array;
var str = _arg1;
ary = [];
try {
str = str.split("\n").join("");
ary = str.split("\tat ");
str = ary[3];
} catch(e:Error) {
} finally {
str = "";
};
return (str);
}
}
}//package com.blitzagency.xray.logger
class LogError extends Error {
private function LogError(_arg1:String){
super(_arg1);
}
}
Section 7
//Logger (com.blitzagency.xray.logger.Logger)
package com.blitzagency.xray.logger {
public interface Logger {
function setLevel(_arg1:Number=0):void;
function debug(_arg1:Log):void;
function fatal(_arg1:Log):void;
function warn(_arg1:Log):void;
function error(_arg1:Log):void;
function log(_arg1:String, _arg2:String, _arg3:String, _arg4:Number, _arg5:Object=null):void;
function info(_arg1:Log):void;
}
}//package com.blitzagency.xray.logger
Section 8
//XrayLog (com.blitzagency.xray.logger.XrayLog)
package com.blitzagency.xray.logger {
public class XrayLog {
private var logger:XrayLogger;
public function XrayLog(){
logger = XrayLogger.getInstance();
}
public function debug(_arg1:String, ... _args):void{
var _local3:Number;
if (_args.length == 0){
logger.debug(new Log(_arg1, null, XrayLogger.DEBUG));
};
_local3 = 0;
while (_local3 < _args.length) {
if (_local3 > 0){
_arg1 = "";
};
logger.debug(new Log(_arg1, _args[_local3], XrayLogger.DEBUG));
_local3++;
};
}
public function fatal(_arg1:String, ... _args):void{
var _local3:Number;
if (_args.length == 0){
logger.fatal(new Log(_arg1, null, XrayLogger.FATAL));
};
_local3 = 0;
while (_local3 < _args.length) {
if (_local3 > 0){
_arg1 = "";
};
logger.fatal(new Log(_arg1, _args[_local3], XrayLogger.FATAL));
_local3++;
};
}
public function info(_arg1:String, ... _args):void{
var _local3:Number;
if (_args.length == 0){
logger.info(new Log(_arg1, null, XrayLogger.INFO));
};
_local3 = 0;
while (_local3 < _args.length) {
if (_local3 > 0){
_arg1 = "";
};
logger.info(new Log(_arg1, _args[_local3], XrayLogger.INFO));
_local3++;
};
}
public function warn(_arg1:String, ... _args):void{
var _local3:Number;
if (_args.length == 0){
logger.warn(new Log(_arg1, null, XrayLogger.WARN));
};
_local3 = 0;
while (_local3 < _args.length) {
if (_local3 > 0){
_arg1 = "";
};
logger.warn(new Log(_arg1, _args[_local3], XrayLogger.WARN));
_local3++;
};
}
public function error(_arg1:String, ... _args):void{
var _local3:Number;
if (_args.length == 0){
logger.error(new Log(_arg1, null, XrayLogger.ERROR));
};
_local3 = 0;
while (_local3 < _args.length) {
if (_local3 > 0){
_arg1 = "";
};
logger.error(new Log(_arg1, _args[_local3], XrayLogger.ERROR));
_local3++;
};
}
}
}//package com.blitzagency.xray.logger
Section 9
//XrayLogger (com.blitzagency.xray.logger.XrayLogger)
package com.blitzagency.xray.logger {
import flash.events.*;
import flash.utils.*;
import com.blitzagency.xray.logger.util.*;
public class XrayLogger extends EventDispatcher implements Logger {
private var displayObjectRecursionDepth:Number;// = 3
private var level:Number;// = 0
private var indentation:Number;// = 0
private var objectRecursionDepth:Number;// = 254
private var filters:Array;
public static var FATAL:Number = 4;
public static var WARN:Number = 2;
public static var ERROR:Number = 3;
public static var INFO:Number = 1;
public static var DEBUG:Number = 0;
private static var _instance:XrayLogger = null;
public static var NONE:Number = 5;
public function XrayLogger(){
level = 0;
displayObjectRecursionDepth = 3;
objectRecursionDepth = 254;
indentation = 0;
filters = [];
super();
}
public function checkFilters():Boolean{
var _local1:uint;
if (filters.length == 0){
return (true);
};
_local1 = 0;
while (_local1 < filters.length) {
_local1++;
};
return (true);
}
public function debug(_arg1:Log):void{
if (_arg1.getLevel() == level){
log(_arg1.getMessage(), _arg1.getCaller(), _arg1.getClassPackage(), 0, _arg1.getDump());
};
}
public function setIndentation(_arg1:Number=0):void{
indentation = _arg1;
}
public function error(_arg1:Log):void{
if (_arg1.getLevel() >= level){
log(_arg1.getMessage(), _arg1.getCaller(), _arg1.getClassPackage(), 3, _arg1.getDump());
};
}
public function setLevel(_arg1:Number=0):void{
level = _arg1;
}
public function fatal(_arg1:Log):void{
if (_arg1.getLevel() >= level){
log(_arg1.getMessage(), _arg1.getCaller(), _arg1.getClassPackage(), 4, _arg1.getDump());
};
}
public function warn(_arg1:Log):void{
if (_arg1.getLevel() >= level){
log(_arg1.getMessage(), _arg1.getCaller(), _arg1.getClassPackage(), 2, _arg1.getDump());
};
}
public function setObjectRecursionDepth(_arg1:Number):void{
objectRecursionDepth = _arg1;
}
public function setDisplayClipRecursionDepth(_arg1:Number):void{
displayObjectRecursionDepth = _arg1;
}
public function info(_arg1:Log):void{
if (_arg1.getLevel() >= level){
log(_arg1.getMessage(), _arg1.getCaller(), _arg1.getClassPackage(), 1, _arg1.getDump());
};
}
public function log(_arg1:String, _arg2:String, _arg3:String, _arg4:Number, _arg5:Object=null):void{
var _local6:String;
var _local7:String;
var _local8:String;
var _local9:Object;
_local6 = (("(" + getTimer()) + ") ");
if (_arg3.length > 0){
_local6 = (_local6 + (_arg2 + "\n"));
};
_local6 = (_local6 + _arg1);
if (_arg1.length > 0){
Debug.trace(_local6, _arg3, _arg4);
};
if (_arg5 == null){
return;
};
_local7 = typeof(_arg5);
if ((((((((((_local7 == "string")) || ((_local7 == "number")))) || ((_local7 == "boolean")))) || ((_local7 == "undefined")))) || ((_local7 == "null")))){
Debug.trace(_arg5, _arg3, _arg4);
} else {
if (_local7 == "xml"){
Debug.trace(_arg5.toString(), _arg3, _arg4);
} else {
_local8 = ObjectTools.getImmediateClassPath(_arg5);
if ((((_local8 == "Object")) || ((_local8 == "Object.Array")))){
Debug.traceObject(_arg5, objectRecursionDepth, indentation, _arg3, _arg4);
} else {
_local9 = PropertyTools.getProperties(_arg5);
Debug.traceObject(_local9, displayObjectRecursionDepth, indentation, _arg3, _arg4);
};
};
};
}
public function setFilters(_arg1:Array):void{
filters = _arg1;
}
public static function getInstance():XrayLogger{
if (_instance == null){
_instance = new (XrayLogger);
};
return (_instance);
}
public static function resolveLevelAsName(_arg1:Number):String{
switch (_arg1){
case 0:
return ("debug");
case 1:
return ("info");
case 2:
return ("warn");
case 3:
return ("error");
case 4:
return ("fatal");
default:
return ("debug");
};
}
}
}//package com.blitzagency.xray.logger
Section 10
//Camera3D (org.papervision3d.cameras.Camera3D)
package org.papervision3d.cameras {
import org.papervision3d.core.proto.*;
import org.papervision3d.core.math.*;
import org.papervision3d.objects.*;
public class Camera3D extends CameraObject3D {
public var goto:Number3D;
public var target:DisplayObject3D;
public static const TYPE:String = "CAMERA3D";
public function Camera3D(_arg1:DisplayObject3D=null, _arg2:Number=2, _arg3:Number=100, _arg4:Object=null){
super(_arg2, _arg3, _arg4);
this.target = ((_arg1) || (DisplayObject3D.ZERO));
this.goto = new Number3D(this.x, this.y, this.z);
}
public function hover(_arg1:Number, _arg2:Number, _arg3:Number):void{
var _local4:DisplayObject3D;
var _local5:Number3D;
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;
_local4 = this.target;
_local5 = this.goto;
_local6 = 8;
switch (_arg1){
case 0:
_local7 = (_local5.x - _local4.x);
_local8 = (_local5.z - _local4.z);
_local9 = Math.atan2(_local8, _local7);
_local10 = Math.sqrt(((_local7 * _local7) + (_local8 * _local8)));
_local11 = (0.5 * _arg2);
_local12 = (_local10 * Math.cos((_local9 - _local11)));
_local13 = (_local10 * Math.sin((_local9 - _local11)));
_local14 = (_local5.y - (300 * _arg3));
this.x = (this.x - ((this.x - _local12) / _local6));
this.y = (this.y - ((this.y - _local14) / _local6));
this.z = (this.z - ((this.z - _local13) / _local6));
break;
case 1:
this.x = (this.x - ((this.x - (1000 * _arg2)) / _local6));
this.y = (this.y - ((this.y - (1000 * _arg3)) / _local6));
break;
};
}
override public function transformView(_arg1:Matrix3D=null):void{
this.lookAt(this.target);
super.transformView();
}
}
}//package org.papervision3d.cameras
Section 11
//CoordinateTools (org.papervision3d.core.components.as3.utils.CoordinateTools)
package org.papervision3d.core.components.as3.utils {
import flash.display.*;
import flash.geom.*;
public class CoordinateTools {
public static function random(_arg1:Number):Number{
return (Math.floor((Math.random() * _arg1)));
}
public static function localToLocal(_arg1:DisplayObject, _arg2:DisplayObject, _arg3:Point=null):Point{
var _local4:Point;
_local4 = (_arg3) ? _arg3 : new Point();
_local4 = _arg1.localToGlobal(_local4);
_local4 = _arg2.globalToLocal(_local4);
return (_local4);
}
}
}//package org.papervision3d.core.components.as3.utils
Section 12
//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 13
//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 14
//DefaultTriangleCuller (org.papervision3d.core.culling.DefaultTriangleCuller)
package org.papervision3d.core.culling {
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.proto.*;
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 15
//FrustumTestMethod (org.papervision3d.core.culling.FrustumTestMethod)
package org.papervision3d.core.culling {
public class FrustumTestMethod {
public static const BOUNDING_SPHERE:int = 0;
public static const BOUNDING_BOX:int = 1;
}
}//package org.papervision3d.core.culling
Section 16
//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 17
//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 18
//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 19
//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 20
//RectangleLineCuller (org.papervision3d.core.culling.RectangleLineCuller)
package org.papervision3d.core.culling {
import org.papervision3d.core.geom.renderables.*;
import flash.geom.*;
import org.papervision3d.core.math.util.*;
public class RectangleLineCuller implements ILineCuller {
private var rectIntersection:Rectangle;
private var lineBoundsRect:Rectangle;
private var cullingRectangle:Rectangle;
public function RectangleLineCuller(_arg1:Rectangle=null):void{
if (_arg1){
this.cullingRectangle = _arg1;
};
lineBoundsRect = new Rectangle();
rectIntersection = new Rectangle();
}
public function testLine(_arg1:Line3D):Boolean{
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
if (((!(_arg1.v0.vertex3DInstance.visible)) || (!(_arg1.v1.vertex3DInstance.visible)))){
return (false);
};
_local2 = _arg1.v0.vertex3DInstance.x;
_local3 = _arg1.v0.vertex3DInstance.y;
_local4 = _arg1.v1.vertex3DInstance.x;
_local5 = _arg1.v1.vertex3DInstance.y;
lineBoundsRect.width = Math.abs((_local4 - _local2));
lineBoundsRect.height = Math.abs((_local5 - _local3));
if (_local2 < _local4){
lineBoundsRect.x = _local2;
} else {
lineBoundsRect.x = _local4;
};
if (_local3 < _local5){
lineBoundsRect.y = _local3;
} else {
lineBoundsRect.y = _local5;
};
if (cullingRectangle.containsRect(lineBoundsRect)){
return (true);
};
if (!FastRectangleTools.intersects(lineBoundsRect, cullingRectangle)){
return (false);
};
rectIntersection = FastRectangleTools.intersection(lineBoundsRect, cullingRectangle);
_local6 = ((_local5 - _local3) / (_local4 - _local2));
_local7 = (_local3 - (_local6 * _local2));
_local8 = ((cullingRectangle.top - _local7) / _local6);
if ((((_local8 > rectIntersection.left)) && ((_local8 < rectIntersection.right)))){
return (true);
};
_local8 = ((cullingRectangle.bottom - _local7) / _local6);
if ((((_local8 > rectIntersection.left)) && ((_local8 < rectIntersection.right)))){
return (true);
};
_local9 = ((_local6 * cullingRectangle.left) + _local7);
if ((((_local9 > rectIntersection.top)) && ((_local9 < rectIntersection.bottom)))){
return (true);
};
_local9 = ((_local6 * cullingRectangle.right) + _local7);
if ((((_local9 > rectIntersection.top)) && ((_local9 < rectIntersection.bottom)))){
return (true);
};
return (false);
}
}
}//package org.papervision3d.core.culling
Section 21
//RectangleParticleCuller (org.papervision3d.core.culling.RectangleParticleCuller)
package org.papervision3d.core.culling {
import org.papervision3d.core.geom.renderables.*;
import flash.geom.*;
import org.papervision3d.core.math.util.*;
public class RectangleParticleCuller implements IParticleCuller {
public var cullingRectangle:Rectangle;
private static var vInstance:Vertex3DInstance;
private static var testPoint:Point;
public function RectangleParticleCuller(_arg1:Rectangle=null){
this.cullingRectangle = _arg1;
testPoint = new Point();
}
public function testParticle(_arg1:Particle):Boolean{
vInstance = _arg1.vertex3D.vertex3DInstance;
if (_arg1.material.invisible == false){
if (vInstance.visible){
if (FastRectangleTools.intersects(_arg1.renderRect, cullingRectangle)){
return (true);
};
};
};
return (false);
}
}
}//package org.papervision3d.core.culling
Section 22
//RectangleTriangleCuller (org.papervision3d.core.culling.RectangleTriangleCuller)
package org.papervision3d.core.culling {
import org.papervision3d.core.geom.renderables.*;
import flash.geom.*;
import org.papervision3d.core.math.util.*;
public class RectangleTriangleCuller extends DefaultTriangleCuller implements ITriangleCuller {
public var cullingRectangle:Rectangle;
private static const DEFAULT_RECT_X:Number = -((DEFAULT_RECT_W / 2));
private static const DEFAULT_RECT_W:Number = 640;
private static const DEFAULT_RECT_H:Number = 480;
private static const DEFAULT_RECT_Y:Number = -((DEFAULT_RECT_H / 2));
private static var hitRect:Rectangle = new Rectangle();
public function RectangleTriangleCuller(_arg1:Rectangle=null):void{
cullingRectangle = new Rectangle(DEFAULT_RECT_X, DEFAULT_RECT_Y, DEFAULT_RECT_W, DEFAULT_RECT_H);
super();
if (_arg1){
this.cullingRectangle = _arg1;
};
}
override public function testFace(_arg1:Triangle3D, _arg2:Vertex3DInstance, _arg3:Vertex3DInstance, _arg4:Vertex3DInstance):Boolean{
if (super.testFace(_arg1, _arg2, _arg3, _arg4)){
hitRect.x = Math.min(_arg4.x, Math.min(_arg3.x, _arg2.x));
hitRect.width = (Math.max(_arg4.x, Math.max(_arg3.x, _arg2.x)) + Math.abs(hitRect.x));
hitRect.y = Math.min(_arg4.y, Math.min(_arg3.y, _arg2.y));
hitRect.height = (Math.max(_arg4.y, Math.max(_arg3.y, _arg2.y)) + Math.abs(hitRect.y));
return (FastRectangleTools.intersects(cullingRectangle, hitRect));
};
return (false);
}
}
}//package org.papervision3d.core.culling
Section 23
//ViewportObjectFilter (org.papervision3d.core.culling.ViewportObjectFilter)
package org.papervision3d.core.culling {
import org.papervision3d.objects.*;
import flash.utils.*;
public class ViewportObjectFilter implements IObjectCuller {
protected var _mode:int;
protected var objects:Dictionary;
public function ViewportObjectFilter(_arg1:int):void{
this.mode = _arg1;
init();
}
public function addObject(_arg1:DisplayObject3D):void{
objects[_arg1] = _arg1;
}
public function removeObject(_arg1:DisplayObject3D):void{
delete objects[_arg1];
}
public function set mode(_arg1:int):void{
_mode = _arg1;
}
public function get mode():int{
return (_mode);
}
private function init():void{
objects = new Dictionary(true);
}
public function testObject(_arg1:DisplayObject3D):int{
if (objects[_arg1]){
if (_mode == ViewportObjectFilterMode.INCLUSIVE){
return (1);
};
if (_mode == ViewportObjectFilterMode.EXCLUSIVE){
return (0);
};
} else {
if (_mode == ViewportObjectFilterMode.INCLUSIVE){
return (0);
};
if (_mode == ViewportObjectFilterMode.EXCLUSIVE){
return (1);
};
};
return (0);
}
public function destroy():void{
objects = null;
}
}
}//package org.papervision3d.core.culling
Section 24
//ViewportObjectFilterMode (org.papervision3d.core.culling.ViewportObjectFilterMode)
package org.papervision3d.core.culling {
public class ViewportObjectFilterMode {
public static const INCLUSIVE:int = 0;
public static const EXCLUSIVE:int = 1;
}
}//package org.papervision3d.core.culling
Section 25
//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 26
//AbstractRenderable (org.papervision3d.core.geom.renderables.AbstractRenderable)
package org.papervision3d.core.geom.renderables {
import org.papervision3d.core.render.command.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.data.*;
public class AbstractRenderable implements IRenderable {
public var _userData:UserData;
public var instance:DisplayObject3D;
public function getRenderListItem():IRenderListItem{
return (null);
}
public function set userData(_arg1:UserData):void{
_userData = _arg1;
}
public function get userData():UserData{
return (_userData);
}
}
}//package org.papervision3d.core.geom.renderables
Section 27
//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 28
//Line3D (org.papervision3d.core.geom.renderables.Line3D)
package org.papervision3d.core.geom.renderables {
import org.papervision3d.core.render.command.*;
import org.papervision3d.core.geom.*;
import org.papervision3d.materials.special.*;
public class Line3D extends AbstractRenderable implements IRenderable {
public var size:Number;
public var cV:Vertex3D;
public var renderCommand:RenderLine;
public var material:LineMaterial;
public var v0:Vertex3D;
public var v1:Vertex3D;
public function Line3D(_arg1:Lines3D, _arg2:LineMaterial, _arg3:Number, _arg4:Vertex3D, _arg5:Vertex3D, _arg6:Vertex3D=null){
this.size = _arg3;
this.material = _arg2;
this.v0 = _arg4;
this.v1 = _arg5;
this.cV = _arg5;
this.instance = _arg1;
this.renderCommand = new RenderLine(this);
}
public function addControlVertex(_arg1:Number, _arg2:Number, _arg3:Number):void{
cV = new Vertex3D(_arg1, _arg2, _arg3);
if (instance.geometry.vertices.indexOf(cV) == -1){
instance.geometry.vertices.push(cV);
};
}
override public function getRenderListItem():IRenderListItem{
return (this.renderCommand);
}
}
}//package org.papervision3d.core.geom.renderables
Section 29
//Particle (org.papervision3d.core.geom.renderables.Particle)
package org.papervision3d.core.geom.renderables {
import flash.geom.*;
import org.papervision3d.core.render.command.*;
import org.papervision3d.materials.special.*;
public class Particle extends AbstractRenderable implements IRenderable {
public var size:Number;
public var renderScale:Number;
public var vertex3D:Vertex3D;
public var renderRect:Rectangle;
public var renderCommand:RenderParticle;
public var material:ParticleMaterial;
public function Particle(_arg1:ParticleMaterial, _arg2:Number=1, _arg3:Number=0, _arg4:Number=0, _arg5:Number=0){
this.material = _arg1;
this.size = _arg2;
this.renderCommand = new RenderParticle(this);
this.renderRect = new Rectangle();
vertex3D = new Vertex3D(_arg3, _arg4, _arg5);
}
public function get y():Number{
return (vertex3D.y);
}
public function updateRenderRect():void{
material.updateRenderRect(this);
}
public function set z(_arg1:Number):void{
vertex3D.z = _arg1;
}
public function set x(_arg1:Number):void{
vertex3D.x = _arg1;
}
public function set y(_arg1:Number):void{
vertex3D.y = _arg1;
}
public function get x():Number{
return (vertex3D.x);
}
public function get z():Number{
return (vertex3D.z);
}
override public function getRenderListItem():IRenderListItem{
return (renderCommand);
}
}
}//package org.papervision3d.core.geom.renderables
Section 30
//Triangle3D (org.papervision3d.core.geom.renderables.Triangle3D)
package org.papervision3d.core.geom.renderables {
import org.papervision3d.core.proto.*;
import org.papervision3d.core.render.command.*;
import org.papervision3d.core.math.*;
import org.papervision3d.objects.*;
public class Triangle3D extends AbstractRenderable implements IRenderable {
public var vertices:Array;
public var v1:Vertex3D;
public var face3DInstance:Triangle3DInstance;
public var _uvArray:Array;
public var visible:Boolean;
public var id:Number;
public var material:MaterialObject3D;
public var renderCommand:RenderTriangle;
public var screenZ:Number;
public var uv0:NumberUV;
public var uv1:NumberUV;
public var uv2:NumberUV;
public var faceNormal:Number3D;
public var _materialName:String;
public var v0:Vertex3D;
public var v2:Vertex3D;
private static var _totalFaces:Number = 0;
public function Triangle3D(_arg1:DisplayObject3D, _arg2:Array, _arg3:MaterialObject3D=null, _arg4:Array=null){
this.instance = _arg1;
this.renderCommand = new RenderTriangle(this);
face3DInstance = new Triangle3DInstance(this, _arg1);
faceNormal = new Number3D();
if (((_arg2) && ((_arg2.length == 3)))){
this.vertices = _arg2;
v0 = _arg2[0];
v1 = _arg2[1];
v2 = _arg2[2];
createNormal();
} else {
_arg2 = new Array();
v0 = (_arg2[0] = new Vertex3D());
v1 = (_arg2[1] = new Vertex3D());
v2 = (_arg2[2] = new Vertex3D());
};
this.material = _arg3;
this.uv = _arg4;
this.id = _totalFaces++;
}
public function set uv(_arg1:Array):void{
if (((_arg1) && ((_arg1.length == 3)))){
uv0 = NumberUV(_arg1[0]);
uv1 = NumberUV(_arg1[1]);
uv2 = NumberUV(_arg1[2]);
};
_uvArray = _arg1;
}
public function createNormal():void{
var _local1:Number3D;
var _local2:Number3D;
var _local3:Number3D;
_local1 = v0.getPosition();
_local2 = v1.getPosition();
_local3 = v2.getPosition();
_local2.minusEq(_local1);
_local3.minusEq(_local1);
faceNormal = Number3D.cross(_local2, _local3, faceNormal);
faceNormal.normalize();
}
public function get uv():Array{
return (_uvArray);
}
public function updateVertices():void{
v0 = vertices[0];
v1 = vertices[1];
v2 = vertices[2];
}
override public function getRenderListItem():IRenderListItem{
return (renderCommand);
}
}
}//package org.papervision3d.core.geom.renderables
Section 31
//Triangle3DInstance (org.papervision3d.core.geom.renderables.Triangle3DInstance)
package org.papervision3d.core.geom.renderables {
import flash.display.*;
import org.papervision3d.core.math.*;
import org.papervision3d.objects.*;
public class Triangle3DInstance {
public var container:Sprite;
public var faceNormal:Number3D;
public var screenZ:Number;
public var visible:Boolean;// = false
public var instance:DisplayObject3D;
public function Triangle3DInstance(_arg1:Triangle3D, _arg2:DisplayObject3D){
visible = false;
super();
this.instance = _arg2;
faceNormal = new Number3D();
}
}
}//package org.papervision3d.core.geom.renderables
Section 32
//Vertex3D (org.papervision3d.core.geom.renderables.Vertex3D)
package org.papervision3d.core.geom.renderables {
import org.papervision3d.core.render.command.*;
import org.papervision3d.core.math.*;
import flash.utils.*;
public class Vertex3D extends AbstractRenderable implements IRenderable {
public var vertex3DInstance:Vertex3DInstance;
public var extra:Object;
public var normal:Number3D;
protected var position:Number3D;
public var connectedFaces:Dictionary;
public var x:Number;
public var y:Number;
public var z:Number;
public function Vertex3D(_arg1:Number=0, _arg2:Number=0, _arg3:Number=0){
position = new Number3D();
super();
this.x = (position.x = _arg1);
this.y = (position.y = _arg2);
this.z = (position.z = _arg3);
this.vertex3DInstance = new Vertex3DInstance();
this.normal = new Number3D();
this.connectedFaces = new Dictionary();
}
public function clone():Vertex3D{
var _local1:Vertex3D;
_local1 = new Vertex3D(x, y, z);
_local1.extra = extra;
_local1.vertex3DInstance = vertex3DInstance.clone();
_local1.normal = normal.clone();
return (_local1);
}
public function getPosition():Number3D{
position.x = x;
position.y = y;
position.z = z;
return (position);
}
public function toNumber3D():Number3D{
return (new Number3D(x, y, z));
}
public function calculateNormal():void{
var _local1:Triangle3D;
var _local2:Number;
_local2 = 0;
normal.reset();
for each (_local1 in connectedFaces) {
if (_local1.faceNormal){
_local2++;
normal.plusEq(_local1.faceNormal);
};
};
normal.x = (normal.x / _local2);
normal.y = (normal.y / _local2);
normal.z = (normal.z / _local2);
normal.normalize();
}
override public function getRenderListItem():IRenderListItem{
return (null);
}
}
}//package org.papervision3d.core.geom.renderables
Section 33
//Vertex3DInstance (org.papervision3d.core.geom.renderables.Vertex3DInstance)
package org.papervision3d.core.geom.renderables {
import org.papervision3d.core.math.*;
public class Vertex3DInstance {
public var visible:Boolean;
public var normal:Number3D;
public var extra:Object;
public var x:Number;
public var y:Number;
public var z:Number;
public function Vertex3DInstance(_arg1:Number=0, _arg2:Number=0, _arg3:Number=0){
this.x = _arg1;
this.y = _arg2;
this.z = _arg3;
this.visible = false;
this.normal = new Number3D();
}
public function clone():Vertex3DInstance{
var _local1:Vertex3DInstance;
_local1 = new Vertex3DInstance(x, y, z);
_local1.visible = visible;
_local1.extra = extra;
return (_local1);
}
public static function cross(_arg1:Vertex3DInstance, _arg2:Vertex3DInstance):Number{
return (((_arg1.x * _arg2.y) - (_arg2.x * _arg1.y)));
}
public static function dot(_arg1:Vertex3DInstance, _arg2:Vertex3DInstance):Number{
return (((_arg1.x * _arg2.x) + (_arg1.y * _arg2.y)));
}
public static function subTo(_arg1:Vertex3DInstance, _arg2:Vertex3DInstance, _arg3:Vertex3DInstance):void{
_arg3.x = (_arg2.x - _arg1.x);
_arg3.y = (_arg2.y - _arg1.y);
}
public static function sub(_arg1:Vertex3DInstance, _arg2:Vertex3DInstance):Vertex3DInstance{
return (new Vertex3DInstance((_arg2.x - _arg1.x), (_arg2.y - _arg1.y)));
}
}
}//package org.papervision3d.core.geom.renderables
Section 34
//Lines3D (org.papervision3d.core.geom.Lines3D)
package org.papervision3d.core.geom {
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.objects.*;
import org.papervision3d.materials.special.*;
import org.papervision3d.core.render.draw.*;
import org.papervision3d.*;
public class Lines3D extends Vertices3D {
public var lines:Array;
private var _material:ILineDrawer;
public function Lines3D(_arg1:LineMaterial, _arg2:String=null){
super(null, _arg2);
this.material = _arg1;
init();
}
private function init():void{
this.lines = new Array();
}
override public function project(_arg1:DisplayObject3D, _arg2:RenderSessionData):Number{
var _local3:Line3D;
var _local4:Number;
super.project(_arg1, _arg2);
for each (_local3 in lines) {
if (_arg2.viewPort.lineCuller.testLine(_local3)){
_local3.renderCommand.renderer = _local3.material;
_local4 = (_local4 + (_local3.renderCommand.screenDepth = ((_local3.v0.vertex3DInstance.z + _local3.v1.vertex3DInstance.z) / 2)));
_arg2.renderer.addToRenderList(_local3.renderCommand);
};
};
return ((_local4 / (lines.length + 1)));
}
public function addLine(_arg1:Line3D):void{
lines.push(_arg1);
_arg1.instance = this;
if (geometry.vertices.indexOf(_arg1.v0) == -1){
geometry.vertices.push(_arg1.v0);
};
if (geometry.vertices.indexOf(_arg1.v1) == -1){
geometry.vertices.push(_arg1.v1);
};
if (_arg1.cV){
if (geometry.vertices.indexOf(_arg1.cV) == -1){
geometry.vertices.push(_arg1.cV);
};
};
}
public function addNewSegmentedLine(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:Number, _arg7:Number, _arg8:Number):void{
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Line3D;
var _local13:Vertex3D;
var _local14:Vertex3D;
var _local15:Number;
_local9 = ((_arg6 - _arg3) / _arg2);
_local10 = ((_arg7 - _arg4) / _arg2);
_local11 = ((_arg8 - _arg5) / _arg2);
_local13 = new Vertex3D(_arg3, _arg4, _arg5);
_local15 = 0;
while (_local15 <= _arg2) {
_local14 = new Vertex3D((_arg3 + (_local9 * _local15)), (_arg4 + (_local10 * _local15)), (_arg5 + (_local11 * _local15)));
_local12 = new Line3D(this, (material as LineMaterial), _arg1, _local13, _local14);
addLine(_local12);
_local13 = _local14;
_local15++;
};
}
public function removeAllLines():void{
}
public function removeLine(_arg1:Line3D):void{
var _local2:int;
_local2 = lines.indexOf(_arg1);
if (_local2 > -1){
lines.splice(_local2, 1);
} else {
if (Papervision3D.VERBOSE){
};
};
}
public function addNewLine(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:Number, _arg7:Number):Line3D{
var _local8:Line3D;
_local8 = new Line3D(this, (material as LineMaterial), _arg1, new Vertex3D(_arg2, _arg3, _arg4), new Vertex3D(_arg5, _arg6, _arg7));
addLine(_local8);
return (_local8);
}
}
}//package org.papervision3d.core.geom
Section 35
//TriangleMesh3D (org.papervision3d.core.geom.TriangleMesh3D)
package org.papervision3d.core.geom {
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.core.render.command.*;
import org.papervision3d.core.math.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.culling.*;
import org.papervision3d.core.render.draw.*;
import flash.utils.*;
public class TriangleMesh3D extends Vertices3D {
public function TriangleMesh3D(_arg1:MaterialObject3D, _arg2:Array, _arg3:Array, _arg4:String=null, _arg5:Object=null){
super(_arg2, _arg4, _arg5);
this.geometry.faces = ((_arg3) || (new Array()));
this.material = ((_arg1) || (MaterialObject3D.DEFAULT));
}
override public function project(_arg1:DisplayObject3D, _arg2:RenderSessionData):Number{
var _local3:Array;
var _local4:Number;
var _local5:Number;
var _local6:ITriangleCuller;
var _local7:Vertex3DInstance;
var _local8:Vertex3DInstance;
var _local9:Vertex3DInstance;
var _local10:Triangle3DInstance;
var _local11:Triangle3D;
var _local12:MaterialObject3D;
var _local13:RenderTriangle;
super.project(_arg1, _arg2);
if (!this.culled){
_local3 = this.geometry.faces;
_local4 = 0;
_local5 = 0;
_local6 = _arg2.triangleCuller;
for each (_local11 in _local3) {
_local12 = (_local11.material) ? _local11.material : material;
_local10 = _local11.face3DInstance;
_local7 = _local11.v0.vertex3DInstance;
_local8 = _local11.v1.vertex3DInstance;
_local9 = _local11.v2.vertex3DInstance;
if ((_local10.visible = _local6.testFace(_local11, _local7, _local8, _local9))){
_local4 = (_local4 + (_local10.screenZ = (((_local7.z + _local8.z) + _local9.z) / 3)));
_local13 = _local11.renderCommand;
_local5++;
_local13.renderer = (_local12 as ITriangleDrawer);
_local13.screenDepth = _local10.screenZ;
_arg2.renderer.addToRenderList(_local13);
} else {
_arg2.renderStatistics.culledTriangles++;
};
};
return ((this.screenZ = (_local4 / _local5)));
//unresolved jump
};
return (0);
}
override public function clone():DisplayObject3D{
var _local1:DisplayObject3D;
var _local2:TriangleMesh3D;
_local1 = super.clone();
_local2 = new TriangleMesh3D(this.material, [], [], _local1.name);
if (this.materials){
_local2.materials = this.materials.clone();
};
if (_local1.geometry){
_local2.geometry = _local1.geometry.clone(_local2);
};
_local2.copyTransform(this.transform);
return (_local2);
}
public function mergeVertices():void{
var _local1:Dictionary;
var _local2:Array;
var _local3:Vertex3D;
var _local4:Triangle3D;
var _local5:Vertex3D;
_local1 = new Dictionary();
_local2 = new Array();
for each (_local3 in this.geometry.vertices) {
for each (_local5 in _local1) {
if ((((((_local3.x == _local5.x)) && ((_local3.y == _local5.y)))) && ((_local3.z == _local5.z)))){
_local1[_local3] = _local5;
break;
};
};
if (!_local1[_local3]){
_local1[_local3] = _local3;
_local2.push(_local3);
};
};
this.geometry.vertices = _local2;
for each (_local4 in geometry.faces) {
_local4.v0 = _local1[_local4.v0];
_local4.v1 = _local1[_local4.v1];
_local4.v2 = _local1[_local4.v2];
};
}
override public function set material(_arg1:MaterialObject3D):void{
var _local2:Triangle3D;
super.material = _arg1;
for each (_local2 in geometry.faces) {
_local2.material = _arg1;
};
}
public function quarterFaces():void{
var _local1:Array;
var _local2:Array;
var _local3:Array;
var _local4:Triangle3D;
var _local5:int;
var _local6:Vertex3D;
var _local7:Vertex3D;
var _local8:Vertex3D;
var _local9:Vertex3D;
var _local10:Vertex3D;
var _local11:Vertex3D;
var _local12:NumberUV;
var _local13:NumberUV;
var _local14:NumberUV;
var _local15:NumberUV;
var _local16:NumberUV;
var _local17:NumberUV;
var _local18:Triangle3D;
var _local19:Triangle3D;
var _local20:Triangle3D;
var _local21:Triangle3D;
_local1 = new Array();
_local2 = new Array();
_local3 = this.geometry.faces;
_local5 = _local3.length;
while ((_local4 = _local3[--_local5])) {
_local6 = _local4.v0;
_local7 = _local4.v1;
_local8 = _local4.v2;
_local9 = new Vertex3D(((_local6.x + _local7.x) / 2), ((_local6.y + _local7.y) / 2), ((_local6.z + _local7.z) / 2));
_local10 = new Vertex3D(((_local7.x + _local8.x) / 2), ((_local7.y + _local8.y) / 2), ((_local7.z + _local8.z) / 2));
_local11 = new Vertex3D(((_local8.x + _local6.x) / 2), ((_local8.y + _local6.y) / 2), ((_local8.z + _local6.z) / 2));
this.geometry.vertices.push(_local9, _local10, _local11);
_local12 = _local4.uv[0];
_local13 = _local4.uv[1];
_local14 = _local4.uv[2];
_local15 = new NumberUV(((_local12.u + _local13.u) / 2), ((_local12.v + _local13.v) / 2));
_local16 = new NumberUV(((_local13.u + _local14.u) / 2), ((_local13.v + _local14.v) / 2));
_local17 = new NumberUV(((_local14.u + _local12.u) / 2), ((_local14.v + _local12.v) / 2));
_local18 = new Triangle3D(this, [_local6, _local9, _local11], _local4.material, [_local12, _local15, _local17]);
_local19 = new Triangle3D(this, [_local9, _local7, _local10], _local4.material, [_local15, _local13, _local16]);
_local20 = new Triangle3D(this, [_local11, _local10, _local8], _local4.material, [_local17, _local16, _local14]);
_local21 = new Triangle3D(this, [_local9, _local10, _local11], _local4.material, [_local15, _local16, _local17]);
_local2.push(_local18, _local19, _local20, _local21);
};
this.geometry.faces = _local2;
this.mergeVertices();
this.geometry.ready = true;
}
public function projectTexture(_arg1:String="x", _arg2:String="y"):void{
var _local3:Array;
var _local4:Object;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:MaterialObject3D;
var _local10:String;
var _local11:Triangle3D;
var _local12:Array;
var _local13:Vertex3D;
var _local14:Vertex3D;
var _local15:Vertex3D;
var _local16:NumberUV;
var _local17:NumberUV;
var _local18:NumberUV;
_local3 = this.geometry.faces;
_local4 = this.boundingBox();
_local5 = _local4.min[_arg1];
_local6 = _local4.size[_arg1];
_local7 = _local4.min[_arg2];
_local8 = _local4.size[_arg2];
_local9 = this.material;
for (_local10 in _local3) {
_local11 = _local3[Number(_local10)];
_local12 = _local11.vertices;
_local13 = _local12[0];
_local14 = _local12[1];
_local15 = _local12[2];
_local16 = new NumberUV(((_local13[_arg1] - _local5) / _local6), ((_local13[_arg2] - _local7) / _local8));
_local17 = new NumberUV(((_local14[_arg1] - _local5) / _local6), ((_local14[_arg2] - _local7) / _local8));
_local18 = new NumberUV(((_local15[_arg1] - _local5) / _local6), ((_local15[_arg2] - _local7) / _local8));
_local11.uv = [_local16, _local17, _local18];
};
}
}
}//package org.papervision3d.core.geom
Section 36
//Vertices3D (org.papervision3d.core.geom.Vertices3D)
package org.papervision3d.core.geom {
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.geom.renderables.*;
import flash.geom.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.core.math.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.culling.*;
public class Vertices3D extends DisplayObject3D {
public function Vertices3D(_arg1:Array, _arg2:String=null, _arg3:Object=null){
super(_arg2, new GeometryObject3D(), _arg3);
this.geometry.vertices = ((_arg1) || (new Array()));
}
public function projectFrustum(_arg1:DisplayObject3D, _arg2:RenderSessionData):Number{
var _local3:Matrix3D;
var _local4:Rectangle;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:Number;
var _local20:Number;
var _local21:Number;
var _local22:Number;
var _local23:Number;
var _local24:Number;
var _local25:Number;
var _local26:Vertex3D;
var _local27:Vertex3DInstance;
var _local28:Array;
var _local29:int;
_local3 = this.view;
_local4 = _arg2.camera.viewport;
_local5 = _local3.n11;
_local6 = _local3.n12;
_local7 = _local3.n13;
_local8 = _local3.n21;
_local9 = _local3.n22;
_local10 = _local3.n23;
_local11 = _local3.n31;
_local12 = _local3.n32;
_local13 = _local3.n33;
_local14 = _local3.n41;
_local15 = _local3.n42;
_local16 = _local3.n43;
_local24 = (_local4.width / 2);
_local25 = (_local4.height / 2);
_local28 = this.geometry.vertices;
_local29 = _local28.length;
while ((_local26 = _local28[--_local29])) {
_local17 = _local26.x;
_local18 = _local26.y;
_local19 = _local26.z;
_local22 = ((((_local17 * _local11) + (_local18 * _local12)) + (_local19 * _local13)) + _local3.n34);
_local23 = ((((_local17 * _local14) + (_local18 * _local15)) + (_local19 * _local16)) + _local3.n44);
_local27 = _local26.vertex3DInstance;
_local22 = (_local22 / _local23);
if ((_local27.visible = (((_local22 > 0)) && ((_local22 < 1))))){
_local20 = (((((_local17 * _local5) + (_local18 * _local6)) + (_local19 * _local7)) + _local3.n14) / _local23);
_local21 = (((((_local17 * _local8) + (_local18 * _local9)) + (_local19 * _local10)) + _local3.n24) / _local23);
_local27.x = (_local20 * _local24);
_local27.y = (_local21 * _local25);
_local27.z = (_local22 * _local23);
};
};
return (0);
}
override public function project(_arg1:DisplayObject3D, _arg2:RenderSessionData):Number{
var _local3:Matrix3D;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:Vertex3D;
var _local20:Vertex3DInstance;
var _local21:Number;
var _local22:Array;
var _local23:int;
var _local24:Number;
var _local25:Number;
super.project(_arg1, _arg2);
if (this.culled){
return (0);
};
if ((_arg2.camera is IObjectCuller)){
return (projectFrustum(_arg1, _arg2));
};
_local3 = this.view;
_local4 = _local3.n11;
_local5 = _local3.n12;
_local6 = _local3.n13;
_local7 = _local3.n21;
_local8 = _local3.n22;
_local9 = _local3.n23;
_local10 = _local3.n31;
_local11 = _local3.n32;
_local12 = _local3.n33;
_local22 = this.geometry.vertices;
_local23 = _local22.length;
_local24 = _arg2.camera.focus;
_local25 = (_local24 * _arg2.camera.zoom);
while ((_local19 = _local22[--_local23])) {
_local13 = _local19.x;
_local14 = _local19.y;
_local15 = _local19.z;
_local18 = ((((_local13 * _local10) + (_local14 * _local11)) + (_local15 * _local12)) + _local3.n34);
_local20 = _local19.vertex3DInstance;
if ((_local20.visible = (_local18 > 0))){
_local16 = ((((_local13 * _local4) + (_local14 * _local5)) + (_local15 * _local6)) + _local3.n14);
_local17 = ((((_local13 * _local7) + (_local14 * _local8)) + (_local15 * _local9)) + _local3.n24);
_local21 = (_local25 / (_local24 + _local18));
_local20.x = (_local16 * _local21);
_local20.y = (_local17 * _local21);
_local20.z = _local18;
};
};
return (0);
}
override public function clone():DisplayObject3D{
var _local1:DisplayObject3D;
var _local2:Vertices3D;
_local1 = super.clone();
_local2 = new Vertices3D(null, _local1.name);
_local2.material = _local1.material;
if (_local1.materials){
_local2.materials = _local1.materials.clone();
};
if (this.geometry){
_local2.geometry = this.geometry.clone(_local2);
};
_local2.copyTransform(this.transform);
return (_local2);
}
public function transformVertices(_arg1:Matrix3D):void{
geometry.transformVertices(_arg1);
}
public function boundingBox():Object{
var _local1:Array;
var _local2:Object;
var _local3:Vertex3D;
_local1 = this.geometry.vertices;
_local2 = new Object();
_local2.min = new Number3D(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
_local2.max = new Number3D(-(Number.MAX_VALUE), -(Number.MAX_VALUE), -(Number.MAX_VALUE));
_local2.size = new Number3D();
for each (_local3 in _local1) {
_local2.min.x = Math.min(_local3.x, _local2.min.x);
_local2.min.y = Math.min(_local3.y, _local2.min.y);
_local2.min.z = Math.min(_local3.z, _local2.min.z);
_local2.max.x = Math.max(_local3.x, _local2.max.x);
_local2.max.y = Math.max(_local3.y, _local2.max.y);
_local2.max.z = Math.max(_local3.z, _local2.max.z);
};
_local2.size.x = (_local2.max.x - _local2.min.x);
_local2.size.y = (_local2.max.y - _local2.min.y);
_local2.size.z = (_local2.max.z - _local2.min.z);
return (_local2);
}
}
}//package org.papervision3d.core.geom
Section 37
//TriangleMaterial (org.papervision3d.core.material.TriangleMaterial)
package org.papervision3d.core.material {
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.geom.renderables.*;
import flash.display.*;
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:Triangle3D, _arg2:Graphics, _arg3:RenderSessionData, _arg4:BitmapData=null, _arg5:Matrix=null):void{
}
}
}//package org.papervision3d.core.material
Section 38
//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 39
//AxisAlignedBoundingBox (org.papervision3d.core.math.AxisAlignedBoundingBox)
package org.papervision3d.core.math {
import org.papervision3d.core.geom.renderables.*;
public class AxisAlignedBoundingBox {
public var minX:Number;
public var minY:Number;
public var minZ:Number;
public var maxX:Number;
public var maxY:Number;
protected var _vertices:Array;
public var maxZ:Number;
public function AxisAlignedBoundingBox(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:Number){
this.minX = _arg1;
this.minY = _arg2;
this.minZ = _arg3;
this.maxX = _arg4;
this.maxY = _arg5;
this.maxZ = _arg6;
createBoxVertices();
}
protected function createBoxVertices():void{
_vertices = new Array();
_vertices.push(new Vertex3D(minX, minY, minZ));
_vertices.push(new Vertex3D(minX, minY, maxZ));
_vertices.push(new Vertex3D(minX, maxY, minZ));
_vertices.push(new Vertex3D(minX, maxY, maxZ));
_vertices.push(new Vertex3D(maxX, minY, minZ));
_vertices.push(new Vertex3D(maxX, minY, maxZ));
_vertices.push(new Vertex3D(maxX, maxY, minZ));
_vertices.push(new Vertex3D(maxX, maxY, maxZ));
}
public function getBoxVertices():Array{
return (_vertices);
}
public static function createFromVertices(_arg1:Array):AxisAlignedBoundingBox{
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Vertex3D;
_local2 = 0;
_local3 = 0;
_local4 = 0;
_local5 = 0;
_local6 = 0;
_local7 = 0;
for each (_local8 in _arg1) {
_local2 = ((_local8.x)<_local2) ? _local8.x : _local2;
_local4 = ((_local8.y)<_local4) ? _local8.y : _local4;
_local6 = ((_local8.z)<_local6) ? _local8.z : _local6;
_local3 = ((_local8.x)>_local3) ? _local8.x : _local3;
_local5 = ((_local8.y)>_local5) ? _local8.y : _local5;
_local7 = ((_local8.z)>_local7) ? _local8.z : _local7;
};
return (new AxisAlignedBoundingBox(_local2, _local4, _local6, _local3, _local5, _local7));
}
}
}//package org.papervision3d.core.math
Section 40
//BoundingSphere (org.papervision3d.core.math.BoundingSphere)
package org.papervision3d.core.math {
import org.papervision3d.core.geom.renderables.*;
public class BoundingSphere {
public var maxDistance:Number;
public var radius:Number;
public function BoundingSphere(_arg1:Number){
this.maxDistance = _arg1;
this.radius = Math.sqrt(_arg1);
}
public static function getFromVertices(_arg1:Array):BoundingSphere{
var _local2:Number;
var _local3:Number;
var _local4:Vertex3D;
_local2 = 0;
for each (_local4 in _arg1) {
_local3 = (((_local4.x * _local4.x) + (_local4.y * _local4.y)) + (_local4.z * _local4.z));
_local2 = ((_local3)>_local2) ? _local3 : _local2;
};
return (new BoundingSphere(_local2));
}
}
}//package org.papervision3d.core.math
Section 41
//Matrix3D (org.papervision3d.core.math.Matrix3D)
package org.papervision3d.core.math {
public class Matrix3D {
public var n31:Number;
public var n32:Number;
public var n11:Number;
public var n13:Number;
public var n14:Number;
public var n33:Number;
public var n12:Number;
public var n42:Number;
public var n21:Number;
public var n22:Number;
public var n23:Number;
public var n24:Number;
public var n34:Number;
public var n41:Number;
public var n43:Number;
public var n44:Number;
private static var _cos:Function = Math.cos;
private static var _sin:Function = Math.sin;
private static var temp:Matrix3D = Matrix3D.IDENTITY;
private static var n3Di:Number3D = Number3D.ZERO;
private static var n3Dj:Number3D = Number3D.ZERO;
private static var n3Dk:Number3D = Number3D.ZERO;
private static var toDEGREES:Number = 57.2957795130823;
private static var toRADIANS:Number = 0.0174532925199433;
public function Matrix3D(_arg1:Array=null){
reset(_arg1);
}
public function calculateMultiply3x3(_arg1:Matrix3D, _arg2:Matrix3D):void{
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:Number;
var _local20:Number;
_local3 = _arg1.n11;
_local4 = _arg2.n11;
_local5 = _arg1.n21;
_local6 = _arg2.n21;
_local7 = _arg1.n31;
_local8 = _arg2.n31;
_local9 = _arg1.n12;
_local10 = _arg2.n12;
_local11 = _arg1.n22;
_local12 = _arg2.n22;
_local13 = _arg1.n32;
_local14 = _arg2.n32;
_local15 = _arg1.n13;
_local16 = _arg2.n13;
_local17 = _arg1.n23;
_local18 = _arg2.n23;
_local19 = _arg1.n33;
_local20 = _arg2.n33;
this.n11 = (((_local3 * _local4) + (_local9 * _local6)) + (_local15 * _local8));
this.n12 = (((_local3 * _local10) + (_local9 * _local12)) + (_local15 * _local14));
this.n13 = (((_local3 * _local16) + (_local9 * _local18)) + (_local15 * _local20));
this.n21 = (((_local5 * _local4) + (_local11 * _local6)) + (_local17 * _local8));
this.n22 = (((_local5 * _local10) + (_local11 * _local12)) + (_local17 * _local14));
this.n23 = (((_local5 * _local16) + (_local11 * _local18)) + (_local17 * _local20));
this.n31 = (((_local7 * _local4) + (_local13 * _local6)) + (_local19 * _local8));
this.n32 = (((_local7 * _local10) + (_local13 * _local12)) + (_local19 * _local14));
this.n33 = (((_local7 * _local16) + (_local13 * _local18)) + (_local19 * _local20));
}
public function calculateMultiply4x4(_arg1:Matrix3D, _arg2:Matrix3D):void{
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:Number;
var _local20:Number;
var _local21:Number;
var _local22:Number;
var _local23:Number;
var _local24:Number;
var _local25:Number;
var _local26:Number;
var _local27:Number;
var _local28:Number;
var _local29:Number;
var _local30:Number;
var _local31:Number;
var _local32:Number;
var _local33:Number;
var _local34:Number;
_local3 = _arg1.n11;
_local4 = _arg2.n11;
_local5 = _arg1.n21;
_local6 = _arg2.n21;
_local7 = _arg1.n31;
_local8 = _arg2.n31;
_local9 = _arg1.n41;
_local10 = _arg2.n41;
_local11 = _arg1.n12;
_local12 = _arg2.n12;
_local13 = _arg1.n22;
_local14 = _arg2.n22;
_local15 = _arg1.n32;
_local16 = _arg2.n32;
_local17 = _arg1.n42;
_local18 = _arg2.n42;
_local19 = _arg1.n13;
_local20 = _arg2.n13;
_local21 = _arg1.n23;
_local22 = _arg2.n23;
_local23 = _arg1.n33;
_local24 = _arg2.n33;
_local25 = _arg1.n43;
_local26 = _arg2.n43;
_local27 = _arg1.n14;
_local28 = _arg2.n14;
_local29 = _arg1.n24;
_local30 = _arg2.n24;
_local31 = _arg1.n34;
_local32 = _arg2.n34;
_local33 = _arg1.n44;
_local34 = _arg2.n44;
this.n11 = (((_local3 * _local4) + (_local11 * _local6)) + (_local19 * _local8));
this.n12 = (((_local3 * _local12) + (_local11 * _local14)) + (_local19 * _local16));
this.n13 = (((_local3 * _local20) + (_local11 * _local22)) + (_local19 * _local24));
this.n14 = ((((_local3 * _local28) + (_local11 * _local30)) + (_local19 * _local32)) + _local27);
this.n21 = (((_local5 * _local4) + (_local13 * _local6)) + (_local21 * _local8));
this.n22 = (((_local5 * _local12) + (_local13 * _local14)) + (_local21 * _local16));
this.n23 = (((_local5 * _local20) + (_local13 * _local22)) + (_local21 * _local24));
this.n24 = ((((_local5 * _local28) + (_local13 * _local30)) + (_local21 * _local32)) + _local29);
this.n31 = (((_local7 * _local4) + (_local15 * _local6)) + (_local23 * _local8));
this.n32 = (((_local7 * _local12) + (_local15 * _local14)) + (_local23 * _local16));
this.n33 = (((_local7 * _local20) + (_local15 * _local22)) + (_local23 * _local24));
this.n34 = ((((_local7 * _local28) + (_local15 * _local30)) + (_local23 * _local32)) + _local31);
this.n41 = (((_local9 * _local4) + (_local17 * _local6)) + (_local25 * _local8));
this.n42 = (((_local9 * _local12) + (_local17 * _local14)) + (_local25 * _local16));
this.n43 = (((_local9 * _local20) + (_local17 * _local22)) + (_local25 * _local24));
this.n44 = ((((_local9 * _local28) + (_local17 * _local30)) + (_local25 * _local32)) + _local33);
}
public function get det():Number{
return ((((((this.n11 * this.n22) - (this.n21 * this.n12)) * this.n33) - (((this.n11 * this.n32) - (this.n31 * this.n12)) * this.n23)) + (((this.n21 * this.n32) - (this.n31 * this.n22)) * this.n13)));
}
public function copy(_arg1:Matrix3D):Matrix3D{
this.n11 = _arg1.n11;
this.n12 = _arg1.n12;
this.n13 = _arg1.n13;
this.n14 = _arg1.n14;
this.n21 = _arg1.n21;
this.n22 = _arg1.n22;
this.n23 = _arg1.n23;
this.n24 = _arg1.n24;
this.n31 = _arg1.n31;
this.n32 = _arg1.n32;
this.n33 = _arg1.n33;
this.n34 = _arg1.n34;
return (this);
}
public function copy3x3(_arg1:Matrix3D):Matrix3D{
this.n11 = _arg1.n11;
this.n12 = _arg1.n12;
this.n13 = _arg1.n13;
this.n21 = _arg1.n21;
this.n22 = _arg1.n22;
this.n23 = _arg1.n23;
this.n31 = _arg1.n31;
this.n32 = _arg1.n32;
this.n33 = _arg1.n33;
return (this);
}
public function calculateAdd(_arg1:Matrix3D, _arg2:Matrix3D):void{
this.n11 = (_arg1.n11 + _arg2.n11);
this.n12 = (_arg1.n12 + _arg2.n12);
this.n13 = (_arg1.n13 + _arg2.n13);
this.n14 = (_arg1.n14 + _arg2.n14);
this.n21 = (_arg1.n21 + _arg2.n21);
this.n22 = (_arg1.n22 + _arg2.n22);
this.n23 = (_arg1.n23 + _arg2.n23);
this.n24 = (_arg1.n24 + _arg2.n24);
this.n31 = (_arg1.n31 + _arg2.n31);
this.n32 = (_arg1.n32 + _arg2.n32);
this.n33 = (_arg1.n33 + _arg2.n33);
this.n34 = (_arg1.n34 + _arg2.n34);
}
public function calculateMultiply(_arg1:Matrix3D, _arg2:Matrix3D):void{
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:Number;
var _local20:Number;
var _local21:Number;
var _local22:Number;
var _local23:Number;
var _local24:Number;
var _local25:Number;
var _local26:Number;
_local3 = _arg1.n11;
_local4 = _arg2.n11;
_local5 = _arg1.n21;
_local6 = _arg2.n21;
_local7 = _arg1.n31;
_local8 = _arg2.n31;
_local9 = _arg1.n12;
_local10 = _arg2.n12;
_local11 = _arg1.n22;
_local12 = _arg2.n22;
_local13 = _arg1.n32;
_local14 = _arg2.n32;
_local15 = _arg1.n13;
_local16 = _arg2.n13;
_local17 = _arg1.n23;
_local18 = _arg2.n23;
_local19 = _arg1.n33;
_local20 = _arg2.n33;
_local21 = _arg1.n14;
_local22 = _arg2.n14;
_local23 = _arg1.n24;
_local24 = _arg2.n24;
_local25 = _arg1.n34;
_local26 = _arg2.n34;
this.n11 = (((_local3 * _local4) + (_local9 * _local6)) + (_local15 * _local8));
this.n12 = (((_local3 * _local10) + (_local9 * _local12)) + (_local15 * _local14));
this.n13 = (((_local3 * _local16) + (_local9 * _local18)) + (_local15 * _local20));
this.n14 = ((((_local3 * _local22) + (_local9 * _local24)) + (_local15 * _local26)) + _local21);
this.n21 = (((_local5 * _local4) + (_local11 * _local6)) + (_local17 * _local8));
this.n22 = (((_local5 * _local10) + (_local11 * _local12)) + (_local17 * _local14));
this.n23 = (((_local5 * _local16) + (_local11 * _local18)) + (_local17 * _local20));
this.n24 = ((((_local5 * _local22) + (_local11 * _local24)) + (_local17 * _local26)) + _local23);
this.n31 = (((_local7 * _local4) + (_local13 * _local6)) + (_local19 * _local8));
this.n32 = (((_local7 * _local10) + (_local13 * _local12)) + (_local19 * _local14));
this.n33 = (((_local7 * _local16) + (_local13 * _local18)) + (_local19 * _local20));
this.n34 = ((((_local7 * _local22) + (_local13 * _local24)) + (_local19 * _local26)) + _local25);
}
public function invert():void{
temp.copy(this);
calculateInverse(temp);
}
public function calculateInverse(_arg1:Matrix3D):void{
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
_local2 = _arg1.det;
if (Math.abs(_local2) > 0.001){
_local2 = (1 / _local2);
_local3 = _arg1.n11;
_local4 = _arg1.n21;
_local5 = _arg1.n31;
_local6 = _arg1.n12;
_local7 = _arg1.n22;
_local8 = _arg1.n32;
_local9 = _arg1.n13;
_local10 = _arg1.n23;
_local11 = _arg1.n33;
_local12 = _arg1.n14;
_local13 = _arg1.n24;
_local14 = _arg1.n34;
this.n11 = (_local2 * ((_local7 * _local11) - (_local8 * _local10)));
this.n12 = (-(_local2) * ((_local6 * _local11) - (_local8 * _local9)));
this.n13 = (_local2 * ((_local6 * _local10) - (_local7 * _local9)));
this.n14 = (-(_local2) * (((_local6 * ((_local10 * _local14) - (_local11 * _local13))) - (_local7 * ((_local9 * _local14) - (_local11 * _local12)))) + (_local8 * ((_local9 * _local13) - (_local10 * _local12)))));
this.n21 = (-(_local2) * ((_local4 * _local11) - (_local5 * _local10)));
this.n22 = (_local2 * ((_local3 * _local11) - (_local5 * _local9)));
this.n23 = (-(_local2) * ((_local3 * _local10) - (_local4 * _local9)));
this.n24 = (_local2 * (((_local3 * ((_local10 * _local14) - (_local11 * _local13))) - (_local4 * ((_local9 * _local14) - (_local11 * _local12)))) + (_local5 * ((_local9 * _local13) - (_local10 * _local12)))));
this.n31 = (_local2 * ((_local4 * _local8) - (_local5 * _local7)));
this.n32 = (-(_local2) * ((_local3 * _local8) - (_local5 * _local6)));
this.n33 = (_local2 * ((_local3 * _local7) - (_local4 * _local6)));
this.n34 = (-(_local2) * (((_local3 * ((_local7 * _local14) - (_local8 * _local13))) - (_local4 * ((_local6 * _local14) - (_local8 * _local12)))) + (_local5 * ((_local6 * _local13) - (_local7 * _local12)))));
};
}
public function toString():String{
var _local1:String;
_local1 = "";
_local1 = (_local1 + ((((((((int((n11 * 1000)) / 1000) + "\t\t") + (int((n12 * 1000)) / 1000)) + "\t\t") + (int((n13 * 1000)) / 1000)) + "\t\t") + (int((n14 * 1000)) / 1000)) + "\n"));
_local1 = (_local1 + ((((((((int((n21 * 1000)) / 1000) + "\t\t") + (int((n22 * 1000)) / 1000)) + "\t\t") + (int((n23 * 1000)) / 1000)) + "\t\t") + (int((n24 * 1000)) / 1000)) + "\n"));
_local1 = (_local1 + ((((((((int((n31 * 1000)) / 1000) + "\t\t") + (int((n32 * 1000)) / 1000)) + "\t\t") + (int((n33 * 1000)) / 1000)) + "\t\t") + (int((n34 * 1000)) / 1000)) + "\n"));
_local1 = (_local1 + ((((((((int((n41 * 1000)) / 1000) + "\t\t") + (int((n42 * 1000)) / 1000)) + "\t\t") + (int((n43 * 1000)) / 1000)) + "\t\t") + (int((n44 * 1000)) / 1000)) + "\n"));
return (_local1);
}
public function reset(_arg1:Array=null):void{
if (((!(_arg1)) || ((_arg1.length < 12)))){
n11 = (n22 = (n33 = (n44 = 1)));
n12 = (n13 = (n14 = (n21 = (n23 = (n24 = (n31 = (n32 = (n34 = (n41 = (n42 = (n43 = 0)))))))))));
} else {
n11 = _arg1[0];
n12 = _arg1[1];
n13 = _arg1[2];
n14 = _arg1[3];
n21 = _arg1[4];
n22 = _arg1[5];
n23 = _arg1[6];
n24 = _arg1[7];
n31 = _arg1[8];
n32 = _arg1[9];
n33 = _arg1[10];
n34 = _arg1[11];
if (_arg1.length == 16){
n41 = _arg1[12];
n42 = _arg1[13];
n43 = _arg1[14];
n44 = _arg1[15];
} else {
n41 = (n42 = (n43 = 0));
n44 = 1;
};
};
}
public static function rotationMatrixWithReference(_arg1:Number3D, _arg2:Number, _arg3:Number3D):Matrix3D{
var _local4:Matrix3D;
_local4 = Matrix3D.translationMatrix(_arg3.x, -(_arg3.y), _arg3.z);
Matrix3D.translationMatrix(_arg3.x, -(_arg3.y), _arg3.z).calculateMultiply(_local4, Matrix3D.rotationMatrix(_arg1.x, _arg1.y, _arg1.z, _arg2));
_local4.calculateMultiply(_local4, Matrix3D.translationMatrix(-(_arg3.x), _arg3.y, -(_arg3.z)));
return (_local4);
}
public static function multiplyVector(_arg1:Matrix3D, _arg2:Number3D):void{
var _local3:Number;
var _local4:Number;
var _local5:Number;
_local3 = _arg2.x;
_local4 = _arg2.y;
_local5 = _arg2.z;
_arg2.x = ((((_local3 * _arg1.n11) + (_local4 * _arg1.n12)) + (_local5 * _arg1.n13)) + _arg1.n14);
_arg2.y = ((((_local3 * _arg1.n21) + (_local4 * _arg1.n22)) + (_local5 * _arg1.n23)) + _arg1.n24);
_arg2.z = ((((_local3 * _arg1.n31) + (_local4 * _arg1.n32)) + (_local5 * _arg1.n33)) + _arg1.n34);
}
public static function multiplyVector4x4(_arg1:Matrix3D, _arg2:Number3D):void{
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
_local3 = _arg2.x;
_local4 = _arg2.y;
_local5 = _arg2.z;
_local6 = (1 / ((((_local3 * _arg1.n41) + (_local4 * _arg1.n42)) + (_local5 * _arg1.n43)) + _arg1.n44));
_arg2.x = ((((_local3 * _arg1.n11) + (_local4 * _arg1.n12)) + (_local5 * _arg1.n13)) + _arg1.n14);
_arg2.y = ((((_local3 * _arg1.n21) + (_local4 * _arg1.n22)) + (_local5 * _arg1.n23)) + _arg1.n24);
_arg2.z = ((((_local3 * _arg1.n31) + (_local4 * _arg1.n32)) + (_local5 * _arg1.n33)) + _arg1.n34);
_arg2.x = (_arg2.x * _local6);
_arg2.y = (_arg2.y * _local6);
_arg2.z = (_arg2.z * _local6);
}
public static function multiply3x3(_arg1:Matrix3D, _arg2:Matrix3D):Matrix3D{
var _local3:Matrix3D;
_local3 = new (Matrix3D);
_local3.calculateMultiply3x3(_arg1, _arg2);
return (_local3);
}
public static function normalizeQuaternion(_arg1:Object):Object{
var _local2:Number;
_local2 = magnitudeQuaternion(_arg1);
_arg1.x = (_arg1.x / _local2);
_arg1.y = (_arg1.y / _local2);
_arg1.z = (_arg1.z / _local2);
_arg1.w = (_arg1.w / _local2);
return (_arg1);
}
public static function multiplyVector3x3(_arg1:Matrix3D, _arg2:Number3D):void{
var _local3:Number;
var _local4:Number;
var _local5:Number;
_local3 = _arg2.x;
_local4 = _arg2.y;
_local5 = _arg2.z;
_arg2.x = (((_local3 * _arg1.n11) + (_local4 * _arg1.n12)) + (_local5 * _arg1.n13));
_arg2.y = (((_local3 * _arg1.n21) + (_local4 * _arg1.n22)) + (_local5 * _arg1.n23));
_arg2.z = (((_local3 * _arg1.n31) + (_local4 * _arg1.n32)) + (_local5 * _arg1.n33));
}
public static function axis2quaternion(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Object{
var _local5:Number;
var _local6:Number;
var _local7:Object;
_local5 = Math.sin((_arg4 / 2));
_local6 = Math.cos((_arg4 / 2));
_local7 = new Object();
_local7.x = (_arg1 * _local5);
_local7.y = (_arg2 * _local5);
_local7.z = (_arg3 * _local5);
_local7.w = _local6;
return (normalizeQuaternion(_local7));
}
public static function translationMatrix(_arg1:Number, _arg2:Number, _arg3:Number):Matrix3D{
var _local4:Matrix3D;
_local4 = IDENTITY;
_local4.n14 = _arg1;
_local4.n24 = _arg2;
_local4.n34 = _arg3;
return (_local4);
}
public static function magnitudeQuaternion(_arg1:Object):Number{
return (Math.sqrt(((((_arg1.w * _arg1.w) + (_arg1.x * _arg1.x)) + (_arg1.y * _arg1.y)) + (_arg1.z * _arg1.z))));
}
public static function rotationX(_arg1:Number):Matrix3D{
var _local2:Matrix3D;
var _local3:Number;
var _local4:Number;
_local2 = IDENTITY;
_local3 = Math.cos(_arg1);
_local4 = Math.sin(_arg1);
_local2.n22 = _local3;
_local2.n23 = -(_local4);
_local2.n32 = _local4;
_local2.n33 = _local3;
return (_local2);
}
public static function rotationY(_arg1:Number):Matrix3D{
var _local2:Matrix3D;
var _local3:Number;
var _local4:Number;
_local2 = IDENTITY;
_local3 = Math.cos(_arg1);
_local4 = Math.sin(_arg1);
_local2.n11 = _local3;
_local2.n13 = -(_local4);
_local2.n31 = _local4;
_local2.n33 = _local3;
return (_local2);
}
public static function rotationZ(_arg1:Number):Matrix3D{
var _local2:Matrix3D;
var _local3:Number;
var _local4:Number;
_local2 = IDENTITY;
_local3 = Math.cos(_arg1);
_local4 = Math.sin(_arg1);
_local2.n11 = _local3;
_local2.n12 = -(_local4);
_local2.n21 = _local4;
_local2.n22 = _local3;
return (_local2);
}
public static function clone(_arg1:Matrix3D):Matrix3D{
return (new Matrix3D([_arg1.n11, _arg1.n12, _arg1.n13, _arg1.n14, _arg1.n21, _arg1.n22, _arg1.n23, _arg1.n24, _arg1.n31, _arg1.n32, _arg1.n33, _arg1.n34]));
}
public static function rotationMatrix(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Matrix3D=null):Matrix3D{
var _local6:Matrix3D;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
if (!_arg5){
_local6 = IDENTITY;
} else {
_local6 = _arg5;
};
_local7 = Math.cos(_arg4);
_local8 = Math.sin(_arg4);
_local9 = (1 - _local7);
_local10 = ((_arg1 * _arg2) * _local9);
_local11 = ((_arg2 * _arg3) * _local9);
_local12 = ((_arg1 * _arg3) * _local9);
_local13 = (_local8 * _arg3);
_local14 = (_local8 * _arg2);
_local15 = (_local8 * _arg1);
_local6.n11 = (_local7 + ((_arg1 * _arg1) * _local9));
_local6.n12 = (-(_local13) + _local10);
_local6.n13 = (_local14 + _local12);
_local6.n21 = (_local13 + _local10);
_local6.n22 = (_local7 + ((_arg2 * _arg2) * _local9));
_local6.n23 = (-(_local15) + _local11);
_local6.n31 = (-(_local14) + _local12);
_local6.n32 = (_local15 + _local11);
_local6.n33 = (_local7 + ((_arg3 * _arg3) * _local9));
return (_local6);
}
public static function add(_arg1:Matrix3D, _arg2:Matrix3D):Matrix3D{
var _local3:Matrix3D;
_local3 = new (Matrix3D);
_local3.calculateAdd(_arg1, _arg2);
return (_local3);
}
public static function multiply(_arg1:Matrix3D, _arg2:Matrix3D):Matrix3D{
var _local3:Matrix3D;
_local3 = new (Matrix3D);
_local3.calculateMultiply(_arg1, _arg2);
return (_local3);
}
public static function euler2quaternion(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Quaternion=null):Quaternion{
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Quaternion;
_local5 = Math.sin((_arg1 * 0.5));
_local6 = Math.cos((_arg1 * 0.5));
_local7 = Math.sin((_arg2 * 0.5));
_local8 = Math.cos((_arg2 * 0.5));
_local9 = Math.sin((_arg3 * 0.5));
_local10 = Math.cos((_arg3 * 0.5));
_local11 = (_local6 * _local8);
_local12 = (_local5 * _local7);
if (!_arg4){
_local13 = new Quaternion();
} else {
_local13 = _arg4;
};
_local13.x = ((_local9 * _local11) - (_local10 * _local12));
_local13.y = (((_local10 * _local5) * _local8) + ((_local9 * _local6) * _local7));
_local13.z = (((_local10 * _local6) * _local7) - ((_local9 * _local5) * _local8));
_local13.w = ((_local10 * _local11) + (_local9 * _local12));
return (_local13);
}
public static function quaternion2matrix(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Matrix3D=null):Matrix3D{
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Matrix3D;
_local6 = (_arg1 * _arg1);
_local7 = (_arg1 * _arg2);
_local8 = (_arg1 * _arg3);
_local9 = (_arg1 * _arg4);
_local10 = (_arg2 * _arg2);
_local11 = (_arg2 * _arg3);
_local12 = (_arg2 * _arg4);
_local13 = (_arg3 * _arg3);
_local14 = (_arg3 * _arg4);
if (!_arg5){
_local15 = IDENTITY;
} else {
_local15 = _arg5;
};
_local15.n11 = (1 - (2 * (_local10 + _local13)));
_local15.n12 = (2 * (_local7 - _local14));
_local15.n13 = (2 * (_local8 + _local12));
_local15.n21 = (2 * (_local7 + _local14));
_local15.n22 = (1 - (2 * (_local6 + _local13)));
_local15.n23 = (2 * (_local11 - _local9));
_local15.n31 = (2 * (_local8 - _local12));
_local15.n32 = (2 * (_local11 + _local9));
_local15.n33 = (1 - (2 * (_local6 + _local10)));
return (_local15);
}
public static function inverse(_arg1:Matrix3D):Matrix3D{
var _local2:Matrix3D;
_local2 = new (Matrix3D);
_local2.calculateInverse(_arg1);
return (_local2);
}
public static function euler2matrix(_arg1:Number3D):Matrix3D{
var _local2:Matrix3D;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
temp.reset();
_local2 = temp;
_local2 = temp;
_local3 = (_arg1.x * toRADIANS);
_local4 = (_arg1.y * toRADIANS);
_local5 = (_arg1.z * toRADIANS);
_local6 = Math.cos(_local3);
_local7 = Math.sin(_local3);
_local8 = Math.cos(_local4);
_local9 = Math.sin(_local4);
_local10 = Math.cos(_local5);
_local11 = Math.sin(_local5);
_local12 = (_local6 * _local9);
_local13 = (_local7 * _local9);
_local2.n11 = (_local8 * _local10);
_local2.n12 = (-(_local8) * _local11);
_local2.n13 = _local9;
_local2.n21 = ((_local13 * _local10) + (_local6 * _local11));
_local2.n22 = ((-(_local13) * _local11) + (_local6 * _local10));
_local2.n23 = (-(_local7) * _local8);
_local2.n31 = ((-(_local12) * _local10) + (_local7 * _local11));
_local2.n32 = ((_local12 * _local11) + (_local7 * _local10));
_local2.n33 = (_local6 * _local8);
return (_local2);
}
public static function scaleMatrix(_arg1:Number, _arg2:Number, _arg3:Number):Matrix3D{
var _local4:Matrix3D;
_local4 = IDENTITY;
_local4.n11 = _arg1;
_local4.n22 = _arg2;
_local4.n33 = _arg3;
return (_local4);
}
public static function rotateAxis(_arg1:Matrix3D, _arg2:Number3D):void{
var _local3:Number;
var _local4:Number;
var _local5:Number;
_local3 = _arg2.x;
_local4 = _arg2.y;
_local5 = _arg2.z;
_arg2.x = (((_local3 * _arg1.n11) + (_local4 * _arg1.n12)) + (_local5 * _arg1.n13));
_arg2.y = (((_local3 * _arg1.n21) + (_local4 * _arg1.n22)) + (_local5 * _arg1.n23));
_arg2.z = (((_local3 * _arg1.n31) + (_local4 * _arg1.n32)) + (_local5 * _arg1.n33));
_arg2.normalize();
}
public static function matrix2euler(_arg1:Matrix3D, _arg2:Number3D=null):Number3D{
var _local3:Matrix3D;
var _local4:Matrix3D;
var _local5:Matrix3D;
var _local6:Number;
if (!_arg2){
_arg2 = Number3D.ZERO;
};
n3Di.reset(_arg1.n11, _arg1.n21, _arg1.n31);
n3Dj.reset(_arg1.n12, _arg1.n22, _arg1.n32);
n3Dk.reset(_arg1.n13, _arg1.n23, _arg1.n33);
n3Di.normalize();
n3Dj.normalize();
n3Dk.normalize();
temp.reset([n3Di.x, n3Dj.x, n3Dk.x, 0, n3Di.y, n3Dj.y, n3Dk.y, 0, n3Di.z, n3Dj.z, n3Dk.z, 0]);
_local3 = temp;
_arg2.x = Math.atan2(_local3.n23, _local3.n33);
_local4 = Matrix3D.rotationX(-(_arg2.x));
_local5 = Matrix3D.multiply(_local4, _local3);
_local6 = Math.sqrt(((_local5.n11 * _local5.n11) + (_local5.n21 * _local5.n21)));
_arg2.y = Math.atan2(-(_local5.n31), _local6);
_arg2.z = Math.atan2(-(_local5.n12), _local5.n11);
if (_arg2.x == Math.PI){
if (_arg2.y > 0){
_arg2.y = (_arg2.y - Math.PI);
} else {
_arg2.y = (_arg2.y + Math.PI);
};
_arg2.x = 0;
_arg2.z = (_arg2.z + Math.PI);
};
_arg2.x = (_arg2.x * toDEGREES);
_arg2.y = (_arg2.y * toDEGREES);
_arg2.z = (_arg2.z * toDEGREES);
return (_arg2);
}
public static function multiplyQuaternion(_arg1:Object, _arg2:Object):Object{
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Object;
_local3 = _arg1.x;
_local4 = _arg1.y;
_local5 = _arg1.z;
_local6 = _arg1.w;
_local7 = _arg2.x;
_local8 = _arg2.y;
_local9 = _arg2.z;
_local10 = _arg2.w;
_local11 = new Object();
_local11.x = ((((_local6 * _local7) + (_local3 * _local10)) + (_local4 * _local9)) - (_local5 * _local8));
_local11.y = ((((_local6 * _local8) + (_local4 * _local10)) + (_local5 * _local7)) - (_local3 * _local9));
_local11.z = ((((_local6 * _local9) + (_local5 * _local10)) + (_local3 * _local8)) - (_local4 * _local7));
_local11.w = ((((_local6 * _local10) - (_local3 * _local7)) - (_local4 * _local8)) - (_local5 * _local9));
return (_local11);
}
public static function get IDENTITY():Matrix3D{
return (new Matrix3D([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]));
}
}
}//package org.papervision3d.core.math
Section 42
//Number2D (org.papervision3d.core.math.Number2D)
package org.papervision3d.core.math {
import org.papervision3d.*;
public class Number2D {
public var x:Number;
public var y:Number;
public static const DEGTORAD:Number = 0.0174532925199433;
public static const RADTODEG:Number = 57.2957795130823;
public function Number2D(_arg1:Number=0, _arg2:Number=0){
this.x = _arg1;
this.y = _arg2;
}
public function divideEq(_arg1:Number):void{
x = (x / _arg1);
y = (y / _arg1);
}
public function copyTo(_arg1:Number2D):void{
_arg1.x = this.x;
_arg1.y = this.y;
}
public function get moduloSquared():Number{
return (((this.x * this.x) + (this.y * this.y)));
}
public function angle():Number{
if (Papervision3D.useDEGREES){
return ((RADTODEG * Math.atan2(y, x)));
};
return (Math.atan2(y, x));
}
public function reset(_arg1:Number=0, _arg2:Number=0):void{
this.x = _arg1;
this.y = _arg2;
}
public function isModuloGreaterThan(_arg1:Number):Boolean{
return ((moduloSquared > (_arg1 * _arg1)));
}
public function clone():Number2D{
return (new Number2D(this.x, this.y));
}
public function reverse():void{
this.x = -(this.x);
this.y = -(this.y);
}
public function plusEq(_arg1:Number2D):void{
x = (x + _arg1.x);
y = (y + _arg1.y);
}
public function rotate(_arg1:Number):void{
var _local2:Number;
var _local3:Number;
var _local4:Number2D;
if (Papervision3D.useDEGREES){
_arg1 = (_arg1 * DEGTORAD);
};
_local2 = Math.cos(_arg1);
_local3 = Math.sin(_arg1);
_local4 = clone();
this.x = ((_local4.x * _local2) - (_local4.y * _local3));
this.y = ((_local4.x * _local3) + (_local4.y * _local2));
}
public function toString():String{
var _local1:Number;
var _local2:Number;
_local1 = (Math.round((this.x * 1000)) / 1000);
_local2 = (Math.round((this.y * 1000)) / 1000);
return ((((("[" + _local1) + ", ") + _local2) + "]"));
}
public function isModuloEqualTo(_arg1:Number):Boolean{
return ((moduloSquared == (_arg1 * _arg1)));
}
public function multiplyEq(_arg1:Number):void{
x = (x * _arg1);
y = (y * _arg1);
}
public function normalise():void{
var _local1:Number;
_local1 = this.modulo;
this.x = (this.x / _local1);
this.y = (this.y / _local1);
}
public function get modulo():Number{
return (Math.sqrt(((x * x) + (y * y))));
}
public function isModuloLessThan(_arg1:Number):Boolean{
return ((moduloSquared < (_arg1 * _arg1)));
}
public function minusEq(_arg1:Number2D):void{
x = (x - _arg1.x);
y = (y - _arg1.y);
}
public function copyFrom(_arg1:Number2D):void{
this.x = _arg1.x;
this.y = _arg1.y;
}
public static function multiplyScalar(_arg1:Number2D, _arg2:Number):Number2D{
return (new Number2D((_arg1.x * _arg2), (_arg1.y * _arg2)));
}
public static function add(_arg1:Number2D, _arg2:Number2D):Number2D{
return (new Number2D((_arg1.x = (_arg1.x + _arg2.x)), (_arg1.y + _arg2.y)));
}
public static function dot(_arg1:Number2D, _arg2:Number2D):Number{
return (((_arg1.x * _arg2.x) + (_arg1.y * _arg2.y)));
}
public static function subtract(_arg1:Number2D, _arg2:Number2D):Number2D{
return (new Number2D((_arg1.x - _arg2.x), (_arg1.y - _arg2.y)));
}
}
}//package org.papervision3d.core.math
Section 43
//Number3D (org.papervision3d.core.math.Number3D)
package org.papervision3d.core.math {
import org.papervision3d.*;
public class Number3D {
public var z:Number;
public var x:Number;
public var y:Number;
public static var toDEGREES:Number = 57.2957795130823;
private static var temp:Number3D = Number3D.ZERO;
public static var toRADIANS:Number = 0.0174532925199433;
public function Number3D(_arg1:Number=0, _arg2:Number=0, _arg3:Number=0){
this.x = _arg1;
this.y = _arg2;
this.z = _arg3;
}
public function normalize():void{
var _local1:Number;
_local1 = this.modulo;
if (((!((_local1 == 0))) && (!((_local1 == 1))))){
this.x = (this.x / _local1);
this.y = (this.y / _local1);
this.z = (this.z / _local1);
};
}
public function copyTo(_arg1:Number3D):void{
_arg1.x = x;
_arg1.y = y;
_arg1.z = z;
}
public function get moduloSquared():Number{
return ((((this.x * this.x) + (this.y * this.y)) + (this.z * this.z)));
}
public function reset(_arg1:Number=0, _arg2:Number=0, _arg3:Number=0):void{
x = _arg1;
y = _arg2;
z = _arg3;
}
public function isModuloGreaterThan(_arg1:Number):Boolean{
return ((moduloSquared > (_arg1 * _arg1)));
}
public function rotateX(_arg1:Number):void{
var _local2:Number;
var _local3:Number;
if (Papervision3D.useDEGREES){
_arg1 = (_arg1 * toRADIANS);
};
_local2 = Math.cos(_arg1);
_local3 = Math.sin(_arg1);
temp.copyFrom(this);
this.y = ((temp.y * _local2) - (temp.z * _local3));
this.z = ((temp.y * _local3) + (temp.z * _local2));
}
public function rotateY(_arg1:Number):void{
var _local2:Number;
var _local3:Number;
if (Papervision3D.useDEGREES){
_arg1 = (_arg1 * toRADIANS);
};
_local2 = Math.cos(_arg1);
_local3 = Math.sin(_arg1);
temp.copyFrom(this);
this.x = ((temp.x * _local2) + (temp.z * _local3));
this.z = ((temp.x * -(_local3)) + (temp.z * _local2));
}
public function rotateZ(_arg1:Number):void{
var _local2:Number;
var _local3:Number;
if (Papervision3D.useDEGREES){
_arg1 = (_arg1 * toRADIANS);
};
_local2 = Math.cos(_arg1);
_local3 = Math.sin(_arg1);
temp.copyFrom(this);
this.x = ((temp.x * _local2) - (temp.y * _local3));
this.y = ((temp.x * _local3) + (temp.y * _local2));
}
public function clone():Number3D{
return (new Number3D(this.x, this.y, this.z));
}
public function plusEq(_arg1:Number3D):void{
x = (x + _arg1.x);
y = (y + _arg1.y);
z = (z + _arg1.z);
}
public function toString():String{
return (((((("x:" + (Math.round((x * 100)) / 100)) + " y:") + (Math.round((y * 100)) / 100)) + " z:") + (Math.round((z * 100)) / 100)));
}
public function isModuloEqualTo(_arg1:Number):Boolean{
return ((moduloSquared == (_arg1 * _arg1)));
}
public function multiplyEq(_arg1:Number):void{
x = (x * _arg1);
y = (y * _arg1);
z = (z * _arg1);
}
public function get modulo():Number{
return (Math.sqrt((((this.x * this.x) + (this.y * this.y)) + (this.z * this.z))));
}
public function isModuloLessThan(_arg1:Number):Boolean{
return ((moduloSquared < (_arg1 * _arg1)));
}
public function minusEq(_arg1:Number3D):void{
x = (x - _arg1.x);
y = (y - _arg1.y);
z = (z - _arg1.z);
}
public function copyFrom(_arg1:Number3D):void{
x = _arg1.x;
y = _arg1.y;
z = _arg1.z;
}
public static function sub(_arg1:Number3D, _arg2:Number3D):Number3D{
return (new Number3D((_arg1.x - _arg2.x), (_arg1.y - _arg2.y), (_arg1.z - _arg2.z)));
}
public static function add(_arg1:Number3D, _arg2:Number3D):Number3D{
return (new Number3D((_arg1.x + _arg2.x), (_arg1.y + _arg2.y), (_arg1.z + _arg2.z)));
}
public static function cross(_arg1:Number3D, _arg2:Number3D, _arg3:Number3D=null):Number3D{
if (!_arg3){
_arg3 = ZERO;
};
_arg3.reset(((_arg2.y * _arg1.z) - (_arg2.z * _arg1.y)), ((_arg2.z * _arg1.x) - (_arg2.x * _arg1.z)), ((_arg2.x * _arg1.y) - (_arg2.y * _arg1.x)));
return (_arg3);
}
public static function dot(_arg1:Number3D, _arg2:Number3D):Number{
return ((((_arg1.x * _arg2.x) + (_arg1.y * _arg2.y)) + (_arg2.z * _arg1.z)));
}
public static function get ZERO():Number3D{
return (new Number3D(0, 0, 0));
}
}
}//package org.papervision3d.core.math
Section 44
//NumberUV (org.papervision3d.core.math.NumberUV)
package org.papervision3d.core.math {
public class NumberUV {
public var u:Number;
public var v:Number;
public function NumberUV(_arg1:Number=0, _arg2:Number=0){
this.u = _arg1;
this.v = _arg2;
}
public function toString():String{
return (((("u:" + u) + " v:") + v));
}
public function clone():NumberUV{
return (new NumberUV(this.u, this.v));
}
public static function get ZERO():NumberUV{
return (new NumberUV(0, 0));
}
}
}//package org.papervision3d.core.math
Section 45
//Quaternion (org.papervision3d.core.math.Quaternion)
package org.papervision3d.core.math {
public class Quaternion {
private var _matrix:Matrix3D;
public var w:Number;
public var x:Number;
public var y:Number;
public var z:Number;
public static const EPSILON:Number = 1E-6;
public static const DEGTORAD:Number = 0.0174532925199433;
public static const RADTODEG:Number = 57.2957795130823;
public function Quaternion(_arg1:Number=0, _arg2:Number=0, _arg3:Number=0, _arg4:Number=1):void{
this.x = _arg1;
this.y = _arg2;
this.z = _arg3;
this.w = _arg4;
_matrix = Matrix3D.IDENTITY;
}
public function normalize():void{
var _local1:Number;
var _local2:Number;
_local1 = this.modulo;
if (Math.abs(_local1) < EPSILON){
x = (y = (z = 0));
w = 1;
} else {
_local2 = (1 / _local1);
x = (x * _local2);
y = (y * _local2);
z = (z * _local2);
w = (w * _local2);
};
}
public function get modulo():Number{
return (Math.sqrt(((((x * x) + (y * y)) + (z * z)) + (w * w))));
}
public function toMatrix():Matrix3D{
var _local1:Number;
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
_local1 = (x * x);
_local2 = (x * y);
_local3 = (x * z);
_local4 = (x * w);
_local5 = (y * y);
_local6 = (y * z);
_local7 = (y * w);
_local8 = (z * z);
_local9 = (z * w);
_matrix.n11 = (1 - (2 * (_local5 + _local8)));
_matrix.n12 = (2 * (_local2 - _local9));
_matrix.n13 = (2 * (_local3 + _local7));
_matrix.n21 = (2 * (_local2 + _local9));
_matrix.n22 = (1 - (2 * (_local1 + _local8)));
_matrix.n23 = (2 * (_local6 - _local4));
_matrix.n31 = (2 * (_local3 - _local7));
_matrix.n32 = (2 * (_local6 + _local4));
_matrix.n33 = (1 - (2 * (_local1 + _local5)));
return (_matrix);
}
public function mult(_arg1:Quaternion):void{
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:Number;
_local2 = this.w;
_local3 = this.x;
_local4 = this.y;
_local5 = this.z;
x = ((((_local2 * _arg1.x) + (_local3 * _arg1.w)) + (_local4 * _arg1.z)) - (_local5 * _arg1.y));
y = ((((_local2 * _arg1.y) - (_local3 * _arg1.z)) + (_local4 * _arg1.w)) + (_local5 * _arg1.x));
z = ((((_local2 * _arg1.z) + (_local3 * _arg1.y)) - (_local4 * _arg1.x)) + (_local5 * _arg1.w));
w = ((((_local2 * _arg1.w) - (_local3 * _arg1.x)) - (_local4 * _arg1.y)) - (_local5 * _arg1.z));
}
public static function sub(_arg1:Quaternion, _arg2:Quaternion):Quaternion{
return (new Quaternion((_arg1.x - _arg2.x), (_arg1.y - _arg2.y), (_arg1.z - _arg2.z), (_arg1.w - _arg2.w)));
}
public static function add(_arg1:Quaternion, _arg2:Quaternion):Quaternion{
return (new Quaternion((_arg1.x + _arg2.x), (_arg1.y + _arg2.y), (_arg1.z + _arg2.z), (_arg1.w + _arg2.w)));
}
public static function createFromEuler(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Boolean=false):Quaternion{
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Quaternion;
if (_arg4){
_arg1 = (_arg1 * DEGTORAD);
_arg2 = (_arg2 * DEGTORAD);
_arg3 = (_arg3 * DEGTORAD);
};
_local5 = Math.sin((_arg1 * 0.5));
_local6 = Math.cos((_arg1 * 0.5));
_local7 = Math.sin((_arg2 * 0.5));
_local8 = Math.cos((_arg2 * 0.5));
_local9 = Math.sin((_arg3 * 0.5));
_local10 = Math.cos((_arg3 * 0.5));
_local11 = (_local6 * _local8);
_local12 = (_local5 * _local7);
_local13 = new (Quaternion);
_local13.x = ((_local9 * _local11) - (_local10 * _local12));
_local13.y = (((_local10 * _local5) * _local8) + ((_local9 * _local6) * _local7));
_local13.z = (((_local10 * _local6) * _local7) - ((_local9 * _local5) * _local8));
_local13.w = ((_local10 * _local11) + (_local9 * _local12));
return (_local13);
}
public static function createFromMatrix(_arg1:Matrix3D):Quaternion{
var _local2:Quaternion;
var _local3:Number;
var _local4:Array;
var _local5:int;
var _local6:int;
var _local7:int;
var _local8:Number;
var _local9:Array;
var _local10:Array;
_local2 = new (Quaternion);
_local4 = new Array(4);
_local8 = ((_arg1.n11 + _arg1.n22) + _arg1.n33);
if (_local8 > 0){
_local3 = Math.sqrt((_local8 + 1));
_local2.w = (_local3 / 2);
_local3 = (0.5 / _local3);
_local2.x = ((_arg1.n32 - _arg1.n23) * _local3);
_local2.y = ((_arg1.n13 - _arg1.n31) * _local3);
_local2.z = ((_arg1.n21 - _arg1.n12) * _local3);
} else {
_local9 = [1, 2, 0];
_local10 = [[_arg1.n11, _arg1.n12, _arg1.n13, _arg1.n14], [_arg1.n21, _arg1.n22, _arg1.n23, _arg1.n24], [_arg1.n31, _arg1.n32, _arg1.n33, _arg1.n34]];
_local5 = 0;
if (_local10[1][1] > _local10[0][0]){
_local5 = 1;
};
if (_local10[2][2] > _local10[_local5][_local5]){
_local5 = 2;
};
_local6 = _local9[_local5];
_local7 = _local9[_local6];
_local3 = Math.sqrt(((_local10[_local5][_local5] - (_local10[_local6][_local6] + _local10[_local7][_local7])) + 1));
_local4[_local5] = (_local3 * 0.5);
if (_local3 != 0){
_local3 = (0.5 / _local3);
};
_local4[3] = ((_local10[_local7][_local6] - _local10[_local6][_local7]) * _local3);
_local4[_local6] = ((_local10[_local6][_local5] + _local10[_local5][_local6]) * _local3);
_local4[_local7] = ((_local10[_local7][_local5] + _local10[_local5][_local7]) * _local3);
_local2.x = _local4[0];
_local2.y = _local4[1];
_local2.z = _local4[2];
_local2.w = _local4[3];
};
return (_local2);
}
public static function dot(_arg1:Quaternion, _arg2:Quaternion):Number{
return (((((_arg1.x * _arg2.x) + (_arg1.y * _arg2.y)) + (_arg1.z * _arg2.z)) + (_arg1.w * _arg2.w)));
}
public static function multiply(_arg1:Quaternion, _arg2:Quaternion):Quaternion{
var _local3:Quaternion;
_local3 = new (Quaternion);
_local3.x = ((((_arg1.w * _arg2.x) + (_arg1.x * _arg2.w)) + (_arg1.y * _arg2.z)) - (_arg1.z * _arg2.y));
_local3.y = ((((_arg1.w * _arg2.y) - (_arg1.x * _arg2.z)) + (_arg1.y * _arg2.w)) + (_arg1.z * _arg2.x));
_local3.z = ((((_arg1.w * _arg2.z) + (_arg1.x * _arg2.y)) - (_arg1.y * _arg2.x)) + (_arg1.z * _arg2.w));
_local3.w = ((((_arg1.w * _arg2.w) - (_arg1.x * _arg2.x)) - (_arg1.y * _arg2.y)) - (_arg1.z * _arg2.z));
return (_local3);
}
public static function createFromAxisAngle(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Quaternion{
var _local5:Number;
var _local6:Number;
var _local7:Quaternion;
_local5 = Math.sin((_arg4 / 2));
_local6 = Math.cos((_arg4 / 2));
_local7 = new (Quaternion);
_local7.x = (_arg1 * _local5);
_local7.y = (_arg2 * _local5);
_local7.z = (_arg3 * _local5);
_local7.w = _local6;
_local7.normalize();
return (_local7);
}
public static function slerp(_arg1:Quaternion, _arg2:Quaternion, _arg3:Number):Quaternion{
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
_local4 = ((((_arg1.w * _arg2.w) + (_arg1.x * _arg2.x)) + (_arg1.y * _arg2.y)) + (_arg1.z * _arg2.z));
if (_local4 < 0){
_arg1.x = (_arg1.x * -1);
_arg1.y = (_arg1.y * -1);
_arg1.z = (_arg1.z * -1);
_arg1.w = (_arg1.w * -1);
_local4 = (_local4 * -1);
};
if ((_local4 + 1) > EPSILON){
if ((1 - _local4) >= EPSILON){
_local7 = Math.acos(_local4);
_local8 = (1 / Math.sin(_local7));
_local5 = (Math.sin((_local7 * (1 - _arg3))) * _local8);
_local6 = (Math.sin((_local7 * _arg3)) * _local8);
} else {
_local5 = (1 - _arg3);
_local6 = _arg3;
};
} else {
_arg2.y = -(_arg1.y);
_arg2.x = _arg1.x;
_arg2.w = -(_arg1.w);
_arg2.z = _arg1.z;
_local5 = Math.sin((Math.PI * (0.5 - _arg3)));
_local6 = Math.sin((Math.PI * _arg3));
};
return (new Quaternion(((_local5 * _arg1.x) + (_local6 * _arg2.x)), ((_local5 * _arg1.y) + (_local6 * _arg2.y)), ((_local5 * _arg1.z) + (_local6 * _arg2.z)), ((_local5 * _arg1.w) + (_local6 * _arg2.w))));
}
public static function createFromOrthoMatrix(_arg1:Matrix3D):Quaternion{
var _local2:Quaternion;
_local2 = new (Quaternion);
_local2.w = (Math.sqrt(Math.max(0, (((1 + _arg1.n11) + _arg1.n22) + _arg1.n33))) / 2);
_local2.x = (Math.sqrt(Math.max(0, (((1 + _arg1.n11) - _arg1.n22) - _arg1.n33))) / 2);
_local2.y = (Math.sqrt(Math.max(0, (((1 - _arg1.n11) + _arg1.n22) - _arg1.n33))) / 2);
_local2.z = (Math.sqrt(Math.max(0, (((1 - _arg1.n11) - _arg1.n22) + _arg1.n33))) / 2);
_local2.x = (((_arg1.n32 - _arg1.n23) < 0)) ? ((_local2.x < 0)) ? _local2.x : -(_local2.x) : ((_local2.x < 0)) ? -(_local2.x) : _local2.x;
_local2.y = (((_arg1.n13 - _arg1.n31) < 0)) ? ((_local2.y < 0)) ? _local2.y : -(_local2.y) : ((_local2.y < 0)) ? -(_local2.y) : _local2.y;
_local2.z = (((_arg1.n21 - _arg1.n12) < 0)) ? ((_local2.z < 0)) ? _local2.z : -(_local2.z) : ((_local2.z < 0)) ? -(_local2.z) : _local2.z;
return (_local2);
}
public static function conjugate(_arg1:Quaternion):Quaternion{
var _local2:Quaternion;
_local2 = new (Quaternion);
_local2.x = -(_arg1.x);
_local2.y = -(_arg1.y);
_local2.z = -(_arg1.z);
_local2.w = _arg1.w;
return (_local2);
}
public static function slerpOld(_arg1:Quaternion, _arg2:Quaternion, _arg3:Number):Quaternion{
var _local4:Quaternion;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
_local4 = new (Quaternion);
_local5 = ((((_arg1.w * _arg2.w) + (_arg1.x * _arg2.x)) + (_arg1.y * _arg2.y)) + (_arg1.z * _arg2.z));
if (Math.abs(_local5) >= 1){
_local4.w = _arg1.w;
_local4.x = _arg1.x;
_local4.y = _arg1.y;
_local4.z = _arg1.z;
return (_local4);
};
_local6 = Math.acos(_local5);
_local7 = Math.sqrt((1 - (_local5 * _local5)));
if (Math.abs(_local7) < 0.001){
_local4.w = ((_arg1.w * 0.5) + (_arg2.w * 0.5));
_local4.x = ((_arg1.x * 0.5) + (_arg2.x * 0.5));
_local4.y = ((_arg1.y * 0.5) + (_arg2.y * 0.5));
_local4.z = ((_arg1.z * 0.5) + (_arg2.z * 0.5));
return (_local4);
};
_local8 = (Math.sin(((1 - _arg3) * _local6)) / _local7);
_local9 = (Math.sin((_arg3 * _local6)) / _local7);
_local4.w = ((_arg1.w * _local8) + (_arg2.w * _local9));
_local4.x = ((_arg1.x * _local8) + (_arg2.x * _local9));
_local4.y = ((_arg1.y * _local8) + (_arg2.y * _local9));
_local4.z = ((_arg1.z * _local8) + (_arg2.z * _local9));
return (_local4);
}
}
}//package org.papervision3d.core.math
Section 46
//pv3dview (org.papervision3d.core.ns.pv3dview)
package org.papervision3d.core.ns {
public namespace pv3dview;
}//package org.papervision3d.core.ns
Section 47
//CameraObject3D (org.papervision3d.core.proto.CameraObject3D)
package org.papervision3d.core.proto {
import flash.geom.*;
import org.papervision3d.core.math.*;
import org.papervision3d.objects.*;
public class CameraObject3D extends DisplayObject3D {
public var eye:Matrix3D;
public var viewport:Rectangle;
public var zoom:Number;
public var sort:Boolean;
public var focus:Number;
public static const TYPE:String = "ABSTRACT";
public static var DEFAULT_POS:Number3D = new Number3D(0, 0, -1000);
private static var _flipY:Matrix3D = Matrix3D.scaleMatrix(1, -1, 1);
public function CameraObject3D(_arg1:Number=3, _arg2:Number=500, _arg3:Object=null){
this.x = (_arg3) ? ((_arg3.x) || (DEFAULT_POS.x)) : DEFAULT_POS.x;
this.y = (_arg3) ? ((_arg3.y) || (DEFAULT_POS.y)) : DEFAULT_POS.y;
this.z = (_arg3) ? ((_arg3.z) || (DEFAULT_POS.z)) : DEFAULT_POS.z;
this.zoom = _arg1;
this.focus = _arg2;
this.eye = Matrix3D.IDENTITY;
this.sort = (_arg3) ? !((_arg3.sort == false)) : true;
}
public function transformView(_arg1:Matrix3D=null):void{
eye.calculateMultiply(((_arg1) || (this.transform)), _flipY);
eye.invert();
}
public function pan(_arg1:Number):void{
super.yaw(_arg1);
}
public function tilt(_arg1:Number):void{
super.pitch(_arg1);
}
}
}//package org.papervision3d.core.proto
Section 48
//DisplayObjectContainer3D (org.papervision3d.core.proto.DisplayObjectContainer3D)
package org.papervision3d.core.proto {
import org.papervision3d.objects.*;
import flash.events.*;
import flash.utils.*;
public class DisplayObjectContainer3D extends EventDispatcher {
private var _childrenTotal:int;
public var root:DisplayObjectContainer3D;
protected var _children:Dictionary;
protected var _childrenByName:Object;
public function DisplayObjectContainer3D():void{
this._children = new Dictionary(false);
this._childrenByName = new Dictionary(true);
this._childrenTotal = 0;
}
public function addChild(_arg1:DisplayObject3D, _arg2:String=null):DisplayObject3D{
_arg2 = ((((_arg2) || (_arg1.name))) || (String(_arg1.id)));
this._children[_arg1] = _arg2;
this._childrenByName[_arg2] = _arg1;
this._childrenTotal++;
_arg1.parent = this;
_arg1.root = this.root;
return (_arg1);
}
private function findChildByName(_arg1:String, _arg2:DisplayObject3D=null):DisplayObject3D{
var _local3:DisplayObject3D;
var _local4:DisplayObject3D;
_arg2 = ((_arg2) || (DisplayObject3D(this)));
if (!_arg2){
return (null);
};
if (_arg2.name == _arg1){
return (_arg2);
};
for each (_local3 in _arg2.children) {
_local4 = findChildByName(_arg1, _local3);
if (_local4){
return (_local4);
};
};
return (null);
}
public function getChildByName(_arg1:String, _arg2:Boolean=false):DisplayObject3D{
if (_arg2){
return (findChildByName(_arg1));
};
return (this._childrenByName[_arg1]);
}
public function get numChildren():int{
return (this._childrenTotal);
}
public function addChildren(_arg1:DisplayObject3D):DisplayObjectContainer3D{
var _local2:DisplayObject3D;
for each (_local2 in _arg1.children) {
_arg1.removeChild(_local2);
this.addChild(_local2);
};
return (this);
}
public function removeChildByName(_arg1:String):DisplayObject3D{
return (removeChild(getChildByName(_arg1)));
}
override public function toString():String{
return (childrenList());
}
public function removeChild(_arg1:DisplayObject3D):DisplayObject3D{
if (_arg1){
delete this._childrenByName[this._children[_arg1]];
delete this._children[_arg1];
_arg1.parent = null;
_arg1.root = null;
return (_arg1);
};
return (null);
}
public function childrenList():String{
var _local1:String;
var _local2:String;
_local1 = "";
for (_local2 in this._children) {
_local1 = (_local1 + (_local2 + "\n"));
};
return (_local1);
}
public function get children():Object{
return (this._childrenByName);
}
}
}//package org.papervision3d.core.proto
Section 49
//GeometryObject3D (org.papervision3d.core.proto.GeometryObject3D)
package org.papervision3d.core.proto {
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.math.*;
import org.papervision3d.objects.*;
import flash.events.*;
import flash.utils.*;
public class GeometryObject3D extends EventDispatcher {
protected var _boundingSphereDirty:Boolean;// = true
public var dirty:Boolean;
protected var _aabbDirty:Boolean;// = true
public var _ready:Boolean;// = false
protected var _boundingSphere:BoundingSphere;
public var faces:Array;
private var _numInstances:uint;// = 0
public var vertices:Array;
protected var _aabb:AxisAlignedBoundingBox;
public function GeometryObject3D(_arg1:Object=null):void{
_boundingSphereDirty = true;
_aabbDirty = true;
_numInstances = 0;
_ready = false;
super();
dirty = true;
}
public function transformVertices(_arg1:Matrix3D):void{
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:int;
var _local15:Vertex3D;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:Number;
var _local20:Number;
var _local21:Number;
_local2 = _arg1.n11;
_local3 = _arg1.n12;
_local4 = _arg1.n13;
_local5 = _arg1.n21;
_local6 = _arg1.n22;
_local7 = _arg1.n23;
_local8 = _arg1.n31;
_local9 = _arg1.n32;
_local10 = _arg1.n33;
_local11 = _arg1.n14;
_local12 = _arg1.n24;
_local13 = _arg1.n34;
_local14 = vertices.length;
while ((_local15 = vertices[--_local14])) {
_local16 = _local15.x;
_local17 = _local15.y;
_local18 = _local15.z;
_local19 = ((((_local16 * _local2) + (_local17 * _local3)) + (_local18 * _local4)) + _local11);
_local20 = ((((_local16 * _local5) + (_local17 * _local6)) + (_local18 * _local7)) + _local12);
_local21 = ((((_local16 * _local8) + (_local17 * _local9)) + (_local18 * _local10)) + _local13);
_local15.x = _local19;
_local15.y = _local20;
_local15.z = _local21;
};
}
private function createVertexNormals():void{
var _local1:Dictionary;
var _local2:Triangle3D;
var _local3:Vertex3D;
_local1 = new Dictionary(true);
for each (_local2 in faces) {
_local2.v0.connectedFaces[_local2] = _local2;
_local2.v1.connectedFaces[_local2] = _local2;
_local2.v2.connectedFaces[_local2] = _local2;
_local1[_local2.v0] = _local2.v0;
_local1[_local2.v1] = _local2.v1;
_local1[_local2.v2] = _local2.v2;
};
for each (_local3 in _local1) {
_local3.calculateNormal();
};
}
public function get boundingSphere():BoundingSphere{
if (_boundingSphereDirty){
_boundingSphere = BoundingSphere.getFromVertices(vertices);
_boundingSphereDirty = false;
};
return (_boundingSphere);
}
public function transformUV(_arg1:MaterialObject3D):void{
var _local2:String;
if (_arg1.bitmap){
for (_local2 in this.faces) {
faces[_local2].transformUV(_arg1);
};
};
}
public function clone(_arg1:DisplayObject3D=null):GeometryObject3D{
var _local2:Dictionary;
var _local3:GeometryObject3D;
var _local4:int;
var _local5:Vertex3D;
var _local6:Triangle3D;
var _local7:Vertex3D;
var _local8:Vertex3D;
var _local9:Vertex3D;
_local2 = new Dictionary();
_local3 = new GeometryObject3D();
_local3.vertices = new Array();
_local3.faces = new Array();
_local4 = 0;
while (_local4 < this.vertices.length) {
_local5 = this.vertices[_local4];
_local2[_local5] = _local5.clone();
_local3.vertices.push(_local2[_local5]);
_local4++;
};
_local4 = 0;
while (_local4 < this.faces.length) {
_local6 = this.faces[_local4];
_local7 = _local2[_local6.v0];
_local8 = _local2[_local6.v1];
_local9 = _local2[_local6.v2];
_local3.faces.push(new Triangle3D(_arg1, [_local7, _local8, _local9], _local6.material, _local6.uv));
_local4++;
};
return (_local3);
}
public function set ready(_arg1:Boolean):void{
if (_arg1){
createVertexNormals();
this.dirty = false;
};
_ready = _arg1;
}
public function get ready():Boolean{
return (_ready);
}
public function get aabb():AxisAlignedBoundingBox{
if (_aabbDirty){
_aabb = AxisAlignedBoundingBox.createFromVertices(vertices);
_aabbDirty = false;
};
return (_aabb);
}
}
}//package org.papervision3d.core.proto
Section 50
//MaterialObject3D (org.papervision3d.core.proto.MaterialObject3D)
package org.papervision3d.core.proto {
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.geom.renderables.*;
import flash.display.*;
import flash.geom.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.render.material.*;
import flash.events.*;
import org.papervision3d.materials.*;
import org.papervision3d.core.render.draw.*;
import flash.utils.*;
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 invisible:Boolean;// = false
public var smooth:Boolean;// = false
public var bitmap:BitmapData;
public var lineColor:Number;
public var lineAlpha:Number;// = 0
public var oneSide:Boolean;// = true
public var lineThickness:Number;// = 1
public var interactive:Boolean;// = false
public var opposite:Boolean;// = false
public var maxU:Number;
public var tiled:Boolean;// = false
public var 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(){
smooth = false;
tiled = false;
lineColor = DEFAULT_COLOR;
lineAlpha = 0;
lineThickness = 1;
fillColor = DEFAULT_COLOR;
fillAlpha = 0;
oneSide = true;
invisible = false;
opposite = false;
widthOffset = 0;
heightOffset = 0;
interactive = false;
super();
this.id = _totalMaterialObjects++;
MaterialManager.registerMaterial(this);
objects = new Dictionary(true);
}
public function drawTriangle(_arg1:Triangle3D, _arg2:Graphics, _arg3:RenderSessionData, _arg4:BitmapData=null, _arg5:Matrix=null):void{
}
public function get doubleSided():Boolean{
return (!(this.oneSide));
}
public function unregisterObject(_arg1:DisplayObject3D):void{
if (((objects) && (!((objects[_arg1] == null))))){
delete objects[_arg1];
};
}
public function set doubleSided(_arg1:Boolean):void{
this.oneSide = !(_arg1);
}
public function registerObject(_arg1:DisplayObject3D):void{
objects[_arg1] = _arg1;
}
public function updateBitmap():void{
}
override public function toString():String{
return (((((("[MaterialObject3D] bitmap:" + this.bitmap) + " lineColor:") + this.lineColor) + " fillColor:") + fillColor));
}
public function copy(_arg1:MaterialObject3D):void{
this.bitmap = _arg1.bitmap;
this.smooth = _arg1.smooth;
this.lineColor = _arg1.lineColor;
this.lineAlpha = _arg1.lineAlpha;
this.fillColor = _arg1.fillColor;
this.fillAlpha = _arg1.fillAlpha;
this.oneSide = _arg1.oneSide;
this.opposite = _arg1.opposite;
this.invisible = _arg1.invisible;
this.name = _arg1.name;
this.maxU = _arg1.maxU;
this.maxV = _arg1.maxV;
}
public function destroy():void{
objects = null;
bitmap = null;
MaterialManager.unRegisterMaterial(this);
}
public function clone():MaterialObject3D{
var _local1:MaterialObject3D;
_local1 = new MaterialObject3D();
_local1.copy(this);
return (_local1);
}
public static function get DEFAULT():MaterialObject3D{
var _local1:MaterialObject3D;
_local1 = new WireframeMaterial();
_local1.lineColor = (0xFFFFFF * Math.random());
_local1.lineAlpha = 1;
_local1.fillColor = DEFAULT_COLOR;
_local1.fillAlpha = 1;
_local1.doubleSided = false;
return (_local1);
}
public static function get DEBUG():MaterialObject3D{
var _local1:MaterialObject3D;
_local1 = new (MaterialObject3D);
_local1.lineColor = (0xFFFFFF * Math.random());
_local1.lineAlpha = 1;
_local1.fillColor = DEBUG_COLOR;
_local1.fillAlpha = 0.37;
_local1.doubleSided = true;
return (_local1);
}
}
}//package org.papervision3d.core.proto
Section 51
//SceneObject3D (org.papervision3d.core.proto.SceneObject3D)
package org.papervision3d.core.proto {
import org.papervision3d.materials.utils.*;
import org.papervision3d.objects.*;
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();
Papervision3D.log((((((Papervision3D.NAME + " ") + Papervision3D.VERSION) + " (") + Papervision3D.DATE) + ")\n"));
this.root = this;
}
override public function removeChild(_arg1:DisplayObject3D):DisplayObject3D{
var _local2:int;
super.removeChild(_arg1);
_local2 = 0;
while (_local2 < this.objects.length) {
if (this.objects[_local2] === _arg1){
this.objects.splice(_local2, 1);
return (_arg1);
};
_local2++;
};
return (_arg1);
}
override public function addChild(_arg1:DisplayObject3D, _arg2:String=null):DisplayObject3D{
var _local3:DisplayObject3D;
_local3 = super.addChild(_arg1, (_arg2) ? _arg2 : _arg1.name);
_arg1.scene = this;
this.objects.push(_local3);
return (_local3);
}
}
}//package org.papervision3d.core.proto
Section 52
//AbstractRenderListItem (org.papervision3d.core.render.command.AbstractRenderListItem)
package org.papervision3d.core.render.command {
import org.papervision3d.core.render.data.*;
import flash.display.*;
public class AbstractRenderListItem implements IRenderListItem {
public var screenDepth:Number;
public function render(_arg1:RenderSessionData, _arg2:Graphics):void{
}
}
}//package org.papervision3d.core.render.command
Section 53
//IRenderListItem (org.papervision3d.core.render.command.IRenderListItem)
package org.papervision3d.core.render.command {
import org.papervision3d.core.render.data.*;
import flash.display.*;
public interface IRenderListItem {
function render(_arg1:RenderSessionData, _arg2:Graphics):void;
}
}//package org.papervision3d.core.render.command
Section 54
//RenderableListItem (org.papervision3d.core.render.command.RenderableListItem)
package org.papervision3d.core.render.command {
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.geom.renderables.*;
import flash.geom.*;
import org.papervision3d.objects.*;
public class RenderableListItem extends AbstractRenderListItem {
public var renderableInstance:AbstractRenderable;
public var renderable:Class;
public var instance:DisplayObject3D;
public function hitTestPoint2D(_arg1:Point, _arg2:RenderHitData):RenderHitData{
return (_arg2);
}
}
}//package org.papervision3d.core.render.command
Section 55
//RenderLine (org.papervision3d.core.render.command.RenderLine)
package org.papervision3d.core.render.command {
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.geom.renderables.*;
import flash.display.*;
import flash.geom.*;
import org.papervision3d.core.math.*;
import org.papervision3d.materials.special.*;
public class RenderLine extends RenderableListItem implements IRenderListItem {
public var renderer:LineMaterial;
private var l1:Number2D;
private var l2:Number2D;
public var line:Line3D;
private var v:Number2D;
private var cp3d:Number3D;
private var p:Number2D;
private static var mouseVector:Number3D = Number3D.ZERO;
private static var lineVector:Number3D = Number3D.ZERO;
public function RenderLine(_arg1:Line3D){
this.renderable = Line3D;
this.renderableInstance = _arg1;
this.line = _arg1;
p = new Number2D();
l1 = new Number2D();
l2 = new Number2D();
v = new Number2D();
cp3d = new Number3D();
}
override public function render(_arg1:RenderSessionData, _arg2:Graphics):void{
renderer.drawLine(line, _arg2, _arg1);
}
override public function hitTestPoint2D(_arg1:Point, _arg2:RenderHitData):RenderHitData{
var _local3:Number;
var _local4:Number;
var _local5:Number;
if (renderer.interactive){
_local3 = line.size;
p.reset(_arg1.x, _arg1.y);
l1.reset(line.v0.vertex3DInstance.x, line.v0.vertex3DInstance.y);
l2.reset(line.v1.vertex3DInstance.x, line.v1.vertex3DInstance.y);
v.copyFrom(l2);
v.minusEq(l1);
_local4 = ((((p.x - l1.x) * (l2.x - l1.x)) + ((p.y - l1.y) * (l2.y - l1.y))) / ((v.x * v.x) + (v.y * v.y)));
if ((((_local4 > 0)) && ((_local4 < 1)))){
v.multiplyEq(_local4);
v.plusEq(l1);
v.minusEq(p);
_local5 = ((v.x * v.x) + (v.y * v.y));
if (_local5 < (_local3 * _local3)){
_arg2.displayObject3D = line.instance;
_arg2.material = renderer;
_arg2.renderable = line;
_arg2.hasHit = true;
cp3d.reset((line.v1.x - line.v0.x), (line.v1.y - line.v0.y), (line.v1.x - line.v0.x));
cp3d.x = (cp3d.x * _local4);
cp3d.y = (cp3d.y * _local4);
cp3d.z = (cp3d.z * _local4);
cp3d.x = (cp3d.x + line.v0.x);
cp3d.y = (cp3d.y + line.v0.y);
cp3d.z = (cp3d.z + line.v0.z);
_arg2.x = cp3d.x;
_arg2.y = cp3d.y;
_arg2.z = cp3d.z;
_arg2.u = 0;
_arg2.v = 0;
return (_arg2);
};
};
};
return (_arg2);
}
}
}//package org.papervision3d.core.render.command
Section 56
//RenderParticle (org.papervision3d.core.render.command.RenderParticle)
package org.papervision3d.core.render.command {
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.geom.renderables.*;
import flash.display.*;
import flash.geom.*;
import org.papervision3d.materials.special.*;
public class RenderParticle extends RenderableListItem implements IRenderListItem {
public var particle:Particle;
public var renderMat:ParticleMaterial;
public function RenderParticle(_arg1:Particle){
this.particle = _arg1;
this.renderableInstance = _arg1;
this.renderable = Particle;
}
override public function render(_arg1:RenderSessionData, _arg2:Graphics):void{
particle.material.drawParticle(particle, _arg2, _arg1);
}
override public function hitTestPoint2D(_arg1:Point, _arg2:RenderHitData):RenderHitData{
renderMat = particle.material;
if (renderMat.interactive){
if (particle.renderRect.contains(_arg1.x, _arg1.y)){
_arg2.displayObject3D = particle.instance;
_arg2.material = renderMat;
_arg2.renderable = particle;
_arg2.hasHit = true;
_arg2.x = particle.x;
_arg2.y = particle.y;
_arg2.z = particle.z;
_arg2.u = 0;
_arg2.v = 0;
return (_arg2);
};
};
return (_arg2);
}
}
}//package org.papervision3d.core.render.command
Section 57
//RenderTriangle (org.papervision3d.core.render.command.RenderTriangle)
package org.papervision3d.core.render.command {
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.geom.renderables.*;
import flash.display.*;
import flash.geom.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.core.math.*;
import org.papervision3d.materials.*;
import org.papervision3d.core.render.draw.*;
public class RenderTriangle extends RenderableListItem implements IRenderListItem {
public var renderer:ITriangleDrawer;
public var triangle:Triangle3D;
public var container:Sprite;
private var position:Number3D;
public var renderMat:MaterialObject3D;
protected static var resPA:Vertex3DInstance = new Vertex3DInstance();
protected static var resBA:Vertex3DInstance = new Vertex3DInstance();
protected static var vPoint:Vertex3DInstance = new Vertex3DInstance();
protected static var resRA:Vertex3DInstance = new Vertex3DInstance();
public function RenderTriangle(_arg1:Triangle3D):void{
position = new Number3D();
super();
this.triangle = _arg1;
renderableInstance = _arg1;
renderable = Triangle3D;
}
override public function render(_arg1:RenderSessionData, _arg2:Graphics):void{
renderer.drawTriangle(triangle, _arg2, _arg1);
}
override public function hitTestPoint2D(_arg1:Point, _arg2:RenderHitData):RenderHitData{
var _local3:Vertex3DInstance;
var _local4:Vertex3DInstance;
var _local5:Vertex3DInstance;
var _local6:Vertex3DInstance;
renderMat = triangle.material;
if (!renderMat){
renderMat = triangle.instance.material;
};
if (renderMat.interactive){
_local3 = RenderTriangle.vPoint;
_local3.x = _arg1.x;
_local3.y = _arg1.y;
_local4 = triangle.v0.vertex3DInstance;
_local5 = triangle.v1.vertex3DInstance;
_local6 = triangle.v2.vertex3DInstance;
if (sameSide(_local3, _local4, _local5, _local6)){
if (sameSide(_local3, _local5, _local4, _local6)){
if (sameSide(_local3, _local6, _local4, _local5)){
return (deepHitTest(triangle, _local3, _arg2));
};
};
};
};
return (_arg2);
}
public function sameSide(_arg1:Vertex3DInstance, _arg2:Vertex3DInstance, _arg3:Vertex3DInstance, _arg4:Vertex3DInstance):Boolean{
Vertex3DInstance.subTo(_arg4, _arg3, resBA);
Vertex3DInstance.subTo(_arg1, _arg3, resPA);
Vertex3DInstance.subTo(_arg2, _arg3, resRA);
return (((Vertex3DInstance.cross(resBA, resPA) * Vertex3DInstance.cross(resBA, resRA)) > 0));
}
private function deepHitTest(_arg1:Triangle3D, _arg2:Vertex3DInstance, _arg3:RenderHitData):RenderHitData{
var _local4:Vertex3DInstance;
var _local5:Vertex3DInstance;
var _local6:Vertex3DInstance;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:Number;
var _local20:Number;
var _local21:Number;
var _local22:Number;
var _local23:Number;
var _local24:Number;
var _local25:Number;
var _local26:Number;
var _local27:Number;
var _local28:Number;
var _local29:Number;
var _local30:Array;
var _local31:Number;
var _local32:Number;
var _local33:Number;
var _local34:Number;
var _local35:Number;
var _local36:Number;
var _local37:Number;
var _local38:Number;
var _local39:BitmapData;
var _local40:Number;
var _local41:Number;
_local4 = _arg1.v0.vertex3DInstance;
_local5 = _arg1.v1.vertex3DInstance;
_local6 = _arg1.v2.vertex3DInstance;
_local7 = (_local6.x - _local4.x);
_local8 = (_local6.y - _local4.y);
_local9 = (_local5.x - _local4.x);
_local10 = (_local5.y - _local4.y);
_local11 = (_arg2.x - _local4.x);
_local12 = (_arg2.y - _local4.y);
_local13 = ((_local7 * _local7) + (_local8 * _local8));
_local14 = ((_local7 * _local9) + (_local8 * _local10));
_local15 = ((_local7 * _local11) + (_local8 * _local12));
_local16 = ((_local9 * _local9) + (_local10 * _local10));
_local17 = ((_local9 * _local11) + (_local10 * _local12));
_local18 = (1 / ((_local13 * _local16) - (_local14 * _local14)));
_local19 = (((_local16 * _local15) - (_local14 * _local17)) * _local18);
_local20 = (((_local13 * _local17) - (_local14 * _local15)) * _local18);
_local21 = (_arg1.v2.x - _arg1.v0.x);
_local22 = (_arg1.v2.y - _arg1.v0.y);
_local23 = (_arg1.v2.z - _arg1.v0.z);
_local24 = (_arg1.v1.x - _arg1.v0.x);
_local25 = (_arg1.v1.y - _arg1.v0.y);
_local26 = (_arg1.v1.z - _arg1.v0.z);
_local27 = ((_arg1.v0.x + (_local21 * _local19)) + (_local24 * _local20));
_local28 = ((_arg1.v0.y + (_local22 * _local19)) + (_local25 * _local20));
_local29 = ((_arg1.v0.z + (_local23 * _local19)) + (_local26 * _local20));
_local30 = _arg1.uv;
_local31 = _local30[0].u;
_local32 = _local30[1].u;
_local33 = _local30[2].u;
_local34 = _local30[0].v;
_local35 = _local30[1].v;
_local36 = _local30[2].v;
_local37 = ((((_local32 - _local31) * _local20) + ((_local33 - _local31) * _local19)) + _local31);
_local38 = ((((_local35 - _local34) * _local20) + ((_local36 - _local34) * _local19)) + _local34);
if (triangle.material){
renderMat = _arg1.material;
} else {
renderMat = _arg1.instance.material;
};
_local39 = renderMat.bitmap;
_local40 = 1;
_local41 = 1;
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);
_arg3.v = (_local41 - (_local38 * _local41));
return (_arg3);
}
}
}//package org.papervision3d.core.render.command
Section 58
//RenderHitData (org.papervision3d.core.render.data.RenderHitData)
package org.papervision3d.core.render.data {
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.objects.*;
public class RenderHitData {
public var y:Number;
public var endTime:int;// = 0
public var displayObject3D:DisplayObject3D;
public var startTime:int;// = 0
public var hasHit:Boolean;// = false
public var material:MaterialObject3D;
public var renderable:IRenderable;
public var u:Number;
public var v:Number;
public var x:Number;
public var z:Number;
public function RenderHitData():void{
startTime = 0;
endTime = 0;
hasHit = false;
super();
}
public function clear():void{
startTime = 0;
endTime = 0;
hasHit = false;
displayObject3D = null;
material = null;
renderable = null;
u = 0;
v = 0;
x = 0;
y = 0;
z = 0;
}
public function clone():RenderHitData{
var _local1:RenderHitData;
_local1 = new RenderHitData();
_local1.startTime = startTime;
_local1.endTime = endTime;
_local1.hasHit = hasHit;
_local1.displayObject3D = displayObject3D;
_local1.material = material;
_local1.renderable = renderable;
_local1.u = u;
_local1.v = v;
_local1.x = x;
_local1.y = y;
_local1.z = z;
return (_local1);
}
public function toString():String{
return (((displayObject3D + " ") + renderable));
}
}
}//package org.papervision3d.core.render.data
Section 59
//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.*;
public class RenderSessionData {
public var renderer:IRenderEngine;
public var particleCuller:IParticleCuller;
public var viewPort:Viewport3D;
public var triangleCuller:ITriangleCuller;
public var container:Sprite;
public var scene:SceneObject3D;
public var renderStatistics:RenderStatistics;
public var renderObjects:Array;
public var camera:CameraObject3D;
public var renderLayers:Array;
public var sorted:Boolean;
public function RenderSessionData():void{
this.renderStatistics = new RenderStatistics();
}
public function destroy():void{
triangleCuller = null;
particleCuller = null;
viewPort = null;
container = null;
scene = null;
camera = null;
renderer = null;
renderStatistics = null;
renderObjects = null;
renderLayers = null;
}
public function clone():RenderSessionData{
var _local1:RenderSessionData;
_local1 = new RenderSessionData();
_local1.triangleCuller = triangleCuller;
_local1.particleCuller = particleCuller;
_local1.viewPort = viewPort;
_local1.container = container;
_local1.scene = scene;
_local1.camera = camera;
_local1.renderer = renderer;
_local1.renderStatistics = renderStatistics.clone();
return (_local1);
}
}
}//package org.papervision3d.core.render.data
Section 60
//RenderStatistics (org.papervision3d.core.render.data.RenderStatistics)
package org.papervision3d.core.render.data {
public class RenderStatistics {
public var renderTime:int;// = 0
public var culledObjects:int;// = 0
public var shadedTriangles:int;// = 0
public var culledParticles:int;// = 0
public var culledTriangles:int;// = 0
public var triangles:int;// = 0
public var particles:int;// = 0
public var rendered:int;// = 0
public var projectionTime:int;// = 0
public var filteredObjects:int;// = 0
public var lines:int;// = 0
public function RenderStatistics(){
projectionTime = 0;
renderTime = 0;
rendered = 0;
triangles = 0;
culledTriangles = 0;
particles = 0;
culledParticles = 0;
lines = 0;
shadedTriangles = 0;
filteredObjects = 0;
culledObjects = 0;
super();
}
public function clone():RenderStatistics{
var _local1:RenderStatistics;
_local1 = new RenderStatistics();
_local1.projectionTime = projectionTime;
_local1.renderTime = renderTime;
_local1.rendered = rendered;
_local1.particles = particles;
_local1.triangles = triangles;
_local1.culledTriangles = culledTriangles;
_local1.lines = lines;
_local1.shadedTriangles = shadedTriangles;
_local1.filteredObjects = filteredObjects;
_local1.culledObjects = culledObjects;
return (_local1);
}
public function clear():void{
projectionTime = 0;
renderTime = 0;
rendered = 0;
particles = 0;
triangles = 0;
culledTriangles = 0;
culledParticles = 0;
lines = 0;
shadedTriangles = 0;
filteredObjects = 0;
culledObjects = 0;
}
public function toString():String{
return (new String((((((((((((((((((("ProjectionTime:" + projectionTime) + " RenderTime:") + renderTime) + " Particles:") + particles) + " CulledParticles :") + culledParticles) + " Triangles:") + triangles) + " ShadedTriangles :") + shadedTriangles) + " CulledTriangles:") + culledTriangles) + " FilteredObjects:") + filteredObjects) + " CulledObjects:") + culledObjects) + "")));
}
}
}//package org.papervision3d.core.render.data
Section 61
//ILineDrawer (org.papervision3d.core.render.draw.ILineDrawer)
package org.papervision3d.core.render.draw {
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.geom.renderables.*;
import flash.display.*;
public interface ILineDrawer {
function drawLine(_arg1:Line3D, _arg2:Graphics, _arg3:RenderSessionData):void;
}
}//package org.papervision3d.core.render.draw
Section 62
//IParticleDrawer (org.papervision3d.core.render.draw.IParticleDrawer)
package org.papervision3d.core.render.draw {
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.geom.renderables.*;
import flash.display.*;
public interface IParticleDrawer {
function updateRenderRect(_arg1:Particle):void;
function drawParticle(_arg1:Particle, _arg2:Graphics, _arg3:RenderSessionData):void;
}
}//package org.papervision3d.core.render.draw
Section 63
//ITriangleDrawer (org.papervision3d.core.render.draw.ITriangleDrawer)
package org.papervision3d.core.render.draw {
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.geom.renderables.*;
import flash.display.*;
import flash.geom.*;
public interface ITriangleDrawer {
function drawTriangle(_arg1:Triangle3D, _arg2:Graphics, _arg3:RenderSessionData, _arg4:BitmapData=null, _arg5:Matrix=null):void;
}
}//package org.papervision3d.core.render.draw
Section 64
//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 65
//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 66
//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 67
//IUpdateBeforeMaterial (org.papervision3d.core.render.material.IUpdateBeforeMaterial)
package org.papervision3d.core.render.material {
import org.papervision3d.core.render.data.*;
public interface IUpdateBeforeMaterial {
function updateBeforeRender(_arg1:RenderSessionData):void;
}
}//package org.papervision3d.core.render.material
Section 68
//MaterialManager (org.papervision3d.core.render.material.MaterialManager)
package org.papervision3d.core.render.material {
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.proto.*;
import flash.utils.*;
public class MaterialManager {
private var materials:Dictionary;
private static var instance:MaterialManager;
public function MaterialManager():void{
if (instance){
throw (new Error("Only 1 instance of materialmanager allowed"));
};
init();
}
private function init():void{
materials = new Dictionary(true);
}
private function _unRegisterMaterial(_arg1:MaterialObject3D):void{
delete materials[_arg1];
}
public function updateMaterialsAfterRender(_arg1:RenderSessionData):void{
var _local2:IUpdateAfterMaterial;
var _local3:MaterialObject3D;
for each (_local3 in materials) {
if ((_local3 is IUpdateAfterMaterial)){
_local2 = (_local3 as IUpdateAfterMaterial);
_local2.updateAfterRender(_arg1);
};
};
}
private function _registerMaterial(_arg1:MaterialObject3D):void{
materials[_arg1] = _arg1;
}
public function updateMaterialsBeforeRender(_arg1:RenderSessionData):void{
var _local2:IUpdateBeforeMaterial;
var _local3:MaterialObject3D;
for each (_local3 in materials) {
if ((_local3 is IUpdateBeforeMaterial)){
_local2 = (_local3 as IUpdateBeforeMaterial);
_local2.updateBeforeRender(_arg1);
};
};
}
public static function getInstance():MaterialManager{
if (!instance){
instance = new (MaterialManager);
};
return (instance);
}
public static function unRegisterMaterial(_arg1:MaterialObject3D):void{
getInstance()._unRegisterMaterial(_arg1);
}
public static function registerMaterial(_arg1:MaterialObject3D):void{
getInstance()._registerMaterial(_arg1);
}
}
}//package org.papervision3d.core.render.material
Section 69
//BasicProjectionPipeline (org.papervision3d.core.render.project.BasicProjectionPipeline)
package org.papervision3d.core.render.project {
import org.papervision3d.core.render.data.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.culling.*;
public class BasicProjectionPipeline extends ProjectionPipeline {
public function BasicProjectionPipeline(){
init();
}
protected function init():void{
}
protected function projectObject(_arg1:DisplayObject3D, _arg2:RenderSessionData):void{
_arg1.project(_arg2.camera, _arg2);
}
override public function project(_arg1:RenderSessionData):void{
var _local2:Array;
var _local3:DisplayObject3D;
var _local4:Number;
_arg1.camera.transformView();
_local2 = _arg1.renderObjects;
_local4 = _local2.length;
if ((_arg1.camera is IObjectCuller)){
for each (_local3 in _local2) {
if (_local3.visible){
if (_arg1.viewPort.viewportObjectFilter){
if (_arg1.viewPort.viewportObjectFilter.testObject(_local3)){
_local3.view.calculateMultiply4x4(_arg1.camera.eye, _local3.transform);
projectObject(_local3, _arg1);
} else {
_arg1.renderStatistics.filteredObjects++;
};
} else {
_local3.view.calculateMultiply4x4(_arg1.camera.eye, _local3.transform);
projectObject(_local3, _arg1);
};
};
};
} else {
for each (_local3 in _local2) {
if (_local3.visible){
if (_arg1.viewPort.viewportObjectFilter){
if (_arg1.viewPort.viewportObjectFilter.testObject(_local3)){
_local3.view.calculateMultiply(_arg1.camera.eye, _local3.transform);
projectObject(_local3, _arg1);
} else {
_arg1.renderStatistics.filteredObjects++;
};
} else {
_local3.view.calculateMultiply(_arg1.camera.eye, _local3.transform);
projectObject(_local3, _arg1);
};
};
};
};
}
}
}//package org.papervision3d.core.render.project
Section 70
//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 71
//BasicRenderSorter (org.papervision3d.core.render.sort.BasicRenderSorter)
package org.papervision3d.core.render.sort {
public class BasicRenderSorter implements IRenderSorter {
public function sort(_arg1:Array):void{
_arg1.sortOn("screenDepth", Array.NUMERIC);
}
}
}//package org.papervision3d.core.render.sort
Section 72
//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 73
//AbstractRenderEngine (org.papervision3d.core.render.AbstractRenderEngine)
package org.papervision3d.core.render {
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.view.*;
import org.papervision3d.core.render.command.*;
import flash.events.*;
public class AbstractRenderEngine extends EventDispatcher implements IRenderEngine {
public function AbstractRenderEngine(_arg1:IEventDispatcher=null){
super(_arg1);
}
public function removeFromRenderList(_arg1:IRenderListItem):int{
return (0);
}
public function addToRenderList(_arg1:IRenderListItem):int{
return (0);
}
public function renderScene(_arg1:SceneObject3D, _arg2:CameraObject3D, _arg3:Viewport3D, _arg4:Boolean=true):RenderStatistics{
return (null);
}
}
}//package org.papervision3d.core.render
Section 74
//IRenderEngine (org.papervision3d.core.render.IRenderEngine)
package org.papervision3d.core.render {
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.view.*;
import org.papervision3d.core.render.command.*;
public interface IRenderEngine {
function addToRenderList(_arg1:IRenderListItem):int;
function removeFromRenderList(_arg1:IRenderListItem):int;
function renderScene(_arg1:SceneObject3D, _arg2:CameraObject3D, _arg3:Viewport3D, _arg4:Boolean=true):RenderStatistics;
}
}//package org.papervision3d.core.render
Section 75
//IVirtualMouseEvent (org.papervision3d.core.utils.virtualmouse.IVirtualMouseEvent)
package org.papervision3d.core.utils.virtualmouse {
public interface IVirtualMouseEvent {
}
}//package org.papervision3d.core.utils.virtualmouse
Section 76
//VirtualMouse (org.papervision3d.core.utils.virtualmouse.VirtualMouse)
package org.papervision3d.core.utils.virtualmouse {
import flash.display.*;
import flash.geom.*;
import com.blitzagency.xray.logger.*;
import flash.events.*;
import flash.utils.*;
import org.papervision3d.core.components.as3.utils.*;
public class VirtualMouse extends EventDispatcher {
private var _container:Sprite;
private var lastDownTarget:DisplayObject;
private var target:InteractiveObject;
private var updateMouseDown:Boolean;// = false
private var eventEvent:Class;
private var _lastEvent:Event;
private var mouseEventEvent:Class;
private var location:Point;
private var delta:int;// = 0
private var disabledEvents:Object;
private var log:XrayLog;
private var ignoredInstances:Dictionary;
private var isLocked:Boolean;// = false
private var lastWithinStage:Boolean;// = true
private var lastLocation:Point;
private var isDoubleClickEvent:Boolean;// = false
private var lastMouseDown:Boolean;// = false
private var altKey:Boolean;// = false
private var _useNativeEvents:Boolean;// = false
private var ctrlKey:Boolean;// = false
private var shiftKey:Boolean;// = false
private var _stage:Stage;
public static const UPDATE:String = "update";
private static var _mouseIsDown:Boolean = false;
public function VirtualMouse(_arg1:Stage=null, _arg2:Sprite=null, _arg3:Number=0, _arg4:Number=0){
altKey = false;
ctrlKey = false;
shiftKey = false;
delta = 0;
isLocked = false;
isDoubleClickEvent = false;
disabledEvents = new Object();
ignoredInstances = new Dictionary(true);
lastMouseDown = false;
updateMouseDown = false;
lastWithinStage = true;
_useNativeEvents = false;
eventEvent = VirtualMouseEvent;
mouseEventEvent = VirtualMouseMouseEvent;
log = new XrayLog();
super();
this.stage = _arg1;
this.container = _arg2;
location = new Point(_arg3, _arg4);
lastLocation = location.clone();
addEventListener(UPDATE, handleUpdate);
update();
}
public function get mouseIsDown():Boolean{
return (_mouseIsDown);
}
public function get stage():Stage{
return (_stage);
}
public function exitContainer():void{
var _local1:Point;
_local1 = target.globalToLocal(location);
if (!disabledEvents[MouseEvent.MOUSE_OUT]){
_lastEvent = new mouseEventEvent(MouseEvent.MOUSE_OUT, true, false, _local1.x, _local1.y, container, ctrlKey, altKey, shiftKey, _mouseIsDown, delta);
container.dispatchEvent(new mouseEventEvent(MouseEvent.MOUSE_OUT, true, false, _local1.x, _local1.y, container, ctrlKey, altKey, shiftKey, _mouseIsDown, delta));
dispatchEvent(new mouseEventEvent(MouseEvent.MOUSE_OUT, true, false, _local1.x, _local1.y, container, ctrlKey, altKey, shiftKey, _mouseIsDown, delta));
};
if (!disabledEvents[MouseEvent.ROLL_OUT]){
_lastEvent = new mouseEventEvent(MouseEvent.ROLL_OUT, false, false, _local1.x, _local1.y, container, ctrlKey, altKey, shiftKey, _mouseIsDown, delta);
container.dispatchEvent(new mouseEventEvent(MouseEvent.ROLL_OUT, false, false, _local1.x, _local1.y, container, ctrlKey, altKey, shiftKey, _mouseIsDown, delta));
dispatchEvent(new mouseEventEvent(MouseEvent.ROLL_OUT, false, false, _local1.x, _local1.y, container, ctrlKey, altKey, shiftKey, _mouseIsDown, delta));
};
if (target != container){
if (!disabledEvents[MouseEvent.MOUSE_OUT]){
_lastEvent = new mouseEventEvent(MouseEvent.MOUSE_OUT, true, false, _local1.x, _local1.y, container, ctrlKey, altKey, shiftKey, _mouseIsDown, delta);
target.dispatchEvent(new mouseEventEvent(MouseEvent.MOUSE_OUT, true, false, _local1.x, _local1.y, container, ctrlKey, altKey, shiftKey, _mouseIsDown, delta));
dispatchEvent(new mouseEventEvent(MouseEvent.MOUSE_OUT, true, false, _local1.x, _local1.y, container, ctrlKey, altKey, shiftKey, _mouseIsDown, delta));
};
if (!disabledEvents[MouseEvent.ROLL_OUT]){
_lastEvent = new mouseEventEvent(MouseEvent.ROLL_OUT, false, false, _local1.x, _local1.y, container, ctrlKey, altKey, shiftKey, _mouseIsDown, delta);
target.dispatchEvent(new mouseEventEvent(MouseEvent.ROLL_OUT, false, false, _local1.x, _local1.y, container, ctrlKey, altKey, shiftKey, _mouseIsDown, delta));
dispatchEvent(new mouseEventEvent(MouseEvent.ROLL_OUT, false, false, _local1.x, _local1.y, container, ctrlKey, altKey, shiftKey, _mouseIsDown, delta));
};
};
target = _stage;
}
public function release():void{
updateMouseDown = true;
_mouseIsDown = false;
if (!isLocked){
update();
};
}
public function click():void{
press();
release();
}
public function get container():Sprite{
return (_container);
}
public function set container(_arg1:Sprite):void{
_container = _arg1;
}
public function get y():Number{
return (location.y);
}
public function set x(_arg1:Number):void{
location.x = _arg1;
if (!isLocked){
update();
};
}
public function disableEvent(_arg1:String):void{
disabledEvents[_arg1] = true;
}
public function get lastEvent():Event{
return (_lastEvent);
}
private function handleUpdate(_arg1:Event):void{
var _local2:Point;
var _local3:Array;
var _local4:InteractiveObject;
var _local5:DisplayObject;
var _local6:int;
var _local7:Point;
var _local8:Point;
var _local9:Boolean;
if (!container){
return;
};
_local2 = CoordinateTools.localToLocal(container, stage, location);
_local3 = container.getObjectsUnderPoint(location);
_local6 = _local3.length;
while (_local6--) {
_local5 = _local3[_local6];
while (_local5) {
if (ignoredInstances[_local5]){
_local4 = null;
break;
};
if (((_local4) && ((_local5 is SimpleButton)))){
_local4 = null;
} else {
if (((_local4) && (!(DisplayObjectContainer(_local5).mouseChildren)))){
_local4 = null;
};
};
if (((((!(_local4)) && ((_local5 is InteractiveObject)))) && (InteractiveObject(_local5).mouseEnabled))){
_local4 = InteractiveObject(_local5);
};
_local5 = _local5.parent;
};
if (_local4){
break;
};
};
if (!_local4){
_local4 = _stage;
};
_local7 = target.globalToLocal(location);
_local8 = _local4.globalToLocal(location);
if (((!((lastLocation.x == location.x))) || (!((lastLocation.y == location.y))))){
_local9 = false;
if (stage){
_local9 = (((((((location.x >= 0)) && ((location.y >= 0)))) && ((location.x <= stage.stageWidth)))) && ((location.y <= stage.stageHeight)));
};
if (((((!(_local9)) && (lastWithinStage))) && (!(disabledEvents[Event.MOUSE_LEAVE])))){
_lastEvent = new eventEvent(Event.MOUSE_LEAVE, false, false);
stage.dispatchEvent(_lastEvent);
dispatchEvent(_lastEvent);
};
if (((_local9) && (!(disabledEvents[MouseEvent.MOUSE_MOVE])))){
_lastEvent = new mouseEventEvent(MouseEvent.MOUSE_MOVE, true, false, _local8.x, _local8.y, _local4, ctrlKey, altKey, shiftKey, _mouseIsDown, delta);
_local4.dispatchEvent(_lastEvent);
dispatchEvent(_lastEvent);
};
lastWithinStage = _local9;
};
if (_local4 != target){
if (!disabledEvents[MouseEvent.MOUSE_OUT]){
_lastEvent = new mouseEventEvent(MouseEvent.MOUSE_OUT, true, false, _local7.x, _local7.y, _local4, ctrlKey, altKey, shiftKey, _mouseIsDown, delta);
target.dispatchEvent(_lastEvent);
dispatchEvent(_lastEvent);
};
if (!disabledEvents[MouseEvent.ROLL_OUT]){
_lastEvent = new mouseEventEvent(MouseEvent.ROLL_OUT, false, false, _local7.x, _local7.y, _local4, ctrlKey, altKey, shiftKey, _mouseIsDown, delta);
target.dispatchEvent(_lastEvent);
dispatchEvent(_lastEvent);
};
if (!disabledEvents[MouseEvent.MOUSE_OVER]){
_lastEvent = new mouseEventEvent(MouseEvent.MOUSE_OVER, true, false, _local8.x, _local8.y, target, ctrlKey, altKey, shiftKey, _mouseIsDown, delta);
_local4.dispatchEvent(_lastEvent);
dispatchEvent(_lastEvent);
};
if (!disabledEvents[MouseEvent.ROLL_OVER]){
_lastEvent = new mouseEventEvent(MouseEvent.ROLL_OVER, false, false, _local8.x, _local8.y, target, ctrlKey, altKey, shiftKey, _mouseIsDown, delta);
_local4.dispatchEvent(_lastEvent);
dispatchEvent(_lastEvent);
};
};
if (updateMouseDown){
if (_mouseIsDown){
if (!disabledEvents[MouseEvent.MOUSE_DOWN]){
_lastEvent = new mouseEventEvent(MouseEvent.MOUSE_DOWN, true, false, _local8.x, _local8.y, _local4, ctrlKey, altKey, shiftKey, _mouseIsDown, delta);
_local4.dispatchEvent(_lastEvent);
dispatchEvent(_lastEvent);
};
lastDownTarget = _local4;
updateMouseDown = false;
} else {
if (!disabledEvents[MouseEvent.MOUSE_UP]){
_lastEvent = new mouseEventEvent(MouseEvent.MOUSE_UP, true, false, _local8.x, _local8.y, _local4, ctrlKey, altKey, shiftKey, _mouseIsDown, delta);
_local4.dispatchEvent(_lastEvent);
dispatchEvent(_lastEvent);
};
if (((!(disabledEvents[MouseEvent.CLICK])) && ((_local4 == lastDownTarget)))){
_lastEvent = new mouseEventEvent(MouseEvent.CLICK, true, false, _local8.x, _local8.y, _local4, ctrlKey, altKey, shiftKey, _mouseIsDown, delta);
_local4.dispatchEvent(_lastEvent);
dispatchEvent(_lastEvent);
};
lastDownTarget = null;
updateMouseDown = false;
};
};
if (((((isDoubleClickEvent) && (!(disabledEvents[MouseEvent.DOUBLE_CLICK])))) && (_local4.doubleClickEnabled))){
_lastEvent = new mouseEventEvent(MouseEvent.DOUBLE_CLICK, true, false, _local8.x, _local8.y, _local4, ctrlKey, altKey, shiftKey, _mouseIsDown, delta);
_local4.dispatchEvent(_lastEvent);
dispatchEvent(_lastEvent);
};
lastLocation = location.clone();
lastMouseDown = _mouseIsDown;
target = _local4;
}
public function getLocation():Point{
return (location.clone());
}
public function get x():Number{
return (location.x);
}
public function lock():void{
isLocked = true;
}
public function get useNativeEvents():Boolean{
return (_useNativeEvents);
}
public function setLocation(_arg1, _arg2=null):void{
var _local3:Point;
if ((_arg1 is Point)){
_local3 = (_arg1 as Point);
location.x = _local3.x;
location.y = _local3.y;
} else {
location.x = Number(_arg1);
location.y = Number(_arg2);
};
if (!isLocked){
update();
};
}
private function keyHandler(_arg1:KeyboardEvent):void{
altKey = _arg1.altKey;
ctrlKey = _arg1.ctrlKey;
shiftKey = _arg1.shiftKey;
}
public function unignore(_arg1:DisplayObject):void{
if ((_arg1 in ignoredInstances)){
delete ignoredInstances[_arg1];
};
}
public function doubleClick():void{
if (isLocked){
release();
} else {
click();
press();
isDoubleClickEvent = true;
release();
isDoubleClickEvent = false;
};
}
public function update():void{
dispatchEvent(new Event(UPDATE, false, false));
}
public function ignore(_arg1:DisplayObject):void{
ignoredInstances[_arg1] = true;
}
public function unlock():void{
isLocked = false;
update();
}
public function enableEvent(_arg1:String):void{
if ((_arg1 in disabledEvents)){
delete disabledEvents[_arg1];
};
}
public function press():void{
updateMouseDown = true;
_mouseIsDown = true;
if (!isLocked){
update();
};
}
public function set useNativeEvents(_arg1:Boolean):void{
if (_arg1 == _useNativeEvents){
return;
};
_useNativeEvents = _arg1;
if (_useNativeEvents){
eventEvent = VirtualMouseEvent;
mouseEventEvent = VirtualMouseMouseEvent;
} else {
eventEvent = Event;
mouseEventEvent = MouseEvent;
};
}
public function set y(_arg1:Number):void{
location.y = _arg1;
if (!isLocked){
update();
};
}
public function set stage(_arg1:Stage):void{
var _local2:Boolean;
if (_stage){
_local2 = true;
_stage.removeEventListener(KeyboardEvent.KEY_DOWN, keyHandler);
_stage.removeEventListener(KeyboardEvent.KEY_UP, keyHandler);
} else {
_local2 = false;
};
_stage = _arg1;
if (_stage){
_stage.addEventListener(KeyboardEvent.KEY_DOWN, keyHandler);
_stage.addEventListener(KeyboardEvent.KEY_UP, keyHandler);
target = _stage;
if (!_local2){
update();
};
};
}
}
}//package org.papervision3d.core.utils.virtualmouse
Section 77
//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 78
//VirtualMouseMouseEvent (org.papervision3d.core.utils.virtualmouse.VirtualMouseMouseEvent)
package org.papervision3d.core.utils.virtualmouse {
import flash.display.*;
import flash.events.*;
public class VirtualMouseMouseEvent extends MouseEvent implements IVirtualMouseEvent {
public function VirtualMouseMouseEvent(_arg1:String, _arg2:Boolean=false, _arg3:Boolean=false, _arg4:Number=NaN, _arg5:Number=NaN, _arg6:InteractiveObject=null, _arg7:Boolean=false, _arg8:Boolean=false, _arg9:Boolean=false, _arg10:Boolean=false, _arg11:int=0){
super(_arg1, _arg2, _arg3, _arg4, _arg5, _arg6, _arg7, _arg8, _arg9, _arg10, _arg11);
}
}
}//package org.papervision3d.core.utils.virtualmouse
Section 79
//InteractiveSceneManager (org.papervision3d.core.utils.InteractiveSceneManager)
package org.papervision3d.core.utils {
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.geom.renderables.*;
import flash.display.*;
import flash.geom.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.view.*;
import org.papervision3d.objects.*;
import com.blitzagency.xray.logger.*;
import flash.events.*;
import org.papervision3d.materials.*;
import org.papervision3d.core.utils.virtualmouse.*;
import org.papervision3d.events.*;
public class InteractiveSceneManager extends EventDispatcher {
public var container:Sprite;
public var currentDisplayObject3D:DisplayObject3D;
public var viewport:Viewport3D;
protected var log:XrayLog;
public var currentMaterial:MaterialObject3D;
public var debug:Boolean;// = false
public var mouse3D:Mouse3D;
public var enableOverOut:Boolean;// = true
public var virtualMouse:VirtualMouse;
public var renderHitData:RenderHitData;
public var currentMouseDO3D:DisplayObject3D;// = null
public static var MOUSE_IS_DOWN:Boolean = false;
public function InteractiveSceneManager(_arg1:Viewport3D){
virtualMouse = new VirtualMouse();
mouse3D = new Mouse3D();
enableOverOut = true;
currentMouseDO3D = null;
debug = false;
log = new XrayLog();
super();
this.viewport = _arg1;
this.container = _arg1.containerSprite;
init();
}
protected function initVirtualMouse():void{
virtualMouse.stage = container.stage;
virtualMouse.container = container;
}
public function init():void{
if (container){
if (container.stage){
initVirtualMouse();
initListeners();
} else {
container.addEventListener(Event.ADDED_TO_STAGE, handleAddedToStage);
};
};
}
public function initListeners():void{
if (viewport.interactive){
container.addEventListener(MouseEvent.MOUSE_DOWN, handleMousePress);
container.addEventListener(MouseEvent.MOUSE_UP, handleMouseRelease);
container.stage.addEventListener(MouseEvent.CLICK, handleMouseClick);
container.stage.addEventListener(MouseEvent.MOUSE_MOVE, handleMouseMove);
};
}
public function updateRenderHitData():void{
resolveRenderHitData();
currentDisplayObject3D = renderHitData.displayObject3D;
currentMaterial = renderHitData.material;
manageOverOut();
}
protected function handleMouseClick(_arg1:MouseEvent):void{
if (!_arg1.relatedObject){
return;
};
if (((renderHitData) && (renderHitData.hasHit))){
dispatchObjectEvent(InteractiveScene3DEvent.OBJECT_CLICK, currentDisplayObject3D);
};
}
protected function handleMouseOut(_arg1:DisplayObject3D):void{
var _local2:MovieMaterial;
if (_arg1){
_local2 = (_arg1.material as MovieMaterial);
if (_local2){
virtualMouse.exitContainer();
};
};
dispatchObjectEvent(InteractiveScene3DEvent.OBJECT_OUT, _arg1);
}
protected function manageOverOut():void{
if (!enableOverOut){
return;
};
if (((renderHitData) && (renderHitData.hasHit))){
if (((!(currentMouseDO3D)) && (currentDisplayObject3D))){
handleMouseOver(currentDisplayObject3D);
currentMouseDO3D = currentDisplayObject3D;
} else {
if (((currentMouseDO3D) && (!((currentMouseDO3D == currentDisplayObject3D))))){
handleMouseOut(currentMouseDO3D);
handleMouseOver(currentDisplayObject3D);
currentMouseDO3D = currentDisplayObject3D;
};
};
} else {
if (currentMouseDO3D != null){
handleMouseOut(currentMouseDO3D);
currentMouseDO3D = null;
};
};
}
protected function dispatchObjectEvent(_arg1:String, _arg2:DisplayObject3D):void{
var _local3:Number;
var _local4:Number;
if (debug){
log.debug(_arg1, _arg2.name);
};
if (((renderHitData) && (renderHitData.hasHit))){
_local3 = (renderHitData.u) ? renderHitData.u : 0;
_local4 = (renderHitData.v) ? renderHitData.v : 0;
dispatchEvent(new InteractiveScene3DEvent(_arg1, _arg2, container, (renderHitData.renderable as Triangle3D), _local3, _local4));
_arg2.dispatchEvent(new InteractiveScene3DEvent(_arg1, _arg2, container, (renderHitData.renderable as Triangle3D), _local3, _local4));
} else {
dispatchEvent(new InteractiveScene3DEvent(_arg1, _arg2, container));
if (_arg2){
_arg2.dispatchEvent(new InteractiveScene3DEvent(_arg1, _arg2, container));
};
};
}
protected function handleMouseMove(_arg1:MouseEvent):void{
var _local2:MovieMaterial;
updateRenderHitData();
if ((_arg1 is IVirtualMouseEvent)){
return;
};
if (((virtualMouse) && (renderHitData))){
_local2 = (currentMaterial as MovieMaterial);
if (_local2){
virtualMouse.container = (_local2.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);
};
};
}
protected function handleMouseOver(_arg1:DisplayObject3D):void{
dispatchObjectEvent(InteractiveScene3DEvent.OBJECT_OVER, _arg1);
}
protected function resolveRenderHitData():void{
var _local1:Point;
_local1 = new Point();
_local1.x = container.mouseX;
_local1.y = container.mouseY;
renderHitData = (viewport.hitTestPoint2D(_local1) as RenderHitData);
}
protected function handleMousePress(_arg1:MouseEvent):void{
if ((_arg1 is IVirtualMouseEvent)){
return;
};
MOUSE_IS_DOWN = true;
if (virtualMouse){
virtualMouse.press();
};
if (((((Mouse3D.enabled) && (renderHitData))) && (!((renderHitData.renderable == null))))){
mouse3D.updatePosition(renderHitData);
};
if (((renderHitData) && (renderHitData.hasHit))){
dispatchObjectEvent(InteractiveScene3DEvent.OBJECT_PRESS, currentDisplayObject3D);
};
}
protected function handleMouseRelease(_arg1:MouseEvent):void{
if ((_arg1 is IVirtualMouseEvent)){
return;
};
MOUSE_IS_DOWN = false;
if (virtualMouse){
virtualMouse.release();
};
if (((((Mouse3D.enabled) && (renderHitData))) && (!((renderHitData.renderable == null))))){
mouse3D.updatePosition(renderHitData);
};
if (((renderHitData) && (renderHitData.hasHit))){
dispatchObjectEvent(InteractiveScene3DEvent.OBJECT_RELEASE, currentDisplayObject3D);
};
}
protected function handleAddedToStage(_arg1:Event):void{
initVirtualMouse();
initListeners();
}
public function destroy():void{
viewport = null;
renderHitData = null;
currentDisplayObject3D = null;
currentMaterial = null;
currentMouseDO3D = null;
container.removeEventListener(MouseEvent.MOUSE_DOWN, handleMousePress);
container.removeEventListener(MouseEvent.MOUSE_UP, handleMouseRelease);
container.removeEventListener(MouseEvent.CLICK, handleMouseClick);
if (container.stage){
container.stage.removeEventListener(MouseEvent.MOUSE_MOVE, handleMouseMove);
};
container = null;
}
}
}//package org.papervision3d.core.utils
Section 80
//Mouse3D (org.papervision3d.core.utils.Mouse3D)
package org.papervision3d.core.utils {
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.math.*;
import org.papervision3d.objects.*;
public class Mouse3D extends DisplayObject3D {
private var position:Number3D;
private var target:Number3D;
public static var enabled:Boolean = false;
private static var UP:Number3D = new Number3D(0, 1, 0);
public function Mouse3D(_arg1:Object=null):void{
position = new Number3D(0, 0, 0);
target = new Number3D();
super();
}
public function updatePosition(_arg1:RenderHitData):void{
var _local2:Triangle3D;
var _local3:Number3D;
var _local4:Matrix3D;
var _local5:Number3D;
var _local6:Number3D;
var _local7:Matrix3D;
_local2 = (_arg1.renderable as Triangle3D);
target.x = _local2.faceNormal.x;
target.y = _local2.faceNormal.y;
target.z = _local2.faceNormal.z;
_local3 = Number3D.sub(target, position);
_local3.normalize();
if (_local3.modulo > 0.1){
_local5 = Number3D.cross(_local3, UP);
_local5.normalize();
_local6 = Number3D.cross(_local3, _local5);
_local6.normalize();
_local7 = this.transform;
_local7.n11 = _local5.x;
_local7.n21 = _local5.y;
_local7.n31 = _local5.z;
_local7.n12 = -(_local6.x);
_local7.n22 = -(_local6.y);
_local7.n32 = -(_local6.z);
_local7.n13 = _local3.x;
_local7.n23 = _local3.y;
_local7.n33 = _local3.z;
};
_local4 = Matrix3D.IDENTITY;
this.transform = Matrix3D.multiply(_local2.instance.world, _local7);
x = _arg1.x;
y = _arg1.y;
z = _arg1.z;
}
}
}//package org.papervision3d.core.utils
Section 81
//StopWatch (org.papervision3d.core.utils.StopWatch)
package org.papervision3d.core.utils {
import flash.events.*;
import flash.utils.*;
public class StopWatch extends EventDispatcher {
private var startTime:int;
private var elapsedTime:int;
private var stopTime:int;
private var isRunning:Boolean;
public function stop():int{
if (isRunning){
stopTime = getTimer();
elapsedTime = (stopTime - startTime);
isRunning = false;
return (elapsedTime);
};
return (0);
}
public function start():void{
if (!isRunning){
startTime = getTimer();
isRunning = true;
};
}
public function reset():void{
isRunning = false;
}
}
}//package org.papervision3d.core.utils
Section 82
//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 83
//FileLoadEvent (org.papervision3d.events.FileLoadEvent)
package org.papervision3d.events {
import flash.events.*;
public class FileLoadEvent extends Event {
public var bytesLoaded:Number;// = -1
public var message:String;// = ""
public var bytesTotal:Number;// = -1
public var dataObj:Object;// = null
public var file:String;// = ""
public static const COLLADA_MATERIALS_DONE:String = "colladaMaterialsDone";
public static const LOAD_PROGRESS:String = "loadProgress";
public static const ANIMATIONS_COMPLETE:String = "animationsComplete";
public static const SECURITY_LOAD_ERROR:String = "securityLoadError";
public static const LOAD_ERROR:String = "loadError";
public static const LOAD_COMPLETE:String = "loadComplete";
public static const ANIMATIONS_PROGRESS:String = "animationsProgress";
public function FileLoadEvent(_arg1:String, _arg2:String="", _arg3:Number=-1, _arg4:Number=-1, _arg5:String="", _arg6:Object=null, _arg7:Boolean=false, _arg8:Boolean=false){
file = "";
bytesLoaded = -1;
bytesTotal = -1;
message = "";
dataObj = null;
super(_arg1, _arg7, _arg8);
this.file = _arg2;
this.bytesLoaded = _arg3;
this.bytesTotal = _arg4;
this.message = _arg5;
this.dataObj = _arg6;
}
}
}//package org.papervision3d.events
Section 84
//InteractiveScene3DEvent (org.papervision3d.events.InteractiveScene3DEvent)
package org.papervision3d.events {
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.geom.renderables.*;
import flash.display.*;
import org.papervision3d.objects.*;
import flash.events.*;
public class InteractiveScene3DEvent extends Event {
public var sprite:Sprite;// = null
public var displayObject3D:DisplayObject3D;// = null
public var face3d:Triangle3D;// = null
public var renderHitData:RenderHitData;
public var x:Number;// = 0
public var y:Number;// = 0
public static const OBJECT_ADDED:String = "objectAdded";
public static const OBJECT_PRESS:String = "mousePress";
public static const OBJECT_RELEASE:String = "mouseRelease";
public static const OBJECT_CLICK:String = "mouseClick";
public static const OBJECT_RELEASE_OUTSIDE:String = "mouseReleaseOutside";
public static const OBJECT_OUT:String = "mouseOut";
public static const OBJECT_MOVE:String = "mouseMove";
public static const OBJECT_OVER:String = "mouseOver";
public function InteractiveScene3DEvent(_arg1:String, _arg2:DisplayObject3D=null, _arg3:Sprite=null, _arg4:Triangle3D=null, _arg5:Number=0, _arg6:Number=0, _arg7:RenderHitData=null, _arg8:Boolean=false, _arg9:Boolean=false){
displayObject3D = null;
sprite = null;
face3d = null;
x = 0;
y = 0;
super(_arg1, _arg8, _arg9);
this.displayObject3D = _arg2;
this.sprite = _arg3;
this.face3d = _arg4;
this.x = _arg5;
this.y = _arg6;
this.renderHitData = _arg7;
}
override public function toString():String{
return (((((((("Type : " + type) + ", DO3D : ") + displayObject3D) + " Sprite : ") + sprite) + " Face : ") + face3d));
}
}
}//package org.papervision3d.events
Section 85
//RendererEvent (org.papervision3d.events.RendererEvent)
package org.papervision3d.events {
import org.papervision3d.core.render.data.*;
import flash.events.*;
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 86
//LineMaterial (org.papervision3d.materials.special.LineMaterial)
package org.papervision3d.materials.special {
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.geom.renderables.*;
import flash.display.*;
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:Line3D, _arg2:Graphics, _arg3:RenderSessionData):void{
_arg2.lineStyle(_arg1.size, lineColor, lineAlpha);
_arg2.moveTo(_arg1.v0.vertex3DInstance.x, _arg1.v0.vertex3DInstance.y);
if (_arg1.cV){
_arg2.curveTo(_arg1.cV.vertex3DInstance.x, _arg1.cV.vertex3DInstance.y, _arg1.v1.vertex3DInstance.x, _arg1.v1.vertex3DInstance.y);
} else {
_arg2.lineTo(_arg1.v1.vertex3DInstance.x, _arg1.v1.vertex3DInstance.y);
};
_arg2.moveTo(0, 0);
_arg2.lineStyle();
}
}
}//package org.papervision3d.materials.special
Section 87
//ParticleMaterial (org.papervision3d.materials.special.ParticleMaterial)
package org.papervision3d.materials.special {
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.geom.renderables.*;
import flash.display.*;
import flash.geom.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.core.render.draw.*;
public class ParticleMaterial extends MaterialObject3D implements IParticleDrawer {
public var shape:int;
public static var SHAPE_SQUARE:int = 0;
public static var SHAPE_CIRCLE:int = 1;
public function ParticleMaterial(_arg1:Number, _arg2:Number, _arg3:int=0){
this.shape = _arg3;
this.fillAlpha = _arg2;
this.fillColor = _arg1;
}
public function updateRenderRect(_arg1:Particle):void{
var _local2:Rectangle;
_local2 = _arg1.renderRect;
if (_arg1.size == 0){
_local2.width = 1;
_local2.height = 1;
} else {
_local2.width = (_arg1.renderScale * _arg1.size);
_local2.height = (_arg1.renderScale * _arg1.size);
};
_local2.x = (_arg1.vertex3D.vertex3DInstance.x - (_local2.width / 2));
_local2.y = (_arg1.vertex3D.vertex3DInstance.y - (_local2.width / 2));
}
public function drawParticle(_arg1:Particle, _arg2:Graphics, _arg3:RenderSessionData):void{
var _local4:Rectangle;
_arg2.beginFill(fillColor, fillAlpha);
_local4 = _arg1.renderRect;
if (shape == SHAPE_SQUARE){
_arg2.drawRect(_local4.x, _local4.y, _local4.width, _local4.height);
} else {
if (shape == SHAPE_CIRCLE){
_arg2.drawCircle((_local4.x + (_local4.width / 2)), (_local4.y + (_local4.width / 2)), (_local4.width / 2));
//unresolved jump
};
};
_arg2.endFill();
_arg3.renderStatistics.particles++;
}
}
}//package org.papervision3d.materials.special
Section 88
//MaterialsList (org.papervision3d.materials.utils.MaterialsList)
package org.papervision3d.materials.utils {
import org.papervision3d.core.proto.*;
import flash.utils.*;
public class MaterialsList {
protected var _materials:Dictionary;
public var materialsByName:Dictionary;
private var _materialsTotal:int;
public function MaterialsList(_arg1=null):void{
var _local2:String;
var _local3:String;
super();
this.materialsByName = new Dictionary(true);
this._materials = new Dictionary(false);
this._materialsTotal = 0;
if (_arg1){
if ((_arg1 is Array)){
for (_local2 in _arg1) {
this.addMaterial(_arg1[_local2]);
};
} else {
if ((_arg1 is Object)){
for (_local3 in _arg1) {
this.addMaterial(_arg1[_local3], _local3);
};
};
};
};
}
public function get numMaterials():int{
return (_materialsTotal);
}
public function addMaterial(_arg1:MaterialObject3D, _arg2:String=null):MaterialObject3D{
_arg2 = ((((_arg2) || (_arg1.name))) || (String(_arg1.id)));
this._materials[_arg1] = _arg2;
this.materialsByName[_arg2] = _arg1;
this._materialsTotal++;
return (_arg1);
}
public function removeMaterial(_arg1:MaterialObject3D):MaterialObject3D{
delete this.materialsByName[this._materials[_arg1]];
delete this._materials[_arg1];
return (_arg1);
}
public function toString():String{
var _local1:String;
var _local2:MaterialObject3D;
_local1 = "";
for each (_local2 in this.materialsByName) {
_local1 = (_local1 + (this._materials[_local2] + "\n"));
};
return (_local1);
}
public function removeMaterialByName(_arg1:String):MaterialObject3D{
return (removeMaterial(getMaterialByName(_arg1)));
}
public function clone():MaterialsList{
var _local1:MaterialsList;
var _local2:MaterialObject3D;
_local1 = new MaterialsList();
for each (_local2 in this.materialsByName) {
_local1.addMaterial(_local2.clone(), this._materials[_local2]);
};
return (_local1);
}
public function getMaterialByName(_arg1:String):MaterialObject3D{
return ((this.materialsByName[_arg1]) ? this.materialsByName[_arg1] : this.materialsByName["all"]);
}
}
}//package org.papervision3d.materials.utils
Section 89
//RenderRecStorage (org.papervision3d.materials.utils.RenderRecStorage)
package org.papervision3d.materials.utils {
import org.papervision3d.core.geom.renderables.*;
import flash.geom.*;
public class RenderRecStorage {
public var mat:Matrix;
public var v0:Vertex3DInstance;
public var v1:Vertex3DInstance;
public var v2:Vertex3DInstance;
public function RenderRecStorage(){
v0 = new Vertex3DInstance();
v1 = new Vertex3DInstance();
v2 = new Vertex3DInstance();
mat = new Matrix();
super();
}
}
}//package org.papervision3d.materials.utils
Section 90
//BitmapFileMaterial (org.papervision3d.materials.BitmapFileMaterial)
package org.papervision3d.materials {
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.geom.renderables.*;
import flash.display.*;
import flash.geom.*;
import org.papervision3d.core.proto.*;
import flash.events.*;
import org.papervision3d.core.render.draw.*;
import flash.utils.*;
import org.papervision3d.*;
import org.papervision3d.events.*;
import flash.net.*;
public class BitmapFileMaterial extends BitmapMaterial implements ITriangleDrawer {
public var loaded:Boolean;
private var errorLoading:Boolean;// = false
public var url:String;// = ""
public static var LOADING_COLOR:int = MaterialObject3D.DEFAULT_COLOR;
public static var callback:Function;
private static var _loadedBitmaps:Object = new Object();
private static var _loadingIdle:Boolean = true;
private static var _waitingBitmaps:Array = new Array();
private static var _subscribedMaterials:Object = new Object();
public static var ERROR_COLOR:int = MaterialObject3D.DEBUG_COLOR;
private static var _loaderUrls:Dictionary = new Dictionary();
public function BitmapFileMaterial(_arg1:String=""){
url = "";
errorLoading = false;
super();
this.url = _arg1;
this.loaded = false;
this.fillAlpha = 1;
this.fillColor = LOADING_COLOR;
if (_arg1.length > 0){
texture = _arg1;
};
}
override public function get texture():Object{
return (this._texture);
}
private function loadComplete():void{
var _local1:FileLoadEvent;
this.fillAlpha = 0;
this.fillColor = 0;
this.loaded = true;
_local1 = new FileLoadEvent(FileLoadEvent.LOAD_COMPLETE, this.url);
this.dispatchEvent(_local1);
}
override public function set texture(_arg1:Object):void{
if ((_arg1 is String) == false){
Papervision3D.log("Error: BitmapFileMaterial.texture requires a String for the texture");
return;
};
bitmap = createBitmapFromURL(String(_arg1));
_texture = _arg1;
}
private function loadBitmapCompleteHandler(_arg1:Event):void{
var _local2:Loader;
var _local3:Bitmap;
var _local4:String;
var _local5:BitmapData;
var _local6:BitmapFileMaterial;
_local2 = Loader(_arg1.target.loader);
_local3 = Bitmap(_local2.content);
_local4 = _loaderUrls[_local2];
_local5 = super.createBitmap(_local3.bitmapData);
for each (_local6 in _subscribedMaterials[_local4]) {
_local6.bitmap = _local5;
_local6.maxU = this.maxU;
_local6.maxV = this.maxV;
_local6.resetMapping();
_local6.loadComplete();
};
_loadedBitmaps[_local4] = _local5;
_waitingBitmaps.shift();
if (_waitingBitmaps.length > 0){
loadNextBitmap();
} else {
_loadingIdle = true;
if (Boolean(callback)){
callback();
};
};
}
override public function drawTriangle(_arg1:Triangle3D, _arg2:Graphics, _arg3:RenderSessionData, _arg4:BitmapData=null, _arg5:Matrix=null):void{
if ((((bitmap == null)) || (errorLoading))){
if (errorLoading){
_arg2.lineStyle(lineThickness, lineColor, lineAlpha);
};
_arg2.beginFill(fillColor, fillAlpha);
_arg2.moveTo(_arg1.v0.vertex3DInstance.x, _arg1.v0.vertex3DInstance.y);
_arg2.lineTo(_arg1.v1.vertex3DInstance.x, _arg1.v1.vertex3DInstance.y);
_arg2.lineTo(_arg1.v2.vertex3DInstance.x, _arg1.v2.vertex3DInstance.y);
_arg2.lineTo(_arg1.v0.vertex3DInstance.x, _arg1.v0.vertex3DInstance.y);
_arg2.endFill();
if (errorLoading){
_arg2.lineStyle();
};
_arg3.renderStatistics.triangles++;
};
super.drawTriangle(_arg1, _arg2, _arg3);
}
private function loadNextBitmap():void{
var file:String;
var request:URLRequest;
var bitmapLoader:Loader;
file = _waitingBitmaps[0];
request = new URLRequest(file);
bitmapLoader = new Loader();
bitmapLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loadBitmapProgressHandler);
bitmapLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadBitmapCompleteHandler);
bitmapLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, loadBitmapErrorHandler);
try {
bitmapLoader.load(request);
_loaderUrls[bitmapLoader] = file;
_loadingIdle = false;
Papervision3D.log(("BitmapFileMaterial: Loading bitmap from " + file));
} catch(error:Error) {
_waitingBitmaps.shift();
_loadingIdle = true;
Papervision3D.log(("[ERROR] BitmapFileMaterial: Unable to load file " + error.message));
};
}
private function loadBitmapErrorHandler(_arg1:IOErrorEvent):void{
var _local2:String;
var _local3:FileLoadEvent;
_local2 = String(_waitingBitmaps.shift());
_loadedBitmaps[_local2] = null;
_subscribedMaterials[_local2] = null;
this.errorLoading = true;
this.lineColor = ERROR_COLOR;
this.lineAlpha = 1;
this.lineThickness = 1;
if (_waitingBitmaps.length > 0){
loadNextBitmap();
} else {
_loadingIdle = true;
if (Boolean(callback)){
callback();
};
};
_local3 = new FileLoadEvent(FileLoadEvent.LOAD_ERROR, _local2, -1, -1, _arg1.text);
dispatchEvent(_local3);
}
private function queueBitmap(_arg1:String):void{
if (!_subscribedMaterials[_arg1]){
_waitingBitmaps.push(_arg1);
_subscribedMaterials[_arg1] = new Array();
};
_subscribedMaterials[_arg1].push(this);
if (_loadingIdle){
loadNextBitmap();
};
}
protected function createBitmapFromURL(_arg1:String):BitmapData{
var _local2:BitmapData;
if (_arg1 == ""){
return (null);
};
if (_loadedBitmaps[_arg1]){
_local2 = _loadedBitmaps[_arg1];
bitmap = super.createBitmap(_local2);
this.loadComplete();
return (_local2);
};
queueBitmap(_arg1);
return (null);
}
private function loadBitmapProgressHandler(_arg1:ProgressEvent):void{
var _local2:FileLoadEvent;
_local2 = new FileLoadEvent(FileLoadEvent.LOAD_PROGRESS, url, _arg1.bytesLoaded, _arg1.bytesTotal);
dispatchEvent(_local2);
}
}
}//package org.papervision3d.materials
Section 91
//BitmapMaterial (org.papervision3d.materials.BitmapMaterial)
package org.papervision3d.materials {
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.geom.renderables.*;
import flash.display.*;
import flash.geom.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.materials.utils.*;
import org.papervision3d.core.render.draw.*;
import flash.utils.*;
import org.papervision3d.*;
import org.papervision3d.core.math.util.*;
import org.papervision3d.core.material.*;
public class BitmapMaterial extends TriangleMaterial implements ITriangleDrawer {
protected var renderRecStorage:Array;
protected var mabz:Number;
protected var dcay:Number;
protected var dsab:Number;
protected var tempTriangleMatrix:Matrix;
protected var dsbc:Number;
private var b2:Number;
protected var _precise:Boolean;
protected var faz:Number;
public var uvMatrices:Dictionary;
protected var dsca:Number;
protected var ax:Number;
protected var az:Number;
protected var ay:Number;
protected var mcay:Number;
protected var bx:Number;
protected var by:Number;
protected var bz:Number;
protected var fbz:Number;
protected var fcz:Number;
public var minimumRenderSize:Number;// = 4
protected var mcaz:Number;
private var c2:Number;
protected var mcax:Number;
protected var dbcx:Number;
protected var cx:Number;
protected var cy:Number;
protected var cz:Number;
private var d2:Number;
protected var dbcy:Number;
protected var dabx:Number;
protected var _perPixelPrecision:int;// = 8
protected var daby:Number;
private var x0:Number;
private var x1:Number;
private var x2:Number;
protected var mbcy:Number;
protected var mbcz:Number;
private var y0:Number;
private var y1:Number;
private var y2:Number;
protected var _texture:Object;
protected var focus:Number;// = 200
protected var maby:Number;
protected var mabx:Number;
protected var dcax:Number;
protected var mbcx:Number;
private var a2:Number;
protected var _precision:int;// = 8
protected static const DEFAULT_FOCUS:Number = 200;
protected static var _triMatrix:Matrix = new Matrix();
protected static var _triMap:Matrix;
public static var AUTO_MIP_MAPPING:Boolean = false;
public static var MIP_MAP_DEPTH:Number = 8;
protected static var hitRect:Rectangle = new Rectangle();
protected static var _localMatrix:Matrix = new Matrix();
public function BitmapMaterial(_arg1:BitmapData=null, _arg2:Boolean=false){
focus = 200;
_precision = 8;
_perPixelPrecision = 8;
minimumRenderSize = 4;
uvMatrices = new Dictionary();
tempTriangleMatrix = new Matrix();
super();
if (_arg1){
texture = _arg1;
};
this.precise = _arg2;
createRenderRecStorage();
}
public function transformUV(_arg1:Triangle3D):Matrix{
var _local2:Array;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Matrix;
var _local16:Matrix;
if (!_arg1.uv){
Papervision3D.log("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);
_local15.invert();
_local16 = (uvMatrices[_arg1]) ? uvMatrices[_arg1] : uvMatrices[_arg1] = _local15.clone();
_local16.a = _local15.a;
_local16.b = _local15.b;
_local16.c = _local15.c;
_local16.d = _local15.d;
_local16.tx = _local15.tx;
_local16.ty = _local15.ty;
} else {
Papervision3D.log("MaterialObject3D: transformUV() material.bitmap not found!");
};
};
return (_local16);
}
protected function renderRec(_arg1:Graphics, _arg2:Matrix, _arg3:Vertex3DInstance, _arg4:Vertex3DInstance, _arg5:Vertex3DInstance, _arg6:Number, _arg7:RenderSessionData, _arg8:BitmapData):void{
var _local9:int;
var _local10:RenderRecStorage;
var _local11:Matrix;
var _local12:Number;
az = _arg3.z;
bz = _arg4.z;
cz = _arg5.z;
if ((((((az <= 0)) && ((bz <= 0)))) && ((cz <= 0)))){
return;
};
cx = _arg5.x;
cy = _arg5.y;
bx = _arg4.x;
by = _arg4.y;
ax = _arg3.x;
ay = _arg3.y;
if (_arg7.viewPort.cullingRectangle){
hitRect.x = Math.min(cx, Math.min(bx, ax));
hitRect.width = (Math.max(cx, Math.max(bx, ax)) + Math.abs(hitRect.x));
hitRect.y = Math.min(cy, Math.min(by, ay));
hitRect.height = (Math.max(cy, Math.max(by, ay)) + Math.abs(hitRect.y));
if (!FastRectangleTools.intersects(hitRect, _arg7.viewPort.cullingRectangle)){
return;
};
};
if ((((((((_arg6 >= 100)) || ((hitRect.width < minimumRenderSize)))) || ((hitRect.height < minimumRenderSize)))) || ((focus == Infinity)))){
renderTriangleBitmap(_arg1, _arg2, _arg3, _arg4, _arg5, smooth, tiled, _arg8);
_arg7.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));
_local9 = (_arg6 + 1);
_local10 = RenderRecStorage(renderRecStorage[int(_arg6)]);
_local11 = _local10.mat;
if ((((((dsab <= _precision)) && ((dsca <= _precision)))) && ((dsbc <= _precision)))){
renderTriangleBitmap(_arg1, _arg2, _arg3, _arg4, _arg5, smooth, tiled, _arg8);
_arg7.renderStatistics.triangles++;
return;
};
if ((((((dsab > _precision)) && ((dsca > _precision)))) && ((dsbc > _precision)))){
_local11.a = (_arg2.a * 2);
_local11.b = (_arg2.b * 2);
_local11.c = (_arg2.c * 2);
_local11.d = (_arg2.d * 2);
_local11.tx = (_arg2.tx * 2);
_local11.ty = (_arg2.ty * 2);
_local10.v0.x = (mabx * 0.5);
_local10.v0.y = (maby * 0.5);
_local10.v0.z = ((az + bz) * 0.5);
_local10.v1.x = (mbcx * 0.5);
_local10.v1.y = (mbcy * 0.5);
_local10.v1.z = ((bz + cz) * 0.5);
_local10.v2.x = (mcax * 0.5);
_local10.v2.y = (mcay * 0.5);
_local10.v2.z = ((cz + az) * 0.5);
renderRec(_arg1, _local11, _arg3, _local10.v0, _local10.v2, _local9, _arg7, _arg8);
_local11.tx = (_local11.tx - 1);
renderRec(_arg1, _local11, _local10.v0, _arg4, _local10.v1, _local9, _arg7, _arg8);
_local11.ty = (_local11.ty - 1);
_local11.tx = (_arg2.tx * 2);
renderRec(_arg1, _local11, _local10.v2, _local10.v1, _arg5, _local9, _arg7, _arg8);
_local11.a = (-(_arg2.a) * 2);
_local11.b = (-(_arg2.b) * 2);
_local11.c = (-(_arg2.c) * 2);
_local11.d = (-(_arg2.d) * 2);
_local11.tx = ((-(_arg2.tx) * 2) + 1);
_local11.ty = ((-(_arg2.ty) * 2) + 1);
renderRec(_arg1, _local11, _local10.v1, _local10.v2, _local10.v0, _local9, _arg7, _arg8);
return;
};
_local12 = Math.max(dsab, Math.max(dsca, dsbc));
if (dsab == _local12){
_local11.a = (_arg2.a * 2);
_local11.b = _arg2.b;
_local11.c = (_arg2.c * 2);
_local11.d = _arg2.d;
_local11.tx = (_arg2.tx * 2);
_local11.ty = _arg2.ty;
_local10.v0.x = (mabx * 0.5);
_local10.v0.y = (maby * 0.5);
_local10.v0.z = ((az + bz) * 0.5);
renderRec(_arg1, _local11, _arg3, _local10.v0, _arg5, _local9, _arg7, _arg8);
_local11.a = ((_arg2.a * 2) + _arg2.b);
_local11.c = ((2 * _arg2.c) + _arg2.d);
_local11.tx = (((_arg2.tx * 2) + _arg2.ty) - 1);
renderRec(_arg1, _local11, _local10.v0, _arg4, _arg5, _local9, _arg7, _arg8);
return;
};
if (dsca == _local12){
_local11.a = _arg2.a;
_local11.b = (_arg2.b * 2);
_local11.c = _arg2.c;
_local11.d = (_arg2.d * 2);
_local11.tx = _arg2.tx;
_local11.ty = (_arg2.ty * 2);
_local10.v2.x = (mcax * 0.5);
_local10.v2.y = (mcay * 0.5);
_local10.v2.z = ((cz + az) * 0.5);
renderRec(_arg1, _local11, _arg3, _arg4, _local10.v2, _local9, _arg7, _arg8);
_local11.b = (_local11.b + _arg2.a);
_local11.d = (_local11.d + _arg2.c);
_local11.ty = (_local11.ty + (_arg2.tx - 1));
renderRec(_arg1, _local11, _local10.v2, _arg4, _arg5, _local9, _arg7, _arg8);
return;
};
_local11.a = (_arg2.a - _arg2.b);
_local11.b = (_arg2.b * 2);
_local11.c = (_arg2.c - _arg2.d);
_local11.d = (_arg2.d * 2);
_local11.tx = (_arg2.tx - _arg2.ty);
_local11.ty = (_arg2.ty * 2);
_local10.v1.x = (mbcx * 0.5);
_local10.v1.y = (mbcy * 0.5);
_local10.v1.z = ((bz + cz) * 0.5);
renderRec(_arg1, _local11, _arg3, _arg4, _local10.v1, _local9, _arg7, _arg8);
_local11.a = (_arg2.a * 2);
_local11.b = (_arg2.b - _arg2.a);
_local11.c = (_arg2.c * 2);
_local11.d = (_arg2.d - _arg2.c);
_local11.tx = (_arg2.tx * 2);
_local11.ty = (_arg2.ty - _arg2.tx);
renderRec(_arg1, _local11, _arg3, _local10.v1, _arg5, _local9, _arg7, _arg8);
}
protected function createRenderRecStorage():void{
var _local1:int;
this.renderRecStorage = new Array();
_local1 = 0;
while (_local1 <= 100) {
this.renderRecStorage[_local1] = new RenderRecStorage();
_local1++;
};
}
public function resetUVS():void{
uvMatrices = new Dictionary(false);
}
public function get texture():Object{
return (this._texture);
}
public function set pixelPrecision(_arg1:int):void{
_precision = ((_arg1 * _arg1) * 1.4);
_perPixelPrecision = _arg1;
}
protected function correctBitmap(_arg1:BitmapData):BitmapData{
var _local2:BitmapData;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Boolean;
_local3 = (1 << MIP_MAP_DEPTH);
_local4 = (_arg1.width / _local3);
_local4 = ((_local4 == uint(_local4))) ? _local4 : (uint(_local4) + 1);
_local5 = (_arg1.height / _local3);
_local5 = ((_local5 == uint(_local5))) ? _local5 : (uint(_local5) + 1);
_local6 = (_local3 * _local4);
_local7 = (_local3 * _local5);
_local8 = true;
if (_local6 > 2880){
_local6 = _arg1.width;
_local8 = false;
};
if (_local7 > 2880){
_local7 = _arg1.height;
_local8 = false;
};
if (!_local8){
Papervision3D.log((("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{
resetMapping();
if (AUTO_MIP_MAPPING){
return (correctBitmap(_arg1));
};
this.maxU = (this.maxV = 1);
return (_arg1);
}
public function get precise():Boolean{
return (_precise);
}
override public function clone():MaterialObject3D{
var _local1:MaterialObject3D;
_local1 = super.clone();
_local1.maxU = this.maxU;
_local1.maxV = this.maxV;
return (_local1);
}
public function set texture(_arg1:Object):void{
if ((_arg1 is BitmapData) == false){
Papervision3D.log("Error: BitmapMaterial.texture requires a BitmapData object for the texture");
return;
};
bitmap = createBitmap(BitmapData(_arg1));
_texture = _arg1;
}
override public function toString():String{
return (((((("Texture:" + this.texture) + " lineColor:") + this.lineColor) + " lineAlpha:") + this.lineAlpha));
}
override public function copy(_arg1:MaterialObject3D):void{
super.copy(_arg1);
this.maxU = _arg1.maxU;
this.maxV = _arg1.maxV;
}
override public function drawTriangle(_arg1:Triangle3D, _arg2:Graphics, _arg3:RenderSessionData, _arg4:BitmapData=null, _arg5:Matrix=null):void{
if (!_precise){
if (lineAlpha){
_arg2.lineStyle(lineThickness, lineColor, lineAlpha);
};
if (bitmap){
_triMap = (_arg5) ? _arg5 : ((uvMatrices[_arg1]) || (transformUV(_arg1)));
x0 = _arg1.v0.vertex3DInstance.x;
y0 = _arg1.v0.vertex3DInstance.y;
x1 = _arg1.v1.vertex3DInstance.x;
y1 = _arg1.v1.vertex3DInstance.y;
x2 = _arg1.v2.vertex3DInstance.x;
y2 = _arg1.v2.vertex3DInstance.y;
_triMatrix.a = (x1 - x0);
_triMatrix.b = (y1 - y0);
_triMatrix.c = (x2 - x0);
_triMatrix.d = (y2 - y0);
_triMatrix.tx = x0;
_triMatrix.ty = y0;
_localMatrix.a = _triMap.a;
_localMatrix.b = _triMap.b;
_localMatrix.c = _triMap.c;
_localMatrix.d = _triMap.d;
_localMatrix.tx = _triMap.tx;
_localMatrix.ty = _triMap.ty;
_localMatrix.concat(_triMatrix);
_arg2.beginBitmapFill((_arg4) ? _arg4 : bitmap, _localMatrix, tiled, smooth);
};
_arg2.moveTo(x0, y0);
_arg2.lineTo(x1, y1);
_arg2.lineTo(x2, y2);
_arg2.lineTo(x0, y0);
if (bitmap){
_arg2.endFill();
};
if (lineAlpha){
_arg2.lineStyle();
};
_arg3.renderStatistics.triangles++;
} else {
_triMap = (_arg5) ? _arg5 : ((uvMatrices[_arg1]) || (transformUV(_arg1)));
focus = _arg3.camera.focus;
renderRec(_arg2, _triMap, _arg1.v0.vertex3DInstance, _arg1.v1.vertex3DInstance, _arg1.v2.vertex3DInstance, 0, _arg3, (_arg4) ? _arg4 : bitmap);
};
}
public function resetMapping():void{
uvMatrices = new Dictionary();
}
public function get precision():int{
return (_precision);
}
public function get pixelPrecision():int{
return (_perPixelPrecision);
}
public function renderTriangleBitmap(_arg1:Graphics, _arg2:Matrix, _arg3:Vertex3DInstance, _arg4:Vertex3DInstance, _arg5:Vertex3DInstance, _arg6:Boolean, _arg7:Boolean, _arg8:BitmapData):void{
a2 = (_arg4.x - _arg3.x);
b2 = (_arg4.y - _arg3.y);
c2 = (_arg5.x - _arg3.x);
d2 = (_arg5.y - _arg3.y);
tempTriangleMatrix.a = ((_arg2.a * a2) + (_arg2.b * c2));
tempTriangleMatrix.b = ((_arg2.a * b2) + (_arg2.b * d2));
tempTriangleMatrix.c = ((_arg2.c * a2) + (_arg2.d * c2));
tempTriangleMatrix.d = ((_arg2.c * b2) + (_arg2.d * d2));
tempTriangleMatrix.tx = (((_arg2.tx * a2) + (_arg2.ty * c2)) + _arg3.x);
tempTriangleMatrix.ty = (((_arg2.tx * b2) + (_arg2.ty * d2)) + _arg3.y);
_arg1.beginBitmapFill(_arg8, tempTriangleMatrix, _arg7, _arg6);
_arg1.moveTo(_arg3.x, _arg3.y);
_arg1.lineTo(_arg4.x, _arg4.y);
_arg1.lineTo(_arg5.x, _arg5.y);
_arg1.endFill();
}
public function set precise(_arg1:Boolean):void{
_precise = _arg1;
}
protected function extendBitmapEdges(_arg1:BitmapData, _arg2:Number, _arg3:Number):void{
var _local4:Rectangle;
var _local5:Point;
var _local6:int;
_local4 = new Rectangle();
_local5 = new Point();
if (_arg1.width > _arg2){
_local4.x = (_arg2 - 1);
_local4.y = 0;
_local4.width = 1;
_local4.height = _arg3;
_local5.y = 0;
_local6 = _arg2;
while (_local6 < _arg1.width) {
_local5.x = _local6;
_arg1.copyPixels(_arg1, _local4, _local5);
_local6++;
};
};
if (_arg1.height > _arg3){
_local4.x = 0;
_local4.y = (_arg3 - 1);
_local4.width = _arg1.width;
_local4.height = 1;
_local5.x = 0;
_local6 = _arg3;
while (_local6 < _arg1.height) {
_local5.y = _local6;
_arg1.copyPixels(_arg1, _local4, _local5);
_local6++;
};
};
}
override public function destroy():void{
super.destroy();
if (uvMatrices){
uvMatrices = null;
};
if (bitmap){
bitmap.dispose();
};
this.renderRecStorage = null;
}
public function set precision(_arg1:int):void{
_precision = _arg1;
}
}
}//package org.papervision3d.materials
Section 92
//ColorMaterial (org.papervision3d.materials.ColorMaterial)
package org.papervision3d.materials {
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.geom.renderables.*;
import flash.display.*;
import flash.geom.*;
import org.papervision3d.core.render.draw.*;
import org.papervision3d.core.material.*;
public class ColorMaterial extends TriangleMaterial implements ITriangleDrawer {
public function ColorMaterial(_arg1:Number=0xFF00FF, _arg2:Number=1, _arg3:Boolean=false){
this.fillColor = _arg1;
this.fillAlpha = _arg2;
this.interactive = _arg3;
}
override public function toString():String{
return (((("ColorMaterial - color:" + this.fillColor) + " alpha:") + this.fillAlpha));
}
override public function drawTriangle(_arg1:Triangle3D, _arg2:Graphics, _arg3:RenderSessionData, _arg4:BitmapData=null, _arg5:Matrix=null):void{
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
_local6 = _arg1.v0.vertex3DInstance.x;
_local7 = _arg1.v0.vertex3DInstance.y;
_local8 = _arg1.v1.vertex3DInstance.x;
_local9 = _arg1.v1.vertex3DInstance.y;
_local10 = _arg1.v2.vertex3DInstance.x;
_local11 = _arg1.v2.vertex3DInstance.y;
_arg2.beginFill(fillColor, fillAlpha);
_arg2.moveTo(_local6, _local7);
_arg2.lineTo(_local8, _local9);
_arg2.lineTo(_local10, _local11);
_arg2.lineTo(_local6, _local7);
_arg2.endFill();
_arg3.renderStatistics.triangles++;
}
}
}//package org.papervision3d.materials
Section 93
//MovieAssetMaterial (org.papervision3d.materials.MovieAssetMaterial)
package org.papervision3d.materials {
import flash.display.*;
import org.papervision3d.core.render.draw.*;
import flash.utils.*;
import org.papervision3d.*;
public class MovieAssetMaterial extends MovieMaterial implements ITriangleDrawer {
public var createUnique:Boolean;// = false
private static var _library:Object = new Object();
private static var _count:Object = new Object();
public function MovieAssetMaterial(_arg1:String="", _arg2:Boolean=false, _arg3:Boolean=false, _arg4:Boolean=false, _arg5:Boolean=false){
createUnique = false;
super();
movieTransparent = _arg2;
this.animated = _arg3;
this.createUnique = _arg4;
this.precise = _arg5;
if (_arg1.length > 0){
texture = _arg1;
};
}
protected function createMovie(_arg1):MovieClip{
var _local2:MovieClip;
var _local3:Class;
var _local4:MovieClip;
if (this._texture != _arg1){
var _local5 = _count;
var _local6 = this._texture;
var _local7 = (_local5[_local6] - 1);
_local5[_local6] = _local7;
_local4 = _library[this._texture];
if (((_local4) && ((_count[this._texture] == 0)))){
_library[this._texture] = null;
};
};
_local2 = _library[_arg1];
if (!_local2){
_local3 = (getDefinitionByName(_arg1) as Class);
_local2 = new (_local3);
_library[_arg1] = _local2;
_count[_arg1] = 0;
} else {
if (createUnique){
_local3 = (getDefinitionByName(_arg1) as Class);
_local2 = new (_local3);
} else {
_local5 = _count;
_local6 = _arg1;
_local7 = (_local5[_local6] + 1);
_local5[_local6] = _local7;
};
};
return (_local2);
}
override public function get texture():Object{
return (this._texture);
}
override public function set texture(_arg1:Object):void{
if ((_arg1 is String) == false){
Papervision3D.log("Error: MovieAssetMaterial.texture requires a String to be passed to create the MovieClip reference from the library");
return;
};
movie = Sprite(createMovie(String(_arg1)));
bitmap = createBitmapFromSprite(movie);
_texture = _arg1;
}
}
}//package org.papervision3d.materials
Section 94
//MovieMaterial (org.papervision3d.materials.MovieMaterial)
package org.papervision3d.materials {
import org.papervision3d.core.render.data.*;
import flash.display.*;
import flash.geom.*;
import org.papervision3d.core.render.material.*;
import org.papervision3d.core.render.draw.*;
import org.papervision3d.*;
public class MovieMaterial extends BitmapMaterial implements ITriangleDrawer, IUpdateBeforeMaterial {
private var _animated:Boolean;
public var movieTransparent:Boolean;
public var movie:DisplayObject;
public var allowAutoResize:Boolean;// = true
public function MovieMaterial(_arg1:DisplayObject=null, _arg2:Boolean=false, _arg3:Boolean=false, _arg4:Boolean=false){
allowAutoResize = true;
super();
movieTransparent = _arg2;
this.animated = _arg3;
this.interactive = interactive;
this.precise = _arg4;
if (_arg1){
texture = _arg1;
};
}
override public function get texture():Object{
return (this._texture);
}
public function set animated(_arg1:Boolean):void{
_animated = _arg1;
}
override public function set texture(_arg1:Object):void{
if ((_arg1 is DisplayObject) == false){
Papervision3D.log("Error: MovieMaterial.texture requires a Sprite to be passed as the object");
return;
};
bitmap = createBitmapFromSprite(DisplayObject(_arg1));
_texture = _arg1;
}
protected function initBitmap(_arg1:DisplayObject):void{
if (bitmap){
bitmap.dispose();
};
if ((((_arg1.width == 0)) || ((_arg1.height == 0)))){
bitmap = new BitmapData(0x0100, 0x0100, movieTransparent, fillColor);
} else {
bitmap = new BitmapData(_arg1.width, _arg1.height, this.movieTransparent);
};
}
public function updateBeforeRender(_arg1:RenderSessionData):void{
var _local2:int;
var _local3:int;
var _local4:Boolean;
if (_animated){
_local2 = int(movie.width);
_local3 = int(movie.height);
if (((allowAutoResize) && (((!((_local2 == bitmap.width))) || (!((_local3 == bitmap.height))))))){
initBitmap(movie);
_local4 = true;
};
drawBitmap();
if (_local4){
bitmap = super.createBitmap(bitmap);
};
};
}
public function get animated():Boolean{
return (_animated);
}
public function drawBitmap():void{
var _local1:Matrix;
bitmap.fillRect(bitmap.rect, this.fillColor);
_local1 = new Matrix();
_local1.scale(movie.scaleX, movie.scaleY);
bitmap.draw(movie, _local1, movie.transform.colorTransform);
}
protected function createBitmapFromSprite(_arg1:DisplayObject):BitmapData{
movie = _arg1;
initBitmap(movie);
drawBitmap();
bitmap = super.createBitmap(bitmap);
return (bitmap);
}
}
}//package org.papervision3d.materials
Section 95
//WireframeMaterial (org.papervision3d.materials.WireframeMaterial)
package org.papervision3d.materials {
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.geom.renderables.*;
import flash.display.*;
import flash.geom.*;
import org.papervision3d.core.render.draw.*;
import org.papervision3d.core.material.*;
public class WireframeMaterial extends TriangleMaterial implements ITriangleDrawer {
public function WireframeMaterial(_arg1:Number=0xFF00FF, _arg2:Number=100, _arg3:Number=0){
this.lineColor = _arg1;
this.lineAlpha = _arg2;
this.lineThickness = _arg3;
this.doubleSided = false;
}
override public function toString():String{
return (((("WireframeMaterial - color:" + this.lineColor) + " alpha:") + this.lineAlpha));
}
override public function drawTriangle(_arg1:Triangle3D, _arg2:Graphics, _arg3:RenderSessionData, _arg4:BitmapData=null, _arg5:Matrix=null):void{
var _local6:Number;
var _local7:Number;
_local6 = _arg1.v0.vertex3DInstance.x;
_local7 = _arg1.v0.vertex3DInstance.y;
if (lineAlpha){
_arg2.lineStyle(lineThickness, lineColor, lineAlpha);
_arg2.moveTo(_local6, _local7);
_arg2.lineTo(_arg1.v1.vertex3DInstance.x, _arg1.v1.vertex3DInstance.y);
_arg2.lineTo(_arg1.v2.vertex3DInstance.x, _arg1.v2.vertex3DInstance.y);
_arg2.lineTo(_local6, _local7);
_arg2.lineStyle();
_arg3.renderStatistics.triangles++;
};
}
}
}//package org.papervision3d.materials
Section 96
//Cube (org.papervision3d.objects.primitives.Cube)
package org.papervision3d.objects.primitives {
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.materials.utils.*;
import org.papervision3d.core.math.*;
import org.papervision3d.core.geom.*;
import org.papervision3d.*;
public class Cube extends TriangleMesh3D {
private var insideFaces:int;
public var segments:Number3D;
private var excludeFaces:int;
public static var ALL:int = (((((FRONT + BACK) + RIGHT) + LEFT) + TOP) + BOTTOM);
public static var LEFT:int = 8;
public static var FRONT:int = 1;
public static var BOTTOM:int = 32;
public static var TOP:int = 16;
public static var BACK:int = 2;
public static var NONE:int = 0;
public static var RIGHT:int = 4;
public function Cube(_arg1:MaterialsList, _arg2:Number=500, _arg3:Number=500, _arg4:Number=500, _arg5:int=1, _arg6:int=1, _arg7:int=1, _arg8:int=0, _arg9:int=0, _arg10:Object=null){
super(_arg1.getMaterialByName("all"), new Array(), new Array(), null, _arg10);
this.materials = _arg1;
this.insideFaces = _arg8;
this.excludeFaces = _arg9;
segments = new Number3D(_arg5, _arg6, _arg7);
buildCube(_arg2, _arg4, _arg3);
}
private function buildPlane(_arg1:String, _arg2:String, _arg3:String, _arg4:Number, _arg5:Number, _arg6:Number, _arg7:Boolean=false):void{
var _local8:MaterialObject3D;
var _local9:String;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Array;
var _local16:Array;
var _local17:Array;
var _local18:Number;
var _local19:Number;
var _local20:Number;
var _local21:Number;
var _local22:int;
var _local23:NumberUV;
var _local24:NumberUV;
var _local25:NumberUV;
var _local26:int;
var _local27:Vertex3D;
var _local28:Vertex3D;
var _local29:Vertex3D;
var _local30:Vertex3D;
_local8 = materials.getMaterialByName(_arg1);
if (!_local8){
_local8 = materials.getMaterialByName("all");
if (!_local8){
Papervision3D.log("Cube: Required material not found in given materials list. Supported materials are: front, back, right, left, top, bottom & all.");
return;
};
};
if ((((((_arg2 == "x")) && ((_arg3 == "y")))) || ((((_arg2 == "y")) && ((_arg3 == "x")))))){
_local9 = "z";
} else {
if ((((((_arg2 == "x")) && ((_arg3 == "z")))) || ((((_arg2 == "z")) && ((_arg3 == "x")))))){
_local9 = "y";
} else {
if ((((((_arg2 == "z")) && ((_arg3 == "y")))) || ((((_arg2 == "y")) && ((_arg3 == "z")))))){
_local9 = "x";
};
};
};
_local10 = (_arg7) ? -1 : 1;
_local11 = this.segments[_arg2];
_local12 = this.segments[_arg3];
_local13 = (_local11 + 1);
_local14 = (_local12 + 1);
_local15 = this.geometry.vertices;
_local16 = this.geometry.faces;
_local17 = new Array();
_local18 = (_arg4 / 2);
_local19 = (_arg5 / 2);
_local20 = (_arg4 / _local11);
_local21 = (_arg5 / _local12);
_local22 = 0;
while (_local22 < _local13) {
_local26 = 0;
while (_local26 < _local14) {
_local27 = new Vertex3D();
_local27[_arg2] = (((_local22 * _local20) - _local18) * _local10);
_local27[_arg3] = ((_local26 * _local21) - _local19);
_local27[_local9] = _arg6;
_local15.push(_local27);
_local17.push(_local27);
_local26++;
};
_local22++;
};
_local22 = 0;
while (_local22 < _local11) {
_local26 = 0;
while (_local26 < _local12) {
_local28 = _local17[((_local22 * _local14) + _local26)];
_local29 = _local17[((_local22 * _local14) + (_local26 + 1))];
_local30 = _local17[(((_local22 + 1) * _local14) + _local26)];
_local23 = new NumberUV((_local22 / _local11), (_local26 / _local12));
_local24 = new NumberUV((_local22 / _local11), ((_local26 + 1) / _local12));
_local25 = new NumberUV(((_local22 + 1) / _local11), (_local26 / _local12));
_local16.push(new Triangle3D(this, [_local28, _local30, _local29], _local8, [_local23, _local25, _local24]));
_local28 = _local17[(((_local22 + 1) * _local14) + (_local26 + 1))];
_local29 = _local17[(((_local22 + 1) * _local14) + _local26)];
_local30 = _local17[((_local22 * _local14) + (_local26 + 1))];
_local23 = new NumberUV(((_local22 + 1) / _local11), ((_local26 + 1) / _local12));
_local24 = new NumberUV(((_local22 + 1) / _local11), (_local26 / _local12));
_local25 = new NumberUV((_local22 / _local11), ((_local26 + 1) / _local12));
_local16.push(new Triangle3D(this, [_local29, _local28, _local30], _local8, [_local24, _local23, _local25]));
_local26++;
};
_local22++;
};
}
private function buildCube(_arg1:Number, _arg2:Number, _arg3:Number):void{
var _local4:Number;
var _local5:Number;
var _local6:Number;
_local4 = (_arg1 / 2);
_local5 = (_arg2 / 2);
_local6 = (_arg3 / 2);
if (!(excludeFaces & FRONT)){
buildPlane("front", "x", "y", _arg1, _arg2, _local6, !(Boolean((insideFaces & FRONT))));
};
if (!(excludeFaces & BACK)){
buildPlane("back", "x", "y", _arg1, _arg2, -(_local6), Boolean((insideFaces & BACK)));
};
if (!(excludeFaces & RIGHT)){
buildPlane("right", "z", "y", _arg3, _arg2, _local4, Boolean((insideFaces & RIGHT)));
};
if (!(excludeFaces & LEFT)){
buildPlane("left", "z", "y", _arg3, _arg2, -(_local4), !(Boolean((insideFaces & LEFT))));
};
if (!(excludeFaces & TOP)){
buildPlane("top", "x", "z", _arg1, _arg3, _local5, Boolean((insideFaces & TOP)));
};
if (!(excludeFaces & BOTTOM)){
buildPlane("bottom", "x", "z", _arg1, _arg3, -(_local5), !(Boolean((insideFaces & BOTTOM))));
};
mergeVertices();
this.geometry.ready = true;
}
}
}//package org.papervision3d.objects.primitives
Section 97
//Plane (org.papervision3d.objects.primitives.Plane)
package org.papervision3d.objects.primitives {
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.core.math.*;
import org.papervision3d.core.geom.*;
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, _arg6:Object=null){
var _local7:Number;
super(_arg1, new Array(), new Array(), null, _arg6);
this.segmentsW = ((_arg4) || (DEFAULT_SEGMENTS));
this.segmentsH = ((_arg5) || (this.segmentsW));
_local7 = DEFAULT_SCALE;
if (!_arg3){
if (_arg2){
_local7 = _arg2;
};
if (((_arg1) && (_arg1.bitmap))){
_arg2 = (_arg1.bitmap.width * _local7);
_arg3 = (_arg1.bitmap.height * _local7);
} else {
_arg2 = (DEFAULT_SIZE * _local7);
_arg3 = (DEFAULT_SIZE * _local7);
};
};
buildPlane(_arg2, _arg3);
}
private function buildPlane(_arg1:Number, _arg2:Number):void{
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Array;
var _local8:Array;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:int;
var _local14:NumberUV;
var _local15:NumberUV;
var _local16:NumberUV;
var _local17:int;
var _local18:Number;
var _local19:Number;
var _local20:Vertex3D;
var _local21:Vertex3D;
var _local22:Vertex3D;
_local3 = this.segmentsW;
_local4 = this.segmentsH;
_local5 = (_local3 + 1);
_local6 = (_local4 + 1);
_local7 = this.geometry.vertices;
_local8 = this.geometry.faces;
_local9 = (_arg1 / 2);
_local10 = (_arg2 / 2);
_local11 = (_arg1 / _local3);
_local12 = (_arg2 / _local4);
_local13 = 0;
while (_local13 < (_local3 + 1)) {
_local17 = 0;
while (_local17 < _local6) {
_local18 = ((_local13 * _local11) - _local9);
_local19 = ((_local17 * _local12) - _local10);
_local7.push(new Vertex3D(_local18, _local19, 0));
_local17++;
};
_local13++;
};
_local13 = 0;
while (_local13 < _local3) {
_local17 = 0;
while (_local17 < _local4) {
_local20 = _local7[((_local13 * _local6) + _local17)];
_local21 = _local7[((_local13 * _local6) + (_local17 + 1))];
_local22 = _local7[(((_local13 + 1) * _local6) + _local17)];
_local14 = new NumberUV((_local13 / _local3), (_local17 / _local4));
_local15 = new NumberUV((_local13 / _local3), ((_local17 + 1) / _local4));
_local16 = new NumberUV(((_local13 + 1) / _local3), (_local17 / _local4));
_local8.push(new Triangle3D(this, [_local20, _local22, _local21], material, [_local14, _local16, _local15]));
_local20 = _local7[(((_local13 + 1) * _local6) + (_local17 + 1))];
_local21 = _local7[(((_local13 + 1) * _local6) + _local17)];
_local22 = _local7[((_local13 * _local6) + (_local17 + 1))];
_local14 = new NumberUV(((_local13 + 1) / _local3), ((_local17 + 1) / _local4));
_local15 = new NumberUV(((_local13 + 1) / _local3), (_local17 / _local4));
_local16 = new NumberUV((_local13 / _local3), ((_local17 + 1) / _local4));
_local8.push(new Triangle3D(this, [_local20, _local22, _local21], material, [_local14, _local16, _local15]));
_local17++;
};
_local13++;
};
this.geometry.ready = true;
}
}
}//package org.papervision3d.objects.primitives
Section 98
//DisplayObject3D (org.papervision3d.objects.DisplayObject3D)
package org.papervision3d.objects {
import org.papervision3d.core.render.data.*;
import flash.display.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.view.*;
import org.papervision3d.materials.utils.*;
import org.papervision3d.core.math.*;
import org.papervision3d.core.data.*;
import org.papervision3d.view.layer.*;
import org.papervision3d.core.culling.*;
import org.papervision3d.*;
public class DisplayObject3D extends DisplayObjectContainer3D {
public var filters:Array;
public var extra:Object;
public var frustumTestMethod:int;// = 0
private var _rotationX:Number;
private var _rotationY:Number;
private var _rotationZ:Number;
private var position:Number3D;
public var meshSort:uint;// = 1
public var materials:MaterialsList;
public var id:int;
private var xAxis:Number3D;
private var zAxis:Number3D;
private var _scaleDirty:Boolean;// = false
private var _numClones:uint;// = 0
public var alpha:Number;// = 1
private var _scaleX:Number;
private var _scaleY:Number;
private var _scaleZ:Number;
public var screen:Number3D;
protected var _userData:UserData;
public var screenZ:Number;
protected var _useOwnContainer:Boolean;// = false
public var visible:Boolean;
public var name:String;
public var container:ViewportLayer;
private var target:Number3D;
public var world:Matrix3D;
public var blendMode:String;// = "normal"
private var _material:MaterialObject3D;
public var culled:Boolean;
public var transform:Matrix3D;
public var geometry:GeometryObject3D;
public var parent:DisplayObjectContainer3D;
public var view:Matrix3D;
protected var _scene:SceneObject3D;// = null
public var faces:Array;
private var yAxis:Number3D;
private var _rotation:Number3D;
protected var _sorted:Array;
protected var _transformDirty:Boolean;// = false
private var _rotationDirty:Boolean;// = false
public var parentContainer:DisplayObject3D;
private static const LEFT:Number3D = new Number3D(-1, 0, 0);
public static const MESH_SORT_CLOSE:uint = 3;
public static const MESH_SORT_CENTER:uint = 1;
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 _totalDisplayObjects:int = 0;
private static var _tempMatrix:Matrix3D = Matrix3D.IDENTITY;
public static var sortedArray:Array = new Array();
private static var _tempQuat:Quaternion = new Quaternion();
private static var toDEGREES:Number = 57.2957795130823;
public static var faceLevelMode:Boolean;
private static var toRADIANS:Number = 0.0174532925199433;
public function DisplayObject3D(_arg1:String=null, _arg2:GeometryObject3D=null, _arg3:Object=null):void{
var _local4:Number;
_transformDirty = false;
position = Number3D.ZERO;
target = Number3D.ZERO;
zAxis = Number3D.ZERO;
xAxis = Number3D.ZERO;
yAxis = Number3D.ZERO;
_rotation = Number3D.ZERO;
_rotationDirty = false;
_scaleDirty = false;
_numClones = 0;
alpha = 1;
blendMode = BlendMode.NORMAL;
filters = [];
_useOwnContainer = false;
frustumTestMethod = FrustumTestMethod.BOUNDING_SPHERE;
screen = new Number3D();
_scene = null;
meshSort = MESH_SORT_CENTER;
faces = new Array();
super();
if (_arg1 != null){
Papervision3D.log(("DisplayObject3D: " + _arg1));
};
this.culled = false;
this.transform = Matrix3D.IDENTITY;
this.world = Matrix3D.IDENTITY;
this.view = Matrix3D.IDENTITY;
if (_arg3 != null){
this.x = (_arg3.x) ? ((_arg3.x) || (0)) : 0;
this.y = (_arg3.y) ? ((_arg3.y) || (0)) : 0;
this.z = (_arg3.z) ? ((_arg3.z) || (0)) : 0;
};
rotationX = (_arg3) ? ((_arg3.rotationX) || (0)) : 0;
rotationY = (_arg3) ? ((_arg3.rotationY) || (0)) : 0;
rotationZ = (_arg3) ? ((_arg3.rotationZ) || (0)) : 0;
_local4 = (Papervision3D.usePERCENT) ? 100 : 1;
scaleX = (_arg3) ? ((_arg3.scaleX) || (_local4)) : _local4;
scaleY = (_arg3) ? ((_arg3.scaleY) || (_local4)) : _local4;
scaleZ = (_arg3) ? ((_arg3.scaleZ) || (_local4)) : _local4;
if (((_arg3) && (_arg3.extra))){
this.extra = _arg3.extra;
};
this.visible = true;
this.id = _totalDisplayObjects++;
this.name = ((_arg1) || (String(this.id)));
_numClones = 0;
if (_arg2){
addGeometry(_arg2);
};
}
public function set z(_arg1:Number):void{
this.transform.n34 = _arg1;
}
public function moveDown(_arg1:Number):void{
translate(_arg1, DOWN);
}
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 project(_arg1:DisplayObject3D, _arg2:RenderSessionData):Number{
var _local3:Number;
var _local4:Number;
var _local5:DisplayObject3D;
if (this._transformDirty){
updateTransform();
};
this.world.calculateMultiply(_arg1.world, this.transform);
if ((_arg2.camera is IObjectCuller)){
if (this === _arg2.camera){
this.culled = true;
} else {
this.culled = (IObjectCuller(_arg2.camera).testObject(this) < 0);
};
if (this.culled){
_arg2.renderStatistics.culledObjects++;
return (0);
};
if (_arg1 !== _arg2.camera){
this.view.calculateMultiply4x4(_arg1.view, this.transform);
};
} else {
if (_arg1 !== _arg2.camera){
this.view.calculateMultiply(_arg1.view, this.transform);
};
};
_local3 = 0;
_local4 = 0;
for each (_local5 in this._childrenByName) {
if (_local5.visible){
_local3 = (_local3 + _local5.project(this, _arg2));
_local4++;
};
};
return ((this.screenZ = (_local3 / _local4)));
}
public function get material():MaterialObject3D{
return (_material);
}
public function get userData():UserData{
return (_userData);
}
private function calculateScreenCoords(_arg1:CameraObject3D):void{
var _local2:Number;
_local2 = ((_arg1.focus * _arg1.zoom) / (_arg1.focus + view.n34));
screen.x = (view.n14 * _local2);
screen.y = (view.n24 * _local2);
screen.z = view.n34;
}
public function lookAt(_arg1:DisplayObject3D, _arg2:Number3D=null):void{
var _local3:Matrix3D;
position.reset(this.x, this.y, this.z);
target.reset(_arg1.x, _arg1.y, _arg1.z);
zAxis.copyFrom(target);
zAxis.minusEq(position);
zAxis.normalize();
if (zAxis.modulo > 0.1){
xAxis = Number3D.cross(zAxis, ((_arg2) || (UP)), xAxis);
xAxis.normalize();
yAxis = Number3D.cross(zAxis, xAxis, yAxis);
yAxis.normalize();
_local3 = this.transform;
_local3.n11 = (xAxis.x * _scaleX);
_local3.n21 = (xAxis.y * _scaleX);
_local3.n31 = (xAxis.z * _scaleX);
_local3.n12 = (-(yAxis.x) * _scaleY);
_local3.n22 = (-(yAxis.y) * _scaleY);
_local3.n32 = (-(yAxis.z) * _scaleY);
_local3.n13 = (zAxis.x * _scaleZ);
_local3.n23 = (zAxis.y * _scaleZ);
_local3.n33 = (zAxis.z * _scaleZ);
this._transformDirty = false;
this._rotationDirty = true;
//unresolved jump
};
}
public function set rotationX(_arg1:Number):void{
this._rotationX = (Papervision3D.useDEGREES) ? (-(_arg1) * toRADIANS) : -(_arg1);
this._transformDirty = true;
}
protected function setParentContainer(_arg1:DisplayObject3D, _arg2:Boolean=true):void{
var _local3:DisplayObject3D;
if (((_arg2) && (!((_arg1 == this))))){
parentContainer = _arg1;
};
for each (_local3 in children) {
_local3.setParentContainer(_arg1, _arg2);
};
}
public function set rotationZ(_arg1:Number):void{
this._rotationZ = (Papervision3D.useDEGREES) ? (-(_arg1) * toRADIANS) : -(_arg1);
this._transformDirty = true;
}
public function set rotationY(_arg1:Number):void{
this._rotationY = (Papervision3D.useDEGREES) ? (-(_arg1) * toRADIANS) : -(_arg1);
this._transformDirty = true;
}
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 addGeometry(_arg1:GeometryObject3D=null):void{
if (_arg1){
this.geometry = _arg1;
};
}
public function get sceneX():Number{
return (this.world.n14);
}
public function get scaleY():Number{
if (Papervision3D.usePERCENT){
return ((this._scaleY * 100));
};
return (this._scaleY);
}
public function get scaleZ():Number{
if (Papervision3D.usePERCENT){
return ((this._scaleZ * 100));
};
return (this._scaleZ);
}
public function moveUp(_arg1:Number):void{
translate(_arg1, UP);
}
public function get scaleX():Number{
if (Papervision3D.usePERCENT){
return ((this._scaleX * 100));
};
return (this._scaleX);
}
public function distanceTo(_arg1:DisplayObject3D):Number{
var _local2:Number;
var _local3:Number;
var _local4:Number;
_local2 = (this.x - _arg1.x);
_local3 = (this.y - _arg1.y);
_local4 = (this.z - _arg1.z);
return (Math.sqrt((((_local2 * _local2) + (_local3 * _local3)) + (_local4 * _local4))));
}
public function get sceneY():Number{
return (this.world.n24);
}
public function set userData(_arg1:UserData):void{
_userData = _arg1;
}
public function clone():DisplayObject3D{
var _local1:String;
var _local2:DisplayObject3D;
var _local3:DisplayObject3D;
_local1 = ((this.name + "_") + _numClones++);
_local2 = new DisplayObject3D(_local1);
if (this.material){
_local2.material = this.material;
};
if (this.materials){
_local2.materials = this.materials.clone();
};
if (this.geometry){
_local2.geometry = this.geometry.clone(_local2);
_local2.geometry.ready = true;
};
_local2.copyTransform(this.transform);
for each (_local3 in this.children) {
_local2.addChild(_local3.clone());
};
return (_local2);
}
public function get sceneZ():Number{
return (this.world.n34);
}
private function updateRotation():void{
_rotation = Matrix3D.matrix2euler(this.transform, _rotation);
this._rotationX = (_rotation.x * toRADIANS);
this._rotationY = (_rotation.y * toRADIANS);
this._rotationZ = (_rotation.z * toRADIANS);
this._rotationDirty = false;
}
public function hitTestObject(_arg1:DisplayObject3D, _arg2:Number=1):Boolean{
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
_local3 = (this.x - _arg1.x);
_local4 = (this.y - _arg1.y);
_local5 = (this.z - _arg1.z);
_local6 = (((_local3 * _local3) + (_local4 * _local4)) + (_local5 * _local5));
_local7 = (this.geometry) ? this.geometry.boundingSphere.maxDistance : 0;
_local8 = (_arg1.geometry) ? _arg1.geometry.boundingSphere.maxDistance : 0;
_local7 = (_local7 * _arg2);
return (((_local7 + _local8) > _local6));
}
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 set material(_arg1:MaterialObject3D):void{
if (_material){
_material.unregisterObject(this);
};
_material = _arg1;
_material.registerObject(this);
}
public function copyTransform(_arg1):void{
var _local2:Matrix3D;
var _local3:Matrix3D;
_local2 = this.transform;
_local3 = ((_arg1 is DisplayObject3D)) ? _arg1.transform : _arg1;
_local2.n11 = _local3.n11;
_local2.n12 = _local3.n12;
_local2.n13 = _local3.n13;
_local2.n14 = _local3.n14;
_local2.n21 = _local3.n21;
_local2.n22 = _local3.n22;
_local2.n23 = _local3.n23;
_local2.n24 = _local3.n24;
_local2.n31 = _local3.n31;
_local2.n32 = _local3.n32;
_local2.n33 = _local3.n33;
_local2.n34 = _local3.n34;
this._transformDirty = false;
this._rotationDirty = true;
}
public function get x():Number{
return (this.transform.n14);
}
public function get y():Number{
return (this.transform.n24);
}
public function get z():Number{
return (this.transform.n34);
}
public function roll(_arg1:Number):void{
var _local2:Number3D;
_arg1 = (Papervision3D.useDEGREES) ? (_arg1 * toRADIANS) : _arg1;
_local2 = FORWARD.clone();
if (this._transformDirty){
updateTransform();
};
Matrix3D.rotateAxis(transform, _local2);
_tempMatrix = Matrix3D.rotationMatrix(_local2.x, _local2.y, _local2.z, _arg1, _tempMatrix);
this.transform.calculateMultiply3x3(_tempMatrix, transform);
this._rotationDirty = true;
}
public function yaw(_arg1:Number):void{
var _local2:Number3D;
_arg1 = (Papervision3D.useDEGREES) ? (_arg1 * toRADIANS) : _arg1;
_local2 = UP.clone();
if (this._transformDirty){
updateTransform();
};
Matrix3D.rotateAxis(transform, _local2);
_tempMatrix = Matrix3D.rotationMatrix(_local2.x, _local2.y, _local2.z, _arg1, _tempMatrix);
this.transform.calculateMultiply3x3(_tempMatrix, transform);
this._rotationDirty = true;
}
public function getMaterialByName(_arg1:String):MaterialObject3D{
var _local2:MaterialObject3D;
var _local3:DisplayObject3D;
_local2 = this.materials.getMaterialByName(_arg1);
if (_local2){
return (_local2);
};
for each (_local3 in this._childrenByName) {
_local2 = _local3.getMaterialByName(_arg1);
if (_local2){
return (_local2);
};
};
return (null);
}
public function set useOwnContainer(_arg1:Boolean):void{
_useOwnContainer = _arg1;
setParentContainer(this, true);
}
public function moveLeft(_arg1:Number):void{
translate(_arg1, LEFT);
}
public function get scene():SceneObject3D{
return (_scene);
}
public function set scale(_arg1:Number):void{
if (Papervision3D.usePERCENT){
_arg1 = (_arg1 / 100);
};
this._scaleX = (this._scaleY = (this._scaleZ = _arg1));
this._transformDirty = true;
}
public function get rotationZ():Number{
if (this._rotationDirty){
updateRotation();
};
return ((Papervision3D.useDEGREES) ? (-(this._rotationZ) * toDEGREES) : -(this._rotationZ));
}
public function set scaleY(_arg1:Number):void{
if (Papervision3D.usePERCENT){
this._scaleY = (_arg1 / 100);
} else {
this._scaleY = _arg1;
};
this._transformDirty = true;
}
public function set scaleZ(_arg1:Number):void{
if (Papervision3D.usePERCENT){
this._scaleZ = (_arg1 / 100);
} else {
this._scaleZ = _arg1;
};
this._transformDirty = true;
}
public function get rotationX():Number{
if (this._rotationDirty){
updateRotation();
};
return ((Papervision3D.useDEGREES) ? (-(this._rotationX) * toDEGREES) : -(this._rotationX));
}
public function get rotationY():Number{
if (this._rotationDirty){
updateRotation();
};
return ((Papervision3D.useDEGREES) ? (-(this._rotationY) * toDEGREES) : -(this._rotationY));
}
public function set scaleX(_arg1:Number):void{
if (Papervision3D.usePERCENT){
this._scaleX = (_arg1 / 100);
} else {
this._scaleX = _arg1;
};
this._transformDirty = true;
}
public function translate(_arg1:Number, _arg2:Number3D):void{
var _local3:Number3D;
_local3 = _arg2.clone();
if (this._transformDirty){
updateTransform();
};
Matrix3D.rotateAxis(transform, _local3);
this.x = (this.x + (_arg1 * _local3.x));
this.y = (this.y + (_arg1 * _local3.y));
this.z = (this.z + (_arg1 * _local3.z));
}
public function pitch(_arg1:Number):void{
var _local2:Number3D;
_arg1 = (Papervision3D.useDEGREES) ? (_arg1 * toRADIANS) : _arg1;
_local2 = RIGHT.clone();
if (this._transformDirty){
updateTransform();
};
Matrix3D.rotateAxis(transform, _local2);
_tempMatrix = Matrix3D.rotationMatrix(_local2.x, _local2.y, _local2.z, _arg1, _tempMatrix);
this.transform.calculateMultiply3x3(_tempMatrix, transform);
this._rotationDirty = true;
}
public function moveForward(_arg1:Number):void{
translate(_arg1, FORWARD);
}
protected function updateTransform():void{
var _local1:Matrix3D;
_tempQuat = Matrix3D.euler2quaternion(-(this._rotationY), -(this._rotationZ), this._rotationX, _tempQuat);
_tempMatrix = Matrix3D.quaternion2matrix(_tempQuat.x, _tempQuat.y, _tempQuat.z, _tempQuat.w, _tempMatrix);
_local1 = this.transform;
_tempMatrix.n14 = _local1.n14;
_tempMatrix.n24 = _local1.n24;
_tempMatrix.n34 = _local1.n34;
_local1.copy(_tempMatrix);
_tempMatrix.reset();
_tempMatrix.n11 = this._scaleX;
_tempMatrix.n22 = this._scaleY;
_tempMatrix.n33 = this._scaleZ;
this.transform.calculateMultiply(_local1, _tempMatrix);
this._transformDirty = false;
}
public function addChildrenToLayer(_arg1:DisplayObject3D, _arg2:ViewportLayer):void{
var _local3:DisplayObject3D;
for each (_local3 in _arg1.children) {
_arg2.addDisplayObject3D(_local3);
_local3.addChildrenToLayer(_local3, _arg2);
};
}
public function copyPosition(_arg1):void{
var _local2:Matrix3D;
var _local3:Matrix3D;
_local2 = this.transform;
_local3 = ((_arg1 is DisplayObject3D)) ? _arg1.transform : _arg1;
_local2.n14 = _local3.n14;
_local2.n24 = _local3.n24;
_local2.n34 = _local3.n34;
}
public function get useOwnContainer():Boolean{
return (_useOwnContainer);
}
public function createViewportLayer(_arg1:Viewport3D, _arg2:Boolean=true):ViewportLayer{
var _local3:ViewportLayer;
_local3 = _arg1.getChildLayer(this, true);
if (_arg2){
addChildrenToLayer(this, _local3);
};
return (_local3);
}
public function hitTestPoint(_arg1:Number, _arg2:Number, _arg3:Number):Boolean{
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
_local4 = (this.x - _arg1);
_local5 = (this.y - _arg2);
_local6 = (this.z - _arg3);
_local7 = (((_local4 * _local4) + (_local5 * _local5)) + (_local6 * _local6));
_local8 = (this.geometry) ? this.geometry.boundingSphere.maxDistance : 0;
return ((_local8 > _local7));
}
public function moveRight(_arg1:Number):void{
translate(_arg1, RIGHT);
}
public function moveBackward(_arg1:Number):void{
translate(_arg1, BACKWARD);
}
public function set x(_arg1:Number):void{
this.transform.n14 = _arg1;
}
public function materialsList():String{
var _local1:String;
var _local2:String;
var _local3:DisplayObject3D;
_local1 = "";
for (_local2 in this.materials) {
_local1 = (_local1 + (_local2 + "\n"));
};
for each (_local3 in this._childrenByName) {
for (_local2 in _local3.materials.materialsByName) {
_local1 = (_local1 + (("+ " + _local2) + "\n"));
};
};
return (_local1);
}
public function set y(_arg1:Number):void{
this.transform.n24 = _arg1;
}
override public function addChild(_arg1:DisplayObject3D, _arg2:String=null):DisplayObject3D{
_arg1 = super.addChild(_arg1, _arg2);
if (_arg1.scene == null){
_arg1.scene = scene;
};
if (this.useOwnContainer){
_arg1.parentContainer = this;
};
return (_arg1);
}
public static function get ZERO():DisplayObject3D{
return (new (DisplayObject3D));
}
}
}//package org.papervision3d.objects
Section 99
//BasicRenderEngine (org.papervision3d.render.BasicRenderEngine)
package org.papervision3d.render {
import org.papervision3d.core.render.data.*;
import flash.geom.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.view.*;
import org.papervision3d.core.render.command.*;
import org.papervision3d.core.render.material.*;
import org.papervision3d.view.layer.*;
import org.papervision3d.core.render.*;
import org.papervision3d.core.render.filter.*;
import org.papervision3d.core.render.sort.*;
import org.papervision3d.core.render.project.*;
import org.papervision3d.events.*;
import org.papervision3d.core.utils.*;
public class BasicRenderEngine extends AbstractRenderEngine implements IRenderEngine {
public var sorter:IRenderSorter;
public var projectionPipeline:ProjectionPipeline;
protected var renderStatistics:RenderStatistics;
protected var renderDoneEvent:RendererEvent;
protected var renderList:Array;
protected var projectionDoneEvent:RendererEvent;
protected var renderSessionData:RenderSessionData;
protected var stopWatch:StopWatch;
public var filter:IRenderFilter;
protected var cleanRHD:RenderHitData;
public function BasicRenderEngine():void{
cleanRHD = new RenderHitData();
super();
init();
}
override public function removeFromRenderList(_arg1:IRenderListItem):int{
return (renderList.splice(renderList.indexOf(_arg1), 1));
}
protected function doRender(_arg1:RenderSessionData, _arg2:Array=null):RenderStatistics{
var _local3:RenderableListItem;
var _local4:Viewport3D;
var _local5:ViewportLayer;
stopWatch.reset();
stopWatch.start();
MaterialManager.getInstance().updateMaterialsBeforeRender(_arg1);
filter.filter(renderList);
sorter.sort(renderList);
_local4 = _arg1.viewPort;
while ((_local3 = renderList.pop())) {
_local5 = _local4.accessLayerFor(_local3, true);
_local3.render(_arg1, _local5.graphicsChannel);
_local4.lastRenderList.push(_local3);
_local5.processRenderItem(_local3);
};
MaterialManager.getInstance().updateMaterialsAfterRender(_arg1);
_arg1.renderStatistics.renderTime = stopWatch.stop();
_arg1.viewPort.updateAfterRender(_arg1);
return (renderStatistics);
}
protected function init():void{
renderStatistics = new RenderStatistics();
projectionPipeline = new BasicProjectionPipeline();
stopWatch = new StopWatch();
sorter = new BasicRenderSorter();
filter = new BasicRenderFilter();
renderList = new Array();
renderSessionData = new RenderSessionData();
renderSessionData.renderer = this;
projectionDoneEvent = new RendererEvent(RendererEvent.PROJECTION_DONE, renderSessionData);
renderDoneEvent = new RendererEvent(RendererEvent.RENDER_DONE, renderSessionData);
}
override public function renderScene(_arg1:SceneObject3D, _arg2:CameraObject3D, _arg3:Viewport3D, _arg4:Boolean=true):RenderStatistics{
renderSessionData.scene = _arg1;
renderSessionData.camera = _arg2;
renderSessionData.viewPort = _arg3;
renderSessionData.container = _arg3.containerSprite;
renderSessionData.triangleCuller = _arg3.triangleCuller;
renderSessionData.particleCuller = _arg3.particleCuller;
renderSessionData.renderObjects = _arg1.objects;
renderSessionData.renderLayers = null;
renderSessionData.renderStatistics.clear();
_arg3.updateBeforeRender(renderSessionData);
projectionPipeline.project(renderSessionData);
if (hasEventListener(RendererEvent.PROJECTION_DONE)){
dispatchEvent(projectionDoneEvent);
};
doRender(renderSessionData, null);
if (hasEventListener(RendererEvent.RENDER_DONE)){
dispatchEvent(renderDoneEvent);
};
return (renderSessionData.renderStatistics);
}
public function hitTestPoint2D(_arg1:Point, _arg2:Viewport3D):RenderHitData{
return (_arg2.hitTestPoint2D(_arg1));
}
override public function addToRenderList(_arg1:IRenderListItem):int{
return (renderList.push(_arg1));
}
public function renderLayers(_arg1:SceneObject3D, _arg2:CameraObject3D, _arg3:Viewport3D, _arg4:Array=null, _arg5:Boolean=true):RenderStatistics{
renderSessionData.scene = _arg1;
renderSessionData.camera = _arg2;
renderSessionData.viewPort = _arg3;
renderSessionData.container = _arg3.containerSprite;
renderSessionData.triangleCuller = _arg3.triangleCuller;
renderSessionData.particleCuller = _arg3.particleCuller;
renderSessionData.renderObjects = getLayerObjects(_arg4);
renderSessionData.renderLayers = _arg4;
renderSessionData.renderStatistics.clear();
_arg3.updateBeforeRender(renderSessionData);
projectionPipeline.project(renderSessionData);
if (hasEventListener(RendererEvent.PROJECTION_DONE)){
dispatchEvent(projectionDoneEvent);
};
doRender(renderSessionData);
if (hasEventListener(RendererEvent.RENDER_DONE)){
dispatchEvent(renderDoneEvent);
};
return (renderSessionData.renderStatistics);
}
private function getLayerObjects(_arg1:Array):Array{
var _local2:Array;
var _local3:ViewportLayer;
_local2 = new Array();
for each (_local3 in _arg1) {
_local2 = _local2.concat(_local3.getLayerObjects());
};
return (_local2);
}
public function destroy():void{
renderDoneEvent = null;
projectionDoneEvent = null;
projectionPipeline = null;
sorter = null;
filter = null;
renderStatistics = null;
renderList = null;
renderSessionData.destroy();
renderSessionData = null;
cleanRHD = null;
stopWatch = null;
}
}
}//package org.papervision3d.render
Section 100
//Scene3D (org.papervision3d.scenes.Scene3D)
package org.papervision3d.scenes {
import org.papervision3d.core.proto.*;
public class Scene3D extends SceneObject3D {
}
}//package org.papervision3d.scenes
Section 101
//ViewportLayerSortMode (org.papervision3d.view.layer.util.ViewportLayerSortMode)
package org.papervision3d.view.layer.util {
public class ViewportLayerSortMode {
public static var Z_SORT:String = "z";
public static var INDEX_SORT:String = "index";
}
}//package org.papervision3d.view.layer.util
Section 102
//ViewportBaseLayer (org.papervision3d.view.layer.ViewportBaseLayer)
package org.papervision3d.view.layer {
import org.papervision3d.view.*;
import org.papervision3d.objects.*;
public class ViewportBaseLayer extends ViewportLayer {
public function ViewportBaseLayer(_arg1:Viewport3D){
super(_arg1, null);
}
override public function updateBeforeRender():void{
var _local1:int;
clear();
_local1 = (childLayers.length - 1);
while (_local1 >= 0) {
if (childLayers[_local1].dynamicLayer){
removeLayerAt(_local1);
};
_local1--;
};
super.updateBeforeRender();
}
override public function getChildLayer(_arg1:DisplayObject3D, _arg2:Boolean=true, _arg3:Boolean=false):ViewportLayer{
var _local4:Number;
var _local5:ViewportLayer;
var _local6:ViewportLayer;
_local4 = childLayerIndex(_arg1);
if (_local4 > -1){
return (childLayers[_local4]);
};
for each (_local5 in childLayers) {
_local6 = _local5.getChildLayer(_arg1, false);
if (_local6){
return (_local6);
};
};
if (((_arg2) || (_arg1.useOwnContainer))){
return (getChildLayerFor(_arg1, _arg3));
};
return (this);
}
}
}//package org.papervision3d.view.layer
Section 103
//ViewportLayer (org.papervision3d.view.layer.ViewportLayer)
package org.papervision3d.view.layer {
import flash.display.*;
import org.papervision3d.view.*;
import org.papervision3d.core.render.command.*;
import org.papervision3d.objects.*;
import flash.utils.*;
import org.papervision3d.view.layer.util.*;
public class ViewportLayer extends Sprite {
public var layerIndex:Number;
public var dynamicLayer:Boolean;// = false
public var sortMode:String;
public var weight:Number;// = 0
public var childLayers:Array;
public var forceDepth:Boolean;// = false
protected var viewport:Viewport3D;
public var screenDepth:Number;// = 0
public var displayObject3D:DisplayObject3D;
public var displayObjects:Dictionary;
public var graphicsChannel:Graphics;
public function ViewportLayer(_arg1:Viewport3D, _arg2:DisplayObject3D, _arg3:Boolean=false){
displayObjects = new Dictionary(true);
forceDepth = false;
screenDepth = 0;
weight = 0;
sortMode = ViewportLayerSortMode.Z_SORT;
dynamicLayer = false;
super();
this.viewport = _arg1;
this.displayObject3D = _arg2;
this.dynamicLayer = _arg3;
this.graphicsChannel = this.graphics;
if (_arg3){
this.filters = _arg2.filters;
this.blendMode = _arg2.blendMode;
this.alpha = _arg2.alpha;
};
addDisplayObject3D(_arg2);
init();
}
public function getLayerObjects(_arg1:Array=null):Array{
var _local2:DisplayObject3D;
var _local3:ViewportLayer;
if (!_arg1){
_arg1 = new Array();
};
for each (_local2 in this.displayObjects) {
if (_local2){
_arg1.push(_local2);
};
};
for each (_local3 in childLayers) {
_local3.getLayerObjects(_arg1);
};
return (_arg1);
}
protected function init():void{
childLayers = new Array();
}
public function updateInfo():void{
var _local1:ViewportLayer;
for each (_local1 in childLayers) {
_local1.updateInfo();
if (!forceDepth){
this.weight = (this.weight + _local1.weight);
this.screenDepth = (this.screenDepth + (_local1.screenDepth * _local1.weight));
};
};
if (!forceDepth){
this.screenDepth = (this.screenDepth / this.weight);
};
}
public function sortChildLayers():void{
if (sortMode == ViewportLayerSortMode.Z_SORT){
childLayers.sortOn("screenDepth", (Array.DESCENDING | Array.NUMERIC));
} else {
childLayers.sortOn("layerIndex", Array.NUMERIC);
};
orderLayers();
}
public function removeAllLayers():void{
var _local1:int;
_local1 = (childLayers.length - 1);
while (_local1 >= 0) {
removeLayerAt(_local1);
_local1--;
};
}
public function updateAfterRender():void{
var _local1:ViewportLayer;
for each (_local1 in childLayers) {
_local1.updateAfterRender();
};
}
public function removeLayer(_arg1:ViewportLayer):void{
var _local2:int;
_local2 = getChildIndex(_arg1);
if (_local2 > -1){
childLayers.splice(_local2, 1);
};
}
protected function getChildLayerFor(_arg1:DisplayObject3D, _arg2:Boolean=false):ViewportLayer{
var _local3:ViewportLayer;
if (_arg1){
_local3 = new ViewportLayer(viewport, _arg1, _arg1.useOwnContainer);
childLayers.push(_local3);
addChild(_local3);
if (_arg2){
_arg1.addChildrenToLayer(_arg1, _local3);
};
return (_local3);
//unresolved jump
};
return (null);
}
public function addLayer(_arg1:ViewportLayer):void{
childLayers.push(_arg1);
addChild(_arg1);
}
public function childLayerIndex(_arg1:DisplayObject3D):Number{
var _local2:int;
_arg1 = (_arg1.parentContainer) ? _arg1.parentContainer : _arg1;
_local2 = 0;
while (_local2 < childLayers.length) {
if (childLayers[_local2].hasDisplayObject3D(_arg1)){
return (_local2);
};
_local2++;
};
return (-1);
}
protected function orderLayers():void{
var _local1:int;
_local1 = 0;
while (_local1 < childLayers.length) {
this.setChildIndex(childLayers[_local1], _local1);
childLayers[_local1].sortChildLayers();
_local1++;
};
}
public function removeLayerAt(_arg1:Number):void{
removeChild(childLayers[_arg1]);
childLayers.splice(_arg1, 1);
}
protected function reset():void{
if ((((sortMode == "z")) && (!(forceDepth)))){
screenDepth = 0;
};
this.weight = 0;
}
public function clear():void{
graphicsChannel.clear();
reset();
}
public function updateBeforeRender():void{
var _local1:ViewportLayer;
clear();
for each (_local1 in childLayers) {
_local1.updateBeforeRender();
};
}
public function getChildLayer(_arg1:DisplayObject3D, _arg2:Boolean=true, _arg3:Boolean=false):ViewportLayer{
var _local4:Number;
var _local5:ViewportLayer;
var _local6:ViewportLayer;
_arg1 = (_arg1.parentContainer) ? _arg1.parentContainer : _arg1;
_local4 = childLayerIndex(_arg1);
if (_local4 > -1){
return (childLayers[_local4]);
};
for each (_local5 in childLayers) {
_local6 = _local5.getChildLayer(_arg1, false);
if (_local6){
return (_local6);
};
};
if (_arg2){
return (getChildLayerFor(_arg1, _arg3));
};
return (null);
}
public function processRenderItem(_arg1:RenderableListItem):void{
if (!forceDepth){
this.screenDepth = (this.screenDepth + _arg1.screenDepth);
this.weight++;
};
}
public function removeDisplayObject3D(_arg1:DisplayObject3D):void{
displayObjects[_arg1] = null;
}
public function addDisplayObject3D(_arg1:DisplayObject3D, _arg2:Boolean=true):void{
if (!_arg1){
return;
};
displayObjects[_arg1] = _arg1;
if (_arg2){
_arg1.addChildrenToLayer(_arg1, this);
};
}
public function hasDisplayObject3D(_arg1:DisplayObject3D):Boolean{
return (!((displayObjects[_arg1] == null)));
}
}
}//package org.papervision3d.view.layer
Section 104
//Viewport3D (org.papervision3d.view.Viewport3D)
package org.papervision3d.view {
import org.papervision3d.core.render.data.*;
import flash.display.*;
import flash.geom.*;
import org.papervision3d.core.render.command.*;
import org.papervision3d.objects.*;
import flash.events.*;
import org.papervision3d.view.layer.*;
import org.papervision3d.core.culling.*;
import org.papervision3d.core.view.*;
import org.papervision3d.core.render.*;
import flash.utils.*;
import org.papervision3d.core.utils.*;
public class Viewport3D extends Sprite implements IViewport3D {
protected var _interactive:Boolean;
public var cullingRectangle:Rectangle;
protected var _viewportObjectFilter:ViewportObjectFilter;
protected var _layerInstances:Dictionary;
protected var _hWidth:Number;
protected var _autoScaleToStage:Boolean;
protected var _lastRenderer:IRenderEngine;
protected var _containerSprite:ViewportBaseLayer;
protected var _hHeight:Number;
public var sizeRectangle:Rectangle;
protected var renderHitData:RenderHitData;
protected var _autoClipping:Boolean;
protected var _height:Number;
public var interactiveSceneManager:InteractiveSceneManager;
public var lastRenderList:Array;
public var lineCuller:ILineCuller;
protected var _autoCulling:Boolean;
public var particleCuller:IParticleCuller;
protected var _width:Number;
public var triangleCuller:ITriangleCuller;
public function Viewport3D(_arg1:Number=640, _arg2:Number=480, _arg3:Boolean=false, _arg4:Boolean=false, _arg5:Boolean=true, _arg6:Boolean=true){
init();
this.interactive = _arg4;
this.viewportWidth = _arg1;
this.viewportHeight = _arg2;
this.autoClipping = _arg5;
this.autoCulling = _arg6;
this.autoScaleToStage = _arg3;
this._layerInstances = new Dictionary(true);
}
public function set autoCulling(_arg1:Boolean):void{
if (_arg1){
triangleCuller = new RectangleTriangleCuller(cullingRectangle);
particleCuller = new RectangleParticleCuller(cullingRectangle);
lineCuller = new RectangleLineCuller(cullingRectangle);
} else {
if (!_arg1){
triangleCuller = new DefaultTriangleCuller();
particleCuller = new DefaultParticleCuller();
lineCuller = new DefaultLineCuller();
};
};
_autoCulling = _arg1;
}
protected function onRemovedFromStage(_arg1:Event):void{
stage.removeEventListener(Event.RESIZE, onStageResize);
}
public function hitTestMouse():RenderHitData{
var _local1:Point;
_local1 = new Point(containerSprite.mouseX, containerSprite.mouseY);
return (hitTestPoint2D(_local1));
}
protected function init():void{
this.renderHitData = new RenderHitData();
lastRenderList = new Array();
sizeRectangle = new Rectangle();
cullingRectangle = new Rectangle();
_containerSprite = new ViewportBaseLayer(this);
addChild(_containerSprite);
addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
addEventListener(Event.REMOVED_FROM_STAGE, onRemovedFromStage);
}
protected function onStageResize(_arg1:Event=null):void{
if (_autoScaleToStage){
viewportWidth = stage.stageWidth;
viewportHeight = stage.stageHeight;
};
}
public function set autoClipping(_arg1:Boolean):void{
if (_arg1){
scrollRect = sizeRectangle;
} else {
scrollRect = null;
};
_autoClipping = _arg1;
}
public function updateAfterRender(_arg1:RenderSessionData):void{
var _local2:ViewportLayer;
if (interactive){
interactiveSceneManager.updateRenderHitData();
};
if (_arg1.renderLayers){
for each (_local2 in _arg1.renderLayers) {
_local2.updateInfo();
_local2.sortChildLayers();
_local2.updateAfterRender();
};
} else {
containerSprite.updateInfo();
containerSprite.sortChildLayers();
containerSprite.updateAfterRender();
};
}
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 (_layerInstances[_local3]){
return (_layerInstances[_local3]);
};
_layerInstances[_local3] = containerSprite.getChildLayer(_local3, false, true);
if (_arg2){
_local3.container = _layerInstances[_local3];
};
return (_layerInstances[_local3]);
//unresolved jump
};
return (containerSprite);
}
public function get viewportHeight():Number{
return (_height);
}
public function get autoCulling():Boolean{
return (_autoCulling);
}
public function hitTestPoint2D(_arg1:Point):RenderHitData{
var _local2:RenderableListItem;
var _local3:RenderHitData;
var _local4:IRenderListItem;
var _local5:uint;
renderHitData.clear();
if (interactive){
_local3 = renderHitData;
_local5 = lastRenderList.length;
while ((_local4 = lastRenderList[--_local5])) {
if ((_local4 is RenderableListItem)){
_local2 = (_local4 as RenderableListItem);
_local3 = _local2.hitTestPoint2D(_arg1, _local3);
if (_local3.hasHit){
return (_local3);
};
};
};
};
return (renderHitData);
}
public function updateBeforeRender(_arg1:RenderSessionData):void{
var _local2:ViewportLayer;
lastRenderList.length = 0;
if (_arg1.renderLayers){
for each (_local2 in _arg1.renderLayers) {
_local2.updateBeforeRender();
};
} else {
_containerSprite.updateBeforeRender();
};
_layerInstances = new Dictionary(true);
}
protected function onAddedToStage(_arg1:Event):void{
stage.addEventListener(Event.RESIZE, onStageResize);
onStageResize();
}
public function getChildLayer(_arg1:DisplayObject3D, _arg2:Boolean=true, _arg3:Boolean=true):ViewportLayer{
return (containerSprite.getChildLayer(_arg1, _arg2, _arg3));
}
public function get viewportObjectFilter():ViewportObjectFilter{
return (_viewportObjectFilter);
}
public function get containerSprite():ViewportLayer{
return (_containerSprite);
}
public function set viewportWidth(_arg1:Number):void{
_width = _arg1;
_hWidth = (_arg1 / 2);
containerSprite.x = _hWidth;
cullingRectangle.x = -(_hWidth);
cullingRectangle.width = _arg1;
sizeRectangle.width = _arg1;
if (_autoClipping){
scrollRect = sizeRectangle;
};
}
public function get autoClipping():Boolean{
return (_autoClipping);
}
public function set viewportObjectFilter(_arg1:ViewportObjectFilter):void{
_viewportObjectFilter = _arg1;
}
public function get viewportWidth():Number{
return (_width);
}
public function set autoScaleToStage(_arg1:Boolean):void{
_autoScaleToStage = _arg1;
if (((_arg1) && (!((stage == null))))){
onStageResize();
};
}
public function set interactive(_arg1:Boolean):void{
if (_arg1 != _interactive){
if (((_interactive) && (interactiveSceneManager))){
interactiveSceneManager.destroy();
interactiveSceneManager = null;
};
_interactive = _arg1;
if (_arg1){
interactiveSceneManager = new InteractiveSceneManager(this);
};
};
}
public function set viewportHeight(_arg1:Number):void{
_height = _arg1;
_hHeight = (_arg1 / 2);
containerSprite.y = _hHeight;
cullingRectangle.y = -(_hHeight);
cullingRectangle.height = _arg1;
sizeRectangle.height = _arg1;
if (_autoClipping){
scrollRect = sizeRectangle;
};
}
public function get autoScaleToStage():Boolean{
return (_autoScaleToStage);
}
public function get interactive():Boolean{
return (_interactive);
}
public function destroy():void{
if (interactiveSceneManager){
interactiveSceneManager.destroy();
interactiveSceneManager = null;
};
lastRenderList = null;
}
}
}//package org.papervision3d.view
Section 105
//Papervision3D (org.papervision3d.Papervision3D)
package org.papervision3d {
public class Papervision3D {
public static var useDEGREES:Boolean = true;
public static var VERBOSE:Boolean = true;
public static var AUTHOR:String = "(c) 2006-2007 Copyright by Carlos Ulloa - | John Grden | Ralph Hauwert | Tim Knip | Andy Zupko";
public static var DATE:String = "24.03.08";
public static var NAME:String = "Papervision3D";
public static var VERSION:String = "Public Alpha 2.0 - Great White";
public static var usePERCENT:Boolean = false;
public static function log(_arg1:String):void{
if (Papervision3D.VERBOSE){
};
}
}
}//package org.papervision3d
Section 106
//assetBank (assetBank)
package {
import org.papervision3d.objects.primitives.*;
import org.papervision3d.materials.utils.*;
import org.papervision3d.materials.*;
public class assetBank {
public var mainCharWalkLeftMaterial:MovieAssetMaterial;
public var usedBonuses:int;// = 0
public var mainCharDieMaterial:MovieAssetMaterial;
public var usedCubes:int;// = 0
public var cubeArray:Array;
public var usedEnemies:int;// = 0
public var mainCharStandMaterial:MovieAssetMaterial;
public var enemyArray:Array;
public var bGArray:Array;
public var usedPlanes:int;// = 0
public var door1:door;
public var mainCharJumpMaterial:MovieAssetMaterial;
public var doorPlane:Plane;
public var enemyMaterial:MovieAssetMaterial;
public var mainCharStandLeftMaterial:MovieAssetMaterial;
public var planeArray:Array;
public var mainCharWalkMaterial:MovieAssetMaterial;
public var bonusMaterial:MovieAssetMaterial;
public var mainCharJumpLeftMaterial:MovieAssetMaterial;
public var mainCharPlane:Plane;
public var doorMaterial:MovieMaterial;
public var bonusArray:Array;
public function assetBank(){
var _local1:MovieAssetMaterial;
var _local2:Plane;
var _local3:int;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:mathExt;
var _local11:int;
usedCubes = 0;
usedBonuses = 0;
usedEnemies = 0;
usedPlanes = 0;
super();
bGArray = new Array();
mainCharStandMaterial = new MovieAssetMaterial("standRight", true);
mainCharStandMaterial.animated = true;
mainCharStandMaterial.doubleSided = true;
mainCharStandMaterial.movieTransparent = true;
mainCharStandMaterial.precise = false;
mainCharWalkMaterial = new MovieAssetMaterial("walkRight", true);
mainCharWalkMaterial.animated = true;
mainCharWalkMaterial.doubleSided = true;
mainCharWalkMaterial.movieTransparent = true;
mainCharWalkMaterial.precise = false;
mainCharJumpMaterial = new MovieAssetMaterial("jumpRight", true);
mainCharJumpMaterial.animated = true;
mainCharJumpMaterial.doubleSided = true;
mainCharJumpMaterial.movieTransparent = true;
mainCharJumpMaterial.precise = false;
mainCharDieMaterial = new MovieAssetMaterial("die3D", true);
mainCharDieMaterial.animated = true;
mainCharDieMaterial.doubleSided = true;
mainCharDieMaterial.movieTransparent = true;
mainCharDieMaterial.precise = false;
mainCharWalkLeftMaterial = new MovieAssetMaterial("walkLeft", true);
mainCharWalkLeftMaterial.animated = true;
mainCharWalkLeftMaterial.doubleSided = true;
mainCharWalkLeftMaterial.movieTransparent = true;
mainCharWalkLeftMaterial.precise = false;
mainCharJumpLeftMaterial = new MovieAssetMaterial("jumpLeft", true);
mainCharJumpLeftMaterial.animated = true;
mainCharJumpLeftMaterial.doubleSided = true;
mainCharJumpLeftMaterial.movieTransparent = true;
mainCharJumpLeftMaterial.precise = false;
mainCharStandLeftMaterial = new MovieAssetMaterial("standLeft", true);
mainCharStandLeftMaterial.animated = true;
mainCharStandLeftMaterial.doubleSided = true;
mainCharStandLeftMaterial.movieTransparent = true;
mainCharStandLeftMaterial.precise = false;
enemyMaterial = new MovieAssetMaterial("textureEnemy", true);
enemyMaterial.animated = true;
enemyMaterial.doubleSided = true;
enemyMaterial.movieTransparent = true;
enemyMaterial.precise = false;
bonusMaterial = new MovieAssetMaterial("textureBonus", true);
bonusMaterial.animated = true;
bonusMaterial.doubleSided = true;
bonusMaterial.movieTransparent = true;
bonusMaterial.precise = false;
_local1 = new MovieAssetMaterial("Tree", true);
_local1.tiled = true;
_local1.maxU = 18;
_local1.maxV = 1;
_local9 = 0;
_local10 = new mathExt(10, 10);
_local7 = -80;
_local8 = 90;
_local4 = 10;
_local5 = 100;
_local3 = 3;
_local11 = 0;
while (_local11 < _local3) {
_local2 = new Plane(_local1, 1080, 100, 18, 1);
_local2.y = _local7;
_local2.z = _local8;
_local2.x = _local9;
_local9 = (_local9 + _local10.randRange(-30, 30));
_local7 = (_local7 + _local4);
_local8 = (_local8 + _local5);
bGArray.push(_local2);
_local11++;
};
door1 = new door();
doorMaterial = new MovieMaterial(door1, true);
doorMaterial.animated = true;
doorPlane = new Plane(doorMaterial, 60, 50, 1, 1);
mainCharPlane = new Plane(mainCharStandMaterial, 20, 30, 1, 1);
enemyArray = new Array();
bonusArray = new Array();
}
public function getPlane():Plane{
var _local1:Plane;
if (usedPlanes < planeArray.length){
usedPlanes++;
return (planeArray[(usedPlanes - 1)]);
};
_local1 = new Plane(mainCharStandMaterial, 20, 30, 1, 1);
planeArray.push(_local1);
usedPlanes++;
return (_local1);
}
public function getCube():Cube{
var _local1:Cube;
if (usedCubes < cubeArray.length){
usedCubes++;
return (cubeArray[(usedCubes - 1)]);
};
_local1 = new Cube(new MaterialsList(), 20, 20, 20, 1, 1, 1);
cubeArray.push(_local1);
usedCubes++;
return (_local1);
}
public function getEnemy():Plane{
var _local1:Plane;
if (usedEnemies < enemyArray.length){
usedEnemies++;
return (enemyArray[(usedEnemies - 1)]);
};
_local1 = new Plane(enemyMaterial, 20, 20, 1, 1);
enemyArray.push(_local1);
usedEnemies++;
return (_local1);
}
public function reset(){
usedCubes = 0;
usedBonuses = 0;
usedEnemies = 0;
usedPlanes = 0;
doorMaterial.animated = false;
door1 = new door();
doorMaterial = new MovieMaterial(door1, true);
doorMaterial.animated = true;
doorPlane = new Plane(doorMaterial, 60, 50, 1, 1);
}
public function shutdown(){
}
public function getBonus():Plane{
var _local1:Plane;
if (usedBonuses < bonusArray.length){
usedBonuses++;
return (bonusArray[(usedBonuses - 1)]);
};
_local1 = new Plane(bonusMaterial, 20, 20, 1, 1);
bonusArray.push(_local1);
usedBonuses++;
return (_local1);
}
}
}//package
Section 107
//betweenLevelScreen (betweenLevelScreen)
package {
import flash.display.*;
public class betweenLevelScreen extends MovieClip {
}
}//package
Section 108
//betweenLevelScreenStartButton (betweenLevelScreenStartButton)
package {
import flash.display.*;
public dynamic class betweenLevelScreenStartButton extends MovieClip {
}
}//package
Section 109
//blankTexture (blankTexture)
package {
import flash.display.*;
public dynamic class blankTexture extends MovieClip {
}
}//package
Section 110
//block1 (block1)
package {
import flash.display.*;
public class block1 extends MovieClip {
}
}//package
Section 111
//block2 (block2)
package {
import flash.display.*;
public dynamic class block2 extends MovieClip {
}
}//package
Section 112
//bonus (bonus)
package {
import flash.display.*;
public class bonus extends MovieClip {
var active:Boolean;// = true
var scoreToDisplay:int;// = 0
var deathPending:Boolean;// = false
public function bonus(){
deathPending = false;
scoreToDisplay = 0;
active = true;
super();
}
public function getScore(){
return (scoreToDisplay);
}
public function getActive():Boolean{
return (active);
}
public function die(_arg1:int){
deathPending = true;
scoreToDisplay = _arg1;
}
public function update():Boolean{
return (deathPending);
}
public function sleep(){
active = false;
}
}
}//package
Section 113
//bonusText (bonusText)
package {
import flash.display.*;
import flash.text.*;
public class bonusText extends MovieClip {
var startX:int;
var startY:int;
var dead:Boolean;// = false
public var scoreText:TextField;
public function bonusText(_arg1:Number, _arg2:Number){
dead = false;
super();
x = _arg1;
y = _arg2;
startX = _arg1;
startY = _arg2;
}
public function die(){
this.parent.removeChild(this);
dead = true;
}
public function update(_arg1:Number){
if (!dead){
y = (y - (1 * _arg1));
if (y < (startY - 60)){
this.die();
};
};
}
}
}//package
Section 114
//charDying (charDying)
package {
import flash.display.*;
public dynamic class charDying extends MovieClip {
}
}//package
Section 115
//charWalkTest (charWalkTest)
package {
import flash.display.*;
public dynamic class charWalkTest extends MovieClip {
}
}//package
Section 116
//cloudTexture (cloudTexture)
package {
import flash.display.*;
public dynamic class cloudTexture extends MovieClip {
}
}//package
Section 117
//coinSound (coinSound)
package {
import flash.media.*;
public dynamic class coinSound extends Sound {
}
}//package
Section 118
//conveyorTop (conveyorTop)
package {
import flash.display.*;
public dynamic class conveyorTop extends MovieClip {
}
}//package
Section 119
//conveyorTopTexture (conveyorTopTexture)
package {
import flash.display.*;
public dynamic class conveyorTopTexture extends MovieClip {
}
}//package
Section 120
//conveyorTopTextureRight (conveyorTopTextureRight)
package {
import flash.display.*;
public dynamic class conveyorTopTextureRight extends MovieClip {
}
}//package
Section 121
//crumbleBlock (crumbleBlock)
package {
import flash.display.*;
public class crumbleBlock extends MovieClip {
var health:Number;
var cBHeight:Number;
var cBWidth:Number;
var mapIndex:int;
var maxHealth:Number;
public function crumbleBlock(_arg1:Number, _arg2:int, _arg3:Number, _arg4:Number){
health = _arg1;
maxHealth = _arg1;
mapIndex = _arg2;
cBWidth = _arg3;
cBHeight = _arg4;
}
public function update(_arg1:mainChar, _arg2:Array, _arg3:Number){
if (health > 0){
if ((((_arg1.x >= this.x)) && ((_arg1.x <= (this.x + cBWidth))))){
if ((((_arg1.y >= (this.y - _arg1.getHeight()))) && ((_arg1.y <= this.y)))){
health = (health - _arg3);
if (health <= 0){
health = 0;
_arg2[mapIndex] = 0;
};
};
};
};
this.alpha = (health / maxHealth);
}
}
}//package
Section 122
//DarkGreyCloud (DarkGreyCloud)
package {
import flash.display.*;
public dynamic class DarkGreyCloud extends MovieClip {
}
}//package
Section 123
//die3D (die3D)
package {
import flash.display.*;
public dynamic class die3D extends MovieClip {
}
}//package
Section 124
//dieSound (dieSound)
package {
import flash.media.*;
public dynamic class dieSound extends Sound {
}
}//package
Section 125
//docClass (docClass)
package {
import org.papervision3d.objects.primitives.*;
import flash.display.*;
import org.papervision3d.view.*;
import flash.events.*;
import org.papervision3d.cameras.*;
import org.papervision3d.scenes.*;
import org.papervision3d.render.*;
import org.papervision3d.materials.*;
public dynamic class docClass extends MovieClip {
var gameOver1:gameOverSound;
private var camera:Camera3D;
var level1:level;
private var cube:Cube;
var levelComplete1:levelCompleteSound;
var gameGrid:Array;
private var wireframeMaterial:WireframeMaterial;
var gameOverScreen1:gameOverScreen;
private var assetBank1:assetBank;
var numLevels:int;// = 4
var score:int;// = 0
private var viewport:Viewport3D;
var gameCompleteScreen1:gameCompleteScreen;
var gameComplete1:gameCompleteSound;
private var scene:Scene3D;
private var renderer:BasicRenderEngine;
var titleScreen1:titleScreen;
var levelNumber:int;
public function docClass(){
numLevels = 4;
score = 0;
gameOver1 = new gameOverSound();
gameComplete1 = new gameCompleteSound();
levelComplete1 = new levelCompleteSound();
super();
assetBank1 = new assetBank();
viewport = new Viewport3D(640, 360, false, true);
scene = new Scene3D();
camera = new Camera3D();
renderer = new BasicRenderEngine();
titleScreen1 = new titleScreen();
this.addChild(titleScreen1);
titleScreen1.start.addEventListener(MouseEvent.CLICK, startGame);
gameOverScreen1 = new gameOverScreen();
gameCompleteScreen1 = new gameCompleteScreen();
gameCompleteScreen1.restart.addEventListener(MouseEvent.CLICK, gCReset);
gameOverScreen1.restart.addEventListener(MouseEvent.CLICK, gOReset);
}
function setupLevel(){
gameGrid = new Array();
switch (levelNumber){
case 0:
gameGrid.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1);
gameGrid.push(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
gameGrid.push(1, 0, 0, 0, 0, 56, 0, 0, 0, 0, 56, 0, 0, 0, 0, 56, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
gameGrid.push(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 57, 0, 0, 0, 1);
gameGrid.push(1, 0, 43, 3, 0, 0, 0, 0, 0, 0, 0, 43, 3, 0, 0, 0, 0, 0, 0, 43, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
gameGrid.push(1, 0, 0, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1);
gameGrid.push(1, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
gameGrid.push(1, 0, 0, 2, 2, 56, 0, 0, 0, 0, 0, 0, 0, 56, 0, 0, 0, 0, 0, 0, 0, 0, 56, 0, 0, 0, 0, 0, 0, 0, 0, 1);
gameGrid.push(1, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
gameGrid.push(1, 0, 0, 2, 2, 0, 43, 3, 0, 0, 0, 0, 0, 0, 43, 3, 0, 0, 0, 0, 0, 0, 43, 3, 0, 0, 0, 0, 0, 43, 0, 1);
gameGrid.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 0, 0, 1);
gameGrid.push(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 1);
gameGrid.push(1, 0, 0, 0, 0, 56, 0, 56, 0, 0, 0, 0, 0, 0, 56, 0, 0, 0, 0, 56, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 1);
gameGrid.push(1, 0, 58, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 1);
gameGrid.push(1, 0, 0, 0, 0, 0, 0, 0, 43, 3, 0, 0, 0, 0, 0, 0, 43, 3, 0, 0, 0, 0, 0, 0, 43, 0, 0, 2, 2, 0, 0, 1);
gameGrid.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1);
break;
case 1:
gameGrid.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1);
gameGrid.push(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
gameGrid.push(1, 0, 0, 0, 0, 56, 0, 0, 0, 0, 56, 0, 0, 0, 0, 56, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
gameGrid.push(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 57, 0, 0, 0, 1);
gameGrid.push(1, 0, 43, 3, 0, 0, 0, 0, 0, 0, 0, 43, 3, 0, 0, 0, 0, 0, 0, 43, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
gameGrid.push(1, 0, 0, 2, 2, 1, 1, 1, 1, 1, 1, 0, 0, 53, 54, 54, 55, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1);
gameGrid.push(1, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
gameGrid.push(1, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 56, 0, 0, 0, 0, 0, 0, 0, 0, 56, 0, 0, 0, 0, 0, 0, 0, 0, 1);
gameGrid.push(1, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
gameGrid.push(1, 0, 0, 2, 2, 0, 43, 3, 0, 0, 0, 0, 0, 0, 43, 3, 0, 0, 0, 0, 0, 0, 43, 3, 0, 0, 0, 0, 0, 43, 0, 1);
gameGrid.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 50, 51, 51, 51, 51, 51, 52, 0, 0, 1, 1, 1, 1, 2, 2, 0, 0, 1);
gameGrid.push(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, 2, 2, 0, 0, 1);
gameGrid.push(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 56, 0, 0, 0, 0, 56, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 1);
gameGrid.push(1, 0, 58, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 1);
gameGrid.push(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 1);
gameGrid.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1);
break;
case 2:
gameGrid.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1);
gameGrid.push(1, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 1);
gameGrid.push(1, 0, 58, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
gameGrid.push(1, 0, 0, 0, 43, 3, 0, 0, 0, 0, 43, 3, 0, 0, 0, 0, 43, 3, 0, 0, 0, 0, 43, 0, 0, 0, 0, 0, 0, 0, 0, 1);
gameGrid.push(1, 1, 1, 1, 1, 1, 0, 56, 0, 1, 1, 1, 0, 56, 0, 1, 1, 1, 0, 56, 0, 1, 2, 2, 0, 0, 0, 1, 1, 0, 0, 1);
gameGrid.push(1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 13, 1, 1, 0, 1, 1, 13, 1, 1, 0, 1, 1, 2, 2, 0, 0, 0, 0, 1, 0, 0, 1);
gameGrid.push(1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 56, 0, 1, 1, 1, 0, 56, 0, 1, 1, 1, 0, 2, 2, 0, 0, 0, 0, 1, 0, 0, 1);
gameGrid.push(1, 0, 0, 0, 0, 0, 0, 23, 0, 0, 33, 0, 0, 23, 0, 0, 33, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 1, 0, 0, 1);
gameGrid.push(1, 0, 0, 56, 1, 0, 0, 56, 0, 0, 1, 0, 0, 56, 0, 0, 1, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 57, 0, 1);
gameGrid.push(1, 0, 0, 0, 1, 1, 0, 33, 0, 1, 1, 1, 0, 33, 0, 1, 1, 1, 0, 0, 0, 0, 2, 2, 0, 43, 3, 0, 0, 0, 0, 1);
gameGrid.push(1, 0, 0, 0, 5, 1, 50, 51, 52, 1, 5, 1, 50, 51, 52, 1, 5, 1, 1, 1, 0, 0, 2, 2, 0, 0, 50, 51, 51, 51, 52, 1);
gameGrid.push(1, 56, 0, 0, 0, 5, 5, 5, 5, 5, 56, 5, 5, 5, 5, 5, 56, 5, 5, 1, 1, 1, 2, 2, 0, 0, 13, 0, 13, 0, 0, 1);
gameGrid.push(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 5, 2, 2, 0, 0, 0, 0, 0, 0, 56, 1);
gameGrid.push(1, 0, 0, 43, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 43, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 1);
gameGrid.push(1, 0, 0, 0, 1, 3, 0, 56, 0, 0, 1, 3, 0, 56, 0, 0, 1, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 1);
gameGrid.push(1, 1, 1, 1, 1, 53, 54, 54, 54, 55, 1, 53, 54, 54, 54, 55, 1, 53, 54, 54, 54, 55, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1);
break;
case 3:
gameGrid.push(1, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 1);
gameGrid.push(6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7);
gameGrid.push(6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7);
gameGrid.push(6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7);
gameGrid.push(6, 0, 0, 56, 0, 56, 0, 0, 0, 56, 0, 0, 0, 56, 0, 0, 0, 56, 0, 0, 0, 56, 0, 0, 0, 56, 0, 56, 0, 57, 0, 7);
gameGrid.push(6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7);
gameGrid.push(6, 2, 3, 0, 0, 1, 3, 0, 0, 1, 3, 0, 0, 1, 3, 0, 0, 1, 3, 0, 0, 1, 3, 0, 0, 1, 3, 0, 0, 1, 1, 7);
gameGrid.push(6, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7);
gameGrid.push(6, 2, 0, 0, 0, 56, 0, 56, 0, 0, 0, 56, 0, 0, 0, 56, 0, 0, 0, 56, 0, 0, 0, 56, 0, 56, 0, 0, 0, 0, 0, 7);
gameGrid.push(6, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7);
gameGrid.push(6, 2, 1, 1, 3, 0, 0, 1, 3, 0, 0, 1, 3, 0, 0, 1, 3, 0, 0, 1, 3, 0, 0, 1, 3, 0, 0, 1, 1, 1, 2, 7);
gameGrid.push(6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 7);
gameGrid.push(6, 58, 0, 56, 0, 56, 0, 0, 0, 56, 0, 0, 0, 56, 0, 0, 0, 56, 0, 0, 0, 56, 0, 0, 0, 56, 0, 56, 0, 0, 2, 7);
gameGrid.push(6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 7);
gameGrid.push(6, 1, 3, 0, 0, 1, 3, 0, 0, 1, 3, 0, 0, 1, 3, 0, 0, 1, 3, 0, 0, 1, 3, 0, 0, 1, 3, 0, 0, 1, 2, 7);
gameGrid.push(1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1);
break;
case 5:
gameGrid.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1);
gameGrid.push(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
gameGrid.push(1, 0, 0, 0, 0, 56, 0, 0, 0, 0, 56, 0, 0, 0, 0, 56, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
gameGrid.push(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 57, 0, 0, 0, 1);
gameGrid.push(1, 0, 43, 3, 0, 0, 0, 0, 0, 0, 0, 43, 3, 0, 0, 0, 0, 0, 0, 43, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
gameGrid.push(1, 0, 0, 2, 2, 1, 1, 1, 1, 1, 1, 0, 0, 53, 54, 54, 55, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1);
gameGrid.push(1, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
gameGrid.push(1, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 56, 0, 0, 0, 0, 0, 0, 0, 0, 56, 0, 0, 0, 0, 0, 0, 0, 0, 1);
gameGrid.push(1, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
gameGrid.push(1, 0, 0, 2, 2, 0, 43, 3, 0, 0, 0, 0, 0, 0, 43, 3, 0, 0, 0, 0, 0, 0, 43, 3, 0, 0, 0, 0, 0, 43, 0, 1);
gameGrid.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 0, 0, 50, 51, 51, 51, 51, 51, 52, 0, 0, 1, 1, 1, 1, 2, 2, 0, 0, 1);
gameGrid.push(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, 2, 2, 0, 0, 1);
gameGrid.push(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 56, 0, 0, 0, 0, 56, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 1);
gameGrid.push(1, 0, 58, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 1);
gameGrid.push(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 1);
gameGrid.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 4, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1);
break;
case 6:
gameGrid.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1);
gameGrid.push(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
gameGrid.push(1, 0, 0, 0, 0, 56, 0, 0, 0, 0, 56, 0, 0, 0, 0, 56, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
gameGrid.push(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 57, 0, 0, 0, 1);
gameGrid.push(1, 0, 43, 3, 0, 0, 0, 0, 0, 0, 0, 43, 3, 0, 0, 0, 0, 0, 0, 43, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
gameGrid.push(1, 0, 0, 2, 2, 1, 1, 1, 1, 1, 1, 0, 0, 53, 54, 54, 55, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1);
gameGrid.push(1, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
gameGrid.push(1, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 56, 0, 0, 0, 0, 0, 0, 0, 0, 56, 0, 0, 0, 0, 0, 0, 0, 0, 1);
gameGrid.push(1, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
gameGrid.push(1, 0, 0, 2, 2, 0, 43, 3, 0, 0, 0, 0, 0, 0, 43, 3, 0, 0, 0, 0, 0, 0, 43, 3, 0, 0, 0, 0, 0, 43, 0, 1);
gameGrid.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 0, 0, 50, 51, 51, 51, 51, 51, 52, 0, 0, 1, 1, 1, 1, 2, 2, 0, 0, 1);
gameGrid.push(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, 2, 2, 0, 0, 1);
gameGrid.push(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 56, 0, 0, 0, 0, 56, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 1);
gameGrid.push(1, 0, 58, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 1);
gameGrid.push(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 1);
gameGrid.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 4, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1);
break;
case 7:
gameGrid.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1);
gameGrid.push(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
gameGrid.push(1, 0, 0, 0, 0, 56, 0, 0, 0, 0, 56, 0, 0, 0, 0, 56, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
gameGrid.push(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 57, 0, 0, 0, 1);
gameGrid.push(1, 0, 43, 3, 0, 0, 0, 0, 0, 0, 0, 43, 3, 0, 0, 0, 0, 0, 0, 43, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
gameGrid.push(1, 0, 0, 2, 2, 1, 1, 1, 1, 1, 1, 0, 0, 53, 54, 54, 55, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1);
gameGrid.push(1, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
gameGrid.push(1, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 56, 0, 0, 0, 0, 0, 0, 0, 0, 56, 0, 0, 0, 0, 0, 0, 0, 0, 1);
gameGrid.push(1, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
gameGrid.push(1, 0, 0, 2, 2, 0, 43, 3, 0, 0, 0, 0, 0, 0, 43, 3, 0, 0, 0, 0, 0, 0, 43, 3, 0, 0, 0, 0, 0, 43, 0, 1);
gameGrid.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 0, 0, 50, 51, 51, 51, 51, 51, 52, 0, 0, 1, 1, 1, 1, 2, 2, 0, 0, 1);
gameGrid.push(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, 2, 2, 0, 0, 1);
gameGrid.push(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 56, 0, 0, 0, 0, 56, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 1);
gameGrid.push(1, 0, 58, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 1);
gameGrid.push(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 1);
gameGrid.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 4, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1);
break;
case 8:
gameGrid.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1);
gameGrid.push(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
gameGrid.push(1, 0, 0, 0, 0, 56, 0, 0, 0, 0, 56, 0, 0, 0, 0, 56, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
gameGrid.push(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 57, 0, 0, 0, 1);
gameGrid.push(1, 0, 43, 3, 0, 0, 0, 0, 0, 0, 0, 43, 3, 0, 0, 0, 0, 0, 0, 43, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
gameGrid.push(1, 0, 0, 2, 2, 1, 1, 1, 1, 1, 1, 0, 0, 53, 54, 54, 55, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1);
gameGrid.push(1, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
gameGrid.push(1, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 56, 0, 0, 0, 0, 0, 0, 0, 0, 56, 0, 0, 0, 0, 0, 0, 0, 0, 1);
gameGrid.push(1, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
gameGrid.push(1, 0, 0, 2, 2, 0, 43, 3, 0, 0, 0, 0, 0, 0, 43, 3, 0, 0, 0, 0, 0, 0, 43, 3, 0, 0, 0, 0, 0, 43, 0, 1);
gameGrid.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 0, 0, 50, 51, 51, 51, 51, 51, 52, 0, 0, 1, 1, 1, 1, 2, 2, 0, 0, 1);
gameGrid.push(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, 2, 2, 0, 0, 1);
gameGrid.push(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 56, 0, 0, 0, 0, 56, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 1);
gameGrid.push(1, 0, 58, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 1);
gameGrid.push(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 1);
gameGrid.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 4, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1);
break;
case 9:
gameGrid.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1);
gameGrid.push(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
gameGrid.push(1, 0, 0, 0, 0, 56, 0, 0, 0, 0, 56, 0, 0, 0, 0, 56, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
gameGrid.push(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 57, 0, 0, 0, 1);
gameGrid.push(1, 0, 43, 3, 0, 0, 0, 0, 0, 0, 0, 43, 3, 0, 0, 0, 0, 0, 0, 43, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
gameGrid.push(1, 0, 0, 2, 2, 1, 1, 1, 1, 1, 1, 0, 0, 53, 54, 54, 55, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1);
gameGrid.push(1, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
gameGrid.push(1, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 56, 0, 0, 0, 0, 0, 0, 0, 0, 56, 0, 0, 0, 0, 0, 0, 0, 0, 1);
gameGrid.push(1, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
gameGrid.push(1, 0, 0, 2, 2, 0, 43, 3, 0, 0, 0, 0, 0, 0, 43, 3, 0, 0, 0, 0, 0, 0, 43, 3, 0, 0, 0, 0, 0, 43, 0, 1);
gameGrid.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 0, 0, 50, 51, 51, 51, 51, 51, 52, 0, 0, 1, 1, 1, 1, 2, 2, 0, 0, 1);
gameGrid.push(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, 2, 2, 0, 0, 1);
gameGrid.push(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 56, 0, 0, 0, 0, 56, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 1);
gameGrid.push(1, 0, 58, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 1);
gameGrid.push(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 1);
gameGrid.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 4, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1);
break;
default:
break;
};
}
function handleKeyUp(_arg1:KeyboardEvent):void{
level1.handleKeyUp(_arg1);
}
public function gCReset(_arg1:MouseEvent){
this.removeChild(gameCompleteScreen1);
reset();
}
public function gameComplete(){
stage.removeEventListener(KeyboardEvent.KEY_DOWN, handleKeyDown);
stage.removeEventListener(KeyboardEvent.KEY_UP, handleKeyUp);
stage.removeEventListener(Event.ENTER_FRAME, update);
gameComplete1.play();
gameCompleteScreen1.scoreText.text = String(score);
this.addChild(gameCompleteScreen1);
}
public function gOReset(_arg1:MouseEvent){
this.removeChild(gameOverScreen1);
reset();
}
public function startGame(_arg1:MouseEvent){
this.removeChild(titleScreen1);
levelNumber = 0;
setupLevel();
assetBank1.reset();
level1 = new level(gameGrid, 1200, viewport, camera, scene, renderer, assetBank1);
addChild(level1);
stage.addEventListener(KeyboardEvent.KEY_DOWN, handleKeyDown);
stage.addEventListener(KeyboardEvent.KEY_UP, handleKeyUp);
stage.addEventListener(Event.ENTER_FRAME, update);
}
public function reset(){
score = 0;
this.addChild(titleScreen1);
}
function handleKeyDown(_arg1:KeyboardEvent):void{
level1.handleKeyDown(_arg1);
}
function update(_arg1:Event){
level1.update(_arg1);
if (level1.timeRemaining <= 0){
score = level1.score;
removeChild(level1);
level1.destroy();
level1 = null;
gameOver();
} else {
if (level1.isComplete()){
score = level1.score;
removeChild(level1);
level1.destroy();
level1 = null;
levelNumber++;
if (levelNumber < numLevels){
levelComplete1.play();
setupLevel();
assetBank1.reset();
level1 = new level(gameGrid, 1200, viewport, camera, scene, renderer, assetBank1);
level1.score = score;
addChild(level1);
} else {
gameComplete();
};
};
};
}
public function gameOver(){
stage.removeEventListener(KeyboardEvent.KEY_DOWN, handleKeyDown);
stage.removeEventListener(KeyboardEvent.KEY_UP, handleKeyUp);
stage.removeEventListener(Event.ENTER_FRAME, update);
gameOver1.play();
gameOverScreen1.scoreText.text = String(score);
this.addChild(gameOverScreen1);
}
}
}//package
Section 126
//door (door)
package {
import flash.display.*;
public class door extends MovieClip {
var open:Boolean;// = false
public var targetClip:doorTarget;
public function door(){
open = false;
super();
addFrameScript(0, frame1, 14, frame15);
}
public function openDoor(){
gotoAndPlay("open");
open = true;
}
function frame15(){
stop();
}
function frame1(){
stop();
}
public function reset(){
if (currentLabel != "closed"){
gotoAndStop("closed");
};
}
public function isOpen():Boolean{
return (open);
}
}
}//package
Section 127
//doorTarget (doorTarget)
package {
import flash.display.*;
public dynamic class doorTarget extends MovieClip {
}
}//package
Section 128
//dummyEnemy (dummyEnemy)
package {
import flash.display.*;
public dynamic class dummyEnemy extends MovieClip {
}
}//package
Section 129
//enemy (enemy)
package {
public class enemy extends gameObject {
var prospectiveX:Number;
var prospectiveY:Number;
var LEFT:int;// = 0
var bottomLeftGridX:Number;
var bottomLeftGridY:Number;
var HORIZONTAL:int;// = 4
var topLeftGridX:Number;
var topLeftGridY:Number;
var topRightGridY:Number;
var topRightGridX:Number;
var speed:Number;
var STATIC:int;// = 3
var gridYSize:int;
var enemyGridXs:Array;
var UP:int;// = 6
var enemyGridYs:Array;
var DOWN:int;// = 7
var movement:int;
var enemyHeight:Number;
var enemyDirection:int;
var topLeftY:Number;
var topLeftX:Number;
var gridXSize:int;
var enemyWidth:Number;
var enemyMathExt:mathExt;
var topRightY:Number;
var topRightX:Number;
var VERTICAL:int;// = 5
var isStationary:Boolean;// = false
var bottomRightGridX:Number;
var bottomRightGridY:Number;
var bottomRightY:Number;
var bottomLeftX:Number;
var bottomRightX:Number;
var bottomLeftY:Number;
var RIGHT:int;// = 1
public function enemy(){
LEFT = 0;
RIGHT = 1;
STATIC = 3;
HORIZONTAL = 4;
VERTICAL = 5;
UP = 6;
DOWN = 7;
isStationary = false;
super();
}
function moveTest(_arg1:Array):Boolean{
var _local2:Boolean;
var _local3:int;
var _local4:int;
var _local5:int;
var _local6:int;
_local2 = true;
_local3 = enemyGridXs.length;
_local4 = 0;
while (_local4 < _local3) {
_local5 = enemyMathExt.convertToIndex(enemyGridXs[_local4], enemyGridYs[_local4]);
switch (enemyDirection){
case LEFT:
_local6 = enemyMathExt.convertToIndex((enemyGridXs[_local4] + 1), enemyGridYs[_local4]);
break;
case RIGHT:
_local6 = enemyMathExt.convertToIndex((enemyGridXs[_local4] - 1), enemyGridYs[_local4]);
break;
case UP:
_local6 = enemyMathExt.convertToIndex(enemyGridXs[_local4], (enemyGridYs[_local4] + 1));
break;
case DOWN:
_local6 = enemyMathExt.convertToIndex(enemyGridXs[_local4], (enemyGridYs[_local4] - 1));
break;
default:
_local6 = enemyMathExt.convertToIndex(enemyGridXs[_local4], enemyGridYs[_local4]);
break;
};
switch (_arg1[_local5]){
case 0:
break;
case 1:
_local2 = false;
break;
case 2:
_local2 = false;
break;
case 43:
_local2 = false;
break;
case 50:
case 51:
case 52:
case 53:
case 54:
case 55:
_local2 = false;
break;
default:
break;
};
_local4++;
};
return (_local2);
}
public function die(){
}
public function update(_arg1:Array, _arg2:Number){
var _local3:Number;
var _local4:Number;
var _local5:int;
var _local6:int;
var _local7:int;
var _local8:int;
var _local9:int;
if (!isStationary){
switch (enemyDirection){
case LEFT:
prospectiveX = (x - (speed * _arg2));
prospectiveY = y;
break;
case RIGHT:
prospectiveX = (x + (speed * _arg2));
prospectiveY = y;
break;
case UP:
prospectiveX = x;
prospectiveY = (y - (speed * _arg2));
break;
case DOWN:
prospectiveX = x;
prospectiveY = (y + (speed * _arg2));
break;
case STATIC:
prospectiveX = x;
prospectiveY = y;
break;
default:
prospectiveX = x;
prospectiveY = y;
break;
};
updateCorners();
if (moveTest(_arg1)){
x = prospectiveX;
y = prospectiveY;
} else {
switch (enemyDirection){
case LEFT:
enemyDirection = RIGHT;
break;
case RIGHT:
enemyDirection = LEFT;
break;
case UP:
enemyDirection = DOWN;
break;
case DOWN:
enemyDirection = UP;
break;
default:
break;
};
};
};
refreshHitBox();
}
public function init(_arg1:Number, _arg2:int, _arg3:int, _arg4:Number, _arg5:Number, _arg6:int, _arg7:int, _arg8){
enemyMathExt = new mathExt(_arg6, _arg7);
speed = _arg1;
gridXSize = _arg2;
gridYSize = _arg3;
enemyWidth = _arg4;
enemyHeight = _arg5;
enemyDirection = STATIC;
enemyGridXs = new Array();
enemyGridYs = new Array();
movement = _arg8;
switch (movement){
case HORIZONTAL:
enemyDirection = RIGHT;
break;
case VERTICAL:
enemyDirection = DOWN;
break;
case STATIC:
enemyDirection = STATIC;
break;
default:
break;
};
setLocalHitBox(3, 3, (gridXSize - 3), (gridYSize - 3));
}
public function kill(){
enemyMathExt = null;
}
function updateCorners(){
var _local1:int;
enemyGridXs = new Array();
enemyGridYs = new Array();
topRightX = (prospectiveX + (enemyWidth - 1));
topRightY = prospectiveY;
topLeftX = prospectiveX;
topLeftY = prospectiveY;
bottomRightX = (prospectiveX + (enemyWidth - 1));
bottomRightY = (prospectiveY + (enemyHeight - 1));
bottomLeftX = prospectiveX;
bottomLeftY = (prospectiveY + (enemyHeight - 1));
topRightGridX = int(((topRightX - (topRightX % gridXSize)) / gridXSize));
topRightGridY = int(((topRightY - (topRightY % gridYSize)) / gridYSize));
topLeftGridX = int(((topLeftX - (topLeftX % gridXSize)) / gridXSize));
topLeftGridY = int(((topLeftY - (topLeftY % gridYSize)) / gridYSize));
bottomRightGridX = int(((bottomRightX - (bottomRightX % gridXSize)) / gridXSize));
bottomRightGridY = int(((bottomRightY - (bottomRightY % gridYSize)) / gridYSize));
bottomLeftGridX = int(((bottomLeftX - (bottomLeftX % gridXSize)) / gridXSize));
bottomLeftGridY = int(((bottomLeftY - (bottomLeftY % gridYSize)) / gridYSize));
enemyGridXs.push(topRightGridX);
enemyGridYs.push(topRightGridY);
enemyGridXs.push(bottomRightGridX);
enemyGridYs.push(bottomRightGridY);
enemyGridXs.push(topLeftGridX);
enemyGridYs.push(topLeftGridY);
enemyGridXs.push(bottomLeftGridX);
enemyGridYs.push(bottomLeftGridY);
if ((topRightGridX - topLeftGridX) > 1){
_local1 = (topLeftGridX + 1);
while (_local1 < topRightGridX) {
enemyGridXs.push(_local1);
enemyGridYs.push(topLeftGridY);
_local1++;
};
};
if ((bottomRightGridX - bottomLeftGridX) > 1){
_local1 = (bottomLeftGridX + 1);
while (_local1 < bottomRightGridX) {
enemyGridXs.push(_local1);
enemyGridYs.push(bottomLeftGridY);
_local1++;
};
};
if ((bottomLeftGridY - topLeftGridY) > 1){
_local1 = (topLeftGridY + 1);
while (_local1 < bottomLeftGridY) {
enemyGridXs.push(topLeftGridX);
enemyGridYs.push(_local1);
_local1++;
};
};
if ((bottomRightGridY - topRightGridY) > 1){
_local1 = (topRightGridY + 1);
while (_local1 < bottomRightGridY) {
enemyGridXs.push(topRightGridX);
enemyGridYs.push(_local1);
_local1++;
};
};
}
}
}//package
Section 130
//gameCompleteScreen (gameCompleteScreen)
package {
import flash.display.*;
import flash.text.*;
public dynamic class gameCompleteScreen extends MovieClip {
public var restart:gameCompleteScreenStartButton;
public var scoreText:TextField;
}
}//package
Section 131
//gameCompleteScreenStartButton (gameCompleteScreenStartButton)
package {
import flash.display.*;
public dynamic class gameCompleteScreenStartButton extends MovieClip {
}
}//package
Section 132
//gameCompleteSound (gameCompleteSound)
package {
import flash.media.*;
public dynamic class gameCompleteSound extends Sound {
}
}//package
Section 133
//gameObject (gameObject)
package {
import flash.display.*;
public class gameObject extends MovieClip {
public var left:Number;
var localLeft:Number;
public var right:Number;
public var bottom:Number;
public var top:Number;
var localRight:Number;
var localBottom:Number;
var localTop:Number;
public function refreshHitBox(){
top = (y + localTop);
bottom = (y + localBottom);
left = (x + localLeft);
right = (x + localRight);
}
public function setLocalHitBox(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number){
localTop = _arg2;
localLeft = _arg1;
localBottom = _arg4;
localRight = _arg3;
}
public function hitBoxTest(_arg1:gameObject):Boolean{
if ((((((top >= _arg1.top)) && ((top < _arg1.bottom)))) || ((((bottom >= _arg1.top)) && ((bottom < _arg1.bottom)))))){
if ((((((left >= _arg1.left)) && ((left < _arg1.right)))) || ((((right >= _arg1.left)) && ((right < _arg1.right)))))){
return (true);
};
};
return (false);
}
}
}//package
Section 134
//gameOverScreen (gameOverScreen)
package {
import flash.display.*;
import flash.text.*;
public dynamic class gameOverScreen extends MovieClip {
public var restart:gameOverScreenStartButton;
public var scoreText:TextField;
}
}//package
Section 135
//gameOverScreenStartButton (gameOverScreenStartButton)
package {
import flash.display.*;
public dynamic class gameOverScreenStartButton extends MovieClip {
}
}//package
Section 136
//gameOverSound (gameOverSound)
package {
import flash.media.*;
public dynamic class gameOverSound extends Sound {
}
}//package
Section 137
//grassBottomTexture (grassBottomTexture)
package {
import flash.display.*;
public dynamic class grassBottomTexture extends MovieClip {
}
}//package
Section 138
//grassTopTexture (grassTopTexture)
package {
import flash.display.*;
public dynamic class grassTopTexture extends MovieClip {
}
}//package
Section 139
//instructionsScreen (instructionsScreen)
package {
import flash.display.*;
public dynamic class instructionsScreen extends MovieClip {
}
}//package
Section 140
//instructionsScreenStartButton (instructionsScreenStartButton)
package {
import flash.display.*;
public dynamic class instructionsScreenStartButton extends MovieClip {
}
}//package
Section 141
//jump (jump)
package {
import flash.display.*;
public dynamic class jump extends MovieClip {
}
}//package
Section 142
//jumpLeft (jumpLeft)
package {
import flash.display.*;
public dynamic class jumpLeft extends MovieClip {
}
}//package
Section 143
//jumpRight (jumpRight)
package {
import flash.display.*;
public dynamic class jumpRight extends MovieClip {
}
}//package
Section 144
//jumpSound (jumpSound)
package {
import flash.media.*;
public dynamic class jumpSound extends Sound {
}
}//package
Section 145
//leftConveyorLeft (leftConveyorLeft)
package {
import flash.display.*;
public dynamic class leftConveyorLeft extends MovieClip {
}
}//package
Section 146
//leftConveyorMiddle (leftConveyorMiddle)
package {
import flash.display.*;
public dynamic class leftConveyorMiddle extends MovieClip {
}
}//package
Section 147
//leftConveyorRight (leftConveyorRight)
package {
import flash.display.*;
public dynamic class leftConveyorRight extends MovieClip {
}
}//package
Section 148
//level (level)
package {
import org.papervision3d.objects.primitives.*;
import flash.display.*;
import org.papervision3d.view.*;
import org.papervision3d.materials.utils.*;
import flash.events.*;
import org.papervision3d.cameras.*;
import org.papervision3d.scenes.*;
import org.papervision3d.render.*;
import org.papervision3d.materials.*;
import flash.utils.*;
import flash.ui.*;
public class level extends MovieClip {
var LEFT:int;// = 0
var gridHeight:int;
var frontMaterialsArray:Array;
var gridWidth:int;
var levelTimer:Timer;
var HORIZONTAL:int;// = 4
private var cube:Cube;
private var wireframeMaterialBlue:ColorMaterial;
var gameGrid:Array;
var backMaterialsArray:Array;
private var plane:Plane;
var enemyDisplayArray:Array;
var STATIC:int;// = 3
var topMaterialsArray:Array;
var gridYSize:int;
private var backgroundMaterial:MovieAssetMaterial;
var bonusDisplayArray:Array;
var timeLeft:int;
private var assetBank1:assetBank;
private var scene:Scene3D;
var bottomMaterialsArray:Array;
var UP:int;// = 6
private var wireframeMaterialYellow:ColorMaterial;
private var viewport:Viewport3D;
var DOWN:int;// = 7
private var wireframeMaterialRed:ColorMaterial;
private var renderer:BasicRenderEngine;
var rightMaterialsArray:Array;
var dummyMovieClip:MovieClip;
var gridXSize:int;
private var wireframeMaterialGreen:BitmapFileMaterial;
private var camera:Camera3D;
var complete:Boolean;
private var wireframeMaterial:ColorMaterial;
var mainChar1:mainChar;
var VERTICAL:int;// = 5
var bonusArray:Array;
var leftMaterialsArray:Array;
var crumbleBlockArray:Array;
var gameMathExt:mathExt;
var enemyArray:Array;
var levelReadOut:readOut;
var displayListArray:Array;
var bonusTextArray:Array;
var RIGHT:int;// = 1
public function level(_arg1:Array, _arg2:int, _arg3:Viewport3D, _arg4:Camera3D, _arg5:Scene3D, _arg6:BasicRenderEngine, _arg7:assetBank){
var _local8:int;
var _local9:int;
var _local10:int;
var _local11:MovieClip;
var _local12:crumbleBlock;
var _local13:MovieClip;
var _local14:bonus;
var _local15:enemy;
var _local16:MovieAssetMaterial;
var _local17:MovieAssetMaterial;
var _local18:MovieAssetMaterial;
var _local19:MovieAssetMaterial;
var _local20:MovieAssetMaterial;
var _local21:MovieAssetMaterial;
var _local22:MaterialsList;
var _local23:ColorMaterial;
var _local24:ColorMaterial;
var _local25:ColorMaterial;
var _local26:MaterialsList;
var _local27:MaterialsList;
var _local28:MaterialsList;
var _local29:MaterialsList;
var _local30:MaterialsList;
var _local31:Array;
var _local32:Boolean;
var _local33:Number;
var _local34:Number;
var _local35:Number;
var _local36:Number;
var _local37:Number;
var _local38:Number;
var _local39:int;
var _local40:int;
var _local41:int;
var _local42:int;
LEFT = 0;
RIGHT = 1;
STATIC = 3;
HORIZONTAL = 4;
VERTICAL = 5;
UP = 6;
DOWN = 7;
super();
dummyMovieClip = new MovieClip();
assetBank1 = _arg7;
displayListArray = new Array();
frontMaterialsArray = new Array();
backMaterialsArray = new Array();
leftMaterialsArray = new Array();
rightMaterialsArray = new Array();
topMaterialsArray = new Array();
bottomMaterialsArray = new Array();
enemyDisplayArray = new Array();
bonusDisplayArray = new Array();
renderer = _arg6;
viewport = _arg3;
scene = _arg5;
camera = _arg4;
camera.zoom = 20;
camera.focus = 50;
wireframeMaterial = new ColorMaterial(0x333333);
wireframeMaterial.doubleSided = true;
wireframeMaterialRed = new ColorMaterial(0xFF0000);
wireframeMaterialRed.doubleSided = true;
wireframeMaterialYellow = new ColorMaterial(0xFFFF00);
wireframeMaterialYellow.doubleSided = true;
wireframeMaterialBlue = new ColorMaterial(0xFF);
wireframeMaterialBlue.doubleSided = true;
wireframeMaterialGreen = new BitmapFileMaterial("testTexture.png");
wireframeMaterialGreen.doubleSided = true;
wireframeMaterialGreen.tiled = true;
wireframeMaterialGreen.maxU = 20;
wireframeMaterialGreen.maxV = 3;
_local23 = new ColorMaterial(0x996600);
_local24 = new ColorMaterial(0xCC00);
_local25 = new ColorMaterial(0);
backgroundMaterial = new MovieAssetMaterial("block1", false);
backgroundMaterial.animated = false;
backgroundMaterial.precise = false;
backgroundMaterial.doubleSided = true;
backgroundMaterial.tiled = true;
backgroundMaterial.maxU = 100;
backgroundMaterial.maxV = 1;
_local26 = new MaterialsList();
_local26.addMaterial(wireframeMaterial, "front");
_local26.addMaterial(wireframeMaterial, "back");
_local26.addMaterial(wireframeMaterial, "left");
_local26.addMaterial(wireframeMaterial, "right");
_local26.addMaterial(wireframeMaterial, "top");
_local26.addMaterial(wireframeMaterial, "bottom");
_local27 = new MaterialsList();
_local27.addMaterial(wireframeMaterialRed, "front");
_local27.addMaterial(wireframeMaterialRed, "back");
_local27.addMaterial(wireframeMaterialRed, "left");
_local27.addMaterial(wireframeMaterialRed, "right");
_local27.addMaterial(wireframeMaterialRed, "top");
_local27.addMaterial(wireframeMaterialRed, "bottom");
_local28 = new MaterialsList();
_local28.addMaterial(wireframeMaterialBlue, "front");
_local28.addMaterial(wireframeMaterialBlue, "back");
_local28.addMaterial(wireframeMaterialBlue, "left");
_local28.addMaterial(wireframeMaterialBlue, "right");
_local28.addMaterial(wireframeMaterialBlue, "top");
_local28.addMaterial(wireframeMaterialBlue, "bottom");
_local29 = new MaterialsList();
_local29.addMaterial(backgroundMaterial, "front");
_local29.addMaterial(backgroundMaterial, "back");
_local29.addMaterial(backgroundMaterial, "left");
_local29.addMaterial(backgroundMaterial, "right");
_local29.addMaterial(backgroundMaterial, "top");
_local29.addMaterial(backgroundMaterial, "bottom");
_local30 = new MaterialsList();
_local30.addMaterial(wireframeMaterialYellow, "front");
_local30.addMaterial(wireframeMaterialYellow, "back");
_local30.addMaterial(wireframeMaterialYellow, "left");
_local30.addMaterial(wireframeMaterialYellow, "right");
_local30.addMaterial(wireframeMaterialYellow, "top");
_local30.addMaterial(wireframeMaterialYellow, "bottom");
timeLeft = _arg2;
levelReadOut = new readOut();
levelReadOut.x = 0;
levelReadOut.y = 320;
addChild(levelReadOut);
levelReadOut.timerText.text = String(timeLeft);
gameGrid = new Array();
enemyArray = new Array();
bonusArray = new Array();
crumbleBlockArray = new Array();
bonusTextArray = new Array();
complete = false;
gridXSize = 20;
gridYSize = 20;
gridWidth = 32;
gridHeight = 16;
gameMathExt = new mathExt(gridWidth, gridHeight);
gameGrid = _arg1;
levelTimer = new Timer(100, timeLeft);
levelTimer.addEventListener("timer", timerHandler, false, 0, true);
levelTimer.start();
_local31 = new Array();
_local8 = 0;
while (_local8 < gameGrid.length) {
_local31[_local8] = gameGrid[_local8];
_local8++;
};
_local32 = false;
_local39 = 0;
_local8 = 0;
while (_local8 <= _local31.length) {
if (((((!((_local31[_local8] == 1))) || ((((gameMathExt.convertToX(_local8) == 0)) && (!((_local8 == 0))))))) || ((_local8 == _local31.length)))){
if (_local32){
if (_local39 > 1){
_local16 = new MovieAssetMaterial("block1", false);
_local16.animated = false;
_local16.doubleSided = true;
_local16.tiled = true;
_local16.maxU = _local39;
_local16.maxV = 1;
_local16.invisible = true;
_local17 = new MovieAssetMaterial("block1", false);
_local17.animated = false;
_local17.doubleSided = true;
_local17.tiled = true;
_local17.maxU = _local39;
_local17.maxV = 1;
_local18 = new MovieAssetMaterial("grassTopTexture", false);
_local18.animated = false;
_local18.doubleSided = true;
_local18.tiled = true;
_local18.maxU = _local39;
_local18.maxV = 1;
_local19 = new MovieAssetMaterial("grassBottomTexture", false);
_local19.animated = false;
_local19.doubleSided = true;
_local19.tiled = true;
_local19.maxU = _local39;
_local19.maxV = 1;
_local20 = new MovieAssetMaterial("block1", false);
_local20.animated = false;
_local20.doubleSided = true;
_local21 = new MovieAssetMaterial("block1", false);
_local21.animated = false;
_local21.doubleSided = true;
_local22 = new MaterialsList();
_local22.addMaterial(_local16, "front");
_local22.addMaterial(_local17, "back");
_local22.addMaterial(_local23, "left");
_local22.addMaterial(_local23, "right");
_local22.addMaterial(_local24, "top");
_local22.addMaterial(_local23, "bottom");
cube = new Cube(_local22, _local37, _local36, _local38, 1, 1, 1);
cube.x = gameMathExt.adjustXFor3D((_local33 * gridXSize), _local37);
cube.y = gameMathExt.adjustYFor3D((_local34 * gridXSize), _local38);
scene.addChild(cube);
displayListArray.push(cube);
_local32 = false;
_local42 = _local40;
while (_local42 < _local8) {
_local31[_local42] = 0;
_local42++;
};
} else {
_local32 = false;
};
};
};
if (_local31[_local8] == 1){
if (_local32){
_local37 = (_local37 + 20);
_local39++;
} else {
_local33 = gameMathExt.convertToX(_local8);
_local34 = gameMathExt.convertToY(_local8);
_local36 = 20;
_local37 = 20;
_local38 = 20;
_local32 = true;
_local40 = _local8;
_local39 = 1;
};
};
_local8++;
};
_local32 = false;
_local9 = 0;
while (_local9 < gridWidth) {
_local10 = 0;
while (_local10 < gridHeight) {
_local8 = ((_local10 * gridWidth) + _local9);
if (((((!((_local31[_local8] == 1))) || ((((gameMathExt.convertToY(_local8) == 0)) && (!((_local8 == 0))))))) || ((_local8 == (_local31.length - 1))))){
if (_local32){
_local16 = new MovieAssetMaterial("block1", false);
_local16.animated = false;
_local16.doubleSided = true;
_local16.tiled = true;
_local16.maxU = 1;
_local16.maxV = _local39;
_local16.invisible = true;
_local17 = new MovieAssetMaterial("block1", false);
_local17.animated = false;
_local17.doubleSided = true;
_local17.tiled = true;
_local17.maxU = 1;
_local17.maxV = _local39;
_local18 = new MovieAssetMaterial("grassTopTexture", false);
_local18.animated = false;
_local18.doubleSided = true;
_local19 = new MovieAssetMaterial("grassBottomTexture", false);
_local19.animated = false;
_local19.doubleSided = true;
_local20 = new MovieAssetMaterial("block1", false);
_local20.animated = false;
_local20.doubleSided = true;
_local20.tiled = true;
_local20.maxU = 1;
_local20.maxV = _local39;
_local21 = new MovieAssetMaterial("block1", false);
_local21.animated = false;
_local21.doubleSided = true;
_local21.tiled = true;
_local21.maxU = 1;
_local21.maxV = _local39;
_local22 = new MaterialsList();
_local22.addMaterial(_local16, "front");
_local22.addMaterial(_local17, "back");
_local22.addMaterial(_local17, "left");
_local22.addMaterial(_local17, "right");
_local22.addMaterial(_local24, "top");
_local22.addMaterial(_local23, "bottom");
cube = new Cube(_local22, _local37, _local36, _local38, 1, 1, 1);
cube.x = gameMathExt.adjustXFor3D((_local33 * gridXSize), _local37);
cube.y = gameMathExt.adjustYFor3D((_local34 * gridXSize), _local38);
scene.addChild(cube);
displayListArray.push(cube);
_local32 = false;
};
};
if (_local31[_local8] == 1){
if (_local32){
_local38 = (_local38 + 20);
_local39++;
} else {
_local33 = gameMathExt.convertToX(_local8);
_local34 = gameMathExt.convertToY(_local8);
_local36 = 20;
_local37 = 20;
_local38 = 20;
_local32 = true;
_local39 = 1;
};
};
_local10++;
};
_local9++;
};
_local32 = false;
_local8 = 0;
while (_local8 <= _local31.length) {
if (((((((((!((_local31[_local8] == 50))) && (!((_local31[_local8] == 51))))) && (!((_local31[_local8] == 52))))) || ((((gameMathExt.convertToX(_local8) == 0)) && (!((_local8 == 0))))))) || ((_local8 == _local31.length)))){
if (_local32){
if (_local39 > 1){
_local16 = new MovieAssetMaterial("leftConveyorMiddle", false);
_local16.animated = false;
_local16.doubleSided = true;
_local16.tiled = true;
_local16.maxU = _local39;
_local16.maxV = 1;
_local16.invisible = true;
_local17 = new MovieAssetMaterial("leftConveyorMiddle", false);
_local17.animated = false;
_local17.doubleSided = true;
_local17.tiled = true;
_local17.maxU = _local39;
_local17.maxV = 1;
_local18 = new MovieAssetMaterial("conveyorTopTexture", false);
_local18.animated = false;
_local18.doubleSided = true;
_local18.tiled = true;
_local18.maxU = _local39;
_local18.maxV = 1;
_local19 = new MovieAssetMaterial("conveyorTopTexture", false);
_local19.animated = false;
_local19.doubleSided = true;
_local19.tiled = true;
_local19.maxU = _local39;
_local19.maxV = 1;
_local20 = new MovieAssetMaterial("conveyorTopTexture", false);
_local20.animated = false;
_local20.doubleSided = true;
_local21 = new MovieAssetMaterial("conveyorTopTexture", false);
_local21.animated = false;
_local21.doubleSided = true;
_local22 = new MaterialsList();
_local22.addMaterial(_local16, "front");
_local22.addMaterial(_local17, "back");
_local22.addMaterial(_local25, "left");
_local22.addMaterial(_local25, "right");
_local22.addMaterial(_local25, "top");
_local22.addMaterial(_local25, "bottom");
cube = new Cube(_local22, _local37, _local36, _local38, 1, 1, 1);
cube.x = gameMathExt.adjustXFor3D((_local33 * gridXSize), _local37);
cube.y = gameMathExt.adjustYFor3D((_local34 * gridXSize), _local38);
scene.addChild(cube);
displayListArray.push(cube);
_local32 = false;
_local42 = _local40;
while (_local42 < _local8) {
_local31[_local42] = 0;
_local42++;
};
} else {
_local32 = false;
};
};
};
if ((((((_local31[_local8] == 50)) || ((_local31[_local8] == 51)))) || ((_local31[_local8] == 52)))){
if (_local32){
_local37 = (_local37 + 20);
_local39++;
} else {
_local33 = gameMathExt.convertToX(_local8);
_local34 = gameMathExt.convertToY(_local8);
_local36 = 20;
_local37 = 20;
_local38 = 20;
_local32 = true;
_local40 = _local8;
_local39 = 1;
};
};
_local8++;
};
_local32 = false;
_local8 = 0;
while (_local8 <= _local31.length) {
if (((((((((!((_local31[_local8] == 53))) && (!((_local31[_local8] == 54))))) && (!((_local31[_local8] == 55))))) || ((((gameMathExt.convertToX(_local8) == 0)) && (!((_local8 == 0))))))) || ((_local8 == _local31.length)))){
if (_local32){
if (_local39 > 1){
_local16 = new MovieAssetMaterial("rightConveyorMiddle", false);
_local16.animated = false;
_local16.doubleSided = true;
_local16.tiled = true;
_local16.maxU = _local39;
_local16.maxV = 1;
_local16.invisible = true;
_local17 = new MovieAssetMaterial("rightConveyorMiddle", false);
_local17.animated = false;
_local17.doubleSided = true;
_local17.tiled = true;
_local17.maxU = _local39;
_local17.maxV = 1;
_local18 = new MovieAssetMaterial("conveyorTopTextureRight", false);
_local18.animated = false;
_local18.doubleSided = true;
_local18.tiled = true;
_local18.maxU = _local39;
_local18.maxV = 1;
_local19 = new MovieAssetMaterial("conveyorTopTextureRight", false);
_local19.animated = false;
_local19.doubleSided = true;
_local19.tiled = true;
_local19.maxU = _local39;
_local19.maxV = 1;
_local20 = new MovieAssetMaterial("conveyorTopTextureRight", false);
_local20.animated = false;
_local20.doubleSided = true;
_local21 = new MovieAssetMaterial("conveyorTopTextureRight", false);
_local21.animated = false;
_local21.doubleSided = true;
_local22 = new MaterialsList();
_local22.addMaterial(_local16, "front");
_local22.addMaterial(_local17, "back");
_local22.addMaterial(_local25, "left");
_local22.addMaterial(_local25, "right");
_local22.addMaterial(_local25, "top");
_local22.addMaterial(_local25, "bottom");
cube = new Cube(_local22, _local37, _local36, _local38, 1, 1, 1);
cube.x = gameMathExt.adjustXFor3D((_local33 * gridXSize), _local37);
cube.y = gameMathExt.adjustYFor3D((_local34 * gridXSize), _local38);
scene.addChild(cube);
displayListArray.push(cube);
_local32 = false;
_local42 = _local40;
while (_local42 < _local8) {
_local31[_local42] = 0;
_local42++;
};
} else {
_local32 = false;
};
};
};
if ((((((_local31[_local8] == 53)) || ((_local31[_local8] == 54)))) || ((_local31[_local8] == 55)))){
if (_local32){
_local37 = (_local37 + 20);
_local39++;
} else {
_local33 = gameMathExt.convertToX(_local8);
_local34 = gameMathExt.convertToY(_local8);
_local36 = 20;
_local37 = 20;
_local38 = 20;
_local32 = true;
_local40 = _local8;
_local39 = 1;
};
};
_local8++;
};
_local32 = false;
_local8 = 0;
while (_local8 <= _local31.length) {
if (((((!((_local31[_local8] == 5))) || ((((gameMathExt.convertToX(_local8) == 0)) && (!((_local8 == 0))))))) || ((_local8 == _local31.length)))){
if (_local32){
_local16 = new MovieAssetMaterial("spikes2", true);
_local16.animated = false;
_local16.doubleSided = true;
_local16.tiled = true;
_local16.maxU = _local39;
_local16.maxV = 1;
_local16.invisible = true;
_local17 = new MovieAssetMaterial("spikes2", true);
_local17.animated = false;
_local17.doubleSided = true;
_local17.tiled = true;
_local17.maxU = _local39;
_local17.maxV = 1;
_local18 = new MovieAssetMaterial("spikesBottomTexture", true);
_local18.animated = false;
_local18.doubleSided = true;
_local18.invisible = true;
_local18.tiled = true;
_local18.maxU = _local39;
_local18.maxV = 1;
_local19 = new MovieAssetMaterial("blankTexture", true);
_local19.animated = false;
_local19.invisible = true;
_local19.doubleSided = true;
_local19.tiled = true;
_local19.maxU = _local39;
_local19.maxV = 1;
_local20 = new MovieAssetMaterial("spikes2", true);
_local20.animated = false;
_local20.doubleSided = true;
_local20.invisible = true;
_local21 = new MovieAssetMaterial("spikes2", true);
_local21.animated = false;
_local21.doubleSided = true;
_local21.invisible = true;
_local22 = new MaterialsList();
_local22.addMaterial(_local16, "front");
_local22.addMaterial(_local17, "back");
_local22.addMaterial(_local20, "left");
_local22.addMaterial(_local21, "right");
_local22.addMaterial(_local18, "top");
_local22.addMaterial(_local19, "bottom");
cube = new Cube(_local22, _local37, _local36, _local38, 1, 1, 1);
cube.x = gameMathExt.adjustXFor3D((_local33 * gridXSize), _local37);
cube.y = gameMathExt.adjustYFor3D((_local34 * gridXSize), _local38);
scene.addChild(cube);
displayListArray.push(cube);
_local32 = false;
_local42 = _local40;
while (_local42 < _local8) {
_local31[_local42] = 0;
_local42++;
};
};
};
if (_local31[_local8] == 5){
if (_local32){
_local37 = (_local37 + 20);
_local39++;
} else {
_local33 = gameMathExt.convertToX(_local8);
_local34 = gameMathExt.convertToY(_local8);
_local36 = 20;
_local37 = 20;
_local38 = 20;
_local32 = true;
_local40 = _local8;
_local39 = 1;
};
};
_local8++;
};
_local32 = false;
_local8 = 0;
while (_local8 <= _local31.length) {
if (((((!((_local31[_local8] == 4))) || ((((gameMathExt.convertToX(_local8) == 0)) && (!((_local8 == 0))))))) || ((_local8 == _local31.length)))){
if (_local32){
_local16 = new MovieAssetMaterial("spikes", true);
_local16.animated = false;
_local16.doubleSided = true;
_local16.tiled = true;
_local16.maxU = _local39;
_local16.maxV = 1;
_local17 = new MovieAssetMaterial("spikes", true);
_local17.animated = false;
_local17.doubleSided = true;
_local17.tiled = true;
_local17.maxU = _local39;
_local17.maxV = 1;
_local17.invisible = true;
_local18 = new MovieAssetMaterial("blankTexture", true);
_local18.animated = false;
_local18.doubleSided = true;
_local18.tiled = true;
_local18.maxU = _local39;
_local18.maxV = 1;
_local18.invisible = true;
_local19 = new MovieAssetMaterial("spikesBottomTexture", true);
_local19.animated = false;
_local19.doubleSided = true;
_local19.tiled = true;
_local19.maxU = _local39;
_local19.maxV = 1;
_local19.invisible = true;
_local20 = new MovieAssetMaterial("spikes", true);
_local20.animated = false;
_local20.doubleSided = true;
_local20.invisible = true;
_local21 = new MovieAssetMaterial("spikes", true);
_local21.animated = false;
_local21.doubleSided = true;
_local21.invisible = true;
_local22 = new MaterialsList();
_local22.addMaterial(_local16, "front");
_local22.addMaterial(_local17, "back");
_local22.addMaterial(_local20, "left");
_local22.addMaterial(_local21, "right");
_local22.addMaterial(_local18, "top");
_local22.addMaterial(_local19, "bottom");
cube = new Cube(_local22, _local37, _local36, _local38, 1, 1, 1);
cube.x = gameMathExt.adjustXFor3D((_local33 * gridXSize), _local37);
cube.y = gameMathExt.adjustYFor3D((_local34 * gridXSize), _local38);
scene.addChild(cube);
displayListArray.push(cube);
_local32 = false;
_local42 = _local40;
while (_local42 < _local8) {
_local31[_local42] = 0;
_local42++;
};
};
};
if (_local31[_local8] == 4){
if (_local32){
_local37 = (_local37 + 20);
_local39++;
} else {
_local33 = gameMathExt.convertToX(_local8);
_local34 = gameMathExt.convertToY(_local8);
_local36 = 20;
_local37 = 20;
_local38 = 20;
_local32 = true;
_local40 = _local8;
_local39 = 1;
};
};
_local8++;
};
_local32 = false;
_local9 = 0;
while (_local9 < gridWidth) {
_local10 = 0;
while (_local10 < gridHeight) {
_local8 = ((_local10 * gridWidth) + _local9);
if (((((!((_local31[_local8] == 7))) || ((((gameMathExt.convertToY(_local8) == 0)) && (!((_local8 == 0))))))) || ((_local8 == (_local31.length - 1))))){
if (_local32){
_local16 = new MovieAssetMaterial("spikes4", true);
_local16.animated = false;
_local16.doubleSided = true;
_local16.tiled = true;
_local16.maxU = 1;
_local16.maxV = _local39;
_local16.invisible = true;
_local17 = new MovieAssetMaterial("spikes4", true);
_local17.animated = false;
_local17.doubleSided = true;
_local17.tiled = true;
_local17.maxU = 1;
_local17.maxV = _local39;
_local18 = new MovieAssetMaterial("spikes4", true);
_local18.animated = false;
_local18.doubleSided = true;
_local18.invisible = true;
_local18.invisible = true;
_local19 = new MovieAssetMaterial("spikes4", true);
_local19.animated = false;
_local19.doubleSided = true;
_local19.invisible = true;
_local19.invisible = true;
_local20 = new MovieAssetMaterial("blankTexture", true);
_local20.animated = false;
_local20.doubleSided = true;
_local20.tiled = true;
_local20.maxU = 1;
_local20.maxV = _local39;
_local20.invisible = true;
_local21 = new MovieAssetMaterial("spikesBottomTexture", true);
_local21.animated = false;
_local21.doubleSided = true;
_local21.tiled = true;
_local21.maxU = 1;
_local21.maxV = _local39;
_local21.invisible = true;
_local22 = new MaterialsList();
_local22.addMaterial(_local16, "front");
_local22.addMaterial(_local17, "back");
_local22.addMaterial(_local20, "left");
_local22.addMaterial(_local21, "right");
_local22.addMaterial(_local18, "top");
_local22.addMaterial(_local19, "bottom");
cube = new Cube(_local22, _local37, _local36, _local38, 1, 1, 1);
cube.x = gameMathExt.adjustXFor3D((_local33 * gridXSize), _local37);
cube.y = gameMathExt.adjustYFor3D((_local34 * gridXSize), _local38);
scene.addChild(cube);
displayListArray.push(cube);
_local32 = false;
};
};
if (_local31[_local8] == 7){
if (_local32){
_local38 = (_local38 + 20);
_local39++;
} else {
_local33 = gameMathExt.convertToX(_local8);
_local34 = gameMathExt.convertToY(_local8);
_local36 = 20;
_local37 = 20;
_local38 = 20;
_local32 = true;
_local39 = 1;
};
};
_local10++;
};
_local9++;
};
_local32 = false;
_local9 = 0;
while (_local9 < gridWidth) {
_local10 = 0;
while (_local10 < gridHeight) {
_local8 = ((_local10 * gridWidth) + _local9);
if (((((!((_local31[_local8] == 6))) || ((((gameMathExt.convertToY(_local8) == 0)) && (!((_local8 == 0))))))) || ((_local8 == (_local31.length - 1))))){
if (_local32){
_local16 = new MovieAssetMaterial("spikes3", true);
_local16.animated = false;
_local16.doubleSided = true;
_local16.tiled = true;
_local16.maxU = 1;
_local16.maxV = _local39;
_local16.invisible = true;
_local17 = new MovieAssetMaterial("spikes3", true);
_local17.animated = false;
_local17.doubleSided = true;
_local17.tiled = true;
_local17.maxU = 1;
_local17.maxV = _local39;
_local18 = new MovieAssetMaterial("spikes3", true);
_local18.animated = false;
_local18.doubleSided = true;
_local18.invisible = true;
_local19 = new MovieAssetMaterial("spikes3", true);
_local19.animated = false;
_local19.doubleSided = true;
_local19.invisible = true;
_local20 = new MovieAssetMaterial("spikesBottomTexture", true);
_local20.animated = false;
_local20.doubleSided = true;
_local20.tiled = true;
_local20.maxU = 1;
_local20.maxV = _local39;
_local20.invisible = true;
_local21 = new MovieAssetMaterial("blankTexture", true);
_local21.animated = false;
_local21.doubleSided = true;
_local21.tiled = true;
_local21.maxU = 1;
_local21.maxV = _local39;
_local21.invisible = true;
_local22 = new MaterialsList();
_local22.addMaterial(_local16, "front");
_local22.addMaterial(_local17, "back");
_local22.addMaterial(_local20, "left");
_local22.addMaterial(_local21, "right");
_local22.addMaterial(_local18, "top");
_local22.addMaterial(_local19, "bottom");
cube = new Cube(_local22, _local37, _local36, _local38, 1, 1, 1);
cube.x = gameMathExt.adjustXFor3D((_local33 * gridXSize), _local37);
cube.y = gameMathExt.adjustYFor3D((_local34 * gridXSize), _local38);
scene.addChild(cube);
displayListArray.push(cube);
_local32 = false;
};
};
if (_local31[_local8] == 6){
if (_local32){
_local38 = (_local38 + 20);
_local39++;
} else {
_local33 = gameMathExt.convertToX(_local8);
_local34 = gameMathExt.convertToY(_local8);
_local36 = 20;
_local37 = 20;
_local38 = 20;
_local32 = true;
_local39 = 1;
};
};
_local10++;
};
_local9++;
};
_local32 = false;
_local8 = 0;
while (_local8 <= _local31.length) {
if (((((!((_local31[_local8] == 2))) || ((((gameMathExt.convertToX(_local8) == 0)) && (!((_local8 == 0))))))) || ((_local8 == _local31.length)))){
if (_local32){
if (_local39 > 1){
_local16 = new MovieAssetMaterial("cloudTexture", true);
_local16.animated = false;
_local16.doubleSided = true;
_local16.tiled = true;
_local16.maxU = _local39;
_local16.maxV = 1;
_local17 = new MovieAssetMaterial("cloudTexture", true);
_local17.animated = false;
_local17.doubleSided = true;
_local17.tiled = true;
_local17.maxU = _local39;
_local17.maxV = 1;
_local18 = new MovieAssetMaterial("blankTexture", true);
_local18.animated = false;
_local18.doubleSided = true;
_local18.tiled = true;
_local18.maxU = _local39;
_local18.maxV = 1;
_local18.invisible = true;
_local19 = new MovieAssetMaterial("blankTexture", true);
_local19.animated = false;
_local19.doubleSided = true;
_local19.tiled = true;
_local19.maxU = _local39;
_local19.maxV = 1;
_local19.invisible = true;
_local20 = new MovieAssetMaterial("cloudTexture", true);
_local20.animated = false;
_local20.doubleSided = true;
_local20.invisible = true;
_local21 = new MovieAssetMaterial("cloudTexture", true);
_local21.animated = false;
_local21.doubleSided = true;
_local21.invisible = true;
_local22 = new MaterialsList();
_local22.addMaterial(_local16, "front");
_local22.addMaterial(_local17, "back");
_local22.addMaterial(_local20, "left");
_local22.addMaterial(_local21, "right");
_local22.addMaterial(_local18, "top");
_local22.addMaterial(_local19, "bottom");
cube = new Cube(_local22, _local37, _local36, _local38, 1, 1, 1);
cube.x = gameMathExt.adjustXFor3D((_local33 * gridXSize), _local37);
cube.y = gameMathExt.adjustYFor3D((_local34 * gridXSize), _local38);
scene.addChild(cube);
displayListArray.push(cube);
_local32 = false;
_local42 = _local40;
while (_local42 < _local8) {
_local31[_local42] = 0;
_local42++;
};
} else {
_local32 = false;
};
};
};
if (_local31[_local8] == 2){
if (_local32){
_local37 = (_local37 + 20);
_local39++;
} else {
_local33 = gameMathExt.convertToX(_local8);
_local34 = gameMathExt.convertToY(_local8);
_local36 = 20;
_local37 = 20;
_local38 = 20;
_local32 = true;
_local40 = _local8;
_local39 = 1;
};
};
_local8++;
};
_local32 = false;
_local9 = 0;
while (_local9 < gridWidth) {
_local10 = 0;
while (_local10 < gridHeight) {
_local8 = ((_local10 * gridWidth) + _local9);
if (((((!((_local31[_local8] == 2))) || ((((gameMathExt.convertToY(_local8) == 0)) && (!((_local8 == 0))))))) || ((_local8 == (_local31.length - 1))))){
if (_local32){
_local16 = new MovieAssetMaterial("cloudTexture", true);
_local16.animated = false;
_local16.doubleSided = true;
_local16.tiled = true;
_local16.maxU = 1;
_local16.maxV = _local39;
_local17 = new MovieAssetMaterial("cloudTexture", true);
_local17.animated = false;
_local17.doubleSided = true;
_local17.tiled = true;
_local17.maxU = 1;
_local17.maxV = _local39;
_local18 = new MovieAssetMaterial("blankTexture", true);
_local18.animated = false;
_local18.doubleSided = true;
_local18.invisible = true;
_local19 = new MovieAssetMaterial("blankTexture", true);
_local19.animated = false;
_local19.doubleSided = true;
_local19.invisible = true;
_local20 = new MovieAssetMaterial("cloudTexture", true);
_local20.animated = false;
_local20.doubleSided = true;
_local20.tiled = true;
_local20.maxU = 1;
_local20.maxV = _local39;
_local20.invisible = true;
_local21 = new MovieAssetMaterial("cloudTexture", true);
_local21.animated = false;
_local21.doubleSided = true;
_local21.tiled = true;
_local21.maxU = 1;
_local21.maxV = _local39;
_local21.invisible = true;
_local22 = new MaterialsList();
_local22.addMaterial(_local16, "front");
_local22.addMaterial(_local17, "back");
_local22.addMaterial(_local20, "left");
_local22.addMaterial(_local21, "right");
_local22.addMaterial(_local18, "top");
_local22.addMaterial(_local19, "bottom");
cube = new Cube(_local22, _local37, _local36, _local38, 1, 1, 1);
cube.x = gameMathExt.adjustXFor3D((_local33 * gridXSize), _local37);
cube.y = gameMathExt.adjustYFor3D((_local34 * gridXSize), _local38);
scene.addChild(cube);
displayListArray.push(cube);
_local32 = false;
};
};
if (_local31[_local8] == 2){
if (_local32){
_local38 = (_local38 + 20);
_local39++;
} else {
_local33 = gameMathExt.convertToX(_local8);
_local34 = gameMathExt.convertToY(_local8);
_local36 = 20;
_local37 = 20;
_local38 = 20;
_local32 = true;
_local39 = 1;
};
};
_local10++;
};
_local9++;
};
_local32 = false;
_local8 = 0;
while (_local8 < gameGrid.length) {
if (gameGrid[_local8] == 44){
_local12 = new crumbleBlock(30, _local8, 20, 20);
_local12.x = (gameMathExt.convertToX(_local8) * gridXSize);
_local12.y = (gameMathExt.convertToY(_local8) * gridYSize);
crumbleBlockArray.push(_local12);
this.addChild(_local12);
gameGrid[_local8] = 2;
} else {
if (gameGrid[_local8] == 3){
_local15 = new enemy();
_local15.init(1, gridXSize, gridYSize, 20, 20, gridWidth, gridHeight, HORIZONTAL);
_local15.x = (gameMathExt.convertToX(_local8) * gridXSize);
_local15.y = (gameMathExt.convertToY(_local8) * gridYSize);
plane = assetBank1.getEnemy();
plane.x = gameMathExt.adjustXFor3D(_local15.x, 20);
plane.y = gameMathExt.adjustYFor3D(_local15.y, 20);
scene.addChild(plane);
displayListArray.push(plane);
enemyDisplayArray.push(plane);
enemyArray.push(_local15);
} else {
if (gameGrid[_local8] == 4){
_local15 = new spikes();
_local15.init(1, gridXSize, gridYSize, 20, 20, gridWidth, gridHeight, HORIZONTAL);
_local15.x = (gameMathExt.convertToX(_local8) * gridXSize);
_local15.y = (gameMathExt.convertToY(_local8) * gridYSize);
enemyDisplayArray.push(dummyMovieClip);
enemyArray.push(_local15);
} else {
if (gameGrid[_local8] == 5){
_local15 = new spikes2();
_local15.init(1, gridXSize, gridYSize, 20, 20, gridWidth, gridHeight, HORIZONTAL);
_local15.x = (gameMathExt.convertToX(_local8) * gridXSize);
_local15.y = (gameMathExt.convertToY(_local8) * gridYSize);
enemyDisplayArray.push(dummyMovieClip);
enemyArray.push(_local15);
} else {
if (gameGrid[_local8] == 6){
_local15 = new spikes3();
_local15.init(1, gridXSize, gridYSize, 20, 20, gridWidth, gridHeight, HORIZONTAL);
_local15.x = (gameMathExt.convertToX(_local8) * gridXSize);
_local15.y = (gameMathExt.convertToY(_local8) * gridYSize);
enemyDisplayArray.push(dummyMovieClip);
enemyArray.push(_local15);
} else {
if (gameGrid[_local8] == 7){
_local15 = new spikes4();
_local15.init(1, gridXSize, gridYSize, 20, 20, gridWidth, gridHeight, HORIZONTAL);
_local15.x = (gameMathExt.convertToX(_local8) * gridXSize);
_local15.y = (gameMathExt.convertToY(_local8) * gridYSize);
enemyDisplayArray.push(dummyMovieClip);
enemyArray.push(_local15);
} else {
if (gameGrid[_local8] == 13){
_local15 = new enemy();
_local15.init(1, gridXSize, gridYSize, 20, 20, gridWidth, gridHeight, VERTICAL);
_local15.x = (gameMathExt.convertToX(_local8) * gridXSize);
_local15.y = (gameMathExt.convertToY(_local8) * gridYSize);
plane = assetBank1.getEnemy();
plane.x = gameMathExt.adjustXFor3D(_local15.x, 20);
plane.y = gameMathExt.adjustYFor3D(_local15.y, 20);
scene.addChild(plane);
displayListArray.push(plane);
enemyDisplayArray.push(plane);
enemyArray.push(_local15);
} else {
if (gameGrid[_local8] == 56){
_local14 = new bonus();
bonusArray.push(_local14);
_local14.x = (gameMathExt.convertToX(_local8) * gridXSize);
_local14.y = (gameMathExt.convertToY(_local8) * gridYSize);
plane = assetBank1.getBonus();
plane.x = gameMathExt.adjustXFor3D(_local14.x, 20);
plane.y = gameMathExt.adjustYFor3D(_local14.y, 20);
scene.addChild(plane);
displayListArray.push(plane);
bonusDisplayArray.push(plane);
} else {
if (gameGrid[_local8] == 57){
assetBank1.door1.x = (gameMathExt.convertToX(_local8) * gridXSize);
assetBank1.door1.y = (gameMathExt.convertToY(_local8) * gridYSize);
assetBank1.doorPlane.x = gameMathExt.adjustXFor3D(assetBank1.door1.x, 20);
assetBank1.doorPlane.y = gameMathExt.adjustYFor3D(assetBank1.door1.y, 30);
assetBank1.doorPlane.z = 5;
scene.addChild(assetBank1.doorPlane);
displayListArray.push(assetBank1.doorPlane);
};
};
};
};
};
};
};
};
};
_local8++;
};
_local8 = 0;
while (_local8 < gameGrid.length) {
if (gameGrid[_local8] == 58){
mainChar1 = new mainChar(4, gridXSize, gridYSize, 20, 30, gridWidth, gridHeight, 60);
mainChar1.x = (gameMathExt.convertToX(_local8) * gridXSize);
mainChar1.y = (gameMathExt.convertToY(_local8) * gridYSize);
assetBank1.mainCharPlane.x = gameMathExt.adjustXFor3D(mainChar1.x, 20);
assetBank1.mainCharPlane.y = gameMathExt.adjustYFor3D(mainChar1.y, 30);
scene.addChild(assetBank1.mainCharPlane);
displayListArray.push(assetBank1.mainCharPlane);
};
_local8++;
};
_local8 = 0;
while (_local8 < 3) {
scene.addChild(assetBank1.bGArray[_local8]);
displayListArray.push(assetBank1.bGArray[_local8]);
_local8++;
};
addChild(viewport);
renderer.renderScene(scene, camera, viewport);
}
function handleKeyUp(_arg1:KeyboardEvent):void{
if (_arg1.keyCode == Keyboard.UP){
mainChar1.stopJump();
};
if (_arg1.keyCode == Keyboard.LEFT){
mainChar1.stopLeft();
};
if (_arg1.keyCode == Keyboard.RIGHT){
mainChar1.stopRight();
};
}
function timerHandler(_arg1:TimerEvent):void{
timeLeft--;
levelReadOut.timerText.text = String(timeLeft);
}
function handleKeyDown(_arg1:KeyboardEvent):void{
if (_arg1.keyCode == Keyboard.UP){
mainChar1.startJump();
};
if (_arg1.keyCode == Keyboard.LEFT){
mainChar1.startLeft();
};
if (_arg1.keyCode == Keyboard.RIGHT){
mainChar1.startRight();
};
}
public function isComplete():Boolean{
return (complete);
}
public function get score():int{
return (mainChar1.getScore());
}
function update(_arg1:Event){
var _local2:int;
var _local3:int;
var _local4:bonusText;
_local2 = enemyArray.length;
if (mainChar1.update(gameGrid, enemyArray, bonusArray, 1, timeLeft) == 0){
if (assetBank1.door1.isOpen() == false){
assetBank1.door1.openDoor();
};
};
_local3 = 0;
while (_local3 < _local2) {
enemyArray[_local3].update(gameGrid, 1);
_local3++;
};
_local2 = crumbleBlockArray.length;
_local3 = 0;
while (_local3 < _local2) {
crumbleBlockArray[_local3].update(mainChar1, gameGrid, 1);
_local3++;
};
_local2 = bonusArray.length;
_local3 = 0;
while (_local3 < _local2) {
if (((bonusArray[_local3].getActive()) && (bonusArray[_local3].update()))){
_local4 = new bonusText(bonusArray[_local3].x, bonusArray[_local3].y);
_local4.scoreText.text = bonusArray[_local3].getScore();
addChild(_local4);
bonusTextArray.push(_local4);
bonusArray[_local3].sleep();
bonusArray[_local3].x = 2000;
bonusArray[_local3].y = 2000;
bonusArray[_local3].visible = false;
};
_local3++;
};
_local2 = bonusTextArray.length;
_local3 = 0;
while (_local3 < _local2) {
bonusTextArray[_local3].update(1);
_local3++;
};
if (((mainChar1.hitTestObject(assetBank1.door1.targetClip)) && (assetBank1.door1.isOpen()))){
complete = true;
};
levelReadOut.scoreText.text = mainChar1.getScore();
_local3 = 0;
while (_local3 < enemyArray.length) {
enemyDisplayArray[_local3].x = gameMathExt.adjustXFor3D(enemyArray[_local3].x, 20);
enemyDisplayArray[_local3].y = gameMathExt.adjustYFor3D(enemyArray[_local3].y, 20);
_local3++;
};
_local3 = 0;
while (_local3 < bonusArray.length) {
bonusDisplayArray[_local3].visible = bonusArray[_local3].visible;
_local3++;
};
assetBank1.mainCharPlane.x = gameMathExt.adjustXFor3D(mainChar1.x, 20);
assetBank1.mainCharPlane.y = gameMathExt.adjustYFor3D(mainChar1.y, 30);
switch (mainChar1.currentFrame){
case 1:
assetBank1.mainCharPlane.material = assetBank1.mainCharWalkMaterial;
break;
case 2:
assetBank1.mainCharPlane.material = assetBank1.mainCharWalkLeftMaterial;
break;
case 3:
assetBank1.mainCharPlane.material = assetBank1.mainCharJumpMaterial;
break;
case 4:
assetBank1.mainCharPlane.material = assetBank1.mainCharJumpLeftMaterial;
break;
case 5:
assetBank1.mainCharPlane.material = assetBank1.mainCharStandMaterial;
break;
case 6:
assetBank1.mainCharPlane.material = assetBank1.mainCharStandLeftMaterial;
break;
default:
break;
};
camera.x = gameMathExt.adjustXFor3D(mainChar1.x, 20);
camera.y = gameMathExt.adjustYFor3D(mainChar1.y, 30);
renderer.renderScene(scene, camera, viewport);
}
public function set score(_arg1:int){
mainChar1.setScore(_arg1);
}
public function get timeRemaining():int{
return (timeLeft);
}
public function getTimeLeft():int{
return (timeLeft);
}
public function destroy(){
var _local1:int;
levelTimer.stop();
levelTimer.removeEventListener("timer", timerHandler);
levelTimer = null;
_local1 = 0;
while (_local1 < displayListArray.length) {
scene.removeChild(displayListArray[_local1]);
displayListArray[_local1] = null;
_local1++;
};
displayListArray = null;
}
}
}//package
Section 149
//levelCompleteSound (levelCompleteSound)
package {
import flash.media.*;
public dynamic class levelCompleteSound extends Sound {
}
}//package
Section 150
//LightGreyCloud (LightGreyCloud)
package {
import flash.display.*;
public dynamic class LightGreyCloud extends MovieClip {
}
}//package
Section 151
//mainChar (mainChar)
package {
public class mainChar extends gameObject {
var jumpPoint:Number;
var prospectiveX:Number;
var prospectiveY:Number;
var charWidth:Number;
var LEFT:int;// = 0
var jumpPressed:Boolean;// = false
var charHeight:Number;
var jumpBaseY:Number;
var bottomLeftGridX:Number;
var bottomLeftGridY:Number;
var startX:Number;
var startY:Number;
var topLeftGridY:Number;
var topLeftGridX:Number;
var mainCharMathExt:mathExt;
var topRightGridY:Number;
var topRightGridX:Number;
var speed:Number;
var gridYSize:int;
var STATIC:int;// = 3
var falling:Boolean;// = false
var score:int;// = 0
var jumpLength:Number;
var charDirection:int;
var topLeftY:Number;
var topLeftX:Number;
var rightBoost:Boolean;// = false
var STATIC_RIGHT:int;// = 5
var gridXSize:int;
var jumpHeight:Number;
var jumping:Boolean;
var dieLimit:Number;// = 400
var totalBonuses:int;// = 0
var dying:Boolean;// = false
var STATIC_LEFT:int;// = 4
var dieCounter:Number;// = 0
var topRightY:Number;
var topRightX:Number;
var jumpPointVertical:Number;
var firstUpdate:Boolean;// = true
var rightBoostSpeed:Number;// = 1
var bottomRightGridX:Number;
var bottomRightGridY:Number;
var die1:dieSound;
var coin1:coinSound;
var bottomRightY:Number;
var jump1:jumpSound;
var bottomLeftX:Number;
var bottomRightX:Number;
var leftBoostSpeed:Number;// = 1
var charGridXs:Array;
var leftBoost:Boolean;// = false
var bottomLeftY:Number;
var dieHeight:Number;// = 25
var RIGHT:int;// = 1
var charGridYs:Array;
public function mainChar(_arg1:Number, _arg2:int, _arg3:int, _arg4:Number, _arg5:Number, _arg6:int, _arg7:int, _arg8){
firstUpdate = true;
LEFT = 0;
RIGHT = 1;
STATIC = 3;
STATIC_LEFT = 4;
STATIC_RIGHT = 5;
jumpPressed = false;
falling = false;
dieHeight = 25;
dying = false;
dieCounter = 0;
dieLimit = 400;
leftBoost = false;
rightBoost = false;
leftBoostSpeed = 1;
rightBoostSpeed = 1;
totalBonuses = 0;
score = 0;
jump1 = new jumpSound();
coin1 = new coinSound();
die1 = new dieSound();
super();
addFrameScript(0, frame1, 1, frame2, 2, frame3, 3, frame4, 4, frame5, 5, frame6, 6, frame7);
mainCharMathExt = new mathExt(_arg6, _arg7);
speed = _arg1;
gridXSize = _arg2;
gridYSize = _arg3;
charWidth = _arg4;
charHeight = _arg5;
jumpHeight = _arg8;
jumping = false;
jumpPoint = 0;
charDirection = STATIC_RIGHT;
this.gotoAndPlay("standRight");
charGridXs = new Array();
charGridYs = new Array();
setLocalHitBox(3, 3, (gridXSize - 3), (gridYSize - 3));
}
function moveTest(_arg1:Array):Boolean{
var _local2:Boolean;
var _local3:int;
var _local4:int;
var _local5:int;
_local2 = true;
_local3 = charGridXs.length;
_local4 = 0;
while (_local4 < _local3) {
_local5 = mainCharMathExt.convertToIndex(charGridXs[_local4], charGridYs[_local4]);
switch (_arg1[_local5]){
case 0:
break;
case 1:
leftBoost = false;
rightBoost = false;
_local2 = false;
break;
case 2:
if ((((prospectiveY > y)) && (!((((prospectiveY + (charHeight - 1)) - ((prospectiveY + (charHeight - 1)) % gridYSize)) == ((y + (charHeight - 1)) - ((y + (charHeight - 1)) % gridYSize))))))){
leftBoost = false;
rightBoost = false;
_local2 = false;
};
break;
case 50:
case 51:
case 52:
if (prospectiveY > y){
leftBoost = true;
_local2 = false;
} else {
leftBoost = false;
rightBoost = false;
_local2 = false;
};
break;
case 53:
case 54:
case 55:
if (prospectiveY > y){
rightBoost = true;
_local2 = false;
} else {
leftBoost = false;
rightBoost = false;
_local2 = false;
};
break;
default:
break;
};
_local4++;
};
return (_local2);
}
public function getHeight():Number{
return (charHeight);
}
public function getWidth():Number{
return (charWidth);
}
function frame2(){
stop();
}
function frame3(){
stop();
}
function frame4(){
stop();
}
function frame5(){
stop();
}
public function getBonus(){
}
function frame7(){
stop();
}
function frame1(){
stop();
}
public function die(){
die1.play();
dying = true;
this.gotoAndStop("dying");
jumping = false;
jumpPoint = 0;
}
function frame6(){
stop();
}
public function update(_arg1:Array, _arg2:Array, _arg3:Array, _arg4:Number, _arg5:int):int{
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:int;
var _local10:int;
var _local11:int;
var _local12:int;
var _local13:int;
var _local14:Number;
var _local15:Number;
var _local16:Boolean;
if (firstUpdate){
firstUpdate = false;
startX = x;
startY = y;
totalBonuses = _arg3.length;
};
if (!dying){
switch (charDirection){
case LEFT:
prospectiveX = (x - (speed * _arg4));
prospectiveY = y;
break;
case RIGHT:
prospectiveX = (x + (speed * _arg4));
prospectiveY = y;
break;
case STATIC_LEFT:
prospectiveX = x;
prospectiveY = y;
break;
case STATIC_RIGHT:
prospectiveX = x;
prospectiveY = y;
break;
default:
prospectiveX = x;
prospectiveY = y;
break;
};
if (leftBoost){
prospectiveX = (prospectiveX - (leftBoostSpeed * _arg4));
};
if (rightBoost){
prospectiveX = (prospectiveX + (rightBoostSpeed * _arg4));
};
if (prospectiveX > x){
_local14 = -1;
} else {
if (prospectiveX < x){
_local14 = 1;
} else {
if (prospectiveX == x){
_local14 = 0;
} else {
_local14 = 0;
};
};
};
if (prospectiveY > y){
_local15 = -1;
} else {
if (prospectiveY < y){
_local15 = 1;
} else {
if (prospectiveY == y){
_local15 = 0;
} else {
_local15 = 0;
};
};
};
while (!((((prospectiveX == x)) && ((prospectiveY == y))))) {
updateCorners();
if (moveTest(_arg1)){
x = prospectiveX;
y = prospectiveY;
break;
};
prospectiveX = (prospectiveX + _local14);
prospectiveY = (prospectiveY + _local15);
};
prospectiveX = x;
prospectiveY = (y + (speed * _arg4));
if (jumping){
jumpPoint = (jumpPoint + (speed * _arg4));
if (jumpPoint > jumpHeight){
jumping = false;
jumpPoint = 0;
switch (charDirection){
case LEFT:
this.gotoAndStop("walkLeft");
break;
case RIGHT:
this.gotoAndStop("walkRight");
break;
case STATIC_RIGHT:
this.gotoAndStop("standRight");
break;
case STATIC_LEFT:
this.gotoAndStop("standLeft");
break;
default:
break;
};
} else {
if (jumpPoint < (jumpHeight / 2)){
_local6 = ((jumpHeight / 2) - jumpPoint);
} else {
_local6 = (jumpPoint - (jumpHeight / 2));
};
};
if (jumping){
jumpPointVertical = Math.sqrt((Math.pow((jumpHeight / 2), 2) - Math.pow(_local6, 2)));
prospectiveY = (jumpBaseY - jumpPointVertical);
};
};
if (prospectiveX > x){
_local14 = -1;
} else {
if (prospectiveX < x){
_local14 = 1;
} else {
if (prospectiveX == x){
_local14 = 0;
} else {
_local14 = 0;
};
};
};
if (prospectiveY > y){
_local15 = -1;
} else {
if (prospectiveY < y){
_local15 = 1;
} else {
if (prospectiveY == y){
_local15 = 0;
} else {
_local15 = 0;
};
};
};
_local16 = true;
while (!((((prospectiveX == x)) && ((prospectiveY == y))))) {
updateCorners();
_local16 = moveTest(_arg1);
if (_local16){
if (prospectiveY > y){
falling = true;
};
x = prospectiveX;
y = prospectiveY;
break;
};
prospectiveX = (prospectiveX + _local14);
prospectiveY = (prospectiveY + _local15);
};
if (!_local16){
if (falling){
switch (charDirection){
case LEFT:
this.gotoAndStop("walkLeft");
break;
case RIGHT:
this.gotoAndStop("walkRight");
break;
case STATIC_RIGHT:
this.gotoAndStop("standRight");
break;
case STATIC_LEFT:
this.gotoAndStop("standLeft");
break;
default:
break;
};
};
falling = false;
jumpPoint = 0;
};
refreshHitBox();
_local12 = _arg2.length;
_local13 = 0;
while (_local13 < _arg2.length) {
if (hitBoxTest(_arg2[_local13])){
die();
};
_local13++;
};
_local12 = _arg3.length;
_local13 = 0;
while (_local13 < _arg3.length) {
if (hitTestObject(_arg3[_local13])){
coin1.play();
_arg3[_local13].die(_arg5);
score = (score + _arg5);
totalBonuses--;
};
_local13++;
};
} else {
dieCounter = (dieCounter + (speed * _arg4));
if (dieCounter > dieHeight){
y = (y + ((speed * 4) * _arg4));
if (y > dieLimit){
x = startX;
y = startY;
dying = false;
this.gotoAndPlay("standRight");
dieCounter = 0;
};
} else {
y = (y - ((speed * 4) * _arg4));
};
};
return (totalBonuses);
}
public function startRight(){
if (charDirection != RIGHT){
if (!jumping){
if (!dying){
this.gotoAndStop("walkRight");
};
} else {
if (!dying){
this.gotoAndStop("jumpRight");
};
};
};
charDirection = RIGHT;
}
function inGridSquare(_arg1:Number, _arg2:Number):Boolean{
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
_local3 = (_arg1 + (charWidth - 1));
_local4 = _arg2;
_local5 = _arg1;
_local6 = _arg2;
_local7 = (_arg1 + (charWidth - 1));
_local8 = (_arg2 + (charHeight - 1));
_local9 = _arg1;
_local10 = (_arg2 + (charHeight - 1));
if ((((((mainCharMathExt.convertToIndex(_local3, _local4) == mainCharMathExt.convertToIndex(_local5, _local6))) && ((mainCharMathExt.convertToIndex(_local3, _local4) == mainCharMathExt.convertToIndex(_local9, _local10))))) && ((mainCharMathExt.convertToIndex(_local3, _local4) == mainCharMathExt.convertToIndex(_local7, _local8))))){
return (true);
};
return (false);
}
public function getScore(){
return (score);
}
public function stopRight(){
if (!dying){
this.gotoAndStop("standRight");
};
charDirection = STATIC_RIGHT;
}
public function setScore(_arg1:int){
score = _arg1;
}
public function stopLeft(){
if (!dying){
this.gotoAndStop("standLeft");
};
charDirection = STATIC_LEFT;
}
public function stopJump(){
jumping = false;
jumpPressed = false;
}
public function kill(){
mainCharMathExt = null;
}
public function startLeft(){
if (charDirection != LEFT){
if (!jumping){
if (!dying){
this.gotoAndStop("walkLeft");
};
} else {
if (!dying){
this.gotoAndStop("jumpLeft");
};
};
};
charDirection = LEFT;
}
public function startJump(){
if ((((((((jumping == false)) && ((jumpPressed == false)))) && ((jumpPoint == 0)))) && ((falling == false)))){
if ((((charDirection == RIGHT)) || ((charDirection == STATIC_RIGHT)))){
if (!dying){
jump1.play();
this.gotoAndStop("jumpRight");
};
} else {
if ((((charDirection == LEFT)) || ((charDirection == STATIC_LEFT)))){
if (!dying){
jump1.play();
this.gotoAndStop("jumpLeft");
};
};
};
jumping = true;
jumpPressed = true;
jumpBaseY = y;
};
}
function updateCorners(){
var _local1:int;
charGridXs = new Array();
charGridYs = new Array();
topRightX = (prospectiveX + (charWidth - 1));
topRightY = prospectiveY;
topLeftX = prospectiveX;
topLeftY = prospectiveY;
bottomRightX = (prospectiveX + (charWidth - 1));
bottomRightY = (prospectiveY + (charHeight - 1));
bottomLeftX = prospectiveX;
bottomLeftY = (prospectiveY + (charHeight - 1));
topRightGridX = int(((topRightX - (topRightX % gridXSize)) / gridXSize));
topRightGridY = int(((topRightY - (topRightY % gridYSize)) / gridYSize));
topLeftGridX = int(((topLeftX - (topLeftX % gridXSize)) / gridXSize));
topLeftGridY = int(((topLeftY - (topLeftY % gridYSize)) / gridYSize));
bottomRightGridX = int(((bottomRightX - (bottomRightX % gridXSize)) / gridXSize));
bottomRightGridY = int(((bottomRightY - (bottomRightY % gridYSize)) / gridYSize));
bottomLeftGridX = int(((bottomLeftX - (bottomLeftX % gridXSize)) / gridXSize));
bottomLeftGridY = int(((bottomLeftY - (bottomLeftY % gridYSize)) / gridYSize));
charGridXs.push(topRightGridX);
charGridYs.push(topRightGridY);
charGridXs.push(bottomRightGridX);
charGridYs.push(bottomRightGridY);
charGridXs.push(topLeftGridX);
charGridYs.push(topLeftGridY);
charGridXs.push(bottomLeftGridX);
charGridYs.push(bottomLeftGridY);
if ((topRightGridX - topLeftGridX) > 1){
_local1 = (topLeftGridX + 1);
while (_local1 < topRightGridX) {
charGridXs.push(_local1);
charGridYs.push(topLeftGridY);
_local1++;
};
};
if ((bottomRightGridX - bottomLeftGridX) > 1){
_local1 = (bottomLeftGridX + 1);
while (_local1 < bottomRightGridX) {
charGridXs.push(_local1);
charGridYs.push(bottomLeftGridY);
_local1++;
};
};
if ((bottomLeftGridY - topLeftGridY) > 1){
_local1 = (topLeftGridY + 1);
while (_local1 < bottomLeftGridY) {
charGridXs.push(topLeftGridX);
charGridYs.push(_local1);
_local1++;
};
};
if ((bottomRightGridY - topRightGridY) > 1){
_local1 = (topRightGridY + 1);
while (_local1 < bottomRightGridY) {
charGridXs.push(topRightGridX);
charGridYs.push(_local1);
_local1++;
};
};
}
}
}//package
Section 152
//mathExt (mathExt)
package {
public class mathExt {
var gridWidth:int;
var gridHeight:int;
public function mathExt(_arg1:int, _arg2:int){
gridWidth = _arg1;
gridHeight = _arg2;
}
public function convertToIndex(_arg1:int, _arg2:int){
return (((_arg2 * gridWidth) + _arg1));
}
public function convertToX(_arg1:int){
return ((_arg1 % gridWidth));
}
public function convertToY(_arg1:int){
return (((_arg1 - (_arg1 % gridWidth)) / gridWidth));
}
public function adjustYFor3D(_arg1:Number, _arg2:Number):Number{
return (((-1 * (_arg1 - 180)) - (_arg2 / 2)));
}
public function adjustXFor3D(_arg1:Number, _arg2:Number):Number{
return (((_arg1 - 320) + (_arg2 / 2)));
}
public function randRange(_arg1:Number, _arg2:Number):Number{
var _local3:Number;
_local3 = (Math.floor((Math.random() * ((_arg2 - _arg1) + 1))) + _arg1);
return (_local3);
}
}
}//package
Section 153
//musicSound (musicSound)
package {
import flash.media.*;
public dynamic class musicSound extends Sound {
}
}//package
Section 154
//readOut (readOut)
package {
import flash.display.*;
import flash.text.*;
public dynamic class readOut extends MovieClip {
public var timerText:TextField;
public var scoreText:TextField;
}
}//package
Section 155
//rightConveyorLeft (rightConveyorLeft)
package {
import flash.display.*;
public dynamic class rightConveyorLeft extends MovieClip {
}
}//package
Section 156
//rightConveyorMiddle (rightConveyorMiddle)
package {
import flash.display.*;
public dynamic class rightConveyorMiddle extends MovieClip {
}
}//package
Section 157
//rightConveyorMiddleBase (rightConveyorMiddleBase)
package {
import flash.display.*;
public dynamic class rightConveyorMiddleBase extends MovieClip {
}
}//package
Section 158
//rightConveyorRight (rightConveyorRight)
package {
import flash.display.*;
public dynamic class rightConveyorRight extends MovieClip {
}
}//package
Section 159
//SkyBG (SkyBG)
package {
import flash.display.*;
public dynamic class SkyBG extends MovieClip {
}
}//package
Section 160
//spikes (spikes)
package {
public class spikes extends enemy {
public function spikes(){
isStationary = true;
}
}
}//package
Section 161
//spikes2 (spikes2)
package {
public class spikes2 extends spikes {
}
}//package
Section 162
//spikes3 (spikes3)
package {
public class spikes3 extends spikes {
}
}//package
Section 163
//spikes4 (spikes4)
package {
public class spikes4 extends spikes {
}
}//package
Section 164
//spikesBottomTexture (spikesBottomTexture)
package {
import flash.display.*;
public dynamic class spikesBottomTexture extends MovieClip {
}
}//package
Section 165
//stand (stand)
package {
import flash.display.*;
public dynamic class stand extends MovieClip {
}
}//package
Section 166
//standLeft (standLeft)
package {
import flash.display.*;
public dynamic class standLeft extends MovieClip {
}
}//package
Section 167
//standRight (standRight)
package {
import flash.display.*;
public dynamic class standRight extends MovieClip {
}
}//package
Section 168
//Symbol7 (Symbol7)
package {
import flash.display.*;
public dynamic class Symbol7 extends MovieClip {
}
}//package
Section 169
//Symbol8 (Symbol8)
package {
import flash.display.*;
public dynamic class Symbol8 extends MovieClip {
}
}//package
Section 170
//Symbol9 (Symbol9)
package {
import flash.display.*;
public dynamic class Symbol9 extends MovieClip {
}
}//package
Section 171
//textureBonus (textureBonus)
package {
import flash.display.*;
public dynamic class textureBonus extends MovieClip {
}
}//package
Section 172
//textureEnemy (textureEnemy)
package {
import flash.display.*;
public dynamic class textureEnemy extends MovieClip {
}
}//package
Section 173
//titleScreen (titleScreen)
package {
import flash.display.*;
public dynamic class titleScreen extends MovieClip {
public var start:titleScreenStartButton;
}
}//package
Section 174
//titleScreenStartButton (titleScreenStartButton)
package {
import flash.display.*;
public dynamic class titleScreenStartButton extends MovieClip {
}
}//package
Section 175
//Tree (Tree)
package {
import flash.display.*;
public dynamic class Tree extends MovieClip {
}
}//package
Section 176
//walkLeft (walkLeft)
package {
import flash.display.*;
public dynamic class walkLeft extends MovieClip {
}
}//package
Section 177
//walkRight (walkRight)
package {
import flash.display.*;
public dynamic class walkRight extends MovieClip {
}
}//package
Section 178
//WhiteCloud (WhiteCloud)
package {
import flash.display.*;
public dynamic class WhiteCloud extends MovieClip {
}
}//package