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 flash.utils.*;
public class ObjectTools {
public function resolveBaseType(_arg1:Object):String{
return ("");
}
public static function getFullClassPath(_arg1:Object):String{
var _local2:Array;
var _local3:String;
_local2 = [];
_local3 = getQualifiedClassName(_arg1);
_local3 = ((_local3.indexOf("::") > -1)) ? _local3.split("::").join(".") : _local3;
_local2.push(_local3);
return (_local2.join("."));
}
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));
}
}
}//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 flash.net.*;
import com.blitzagency.xray.logger.events.*;
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 pMsg = _arg1;
var pPackage = _arg2;
var pLevel = _arg3;
ed.sendEvent(DebugDispatcher.TRACE, {message:pMsg, classPackage:pPackage});
if (!connected){
makeConnection();
};
if (connected){
try {
xrayLC.send("_xray_view_conn", "setTrace", pMsg, 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");
xrayLC.close();
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:Object, _arg3:String, _arg4:String, _arg5:Number):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, _arg2=""):void{
logger.debug(new Log(_arg1, _arg2, XrayLogger.DEBUG));
}
public function fatal(_arg1:String, _arg2=""):void{
logger.fatal(new Log(_arg1, _arg2, XrayLogger.FATAL));
}
public function info(_arg1:String, _arg2=""):void{
logger.info(new Log(_arg1, _arg2, XrayLogger.INFO));
}
public function warn(_arg1:String, _arg2=""):void{
logger.warn(new Log(_arg1, _arg2, XrayLogger.WARN));
}
public function error(_arg1:String, _arg2=""):void{
logger.error(new Log(_arg1, _arg2, XrayLogger.ERROR));
}
}
}//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.getDump(), _arg1.getCaller(), _arg1.getClassPackage(), 0);
};
}
public function setIndentation(_arg1:Number=0):void{
indentation = _arg1;
}
public function error(_arg1:Log):void{
if (_arg1.getLevel() >= level){
log(_arg1.getMessage(), _arg1.getDump(), _arg1.getCaller(), _arg1.getClassPackage(), 3);
};
}
public function setLevel(_arg1:Number=0):void{
level = _arg1;
}
public function fatal(_arg1:Log):void{
if (_arg1.getLevel() >= level){
log(_arg1.getMessage(), _arg1.getDump(), _arg1.getCaller(), _arg1.getClassPackage(), 4);
};
}
public function warn(_arg1:Log):void{
if (_arg1.getLevel() >= level){
log(_arg1.getMessage(), _arg1.getDump(), _arg1.getCaller(), _arg1.getClassPackage(), 2);
};
}
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.getDump(), _arg1.getCaller(), _arg1.getClassPackage(), 1);
};
}
public function log(_arg1:String, _arg2:Object, _arg3:String, _arg4:String, _arg5:Number):void{
var _local6:String;
var _local7:String;
var _local8:String;
var _local9:Object;
_local6 = (("(" + getTimer()) + ") ");
if (_arg4.length > 0){
_local6 = (_local6 + (_arg3 + "\n"));
};
_local6 = (_local6 + _arg1);
Debug.trace(_local6, _arg4, _arg5);
_local7 = typeof(_arg2);
if ((((((((((_local7 == "string")) || ((_local7 == "number")))) || ((_local7 == "boolean")))) || ((_local7 == "undefined")))) || ((_local7 == "null")))){
Debug.trace(_arg2, _arg4, _arg5);
} else {
if (_local7 == "xml"){
Debug.trace(_arg2.toString(), _arg4, _arg5);
} else {
_local8 = ObjectTools.getImmediateClassPath(_arg2);
if ((((_local8 == "Object")) || ((_local8 == "Object.Array")))){
Debug.traceObject(_arg2, objectRecursionDepth, indentation, _arg4, _arg5);
} else {
_local9 = PropertyTools.getProperties(_arg2);
Debug.traceObject(_local9, displayObjectRecursionDepth, indentation, _arg4, _arg5);
};
};
};
}
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
//Histogram (de.popforge.imageprocessing.core.Histogram)
package de.popforge.imageprocessing.core {
import flash.display.*;
import flash.geom.*;
import de.popforge.imageprocessing.errors.*;
public final class Histogram {
public var maxPeak:int;
private var h:int;
private var imageDimension:int;
public var channels:Array;
private var numChannels:int;
public var format:int;
private var w:int;
public static var DETAIL:int = 4;
public function Histogram(_arg1:Image=null){
format = 0xFF;
if (_arg1 != null){
analyze(_arg1);
};
}
public function getValue(_arg1:int):int{
var _local2:int;
var _local3:int;
if (_arg1 > 254){
_arg1 = 254;
};
if (_arg1 < 0){
_arg1 = 0;
};
if (channels.length == 1){
return (channels[0][_arg1]);
};
_local2 = channels[0][_arg1];
_local3 = 1;
while (_local3 < channels.length) {
if (channels[_local3][_arg1] < _local2){
_local2 = channels[_local3][_arg1];
};
_local3++;
};
return (_local2);
}
public function clone():Histogram{
var _local1:Histogram;
var _local2:int;
_local1 = new Histogram();
_local1.format = format;
_local1.maxPeak = maxPeak;
if (channels != null){
_local1.channels = new Array();
_local2 = 0;
while (_local2 < channels.length) {
_local1.channels.push((channels[_local2] as Array).slice());
_local2++;
};
};
return (_local1);
}
private function getArray():Array{
return (new Array(0x0100));
}
public function getBitmapData(_arg1:int=0x0100, _arg2:int=0x0100, _arg3:Boolean=false):BitmapData{
var _local4:BitmapData;
var _local5:BitmapData;
var _local6:Array;
var _local7:Rectangle;
var _local8:int;
var _local9:Number;
var _local10:int;
var _local11:Array;
var _local12:int;
var _local13:int;
var _local14:int;
_local4 = new BitmapData(_arg1, _arg2, false, 0);
_local7 = new Rectangle(0, 0, (_arg1 / 0x0100), 0);
_local8 = maxPeak;
if (_arg3){
_local11 = new Array();
_local10 = 0;
while (_local10 < channels.length) {
_local11 = _local11.concat(channels[_local10]);
_local10++;
};
_local11.sort(Array.NUMERIC);
_local13 = _local11.length;
if ((_local13 & 1) == 0){
_local8 = _local11[int(((_local13 | 1) >> 1))];
} else {
_local13 = (_local13 >> 1);
_local8 = int((0.5 + (0.5 * (_local11[int((_local13 + 1))] + _local11[int((_local13 - 1))]))));
};
};
switch (format){
case ImageFormat.BINARY:
_local7.width = (_arg1 / 2);
case ImageFormat.GRAYSCALE:
_local6 = new Array();
_local6.push(0xFFFFFF);
break;
case ImageFormat.RGB:
_local6 = new Array(0xFF0000, 0xFF00, 0xFF);
break;
case ImageFormat.RGBA:
_local6 = new Array(0xFF0000, 0xFF00, 0xFF);
break;
default:
throw (new InvalidImageFormatError());
};
_local10 = 0;
while (_local10 < channels.length) {
if (_local10 == ImageChannel.ALPHA){
} else {
_local5 = new BitmapData(_arg1, _arg2, false, 0);
_local14 = 0;
while (_local14 < channels[_local10].length) {
_local9 = (channels[_local10][_local14] / _local8);
if (_local9 > 1){
_local9 = 1;
};
_local7.x = (_local14 * _local7.width);
_local7.height = (_local9 * _arg2);
_local7.y = (_arg2 - _local7.height);
_local5.fillRect(_local7, _local6[_local10]);
_local14++;
};
_local4.draw(_local5, null, null, BlendMode.ADD);
_local5.dispose();
};
_local10++;
};
return (_local4);
}
private function initChannels():void{
var _local1:int;
var _local2:int;
_local1 = 0;
channels = new Array();
switch (format){
case ImageFormat.BINARY:
channels.push(new Array(0, 0));
return;
case ImageFormat.GRAYSCALE:
_local1 = 1;
break;
case ImageFormat.RGB:
_local1 = 3;
break;
case ImageFormat.RGBA:
_local1 = 4;
break;
default:
throw (new InvalidImageFormatError());
};
_local2 = 0;
while (_local2 < _local1) {
channels.push(getArray());
_local2++;
};
}
public function getCount(_arg1:int, _arg2:int):int{
var _local3:int;
var _local4:Array;
var _local5:int;
var _local6:int;
if (_arg1 > 0xFF){
_arg1 = 0xFF;
};
if (_arg1 < 0){
_arg1 = 0;
};
if (_arg2 > 0xFF){
_arg2 = 0xFF;
};
if (_arg2 < 0){
_arg2 = 0;
};
if (_arg1 > _arg2){
throw (new ArgumentError("Start is higher than end value"));
};
_local3 = 0;
_local5 = 0;
while (_local5 < numChannels) {
_local4 = channels[_local5];
_local6 = _arg1;
while (_local6 < _arg2) {
_local3 = (_local3 + _local4[_local6]);
_local6++;
};
_local5++;
};
return (_local3);
}
public function analyze(_arg1:Image):void{
var _local2:BitmapData;
var _local3:Array;
var _local4:int;
var _local5:int;
var _local6:int;
var _local7:int;
if (format == 0xFF){
format = _arg1.format;
imageDimension = (_arg1.width * _arg1.height);
initChannels();
numChannels = channels.length;
w = _arg1.width;
h = _arg1.height;
};
maxPeak = 0;
_local7 = 0;
while (_local7 < numChannels) {
if (_local7 == ImageChannel.ALPHA){
} else {
_local2 = _arg1.channels[_local7];
_local3 = channels[_local7];
_local5 = 0;
while (_local5 < 0x0100) {
_local3[_local5] = 0;
_local5++;
};
_local5 = 0;
while (_local5 < w) {
_local6 = 0;
while (_local6 < h) {
var _local8 = _local3;
var _local9 = _local2.getPixel(_local5, _local6);
var _local10 = (_local8[_local9] + 1);
_local8[_local9] = _local10;
_local4 = _local10;
if (_local4 > maxPeak){
maxPeak = _local4;
};
_local6 = (_local6 + DETAIL);
};
_local5 = (_local5 + DETAIL);
};
};
_local7++;
};
}
}
}//package de.popforge.imageprocessing.core
Section 11
//IImage (de.popforge.imageprocessing.core.IImage)
package de.popforge.imageprocessing.core {
import flash.display.*;
import flash.geom.*;
import flash.utils.*;
public interface IImage {
function toJPEG(_arg1:int=80):ByteArray;
function get rect():Rectangle;
function get width():int;
function toString():String;
function get height():int;
function getPixel(_arg1:int, _arg2:int):int;
function toPNG(_arg1:Boolean=true):ByteArray;
function render(_arg1:BitmapData):void;
function get format():int;
function get bitmapData():BitmapData;
function getPixel32(_arg1:int, _arg2:int):int;
function loadBitmapData(_arg1:BitmapData, _arg2:Boolean=false, _arg3:Boolean=true):void;
}
}//package de.popforge.imageprocessing.core
Section 12
//Image (de.popforge.imageprocessing.core.Image)
package de.popforge.imageprocessing.core {
import flash.display.*;
import flash.geom.*;
import flash.utils.*;
import de.popforge.imageprocessing.filters.*;
import de.popforge.imageprocessing.filters.color.*;
import de.popforge.imageprocessing.utils.*;
import de.popforge.imageprocessing.errors.*;
import de.popforge.imageprocessing.filters.binarization.*;
import de.popforge.imageprocessing.formats.*;
public final class Image implements IImage {
private var _rect:Rectangle;
private var _height:int;
private var _width:int;
private var _format:int;
public var channels:Array;
public var histogram:Histogram;
public static const origin:Point = new Point();
public static const identity:Matrix = new Matrix();
public static var grayscale:IFilter = new GrayscaleBT709();
public static var threshold:IFilter = new Threshold();
public function Image(_arg1:int, _arg2:int, _arg3:int){
_width = _arg1;
_height = _arg2;
_format = _arg3;
_rect = new Rectangle(0, 0, _arg1, _arg2);
histogram = new Histogram();
initChannels();
}
private function initChannels():void{
var _local1:int;
var _local2:int;
var _local3:int;
var _local4:BitmapData;
if (channels != null){
_local3 = 0;
while (_local3 < channels.length) {
(channels[_local3] as BitmapData).dispose();
_local3++;
};
};
channels = new Array();
switch (format){
case ImageFormat.BINARY:
_local1 = 1;
break;
case ImageFormat.GRAYSCALE:
_local1 = 1;
break;
case ImageFormat.RGB:
_local1 = 3;
break;
case ImageFormat.RGBA:
_local1 = 4;
break;
default:
throw (new InvalidImageFormatError());
};
_local2 = 0;
while (_local2 < _local1) {
_local4 = getBitmapData();
_local4.lock();
channels.push(_local4);
_local2++;
};
}
public function get numChannels():int{
return (channels.length);
}
private function getBitmapData():BitmapData{
return (new BitmapData(width, height, false, 0));
}
public function get width():int{
return (_width);
}
public function updateHistogram():void{
histogram.analyze(this);
}
public function clone():Image{
var _local1:Image;
var _local2:int;
_local1 = new Image(width, height, format);
_local2 = 0;
while (_local2 < channels.length) {
_local1.channels[_local2].draw(channels[_local2]);
_local2++;
};
_local1.histogram = histogram.clone();
return (_local1);
}
public function getPixel(_arg1:int, _arg2:int):int{
var _local3:int;
_local3 = 0;
switch (format){
case ImageFormat.BINARY:
_local3 = BitmapData(channels[ImageChannel.BINARY]).getPixel(_arg1, _arg2);
_local3 = ((_local3)==1) ? 0xFFFFFF : 0;
break;
case ImageFormat.GRAYSCALE:
_local3 = BitmapData(channels[ImageChannel.GRAY]).getPixel(_arg1, _arg2);
_local3 = (_local3 | ((_local3 << 16) | (_local3 << 8)));
break;
case ImageFormat.RGB:
case ImageFormat.RGBA:
_local3 = BitmapData(channels[ImageChannel.BLUE]).getPixel(_arg1, _arg2);
_local3 = (_local3 | (BitmapData(channels[ImageChannel.GREEN]).getPixel(_arg1, _arg2) << 8));
_local3 = (_local3 | (BitmapData(channels[ImageChannel.RED]).getPixel(_arg1, _arg2) << 16));
break;
default:
throw (new InvalidImageFormatError());
};
return (_local3);
}
public function loadBitmapData(_arg1:BitmapData, _arg2:Boolean=false, _arg3:Boolean=true):void{
var bitmap = _arg1;
var convertToGrayscale = _arg2;
var keepSize = _arg3;
if (keepSize){
DimensionTest.isEqual(bitmap, this);
} else {
try {
DimensionTest.isEqual(bitmap, this);
} catch(error:UnequalDimensionsError) {
_rect.width = (_width = bitmap.width);
_rect.height = (_height = bitmap.height);
initChannels();
};
};
switch (format){
case ImageFormat.BINARY:
BitmapData(channels[ImageChannel.BINARY]).draw(bitmap);
if (convertToGrayscale){
_format = ImageFormat.RGB;
grayscale.apply(this);
_format = ImageFormat.BINARY;
};
threshold.apply(this);
break;
case ImageFormat.GRAYSCALE:
if (convertToGrayscale){
BitmapData(channels[ImageChannel.GRAY]).draw(bitmap);
grayscale.apply(this);
} else {
BitmapData(channels[ImageChannel.GRAY]).copyChannel(bitmap, rect, origin, BitmapDataChannel.BLUE, BitmapDataChannel.BLUE);
};
break;
case ImageFormat.RGBA:
BitmapData(channels[ImageChannel.ALPHA]).copyChannel(bitmap, rect, origin, BitmapDataChannel.ALPHA, BitmapDataChannel.BLUE);
case ImageFormat.RGB:
BitmapData(channels[ImageChannel.RED]).copyChannel(bitmap, rect, origin, BitmapDataChannel.RED, BitmapDataChannel.BLUE);
BitmapData(channels[ImageChannel.GREEN]).copyChannel(bitmap, rect, origin, BitmapDataChannel.GREEN, BitmapDataChannel.BLUE);
BitmapData(channels[ImageChannel.BLUE]).copyChannel(bitmap, rect, origin, BitmapDataChannel.BLUE, BitmapDataChannel.BLUE);
break;
default:
throw (new InvalidImageFormatError());
};
}
public function toJPEG(_arg1:int=80):ByteArray{
return (JPEG.encode(bitmapData, _arg1));
}
public function render(_arg1:BitmapData):void{
var _local2:Array;
switch (format){
case ImageFormat.BINARY:
_local2 = new Array(0x0100);
_local2[0] = 0;
_local2[1] = 4294967295;
_arg1.paletteMap((channels[ImageChannel.BINARY] as BitmapData), _arg1.rect, origin, null, null, _local2);
break;
case ImageFormat.GRAYSCALE:
_arg1.copyChannel((channels[ImageChannel.GRAY] as BitmapData), rect, origin, BitmapDataChannel.BLUE, BitmapDataChannel.RED);
_arg1.copyChannel(_arg1, rect, origin, BitmapDataChannel.RED, BitmapDataChannel.GREEN);
_arg1.copyChannel(_arg1, rect, origin, BitmapDataChannel.RED, BitmapDataChannel.BLUE);
break;
case ImageFormat.RGBA:
_arg1.copyChannel((channels[ImageChannel.ALPHA] as BitmapData), rect, origin, BitmapDataChannel.BLUE, BitmapDataChannel.ALPHA);
case ImageFormat.RGB:
_arg1.copyChannel((channels[ImageChannel.RED] as BitmapData), rect, origin, BitmapDataChannel.BLUE, BitmapDataChannel.RED);
_arg1.copyChannel((channels[ImageChannel.GREEN] as BitmapData), rect, origin, BitmapDataChannel.BLUE, BitmapDataChannel.GREEN);
_arg1.copyChannel((channels[ImageChannel.BLUE] as BitmapData), rect, origin, BitmapDataChannel.BLUE, BitmapDataChannel.BLUE);
break;
default:
throw (new InvalidImageFormatError());
};
}
public function dispose():void{
var _local1:int;
_local1 = 0;
while (_local1 < channels.length) {
BitmapData(channels[_local1]).dispose();
_local1++;
};
}
public function get height():int{
return (_height);
}
public function get rect():Rectangle{
return (_rect);
}
public function toPNG(_arg1:Boolean=true):ByteArray{
return (PNG.encode(bitmapData, (_arg1) ? PNG.RGBA : PNG.RGB));
}
public function getMeanValue(_arg1:int):Number{
var _local2:int;
var _local3:BitmapData;
var _local4:int;
var _local5:int;
if ((((_arg1 < 0)) || ((_arg1 >= channels.length)))){
throw (new InvalidChannelError());
};
_local2 = 0;
_local3 = channels[_arg1];
_local4 = 0;
while (_local4 < width) {
_local5 = 0;
while (_local5 < height) {
_local2 = (_local2 + _local3.getPixel(_local4, _local5));
_local5++;
};
_local4++;
};
_local2 = (_local2 / (width * height));
return (_local2);
}
public function get format():int{
return (_format);
}
public function get bitmapData():BitmapData{
var _local1:BitmapData;
_local1 = new BitmapData(width, height, (format == ImageFormat.RGBA), 0);
render(_local1);
return (_local1);
}
public function toString():String{
var _local1:String;
switch (format){
case ImageFormat.BINARY:
_local1 = "ImageFormat.BINARY";
break;
case ImageFormat.GRAYSCALE:
_local1 = "ImageFormat.GRAYSCALE";
break;
case ImageFormat.RGB:
_local1 = "ImageFormat.RGB";
break;
case ImageFormat.RGBA:
_local1 = "ImageFormat.RGBA";
break;
default:
_local1 = "Unknown";
};
return ((((((("[Image dim: " + width) + "x") + height) + ", format: ") + _local1) + "]"));
}
public function getPixel32(_arg1:int, _arg2:int):int{
var _local3:int;
_local3 = 0;
switch (format){
case ImageFormat.BINARY:
case ImageFormat.GRAYSCALE:
case ImageFormat.RGB:
_local3 = getPixel(_arg1, _arg2);
_local3 = (_local3 | (0xFF << 24));
break;
case ImageFormat.RGBA:
_local3 = BitmapData(channels[ImageChannel.BLUE]).getPixel(_arg1, _arg2);
_local3 = (_local3 | (BitmapData(channels[ImageChannel.GREEN]).getPixel(_arg1, _arg2) << 8));
_local3 = (_local3 | (BitmapData(channels[ImageChannel.RED]).getPixel(_arg1, _arg2) << 16));
_local3 = (_local3 | (BitmapData(channels[ImageChannel.ALPHA]).getPixel(_arg1, _arg2) << 24));
break;
default:
throw (new InvalidImageFormatError());
};
return (_local3);
}
public static function fromBitmapData(_arg1:BitmapData, _arg2:int, _arg3:Boolean=false):Image{
var _local4:Image;
_local4 = new Image(_arg1.width, _arg1.height, _arg2);
_local4.loadBitmapData(_arg1, _arg3);
return (_local4);
}
}
}//package de.popforge.imageprocessing.core
Section 13
//ImageChannel (de.popforge.imageprocessing.core.ImageChannel)
package de.popforge.imageprocessing.core {
public final class ImageChannel {
public static const BINARY:int = 0;
public static const GRAY:int = 0;
public static const GREEN:int = 1;
public static const RED:int = 0;
public static const BLUE:int = 2;
public static const ALPHA:int = 3;
}
}//package de.popforge.imageprocessing.core
Section 14
//ImageFormat (de.popforge.imageprocessing.core.ImageFormat)
package de.popforge.imageprocessing.core {
public final class ImageFormat {
public static const BINARY:int = 1;
public static const RGBA:int = 8;
public static const GRAYSCALE:int = 2;
public static const RGB:int = 4;
}
}//package de.popforge.imageprocessing.core
Section 15
//InvalidChannelError (de.popforge.imageprocessing.errors.InvalidChannelError)
package de.popforge.imageprocessing.errors {
import flash.events.*;
public final class InvalidChannelError extends ErrorEvent {
public function InvalidChannelError(){
super("Invalid Channel");
}
}
}//package de.popforge.imageprocessing.errors
Section 16
//InvalidImageFormatError (de.popforge.imageprocessing.errors.InvalidImageFormatError)
package de.popforge.imageprocessing.errors {
import flash.events.*;
public final class InvalidImageFormatError extends ErrorEvent {
public function InvalidImageFormatError(){
super("Invalid or unknown ImageFormat");
}
}
}//package de.popforge.imageprocessing.errors
Section 17
//UnequalDimensionsError (de.popforge.imageprocessing.errors.UnequalDimensionsError)
package de.popforge.imageprocessing.errors {
import flash.events.*;
public final class UnequalDimensionsError extends ErrorEvent {
public function UnequalDimensionsError(_arg1:int, _arg2:int, _arg3:int, _arg4:int){
super(((((((("Dimensions are not equal. " + _arg1) + "x") + _arg2) + " != ") + _arg3) + "x") + _arg4));
}
}
}//package de.popforge.imageprocessing.errors
Section 18
//Threshold (de.popforge.imageprocessing.filters.binarization.Threshold)
package de.popforge.imageprocessing.filters.binarization {
import flash.display.*;
import de.popforge.imageprocessing.core.*;
import de.popforge.imageprocessing.filters.*;
import de.popforge.imageprocessing.utils.*;
public final class Threshold implements IFilter {
private var thresholdValue:int;
private var threshold:Array;
public function Threshold(_arg1:int=128){
this.thresholdValue = _arg1;
threshold = new Array(0x0100);
updateTable();
}
protected function updateTable():void{
var _local1:int;
_local1 = 0;
while (_local1 < 0x0100) {
threshold[_local1] = ((_local1)>=thresholdValue) ? 1 : 0;
_local1++;
};
}
public function toString():String{
return ("[Threshold]");
}
public function apply(_arg1:Image):void{
var _local2:BitmapData;
FormatTest.require(_arg1, ImageFormat.BINARY);
_local2 = _arg1.channels[ImageChannel.BINARY];
_local2.paletteMap(_local2, _arg1.rect, Image.origin, null, null, threshold, null);
}
}
}//package de.popforge.imageprocessing.filters.binarization
Section 19
//Grayscale (de.popforge.imageprocessing.filters.color.Grayscale)
package de.popforge.imageprocessing.filters.color {
import flash.display.*;
import de.popforge.imageprocessing.core.*;
import de.popforge.imageprocessing.filters.*;
import flash.filters.*;
import de.popforge.imageprocessing.utils.*;
public class Grayscale implements IFilter {
private var colorMatrix:ColorMatrixFilter;
public function Grayscale(_arg1:Number, _arg2:Number, _arg3:Number){
colorMatrix = new ColorMatrixFilter();
colorMatrix.matrix = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, _arg1, _arg2, _arg3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
}
public function toString():String{
return ("[Grayscale]");
}
public function apply(_arg1:Image):void{
var _local2:BitmapData;
var _local3:int;
FormatTest.deny(_arg1, ImageFormat.BINARY);
_local3 = 0;
while (_local3 < _arg1.numChannels) {
_local2 = _arg1.channels[_local3];
_local2.applyFilter(_local2, _arg1.rect, Image.origin, colorMatrix);
_local3++;
};
}
}
}//package de.popforge.imageprocessing.filters.color
Section 20
//GrayscaleBT709 (de.popforge.imageprocessing.filters.color.GrayscaleBT709)
package de.popforge.imageprocessing.filters.color {
public final class GrayscaleBT709 extends Grayscale {
public function GrayscaleBT709(){
super(0.2125, 0.7154, 0.0721);
}
override public function toString():String{
return ("[GrayscaleBT709]");
}
}
}//package de.popforge.imageprocessing.filters.color
Section 21
//Sepia (de.popforge.imageprocessing.filters.color.Sepia)
package de.popforge.imageprocessing.filters.color {
import flash.display.*;
import de.popforge.imageprocessing.core.*;
import de.popforge.imageprocessing.filters.*;
import de.popforge.imageprocessing.utils.*;
public final class Sepia implements IFilter {
public function apply(_arg1:Image):void{
var _local2:Number;
var _local3:int;
var _local4:int;
var _local5:int;
var _local6:BitmapData;
var _local7:BitmapData;
var _local8:BitmapData;
var _local9:int;
var _local10:int;
FormatTest.require(_arg1, (ImageFormat.RGB | ImageFormat.RGBA));
_local6 = _arg1.channels[ImageChannel.RED];
_local7 = _arg1.channels[ImageChannel.GREEN];
_local8 = _arg1.channels[ImageChannel.BLUE];
_local9 = 0;
while (_local9 < _arg1.width) {
_local10 = 0;
while (_local10 < _arg1.height) {
_local3 = _local6.getPixel(_local9, _local10);
_local4 = _local7.getPixel(_local9, _local10);
_local5 = _local8.getPixel(_local9, _local10);
_local2 = (((0.299 * _local3) + (0.587 * _local4)) + (0.114 * _local5));
_local6.setPixel(_local9, _local10, ((_local2)>206) ? 0xFF : (_local2 + 49));
_local7.setPixel(_local9, _local10, ((_local2)<14) ? 0 : (_local2 - 14));
_local8.setPixel(_local9, _local10, ((_local2)<56) ? 0 : (_local2 - 56));
_local10++;
};
_local9++;
};
}
public function toString():String{
return ("[Sepia]");
}
}
}//package de.popforge.imageprocessing.filters.color
Section 22
//Convolution (de.popforge.imageprocessing.filters.convolution.Convolution)
package de.popforge.imageprocessing.filters.convolution {
import de.popforge.imageprocessing.filters.*;
import flash.filters.*;
public class Convolution extends NativeFilter {
public function Convolution(){
filter = new ConvolutionFilter();
}
override public function toString():String{
return ("[Convolution]");
}
}
}//package de.popforge.imageprocessing.filters.convolution
Section 23
//Emboss (de.popforge.imageprocessing.filters.convolution.Emboss)
package de.popforge.imageprocessing.filters.convolution {
import flash.filters.*;
public final class Emboss extends Convolution {
public function Emboss(){
init();
}
private function init():void{
var _local1:ConvolutionFilter;
_local1 = ConvolutionFilter(filter);
_local1.matrixX = 3;
_local1.matrixY = 3;
_local1.divisor = 2.2;
_local1.bias = 0;
_local1.matrix = new Array(-4, -2, 0, -2, 2, 2, 0, 2, 4);
}
override public function toString():String{
return ("[Emboss]");
}
}
}//package de.popforge.imageprocessing.filters.convolution
Section 24
//PerlinNoise (de.popforge.imageprocessing.filters.noise.PerlinNoise)
package de.popforge.imageprocessing.filters.noise {
import flash.display.*;
import de.popforge.imageprocessing.core.*;
import de.popforge.imageprocessing.filters.*;
import de.popforge.imageprocessing.errors.*;
public final class PerlinNoise implements IFilter {
private var _fractalNoise:Boolean;
private var _channelOptions:int;
private var _stitch:Boolean;
private var _offsets:Array;
private var noise:BitmapData;
private var cached:Boolean;
private var _baseX:int;
private var _baseY:int;
private var _randomSeed:int;
private var _numOctaves:uint;
public static const CHANNEL_RED:int = 1;
public static const CHANNEL_BLUE:int = 4;
public static const CHANNEL_GREEN:int = 2;
public static const CHANNEL_ALPHA:int = 8;
public static const CHANNEL_GRAY:int = 1;
public function PerlinNoise(_arg1:int=0, _arg2:int=0, _arg3:uint=1, _arg4:int=-1, _arg5:Boolean=false, _arg6:Boolean=false, _arg7:int=1, _arg8:Array=null){
_baseX = _arg1;
_baseY = _arg2;
_numOctaves = _arg3;
_randomSeed = ((_arg4 == -1)) ? (Math.random() * int.MAX_VALUE) : _arg4;
_stitch = _arg5;
_fractalNoise = _arg6;
_channelOptions = _arg7;
_offsets = _arg8;
cached = false;
}
public function get stitch():Boolean{
return (_stitch);
}
public function set cache(_arg1:Boolean):void{
cached = _arg1;
}
private function applyChannel(_arg1:BitmapData, _arg2:int, _arg3:int):void{
if ((_channelOptions & _arg2) != 0){
_arg1.copyChannel(noise, noise.rect, Image.origin, _arg3, BitmapDataChannel.BLUE);
};
}
public function set baseX(_arg1:int):void{
_baseX = _arg1;
cached = false;
}
public function get cache():Boolean{
return (cached);
}
public function get randomSeed():int{
return (_randomSeed);
}
public function set offsets(_arg1:Array):void{
_offsets = _arg1;
cached = false;
}
public function get channelOptions():int{
return (_channelOptions);
}
public function set numOctaves(_arg1:int):void{
_numOctaves = _arg1;
cached = false;
}
public function get numOctaves():int{
return (_numOctaves);
}
public function set fractalNoise(_arg1:Boolean):void{
_fractalNoise = _arg1;
cached = false;
}
public function get baseX():int{
return (_baseX);
}
public function toString():String{
return ("[PerlinNoise]");
}
public function get offsets():Array{
return (_offsets);
}
public function apply(_arg1:Image):void{
if (cached){
if (((!((_arg1.width == noise.width))) || (!((_arg1.height == noise.height))))){
cached = false;
};
};
if (!cached){
if (noise != null){
noise.dispose();
};
noise = new BitmapData(_arg1.width, _arg1.height, true, 0);
noise.perlinNoise(_baseX, _baseY, _numOctaves, _randomSeed, _stitch, _fractalNoise, _channelOptions, false, _offsets);
cached = true;
};
switch (_arg1.format){
case ImageFormat.RGBA:
applyChannel(_arg1.channels[ImageChannel.ALPHA], _slot1.CHANNEL_ALPHA, BitmapDataChannel.ALPHA);
case ImageFormat.RGB:
applyChannel(_arg1.channels[ImageChannel.RED], _slot1.CHANNEL_RED, BitmapDataChannel.RED);
applyChannel(_arg1.channels[ImageChannel.GREEN], _slot1.CHANNEL_GREEN, BitmapDataChannel.GREEN);
applyChannel(_arg1.channels[ImageChannel.BLUE], _slot1.CHANNEL_BLUE, BitmapDataChannel.BLUE);
break;
case ImageFormat.GRAYSCALE:
applyChannel(_arg1.channels[ImageChannel.GRAY], _slot1.CHANNEL_GRAY, BitmapDataChannel.BLUE);
break;
default:
throw (new InvalidImageFormatError());
};
}
public function get baseY():int{
return (_baseY);
}
public function get fractalNoise():Boolean{
return (_fractalNoise);
}
public function set stitch(_arg1:Boolean):void{
_stitch = _arg1;
cached = false;
}
public function set baseY(_arg1:int):void{
_baseY = _arg1;
cached = false;
}
public function set channelOptions(_arg1:int):void{
if (_arg1 > _channelOptions){
cached = false;
};
_channelOptions = _arg1;
}
public function set randomSeed(_arg1:int):void{
_randomSeed = _arg1;
cached = false;
}
}
}//package de.popforge.imageprocessing.filters.noise
Section 25
//IFilter (de.popforge.imageprocessing.filters.IFilter)
package de.popforge.imageprocessing.filters {
import de.popforge.imageprocessing.core.*;
public interface IFilter {
function toString():String;
function apply(_arg1:Image):void;
}
}//package de.popforge.imageprocessing.filters
Section 26
//NativeFilter (de.popforge.imageprocessing.filters.NativeFilter)
package de.popforge.imageprocessing.filters {
import flash.display.*;
import de.popforge.imageprocessing.core.*;
import flash.filters.*;
import de.popforge.imageprocessing.utils.*;
public class NativeFilter implements IFilter {
protected var filter:BitmapFilter;
public function toString():String{
return ("[NativeFilter (override me)]");
}
public function apply(_arg1:Image):void{
var _local2:BitmapData;
FormatTest.deny(_arg1, ImageFormat.BINARY);
_local2 = _arg1.bitmapData;
_local2.applyFilter(_local2, _arg1.rect, Image.origin, filter);
_arg1.loadBitmapData(_local2, true);
_local2.dispose();
}
}
}//package de.popforge.imageprocessing.filters
Section 27
//JPEG (de.popforge.imageprocessing.formats.JPEG)
package de.popforge.imageprocessing.formats {
import flash.display.*;
import flash.utils.*;
public final class JPEG {
private var fdtbl_UV:Array;
private var std_ac_chrominance_values:Array;
private var std_dc_chrominance_nrcodes:Array;
private var std_dc_chrominance_values:Array;
private var ZigZag:Array;
private var YDC_HT:Array;
private var bytenew:int;// = 0
private var fdtbl_Y:Array;
private var YAC_HT:Array;
private var std_ac_chrominance_nrcodes:Array;
private var DU:Array;
private var std_ac_luminance_values:Array;
private var UVTable:Array;
private var UDU:Array;
private var YDU:Array;
private var byteout:ByteArray;
private var UVAC_HT:Array;
private var UVDC_HT:Array;
private var bytepos:int;// = 7
private var VDU:Array;
private var std_ac_luminance_nrcodes:Array;
private var std_dc_luminance_values:Array;
private var YTable:Array;
private var std_dc_luminance_nrcodes:Array;
private var bitcode:Array;
private var category:Array;
private static var init:Boolean = false;
public function JPEG(_arg1:Number){
var _local2:int;
ZigZag = [0, 1, 5, 6, 14, 15, 27, 28, 2, 4, 7, 13, 16, 26, 29, 42, 3, 8, 12, 17, 25, 30, 41, 43, 9, 11, 18, 24, 31, 40, 44, 53, 10, 19, 23, 32, 39, 45, 52, 54, 20, 22, 33, 38, 46, 51, 55, 60, 21, 34, 37, 47, 50, 56, 59, 61, 35, 36, 48, 49, 57, 58, 62, 63];
YTable = new Array(64);
UVTable = new Array(64);
fdtbl_Y = new Array(64);
fdtbl_UV = new Array(64);
std_dc_luminance_nrcodes = [0, 0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0];
std_dc_luminance_values = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11];
std_ac_luminance_nrcodes = [0, 0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 125];
std_ac_luminance_values = [1, 2, 3, 0, 4, 17, 5, 18, 33, 49, 65, 6, 19, 81, 97, 7, 34, 113, 20, 50, 129, 145, 161, 8, 35, 66, 177, 193, 21, 82, 209, 240, 36, 51, 98, 114, 130, 9, 10, 22, 23, 24, 25, 26, 37, 38, 39, 40, 41, 42, 52, 53, 54, 55, 56, 57, 58, 67, 68, 69, 70, 71, 72, 73, 74, 83, 84, 85, 86, 87, 88, 89, 90, 99, 100, 101, 102, 103, 104, 105, 106, 115, 116, 117, 118, 119, 120, 121, 122, 131, 132, 133, 134, 135, 136, 137, 138, 146, 147, 148, 149, 150, 151, 152, 153, 154, 162, 163, 164, 165, 166, 167, 168, 169, 170, 178, 179, 180, 181, 182, 183, 184, 185, 186, 194, 195, 196, 197, 198, 199, 200, 201, 202, 210, 211, 212, 213, 214, 215, 216, 217, 218, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250];
std_dc_chrominance_nrcodes = [0, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0];
std_dc_chrominance_values = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11];
std_ac_chrominance_nrcodes = [0, 0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2, 119];
std_ac_chrominance_values = [0, 1, 2, 3, 17, 4, 5, 33, 49, 6, 18, 65, 81, 7, 97, 113, 19, 34, 50, 129, 8, 20, 66, 145, 161, 177, 193, 9, 35, 51, 82, 240, 21, 98, 114, 209, 10, 22, 36, 52, 225, 37, 241, 23, 24, 25, 26, 38, 39, 40, 41, 42, 53, 54, 55, 56, 57, 58, 67, 68, 69, 70, 71, 72, 73, 74, 83, 84, 85, 86, 87, 88, 89, 90, 99, 100, 101, 102, 103, 104, 105, 106, 115, 116, 117, 118, 119, 120, 121, 122, 130, 131, 132, 133, 134, 135, 136, 137, 138, 146, 147, 148, 149, 150, 151, 152, 153, 154, 162, 163, 164, 165, 166, 167, 168, 169, 170, 178, 179, 180, 181, 182, 183, 184, 185, 186, 194, 195, 196, 197, 198, 199, 200, 201, 202, 210, 211, 212, 213, 214, 215, 216, 217, 218, 226, 227, 228, 229, 230, 231, 232, 233, 234, 242, 243, 244, 245, 246, 247, 248, 249, 250];
bitcode = new Array(0xFFFF);
category = new Array(0xFFFF);
bytenew = 0;
bytepos = 7;
DU = new Array(64);
YDU = new Array(64);
UDU = new Array(64);
VDU = new Array(64);
super();
if (!init){
throw (new Error("Can not create JPEG instance. Please use JPEG.encode() instead."));
};
if (_arg1 <= 0){
_arg1 = 1;
};
if (_arg1 > 100){
_arg1 = 100;
};
_local2 = 0;
if (_arg1 < 50){
_local2 = int((5000 / _arg1));
} else {
_local2 = int((200 - (_arg1 * 2)));
};
initHuffmanTbl();
initCategoryNumber();
initQuantTables(_local2);
}
private function RGB2YUV(_arg1:BitmapData, _arg2:int, _arg3:int):void{
var _local4:int;
var _local5:int;
var _local6:int;
var _local7:uint;
var _local8:Number;
var _local9:Number;
var _local10:Number;
_local4 = 0;
_local5 = 0;
while (_local5 < 8) {
_local6 = 0;
while (_local6 < 8) {
_local7 = _arg1.getPixel32((_arg2 + _local6), (_arg3 + _local5));
_local8 = Number(((_local7 >> 16) & 0xFF));
_local9 = Number(((_local7 >> 8) & 0xFF));
_local10 = Number((_local7 & 0xFF));
YDU[_local4] = ((((0.299 * _local8) + (0.587 * _local9)) + (0.114 * _local10)) - 128);
UDU[_local4] = (((-0.16874 * _local8) + (-0.33126 * _local9)) + (0.5 * _local10));
VDU[_local4] = (((0.5 * _local8) + (-0.41869 * _local9)) + (-0.08131 * _local10));
_local4++;
_local6++;
};
_local5++;
};
}
private function writeWord(_arg1:int):void{
writeByte(((_arg1 >> 8) & 0xFF));
writeByte((_arg1 & 0xFF));
}
private function writeByte(_arg1:int):void{
byteout.writeByte(_arg1);
}
private function writeDHT():void{
var _local1:int;
writeWord(65476);
writeWord(418);
writeByte(0);
_local1 = 0;
while (_local1 < 16) {
writeByte(std_dc_luminance_nrcodes[(_local1 + 1)]);
_local1++;
};
_local1 = 0;
while (_local1 <= 11) {
writeByte(std_dc_luminance_values[_local1]);
_local1++;
};
writeByte(16);
_local1 = 0;
while (_local1 < 16) {
writeByte(std_ac_luminance_nrcodes[(_local1 + 1)]);
_local1++;
};
_local1 = 0;
while (_local1 <= 161) {
writeByte(std_ac_luminance_values[_local1]);
_local1++;
};
writeByte(1);
_local1 = 0;
while (_local1 < 16) {
writeByte(std_dc_chrominance_nrcodes[(_local1 + 1)]);
_local1++;
};
_local1 = 0;
while (_local1 <= 11) {
writeByte(std_dc_chrominance_values[_local1]);
_local1++;
};
writeByte(17);
_local1 = 0;
while (_local1 < 16) {
writeByte(std_ac_chrominance_nrcodes[(_local1 + 1)]);
_local1++;
};
_local1 = 0;
while (_local1 <= 161) {
writeByte(std_ac_chrominance_values[_local1]);
_local1++;
};
}
private function writeBits(_arg1:BitString):void{
var _local2:int;
var _local3:int;
_local2 = _arg1.val;
_local3 = (_arg1.len - 1);
while (_local3 >= 0) {
if ((_local2 & uint((1 << _local3)))){
bytenew = (bytenew | uint((1 << bytepos)));
};
_local3--;
bytepos--;
if (bytepos < 0){
if (bytenew == 0xFF){
writeByte(0xFF);
writeByte(0);
} else {
writeByte(bytenew);
};
bytepos = 7;
bytenew = 0;
};
};
}
private function initHuffmanTbl():void{
YDC_HT = computeHuffmanTbl(std_dc_luminance_nrcodes, std_dc_luminance_values);
UVDC_HT = computeHuffmanTbl(std_dc_chrominance_nrcodes, std_dc_chrominance_values);
YAC_HT = computeHuffmanTbl(std_ac_luminance_nrcodes, std_ac_luminance_values);
UVAC_HT = computeHuffmanTbl(std_ac_chrominance_nrcodes, std_ac_chrominance_values);
}
private function encode(_arg1:BitmapData):ByteArray{
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:int;
var _local6:int;
var _local7:BitString;
byteout = new ByteArray();
bytenew = 0;
bytepos = 7;
writeWord(65496);
writeAPP0();
writeDQT();
writeSOF0(_arg1.width, _arg1.height);
writeDHT();
writeSOS();
_local2 = 0;
_local3 = 0;
_local4 = 0;
bytenew = 0;
bytepos = 7;
_local5 = 0;
while (_local5 < _arg1.height) {
_local6 = 0;
while (_local6 < _arg1.width) {
RGB2YUV(_arg1, _local6, _local5);
_local2 = processDU(YDU, fdtbl_Y, _local2, YDC_HT, YAC_HT);
_local3 = processDU(UDU, fdtbl_UV, _local3, UVDC_HT, UVAC_HT);
_local4 = processDU(VDU, fdtbl_UV, _local4, UVDC_HT, UVAC_HT);
_local6 = (_local6 + 8);
};
_local5 = (_local5 + 8);
};
if (bytepos >= 0){
_local7 = new BitString();
_local7.len = (bytepos + 1);
_local7.val = ((1 << (bytepos + 1)) - 1);
writeBits(_local7);
};
writeWord(65497);
return (byteout);
}
private function initCategoryNumber():void{
var _local1:int;
var _local2:int;
var _local3:int;
var _local4:int;
_local1 = 1;
_local2 = 2;
_local3 = 1;
while (_local3 <= 15) {
_local4 = _local1;
while (_local4 < _local2) {
category[(32767 + _local4)] = _local3;
bitcode[(32767 + _local4)] = new BitString();
bitcode[(32767 + _local4)].len = _local3;
bitcode[(32767 + _local4)].val = _local4;
_local4++;
};
_local4 = -((_local2 - 1));
while (_local4 <= -(_local1)) {
category[(32767 + _local4)] = _local3;
bitcode[(32767 + _local4)] = new BitString();
bitcode[(32767 + _local4)].len = _local3;
bitcode[(32767 + _local4)].val = ((_local2 - 1) + _local4);
_local4++;
};
_local1 = (_local1 << 1);
_local2 = (_local2 << 1);
_local3++;
};
}
private function writeDQT():void{
var _local1:int;
writeWord(65499);
writeWord(132);
writeByte(0);
_local1 = 0;
while (_local1 < 64) {
writeByte(YTable[_local1]);
_local1++;
};
writeByte(1);
_local1 = 0;
while (_local1 < 64) {
writeByte(UVTable[_local1]);
_local1++;
};
}
private function writeAPP0():void{
writeWord(65504);
writeWord(16);
writeByte(74);
writeByte(70);
writeByte(73);
writeByte(70);
writeByte(0);
writeByte(1);
writeByte(1);
writeByte(0);
writeWord(1);
writeWord(1);
writeByte(0);
writeByte(0);
}
private function writeSOS():void{
writeWord(65498);
writeWord(12);
writeByte(3);
writeByte(1);
writeByte(0);
writeByte(2);
writeByte(17);
writeByte(3);
writeByte(17);
writeByte(0);
writeByte(63);
writeByte(0);
}
private function processDU(_arg1:Array, _arg2:Array, _arg3:Number, _arg4:Array, _arg5:Array):Number{
var _local6:BitString;
var _local7:BitString;
var _local8:Array;
var _local9:int;
var _local10:int;
var _local11:int;
var _local12:int;
var _local13:int;
var _local14:int;
_local6 = _arg5[0];
_local7 = _arg5[240];
_local8 = fDCTQuant(_arg1, _arg2);
_local9 = 0;
while (_local9 < 64) {
DU[ZigZag[_local9]] = _local8[_local9];
_local9++;
};
_local10 = (DU[0] - _arg3);
_arg3 = DU[0];
if (_local10 == 0){
writeBits(_arg4[0]);
} else {
writeBits(_arg4[category[(32767 + _local10)]]);
writeBits(bitcode[(32767 + _local10)]);
};
_local11 = 63;
while ((((_local11 > 0)) && ((DU[_local11] == 0)))) {
_local11--;
};
if (_local11 == 0){
writeBits(_local6);
return (_arg3);
};
_local9 = 1;
while (_local9 <= _local11) {
_local12 = _local9;
while ((((DU[_local9] == 0)) && ((_local9 <= _local11)))) {
_local9++;
};
_local13 = (_local9 - _local12);
if (_local13 >= 16){
_local14 = 1;
while (_local14 <= (_local13 / 16)) {
writeBits(_local7);
_local14++;
};
_local13 = int((_local13 & 15));
};
writeBits(_arg5[((_local13 * 16) + category[(32767 + DU[_local9])])]);
writeBits(bitcode[(32767 + DU[_local9])]);
_local9++;
};
if (_local11 != 63){
writeBits(_local6);
};
return (_arg3);
}
private function initQuantTables(_arg1:int):void{
var _local2:Array;
var _local3:int;
var _local4:Array;
var _local5:Array;
var _local6:int;
var _local7:Number;
var _local8:int;
_local2 = [16, 11, 10, 16, 24, 40, 51, 61, 12, 12, 14, 19, 26, 58, 60, 55, 14, 13, 16, 24, 40, 57, 69, 56, 14, 17, 22, 29, 51, 87, 80, 62, 18, 22, 37, 56, 68, 109, 103, 77, 24, 35, 55, 64, 81, 104, 113, 92, 49, 64, 78, 87, 103, 121, 120, 101, 72, 92, 95, 98, 112, 100, 103, 99];
_local3 = 0;
while (_local3 < 64) {
_local7 = Math.floor((((_local2[_local3] * _arg1) + 50) / 100));
if (_local7 < 1){
_local7 = 1;
} else {
if (_local7 > 0xFF){
_local7 = 0xFF;
};
};
YTable[ZigZag[_local3]] = _local7;
_local3++;
};
_local4 = [17, 18, 24, 47, 99, 99, 99, 99, 18, 21, 26, 66, 99, 99, 99, 99, 24, 26, 56, 99, 99, 99, 99, 99, 47, 66, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99];
_local3 = 0;
while (_local3 < 64) {
_local7 = Math.floor((((_local4[_local3] * _arg1) + 50) / 100));
if (_local7 < 1){
_local7 = 1;
} else {
if (_local7 > 0xFF){
_local7 = 0xFF;
};
};
UVTable[ZigZag[_local3]] = _local7;
_local3++;
};
_local5 = [1, 1.387039845, 1.306562965, 1.175875602, 1, 0.785694958, 0.5411961, 0.275899379];
_local3 = 0;
_local6 = 0;
while (_local6 < 8) {
_local8 = 0;
while (_local8 < 8) {
fdtbl_Y[_local3] = (1 / (((YTable[ZigZag[_local3]] * _local5[_local6]) * _local5[_local8]) * 8));
fdtbl_UV[_local3] = (1 / (((UVTable[ZigZag[_local3]] * _local5[_local6]) * _local5[_local8]) * 8));
_local3++;
_local8++;
};
_local6++;
};
}
private function writeSOF0(_arg1:int, _arg2:int):void{
writeWord(65472);
writeWord(17);
writeByte(8);
writeWord(_arg2);
writeWord(_arg1);
writeByte(3);
writeByte(1);
writeByte(17);
writeByte(0);
writeByte(2);
writeByte(17);
writeByte(1);
writeByte(3);
writeByte(17);
writeByte(1);
}
private function computeHuffmanTbl(_arg1:Array, _arg2:Array):Array{
var _local3:int;
var _local4:int;
var _local5:Array;
var _local6:int;
var _local7:int;
_local3 = 0;
_local4 = 0;
_local5 = new Array();
_local6 = 1;
while (_local6 <= 16) {
_local7 = 1;
while (_local7 <= _arg1[_local6]) {
_local5[_arg2[_local4]] = new BitString();
_local5[_arg2[_local4]].val = _local3;
_local5[_arg2[_local4]].len = _local6;
_local4++;
_local3++;
_local7++;
};
_local3 = (_local3 * 2);
_local6++;
};
return (_local5);
}
private function fDCTQuant(_arg1:Array, _arg2:Array):Array{
var _local3:int;
var _local4:int;
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;
_local3 = 0;
_local4 = 0;
while (_local4 < 8) {
_local5 = (_arg1[(_local3 + 0)] + _arg1[(_local3 + 7)]);
_local6 = (_arg1[(_local3 + 0)] - _arg1[(_local3 + 7)]);
_local7 = (_arg1[(_local3 + 1)] + _arg1[(_local3 + 6)]);
_local8 = (_arg1[(_local3 + 1)] - _arg1[(_local3 + 6)]);
_local9 = (_arg1[(_local3 + 2)] + _arg1[(_local3 + 5)]);
_local10 = (_arg1[(_local3 + 2)] - _arg1[(_local3 + 5)]);
_local11 = (_arg1[(_local3 + 3)] + _arg1[(_local3 + 4)]);
_local12 = (_arg1[(_local3 + 3)] - _arg1[(_local3 + 4)]);
_local13 = (_local5 + _local11);
_local14 = (_local5 - _local11);
_local15 = (_local7 + _local9);
_local16 = (_local7 - _local9);
_arg1[(_local3 + 0)] = (_local13 + _local15);
_arg1[(_local3 + 4)] = (_local13 - _local15);
_local17 = ((_local16 + _local14) * 0.707106781);
_arg1[(_local3 + 2)] = (_local14 + _local17);
_arg1[(_local3 + 6)] = (_local14 - _local17);
_local13 = (_local12 + _local10);
_local15 = (_local10 + _local8);
_local16 = (_local8 + _local6);
_local18 = ((_local13 - _local16) * 0.382683433);
_local19 = ((0.5411961 * _local13) + _local18);
_local20 = ((1.306562965 * _local16) + _local18);
_local21 = (_local15 * 0.707106781);
_local22 = (_local6 + _local21);
_local23 = (_local6 - _local21);
_arg1[(_local3 + 5)] = (_local23 + _local19);
_arg1[(_local3 + 3)] = (_local23 - _local19);
_arg1[(_local3 + 1)] = (_local22 + _local20);
_arg1[(_local3 + 7)] = (_local22 - _local20);
_local3 = (_local3 + 8);
_local4++;
};
_local3 = 0;
_local4 = 0;
while (_local4 < 8) {
_local5 = (_arg1[(_local3 + 0)] + _arg1[(_local3 + 56)]);
_local6 = (_arg1[(_local3 + 0)] - _arg1[(_local3 + 56)]);
_local7 = (_arg1[(_local3 + 8)] + _arg1[(_local3 + 48)]);
_local8 = (_arg1[(_local3 + 8)] - _arg1[(_local3 + 48)]);
_local9 = (_arg1[(_local3 + 16)] + _arg1[(_local3 + 40)]);
_local10 = (_arg1[(_local3 + 16)] - _arg1[(_local3 + 40)]);
_local11 = (_arg1[(_local3 + 24)] + _arg1[(_local3 + 32)]);
_local12 = (_arg1[(_local3 + 24)] - _arg1[(_local3 + 32)]);
_local13 = (_local5 + _local11);
_local14 = (_local5 - _local11);
_local15 = (_local7 + _local9);
_local16 = (_local7 - _local9);
_arg1[(_local3 + 0)] = (_local13 + _local15);
_arg1[(_local3 + 32)] = (_local13 - _local15);
_local17 = ((_local16 + _local14) * 0.707106781);
_arg1[(_local3 + 16)] = (_local14 + _local17);
_arg1[(_local3 + 48)] = (_local14 - _local17);
_local13 = (_local12 + _local10);
_local15 = (_local10 + _local8);
_local16 = (_local8 + _local6);
_local18 = ((_local13 - _local16) * 0.382683433);
_local19 = ((0.5411961 * _local13) + _local18);
_local20 = ((1.306562965 * _local16) + _local18);
_local21 = (_local15 * 0.707106781);
_local22 = (_local6 + _local21);
_local23 = (_local6 - _local21);
_arg1[(_local3 + 40)] = (_local23 + _local19);
_arg1[(_local3 + 24)] = (_local23 - _local19);
_arg1[(_local3 + 8)] = (_local22 + _local20);
_arg1[(_local3 + 56)] = (_local22 - _local20);
_local3++;
_local4++;
};
_local4 = 0;
while (_local4 < 64) {
_arg1[_local4] = Math.round((_arg1[_local4] * _arg2[_local4]));
_local4++;
};
return (_arg1);
}
public static function defaultEncode(_arg1:BitmapData):ByteArray{
return (JPEG.encode(_arg1, 80));
}
public static function encode(_arg1:BitmapData, _arg2:int=50):ByteArray{
var _local3:JPEG;
init = true;
_local3 = new JPEG(_arg2);
init = false;
return (_local3.encode(_arg1));
}
}
}//package de.popforge.imageprocessing.formats
class BitString {
public var val:int;// = 0
public var len:int;// = 0
private function BitString(){
len = 0;
val = 0;
super();
}
}
Section 28
//PNG (de.popforge.imageprocessing.formats.PNG)
package de.popforge.imageprocessing.formats {
import flash.display.*;
import flash.geom.*;
import flash.utils.*;
public final class PNG {
public static const RGB:int = 1;
public static const RGBA:int = 0;
private static var crcTableComputed:Boolean = false;
private static var crcTable:Array;
private static function writeRaw(_arg1:BitmapData, _arg2:ByteArray):void{
var _local3:int;
var _local4:int;
var _local5:int;
var _local6:Rectangle;
var _local7:ByteArray;
var _local8:uint;
var _local9:int;
_local3 = _arg1.height;
_local4 = _arg1.width;
if (!_arg1.transparent){
_local6 = new Rectangle(0, 0, _local4, 1);
_local5 = 0;
while (_local5 < _local3) {
_local6.y = _local5;
_local7 = _arg1.getPixels(_local6);
_local7[0] = 0;
_arg2.writeBytes(_local7);
_arg2.writeByte(0xFF);
_local5++;
};
} else {
_local5 = 0;
while (_local5 < _local3) {
_arg2.writeByte(0);
_local9 = 0;
while (_local9 < _local4) {
_local8 = _arg1.getPixel32(_local9, _local5);
_arg2.writeUnsignedInt(uint((((_local8 & 0xFFFFFF) << 8) | (_local8 >>> 24))));
_local9++;
};
_local5++;
};
};
}
public static function defaulEncode(_arg1:BitmapData):ByteArray{
return (encode(_arg1, 0));
}
private static function writeChunk(_arg1:ByteArray, _arg2:int, _arg3:ByteArray):void{
var _local4:uint;
var _local5:uint;
var _local6:uint;
var _local7:uint;
var _local8:int;
var _local9:int;
var _local10:int;
if (!crcTableComputed){
crcTableComputed = true;
crcTable = [];
_local9 = 0;
while (_local9 < 0x0100) {
_local7 = _local9;
_local10 = 0;
while (_local10 < 8) {
if ((_local7 & 1)){
_local7 = uint((uint(3988292384) ^ uint((_local7 >>> 1))));
} else {
_local7 = uint((_local7 >>> 1));
};
_local10++;
};
crcTable[_local9] = _local7;
_local9++;
};
};
_local4 = 0;
if (_arg3 != null){
_local4 = _arg3.length;
};
_arg1.writeUnsignedInt(_local4);
_local5 = _arg1.position;
_arg1.writeUnsignedInt(_arg2);
if (_arg3 != null){
_arg1.writeBytes(_arg3);
};
_local6 = _arg1.position;
_arg1.position = _local5;
_local7 = 4294967295;
_local8 = 0;
while (_local8 < (_local6 - _local5)) {
_local7 = uint((crcTable[((_local7 ^ _arg1.readUnsignedByte()) & 0xFF)] ^ (_local7 >>> 8)));
_local8++;
};
_local7 = uint((_local7 ^ uint(4294967295)));
_arg1.position = _local6;
_arg1.writeUnsignedInt(_local7);
}
public static function encode(_arg1:BitmapData, _arg2:int=0):ByteArray{
var _local3:ByteArray;
var _local4:ByteArray;
var _local5:ByteArray;
_local3 = new ByteArray();
_local3.writeUnsignedInt(2303741511);
_local3.writeUnsignedInt(218765834);
_local4 = new ByteArray();
_local4.writeInt(_arg1.width);
_local4.writeInt(_arg1.height);
if (((_arg1.transparent) || ((_arg2 == 0)))){
_local4.writeUnsignedInt(134610944);
} else {
_local4.writeUnsignedInt(134348800);
};
_local4.writeByte(0);
writeChunk(_local3, 1229472850, _local4);
_local5 = new ByteArray();
switch (_arg2){
case PNG.RGBA:
writeRaw(_arg1, _local5);
break;
case PNG.RGB:
writeSub(_arg1, _local5);
break;
default:
throw (new Error(("Unknown PNG format: " + _arg2)));
};
_local5.compress();
writeChunk(_local3, 1229209940, _local5);
writeChunk(_local3, 1229278788, null);
return (_local3);
}
private static function writeSub(_arg1:BitmapData, _arg2:ByteArray):void{
var _local3:int;
var _local4:int;
var _local5:int;
var _local6:int;
var _local7:int;
var _local8:int;
var _local9:int;
var _local10:int;
var _local11:int;
var _local12:int;
var _local13:int;
var _local14:int;
var _local15:uint;
var _local16:int;
var _local17:int;
var _local18:int;
var _local19:int;
_local16 = _arg1.height;
_local17 = _arg1.width;
if (!_arg1.transparent){
_local19 = 0;
while (_local19 < _local16) {
_arg2.writeByte(1);
_local5 = 0;
_local4 = _local5;
_local3 = _local4;
_local6 = 0xFF;
_local18 = 0;
while (_local18 < _local17) {
_local15 = _arg1.getPixel(_local18, _local19);
_local7 = ((_local15 >> 16) & 0xFF);
_local8 = ((_local15 >> 8) & 0xFF);
_local9 = (_local15 & 0xFF);
_local11 = (((_local7 - _local3) + 0x0100) & 0xFF);
_local12 = (((_local8 - _local4) + 0x0100) & 0xFF);
_local13 = (((_local9 - _local5) + 0x0100) & 0xFF);
_arg2.writeByte(_local11);
_arg2.writeByte(_local12);
_arg2.writeByte(_local13);
_local3 = _local7;
_local4 = _local8;
_local5 = _local9;
_local6 = 0;
_local18++;
};
_local19++;
};
} else {
_local19 = 0;
while (_local19 < _local16) {
_arg2.writeByte(1);
_local6 = 0;
_local5 = _local6;
_local4 = _local5;
_local3 = _local4;
_local18 = 0;
while (_local18 < _local17) {
_local15 = _arg1.getPixel32(_local18, _local19);
_local10 = ((_local15 >> 24) & 0xFF);
_local7 = ((_local15 >> 16) & 0xFF);
_local8 = ((_local15 >> 8) & 0xFF);
_local9 = (_local15 & 0xFF);
_local11 = (((_local7 - _local3) + 0x0100) & 0xFF);
_local12 = (((_local8 - _local4) + 0x0100) & 0xFF);
_local13 = (((_local9 - _local5) + 0x0100) & 0xFF);
_local14 = (((_local10 - _local6) + 0x0100) & 0xFF);
_arg2.writeByte(_local11);
_arg2.writeByte(_local12);
_arg2.writeByte(_local13);
_arg2.writeByte(_local14);
_local3 = _local7;
_local4 = _local8;
_local5 = _local9;
_local6 = _local10;
_local18++;
};
_local19++;
};
};
}
}
}//package de.popforge.imageprocessing.formats
Section 29
//Curve (de.popforge.imageprocessing.geom.Curve)
package de.popforge.imageprocessing.geom {
import flash.display.*;
import flash.geom.*;
public final class Curve {
private var interpolation:int;
public var points:Array;
public function Curve(_arg1:Boolean=true, _arg2:int=4){
interpolation = _arg2;
points = new Array();
if (_arg1){
addPoint(new Point(0, 0));
addPoint(new Point(0xFF, 0xFF));
};
}
public function get mode():int{
return (interpolation);
}
public function removePoint(_arg1:Point):void{
var _local2:int;
if (_arg1.x == 0){
return;
};
if (_arg1.x == 0xFF){
return;
};
_local2 = 0;
while (_local2 < points.length) {
if (_arg1.equals(points[_local2])){
points.splice(_local2, 1);
return;
};
_local2++;
};
}
public function set mode(_arg1:int):void{
this.interpolation = _arg1;
}
public function addPoint(_arg1:Point):void{
var _local2:int;
_local2 = 0;
while (_local2 < points.length) {
if (_arg1.equals(points[_local2])){
return;
};
_local2++;
};
points.push(_arg1);
}
public function getBitmapData(_arg1:int=0x333333, _arg2:int=0xFF00FF, _arg3:int=0x666666, _arg4:int=0x3A3A3A):BitmapData{
var _local5:BitmapData;
var _local6:Array;
var _local7:int;
var _local8:int;
var _local9:int;
var _local10:int;
var _local11:int;
var _local12:Point;
_local5 = new BitmapData(0x0100, 0x0100, false, _arg1);
_local6 = getTable();
_local8 = 0;
while (_local8 < 0x0100) {
_local5.setPixel(_local8, 0, _arg4);
_local5.setPixel(_local8, 64, _arg4);
_local5.setPixel(_local8, 128, _arg4);
_local5.setPixel(_local8, 192, _arg4);
_local5.setPixel(_local8, 0xFF, _arg4);
_local8++;
};
_local10 = 0;
while (_local10 < 0x0100) {
_local5.setPixel(0, _local10, _arg4);
_local5.setPixel(64, _local10, _arg4);
_local5.setPixel(128, _local10, _arg4);
_local5.setPixel(192, _local10, _arg4);
_local5.setPixel(0xFF, _local10, _arg4);
_local10++;
};
_local7 = (0xFF - _local6[0]);
_local8 = 0;
while (_local8 < 0x0100) {
_local10 = (0xFF - _local6[_local8]);
_local11 = _local10;
_local5.setPixel(_local8, _local10, _arg3);
if (_local11 > _local7){
while (--_local11 > _local7) {
_local5.setPixel(_local8, _local11, _arg3);
};
} else {
if (_local11 < _local7){
while (++_local11 < _local7) {
_local5.setPixel(_local8, _local11, _arg3);
};
};
};
_local7 = _local10;
_local8++;
};
_local9 = 0;
while (_local9 < points.length) {
_local12 = points[_local9];
_local5.setPixel(_local12.x, ((0xFF - _local12.y) - 2), _arg2);
_local5.setPixel(_local12.x, ((0xFF - _local12.y) - 1), _arg2);
_local5.setPixel((_local12.x - 2), (0xFF - _local12.y), _arg2);
_local5.setPixel((_local12.x - 1), (0xFF - _local12.y), _arg2);
_local5.setPixel(_local12.x, (0xFF - _local12.y), _arg2);
_local5.setPixel((_local12.x + 1), (0xFF - _local12.y), _arg2);
_local5.setPixel((_local12.x + 2), (0xFF - _local12.y), _arg2);
_local5.setPixel(_local12.x, ((0xFF - _local12.y) + 1), _arg2);
_local5.setPixel(_local12.x, ((0xFF - _local12.y) + 2), _arg2);
_local9++;
};
return (_local5);
}
private function cosineInterpolate(_arg1:Number, _arg2:Number, _arg3:Number):Number{
var _local4:Number;
_local4 = ((1 + Math.cos((_arg3 * Math.PI))) * 0.5);
return (((_local4 * _arg1) + ((1 - _local4) * _arg2)));
}
public function getTable():Array{
var _local1:Array;
var _local2:Array;
var _local3:Point;
var _local4:Point;
var _local5:Point;
var _local6:Point;
var _local7:int;
var _local8:Number;
var _local9:Number;
var _local10:int;
var _local11:int;
var _local12:int;
_local1 = new Array(0x0100);
if (points.length == 0){
_local7 = 0;
while (_local7 < 0x0100) {
_local1[_local7] = 0;
_local7++;
};
return (_local1);
};
_local2 = points.slice();
_local2.sortOn("x", Array.NUMERIC);
_local2.push(new Point(0xFF, (_local2[(_local2.unshift(new Point(0, (_local2[0] as Point).y)) - 1)] as Point).y));
_local12 = _local2.length;
switch (interpolation){
case CurveMode.LINEAR:
_local12--;
_local7 = 0;
while (_local7 < _local12) {
_local3 = _local2[_local7];
_local4 = _local2[(_local7 + 1)];
_local8 = 0;
_local9 = Math.abs((_local4.x - _local3.x));
if (_local9 != 0){
_local10 = _local3.x;
while (_local10 <= _local4.x) {
_local11 = int((linearInterpolate(_local3.y, _local4.y, (_local8 / _local9)) + 0.5));
_local1[_local10] = clamp(_local11);
_local8++;
_local10++;
};
};
_local7++;
};
break;
case CurveMode.COSINE:
_local3 = _local2[0];
_local4 = _local2[1];
_local8 = 0;
_local9 = Math.abs((_local4.x - _local3.x));
if (_local9 != 0){
_local10 = _local3.x;
while (_local10 <= _local4.x) {
_local11 = int((linearInterpolate(_local3.y, _local4.y, (_local8 / _local9)) + 0.5));
_local1[_local10] = clamp(_local11);
_local8++;
_local10++;
};
};
_local12 = (_local12 - 2);
_local7 = 1;
while (_local7 < _local12) {
_local3 = _local2[_local7];
_local4 = _local2[(_local7 + 1)];
_local8 = 0;
_local9 = Math.abs((_local4.x - _local3.x));
_local10 = _local3.x;
while (_local10 <= _local4.x) {
_local11 = int((cosineInterpolate(_local3.y, _local4.y, (_local8 / _local9)) + 0.5));
_local1[_local10] = clamp(_local11);
_local8++;
_local10++;
};
_local7++;
};
_local12 = (_local12 + 2);
_local3 = _local2[int((_local12 - 2))];
_local4 = _local2[int((_local12 - 1))];
_local8 = 0;
_local9 = Math.abs((_local4.x - _local3.x));
if (_local9 != 0){
_local10 = _local3.x;
while (_local10 <= _local4.x) {
_local11 = int((linearInterpolate(_local3.y, _local4.y, (_local8 / _local9)) + 0.5));
_local1[_local10] = clamp(_local11);
_local8++;
_local10++;
};
};
break;
case CurveMode.CUBIC:
_local3 = _local2[0];
_local4 = _local2[1];
_local8 = 0;
_local9 = Math.abs((_local4.x - _local3.x));
if (_local9 != 0){
_local10 = _local3.x;
while (_local10 <= _local4.x) {
_local11 = int((linearInterpolate(_local3.y, _local4.y, (_local8 / _local9)) + 0.5));
_local1[_local10] = clamp(_local11);
_local8++;
_local10++;
};
};
_local12 = (_local12 - 2);
_local7 = 1;
while (_local7 < _local12) {
_local3 = _local2[(_local7 - 1)];
_local4 = _local2[_local7];
_local5 = _local2[(_local7 + 1)];
_local6 = _local2[(_local7 + 2)];
_local8 = 0;
_local9 = Math.abs((_local5.x - _local4.x));
_local10 = _local4.x;
while (_local10 <= _local5.x) {
_local11 = int((cubicInterpolate(_local3.y, _local4.y, _local5.y, _local6.y, (_local8 / _local9)) + 0.5));
_local1[_local10] = clamp(_local11);
_local8++;
_local10++;
};
_local7++;
};
_local12 = (_local12 + 2);
_local3 = _local2[int((_local12 - 2))];
_local4 = _local2[int((_local12 - 1))];
_local8 = 0;
_local9 = Math.abs((_local4.x - _local3.x));
if (_local9 != 0){
_local10 = _local3.x;
while (_local10 <= _local4.x) {
_local11 = int((linearInterpolate(_local3.y, _local4.y, (_local8 / _local9)) + 0.5));
_local1[_local10] = clamp(_local11);
_local8++;
_local10++;
};
};
break;
};
return (_local1);
}
private function clamp(_arg1:int):int{
if (_arg1 > 0xFF){
return (0xFF);
};
if (_arg1 < 0){
return (0);
};
return (_arg1);
}
private function linearInterpolate(_arg1:Number, _arg2:Number, _arg3:Number):Number{
return ((_arg1 + ((_arg2 - _arg1) * _arg3)));
}
private function cubicInterpolate(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number):Number{
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
_local6 = ((_arg4 - _arg3) - (_arg1 - _arg2));
_local7 = ((_arg1 - _arg2) - _local6);
_local8 = (_arg3 - _arg1);
_local9 = _arg2;
return (((((((_local6 * _arg5) * _arg5) * _arg5) + ((_local7 * _arg5) * _arg5)) + (_local8 * _arg5)) + _local9));
}
}
}//package de.popforge.imageprocessing.geom
Section 30
//CurveMode (de.popforge.imageprocessing.geom.CurveMode)
package de.popforge.imageprocessing.geom {
public final class CurveMode {
public static const LINEAR:int = 1;
public static const COSINE:int = 2;
public static const CUBIC:int = 4;
}
}//package de.popforge.imageprocessing.geom
Section 31
//DimensionTest (de.popforge.imageprocessing.utils.DimensionTest)
package de.popforge.imageprocessing.utils {
import flash.display.*;
import de.popforge.imageprocessing.core.*;
import de.popforge.imageprocessing.errors.*;
public final class DimensionTest {
public static function isEqual(_arg1:BitmapData, _arg2:Image):void{
if (((!((_arg1.width == _arg2.width))) || (!((_arg1.height == _arg2.height))))){
throw (new UnequalDimensionsError(_arg1.width, _arg1.height, _arg2.width, _arg2.height));
};
}
}
}//package de.popforge.imageprocessing.utils
Section 32
//FormatTest (de.popforge.imageprocessing.utils.FormatTest)
package de.popforge.imageprocessing.utils {
import de.popforge.imageprocessing.core.*;
import de.popforge.imageprocessing.errors.*;
public final class FormatTest {
public static function deny(_arg1:Image, _arg2:int):void{
if ((_arg2 & _arg1.format) != 0){
throw (new InvalidImageFormatError());
};
}
public static function require(_arg1:Image, _arg2:int):void{
if ((_arg2 & _arg1.format) == 0){
throw (new InvalidImageFormatError());
};
}
}
}//package de.popforge.imageprocessing.utils
Section 33
//Camera3D (org.papervision3d.cameras.Camera3D)
package org.papervision3d.cameras {
import org.papervision3d.core.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.objects.*;
public class Camera3D extends CameraObject3D {
public var goto:Number3D;
public var target:DisplayObject3D;
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);
}
override public function transformView(_arg1:Matrix3D=null):void{
this.lookAt(this.target);
super.transformView();
}
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;
};
}
}
}//package org.papervision3d.cameras
Section 34
//Face3D (org.papervision3d.core.geom.Face3D)
package org.papervision3d.core.geom {
import org.papervision3d.core.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.objects.*;
import flash.display.*;
import flash.geom.*;
import flash.utils.*;
import org.papervision3d.*;
public class Face3D {
public var vertices:Array;
public var uv:Array;
public var materialName:String;
public var screenZ:Number;
public var visible:Boolean;
public var id:Number;
private static var _totalFaces:Number = 0;
private static var _bitmapMatrix:Matrix;
public function Face3D(_arg1:Array, _arg2:String=null, _arg3:Array=null){
this.vertices = _arg1;
this.materialName = _arg2;
this.uv = _arg3;
this.id = _totalFaces++;
if (!_bitmapMatrix){
_bitmapMatrix = new Matrix();
};
}
public function transformUV(_arg1:DisplayObject3D=null):Object{
var _local2:MaterialObject3D;
var _local3:Array;
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:Matrix;
var _local17:Object;
_local2 = (((this.materialName) && (_arg1.materials))) ? _arg1.materials.materialsByName[this.materialName] : _arg1.material;
if (!this.uv){
Papervision3D.log("Face3D: transformUV() uv not found!");
} else {
if (((_local2) && (_local2.bitmap))){
_local3 = this.uv;
_local4 = _local2.bitmap.width;
_local5 = _local2.bitmap.height;
_local6 = (_local4 * _local3[0].u);
_local7 = (_local5 * (1 - _local3[0].v));
_local8 = (_local4 * _local3[1].u);
_local9 = (_local5 * (1 - _local3[1].v));
_local10 = (_local4 * _local3[2].u);
_local11 = (_local5 * (1 - _local3[2].v));
if ((((((_local6 == _local8)) && ((_local7 == _local9)))) || ((((_local6 == _local10)) && ((_local7 == _local11)))))){
_local6 = (_local6 - ((_local6)>0.05) ? 0.05 : -0.05);
_local7 = (_local7 - ((_local7)>0.07) ? 0.07 : -0.07);
};
if ((((_local10 == _local8)) && ((_local11 == _local9)))){
_local10 = (_local10 - ((_local10)>0.05) ? 0.04 : -0.04);
_local11 = (_local11 - ((_local11)>0.06) ? 0.06 : -0.06);
};
_local12 = (_local8 - _local6);
_local13 = (_local9 - _local7);
_local14 = (_local10 - _local6);
_local15 = (_local11 - _local7);
_local16 = new Matrix(_local12, _local13, _local14, _local15, _local6, _local7);
_local16.invert();
_local17 = ((_arg1.projected[this]) || ((_arg1.projected[this] = new Object())));
_local17._a = _local16.a;
_local17._b = _local16.b;
_local17._c = _local16.c;
_local17._d = _local16.d;
_local17._tx = _local16.tx;
_local17._ty = _local16.ty;
} else {
Papervision3D.log("Face3D: transformUV() material.bitmap not found!");
};
};
return (_local17);
}
public function render(_arg1:DisplayObject3D, _arg2:Sprite):Number{
var _local3:Array;
var _local4:Dictionary;
var _local5:Vertex2D;
var _local6:Vertex2D;
var _local7:Vertex2D;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:MaterialObject3D;
var _local15:BitmapData;
var _local16:Number;
var _local17:Number;
var _local18:Graphics;
var _local19:Object;
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:Matrix;
_local3 = this.vertices;
_local4 = _arg1.projected;
_local5 = _local4[_local3[0]];
_local6 = _local4[_local3[1]];
_local7 = _local4[_local3[2]];
_local8 = _local5.x;
_local9 = _local5.y;
_local10 = _local6.x;
_local11 = _local6.y;
_local12 = _local7.x;
_local13 = _local7.y;
_local14 = (((this.materialName) && (_arg1.materials))) ? _arg1.materials.materialsByName[this.materialName] : _arg1.material;
if (_local14.invisible){
return (0);
};
if (_local14.oneSide){
if (_local14.opposite){
if ((((_local12 - _local8) * (_local11 - _local9)) - ((_local13 - _local9) * (_local10 - _local8))) > 0){
return (0);
};
} else {
if ((((_local12 - _local8) * (_local11 - _local9)) - ((_local13 - _local9) * (_local10 - _local8))) < 0){
return (0);
};
};
};
_local15 = _local14.bitmap;
_local16 = _local14.fillAlpha;
_local17 = _local14.lineAlpha;
_local18 = _arg2.graphics;
if (_local15){
_local19 = ((_arg1.projected[this]) || (transformUV(_arg1)));
_local20 = _local19._a;
_local21 = _local19._b;
_local22 = _local19._c;
_local23 = _local19._d;
_local24 = _local19._tx;
_local25 = _local19._ty;
_local26 = (_local10 - _local8);
_local27 = (_local11 - _local9);
_local28 = (_local12 - _local8);
_local29 = (_local13 - _local9);
_local30 = _bitmapMatrix;
_local30.a = ((_local20 * _local26) + (_local21 * _local28));
_local30.b = ((_local20 * _local27) + (_local21 * _local29));
_local30.c = ((_local22 * _local26) + (_local23 * _local28));
_local30.d = ((_local22 * _local27) + (_local23 * _local29));
_local30.tx = (((_local24 * _local26) + (_local25 * _local28)) + _local8);
_local30.ty = (((_local24 * _local27) + (_local25 * _local29)) + _local9);
_local18.beginBitmapFill(_local15, _local30, false, _local14.smooth);
} else {
if (_local16){
_local18.beginFill(_local14.fillColor, _local16);
};
};
if (_local17){
_local18.lineStyle(0, _local14.lineColor, _local17);
} else {
_local18.lineStyle();
};
_local18.moveTo(_local8, _local9);
_local18.lineTo(_local10, _local11);
_local18.lineTo(_local12, _local13);
if (_local17){
_local18.lineTo(_local8, _local9);
};
if (((_local15) || (_local16))){
_local18.endFill();
};
return (1);
}
}
}//package org.papervision3d.core.geom
Section 35
//Mesh3D (org.papervision3d.core.geom.Mesh3D)
package org.papervision3d.core.geom {
import org.papervision3d.core.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.objects.*;
import flash.utils.*;
public class Mesh3D extends Vertices3D {
public function Mesh3D(_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:CameraObject3D, _arg3:Array=null):Number{
var _local4:Dictionary;
var _local5:Matrix3D;
var _local6:Array;
var _local7:Array;
var _local8:Number;
var _local9:Number;
var _local10:Vertex2D;
var _local11:Vertex2D;
var _local12:Vertex2D;
var _local13:Number;
var _local14:Object;
var _local15:Face3D;
var _local16:int;
super.project(_arg1, _arg2, _arg3);
if (!_arg3){
_arg3 = this._sorted;
};
_local4 = this.projected;
_local5 = this.view;
_local6 = this.geometry.faces;
_local7 = this.faces;
_local8 = 0;
_local9 = 0;
_local16 = 0;
while ((_local15 = _local6[_local16])) {
_local14 = ((_local7[_local16]) || ((_local7[_local16] = {})));
_local14.face = _local15;
_local14.instance = this;
_local10 = _local4[_local15.vertices[0]];
_local11 = _local4[_local15.vertices[1]];
_local12 = _local4[_local15.vertices[2]];
_local13 = ((Number(_local10.visible) + Number(_local11.visible)) + Number(_local12.visible));
_local14.visible = (_local13 == 3);
if (_local14.visible){
_local8 = (_local8 + (_local14.screenZ = (((_local10.z + _local11.z) + _local12.z) / 3)));
_local9++;
if (_arg3){
_arg3.push(_local14);
};
};
_local16++;
};
return ((this.screenZ = (_local8 / _local9)));
}
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:Face3D;
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
//Vertex2D (org.papervision3d.core.geom.Vertex2D)
package org.papervision3d.core.geom {
public class Vertex2D {
public var visible:Boolean;
public var extra:Object;
public var x:Number;
public var y:Number;
public var z:Number;
public function Vertex2D(_arg1:Number=0, _arg2:Number=0, _arg3:Number=0){
this.x = _arg1;
this.y = _arg2;
this.z = _arg3;
this.visible = false;
}
}
}//package org.papervision3d.core.geom
Section 37
//Vertex3D (org.papervision3d.core.geom.Vertex3D)
package org.papervision3d.core.geom {
public class Vertex3D {
public var extra:Object;
public var x:Number;
public var y:Number;
public var z:Number;
public function Vertex3D(_arg1:Number=0, _arg2:Number=0, _arg3:Number=0){
this.x = _arg1;
this.y = _arg2;
this.z = _arg3;
}
}
}//package org.papervision3d.core.geom
Section 38
//Vertices3D (org.papervision3d.core.geom.Vertices3D)
package org.papervision3d.core.geom {
import org.papervision3d.core.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.objects.*;
import flash.utils.*;
import org.papervision3d.scenes.*;
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 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:Array;
var _local15:int;
var _local16:Vertex3D;
var _local17:Number;
var _local18:Number;
var _local19:Number;
var _local20:Number;
var _local21:Number;
var _local22: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 = this.geometry.vertices;
_local15 = _local14.length;
while ((_local16 = _local14[--_local15])) {
_local17 = _local16.x;
_local18 = _local16.y;
_local19 = _local16.z;
_local20 = ((((_local17 * _local2) + (_local18 * _local3)) + (_local19 * _local4)) + _local11);
_local21 = ((((_local17 * _local5) + (_local18 * _local6)) + (_local19 * _local7)) + _local12);
_local22 = ((((_local17 * _local8) + (_local18 * _local9)) + (_local19 * _local10)) + _local13);
_local16.x = _local20;
_local16.y = _local21;
_local16.z = _local22;
};
}
override public function project(_arg1:DisplayObject3D, _arg2:CameraObject3D, _arg3:Array=null):Number{
var _local4:Dictionary;
var _local5: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:Array;
var _local16:int;
var _local17:Number;
var _local18:Number;
var _local19:Vertex3D;
var _local20:Vertex2D;
var _local21:Number;
var _local22:Number;
var _local23:Number;
var _local24:Number;
var _local25:Number;
var _local26:Number;
var _local27:Number;
super.project(_arg1, _arg2, _arg3);
_local4 = this.projected;
_local5 = this.view;
_local6 = _local5.n11;
_local7 = _local5.n12;
_local8 = _local5.n13;
_local9 = _local5.n21;
_local10 = _local5.n22;
_local11 = _local5.n23;
_local12 = _local5.n31;
_local13 = _local5.n32;
_local14 = _local5.n33;
_local15 = this.geometry.vertices;
_local16 = _local15.length;
_local17 = _arg2.focus;
_local18 = _arg2.zoom;
while ((_local19 = _local15[--_local16])) {
_local22 = _local19.x;
_local23 = _local19.y;
_local24 = _local19.z;
_local25 = ((((_local22 * _local6) + (_local23 * _local7)) + (_local24 * _local8)) + _local5.n14);
_local26 = ((((_local22 * _local9) + (_local23 * _local10)) + (_local24 * _local11)) + _local5.n24);
_local27 = ((((_local22 * _local12) + (_local23 * _local13)) + (_local24 * _local14)) + _local5.n34);
_local20 = ((_local4[_local19]) || ((_local4[_local19] = new Vertex2D())));
if ((_local20.visible = (_local27 > 0))){
_local21 = ((_local17 / (_local17 + _local27)) * _local18);
_local20.x = (_local25 * _local21);
_local20.y = (_local26 * _local21);
_local20.z = _local27;
};
};
return (0);
}
public function boundingBox():Object{
var _local1:Object;
var _local2:Object;
var _local3:String;
var _local4:Vertex3D;
_local1 = this.geometry.vertices;
_local2 = new Object();
_local2.min = new Number3D();
_local2.max = new Number3D();
_local2.size = new Number3D();
for (_local3 in _local1) {
_local4 = _local1[Number(_local3)];
_local2.min.x = ((_local2.min.x)==undefined) ? _local4.x : Math.min(_local4.x, _local2.min.x);
_local2.max.x = ((_local2.max.x)==undefined) ? _local4.x : Math.max(_local4.x, _local2.max.x);
_local2.min.y = ((_local2.min.y)==undefined) ? _local4.y : Math.min(_local4.y, _local2.min.y);
_local2.max.y = ((_local2.max.y)==undefined) ? _local4.y : Math.max(_local4.y, _local2.max.y);
_local2.min.z = ((_local2.min.z)==undefined) ? _local4.z : Math.min(_local4.z, _local2.min.z);
_local2.max.z = ((_local2.max.z)==undefined) ? _local4.z : Math.max(_local4.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 39
//CameraObject3D (org.papervision3d.core.proto.CameraObject3D)
package org.papervision3d.core.proto {
import org.papervision3d.core.*;
import org.papervision3d.objects.*;
public class CameraObject3D extends DisplayObject3D {
public var sort:Boolean;
public var zoom:Number;
public var focus:Number;
private static var _flipY:Matrix3D = Matrix3D.scaleMatrix(1, -1, 1);
public static var DEFAULT_POS:Number3D = new Number3D(0, 0, -1000);
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.sort = (_arg3) ? !((_arg3.sort == false)) : true;
}
public function transformView(_arg1:Matrix3D=null):void{
this.view = Matrix3D.inverse(Matrix3D.multiply(((_arg1) || (this.transform)), _flipY));
}
public function pan(_arg1:Number):void{
super.yaw(_arg1);
}
public function tilt(_arg1:Number):void{
super.pitch(_arg1);
}
}
}//package org.papervision3d.core.proto
Section 40
//DisplayObjectContainer3D (org.papervision3d.core.proto.DisplayObjectContainer3D)
package org.papervision3d.core.proto {
import org.papervision3d.objects.*;
import org.papervision3d.materials.*;
import flash.events.*;
import flash.utils.*;
import org.papervision3d.core.utils.*;
public class DisplayObjectContainer3D extends EventDispatcher {
protected var _childrenByName:Dictionary;
protected var _children:Dictionary;
private var _childrenTotal:int;
public function DisplayObjectContainer3D():void{
this._children = new Dictionary(false);
this._childrenByName = new Dictionary(true);
this._childrenTotal = 0;
}
public function getChildByName(_arg1:String):DisplayObject3D{
return (this._childrenByName[_arg1]);
}
public function addCollada(_arg1:String, _arg2:MaterialsList=null, _arg3:Number=1):void{
var _local4:Collada;
_local4 = new Collada(this, _arg1, _arg2, _arg3);
}
public function removeChildByName(_arg1:String):DisplayObject3D{
return (removeChild(getChildByName(_arg1)));
}
public function get numChildren():int{
return (this._childrenTotal);
}
override public function toString():String{
return (childrenList());
}
public function removeChild(_arg1:DisplayObject3D):DisplayObject3D{
delete this._childrenByName[this._children[_arg1]];
delete this._children[_arg1];
return (_arg1);
}
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++;
return (_arg1);
}
public function childrenList():String{
var _local1:String;
var _local2:String;
_local1 = "";
for (_local2 in this._children) {
_local1 = (_local1 + (_local2 + "\n"));
};
return (_local1);
}
}
}//package org.papervision3d.core.proto
Section 41
//GeometryObject3D (org.papervision3d.core.proto.GeometryObject3D)
package org.papervision3d.core.proto {
import org.papervision3d.core.*;
import org.papervision3d.materials.*;
import flash.events.*;
import org.papervision3d.core.geom.*;
import org.papervision3d.scenes.*;
public class GeometryObject3D extends EventDispatcher {
protected var _boundingSphere2:Number;
protected var _boundingSphereDirty:Boolean;// = true
public var ready:Boolean;// = false
protected var _material:MaterialObject3D;
public var faces:Array;
public var vertices:Array;
public function GeometryObject3D(_arg1:Object=null):void{
ready = false;
_boundingSphereDirty = true;
super();
}
public function transformVertices(_arg1:Matrix3D):void{
}
public function get boundingSphere2():Number{
if (_boundingSphereDirty){
return (getBoundingSphere2());
};
return (_boundingSphere2);
}
public function getBoundingSphere2():Number{
var _local1:Number;
var _local2:Number;
var _local3:Vertex3D;
_local1 = 0;
for each (_local3 in this.vertices) {
_local2 = (((_local3.x * _local3.x) + (_local3.y * _local3.y)) + (_local3.z * _local3.z));
_local1 = ((_local2)>_local1) ? _local2 : _local1;
};
this._boundingSphereDirty = false;
return ((_boundingSphere2 = _local1));
}
public function transformUV(_arg1:MaterialObject3D):void{
var _local2:String;
if (_arg1.bitmap){
for (_local2 in this.faces) {
faces[_local2].transformUV(_arg1);
};
};
}
}
}//package org.papervision3d.core.proto
Section 42
//MaterialObject3D (org.papervision3d.core.proto.MaterialObject3D)
package org.papervision3d.core.proto {
import flash.display.*;
public class MaterialObject3D {
public var lineAlpha:Number;
public var name:String;
public var scene:SceneObject3D;
public var lineColor:Number;
public var fillAlpha:Number;
public var oneSide:Boolean;
public var fillColor:Number;
public var id:Number;
public var animated:Boolean;
public var opposite:Boolean;
public var invisible:Boolean;
public var smooth:Boolean;
public var bitmap:BitmapData;
public static var DEFAULT_COLOR:Number = 0xFF00FF;
private static var _totalMaterialObjects:Number = 0;
public function MaterialObject3D(_arg1:Object=null){
if (((_arg1) && (_arg1.bitmap))){
this.bitmap = _arg1.bitmap;
};
this.lineColor = (_arg1) ? ((_arg1.lineColor) || (DEFAULT_COLOR)) : DEFAULT_COLOR;
this.lineAlpha = (_arg1) ? ((_arg1.lineAlpha) || (0)) : 0;
this.fillColor = (_arg1) ? ((_arg1.fillColor) || (DEFAULT_COLOR)) : DEFAULT_COLOR;
this.fillAlpha = (_arg1) ? ((_arg1.fillAlpha) || (0)) : 0;
this.animated = (_arg1) ? ((_arg1.animated) || (false)) : false;
this.invisible = (_arg1) ? ((_arg1.invisible) || (false)) : false;
this.smooth = (_arg1) ? ((_arg1.smooth) || (false)) : false;
this.doubleSided = (_arg1) ? ((_arg1.doubleSided) || (false)) : false;
this.opposite = (_arg1) ? ((_arg1.opposite) || (false)) : false;
this.id = _totalMaterialObjects++;
}
public function get doubleSided():Boolean{
return (!(this.oneSide));
}
public function updateBitmap():void{
}
public function clone():MaterialObject3D{
var _local1:MaterialObject3D;
_local1 = new MaterialObject3D();
_local1.bitmap = this.bitmap;
_local1.animated = this.animated;
_local1.smooth = this.smooth;
_local1.lineColor = this.lineColor;
_local1.lineAlpha = this.lineAlpha;
_local1.fillColor = this.fillColor;
_local1.fillAlpha = this.fillAlpha;
_local1.oneSide = this.oneSide;
_local1.opposite = this.opposite;
_local1.invisible = this.invisible;
_local1.scene = this.scene;
_local1.name = this.name;
return (_local1);
}
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.animated = _arg1.animated;
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.scene = _arg1.scene;
this.name = _arg1.name;
}
public function set doubleSided(_arg1:Boolean):void{
this.oneSide = !(_arg1);
}
public static function get DEFAULT():MaterialObject3D{
var _local1:MaterialObject3D;
_local1 = new (MaterialObject3D);
_local1.lineColor = DEFAULT_COLOR;
_local1.lineAlpha = 100;
_local1.fillColor = DEFAULT_COLOR;
_local1.fillAlpha = 10;
_local1.doubleSided = true;
return (_local1);
}
}
}//package org.papervision3d.core.proto
Section 43
//SceneObject3D (org.papervision3d.core.proto.SceneObject3D)
package org.papervision3d.core.proto {
import org.papervision3d.objects.*;
import org.papervision3d.materials.*;
import flash.display.*;
import flash.utils.*;
import org.papervision3d.*;
public class SceneObject3D extends DisplayObjectContainer3D {
public var container:Sprite;
private var geometries:Dictionary;
public var objects:Array;
public var stats:Object;
public var materials:MaterialsList;
public function SceneObject3D(_arg1:Sprite){
if (_arg1){
this.container = _arg1;
} else {
Papervision3D.log("Scene3D: container argument required.");
};
this.objects = new Array();
this.materials = new MaterialsList();
Papervision3D.log((((((Papervision3D.NAME + " ") + Papervision3D.VERSION) + " (") + Papervision3D.DATE) + ")\n"));
this.stats = new Object();
this.stats.points = 0;
this.stats.polys = 0;
this.stats.triangles = 0;
this.stats.performance = 0;
this.stats.rendered = 0;
}
public function renderCamera(_arg1:CameraObject3D):void{
var _local2:Object;
var _local3:MaterialObject3D;
var _local4:Array;
var _local5:DisplayObject3D;
var _local6:Number;
_local2 = this.stats;
_local2.performance = getTimer();
for each (_local3 in this.materials) {
trace(("SceneObject3D:materials " + _local3));
if (_local3.animated){
_local3.updateBitmap();
};
};
if (_arg1){
_arg1.transformView();
_local4 = this.objects;
_local6 = _local4.length;
while ((_local5 = _local4[--_local6])) {
if (_local5.visible){
_local5.project(_arg1, _arg1);
};
};
};
if (_arg1.sort){
this.objects.sortOn("screenZ", Array.NUMERIC);
};
_local2.rendered = 0;
renderObjects(_arg1.sort);
}
protected function renderObjects(_arg1:Boolean):void{
}
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);
this.objects.push(_local3);
return (_local3);
}
}
}//package org.papervision3d.core.proto
Section 44
//Collada (org.papervision3d.core.utils.Collada)
package org.papervision3d.core.utils {
import org.papervision3d.core.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.objects.*;
import org.papervision3d.materials.*;
import flash.events.*;
import flash.display.*;
import org.papervision3d.core.geom.*;
import org.papervision3d.scenes.*;
import flash.net.*;
import org.papervision3d.*;
import org.papervision3d.events.*;
public class Collada extends EventDispatcher {
private var _container:DisplayObjectContainer3D;
private var _scaling:Number;
private var COLLADA:XML;
private var _callback:Function;
private var _filename:String;
private var _materials:MaterialsList;
private var _loader:URLLoader;
private var _yUp:Boolean;
private var _geometries:Object;
private static var NODESECTION:String = "node";
private static var SKEWNODE:String = "skew";
private static var INPUTTAG:String = "input";
private static var GEOMETRYSECTION:String = "geometry";
private static var VERTEXINPUT:String = "VERTEX";
private static var INSTANCENODE:String = "instance";
private static var POLYGON:String = "p";
private static var PERSPECTIVENODE:String = "perspective";
private static var POSITIONINPUT:String = "POSITION";
private static var LOOKATNODE:String = "lookat";
private static var ACCESSORSECTION:String = "accessor";
private static var UVINPUT:String = "UV";
private static var NORMALINPUT:String = "NORMAL";
private static var POLYGONSSECTION:String = "polygons";
private static var INSTACESCENE:String = "instance_visual_scene";
private static var TRANSLATENODE:String = "translate";
private static var SCALENODE:String = "scale";
private static var MESHSECTION:String = "mesh";
private static var VERTICESSECTION:String = "vertices";
private static var TANGENTINPUT:String = "TANGENT";
private static var MATERIALSECTION:String = "material";
private static var toDEGREES:Number = 57.2957795130823;
public static var DEFAULT_SCALING:Number = 1;
private static var SOURCESECTION:String = "source";
private static var TEXCOORDINPUT:String = "TEXCOORD";
private static var LIBRARYSECTION:String = "library";
private static var MATRIXNODE:String = "matrix";
private static var ROTATENODE:String = "rotate";
private static var SCENESECTION:String = "scene";
private static var INTERNAL_SCALING:Number = 100;
private static var CAMERAPREFAB:String = "camera";
private static var ARRAYSECTION:String = "array";
private static var PARAMTAG:String = "param";
private static var COLLADASECTION:String = "COLLADA";
private static var ASSETSECTION:String = "asset";
private static var LIGHTPREFAB:String = "light";
private static var toRADIANS:Number = 0.0174532925199433;
public function Collada(_arg1:DisplayObjectContainer3D, _arg2:String, _arg3:MaterialsList=null, _arg4:Number=1, _arg5:Function=null, _arg6:Object=null){
this._container = _arg1;
this._filename = _arg2;
this._materials = _arg3;
this._scaling = ((_arg4) || (DEFAULT_SCALING));
this._scaling = (this._scaling * INTERNAL_SCALING);
this._callback = _arg5;
this._geometries = new Object();
loadCollada();
}
private function parseGeometry(_arg1:XML, _arg2:DisplayObject3D, _arg3:Matrix3D=null):void{
var _local4:Matrix3D;
var _local5:Object;
var _local6:Array;
var _local7:Boolean;
var _local8:XML;
var _local9:Array;
var _local10:XML;
var _local11:Array;
var _local12:Number;
var _local13:String;
var _local14:Number;
var _local15:Object;
var _local16:Number;
var _local17:String;
var _local18:Number;
_local4 = ((Matrix3D.clone(_arg3)) || (Matrix3D.IDENTITY));
_local5 = new Object();
_local5.name = _arg1.@id;
_local6 = (_local5.triangles = new Array());
_local7 = (_arg1.mesh.triangles.length() > 1);
for each (_local8 in _arg1.mesh.triangles) {
_local9 = new Array();
for each (_local10 in _local8.input) {
_local5[_local10.@semantic] = deserialize(_local10, _arg1);
_local9.push(_local10.@semantic);
};
_local11 = _local8.p.split(" ");
_local12 = _local8.@count;
_local13 = _local8.@material;
addMaterial(_arg2, _local13);
_local14 = 0;
while (_local14 < _local12) {
_local15 = new Object();
_local16 = 0;
while (_local16 < 3) {
_local18 = 0;
while ((_local17 = _local9[_local18])) {
if (!_local15[_local17]){
_local15[_local17] = new Array();
};
_local15[_local17].push(Number(_local11.shift()));
_local18++;
};
_local15["material"] = _local13;
_local16++;
};
_local6.push(_local15);
_local14++;
};
};
buildObject(_local5, _arg2, _local4);
}
private function buildObject(_arg1:Object, _arg2:DisplayObject3D, _arg3:Matrix3D=null):void{
var _local4:Array;
var _local5:Number;
var _local6:Number;
var _local7:Array;
var _local8:Number;
var _local9:int;
var _local10:Array;
var _local11:Array;
var _local12:Object;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Array;
var _local17:Vertex3D;
var _local18:Vertex3D;
var _local19:Vertex3D;
var _local20:Array;
var _local21:Array;
var _local22:Array;
var _local23:Array;
var _local24:NumberUV;
var _local25:NumberUV;
var _local26:NumberUV;
var _local27:String;
var _local28:Face3D;
_arg3 = ((_arg3) || (Matrix3D.IDENTITY));
_arg2.addGeometry(new GeometryObject3D());
_local4 = (_arg2.geometry.vertices = new Array());
_local5 = this._scaling;
_local6 = _local4.length;
_local7 = _arg1.VERTEX;
_local8 = _local7.length;
_local9 = 0;
while (_local9 < _local8) {
_local12 = _local7[_local9];
_local13 = (Number(_local12.X) * _local5);
_local14 = (Number(_local12.Y) * _local5);
_local15 = (Number(_local12.Z) * _local5);
if (this._yUp){
_local4.push(new Vertex3D(-(_local13), _local14, _local15));
} else {
_local4.push(new Vertex3D(_local13, _local15, _local14));
};
_local9++;
};
_local10 = (_arg2.geometry.faces = new Array());
_local11 = _arg1.triangles;
_local8 = _local11.length;
_local9 = 0;
while (_local9 < _local8) {
_local16 = _local11[_local9].VERTEX;
_local17 = _local4[(_local6 + _local16[0])];
_local18 = _local4[(_local6 + _local16[1])];
_local19 = _local4[(_local6 + _local16[2])];
_local20 = [_local17, _local18, _local19];
_local21 = _arg1.TEXCOORD;
_local22 = _local11[_local9].TEXCOORD;
if (((_local22) && (_local21))){
_local24 = new NumberUV(_local21[_local22[0]].S, _local21[_local22[0]].T);
_local25 = new NumberUV(_local21[_local22[1]].S, _local21[_local22[1]].T);
_local26 = new NumberUV(_local21[_local22[2]].S, _local21[_local22[2]].T);
_local23 = [_local24, _local25, _local26];
} else {
_local23 = null;
};
_local27 = ((_local11[_local9].material) || (null));
_local28 = new Face3D(_local20, _local27, _local23);
_local10.push(_local28);
_local9++;
};
_arg2.geometry.ready = true;
_arg3.n14 = (_arg3.n14 * _local5);
_arg3.n24 = (_arg3.n24 * _local5);
_arg3.n34 = (_arg3.n34 * _local5);
_arg2.material = new ColorMaterial(0xFF0000, 0.25);
_arg2.visible = true;
}
private function getId(_arg1:String):String{
return (_arg1.split("#")[1]);
}
private function parseScene(_arg1:XML):void{
var _local2:XML;
for each (_local2 in _arg1.node) {
parseNode(_local2, this._container);
};
}
private function parseNode(_arg1:XML, _arg2:DisplayObjectContainer3D):void{
var matrix:Matrix3D;
var newNode:DisplayObject3D;
var instance:DisplayObject3D;
var children:XMLList;
var totalChildren:int;
var i:int;
var child:XML;
var geometry:XML;
var geoId:String;
var geo:XML;
var node = _arg1;
var parent = _arg2;
matrix = Matrix3D.IDENTITY;
if (String(node.instance_geometry) == ""){
newNode = new DisplayObject3D(node.@name);
} else {
newNode = new Mesh3D(null, null, null, node.@name);
};
instance = parent.addChild(newNode, node.@name);
children = node.children();
totalChildren = children.length();
i = 0;
while (i < totalChildren) {
child = children[i];
switch (child.name().localName){
case "translate":
matrix = Matrix3D.multiply(matrix, translateMatrix(getArray(child)));
break;
case "rotate":
matrix = Matrix3D.multiply(matrix, rotateMatrix(getArray(child)));
break;
case "scale":
matrix = Matrix3D.multiply(matrix, scaleMatrix(getArray(child)));
break;
case "matrix":
matrix = Matrix3D.multiply(matrix, new Matrix3D(getArray(child)));
break;
case "node":
parseNode(child, instance);
break;
case "instance_geometry":
for each (geometry in child) {
geoId = getId(geometry.@url);
geo = COLLADA.library_geometries.geometry.(@id == geoId)[0];
parseGeometry(geo, instance, Matrix3D.clone(matrix));
};
break;
};
i = (i + 1);
};
instance.copyTransform(matrix);
}
private function getArray(_arg1:String):Array{
var _local2:Array;
var _local3:Array;
var _local4:Number;
var _local5:Number;
_local2 = _arg1.split(" ");
_local3 = new Array();
_local4 = _local2.length;
_local5 = 0;
while (_local5 < _local4) {
_local3[_local5] = Number(_local2[_local5]);
_local5++;
};
return (_local3);
}
private function buildCollada():void{
var sceneId:String;
var scene:XML;
var fileEvent:FileLoadEvent;
this._yUp = (COLLADA.asset.up_axis == "Y_UP");
sceneId = getId(COLLADA.scene.instance_visual_scene.@url);
scene = COLLADA.library_visual_scenes.visual_scene.(@id == sceneId)[0];
parseScene(scene);
fileEvent = new FileLoadEvent(FileLoadEvent.LOAD_COMPLETE, _filename);
this.dispatchEvent(fileEvent);
}
private function addMaterial(_arg1:DisplayObject3D, _arg2:String):void{
var _local3:MaterialObject3D;
_local3 = this._materials.getMaterialByName(_arg2);
if (!_local3){
_local3 = new WireframeMaterial((Math.random() * 0xFFFFFF));
_local3.name = _arg2;
_local3.fillAlpha = 1;
_local3.fillColor = 0;
_local3.oneSide = true;
Papervision3D.log((("Collada material " + _arg2) + " not found."));
};
if (!_arg1.materials){
_arg1.materials = new MaterialsList();
};
_arg1.materials.addMaterial(_local3, _arg2);
}
private function scaleMatrix(_arg1:Array):Matrix3D{
if (this._yUp){
return (Matrix3D.scaleMatrix(_arg1[0], _arg1[1], _arg1[2]));
};
return (Matrix3D.scaleMatrix(_arg1[0], _arg1[2], _arg1[1]));
}
private function loadCollada():void{
this._loader = new URLLoader();
this._loader.addEventListener(Event.COMPLETE, onComplete);
this._loader.load(new URLRequest(this._filename));
}
private function translateMatrix(_arg1:Array):Matrix3D{
if (this._yUp){
return (Matrix3D.translationMatrix((-(_arg1[0]) * this._scaling), (_arg1[1] * this._scaling), (_arg1[2] * this._scaling)));
};
return (Matrix3D.translationMatrix((_arg1[0] * this._scaling), (_arg1[2] * this._scaling), (_arg1[1] * this._scaling)));
}
private function onComplete(_arg1:Event):void{
COLLADA = new XML(this._loader.data);
buildCollada();
}
private function rotateMatrix(_arg1:Array):Matrix3D{
if (this._yUp){
return (Matrix3D.rotationMatrix(_arg1[0], _arg1[1], _arg1[2], (-(_arg1[3]) * toRADIANS)));
};
return (Matrix3D.rotationMatrix(_arg1[0], _arg1[2], _arg1[1], (-(_arg1[3]) * toRADIANS)));
}
private function deserialize(_arg1:XML, _arg2:XML):Array{
var output:Array;
var id:String;
var acc:XMLList;
var floId:String;
var floXML:XMLList;
var floStr:String;
var floats:Array;
var params:Array;
var par:XML;
var count:int;
var stride:int;
var i:int;
var element:Object;
var j:int;
var recursive:XMLList;
var input = _arg1;
var geo = _arg2;
output = new Array();
id = input.@source.split("#")[1];
acc = geo..source.(@id == id).technique_common.accessor;
if (acc != new XMLList()){
floId = acc.@source.split("#")[1];
floXML = COLLADA..float_array.(@id == floId);
floStr = floXML.toString();
floats = floStr.split(" ");
params = new Array();
for each (par in acc.param) {
params.push(par.@name);
};
count = acc.@count;
stride = acc.@stride;
i = 0;
while (i < count) {
element = new Object();
j = 0;
while (j < stride) {
element[params[j]] = floats.shift();
j = (j + 1);
};
output.push(element);
i = (i + 1);
};
} else {
recursive = geo..vertices.(@id == id)[INPUTTAG];
output = deserialize(recursive[0], geo);
};
return (output);
}
}
}//package org.papervision3d.core.utils
Section 45
//Matrix3D (org.papervision3d.core.Matrix3D)
package org.papervision3d.core {
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 n21:Number;
public var n22:Number;
public var n23:Number;
public var n24:Number;
public var n34:Number;
private static var toDEGREES:Number = (180 / Math.PI);
private static var toRADIANS:Number = (Math.PI / 180);
public function Matrix3D(_arg1:Array){
if (_arg1.length >= 12){
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];
} else {
n11 = (n22 = (n33 = 1));
n12 = (n13 = (n14 = (n21 = (n23 = (n24 = (n31 = (n32 = (n34 = 0))))))));
};
}
public function get det():Number{
return ((((((this.n11 * this.n22) - (this.n21 * this.n12)) * this.n33) - (((this.n11 * this.n32) - (this.n31 * this.n12)) * this.n23)) + (((this.n21 * this.n32) - (this.n31 * this.n22)) * this.n13)));
}
public function 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 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"));
return (_local1);
}
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 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 multiply3x3(_arg1:Matrix3D, _arg2:Matrix3D):Matrix3D{
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:Number;
var _local20:Number;
var _local21:Number;
_local3 = IDENTITY;
_local4 = _arg1.n11;
_local5 = _arg2.n11;
_local6 = _arg1.n21;
_local7 = _arg2.n21;
_local8 = _arg1.n31;
_local9 = _arg2.n31;
_local10 = _arg1.n12;
_local11 = _arg2.n12;
_local12 = _arg1.n22;
_local13 = _arg2.n22;
_local14 = _arg1.n32;
_local15 = _arg2.n32;
_local16 = _arg1.n13;
_local17 = _arg2.n13;
_local18 = _arg1.n23;
_local19 = _arg2.n23;
_local20 = _arg1.n33;
_local21 = _arg2.n33;
_local3.n11 = (((_local4 * _local5) + (_local10 * _local7)) + (_local16 * _local9));
_local3.n12 = (((_local4 * _local11) + (_local10 * _local13)) + (_local16 * _local15));
_local3.n13 = (((_local4 * _local17) + (_local10 * _local19)) + (_local16 * _local21));
_local3.n21 = (((_local6 * _local5) + (_local12 * _local7)) + (_local18 * _local9));
_local3.n22 = (((_local6 * _local11) + (_local12 * _local13)) + (_local18 * _local15));
_local3.n23 = (((_local6 * _local17) + (_local12 * _local19)) + (_local18 * _local21));
_local3.n31 = (((_local8 * _local5) + (_local14 * _local7)) + (_local20 * _local9));
_local3.n32 = (((_local8 * _local11) + (_local14 * _local13)) + (_local20 * _local15));
_local3.n33 = (((_local8 * _local17) + (_local14 * _local19)) + (_local20 * _local21));
_local3.n14 = _arg1.n14;
_local3.n24 = _arg1.n24;
_local3.n34 = _arg1.n34;
return (_local3);
}
public static function normalizeQuaternion(_arg1:Object):Object{
var _local2:Number;
_local2 = magnitudeQuaternion(_arg1);
_arg1.x = (_arg1.x / _local2);
_arg1.y = (_arg1.y / _local2);
_arg1.z = (_arg1.z / _local2);
_arg1.w = (_arg1.w / _local2);
return (_arg1);
}
public static function multiplyVector(_arg1: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 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 getTrace(_arg1:Matrix3D):Number{
return ((((_arg1.n11 + _arg1.n22) + _arg1.n33) + 1));
}
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 euler2quaternion(_arg1:Number, _arg2:Number, _arg3:Number):Object{
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Object;
_local4 = Math.sin((_arg1 * 0.5));
_local5 = Math.cos((_arg1 * 0.5));
_local6 = Math.sin((_arg2 * 0.5));
_local7 = Math.cos((_arg2 * 0.5));
_local8 = Math.sin((_arg3 * 0.5));
_local9 = Math.cos((_arg3 * 0.5));
_local10 = (_local5 * _local7);
_local11 = (_local4 * _local6);
_local12 = new Object();
_local12.x = ((_local8 * _local10) - (_local9 * _local11));
_local12.y = (((_local9 * _local4) * _local7) + ((_local8 * _local5) * _local6));
_local12.z = (((_local9 * _local5) * _local6) - ((_local8 * _local4) * _local7));
_local12.w = ((_local9 * _local10) + (_local8 * _local11));
return (_local12);
}
public static function add(_arg1:Matrix3D, _arg2:Matrix3D):Matrix3D{
var _local3:Matrix3D;
_local3 = IDENTITY;
_local3.n11 = (_arg1.n11 + _arg2.n11);
_local3.n12 = (_arg1.n12 + _arg2.n12);
_local3.n13 = (_arg1.n13 + _arg2.n13);
_local3.n14 = (_arg1.n14 + _arg2.n14);
_local3.n21 = (_arg1.n21 + _arg2.n21);
_local3.n22 = (_arg1.n22 + _arg2.n22);
_local3.n23 = (_arg1.n23 + _arg2.n23);
_local3.n24 = (_arg1.n24 + _arg2.n24);
_local3.n31 = (_arg1.n31 + _arg2.n31);
_local3.n32 = (_arg1.n32 + _arg2.n32);
_local3.n33 = (_arg1.n33 + _arg2.n33);
_local3.n34 = (_arg1.n34 + _arg2.n34);
return (_local3);
}
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 multiply(_arg1:Matrix3D, _arg2:Matrix3D):Matrix3D{
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: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;
_local3 = IDENTITY;
_local4 = _arg1.n11;
_local5 = _arg2.n11;
_local10 = _arg1.n12;
_local7 = _arg2.n21;
_local16 = _arg1.n13;
_local9 = _arg2.n31;
_local3.n11 = (((_local4 * _local5) + (_local10 * _local7)) + (_local16 * _local9));
_local11 = _arg2.n12;
_local13 = _arg2.n22;
_local15 = _arg2.n32;
_local3.n12 = (((_local4 * _local11) + (_local10 * _local13)) + (_local16 * _local15));
_local17 = _arg2.n13;
_local19 = _arg2.n23;
_local21 = _arg2.n33;
_local3.n13 = (((_local4 * _local17) + (_local10 * _local19)) + (_local16 * _local21));
_local23 = _arg2.n14;
_local25 = _arg2.n24;
_local27 = _arg2.n34;
_local22 = _arg1.n14;
_local3.n14 = ((((_local4 * _local23) + (_local10 * _local25)) + (_local16 * _local27)) + _local22);
_local6 = _arg1.n21;
_local12 = _arg1.n22;
_local18 = _arg1.n23;
_local3.n21 = (((_local6 * _local5) + (_local12 * _local7)) + (_local18 * _local9));
_local3.n22 = (((_local6 * _local11) + (_local12 * _local13)) + (_local18 * _local15));
_local3.n23 = (((_local6 * _local17) + (_local12 * _local19)) + (_local18 * _local21));
_local24 = _arg1.n24;
_local3.n24 = ((((_local6 * _local23) + (_local12 * _local25)) + (_local18 * _local27)) + _local24);
_local8 = _arg1.n31;
_local14 = _arg1.n32;
_local20 = _arg1.n33;
_local3.n31 = (((_local8 * _local5) + (_local14 * _local7)) + (_local20 * _local9));
_local3.n32 = (((_local8 * _local11) + (_local14 * _local13)) + (_local20 * _local15));
_local3.n33 = (((_local8 * _local17) + (_local14 * _local19)) + (_local20 * _local21));
_local26 = _arg1.n34;
_local3.n34 = ((((_local8 * _local23) + (_local14 * _local25)) + (_local20 * _local27)) + _local26);
return (_local3);
}
public static function axisRotationWithReference(_arg1:Number3D, _arg2:Number3D, _arg3:Number):Matrix3D{
var _local4:Number;
var _local5:Matrix3D;
_local4 = ((_arg3 + 360) % 360);
_local5 = Matrix3D.translationMatrix(_arg2.x, -(_arg2.y), _arg2.z);
_local5 = Matrix3D.multiply(_local5, Matrix3D.rotationMatrix(_arg1.x, _arg1.y, _arg1.z, _local4));
_local5 = Matrix3D.multiply(_local5, Matrix3D.translationMatrix(-(_arg2.x), _arg2.y, -(_arg2.z)));
return (_local5);
}
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.w;
_local4 = _arg1.x;
_local5 = _arg1.y;
_local6 = _arg1.z;
_local7 = _arg1.w;
_local8 = _arg1.x;
_local9 = _arg1.y;
_local10 = _arg1.z;
_local11 = new Object();
_local11.w = ((((_local3 * _local7) - (_local4 * _local8)) - (_local5 * _local9)) - (_local6 * _local10));
_local11.x = ((((_local3 * _local8) + (_local4 * _local7)) + (_local5 * _local10)) - (_local6 * _local9));
_local11.y = ((((_local3 * _local9) + (_local5 * _local7)) + (_local6 * _local8)) - (_local4 * _local10));
_local11.z = ((((_local3 * _local10) + (_local6 * _local7)) + (_local4 * _local9)) - (_local5 * _local8));
return (_local11);
}
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;
_local2 = IDENTITY;
_local3 = (_arg1.x * toRADIANS);
_local4 = (_arg1.y * toRADIANS);
_local5 = (_arg1.z * toRADIANS);
_local6 = Math.cos(_local3);
_local7 = Math.sin(_local3);
_local8 = Math.cos(_local4);
_local9 = Math.sin(_local4);
_local10 = Math.cos(_local5);
_local11 = Math.sin(_local5);
_local12 = (_local6 * _local9);
_local13 = (_local7 * _local9);
_local2.n11 = (_local8 * _local10);
_local2.n12 = (-(_local8) * _local11);
_local2.n13 = _local9;
_local2.n21 = ((_local13 * _local10) + (_local6 * _local11));
_local2.n22 = ((-(_local13) * _local11) + (_local6 * _local10));
_local2.n23 = (-(_local7) * _local8);
_local2.n31 = ((-(_local12) * _local10) + (_local7 * _local11));
_local2.n32 = ((_local12 * _local11) + (_local7 * _local10));
_local2.n33 = (_local6 * _local8);
return (_local2);
}
public static function scaleMatrix(_arg1:Number, _arg2:Number, _arg3:Number):Matrix3D{
var _local4:Matrix3D;
_local4 = IDENTITY;
_local4.n11 = _arg1;
_local4.n22 = _arg2;
_local4.n33 = _arg3;
return (_local4);
}
public static function quaternion2matrix(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Matrix3D{
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:Matrix3D;
_local5 = (_arg1 * _arg1);
_local6 = (_arg1 * _arg2);
_local7 = (_arg1 * _arg3);
_local8 = (_arg1 * _arg4);
_local9 = (_arg2 * _arg2);
_local10 = (_arg2 * _arg3);
_local11 = (_arg2 * _arg4);
_local12 = (_arg3 * _arg3);
_local13 = (_arg3 * _arg4);
_local14 = IDENTITY;
_local14.n11 = (1 - (2 * (_local9 + _local12)));
_local14.n12 = (2 * (_local6 - _local13));
_local14.n13 = (2 * (_local7 + _local11));
_local14.n21 = (2 * (_local6 + _local13));
_local14.n22 = (1 - (2 * (_local5 + _local12)));
_local14.n23 = (2 * (_local10 - _local8));
_local14.n31 = (2 * (_local7 - _local11));
_local14.n32 = (2 * (_local10 + _local8));
_local14.n33 = (1 - (2 * (_local5 + _local9)));
return (_local14);
}
public static function rotationMatrix(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Matrix3D{
var _local5: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;
_local5 = IDENTITY;
_local6 = Math.cos(_arg4);
_local7 = Math.sin(_arg4);
_local8 = (1 - _local6);
_local9 = ((_arg1 * _arg2) * _local8);
_local10 = ((_arg2 * _arg3) * _local8);
_local11 = ((_arg1 * _arg3) * _local8);
_local12 = (_local7 * _arg3);
_local13 = (_local7 * _arg2);
_local14 = (_local7 * _arg1);
_local5.n11 = (_local6 + ((_arg1 * _arg1) * _local8));
_local5.n12 = (-(_local12) + _local9);
_local5.n13 = (_local13 + _local11);
_local5.n21 = (_local12 + _local9);
_local5.n22 = (_local6 + ((_arg2 * _arg2) * _local8));
_local5.n23 = (-(_local14) + _local10);
_local5.n31 = (-(_local13) + _local11);
_local5.n32 = (_local14 + _local10);
_local5.n33 = (_local6 + ((_arg3 * _arg3) * _local8));
return (_local5);
}
public static function inverse(_arg1:Matrix3D):Matrix3D{
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){
return (null);
};
_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;
return (new Matrix3D([(_local2 * ((_local7 * _local11) - (_local8 * _local10))), (-(_local2) * ((_local6 * _local11) - (_local8 * _local9))), (_local2 * ((_local6 * _local10) - (_local7 * _local9))), (-(_local2) * (((_local6 * ((_local10 * _local14) - (_local11 * _local13))) - (_local7 * ((_local9 * _local14) - (_local11 * _local12)))) + (_local8 * ((_local9 * _local13) - (_local10 * _local12))))), (-(_local2) * ((_local4 * _local11) - (_local5 * _local10))), (_local2 * ((_local3 * _local11) - (_local5 * _local9))), (-(_local2) * ((_local3 * _local10) - (_local4 * _local9))), (_local2 * (((_local3 * ((_local10 * _local14) - (_local11 * _local13))) - (_local4 * ((_local9 * _local14) - (_local11 * _local12)))) + (_local5 * ((_local9 * _local13) - (_local10 * _local12))))), (_local2 * ((_local4 * _local8) - (_local5 * _local7))), (-(_local2) * ((_local3 * _local8) - (_local5 * _local6))), (_local2 * ((_local3 * _local7) - (_local4 * _local6))), (-(_local2) * (((_local3 * ((_local7 * _local14) - (_local8 * _local13))) - (_local4 * ((_local6 * _local14) - (_local8 * _local12)))) + (_local5 * ((_local6 * _local13) - (_local7 * _local12)))))]));
}
public static function matrix2euler(_arg1:Matrix3D):Number3D{
var _local2:Number3D;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
_local2 = new Number3D();
_local3 = -(Math.asin(Math.max(-1, Math.min(1, _arg1.n13))));
_local4 = Math.cos(_local3);
_local2.y = (_local3 * toDEGREES);
if (Math.abs(_local4) > 0.005){
_local5 = (_arg1.n33 / _local4);
_local6 = (-(_arg1.n23) / _local4);
_local2.x = (Math.atan2(_local6, _local5) * toDEGREES);
_local5 = (_arg1.n11 / _local4);
_local6 = (-(_arg1.n12) / _local4);
_local2.z = (Math.atan2(_local6, _local5) * toDEGREES);
} else {
_local2.x = 0;
_local5 = _arg1.n22;
_local6 = _arg1.n21;
_local2.z = (Math.atan2(_local6, _local5) * toDEGREES);
};
return (_local2);
}
public static function get IDENTITY():Matrix3D{
return (new Matrix3D([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0]));
}
}
}//package org.papervision3d.core
Section 46
//Number3D (org.papervision3d.core.Number3D)
package org.papervision3d.core {
public class Number3D {
public var x:Number;
public var y:Number;
public var z:Number;
public function Number3D(_arg1:Number=0, _arg2:Number=0, _arg3:Number=0){
this.x = _arg1;
this.y = _arg2;
this.z = _arg3;
}
public function toString():String{
return (((((("x:" + x) + " y:") + y) + " z:") + z));
}
public function normalize():void{
var _local1:Number;
_local1 = this.modulo;
if (((!((_local1 == 0))) && (!((_local1 == 1))))){
this.x = (this.x / _local1);
this.y = (this.y / _local1);
this.z = (this.z / _local1);
};
}
public function get modulo():Number{
return (Math.sqrt((((this.x * this.x) + (this.y * this.y)) + (this.z * this.z))));
}
public function clone():Number3D{
return (new Number3D(this.x, this.y, this.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):Number3D{
return (new Number3D(((_arg2.y * _arg1.z) - (_arg2.z * _arg1.y)), ((_arg2.z * _arg1.x) - (_arg2.x * _arg1.z)), ((_arg2.x * _arg1.y) - (_arg2.y * _arg1.x))));
}
public static function get ZERO():Number3D{
return (new Number3D(0, 0, 0));
}
public static function dot(_arg1:Number3D, _arg2:Number3D):Number{
return ((((_arg1.x * _arg2.x) + (_arg1.y * _arg2.y)) + (_arg2.z * _arg1.z)));
}
}
}//package org.papervision3d.core
Section 47
//NumberUV (org.papervision3d.core.NumberUV)
package org.papervision3d.core {
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
Section 48
//FileLoadEvent (org.papervision3d.events.FileLoadEvent)
package org.papervision3d.events {
import flash.events.*;
public class FileLoadEvent extends Event {
public var file:String;
public static var LOAD_COMPLETE:String = "loadComplete";
public static var LOAD_ERROR:String = "loadError";
public function FileLoadEvent(_arg1:String, _arg2:String="", _arg3:Boolean=false, _arg4:Boolean=false){
super(_arg1, _arg3, _arg4);
file = _arg2;
}
}
}//package org.papervision3d.events
Section 49
//BitmapMaterial (org.papervision3d.materials.BitmapMaterial)
package org.papervision3d.materials {
import org.papervision3d.core.proto.*;
import flash.display.*;
public class BitmapMaterial extends MaterialObject3D {
protected var _texture;
public function BitmapMaterial(_arg1, _arg2:Object=null){
super(_arg2);
texture = _arg1;
}
public function set texture(_arg1):void{
this.bitmap = createBitmap(_arg1);
this._texture = _arg1;
}
protected function createBitmap(_arg1):BitmapData{
return (_arg1);
}
public function get texture(){
return (this._texture);
}
override public function toString():String{
return (((((("Texture:" + this.texture) + " lineColor:") + this.lineColor) + " lineAlpha:") + this.lineAlpha));
}
}
}//package org.papervision3d.materials
Section 50
//ColorMaterial (org.papervision3d.materials.ColorMaterial)
package org.papervision3d.materials {
import org.papervision3d.core.proto.*;
public class ColorMaterial extends MaterialObject3D {
public function ColorMaterial(_arg1:Number=0xFF00FF, _arg2:Number=100, _arg3:Object=null){
super(_arg3);
this.fillColor = _arg1;
this.fillAlpha = _arg2;
}
override public function toString():String{
return (((("ColorMaterial - color:" + this.fillColor) + " alpha:") + this.fillAlpha));
}
}
}//package org.papervision3d.materials
Section 51
//MaterialsList (org.papervision3d.materials.MaterialsList)
package org.papervision3d.materials {
import org.papervision3d.core.proto.*;
import flash.utils.*;
public class MaterialsList {
public var materialsByName:Dictionary;
protected var _materials: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 (this._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]);
}
}
}//package org.papervision3d.materials
Section 52
//WireframeMaterial (org.papervision3d.materials.WireframeMaterial)
package org.papervision3d.materials {
import org.papervision3d.core.proto.*;
public class WireframeMaterial extends MaterialObject3D {
public function WireframeMaterial(_arg1:Number=0xFF00FF, _arg2:Number=100, _arg3:Object=null){
super(_arg3);
this.lineColor = _arg1;
this.lineAlpha = _arg2;
this.doubleSided = true;
}
override public function toString():String{
return (((("WireframeMaterial - color:" + this.lineColor) + " alpha:") + this.lineAlpha));
}
}
}//package org.papervision3d.materials
Section 53
//DisplayObject3D (org.papervision3d.objects.DisplayObject3D)
package org.papervision3d.objects {
import org.papervision3d.core.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.materials.*;
import flash.display.*;
import flash.utils.*;
import com.blitzagency.xray.logger.*;
import org.papervision3d.*;
public class DisplayObject3D extends DisplayObjectContainer3D {
public var extra:Object;
public var id:int;
private var _rotationY:Number;
private var _rotationZ:Number;
private var _rotationX:Number;
public var material:MaterialObject3D;
public var materials:MaterialsList;
private var _scaleDirty:Boolean;// = false
private var _scaleX:Number;
public var screenZ:Number;
public var geometry:GeometryObject3D;
private var _scaleY:Number;
private var _scaleZ:Number;
public var projected:Dictionary;
public var transform:Matrix3D;
public var visible:Boolean;
public var name:String;
public var scene:SceneObject3D;
public var container:Sprite;
public var parent:DisplayObjectContainer3D;
public var view:Matrix3D;
public var faces:Array;
protected var _transformDirty:Boolean;// = false
private var _rotationDirty:Boolean;// = false
protected var _sorted:Array;
private static var BACKWARD:Number3D = new Number3D(0, 0, -1);
private static var FORWARD:Number3D = new Number3D(0, 0, 1);
private static var LEFT:Number3D = new Number3D(-1, 0, 0);
private static var DOWN:Number3D = new Number3D(0, -1, 0);
private static var toDEGREES:Number = 57.2957795130823;
private static var _totalDisplayObjects:int = 0;
private static var UP:Number3D = new Number3D(0, 1, 0);
private static var RIGHT:Number3D = new Number3D(1, 0, 0);
private static var toRADIANS:Number = 0.0174532925199433;
public function DisplayObject3D(_arg1:String=null, _arg2:GeometryObject3D=null, _arg3:Object=null):void{
var _local4:Number;
faces = new Array();
_transformDirty = false;
_rotationDirty = false;
_scaleDirty = false;
super();
Papervision3D.log(("DisplayObject3D: " + _arg1));
this.transform = Matrix3D.IDENTITY;
this.view = Matrix3D.IDENTITY;
this.x = (_arg3) ? ((_arg3.x) || (0)) : 0;
this.y = (_arg3) ? ((_arg3.y) || (0)) : 0;
this.z = (_arg3) ? ((_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;
};
if (((_arg3) && (_arg3.container))){
this.container = _arg3.container;
};
this.visible = true;
this.id = _totalDisplayObjects++;
this.name = ((_arg1) || (String(this.id)));
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 project(_arg1:DisplayObject3D, _arg2:CameraObject3D, _arg3:Array=null):Number{
var _local4:Number;
var _local5:Number;
var _local6:DisplayObject3D;
if (!_arg3){
_arg3 = new Array();
this._sorted = _arg3;
};
if (this._transformDirty){
updateTransform();
};
this.view = Matrix3D.multiply(_arg1.view, this.transform);
_local4 = 0;
_local5 = 0;
for each (_local6 in this._childrenByName) {
if (_local6.visible){
_local4 = (_local4 + _local6.project(this, _arg2, _arg3));
_local5++;
};
};
return ((this.screenZ = (_local4 / _local5)));
}
public function lookAt(_arg1:DisplayObject3D, _arg2:Number3D=null):void{
var _local3:Number3D;
var _local4:Number3D;
var _local5:Number3D;
var _local6:Number3D;
var _local7:Number3D;
var _local8:Matrix3D;
var _local9:XrayLog;
_local3 = new Number3D(this.x, this.y, this.z);
_local4 = new Number3D(_arg1.x, _arg1.y, _arg1.z);
_local5 = Number3D.sub(_local4, _local3);
_local5.normalize();
if (_local5.modulo > 0.1){
_local6 = Number3D.cross(_local5, ((_arg2) || (UP)));
_local6.normalize();
_local7 = Number3D.cross(_local5, _local6);
_local7.normalize();
_local8 = this.transform;
_local8.n11 = _local6.x;
_local8.n21 = _local6.y;
_local8.n31 = _local6.z;
_local8.n12 = -(_local7.x);
_local8.n22 = -(_local7.y);
_local8.n32 = -(_local7.z);
_local8.n13 = _local5.x;
_local8.n23 = _local5.y;
_local8.n33 = _local5.z;
this._transformDirty = false;
this._rotationDirty = true;
} else {
_local9 = new XrayLog();
_local9.debug("lookAt Error");
};
}
public function set rotationX(_arg1:Number):void{
this._rotationX = (Papervision3D.useDEGREES) ? (-(_arg1) * toRADIANS) : -(_arg1);
this._transformDirty = true;
}
public function set rotationZ(_arg1:Number):void{
this._rotationZ = (Papervision3D.useDEGREES) ? (-(_arg1) * toRADIANS) : -(_arg1);
this._transformDirty = true;
}
public function addGeometry(_arg1:GeometryObject3D=null):void{
if (_arg1){
this.geometry = _arg1;
};
this.projected = new Dictionary();
}
public function set rotationY(_arg1:Number):void{
this._rotationY = (Papervision3D.useDEGREES) ? (-(_arg1) * toRADIANS) : -(_arg1);
this._transformDirty = true;
}
public function moveUp(_arg1:Number):void{
translate(_arg1, UP);
}
public function pitch(_arg1:Number):void{
var _local2:Number3D;
var _local3:Matrix3D;
_arg1 = (Papervision3D.useDEGREES) ? (_arg1 * toRADIANS) : _arg1;
_local2 = RIGHT.clone();
if (this._transformDirty){
updateTransform();
};
Matrix3D.rotateAxis(transform, _local2);
_local3 = Matrix3D.rotationMatrix(_local2.x, _local2.y, _local2.z, _arg1);
this.transform.copy3x3(Matrix3D.multiply3x3(_local3, transform));
this._rotationDirty = true;
}
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 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 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.boundingSphere2 : 0;
_local8 = (_arg1.geometry) ? _arg1.geometry.boundingSphere2 : 0;
_local7 = (_local7 * _arg2);
return (((_local7 + _local8) > _local6));
}
private function updateRotation():void{
var _local1:Number3D;
_local1 = Matrix3D.matrix2euler(this.transform);
this._rotationX = (_local1.x * toRADIANS);
this._rotationY = (_local1.y * toRADIANS);
this._rotationZ = (_local1.z * toRADIANS);
this._rotationDirty = false;
}
public function yaw(_arg1:Number):void{
var _local2:Number3D;
var _local3:Matrix3D;
_arg1 = (Papervision3D.useDEGREES) ? (_arg1 * toRADIANS) : _arg1;
_local2 = UP.clone();
if (this._transformDirty){
updateTransform();
};
Matrix3D.rotateAxis(transform, _local2);
_local3 = Matrix3D.rotationMatrix(_local2.x, _local2.y, _local2.z, _arg1);
this.transform.copy3x3(Matrix3D.multiply3x3(_local3, transform));
this._rotationDirty = true;
}
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 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 y():Number{
return (this.transform.n24);
}
public function get z():Number{
return (this.transform.n34);
}
public function roll(_arg1:Number):void{
var _local2:Number3D;
var _local3:Matrix3D;
_arg1 = (Papervision3D.useDEGREES) ? (_arg1 * toRADIANS) : _arg1;
_local2 = FORWARD.clone();
if (this._transformDirty){
updateTransform();
};
Matrix3D.rotateAxis(transform, _local2);
_local3 = Matrix3D.rotationMatrix(_local2.x, _local2.y, _local2.z, _arg1);
this.transform.copy3x3(Matrix3D.multiply3x3(_local3, 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 moveLeft(_arg1:Number):void{
translate(_arg1, LEFT);
}
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 render(_arg1:SceneObject3D):void{
var _local2:Array;
var _local3:Sprite;
var _local4:Number;
var _local5:Object;
var _local6:int;
_local2 = this._sorted;
_local2.sortOn("screenZ", (Array.DESCENDING | Array.NUMERIC));
_local3 = ((this.container) || (_arg1.container));
_local4 = 0;
_local6 = 0;
while ((_local5 = _local2[_local6])) {
if (_local5.visible){
_local4 = (_local4 + _local5.face.render(_local5.instance, _local3));
};
_local6++;
};
_arg1.stats.rendered = (_arg1.stats.rendered + _local4);
}
public function get rotationY():Number{
if (this._rotationDirty){
updateRotation();
};
return ((Papervision3D.useDEGREES) ? (-(this._rotationY) * toDEGREES) : -(this._rotationY));
}
public function get rotationZ():Number{
if (this._rotationDirty){
updateRotation();
};
return ((Papervision3D.useDEGREES) ? (-(this._rotationZ) * toDEGREES) : -(this._rotationZ));
}
public function set scaleY(_arg1:Number):void{
if (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 set scaleX(_arg1:Number):void{
if (Papervision3D.usePERCENT){
this._scaleX = (_arg1 / 100);
} else {
this._scaleX = _arg1;
};
this._transformDirty = true;
}
public function get x():Number{
return (this.transform.n14);
}
protected function updateTransform():void{
var _local1:Object;
var _local2:Matrix3D;
var _local3:Matrix3D;
var _local4:Matrix3D;
_local1 = Matrix3D.euler2quaternion(-(this._rotationY), -(this._rotationZ), this._rotationX);
_local2 = Matrix3D.quaternion2matrix(_local1.x, _local1.y, _local1.z, _local1.w);
_local3 = this.transform;
_local2.n14 = _local3.n14;
_local2.n24 = _local3.n24;
_local2.n34 = _local3.n34;
_local3.copy(_local2);
_local4 = Matrix3D.IDENTITY;
_local4.n11 = this._scaleX;
_local4.n22 = this._scaleY;
_local4.n33 = this._scaleZ;
this.transform = Matrix3D.multiply(_local3, _local4);
this._transformDirty = false;
}
public function moveForward(_arg1:Number):void{
translate(_arg1, FORWARD);
}
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 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 = (((_arg1 * _arg1) + (_arg2 * _arg2)) + (_arg3 * _arg3));
_local8 = (this.geometry) ? this.geometry.boundingSphere2 : 0;
return ((_local8 > _local7));
}
public function moveRight(_arg1:Number):void{
translate(_arg1, RIGHT);
}
public function moveBackward(_arg1:Number):void{
translate(_arg1, BACKWARD);
}
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 x(_arg1:Number):void{
this.transform.n14 = _arg1;
}
public function set y(_arg1:Number):void{
this.transform.n24 = _arg1;
}
public static function get ZERO():DisplayObject3D{
return (new (DisplayObject3D));
}
}
}//package org.papervision3d.objects
Section 54
//Scene3D (org.papervision3d.scenes.Scene3D)
package org.papervision3d.scenes {
import org.papervision3d.core.proto.*;
import org.papervision3d.objects.*;
import flash.display.*;
import flash.utils.*;
public class Scene3D extends SceneObject3D {
public function Scene3D(_arg1:Sprite){
super(_arg1);
}
override protected function renderObjects(_arg1:Boolean):void{
var _local2:DisplayObject3D;
var _local3:Array;
var _local4:Number;
var _local5:Object;
this.container.graphics.clear();
_local3 = this.objects;
_local4 = _local3.length;
while ((_local2 = _local3[--_local4])) {
if (_local2.visible){
_local2.render(this);
};
};
_local5 = this.stats;
_local5.performance = (getTimer() - _local5.performance);
}
}
}//package org.papervision3d.scenes
Section 55
//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 | papervision3d.org | C4RL054321@gmail.com";
public static var DATE:String = "01.02.07";
public static var NAME:String = "Papervision3D";
public static var VERSION:String = "Beta RC1";
public static var usePERCENT:Boolean = false;
public static function log(_arg1:String):void{
if (Papervision3D.VERBOSE){
trace(_arg1);
};
}
}
}//package org.papervision3d
Section 56
//Main (Main)
package {
import org.papervision3d.core.proto.*;
import org.papervision3d.materials.*;
import flash.events.*;
import flash.display.*;
import de.popforge.imageprocessing.core.*;
import flash.geom.*;
import org.papervision3d.cameras.*;
import org.papervision3d.scenes.*;
import de.popforge.imageprocessing.geom.*;
import de.popforge.imageprocessing.filters.color.*;
import de.popforge.imageprocessing.filters.convolution.*;
import de.popforge.imageprocessing.filters.noise.*;
import flash.text.*;
public class Main extends Sprite {
private var camera:Camera3D;
private var material:MaterialObject3D;
private var curveScreen:Bitmap;
private var geom:RotationGeometry;
private var center:RotationMesh;
private var container:Sprite;
private var scene:Scene3D;
private var dragPoint:Point;
private var table:Array;
private var curve:Curve;
public function Main(){
var _local1:TextField;
var _local2:TextFormat;
var _local3:Image;
super();
stage.quality = StageQuality.LOW;
stage.scaleMode = StageScaleMode.NO_SCALE;
curve = new Curve(true, CurveMode.CUBIC);
curve.addPoint(new Point(64, 192));
curve.addPoint(new Point(192, 64));
curveScreen = new Bitmap(new BitmapData(0x0100, 0x0100, false, 0));
update();
_local1 = new TextField();
_local2 = new TextFormat();
_local1.x = 10;
_local1.y = 10;
_local1.width = 640;
_local1.selectable = false;
_local1.textColor = 0xCCCCCC;
_local2.size = 10;
_local2.bold = true;
_local2.font = "Verdana";
_local1.defaultTextFormat = _local2;
_local1.multiline = true;
_local1.text = "papervision3d dynamic roto geom.\nclick on screen for wireframe.\nplay around with curve :)";
container = new Sprite();
container.x = 500;
container.y = 300;
scene = new Scene3D(container);
camera = new Camera3D();
camera.x = 2000;
camera.y = 500;
camera.z = 500;
camera.zoom = 5;
camera.focus = 100;
curveScreen.x = (1000 - 266);
curveScreen.y = 10;
addChild(curveScreen);
addChild(container);
addChild(_local1);
geom = new RotationGeometry(curveFunction, 500, 500, 16, 16);
_local3 = new Image(0x0100, 0x0100, ImageFormat.RGB);
new PerlinNoise(32, 32, 16, -1, true, true, 7).apply(_local3);
new Sepia().apply(_local3);
new Emboss().apply(_local3);
material = new BitmapMaterial(_local3.bitmapData);
material.doubleSided = true;
material.lineColor = 0xFFFF;
scene.addChild((center = new RotationMesh(material, geom)));
stage.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
stage.addEventListener(MouseEvent.MOUSE_UP, onMouseUp);
stage.addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
private function onMouseUp(_arg1:MouseEvent):void{
dragPoint = null;
material.lineAlpha = 0;
stage.removeEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
update();
}
private function onEnterFrame(_arg1:Event):void{
camera.x = (camera.x + (((-(container.mouseX) * 5) - camera.x) / 40));
camera.y = (camera.y + (((-(container.mouseY) * 5) - camera.y) / 40));
center.rotationY = (center.rotationY + 0.5);
scene.renderCamera(camera);
}
private function onMouseDown(_arg1:MouseEvent):void{
var _local2:Point;
var _local3:Point;
var _local4:int;
var _local5:Number;
var _local6:Number;
_local2 = new Point(_arg1.stageX, _arg1.stageY);
_local3 = _local2.clone();
_local2.x = (_local2.x - curveScreen.x);
_local2.y = (_local2.y - curveScreen.y);
_local2.x = int((_local2.x + 0.5));
_local2.y = (0xFF - int((_local2.y + 0.5)));
dragPoint = null;
_local4 = 0;
while (_local4 < curve.points.length) {
_local5 = ((curve.points[_local4] as Point).x - _local2.x);
_local6 = ((curve.points[_local4] as Point).y - _local2.y);
if (Math.sqrt(((_local5 * _local5) + (_local6 * _local6))) < 8){
dragPoint = curve.points[_local4];
stage.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
return;
};
_local4++;
};
if (curveScreen.getRect(stage).containsPoint(_local3)){
curve.addPoint(_local2);
dragPoint = _local2;
stage.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
update();
} else {
material.lineAlpha = 1;
};
}
private function update():void{
curveScreen.bitmapData.draw(curve.getBitmapData());
table = curve.getTable();
geom = new RotationGeometry(curveFunction, 500, 500, 16, 16);
if (center != null){
center.geometry = geom;
center.projectTexture("x", "z");
};
}
private function curveFunction(_arg1:Number):Number{
return ((((table[Math.round((_arg1 * 0xFF))] - 128) / 128) * 250));
}
private function onMouseMove(_arg1:MouseEvent):void{
var _local2:Point;
if (dragPoint == null){
return;
};
_local2 = new Point(_arg1.stageX, _arg1.stageY);
if (curveScreen.getRect(stage).containsPoint(_local2)){
_local2.x = (_local2.x - curveScreen.x);
_local2.y = (_local2.y - curveScreen.y);
_local2.x = int((_local2.x + 0.5));
_local2.y = (0xFF - int((_local2.y + 0.5)));
dragPoint.x = _local2.x;
dragPoint.y = _local2.y;
} else {
curve.removePoint(dragPoint);
dragPoint = null;
};
update();
}
}
}//package
import org.papervision3d.core.proto.*;
import org.papervision3d.core.geom.*;
class RotationGeometry extends GeometryObject3D {
private var radiusDetail:int;
private var radius:Number;
private var heightHalf:Number;
private var height:Number;
private var radiusAdd:Number;
private var funcDetail:int;
private var funcAdd:Number;
private var func:Function;
private var stripes:Array;
private var heightAdd:Number;
private function RotationGeometry(_arg1:Function, _arg2:Number=100, _arg3:Number=100, _arg4:int=16, _arg5:int=16){
func = _arg1;
funcDetail = _arg4;
this.height = _arg2;
this.radius = _arg3;
this.radiusDetail = _arg5;
radiusAdd = (360 / _arg5);
funcAdd = (1 / _arg4);
heightAdd = (_arg2 * funcAdd);
heightHalf = (-(_arg2) * 0.5);
stripes = new Array(_arg5);
buildGeometry();
}
private function buildGeometry():void{
var _local1:Number;
var _local2:Number;
var _local3:Vertex3D;
var _local4:int;
var _local5:int;
var _local6:int;
var _local7:Number;
var _local8:Number;
var _local9:int;
var _local10:Number;
var _local11:Number;
var _local12:int;
var _local13:int;
var _local14:int;
vertices = new Array();
_local1 = radiusAdd;
_local4 = 0;
while (_local4 < radiusDetail) {
stripes[_local4] = new Array();
_local2 = 0;
_local9 = 0;
while (_local9 < funcDetail) {
_local10 = (_local1 * (Math.PI / 180));
_local11 = (radius + func((_local9 / funcDetail)));
_local3 = new Vertex3D((Math.cos(_local10) * _local11), (heightHalf + _local2), (Math.sin(_local10) * _local11));
stripes[_local4].push(_local3);
vertices.push(_local3);
_local2 = (_local2 + heightAdd);
_local9++;
};
_local1 = (_local1 + radiusAdd);
_local4++;
};
faces = new Array();
_local5 = (radiusDetail - 1);
_local6 = (funcDetail - 1);
_local7 = (1 / radiusDetail);
_local8 = (1 / funcDetail);
_local4 = 0;
while (_local4 < radiusDetail) {
_local9 = 0;
while (_local9 < funcDetail) {
_local12 = (_local4 + 1);
_local13 = (_local9 + 1);
_local14 = _local12;
if (_local4 == _local5){
_local12 = 0;
};
if (_local9 == _local6){
} else {
faces.push(new Face3D([stripes[_local4][_local9], stripes[_local4][_local13], stripes[_local12][_local9]]));
faces.push(new Face3D([stripes[_local12][_local9], stripes[_local4][_local13], stripes[_local12][_local13]]));
};
_local9++;
};
_local4++;
};
ready = true;
}
}
class RotationMesh extends Mesh3D {
private function RotationMesh(_arg1:MaterialObject3D, _arg2:RotationGeometry, _arg3:Object=null){
super(_arg1, new Array(), new Array(), null, _arg3);
this.geometry = _arg2;
projectTexture("x", "z");
}
}