Section 1
//KerbLog (com.kerb.logger.KerbLog)
package com.kerb.logger {
import flash.events.*;
import flash.display.*;
public final class KerbLog extends EventDispatcher {
private var _view:KerbLogView;
private var _level:KerbLogLevel;
private var _entries:Array;
private static const MAX_ENTRIES:uint = 100;
private static var _allow:Boolean = false;
private static var _instance:KerbLog = null;
public function KerbLog(){
if (!_allow){
throw (new Error("direct instantiation of uk.kerb.utils.logger.Log is forbidden"));
};
_entries = new Array();
_level = KerbLogLevel.Info;
_view = new KerbLogView(this);
}
public function set stage(_arg1:Stage):void{
_view.stage = _arg1;
}
private function _add(_arg1:String):void{
_entries.push(new KerbLogEntry(_arg1));
if (_entries.length > MAX_ENTRIES){
_entries.shift();
};
}
public function fatal(_arg1:String):void{
_add(_arg1);
if ((((((_level == KerbLogLevel.Fatal)) || ((_level == KerbLogLevel.Info)))) || ((_level == KerbLogLevel.Debug)))){
_dispatch();
};
}
public function info(_arg1:String):void{
_add(_arg1);
if ((((_level == KerbLogLevel.Info)) || ((_level == KerbLogLevel.Debug)))){
_dispatch();
};
}
public function set level(_arg1:KerbLogLevel):void{
_level = _arg1;
}
private function _dispatch():void{
dispatchEvent(new KerbLogEvent(_entries[(_entries.length - 1)]));
}
public function debug(_arg1:String):void{
_add(_arg1);
if (_level == KerbLogLevel.Debug){
_dispatch();
};
}
public function get level():KerbLogLevel{
return (_level);
}
public static function instance():KerbLog{
if (_instance == null){
_allow = true;
_instance = new (KerbLog);
_allow = false;
};
return (_instance);
}
}
}//package com.kerb.logger
Section 2
//KerbLogEntry (com.kerb.logger.KerbLogEntry)
package com.kerb.logger {
final class KerbLogEntry {
private var _message:String;
private var _date:Date;
function KerbLogEntry(_arg1:String){
_message = _arg1;
_date = new Date();
}
public function get message():String{
return (_message);
}
public function get date():Date{
return (_date);
}
}
}//package com.kerb.logger
Section 3
//KerbLogEvent (com.kerb.logger.KerbLogEvent)
package com.kerb.logger {
import flash.events.*;
final class KerbLogEvent extends Event {
private var _logEntry:KerbLogEntry;
public static const TYPE:String = "onLogEntry";
function KerbLogEvent(_arg1:KerbLogEntry){
super(TYPE);
_logEntry = _arg1;
}
public function get logEntry():KerbLogEntry{
return (_logEntry);
}
}
}//package com.kerb.logger
Section 4
//KerbLogLevel (com.kerb.logger.KerbLogLevel)
package com.kerb.logger {
public final class KerbLogLevel {
public static const Debug:KerbLogLevel = new (KerbLogLevel);
;
public static const Fatal:KerbLogLevel = new (KerbLogLevel);
;
public static const Info:KerbLogLevel = new (KerbLogLevel);
;
public static const None:KerbLogLevel = new (KerbLogLevel);
;
}
}//package com.kerb.logger
Section 5
//KerbLogView (com.kerb.logger.KerbLogView)
package com.kerb.logger {
import flash.events.*;
import flash.display.*;
import com.kerb.logger.*;
import flash.utils.*;
import flash.text.*;
import flash.ui.*;
import flash.system.*;
final class KerbLogView {
private var _container:Sprite;
private var _log:KerbLog;
private var _timer:Timer;// = null
private var _dragBar:Sprite;
private var _closeButton:Sprite;
private var _textField:TextField;
private var _frames:uint;// = 0
private var _minimized:Boolean;// = false
private var _clearButton:Sprite;
private var _minButton:Sprite;
private var _copyButton:Sprite;
private var _fps:TextField;
private var _greyBox:Sprite;
private var _stage:Stage;
private static const HEIGHT:uint = 100;
private static const DRAG_BAR_HEIGHT:uint = 10;
private static const COLOUR_BLUE:uint = 0xFF;
private static const MARGIN:uint = 5;
private static const COLOUR_GREEN:uint = 0x66CC00;
private static const COLOUR_GREY:uint = 0x999999;
private static const BUTTON_LENGTH:uint = 10;
private static const DISPLAY_FONT_SIZE:uint = 11;
private static const COLOUR_WHITE:uint = 0xFFFFFF;
private static const COLOUR_RED:uint = 0xFF0000;
private static const DISPLAY_FONT_COLOUR:uint = 0xFFFFFF;
function KerbLogView(_arg1:KerbLog){
_log = _arg1;
_log.addEventListener(KerbLogEvent.TYPE, _eventHandler);
_timer = new Timer(1000);
_timer.addEventListener(TimerEvent.TIMER, _onTimer);
}
private function _onCloseButtonClick(_arg1:MouseEvent):void{
_container.visible = false;
}
private function _createMinButton():void{
_minButton = new Sprite();
_minButton.x = ((_container.width - (2.5 * BUTTON_LENGTH)) - MARGIN);
_minButton.y = MARGIN;
_minButton.graphics.beginFill(COLOUR_RED);
_minButton.graphics.lineStyle(0, COLOUR_WHITE);
_minButton.graphics.drawRect(0, 0, BUTTON_LENGTH, BUTTON_LENGTH);
_minButton.graphics.endFill();
_minButton.graphics.moveTo(0, (BUTTON_LENGTH / 2));
_minButton.graphics.lineTo(BUTTON_LENGTH, (BUTTON_LENGTH / 2));
_minButton.buttonMode = true;
_minButton.addEventListener(MouseEvent.CLICK, _onMinButtonClick, false, 0, true);
_container.addChild(_minButton);
}
private function _createGraphics():void{
if (_container == null){
_createContainer();
_createDragBar();
_createFPSTextField();
_createCloseButton();
_createMinButton();
_createClearButton();
_createCopyButton();
_createTextField();
_container.addEventListener(MouseEvent.MOUSE_OVER, _onMouseOver);
_timer.start();
_container.addEventListener(Event.ENTER_FRAME, _onEnterFrame);
} else {
if (!_container.visible){
_container.visible = true;
};
};
}
private function _onDragBarMouseUp(_arg1:MouseEvent):void{
_container.removeEventListener(MouseEvent.MOUSE_MOVE, _onContainerMouseMove);
_container.stopDrag();
}
private function _onDragBarMouseDown(_arg1:MouseEvent):void{
_container.addEventListener(MouseEvent.MOUSE_MOVE, _onContainerMouseMove);
_container.startDrag();
}
private function _onEnterFrame(_arg1:Event):void{
_frames++;
}
private function _onCopyButtonClick(_arg1:MouseEvent):void{
System.setClipboard(_textField.text);
}
private function _createCopyButton():void{
_copyButton = new Sprite();
_copyButton.x = ((_container.width - (5.5 * BUTTON_LENGTH)) - MARGIN);
_copyButton.y = MARGIN;
_copyButton.graphics.beginFill(COLOUR_GREEN);
_copyButton.graphics.lineStyle(0, COLOUR_WHITE);
_copyButton.graphics.drawRect(0, 0, BUTTON_LENGTH, BUTTON_LENGTH);
_copyButton.graphics.endFill();
_copyButton.buttonMode = true;
_copyButton.addEventListener(MouseEvent.CLICK, _onCopyButtonClick, false, 0, true);
_container.addChild(_copyButton);
}
private function _onTimer(_arg1:TimerEvent):void{
_fps.text = (String(_frames) + " fps");
_frames = 0;
}
private function _onMinButtonClick(_arg1:MouseEvent):void{
_doMinButtonClick();
}
private function _createDragBar():void{
_dragBar = new Sprite();
_dragBar.x = 0;
_dragBar.y = 0;
_dragBar.graphics.beginFill(COLOUR_BLUE);
_dragBar.graphics.lineStyle(0, COLOUR_WHITE, 0);
_dragBar.graphics.drawRect(0, 0, _container.width, (2 * BUTTON_LENGTH));
_dragBar.graphics.endFill();
_dragBar.buttonMode = true;
_dragBar.addEventListener(MouseEvent.MOUSE_DOWN, _onDragBarMouseDown, false, 0, true);
_dragBar.addEventListener(MouseEvent.MOUSE_UP, _onDragBarMouseUp, false, 0, true);
_container.addChild(_dragBar);
}
private function _createFPSTextField():void{
_fps = new TextField();
_fps.x = MARGIN;
_fps.y = 1;
_fps.width = 100;
_fps.height = 30;
_fps.autoSize = TextFieldAutoSize.NONE;
_fps.embedFonts = false;
_fps.antiAliasType = AntiAliasType.NORMAL;
_fps.wordWrap = true;
_fps.selectable = false;
_fps.mouseEnabled = false;
_fps.defaultTextFormat = new TextFormat("_typewriter", DISPLAY_FONT_SIZE, DISPLAY_FONT_COLOUR);
_container.addChild(_fps);
}
private function _eventHandler(_arg1:KerbLogEvent):void{
var _local2:String;
_createGraphics();
if (_textField != null){
_local2 = ((timeTo24HourString(_arg1.logEntry.date) + ": ") + _arg1.logEntry.message);
_textField.appendText((_local2 + "\n"));
trace(_local2);
_textField.scrollV = _textField.maxScrollV;
};
}
private function _doMinButtonClick():void{
_minimized = !(_minimized);
_greyBox.visible = !(_minimized);
_textField.visible = !(_minimized);
_container.y = ((_stage.stageHeight - (_minimized) ? (2 * BUTTON_LENGTH) : HEIGHT) - MARGIN);
}
private function _createClearButton():void{
_clearButton = new Sprite();
_clearButton.x = ((_container.width - (4 * BUTTON_LENGTH)) - MARGIN);
_clearButton.y = MARGIN;
_clearButton.graphics.beginFill(COLOUR_GREY);
_clearButton.graphics.lineStyle(0, COLOUR_WHITE);
_clearButton.graphics.drawRect(0, 0, BUTTON_LENGTH, BUTTON_LENGTH);
_clearButton.graphics.endFill();
_clearButton.buttonMode = true;
_clearButton.addEventListener(MouseEvent.CLICK, _onClearButtonClick, false, 0, true);
_container.addChild(_clearButton);
}
private function _createTextField():void{
_textField = new TextField();
_textField.x = MARGIN;
_textField.y = ((2 * BUTTON_LENGTH) + MARGIN);
_textField.width = (_container.width - (2 * MARGIN));
_textField.height = ((_container.height - (2 * BUTTON_LENGTH)) - (2 * MARGIN));
_textField.autoSize = TextFieldAutoSize.NONE;
_textField.embedFonts = false;
_textField.antiAliasType = AntiAliasType.NORMAL;
_textField.wordWrap = true;
_textField.defaultTextFormat = new TextFormat("_typewriter", DISPLAY_FONT_SIZE, DISPLAY_FONT_COLOUR);
_container.addChild(_textField);
}
private function _onClearButtonClick(_arg1:MouseEvent):void{
_textField.text = "";
}
private function _createContainer():void{
_container = new Sprite();
_container.x = MARGIN;
_container.y = ((_stage.stageHeight - HEIGHT) - MARGIN);
_greyBox = new Sprite();
_greyBox.graphics.beginFill(COLOUR_GREY);
_greyBox.graphics.drawRect(0, 0, (_stage.stageWidth - (2 * MARGIN)), (HEIGHT - (2 * BUTTON_LENGTH)));
_greyBox.graphics.endFill();
_greyBox.y = (2 * BUTTON_LENGTH);
_container.addChild(_greyBox);
_stage.addChild(_container);
}
private function _createCloseButton():void{
_closeButton = new Sprite();
_closeButton.x = ((_container.width - BUTTON_LENGTH) - MARGIN);
_closeButton.y = MARGIN;
_closeButton.graphics.beginFill(COLOUR_RED);
_closeButton.graphics.lineStyle(0, COLOUR_WHITE);
_closeButton.graphics.drawRect(0, 0, BUTTON_LENGTH, BUTTON_LENGTH);
_closeButton.graphics.endFill();
_closeButton.graphics.moveTo(0, 0);
_closeButton.graphics.lineTo(BUTTON_LENGTH, BUTTON_LENGTH);
_closeButton.graphics.moveTo(BUTTON_LENGTH, 0);
_closeButton.graphics.lineTo(0, BUTTON_LENGTH);
_closeButton.buttonMode = true;
_closeButton.addEventListener(MouseEvent.CLICK, _onCloseButtonClick, false, 0, true);
_container.addChild(_closeButton);
}
private function _onContainerMouseMove(_arg1:MouseEvent):void{
_arg1.updateAfterEvent();
}
private function _onMouseOver(_arg1:MouseEvent):void{
Mouse.show();
}
public function set stage(_arg1:Stage):void{
_stage = _arg1;
}
public static function timeTo24HourString(_arg1:Date):String{
var _local2 = "";
_local2 = (_local2 + numberToFixedLengthString(_arg1.getHours(), 2, 0, "0"));
_local2 = (_local2 + ":");
_local2 = (_local2 + numberToFixedLengthString(_arg1.getMinutes(), 2, 0, "0"));
_local2 = (_local2 + ":");
_local2 = (_local2 + numberToFixedLengthString(_arg1.getSeconds(), 2, 0, "0"));
return (_local2);
}
public static function numberToFixedLengthString(_arg1:Number, _arg2:uint=4, _arg3:uint=4, _arg4:String=" "):String{
var _local5:String = String(((_arg1 == 0)) ? _arg1 : _arg1.toFixed(_arg3));
var _local6:uint = _arg2;
if (_arg3 > 0){
_local6 = (_local6 + (1 + _arg3));
};
_arg4 = _arg4.charAt(0);
while (_local5.length < _local6) {
_local5 = (_arg4 + _local5);
};
return (_local5);
}
}
}//package com.kerb.logger
Section 6
//IScreen (com.kerb.sokator.freekick.screens.IScreen)
package com.kerb.sokator.freekick.screens {
import flash.events.*;
import flash.display.*;
import com.kerb.utils.*;
public interface IScreen extends IDisposable, IEventDispatcher {
function setTotalKicks(_arg1:int):void;
function setRanking(_arg1:int):void;
function setVideoAsset(_arg1:MovieClip):void;
}
}//package com.kerb.sokator.freekick.screens
Section 7
//ScreenBase (com.kerb.sokator.freekick.screens.ScreenBase)
package com.kerb.sokator.freekick.screens {
import flash.events.*;
import flash.display.*;
import flash.net.*;
import com.kerb.utils.*;
import com.kerb.logger.*;
import com.kerb.sokator.freekick.*;
import flash.geom.*;
import com.kerb.tracking.*;
import com.kerb.sokator.freekick.screens.*;
import flash.text.*;
class ScreenBase extends EventDispatcher implements IScreen {
protected var _af:AssetFactory;
private var _dao:DisplayObjectContainer;
private var _videoAsset:MovieClip;
private var _promoCode:String;
private var _symbolName:String;
private var _doubleQuickClickId:int;
private var _kicks:int;
protected var _clip:MovieClip;
private var _ranking:int;
function ScreenBase(_arg1:String, _arg2:DisplayObjectContainer, _arg3:String, _arg4:int){
_symbolName = _arg1;
_dao = _arg2;
_promoCode = _arg3;
_doubleQuickClickId = _arg4;
_af = new AssetFactory();
_af.addEventListener(AssetFactory.EVENT_ASSET_FACTORY_READY, _onAssetFactoryReady);
}
final protected function _getTotalKicks():int{
return (Math.min(9999, _kicks));
}
private function _onPlaySfxLaserWipe(_arg1:Event):void{
_clip.removeEventListener("EVENT_PLAY_SFX_LASER_WIPE", _onPlaySfxLaserWipe);
Sounds.instance().playLaserWipe();
}
final public function dispose():void{
if (_dao != null){
if (_dao.contains(_clip)){
_dao.removeChild(_clip);
};
_clip = null;
};
}
final public function setVideoAsset(_arg1:MovieClip):void{
_videoAsset = _arg1;
}
private function _onClipComplete(_arg1:Event):void{
var _local2:DisplayObjectContainer;
_clip.removeEventListener(Event.COMPLETE, _onClipComplete);
if (_videoAsset != null){
_videoAsset.gotoAndStop(1);
_local2 = _videoAsset.parent;
if (_local2 != null){
_local2.removeChild(_videoAsset);
};
_videoAsset = null;
};
dispatchEvent(new Event(Event.COMPLETE));
}
final public function setTotalKicks(_arg1:int):void{
_kicks = _arg1;
}
private function _onVideoAssetAddedToStage(_arg1:Event):void{
_videoAsset.removeEventListener(Event.ADDED_TO_STAGE, _onVideoAssetAddedToStage);
_videoAsset.gotoAndPlay(2);
_videoAsset.addEventListener(MouseEvent.CLICK, _onVideoAssetClicked);
_videoAsset.addEventListener(MouseEvent.ROLL_OVER, _onVideoAssetRollOver);
_videoAsset.addEventListener(MouseEvent.ROLL_OUT, _onVideoAssetRollOut);
_videoAsset.buttonMode = true;
_videoAsset.mouseChildren = false;
_videoAsset.mouseEnabled = true;
_videoAsset.useHandCursor = true;
}
final protected function _getRanking():int{
return (_ranking);
}
private function _onVideoAssetClicked(_arg1:MouseEvent):void{
navigateToURL(new URLRequest(Main.SOKATOR_URL));
DoubleQuick.click(_doubleQuickClickId);
}
private function _onSetup(_arg1:Event):void{
_clip.removeEventListener("EVENT_SETUP", _onSetup);
_setupNextButton();
var _local2:TextField = (_clip.getChildByName("code_txt") as TextField);
if (_local2 != null){
Sounds.instance().playPromoInfoDisplay();
_local2.selectable = true;
_local2.text = _promoCode;
} else {
KerbLog.instance().info("\"code_txt\" missing from timeline");
};
var _local3:MovieClip = (_clip.getChildByName("link1_mc") as MovieClip);
if (_local3 != null){
_local3.mouseChildren = false;
_local3.mouseEnabled = true;
_local3.buttonMode = true;
_local3.useHandCursor = true;
_local3.addEventListener(MouseEvent.CLICK, _onSokatorSiteLinkClicked);
} else {
KerbLog.instance().info("\"link1_mc\" missing from timeline");
};
var _local4:MovieClip = (_clip.getChildByName("placeholder_mc") as MovieClip);
if (_local4 != null){
if (_videoAsset != null){
_videoAsset.addEventListener(Event.ADDED_TO_STAGE, _onVideoAssetAddedToStage);
_local4.addChild(_videoAsset);
Sounds.instance().playMusicTheme();
} else {
KerbLog.instance().info("_videoAsset hasn't been setup");
};
} else {
KerbLog.instance().info("\"placeholder_mc\" missing from timeline");
};
_setupExtraStuff();
}
protected function _setupNextButton():void{
var _local1:MovieClip = (_clip.getChildByName("next_mc") as MovieClip);
if (_local1 != null){
_local1.mouseChildren = false;
_local1.mouseEnabled = true;
_local1.buttonMode = true;
_local1.useHandCursor = true;
_local1.addEventListener(MouseEvent.CLICK, _onNextClicked);
} else {
KerbLog.instance().info("\"next_mc\" missing from timeline");
};
}
private function _onVideoAssetRollOver(_arg1:MouseEvent):void{
_videoAsset.transform.colorTransform = new ColorTransform(0.45, 0.45, 0.45);
}
private function _onNextClicked(_arg1:MouseEvent):void{
var _local2:MovieClip = (_clip.getChildByName("next_mc") as MovieClip);
if (_local2 != null){
Sounds.instance().stopPromoInfoDisplay();
Sounds.instance().playButtonPress();
_local2.mouseChildren = false;
_local2.mouseEnabled = false;
_local2.buttonMode = false;
_local2.useHandCursor = false;
_local2.removeEventListener(MouseEvent.CLICK, _onNextClicked);
};
_clip.gotoAndPlay("out");
Sounds.instance().stopMusicTheme();
}
protected function _setupExtraStuff():void{
}
private function _onAssetFactoryReady(_arg1:Event):void{
_af.removeEventListener(AssetFactory.EVENT_ASSET_FACTORY_READY, _onAssetFactoryReady);
_clip = (_af.createDisplayObject(_symbolName) as MovieClip);
_clip.y = 30;
_dao.addChild(_clip);
_clip.addEventListener("EVENT_PLAY_SFX_LASER_WIPE", _onPlaySfxLaserWipe);
_clip.addEventListener("EVENT_SETUP", _onSetup);
_clip.addEventListener(Event.COMPLETE, _onClipComplete);
}
final public function setRanking(_arg1:int):void{
_ranking = _arg1;
}
private function _onVideoAssetRollOut(_arg1:MouseEvent):void{
_videoAsset.transform.colorTransform = new ColorTransform(1, 1, 1);
}
private function _onSokatorSiteLinkClicked(_arg1:MouseEvent):void{
navigateToURL(new URLRequest(Main.SOKATOR_URL));
DoubleQuick.click(_doubleQuickClickId);
}
}
}//package com.kerb.sokator.freekick.screens
Section 8
//ScreenBoots (com.kerb.sokator.freekick.screens.ScreenBoots)
package com.kerb.sokator.freekick.screens {
import flash.display.*;
public final class ScreenBoots extends ScreenBase {
private const swfBytes:Class;
public function ScreenBoots(_arg1:DisplayObjectContainer, _arg2:String, _arg3:int){
swfBytes = ScreenBoots_swfBytes;
super("ScreenBoots", _arg1, _arg2, _arg3);
_af.initialize(swfBytes);
}
}
}//package com.kerb.sokator.freekick.screens
Section 9
//ScreenBoots_swfBytes (com.kerb.sokator.freekick.screens.ScreenBoots_swfBytes)
package com.kerb.sokator.freekick.screens {
import mx.core.*;
public class ScreenBoots_swfBytes extends ByteArrayAsset {
}
}//package com.kerb.sokator.freekick.screens
Section 10
//ScreenGoggles (com.kerb.sokator.freekick.screens.ScreenGoggles)
package com.kerb.sokator.freekick.screens {
import flash.display.*;
public final class ScreenGoggles extends ScreenBase {
private const swfBytes:Class;
public function ScreenGoggles(_arg1:DisplayObjectContainer, _arg2:String, _arg3:int){
swfBytes = ScreenGoggles_swfBytes;
super("ScreenGoggles", _arg1, _arg2, _arg3);
_af.initialize(swfBytes);
}
}
}//package com.kerb.sokator.freekick.screens
Section 11
//ScreenGoggles_swfBytes (com.kerb.sokator.freekick.screens.ScreenGoggles_swfBytes)
package com.kerb.sokator.freekick.screens {
import mx.core.*;
public class ScreenGoggles_swfBytes extends ByteArrayAsset {
}
}//package com.kerb.sokator.freekick.screens
Section 12
//ScreenPeace (com.kerb.sokator.freekick.screens.ScreenPeace)
package com.kerb.sokator.freekick.screens {
import flash.display.*;
public final class ScreenPeace extends ScreenBase {
private const swfBytes:Class;
public function ScreenPeace(_arg1:DisplayObjectContainer, _arg2:String, _arg3:int){
swfBytes = ScreenPeace_swfBytes;
super("ScreenPeace", _arg1, _arg2, _arg3);
_af.initialize(swfBytes);
}
}
}//package com.kerb.sokator.freekick.screens
Section 13
//ScreenPeace_swfBytes (com.kerb.sokator.freekick.screens.ScreenPeace_swfBytes)
package com.kerb.sokator.freekick.screens {
import mx.core.*;
public class ScreenPeace_swfBytes extends ByteArrayAsset {
}
}//package com.kerb.sokator.freekick.screens
Section 14
//ScreenSuperTop (com.kerb.sokator.freekick.screens.ScreenSuperTop)
package com.kerb.sokator.freekick.screens {
import flash.display.*;
public final class ScreenSuperTop extends ScreenBase {
private const swfBytes:Class;
public function ScreenSuperTop(_arg1:DisplayObjectContainer, _arg2:String, _arg3:int){
swfBytes = ScreenSuperTop_swfBytes;
super("ScreenSuperTop", _arg1, _arg2, _arg3);
_af.initialize(swfBytes);
}
}
}//package com.kerb.sokator.freekick.screens
Section 15
//ScreenSuperTop_swfBytes (com.kerb.sokator.freekick.screens.ScreenSuperTop_swfBytes)
package com.kerb.sokator.freekick.screens {
import mx.core.*;
public class ScreenSuperTop_swfBytes extends ByteArrayAsset {
}
}//package com.kerb.sokator.freekick.screens
Section 16
//ScreenUnicycle (com.kerb.sokator.freekick.screens.ScreenUnicycle)
package com.kerb.sokator.freekick.screens {
import flash.display.*;
import com.kerb.logger.*;
import flash.text.*;
public final class ScreenUnicycle extends ScreenBase {
private const swfBytes:Class;
public function ScreenUnicycle(_arg1:DisplayObjectContainer, _arg2:String, _arg3:int){
swfBytes = ScreenUnicycle_swfBytes;
super("ScreenUnicycle", _arg1, _arg2, _arg3);
_af.initialize(swfBytes);
}
private function _setRanking(_arg1:MovieClip, _arg2:int):void{
if (_arg2 < 1){
_arg2 = 1;
};
if (_arg2 > 10){
_arg2 = 10;
};
_arg1.gotoAndStop(_arg2);
}
override protected function _setupExtraStuff():void{
var _local1:String = _getTotalKicks().toString();
while (_local1.length < 4) {
_local1 = ("0" + _local1);
};
var _local2:TextField = (_clip.getChildByName("kicks_txt") as TextField);
if (_local2 != null){
_local2.text = _local1;
} else {
KerbLog.instance().info("\"kicks_txt\" missing from timeline");
};
var _local3:MovieClip = (_clip.getChildByName("ranking_mc") as MovieClip);
if (_local3 != null){
_setRanking(_local3, _getRanking());
} else {
KerbLog.instance().info("\"ranking_mc\" missing from timeline");
};
}
override protected function _setupNextButton():void{
}
}
}//package com.kerb.sokator.freekick.screens
Section 17
//ScreenUnicycle_swfBytes (com.kerb.sokator.freekick.screens.ScreenUnicycle_swfBytes)
package com.kerb.sokator.freekick.screens {
import mx.core.*;
public class ScreenUnicycle_swfBytes extends ByteArrayAsset {
}
}//package com.kerb.sokator.freekick.screens
Section 18
//BaseTexturePack (com.kerb.sokator.freekick.textures.BaseTexturePack)
package com.kerb.sokator.freekick.textures {
import flash.display.*;
import com.kerb.utils.*;
import com.kerb.sokator.freekick.textures.*;
class BaseTexturePack implements ITexturePack {
protected var _rightWallBitmapData:BitmapData;
protected var _floorBitmapData:BitmapData;
protected var _leftWallBitmapData:BitmapData;
protected var _ceilingColour:Number;
protected var _backWallMovieClipName:String;
final public function getFloorBitmapData():BitmapData{
return (_floorBitmapData);
}
final public function getRightWallBitmapData():BitmapData{
return (_rightWallBitmapData);
}
final public function getLeftWallBitmapData():BitmapData{
return (_leftWallBitmapData);
}
final public function getBackWallMovieClip(_arg1:AssetFactory):MovieClip{
return ((_arg1.createDisplayObject(_backWallMovieClipName) as MovieClip));
}
final public function getCeilingColour():Number{
return (_ceilingColour);
}
}
}//package com.kerb.sokator.freekick.textures
Section 19
//Desert (com.kerb.sokator.freekick.textures.Desert)
package com.kerb.sokator.freekick.textures {
public class Desert extends BaseTexturePack {
private var WallRightTexture:Class;
private var WallLeftTexture:Class;
private var FloorTexture:Class;
public function Desert(){
FloorTexture = Desert_FloorTexture;
WallLeftTexture = Desert_WallLeftTexture;
WallRightTexture = Desert_WallRightTexture;
super();
_floorBitmapData = new FloorTexture().bitmapData;
_leftWallBitmapData = new WallLeftTexture().bitmapData;
_rightWallBitmapData = new WallRightTexture().bitmapData;
_backWallMovieClipName = "BackWallDesert";
_ceilingColour = 0xB74800;
}
}
}//package com.kerb.sokator.freekick.textures
Section 20
//Desert_FloorTexture (com.kerb.sokator.freekick.textures.Desert_FloorTexture)
package com.kerb.sokator.freekick.textures {
import mx.core.*;
public class Desert_FloorTexture extends BitmapAsset {
}
}//package com.kerb.sokator.freekick.textures
Section 21
//Desert_WallLeftTexture (com.kerb.sokator.freekick.textures.Desert_WallLeftTexture)
package com.kerb.sokator.freekick.textures {
import mx.core.*;
public class Desert_WallLeftTexture extends BitmapAsset {
}
}//package com.kerb.sokator.freekick.textures
Section 22
//Desert_WallRightTexture (com.kerb.sokator.freekick.textures.Desert_WallRightTexture)
package com.kerb.sokator.freekick.textures {
import mx.core.*;
public class Desert_WallRightTexture extends BitmapAsset {
}
}//package com.kerb.sokator.freekick.textures
Section 23
//Ice (com.kerb.sokator.freekick.textures.Ice)
package com.kerb.sokator.freekick.textures {
public final class Ice extends BaseTexturePack {
private var WallRightTexture:Class;
private var WallLeftTexture:Class;
private var FloorTexture:Class;
public function Ice(){
FloorTexture = Ice_FloorTexture;
WallLeftTexture = Ice_WallLeftTexture;
WallRightTexture = Ice_WallRightTexture;
super();
_floorBitmapData = new FloorTexture().bitmapData;
_leftWallBitmapData = new WallLeftTexture().bitmapData;
_rightWallBitmapData = new WallRightTexture().bitmapData;
_backWallMovieClipName = "BackWallIce";
_ceilingColour = 1548503;
}
}
}//package com.kerb.sokator.freekick.textures
Section 24
//Ice_FloorTexture (com.kerb.sokator.freekick.textures.Ice_FloorTexture)
package com.kerb.sokator.freekick.textures {
import mx.core.*;
public class Ice_FloorTexture extends BitmapAsset {
}
}//package com.kerb.sokator.freekick.textures
Section 25
//Ice_WallLeftTexture (com.kerb.sokator.freekick.textures.Ice_WallLeftTexture)
package com.kerb.sokator.freekick.textures {
import mx.core.*;
public class Ice_WallLeftTexture extends BitmapAsset {
}
}//package com.kerb.sokator.freekick.textures
Section 26
//Ice_WallRightTexture (com.kerb.sokator.freekick.textures.Ice_WallRightTexture)
package com.kerb.sokator.freekick.textures {
import mx.core.*;
public class Ice_WallRightTexture extends BitmapAsset {
}
}//package com.kerb.sokator.freekick.textures
Section 27
//ITexturePack (com.kerb.sokator.freekick.textures.ITexturePack)
package com.kerb.sokator.freekick.textures {
import flash.display.*;
import com.kerb.utils.*;
public interface ITexturePack {
function getLeftWallBitmapData():BitmapData;
function getCeilingColour():Number;
function getBackWallMovieClip(_arg1:AssetFactory):MovieClip;
function getRightWallBitmapData():BitmapData;
function getFloorBitmapData():BitmapData;
}
}//package com.kerb.sokator.freekick.textures
Section 28
//Jungle (com.kerb.sokator.freekick.textures.Jungle)
package com.kerb.sokator.freekick.textures {
public class Jungle extends BaseTexturePack {
private var WallRightTexture:Class;
private var WallLeftTexture:Class;
private var FloorTexture:Class;
public function Jungle(){
FloorTexture = Jungle_FloorTexture;
WallLeftTexture = Jungle_WallLeftTexture;
WallRightTexture = Jungle_WallRightTexture;
super();
_floorBitmapData = new FloorTexture().bitmapData;
_leftWallBitmapData = new WallLeftTexture().bitmapData;
_rightWallBitmapData = new WallRightTexture().bitmapData;
_backWallMovieClipName = "BackWallJungle";
_ceilingColour = 15332268;
}
}
}//package com.kerb.sokator.freekick.textures
Section 29
//Jungle_FloorTexture (com.kerb.sokator.freekick.textures.Jungle_FloorTexture)
package com.kerb.sokator.freekick.textures {
import mx.core.*;
public class Jungle_FloorTexture extends BitmapAsset {
}
}//package com.kerb.sokator.freekick.textures
Section 30
//Jungle_WallLeftTexture (com.kerb.sokator.freekick.textures.Jungle_WallLeftTexture)
package com.kerb.sokator.freekick.textures {
import mx.core.*;
public class Jungle_WallLeftTexture extends BitmapAsset {
}
}//package com.kerb.sokator.freekick.textures
Section 31
//Jungle_WallRightTexture (com.kerb.sokator.freekick.textures.Jungle_WallRightTexture)
package com.kerb.sokator.freekick.textures {
import mx.core.*;
public class Jungle_WallRightTexture extends BitmapAsset {
}
}//package com.kerb.sokator.freekick.textures
Section 32
//Mountain (com.kerb.sokator.freekick.textures.Mountain)
package com.kerb.sokator.freekick.textures {
public class Mountain extends BaseTexturePack {
private var WallRightTexture:Class;
private var WallLeftTexture:Class;
private var FloorTexture:Class;
public function Mountain(){
FloorTexture = Mountain_FloorTexture;
WallLeftTexture = Mountain_WallLeftTexture;
WallRightTexture = Mountain_WallRightTexture;
super();
_floorBitmapData = new FloorTexture().bitmapData;
_leftWallBitmapData = new WallLeftTexture().bitmapData;
_rightWallBitmapData = new WallRightTexture().bitmapData;
_backWallMovieClipName = "BackWallMountain";
_ceilingColour = 8612982;
}
}
}//package com.kerb.sokator.freekick.textures
Section 33
//Mountain_FloorTexture (com.kerb.sokator.freekick.textures.Mountain_FloorTexture)
package com.kerb.sokator.freekick.textures {
import mx.core.*;
public class Mountain_FloorTexture extends BitmapAsset {
}
}//package com.kerb.sokator.freekick.textures
Section 34
//Mountain_WallLeftTexture (com.kerb.sokator.freekick.textures.Mountain_WallLeftTexture)
package com.kerb.sokator.freekick.textures {
import mx.core.*;
public class Mountain_WallLeftTexture extends BitmapAsset {
}
}//package com.kerb.sokator.freekick.textures
Section 35
//Mountain_WallRightTexture (com.kerb.sokator.freekick.textures.Mountain_WallRightTexture)
package com.kerb.sokator.freekick.textures {
import mx.core.*;
public class Mountain_WallRightTexture extends BitmapAsset {
}
}//package com.kerb.sokator.freekick.textures
Section 36
//Swamp (com.kerb.sokator.freekick.textures.Swamp)
package com.kerb.sokator.freekick.textures {
public class Swamp extends BaseTexturePack {
private var WallRightTexture:Class;
private var WallLeftTexture:Class;
private var FloorTexture:Class;
public function Swamp(){
FloorTexture = Swamp_FloorTexture;
WallLeftTexture = Swamp_WallLeftTexture;
WallRightTexture = Swamp_WallRightTexture;
super();
_floorBitmapData = new FloorTexture().bitmapData;
_leftWallBitmapData = new WallLeftTexture().bitmapData;
_rightWallBitmapData = new WallRightTexture().bitmapData;
_backWallMovieClipName = "BackWallSwamp";
_ceilingColour = 15462608;
}
}
}//package com.kerb.sokator.freekick.textures
Section 37
//Swamp_FloorTexture (com.kerb.sokator.freekick.textures.Swamp_FloorTexture)
package com.kerb.sokator.freekick.textures {
import mx.core.*;
public class Swamp_FloorTexture extends BitmapAsset {
}
}//package com.kerb.sokator.freekick.textures
Section 38
//Swamp_WallLeftTexture (com.kerb.sokator.freekick.textures.Swamp_WallLeftTexture)
package com.kerb.sokator.freekick.textures {
import mx.core.*;
public class Swamp_WallLeftTexture extends BitmapAsset {
}
}//package com.kerb.sokator.freekick.textures
Section 39
//Swamp_WallRightTexture (com.kerb.sokator.freekick.textures.Swamp_WallRightTexture)
package com.kerb.sokator.freekick.textures {
import mx.core.*;
public class Swamp_WallRightTexture extends BitmapAsset {
}
}//package com.kerb.sokator.freekick.textures
Section 40
//BackWall (com.kerb.sokator.freekick.BackWall)
package com.kerb.sokator.freekick {
import com.kerb.utils.*;
import com.kerb.sokator.freekick.*;
import org.papervision3d.scenes.*;
import org.papervision3d.view.layer.*;
import org.papervision3d.materials.utils.*;
import jiglib.math.*;
import jiglib.physics.*;
import jiglib.geometry.*;
import org.papervision3d.lights.*;
import org.papervision3d.objects.primitives.*;
import org.papervision3d.materials.shadematerials.*;
final class BackWall implements IDisposable {
private var _physics:PhysicsSystem;
private var _boxes:Array;
public static const BLOCK_DEPTH:Number = 50;
private static const BLOCK_HEIGHT:Number = 10000;
private static const BLOCK_COUNT:int = 15;
function BackWall(_arg1:Scene3D, _arg2:PhysicsSystem, _arg3:ViewportLayer, _arg4:PointLight3D, _arg5:Number, _arg6:LevelData){
_physics = _arg2;
_boxes = [];
_makeHole(_arg1, _arg3, _arg4, _arg5, _arg6);
}
private function _makeHole(_arg1:Scene3D, _arg2:ViewportLayer, _arg3:PointLight3D, _arg4:Number, _arg5:LevelData):void{
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local16:Cube;
var _local17:JBox;
var _local18:JNumber3D;
var _local19:JMatrix3D;
var _local6:Number = _arg5.hole.x;
var _local7:Number = _arg5.hole.y;
var _local8:Number = _arg5.hole.radius;
_arg4 = (_arg4 + (0.5 * BLOCK_DEPTH));
var _local9:Number = ((2 * _local8) * Math.sin((Math.PI / BLOCK_COUNT)));
_local9 = (_local9 * 10);
_local8 = (_local8 - (0.5 * BLOCK_HEIGHT));
_local8 = (_local8 + BLOCK_HEIGHT);
var _local10:MaterialsList = new MaterialsList();
var _local11:FlatShadeMaterial = new FlatShadeMaterial(_arg3, 3381708);
_local10.addMaterial(_local11, "all");
var _local15:int;
while (_local15 < BLOCK_COUNT) {
_local12 = (((2 * Math.PI) * _local15) / BLOCK_COUNT);
_local13 = ((_local8 * Math.cos(_local12)) + _local6);
_local14 = ((_local8 * Math.sin(_local12)) + _local7);
_local12 = (_local12 + (0.5 * Math.PI));
_local16 = new Cube(_local10, _local9, BLOCK_DEPTH, BLOCK_HEIGHT);
_local16.rotationX = ((180 * _local12) / Math.PI);
_local17 = new JBox(_local16, false, _local9, BLOCK_DEPTH, BLOCK_HEIGHT);
_local17.Material.Restitution = 1;
_local18 = new JNumber3D(_local13, _local14, _arg4);
_local19 = JMatrix3D.rotationZ(_local12);
_local17.MoveTo(_local18, _local19);
_physics.AddBody(_local17);
_boxes.push(_local17);
_local15++;
};
}
public function dispose():void{
var _local1:int;
while (_local1 < _boxes.length) {
if ((_boxes[_local1] is JBox)){
_physics.RemoveBody(_boxes[_local1]);
};
_local1++;
};
}
}
}//package com.kerb.sokator.freekick
Section 41
//CameraTweener (com.kerb.sokator.freekick.CameraTweener)
package com.kerb.sokator.freekick {
import flash.events.*;
import com.kerb.utils.*;
import org.papervision3d.render.*;
import org.papervision3d.scenes.*;
import org.papervision3d.cameras.*;
import org.papervision3d.view.*;
import org.papervision3d.objects.*;
import flash.utils.*;
import com.robertpenner.easing.*;
final class CameraTweener extends EventDispatcher implements IDisposable {
private var _camera:Camera3D;
private var _viewport:Viewport3D;
private var _timer:Timer;
private var _scene:Scene3D;
private var _lookAt:DisplayObject3D;
private var _targetRotationZ:Number;
private var _initialRotationX:Number;
private var _initialRotationY:Number;
private var _initialRotationZ:Number;
private var _targetRotationX:Number;
private var _t0:int;
private var _period:int;
private var _renderer:BasicRenderEngine;
private var _targetRotationY:Number;
private var _targetX:Number;
private var _targetY:Number;
private var _initialX:Number;
private var _initialY:Number;
private var _initialZ:Number;
private var _targetZ:Number;
function CameraTweener(_arg1:BasicRenderEngine, _arg2:Scene3D, _arg3:Camera3D, _arg4:Viewport3D){
_renderer = _arg1;
_scene = _arg2;
_camera = _arg3;
_viewport = _arg4;
_initialX = _camera.x;
_initialY = _camera.y;
_initialZ = _camera.z;
_initialRotationX = _camera.rotationX;
_initialRotationY = _camera.rotationY;
_initialRotationZ = _camera.rotationZ;
_targetRotationX = 0;
_targetRotationY = 0;
_targetRotationZ = 0;
}
private function _killTimer():void{
if (_timer != null){
_timer.stop();
_timer.removeEventListener(TimerEvent.TIMER, _onTimer);
_timer = null;
};
}
public function setPeriod(_arg1:int):void{
_period = _arg1;
}
public function setTargetRotationX(_arg1:Number):void{
_targetRotationX = _arg1;
}
public function setTargetRotationZ(_arg1:Number):void{
_targetRotationZ = _arg1;
}
public function setTargetRotationY(_arg1:Number):void{
_targetRotationY = _arg1;
}
public function setTargetPosition(_arg1:Number, _arg2:Number, _arg3:Number):void{
_targetX = _arg1;
_targetY = _arg2;
_targetZ = _arg3;
}
public function dispose():void{
_killTimer();
}
private function _onTimer(_arg1:TimerEvent):void{
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local2:int = (getTimer() - _t0);
var _local3:Number = (_local2 / _period);
if (_local3 >= 1){
_killTimer();
dispatchEvent(new Event(Event.COMPLETE));
} else {
_local4 = Quad.easeInOut(_local2, _initialX, (_targetX - _initialX), _period);
_local5 = Quad.easeInOut(_local2, _initialY, (_targetY - _initialY), _period);
_local6 = Quad.easeInOut(_local2, _initialZ, (_targetZ - _initialZ), _period);
_local7 = Back.easeInOut(_local2, _initialRotationX, (_targetRotationX - _initialRotationX), _period);
_local8 = Back.easeInOut(_local2, _initialRotationY, (_targetRotationY - _initialRotationY), _period);
_local9 = Back.easeInOut(_local2, _initialRotationZ, (_targetRotationZ - _initialRotationZ), _period);
_camera.x = _local4;
_camera.y = _local5;
_camera.z = _local6;
_camera.rotationX = _local7;
_camera.rotationY = _local8;
_camera.rotationZ = _local9;
_renderer.renderScene(_scene, _camera, _viewport);
};
}
public function tween():void{
_t0 = getTimer();
_timer = new Timer(10);
_timer.addEventListener(TimerEvent.TIMER, _onTimer);
_timer.start();
}
}
}//package com.kerb.sokator.freekick
Section 42
//Game (com.kerb.sokator.freekick.Game)
package com.kerb.sokator.freekick {
import flash.events.*;
import flash.display.*;
import com.kerb.utils.*;
import com.kerb.logger.*;
import com.kerb.sokator.freekick.*;
import com.kerb.sokator.freekick.textures.*;
import com.kerb.sokator.freekick.screens.*;
import flash.text.*;
final class Game extends EventDispatcher implements IDisposable {
private var _level:Level;
private var _levelIntroAnim:MovieClip;
private var _screenDrop:IScreen;
private var _gameFrame:DisplayObjectContainer;
private var _fps:int;
private var _af:AssetFactory;
private var _dao:DisplayObjectContainer;
private var _index:int;
private var _gameBackground:Sprite;
private var _kicksPerLevel:Array;
private var _ranking:int;
private var _levelContainer:DisplayObjectContainer;
private static const DOUBLE_QUICK_CLICK_IDS:Array = [359, 360, 361, 362, 363];
private static const INITIAL_LEVEL_INDEX:int = 0;
private static const LEVEL_DATA:Array = [new LevelData(new Desert(), new Hole(0, 12, 65), 0.9, 1, 1.25, 164), new LevelData(new Mountain(), new Hole(-61, 56, 56), 0.9, 1, 0.75, 165), new LevelData(new Jungle(), new Hole(90, -10, 50), 0.9, 1, 1.25, 166), new LevelData(new Swamp(), new Hole(48, 38, 44), 0.9, 1, 1.4, 168), new LevelData(new Ice(), new Hole(140, 89, 38), 0.9, 0.005, 1, 169)];
private static const SCREEN_CLASSES:Array = [ScreenGoggles, ScreenSuperTop, ScreenBoots, ScreenPeace, ScreenUnicycle];
private static const MAX_KICKS_PER_LEVEL:int = 20;
private static const PROMO_CODES:Array = ["h3ader5", "sh1rt5", "5hort13s", "b1ingo", "tr0ph13s"];
private static const FAST_FRAME_RATE:int = 100;
function Game(_arg1:AssetFactory, _arg2:DisplayObjectContainer, _arg3:DisplayObjectContainer){
_af = _arg1;
_dao = _arg2;
_gameFrame = _arg3;
_fps = _dao.stage.frameRate;
_kicksPerLevel = [];
var _local4:int;
while (_local4 < LEVEL_DATA.length) {
_kicksPerLevel.push(0);
_local4++;
};
_setKicksText();
_setupGameBackground();
_setupLevelContainer();
}
private function _getTotalKicks():int{
var _local1:int;
var _local2:int;
while (_local2 < _kicksPerLevel.length) {
_local1 = (_local1 + _kicksPerLevel[_local2]);
_local2++;
};
return (_local1);
}
private function _onCameraLookingAtLeftWall(_arg1:Event):void{
_level.removeEventListener(Level.EVENT_LOOKING_AT_LEFT_WALL, _onCameraLookingAtLeftWall);
Sounds.instance().playBlingConsoleAppearing();
var _local2:Class = SCREEN_CLASSES[_index];
_screenDrop = new _local2(_dao, PROMO_CODES[_index], DOUBLE_QUICK_CLICK_IDS[_index]);
_screenDrop.setVideoAsset((_af.createDisplayObject("PromoVideo") as MovieClip));
_screenDrop.setTotalKicks(_getTotalKicks());
_screenDrop.setRanking(_ranking);
_screenDrop.addEventListener(Event.COMPLETE, _onScreenComplete);
_setNormalFrameRate();
(_gameFrame as MovieClip).gotoAndPlay("attempts_out");
_switchOnTopLeftLogoAnim();
}
private function _switchOnTopLeftLogoAnim():void{
var _local1:MovieClip = (_gameFrame.getChildByName("link_mc") as MovieClip);
_local1 = (_local1.getChildByName("link_mc") as MovieClip);
var _local2:MovieClip = (_local1.getChildByName("text_mc") as MovieClip);
_local2.gotoAndPlay(1);
var _local3:MovieClip = (_local1.getChildByName("shine_mc") as MovieClip);
_local3.gotoAndPlay(1);
_local3.visible = true;
}
private function _getAverageKicks():int{
var _local1:int = _getTotalKicks();
return (Math.round((_local1 / (_index + 1))));
}
private function _getRankingFromKicks():int{
var _local1:int = _getAverageKicks();
KerbLog.instance().info(("average kicks is " + _local1.toString()));
if (_local1 > MAX_KICKS_PER_LEVEL){
_local1 = MAX_KICKS_PER_LEVEL;
};
if (_local1 < 1){
_local1 = 1;
};
KerbLog.instance().info(("min/max'd average kicks is " + _local1.toString()));
_local1 = ((MAX_KICKS_PER_LEVEL + 1) - _local1);
var _local2:int = Math.ceil((_local1 / 2));
KerbLog.instance().info(("ranking is " + _local2.toString()));
return (_local2);
}
private function _setFastFrameRate():void{
_dao.stage.frameRate = FAST_FRAME_RATE;
}
private function _setRanking(_arg1:MovieClip, _arg2:int):void{
if (_arg2 < 1){
_arg2 = 1;
};
if (_arg2 > 10){
_arg2 = 10;
};
_arg1.gotoAndStop((10 + _arg2));
}
private function _onLevelIntroAnimationComplete(_arg1:Event):void{
Sounds.instance().playLevelAmbienceLoop(_index);
_levelIntroAnim.removeEventListener(Event.COMPLETE, _onLevelIntroAnimationComplete);
_dao.removeChild(_levelIntroAnim);
_levelIntroAnim = null;
_setFastFrameRate();
}
public function dispose():void{
_cleanLevel();
if (_levelContainer != null){
if (_dao.contains(_levelContainer)){
_dao.removeChild(_levelContainer);
};
if (_dao.contains(_gameBackground)){
_dao.removeChild(_gameBackground);
};
_levelContainer = null;
};
}
private function _setNormalFrameRate():void{
_dao.stage.frameRate = _fps;
}
private function _doKicksDisplayCommon(_arg1:MovieClip):void{
var _local2:TextField;
var _local3:int;
var _local4:String;
if (_arg1 != null){
_local2 = (_arg1.getChildByName("text_txt") as TextField);
if (_local2 != null){
_local2.embedFonts = true;
_local3 = _getTotalKicks();
if (_local3 > 9999){
_local3 = 9999;
};
_local4 = _local3.toString();
while (_local4.length < 4) {
_local4 = ("0" + _local4);
};
_local2.text = _local4;
};
};
}
private function _onLevelIntroAnimSetupRanking(_arg1:Event):void{
var _local2:MovieClip = (_arg1.target as MovieClip);
_local2.removeEventListener("EVENT_SETUP_RANKING", _onLevelIntroAnimSetupRanking);
var _local3:MovieClip = (_local2.getChildByName("ranking_mc") as MovieClip);
if (_local3 != null){
if (_index == 0){
_setRanking(_local3, 1);
} else {
_setRanking(_local3, _ranking);
};
} else {
KerbLog.instance().info("\"ranking_mc\" missing from timeline");
};
}
private function _newLevel():void{
_cleanLevel();
_index++;
_startLevel();
}
public function startFirstLevel():void{
(_gameFrame as MovieClip).gotoAndPlay("in");
_index = INITIAL_LEVEL_INDEX;
_startLevel();
}
private function _switchOffTopLeftLogoAnim():void{
var _local1:MovieClip = (_gameFrame.getChildByName("link_mc") as MovieClip);
_local1 = (_local1.getChildByName("link_mc") as MovieClip);
var _local2:MovieClip = (_local1.getChildByName("text_mc") as MovieClip);
_local2.gotoAndStop("normal");
var _local3:MovieClip = (_local1.getChildByName("shine_mc") as MovieClip);
_local3.gotoAndStop(1);
_local3.visible = false;
}
private function _onLevelIntroStartLevel(_arg1:Event):void{
_levelIntroAnim.removeEventListener("EVENT_START_LEVEL", _onLevelIntroStartLevel);
_dao.setChildIndex(_gameBackground, 0);
_dao.setChildIndex(_levelContainer, 1);
_level = new Level(_af, _levelContainer, LEVEL_DATA[_index]);
_level.addEventListener(Level.EVENT_BALL_KICKED, _onBallKicked);
_level.addEventListener(Event.COMPLETE, _onLevelComplete);
}
private function _onLevelIntroSetupHolodeck(_arg1:Event):void{
var _local3:MovieClip;
Sounds.instance().playHolodeckStartup();
_levelIntroAnim.removeEventListener("EVENT_SETUP_HOLODECK", _onLevelIntroSetupHolodeck);
var _local2:int;
while (_local2 < LEVEL_DATA.length) {
_local3 = (_levelIntroAnim.getChildByName((("level" + (_local2 + 1).toString()) + "_mc")) as MovieClip);
if (((!((_local3 == null))) && (!((_local2 == _index))))){
_local3.visible = false;
_levelIntroAnim.removeChild(_local3);
} else {
_local3.addEventListener("EVENT_SETUP_RANKING", _onLevelIntroAnimSetupRanking);
};
_local2++;
};
}
private function _setKicksText():void{
var _local1:MovieClip = (_gameFrame.getChildByName("counter_mc") as MovieClip);
if (_local1 != null){
_local1.gotoAndPlay("in");
_local1.addEventListener(Event.ENTER_FRAME, _onContainerEnterFrame);
} else {
KerbLog.instance().info("\"counter_mc\" missing from timeline");
};
}
private function _setupGameBackground():void{
_gameBackground = (_af.createDisplayObject("GameBackground") as Sprite);
_gameBackground.cacheAsBitmap = true;
_dao.addChild(_gameBackground);
}
private function _startLevel():void{
_switchOffTopLeftLogoAnim();
Sounds.instance().playTravelThroughHole();
_levelIntroAnim = (_af.createDisplayObject("LevelIntroAnim") as MovieClip);
_levelIntroAnim.addEventListener("EVENT_SETUP_HOLODECK", _onLevelIntroSetupHolodeck);
_levelIntroAnim.addEventListener("EVENT_START_LEVEL", _onLevelIntroStartLevel);
_levelIntroAnim.addEventListener(Event.COMPLETE, _onLevelIntroAnimationComplete);
_dao.addChild(_levelIntroAnim);
}
private function _onCameraThroughHole(_arg1:Event):void{
_setNormalFrameRate();
_level.removeEventListener(Level.EVENT_CAMERA_THROUGH_HOLE, _onCameraThroughHole);
_newLevel();
}
private function _onScreenComplete(_arg1:Event):void{
_screenDrop.removeEventListener(Event.COMPLETE, _onScreenComplete);
_screenDrop.dispose();
_screenDrop = null;
if ((_index + 1) > (LEVEL_DATA.length - 1)){
_cleanLevel();
_index = 0;
_dao.stage.frameRate = _fps;
dispatchEvent(new Event(Event.COMPLETE));
} else {
_level.addEventListener(Level.EVENT_CAMERA_THROUGH_HOLE, _onCameraThroughHole);
_level.moveCameraThroughHole();
_setFastFrameRate();
};
(_gameFrame as MovieClip).gotoAndPlay("attempts_in");
}
private function _onBallKicked(_arg1:Event):void{
var _local3 = _kicksPerLevel;
var _local4 = _index;
var _local5 = (_local3[_local4] + 1);
_local3[_local4] = _local5;
var _local2:MovieClip = (_gameFrame.getChildByName("attempts_mc") as MovieClip);
if (_local2 != null){
_local2.gotoAndPlay("in");
_local2.addEventListener(Event.ENTER_FRAME, _onAttemptsEnterFrame);
} else {
KerbLog.instance().info("\"attempts_mc\" missing from timeline");
};
}
private function _cleanLevel():void{
if (_level != null){
_level.removeEventListener(Level.EVENT_BALL_KICKED, _onBallKicked);
_level.removeEventListener(Event.COMPLETE, _onLevelComplete);
_level.dispose();
_level = null;
};
}
private function _onContainerEnterFrame(_arg1:Event):void{
var _local3:MovieClip;
var _local2:MovieClip = (_arg1.target as MovieClip);
if (_local2.currentFrame == 1){
_local2.removeEventListener(Event.ENTER_FRAME, _onContainerEnterFrame);
} else {
_local3 = (_local2.getChildByName("score_mc") as MovieClip);
_doKicksDisplayCommon(_local3);
};
}
private function _onAttemptsEnterFrame(_arg1:Event):void{
var _local3:MovieClip;
var _local2:MovieClip = (_arg1.target as MovieClip);
if (_local2.currentFrame == 1){
_local2.removeEventListener(Event.ENTER_FRAME, _onAttemptsEnterFrame);
_setKicksText();
} else {
_local3 = (_local2.getChildByName("score_mc") as MovieClip);
_doKicksDisplayCommon(_local3);
};
}
private function _setupLevelContainer():void{
_levelContainer = new Sprite();
_dao.addChild(_levelContainer);
}
private function _onLevelComplete(_arg1:Event):void{
_ranking = _getRankingFromKicks();
Sounds.instance().stopLevelAmbienceLoop();
_level.addEventListener(Level.EVENT_LOOKING_AT_LEFT_WALL, _onCameraLookingAtLeftWall);
_level.hideBall();
_level.lookAtLeftWall();
}
}
}//package com.kerb.sokator.freekick
Section 43
//Hole (com.kerb.sokator.freekick.Hole)
package com.kerb.sokator.freekick {
final class Hole {
public var radius:int;
public var x:int;
public var y:int;
function Hole(_arg1:int, _arg2:int, _arg3:int){
this.x = _arg1;
this.y = _arg2;
this.radius = _arg3;
}
}
}//package com.kerb.sokator.freekick
Section 44
//Level (com.kerb.sokator.freekick.Level)
package com.kerb.sokator.freekick {
import flash.events.*;
import flash.display.*;
import com.kerb.utils.*;
import com.kerb.sokator.freekick.*;
import org.papervision3d.events.*;
import flash.geom.*;
import org.papervision3d.render.*;
import org.papervision3d.scenes.*;
import org.papervision3d.cameras.*;
import org.papervision3d.view.*;
import org.papervision3d.objects.*;
import org.papervision3d.view.layer.*;
import flash.utils.*;
import org.papervision3d.materials.utils.*;
import jiglib.math.*;
import jiglib.physics.*;
import jiglib.geometry.*;
import org.papervision3d.lights.*;
import org.papervision3d.materials.*;
import com.kerb.tracking.*;
import org.papervision3d.objects.primitives.*;
import org.papervision3d.objects.parsers.*;
import org.papervision3d.materials.shadematerials.*;
import org.papervision3d.view.layer.util.*;
import flash.ui.*;
final class Level extends EventDispatcher implements IDisposable {
private var _viewport:Viewport3D;
private var _arrowAsset:MovieClip;
private var _physics:PhysicsSystem;
private var _vplFarZPlane:ViewportLayer;
private var _arrow:Plane;
private var _ct:CameraTweener;
private var _renderer:BasicRenderEngine;
private var _kickTimer:Timer;
private var _vplShadow:ViewportLayer;
private var _vpl:ViewportLayer;
private var _do3d:DisplayObject3D;
private var _shadow:Plane;
private var _camera:Camera3D;
private var _jCeiling:JPlane;
private var _jRightWall:JPlane;
private var _mouseDownCoordinates:Point;
private var _cheered:Boolean;
private var _roomLight:PointLight3D;
private var _jBall:JSphere;
private var _jLeftWall:JPlane;
private var _scene:Scene3D;
private var _shakesZ:int;
private var _shakesX:int;
private var _shakesY:int;
private var _vplArrow:ViewportLayer;
private var _vplFloor:ViewportLayer;
private var _backWallZ:Number;
private var _dragging:Boolean;
private var _mouseDelta:Point;
private var _vplBackWall:ViewportLayer;
private var _backWall:BackWall;
private var FootballDAE:Class;
private var _af:AssetFactory;
private var _kickForce:JNumber3D;
private var _football:DAE;
private var FootballTexture:Class;
private var _levelData:LevelData;
private var _leftWall:Plane;
private var _vplBall:ViewportLayer;
private var _dao:DisplayObjectContainer;
private var _ballLight:PointLight3D;
private var _ballVelocity:JNumber3D;
private var _levelComplete:Boolean;
private var _jFloor:JPlane;
private var _ball:Sphere;
private var _jFrontWall:JPlane;
public static const ALLOW_SKIP_LEVEL:Boolean = true;
private static const CAMERA_SHAKES:int = 15;
private static const ROOM_HEIGHT:int = 300;
private static const LAYER_INDEX_FLOOR:int = 1;
public static const EVENT_LOOKING_AT_LEFT_WALL:String = "EVENT_LOOKING_AT_LEFT_WALL";
private static const LAYER_INDEX_SHADOW:int = 5;
private static const LAYER_INDEX_ARROW:int = 4;
private static const BALL_INIT_Y:Number = 300;
private static const BALL_INIT_Z:Number = -250;
public static const EVENT_CAMERA_THROUGH_HOLE:String = "EVENT_CAMERA_THROUGH_HOLE";
private static const LAYER_INDEX_FAR_Z:int = 0;
private static const LAYER_INDEX_BALL:int = 6;
private static const ROOM_DEPTH:int = 1000;
private static const ROOM_WIDTH:int = 400;
private static const CAMERA_INIT_X:Number = 0;
private static const CAMERA_INIT_Y:Number = 0;
private static const CAMERA_INIT_Z:Number = -1010;
private static const VIEWPORT_WIDTH:int = 550;
private static const MIN_COMPONENT_VELOCITY_FOR_BOUNCE:Number = 35;
private static const BALL_RADIUS:Number = 25;
private static const LAYER_INDEX_BACK_WALL:int = 2;
public static const EVENT_BALL_KICKED:String = "EVENT_BALL_KICKED";
private static const VIEWPORT_HEIGHT:int = 400;
private static const MAX_KICK_FORCE:Number = 500;
private static const BALL_SPEED:Number = 10;
private static const LAYER_INDEX_MAIN:int = 3;
private static const MIN_COMPONENT_VELOCITY_FOR_SHAKE:Number = 50;
function Level(_arg1:AssetFactory, _arg2:DisplayObjectContainer, _arg3:LevelData){
FootballDAE = Level_FootballDAE;
FootballTexture = Level_FootballTexture;
super();
_af = _arg1;
_dao = _arg2;
_levelData = _arg3;
_init();
_dao.stage.addEventListener(KeyboardEvent.KEY_DOWN, _onKeyDown);
Mouse.show();
DoubleQuick.event(_arg3.doubleQuickEventId);
}
private function _updateBall():void{
var _local1:JNumber3D;
var _local2:JNumber3D;
var _local3:JNumber3D;
if (_ball != null){
_ball.x = _jBall.BodySkin.x;
_ball.y = _jBall.BodySkin.y;
_ball.z = _jBall.BodySkin.z;
if (_shadow != null){
_shadow.x = _jBall.BodySkin.x;
_shadow.z = _jBall.BodySkin.z;
_shadow.scale = (1 - ((_jBall.BodySkin.y + (0.5 * ROOM_HEIGHT)) / ROOM_HEIGHT));
};
_local1 = _jBall.GetVelocity(JNumber3D.ZERO);
_local1.z = Math.min(100, _local1.z);
_jBall.SetVelocity(_local1);
if (_ballVelocity == null){
_ballVelocity = _jBall.GetVelocity(JNumber3D.ZERO);
} else {
_local2 = _ballVelocity;
_local3 = _jBall.GetVelocity(JNumber3D.ZERO);
if ((((((_local3.x < 0)) && ((_local2.x > 0)))) || ((((_local3.x > 0)) && ((_local2.x < 0)))))){
if (Math.abs(_local3.x) > MIN_COMPONENT_VELOCITY_FOR_BOUNCE){
Sounds.instance().playBallBounce();
if (Math.abs(_local3.x) > MIN_COMPONENT_VELOCITY_FOR_SHAKE){
_shakesX = CAMERA_SHAKES;
};
};
} else {
if ((((((_local3.y < 0)) && ((_local2.y > 0)))) || ((((_local3.y > 0)) && ((_local2.y < 0)))))){
if (Math.abs(_local3.y) > MIN_COMPONENT_VELOCITY_FOR_BOUNCE){
Sounds.instance().playBallBounce();
if (Math.abs(_local3.y) > MIN_COMPONENT_VELOCITY_FOR_SHAKE){
_shakesY = CAMERA_SHAKES;
};
};
} else {
if ((((((_local3.z < 0)) && ((_local2.z > 0)))) || ((((_local3.z > 0)) && ((_local2.z < 0)))))){
if (Math.abs(_local3.z) > MIN_COMPONENT_VELOCITY_FOR_BOUNCE){
Sounds.instance().playBallBounce();
if (Math.abs(_local3.z) > MIN_COMPONENT_VELOCITY_FOR_SHAKE){
_shakesZ = CAMERA_SHAKES;
};
} else {
if (_local2.z > 0){
_jBall.AddWorldForce(new JNumber3D(0, 0, -50), _jBall.CurrentState.Position);
};
};
};
};
};
_ballVelocity = _local3;
};
if (_ball.z > ((_backWallZ + BALL_RADIUS) + 10)){
_vpl.layerIndex = LAYER_INDEX_BALL;
_vplBall.layerIndex = LAYER_INDEX_MAIN;
if (!_cheered){
Sounds.instance().playBallInHoleCheer();
_cheered = true;
};
if (_ball.y < (((-0.5 * ROOM_HEIGHT) + BALL_RADIUS) + 10)){
_levelComplete = true;
};
} else {
_vpl.layerIndex = LAYER_INDEX_MAIN;
_vplBall.layerIndex = LAYER_INDEX_BALL;
};
};
}
private function _initPapervision():void{
_scene = new Scene3D();
_renderer = new BasicRenderEngine();
_viewport = new Viewport3D(VIEWPORT_WIDTH, VIEWPORT_HEIGHT, false, false, true, true);
_viewport.containerSprite.sortMode = ViewportLayerSortMode.INDEX_SORT;
_viewport.interactive = true;
_dao.addChild(_viewport);
_roomLight = new PointLight3D();
_roomLight.z = (-0.5 * ROOM_DEPTH);
_ballLight = new PointLight3D();
_ballLight.x = (0.25 * ROOM_WIDTH);
_ballLight.y = ROOM_HEIGHT;
_ballLight.z = (-2 * ROOM_DEPTH);
_camera = new Camera3D();
_camera.zoom = 10;
_camera.focus = 70;
_camera.x = CAMERA_INIT_X;
_camera.y = CAMERA_INIT_Y;
_camera.z = CAMERA_INIT_Z;
}
public function dispose():void{
_killCameraTweener();
_killKickTimer();
if (_backWall != null){
_backWall.dispose();
_backWall = null;
};
if (_dao != null){
_dao.stage.removeEventListener(KeyboardEvent.KEY_DOWN, _onKeyDown);
_dao.removeEventListener(Event.ENTER_FRAME, _onEnterFrame);
if (_dao.contains(_viewport)){
_dao.removeChild(_viewport);
};
};
_dao = null;
if (_renderer != null){
_renderer.destroy();
_renderer = null;
};
if (_viewport != null){
_viewport = null;
};
if (_physics != null){
_physics.RemoveBody(_jFloor);
_physics.RemoveBody(_jCeiling);
_physics.RemoveBody(_jLeftWall);
_physics.RemoveBody(_jRightWall);
_physics.RemoveBody(_jFrontWall);
_physics.RemoveBody(_jBall);
};
_jBall = null;
_jFloor = null;
_jCeiling = null;
_jLeftWall = null;
_jRightWall = null;
_jFrontWall = null;
_ball = null;
_shadow = null;
_camera = null;
_roomLight = null;
_ballLight = null;
}
private function _shakeCamera():void{
var _local1:Number = 0.3;
if (_shakesX > 0){
if ((_shakesX % 2) == 0){
_camera.rotationY = -(_local1);
} else {
_camera.rotationY = _local1;
};
_shakesX--;
if (_shakesX == 0){
_camera.rotationY = 0;
};
};
if (_shakesY > 0){
if ((_shakesY % 2) == 0){
_camera.rotationX = -(_local1);
} else {
_camera.rotationX = _local1;
};
_shakesY--;
if (_shakesY == 0){
_camera.rotationX = 0;
};
};
if (_shakesZ > 0){
if ((_shakesZ % 2) == 0){
_camera.rotationZ = -(_local1);
} else {
_camera.rotationZ = _local1;
};
_shakesZ--;
if (_shakesZ == 0){
_camera.rotationZ = 0;
};
};
}
private function _removeArrow():void{
if (_arrow != null){
_scene.removeChild(_arrow);
_vplArrow.removeDisplayObject3D(_arrow);
};
}
private function _onKickTimerComplete(_arg1:TimerEvent):void{
_do3d.addEventListener(InteractiveScene3DEvent.OBJECT_PRESS, _onBallMouseDown);
Mouse.show();
_killKickTimer();
}
private function _killCameraTweener(_arg1:Event=null):void{
if (_ct != null){
_ct.dispose();
_ct = null;
};
}
private function _updateKickForce():void{
var _local1:Number = (-8 * _mouseDelta.x);
var _local2:Number = (3 * _mouseDelta.y);
var _local3:Number = Math.sqrt(((_local1 * _local1) + (_local2 * _local2)));
if (_kickForce == null){
_kickForce = new JNumber3D();
};
_kickForce.x = _local1;
_kickForce.y = _local2;
_kickForce.z = _local3;
var _local4:Number = _kickForce.modulo;
if (_local4 > MAX_KICK_FORCE){
_kickForce.normalize();
_kickForce = JNumber3D.multiply(_kickForce, MAX_KICK_FORCE);
};
_kickForce.z = Math.min(MAX_KICK_FORCE, _kickForce.z);
}
private function _onLookAtLeftWallComplete(_arg1:Event):void{
_killCameraTweener();
dispatchEvent(new Event(EVENT_LOOKING_AT_LEFT_WALL));
}
private function _onKeyDown(_arg1:KeyboardEvent):void{
switch (_arg1.keyCode){
};
}
private function _addArrow():void{
if (_arrow != null){
_scene.addChild(_arrow);
_vplArrow.addDisplayObject3D(_arrow);
};
}
private function _initBallShadow():void{
_shadow = new Plane(new MovieMaterial(_af.createDisplayObject("BallShadow"), true, true, true), 40, 40, 2, 2);
_shadow.rotationX = 90;
_shadow.x = _ball.x;
_shadow.y = (-0.5 * ROOM_HEIGHT);
_shadow.z = _ball.z;
_vplShadow = new ViewportLayer(_viewport, null);
_vplShadow.layerIndex = LAYER_INDEX_SHADOW;
_viewport.containerSprite.addLayer(_vplShadow);
_scene.addChild(_shadow);
_vplShadow.addDisplayObject3D(_shadow);
}
private function _initPhysics():void{
_physics = PhysicsSystem.getInstance();
}
private function _initArrow():void{
var _local1 = 8;
_arrowAsset = (_af.createDisplayObject("Arrow") as MovieClip);
_arrowAsset.transform.colorTransform = new ColorTransform();
var _local2:MovieMaterial = new MovieMaterial(_arrowAsset, true, true);
_arrow = new Plane(_local2, (5 * BALL_RADIUS), (12 * BALL_RADIUS), _local1, _local1);
_arrow.rotationX = 90;
_arrow.rotationY = 0;
_arrow.rotationZ = 0;
_vplArrow = new ViewportLayer(_viewport, null);
_vplArrow.layerIndex = LAYER_INDEX_ARROW;
_viewport.containerSprite.addLayer(_vplArrow);
}
private function _initFloor():void{
var _local1 = 6;
_vplFloor = new ViewportLayer(_viewport, null);
_vplFloor.layerIndex = LAYER_INDEX_FLOOR;
_viewport.containerSprite.addLayer(_vplFloor);
var _local2:BitmapMaterial = new BitmapMaterial(_levelData.tp.getFloorBitmapData());
var _local3:Plane = new Plane(_local2, ROOM_WIDTH, ROOM_DEPTH, _local1, _local1);
_jFloor = new JPlane(_local3);
_jFloor.Material.Restitution = _levelData.restitution;
_jFloor.Material.StaticFriction = _levelData.friction;
_jFloor.Material.DynamicFriction = _levelData.friction;
_jFloor.MoveTo(new JNumber3D(0, (-0.5 * ROOM_HEIGHT), 0), JMatrix3D.rotationX((0.5 * Math.PI)));
_physics.AddBody(_jFloor);
_scene.addChild(_local3);
_vplFloor.addDisplayObject3D(_local3);
}
public function hideBall():void{
if (_ball.visible){
_viewport.containerSprite.removeLayer(_vplBall);
_viewport.containerSprite.removeLayer(_vplShadow);
_ball.visible = false;
_shadow.visible = false;
_scene.removeChild(_football);
_scene.removeChild(_shadow);
};
}
private function _initViewPortLayer():void{
_vpl = new ViewportLayer(_viewport, null);
_vpl.layerIndex = LAYER_INDEX_MAIN;
_viewport.containerSprite.addLayer(_vpl);
}
private function _initBall():void{
_vplBall = new ViewportLayer(_viewport, null);
_vplBall.layerIndex = LAYER_INDEX_BALL;
_viewport.containerSprite.addLayer(_vplBall);
var _local1:Number = ((((2 * Math.random()) - 1) * (ROOM_WIDTH - (2 * BALL_RADIUS))) / 2);
var _local2:JNumber3D = new JNumber3D(_local1, BALL_INIT_Y, BALL_INIT_Z);
var _local3:GouraudMaterial = new GouraudMaterial(_ballLight, 0xFFFFFF, 0x333333);
_ball = new Sphere(_local3, BALL_RADIUS, 8, 8);
_scene.addChild(_ball);
_vplBall.addDisplayObject3D(_ball);
_football = new DAE(false);
var _local4:Bitmap = new FootballTexture();
var _local5:BitmapMaterial = new BitmapMaterial(_local4.bitmapData);
_local5.interactive = true;
var _local6:MaterialsList = new MaterialsList();
_local6.addMaterial(_local5, "soccer_texture.bmp");
_football.load(XML(new FootballDAE()), _local6);
_scene.addChild(_football);
_jBall = new JSphere(_football, true, BALL_RADIUS);
_jBall.Material.Restitution = _levelData.restitution;
_jBall.Material.StaticFriction = _levelData.friction;
_jBall.Material.DynamicFriction = _levelData.friction;
_jBall.setMass(_levelData.ballMass);
_jBall.MoveTo(_local2, JMatrix3D.IDENTITY);
_physics.AddBody(_jBall);
_do3d = _football.getChildByName("soccer_body", true);
_vplBall.addDisplayObject3D(_do3d);
_vplBall.getChildLayer(_do3d).blendMode = BlendMode.MULTIPLY;
_do3d.addEventListener(InteractiveScene3DEvent.OBJECT_PRESS, _onBallMouseDown);
}
private function _onEnterFrame(_arg1:Event):void{
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:ColorTransform;
_physics.Integrate(0.3);
_updateBall();
if (_levelComplete){
dispatchEvent(new Event(Event.COMPLETE));
} else {
if (_dragging){
_local2 = (_dao.stage.mouseX - _mouseDownCoordinates.x);
_local3 = (_dao.stage.mouseY - _mouseDownCoordinates.y);
_mouseDownCoordinates.x = _dao.stage.mouseX;
_mouseDownCoordinates.y = _dao.stage.mouseY;
_mouseDelta.x = (_mouseDelta.x + _local2);
_mouseDelta.y = (_mouseDelta.y + _local3);
_camera.rotationY = (_mouseDelta.x / 200);
_camera.rotationX = (_mouseDelta.y / 200);
_updateKickForce();
_arrow.rotationY = -((((180 * Math.atan2(_kickForce.z, _kickForce.x)) / Math.PI) - 90));
if ((((_mouseDelta.x == 0)) && ((_mouseDelta.y == 0)))){
_arrow.rotationY = 0;
};
_arrow.x = _jBall.BodySkin.x;
_arrow.y = (-0.5 * ROOM_HEIGHT);
_arrow.z = _jBall.BodySkin.z;
_local4 = (_kickForce.modulo / MAX_KICK_FORCE);
_arrow.scale = Math.max(0.4, _local4);
_local5 = _arrowAsset.transform.colorTransform;
if (_local4 < 0.7){
_local5.redOffset = 0;
_local5.greenOffset = (0xFF - (0xFF * (_local4 / 0.7)));
} else {
_local5.redOffset = (0xFF * ((_local4 - 0.7) / 0.3));
_local5.greenOffset = 0;
};
_arrowAsset.transform.colorTransform = _local5;
} else {
_shakeCamera();
_removeArrow();
};
_renderer.renderScene(_scene, _camera, _viewport);
};
}
public function showBall():void{
if (!_ball.visible){
_viewport.containerSprite.addLayer(_vplBall);
_viewport.containerSprite.addLayer(_vplShadow);
_ball.visible = true;
_shadow.visible = true;
_scene.addChild(_football);
_scene.addChild(_shadow);
};
}
private function _doKickBall():void{
_scene.addChild(_shadow);
_removeArrow();
Sounds.instance().playKick();
_dragging = false;
_restoreCameraRotation();
_updateKickForce();
_jBall.AddWorldForce(_kickForce, _jBall.CurrentState.Position);
_killKickTimer();
_kickTimer = new Timer(2000, 1);
_kickTimer.addEventListener(TimerEvent.TIMER_COMPLETE, _onKickTimerComplete);
_kickTimer.start();
dispatchEvent(new Event(EVENT_BALL_KICKED));
}
private function _initWallsAndCeiling():void{
var _local2:JNumber3D;
var _local3:JMatrix3D;
var _local1 = 4;
_vplBackWall = new ViewportLayer(_viewport, null);
_vplBackWall.layerIndex = LAYER_INDEX_BACK_WALL;
_viewport.containerSprite.addLayer(_vplBackWall);
_backWallZ = (0.5 * ROOM_DEPTH);
_backWall = new BackWall(_scene, _physics, _vplBackWall, _roomLight, _backWallZ, _levelData);
var _local4:MovieMaterial = new MovieMaterial(_levelData.tp.getBackWallMovieClip(_af), true);
var _local5:Plane = new Plane(_local4, ROOM_WIDTH, ROOM_HEIGHT, _local1, _local1);
_local5.z = _backWallZ;
_scene.addChild(_local5);
_vpl.addDisplayObject3D(_local5);
var _local6:BitmapMaterial = new BitmapMaterial(_levelData.tp.getLeftWallBitmapData());
_leftWall = new Plane(_local6, ROOM_DEPTH, ROOM_HEIGHT, _local1, _local1);
_jLeftWall = new JPlane(_leftWall);
_jLeftWall.Material.Restitution = _levelData.restitution;
_local2 = new JNumber3D((-0.5 * ROOM_WIDTH), 0, 0);
_local3 = JMatrix3D.rotationY((0.5 * Math.PI));
_jLeftWall.MoveTo(_local2, _local3);
_physics.AddBody(_jLeftWall);
_scene.addChild(_leftWall);
_vpl.addDisplayObject3D(_leftWall);
var _local7:BitmapMaterial = new BitmapMaterial(_levelData.tp.getRightWallBitmapData());
var _local8:Plane = new Plane(_local7, ROOM_DEPTH, ROOM_HEIGHT, _local1, _local1);
_jRightWall = new JPlane(_local8);
_jRightWall.Material.Restitution = _levelData.restitution;
_local2 = new JNumber3D((0.5 * ROOM_WIDTH), 0, 0);
_local3 = JMatrix3D.rotationY((-0.5 * Math.PI));
_jRightWall.MoveTo(_local2, _local3);
_physics.AddBody(_jRightWall);
_scene.addChild(_local8);
_vpl.addDisplayObject3D(_local8);
var _local9:Plane = new Plane(null, ROOM_WIDTH, ROOM_HEIGHT, 1, 1);
_local9.visible = false;
_jFrontWall = new JPlane(_local9);
_jFrontWall.Material.Restitution = _levelData.restitution;
_local2 = new JNumber3D(0, 0, (-0.4 * ROOM_DEPTH));
_local3 = JMatrix3D.rotationY(Math.PI);
_jFrontWall.MoveTo(_local2, _local3);
_physics.AddBody(_jFrontWall);
_scene.addChild(_local9);
var _local10:Plane = new Plane(new ColorMaterial(_levelData.tp.getCeilingColour()), ROOM_WIDTH, ROOM_DEPTH, _local1, _local1);
_jCeiling = new JPlane(_local10);
_jCeiling.Material.Restitution = _levelData.restitution;
_local2 = new JNumber3D(0, (0.5 * ROOM_HEIGHT), 0);
_local3 = JMatrix3D.rotationX((-0.5 * Math.PI));
_jCeiling.MoveTo(_local2, _local3);
_physics.AddBody(_jCeiling);
_scene.addChild(_local10);
_vpl.addDisplayObject3D(_local10);
}
private function _initFarZPlane():void{
var _local1 = 4;
_vplFarZPlane = new ViewportLayer(_viewport, null);
_vplFarZPlane.layerIndex = LAYER_INDEX_FAR_Z;
_viewport.containerSprite.addLayer(_vplFarZPlane);
var _local2:Plane = new Plane(new ColorMaterial(0), (2 * ROOM_WIDTH), (2 * ROOM_HEIGHT), _local1, _local1);
_local2.moveForward((0.75 * ROOM_DEPTH));
_scene.addChild(_local2);
_vplFarZPlane.addDisplayObject3D(_local2);
}
private function _onBallMouseDown(_arg1:InteractiveScene3DEvent):void{
_do3d.removeEventListener(InteractiveScene3DEvent.OBJECT_PRESS, _onBallMouseDown);
_scene.removeChild(_shadow);
_mouseDownCoordinates = new Point(_dao.stage.mouseX, _dao.stage.mouseY);
_mouseDelta = new Point(0, 0);
_dragging = true;
_dao.stage.addEventListener(MouseEvent.MOUSE_UP, _onStageMouseUp);
_addArrow();
}
private function _onCameraThroughHoleStage1Complete(_arg1:Event):void{
Sounds.instance().playHeadToHole();
_killCameraTweener();
_ct = new CameraTweener(_renderer, _scene, _camera, _viewport);
_ct.setTargetPosition(_levelData.hole.x, _levelData.hole.y, (0.5 * ROOM_DEPTH));
var _local2:Number = Math.atan2(_levelData.hole.x, ROOM_DEPTH);
_ct.setTargetRotationX(0);
_ct.setTargetRotationY(((180 * _local2) / Math.PI));
_ct.setTargetRotationZ(((Math.random() < 0.5)) ? 180 : -180);
_ct.setPeriod(1000);
_ct.addEventListener(Event.COMPLETE, _onCameraThroughHoleStage2Complete);
_ct.tween();
}
private function _onCameraThroughHoleStage2Complete(_arg1:Event):void{
_killCameraTweener();
dispatchEvent(new Event(EVENT_CAMERA_THROUGH_HOLE));
}
private function _onStageMouseUp(_arg1:MouseEvent):void{
_dao.stage.removeEventListener(MouseEvent.MOUSE_UP, _onStageMouseUp);
_doKickBall();
}
private function _killKickTimer():void{
if (_kickTimer != null){
_kickTimer.removeEventListener(TimerEvent.TIMER_COMPLETE, _onKickTimerComplete);
_kickTimer.stop();
_kickTimer = null;
};
}
private function _init():void{
_initPapervision();
_initPhysics();
_initViewPortLayer();
_initFloor();
_initWallsAndCeiling();
_initFarZPlane();
_initBall();
_initBallShadow();
_initArrow();
_dao.addEventListener(Event.ENTER_FRAME, _onEnterFrame);
}
public function lookAtLeftWall():void{
_dao.removeEventListener(Event.ENTER_FRAME, _onEnterFrame);
_killCameraTweener();
_ct = new CameraTweener(_renderer, _scene, _camera, _viewport);
_ct.setTargetPosition(ROOM_WIDTH, 0, 0);
_ct.setTargetRotationY(-90);
_ct.setPeriod(1000);
_ct.addEventListener(Event.COMPLETE, _onLookAtLeftWallComplete);
_ct.tween();
}
private function _restoreCameraRotation():void{
_killCameraTweener();
_ct = new CameraTweener(_renderer, _scene, _camera, _viewport);
_ct.setTargetPosition(CAMERA_INIT_X, CAMERA_INIT_Y, CAMERA_INIT_Z);
_ct.setTargetRotationX(0);
_ct.setTargetRotationY(0);
_ct.setPeriod(500);
_ct.addEventListener(Event.COMPLETE, _killCameraTweener);
_ct.tween();
}
public function moveCameraThroughHole():void{
_killCameraTweener();
_ct = new CameraTweener(_renderer, _scene, _camera, _viewport);
_ct.setTargetPosition(CAMERA_INIT_X, CAMERA_INIT_Y, CAMERA_INIT_Z);
_ct.setTargetRotationX(0);
_ct.setTargetRotationY(0);
_ct.setPeriod(1000);
_ct.addEventListener(Event.COMPLETE, _onCameraThroughHoleStage1Complete);
_ct.tween();
}
}
}//package com.kerb.sokator.freekick
Section 45
//Level_FootballDAE (com.kerb.sokator.freekick.Level_FootballDAE)
package com.kerb.sokator.freekick {
import mx.core.*;
public class Level_FootballDAE extends ByteArrayAsset {
}
}//package com.kerb.sokator.freekick
Section 46
//Level_FootballTexture (com.kerb.sokator.freekick.Level_FootballTexture)
package com.kerb.sokator.freekick {
import mx.core.*;
public class Level_FootballTexture extends BitmapAsset {
}
}//package com.kerb.sokator.freekick
Section 47
//LevelData (com.kerb.sokator.freekick.LevelData)
package com.kerb.sokator.freekick {
import com.kerb.sokator.freekick.textures.*;
final class LevelData {
public var hole:Hole;
public var restitution:Number;
public var ballMass:Number;
public var doubleQuickEventId:int;
public var friction:Number;
public var tp:ITexturePack;
function LevelData(_arg1:ITexturePack, _arg2:Hole, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:int){
this.tp = _arg1;
this.hole = _arg2;
this.restitution = _arg3;
this.friction = _arg4;
this.ballMass = _arg5;
this.doubleQuickEventId = _arg6;
}
}
}//package com.kerb.sokator.freekick
Section 48
//Main (com.kerb.sokator.freekick.Main)
package com.kerb.sokator.freekick {
import flash.events.*;
import flash.display.*;
import flash.net.*;
import com.kerb.utils.*;
import com.kerb.logger.*;
import com.kerb.sound.*;
import com.kerb.tracking.*;
import com.kerb.ui.*;
import flash.ui.*;
public final class Main extends Sprite {
private var _af:AssetFactory;
private var _game:Game;
private var _frontPage:Sprite;
private var _gameFrame:Sprite;
private var _frontPagePanel:MovieClip;
private var _sc:SoundControl;
private var _gameContainer:DisplayObjectContainer;
private var _inGameHelp:MovieClip;
private static const STAGE_WIDTH:int = 550;
private static const STAGE_HEIGHT:int = 400;
public static const SOKATOR_URL:String = "http://www.sokator442.com";
public function Main(_arg1:AssetFactory){
_af = _arg1;
addEventListener(Event.ADDED_TO_STAGE, _onAddedToStage);
}
private function _onGameFrameAddedToStage(_arg1:Event):void{
var _local2:MovieClip;
_gameFrame.removeEventListener(Event.ADDED_TO_STAGE, _onGameFrameAddedToStage);
_setupSound();
_setupInGameHelp();
_local2 = (_gameFrame.getChildByName("link_mc") as MovieClip);
_local2.mouseChildren = false;
_local2.mouseEnabled = true;
_local2.buttonMode = true;
_local2.useHandCursor = true;
_local2.addEventListener(MouseEvent.CLICK, _onInGameHelpLinkClicked);
}
private function _onAddedToStage(_arg1:Event):void{
_gameFrame = (_af.createDisplayObject("GameFrame") as Sprite);
if (_gameFrame != null){
_gameFrame.addEventListener(Event.ADDED_TO_STAGE, _onGameFrameAddedToStage);
addChild(_gameFrame);
} else {
KerbLog.instance().info("could not find \"GameFrame\" in assets.swf");
};
stage.addEventListener(KeyboardEvent.KEY_DOWN, _onKeyDown);
}
private function _setupSokatorLinkButton(_arg1:MovieClip):void{
_arg1.mouseChildren = false;
_arg1.mouseEnabled = true;
_arg1.buttonMode = true;
_arg1.useHandCursor = true;
_arg1.addEventListener(MouseEvent.CLICK, _onInGameHelpLinkClicked);
}
private function _onKeyDown(_arg1:KeyboardEvent):void{
switch (_arg1.keyCode){
case Keyboard.DELETE:
_gameFrame.visible = false;
break;
case Keyboard.INSERT:
_gameFrame.visible = true;
break;
};
}
private function _hideInstructionsPanel():void{
var _local1:MovieClip = (_frontPagePanel.getChildByName("instrPanel_mc") as MovieClip);
var _local2:MovieClip = (_frontPagePanel.getChildByName("instructions_mc") as MovieClip);
if (((!((_local1 == null))) && (!((_local2 == null))))){
if (_local1.visible){
_local1.visible = false;
_local1.alpha = 0;
_local1.gotoAndStop(1);
_local2.visible = true;
};
};
}
private function _hideFrontPage():void{
_frontPage.visible = false;
if (contains(_frontPage)){
removeChild(_frontPage);
};
}
private function _onInGameHelpClosed(_arg1:MouseEvent):void{
var _local3:MovieClip;
var _local2:MovieClip = (_inGameHelp.getChildByName("thing_mc") as MovieClip);
if (_local2 != null){
_local3 = (_local2.getChildByName("close_mc") as MovieClip);
if (_local3 != null){
Sounds.instance().playButtonPress();
_local3.mouseChildren = false;
_local3.mouseEnabled = false;
_local3.buttonMode = false;
_local3.useHandCursor = false;
_local3.removeEventListener(MouseEvent.CLICK, _onInGameHelpClosed);
};
};
_removeInGameHelp();
_enableInGameHelpButton();
}
private function _onInstructionsPanelOpened(_arg1:Event):void{
var _local2:MovieClip = (_arg1.target as MovieClip);
var _local3:MovieClip = (_local2.getChildByName("thing_mc") as MovieClip);
if (_local3 != null){
_setupSokatorLinkButton((_local3.getChildByName("link1_mc") as MovieClip));
_setupSokatorLinkButton((_local3.getChildByName("link2_mc") as MovieClip));
};
}
private function _setupInstructionsPanel():void{
var _local1:MovieClip = (_frontPagePanel.getChildByName("instrPanel_mc") as MovieClip);
if (_local1 != null){
_local1.visible = false;
} else {
KerbLog.instance().info("could not find \"thing_mc.panel_mc\" in FrontPage");
};
}
private function _setupGameContainer():void{
_gameContainer = new Sprite();
addChildAt(_gameContainer, 0);
}
private function _onSoundsInitialized(_arg1:Event):void{
Sounds.instance().removeEventListener(Event.COMPLETE, _onSoundsInitialized);
_frontPage = (_af.createDisplayObject("FrontPage") as Sprite);
if (_frontPage != null){
_frontPage.addEventListener(Event.ADDED_TO_STAGE, _onFrontPageAddedToStage);
addChildAt(_frontPage, 0);
} else {
KerbLog.instance().info("could not find \"FrontPage\" in assets.swf");
};
Sounds.instance().playMusicTheme();
}
private function _setupInstructionsButton():void{
var _local1:MovieClip = (_frontPagePanel.getChildByName("instructions_mc") as MovieClip);
if (_local1 != null){
_local1.buttonMode = true;
_local1.mouseChildren = false;
_local1.mouseEnabled = true;
_local1.useHandCursor = true;
_local1.addEventListener(MouseEvent.CLICK, _onInstructionsButtonClicked);
} else {
KerbLog.instance().info("could not find \"thing_mc.instructions_mc\" in FrontPage");
};
}
private function _removeInGameHelp():void{
if (_inGameHelp != null){
if (_gameFrame.contains(_inGameHelp)){
_gameFrame.removeChild(_inGameHelp);
};
_inGameHelp = null;
};
}
private function _onInstructionsButtonClicked(_arg1:MouseEvent):void{
var _local2:MovieClip = (_frontPagePanel.getChildByName("instrPanel_mc") as MovieClip);
var _local3:MovieClip = (_frontPagePanel.getChildByName("instructions_mc") as MovieClip);
if (((!((_local2 == null))) && (!((_local3 == null))))){
Sounds.instance().playButtonPress();
_local2.visible = true;
_local2.alpha = 1;
_local2.gotoAndPlay(1);
_local2.addEventListener(Event.COMPLETE, _onInstructionsPanelOpened);
_local3.visible = false;
};
}
private function _onPlayButtonClicked(_arg1:MouseEvent):void{
Sounds.instance().stopMusicTheme();
Sounds.instance().playButtonPress();
_hideFrontPage();
_enableInGameHelpButton();
_game = new Game(_af, _gameContainer, _gameFrame);
_game.addEventListener(Event.COMPLETE, _onGameComplete);
_game.startFirstLevel();
}
private function _setupPlayButton():void{
var _local1:MovieClip = (_frontPagePanel.getChildByName("play_mc") as MovieClip);
if (_local1 != null){
_local1.buttonMode = true;
_local1.mouseChildren = false;
_local1.mouseEnabled = true;
_local1.useHandCursor = true;
_local1.addEventListener(MouseEvent.CLICK, _onPlayButtonClicked);
} else {
KerbLog.instance().info("could not find \"thing_mc.play_mc\" in FrontPage");
};
}
private function _onGameComplete(_arg1:Event):void{
_game.removeEventListener(Event.COMPLETE, _onGameComplete);
_game.dispose();
_game = null;
_hideInstructionsPanel();
_removeInGameHelp();
_disableInGameHelpButton();
_showFrontPage();
Sounds.instance().playMusicTheme();
}
private function _enableInGameHelpButton():void{
var _local1:MovieClip = (_gameFrame.getChildByName("help_mc") as MovieClip);
_local1.mouseChildren = false;
_local1.mouseEnabled = true;
_local1.buttonMode = true;
_local1.useHandCursor = true;
_local1.addEventListener(MouseEvent.CLICK, _onInGameHelpButtonClicked);
_local1.gotoAndStop("_up");
}
private function _setupSound():void{
var _local1:SoundManager = new SoundManager();
var _local2:SoundManager = new SoundManager();
_sc = (_gameFrame.getChildByName("soundControl_mc") as SoundControl);
_sc.init(_local1, _local2);
Sounds.instance().addEventListener(Event.COMPLETE, _onSoundsInitialized);
Sounds.instance().init(_local1, _local2);
}
private function _showFrontPage():void{
_frontPage.visible = true;
if (!contains(_frontPage)){
addChildAt(_frontPage, 0);
};
}
private function _onPlayIntroSound(_arg1:Event):void{
_frontPagePanel.removeEventListener("EVENT_PLAY_INTRO_SOUND", _onPlayIntroSound);
Sounds.instance().playFrontPageAppearing();
}
private function _setupInGameHelp():void{
_disableInGameHelpButton();
}
private function _onInGameHelpAddedToStage(_arg1:Event):void{
var _local3:MovieClip;
_inGameHelp.removeEventListener(Event.ADDED_TO_STAGE, _onInGameHelpAddedToStage);
var _local2:MovieClip = (_inGameHelp.getChildByName("thing_mc") as MovieClip);
if (_local2 != null){
_local3 = (_local2.getChildByName("close_mc") as MovieClip);
if (_local3 != null){
_local3.mouseChildren = false;
_local3.mouseEnabled = true;
_local3.buttonMode = true;
_local3.useHandCursor = true;
_local3.addEventListener(MouseEvent.CLICK, _onInGameHelpClosed);
};
_setupSokatorLinkButton((_local2.getChildByName("link1_mc") as MovieClip));
_setupSokatorLinkButton((_local2.getChildByName("link2_mc") as MovieClip));
};
}
private function _disableInGameHelpButton():void{
var _local1:MovieClip = (_gameFrame.getChildByName("help_mc") as MovieClip);
_local1.mouseChildren = false;
_local1.mouseEnabled = false;
_local1.buttonMode = false;
_local1.useHandCursor = false;
_local1.removeEventListener(MouseEvent.CLICK, _onInGameHelpButtonClicked);
}
private function _onFrontPageAddedToStage(_arg1:Event):void{
_frontPage.removeEventListener(Event.ADDED_TO_STAGE, _onFrontPageAddedToStage);
_frontPagePanel = (_frontPage.getChildByName("panel_mc") as MovieClip);
if (_frontPagePanel != null){
_frontPagePanel.addEventListener("EVENT_PLAY_INTRO_SOUND", _onPlayIntroSound);
_setupGameContainer();
_setupInstructionsButton();
_setupInstructionsPanel();
_setupPlayButton();
} else {
KerbLog.instance().info("could not find \"panel_mc\" in FrontPage");
};
}
private function _onInGameHelpLinkClicked(_arg1:MouseEvent):void{
navigateToURL(new URLRequest(SOKATOR_URL));
DoubleQuick.click(358);
}
private function _onInGameHelpButtonClicked(_arg1:MouseEvent):void{
Sounds.instance().playButtonPress();
_disableInGameHelpButton();
_removeInGameHelp();
_inGameHelp = (_af.createDisplayObject("InGameHelp") as MovieClip);
_inGameHelp.addEventListener(Event.ADDED_TO_STAGE, _onInGameHelpAddedToStage);
_gameFrame.addChild(_inGameHelp);
}
}
}//package com.kerb.sokator.freekick
Section 49
//Preloader (com.kerb.sokator.freekick.Preloader)
package com.kerb.sokator.freekick {
import flash.events.*;
import flash.display.*;
import com.kerb.utils.*;
import flash.utils.*;
public final class Preloader extends MovieClip {
private const swfBytes:Class;
private var _preloaderAsset:MovieClip;// = null
private var _af:AssetFactory;// = null
public function Preloader(){
swfBytes = Preloader_swfBytes;
super();
stop();
_af = new AssetFactory();
_af.addEventListener(AssetFactory.EVENT_ASSET_FACTORY_READY, _onAssetFactoryReady);
_af.initialize(swfBytes);
}
private function _onEnterFrame(_arg1:Event):void{
var _local2:Class;
var _local3:Number;
if (root.loaderInfo.bytesLoaded >= root.loaderInfo.bytesTotal){
removeEventListener(Event.ENTER_FRAME, _onEnterFrame);
_removePreloaderAsset();
_af = null;
nextFrame();
_local2 = (getDefinitionByName("FreeKickGame") as Class);
if (_local2){
addChild((new (_local2) as Sprite));
};
} else {
_addPreloaderAsset();
_local3 = ((100 * root.loaderInfo.bytesLoaded) / root.loaderInfo.bytesTotal);
_preloaderAsset.loading_mc.percent_mc.gotoAndStop(Math.ceil(_local3));
};
}
private function _onAssetFactoryReady(_arg1:Event):void{
_af.removeEventListener(AssetFactory.EVENT_ASSET_FACTORY_READY, _onAssetFactoryReady);
addEventListener(Event.ENTER_FRAME, _onEnterFrame);
}
private function _addPreloaderAsset():void{
if (_preloaderAsset == null){
_preloaderAsset = (_af.createDisplayObject("Preloader") as MovieClip);
addChild(_preloaderAsset);
};
}
private function _removePreloaderAsset():void{
if (_preloaderAsset != null){
if (contains(_preloaderAsset)){
removeChild(_preloaderAsset);
};
_preloaderAsset = null;
};
}
}
}//package com.kerb.sokator.freekick
Section 50
//Preloader_swfBytes (com.kerb.sokator.freekick.Preloader_swfBytes)
package com.kerb.sokator.freekick {
import mx.core.*;
public class Preloader_swfBytes extends ByteArrayAsset {
}
}//package com.kerb.sokator.freekick
Section 51
//Sounds (com.kerb.sokator.freekick.Sounds)
package com.kerb.sokator.freekick {
import flash.events.*;
import com.kerb.utils.*;
import com.kerb.sound.*;
import flash.utils.*;
import flash.media.*;
public final class Sounds extends EventDispatcher {
private const swfBytes:Class;
private var _promoInfoDisplay:ExtendedSound;
private var _blingConsoleAppearing:ExtendedSound;
private var _kick:ExtendedSound;
private var _levelAmbienceLoop:Array;
private var _ballInholeCheer:ExtendedSound;
private var _smMusic:SoundManager;
private var _stBounce:SoundTransform;
private var _laserWipe:ExtendedSound;
private var _travelThroughHole:ExtendedSound;
private var _musicTheme:ExtendedSound;
private var _af:AssetFactory;
private var _holodeckStartup1:ExtendedSound;
private var _holodeckStartup2:ExtendedSound;
private var _smSfx:SoundManager;
private var _frontPageAppearing:ExtendedSound;
private var _buttonPress:ExtendedSound;
private var _headToHole:ExtendedSound;
private static var _instance:Sounds;
public function Sounds(){
swfBytes = Sounds_swfBytes;
_stBounce = new SoundTransform(0.4);
super();
}
public function playFrontPageAppearing():void{
_frontPageAppearing.play();
}
public function playKick():void{
_kick.play();
}
public function init(_arg1:SoundManager, _arg2:SoundManager):void{
_smMusic = _arg1;
_smSfx = _arg2;
_af = new AssetFactory();
_af.addEventListener(AssetFactory.EVENT_ASSET_FACTORY_READY, _onAssetFactoryReady);
_af.initialize(swfBytes);
}
public function playHolodeckStartup():void{
var _local1 = 2000;
_holodeckStartup1.play();
_holodeckStartup1.fadeOut(_local1);
var _local2:Timer = new Timer(_local1, 1);
_local2.addEventListener(TimerEvent.TIMER_COMPLETE, _onPlayHolodeckStartup2);
_local2.start();
}
public function playBlingConsoleAppearing():void{
_blingConsoleAppearing.play();
}
public function playHeadToHole():void{
_headToHole.play();
}
public function stopLevelAmbienceLoop():void{
var _local1:int;
while (_local1 < _levelAmbienceLoop.length) {
_levelAmbienceLoop[_local1].stop();
_local1++;
};
}
public function stopMusicTheme():void{
_musicTheme.stop();
}
public function playLevelAmbienceLoop(_arg1:int):void{
var _local2:Number = 0;
switch (_arg1){
case 3:
_local2 = 0.5;
break;
default:
_local2 = 0.15;
break;
};
_levelAmbienceLoop[_arg1].play(0, 99999, new SoundTransform(_local2));
}
public function playBallBounce():void{
_kick.play(0, 0, _stBounce);
}
public function stopPromoInfoDisplay():void{
_promoInfoDisplay.stop();
}
public function playTravelThroughHole():void{
_travelThroughHole.play();
_travelThroughHole.fadeOut(1500);
}
private function _onPlayHolodeckStartup2(_arg1:TimerEvent):void{
_holodeckStartup2.play();
}
public function playButtonPress():void{
_buttonPress.play();
}
public function playLaserWipe():void{
_laserWipe.play();
}
private function _onAssetFactoryReady(_arg1:Event):void{
_af.removeEventListener(AssetFactory.EVENT_ASSET_FACTORY_READY, _onAssetFactoryReady);
_ballInholeCheer = _af.createExtendedSound("SfxBallInHoleCheer");
_smSfx.registerSound(_ballInholeCheer, "SfxBallInHoleCheer");
_blingConsoleAppearing = _af.createExtendedSound("SfxBlingConsoleAppearing");
_smSfx.registerSound(_blingConsoleAppearing, "SfxBlingConsoleAppearing");
_buttonPress = _af.createExtendedSound("SfxButtonPress");
_smSfx.registerSound(_buttonPress, "SfxButtonPress");
_holodeckStartup1 = _af.createExtendedSound("SfxHolodeckStartup1");
_smSfx.registerSound(_holodeckStartup1, "SfxHolodeckStartup1");
_holodeckStartup2 = _af.createExtendedSound("SfxHolodeckStartup2");
_smSfx.registerSound(_holodeckStartup2, "SfxHolodeckStartup2");
_levelAmbienceLoop = new Array(5);
_levelAmbienceLoop[0] = _af.createExtendedSound("SfxAmbientCelc");
_smSfx.registerSound(_levelAmbienceLoop[0], "SfxAmbientCelc");
_levelAmbienceLoop[1] = _af.createExtendedSound("SfxAmbientKrys");
_smSfx.registerSound(_levelAmbienceLoop[1], "SfxAmbientStra");
_levelAmbienceLoop[2] = _af.createExtendedSound("SfxAmbientCamo");
_smSfx.registerSound(_levelAmbienceLoop[2], "SfxAmbientCamo");
_levelAmbienceLoop[3] = _af.createExtendedSound("SfxAmbientFore");
_smSfx.registerSound(_levelAmbienceLoop[3], "SfxAmbientFore");
_levelAmbienceLoop[4] = _af.createExtendedSound("SfxAmbientKrys");
_smSfx.registerSound(_levelAmbienceLoop[4], "SfxAmbientKrys");
_promoInfoDisplay = _af.createExtendedSound("SfxPromoInformationDisplay");
_smSfx.registerSound(_promoInfoDisplay, "SfxPromoInformationDisplay");
_frontPageAppearing = _af.createExtendedSound("SfxFrontPageAppearing");
_smSfx.registerSound(_frontPageAppearing, "SfxFrontPageAppearing");
_headToHole = _af.createExtendedSound("SfxHeadToHole");
_smSfx.registerSound(_headToHole, "SfxHeadToHole");
_kick = _af.createExtendedSound("SfxKick");
_smSfx.registerSound(_kick, "SfxKick");
_travelThroughHole = _af.createExtendedSound("SfxTravelThroughHole");
_smSfx.registerSound(_travelThroughHole, "SfxTravelThroughHole");
_laserWipe = _af.createExtendedSound("SfxLaserWipe");
_smSfx.registerSound(_laserWipe, "SfxLaserWipe");
_musicTheme = _af.createExtendedSound("MusicTheme");
_smMusic.registerSound(_musicTheme, "MusicTheme");
dispatchEvent(new Event(Event.COMPLETE));
}
public function playBallInHoleCheer():void{
_ballInholeCheer.play();
}
public function playMusicTheme():void{
_musicTheme.play(0, 99999);
}
public function playPromoInfoDisplay():void{
_promoInfoDisplay.play();
}
public static function instance():Sounds{
if (_instance == null){
_instance = new (Sounds);
};
return (_instance);
}
}
}//package com.kerb.sokator.freekick
Section 52
//Sounds_swfBytes (com.kerb.sokator.freekick.Sounds_swfBytes)
package com.kerb.sokator.freekick {
import mx.core.*;
public class Sounds_swfBytes extends ByteArrayAsset {
}
}//package com.kerb.sokator.freekick
Section 53
//ExtendedSound (com.kerb.sound.ExtendedSound)
package com.kerb.sound {
import flash.events.*;
import flash.media.*;
import flash.utils.*;
public class ExtendedSound extends Sound {
protected var fadeStartVolume:Number;
protected var panStartPosition:Number;
protected var masterVolume:Number;// = 1
protected var panTimer:Timer;
protected var fadeTimer:Timer;
protected var paused:Boolean;
protected var fadeDuration:Number;
protected var fadeStartTime:Number;
protected var fadeEndVolume:Number;
protected var playingLoops:Number;
protected var panEndPosition:Number;
protected var panStartTime:Number;
protected var panDuration:Number;
protected var pauseTime:Number;
protected var transform:SoundTransform;
protected var soundChannel:SoundChannel;
private static const TIMER_UPDATE_RATE:Number = 20;
public function stop():void{
if (soundChannel != null){
soundChannel.stop();
soundChannel.removeEventListener(Event.SOUND_COMPLETE, onSoundComplete);
soundChannel = null;
};
}
protected function updatePan(_arg1:TimerEvent):void{
var _local2:Number;
var _local3:Number = ((getTimer() - panStartTime) / panDuration);
if (_local3 >= 1){
stopPan();
_local2 = panEndPosition;
} else {
if (_local3 > 0){
_local2 = ((_local3 * (panEndPosition - panStartPosition)) + panStartPosition);
};
};
var _local4:Number = soundChannel.soundTransform.volume;
transform = new SoundTransform(_local4, _local2);
soundChannel.soundTransform = transform;
}
public function fadeTo(_arg1:Number, _arg2:Number):void{
if (((soundChannel) && (soundChannel.soundTransform))){
fadeStartTime = getTimer();
fadeDuration = _arg2;
fadeStartVolume = (soundChannel.soundTransform.volume / masterVolume);
fadeEndVolume = _arg1;
startFade();
};
}
public function setMasterVolume(_arg1:Number):void{
var _local2:Number;
masterVolume = Math.max(0, Math.min(1, _arg1));
if (soundChannel != null){
_local2 = soundChannel.soundTransform.pan;
transform = new SoundTransform((_arg1 * masterVolume), _local2);
soundChannel.soundTransform = transform;
};
}
protected function stopFade():void{
if (((!((fadeTimer == null))) && (fadeTimer.running))){
fadeTimer.reset();
};
}
public function setVolume(_arg1:Number):void{
var _local2:Number;
if (soundChannel != null){
_arg1 = Math.max(0, Math.min(1, _arg1));
_local2 = soundChannel.soundTransform.pan;
transform = new SoundTransform((_arg1 * masterVolume), _local2);
soundChannel.soundTransform = transform;
stopFade();
};
}
public function fadeOut(_arg1:Number=0):void{
if ((((((_arg1 > 0)) && (soundChannel))) && (soundChannel.soundTransform))){
fadeStartTime = getTimer();
fadeDuration = _arg1;
fadeStartVolume = (soundChannel.soundTransform.volume / masterVolume);
fadeEndVolume = 0;
startFade();
} else {
stop();
};
}
override public function play(_arg1:Number=0, _arg2:int=0, _arg3:SoundTransform=null):SoundChannel{
if (_arg3 != null){
_arg3.volume = (_arg3.volume * masterVolume);
} else {
_arg3 = new SoundTransform(masterVolume);
};
soundChannel = super.play(_arg1, _arg2, _arg3);
soundChannel.addEventListener(Event.SOUND_COMPLETE, onSoundComplete);
playingLoops = _arg2;
transform = _arg3;
paused = false;
return (soundChannel);
}
protected function stopPan():void{
if (((!((panTimer == null))) && (panTimer.running))){
panTimer.reset();
};
}
public function fadeIn(_arg1:Number=0, _arg2:Number=1, _arg3:Number=0, _arg4:int=0, _arg5:Number=0):SoundChannel{
fadeStartVolume = Math.max(0, Math.min(1, _arg1));
play(_arg5, _arg4, new SoundTransform((fadeStartVolume * masterVolume)));
if (_arg3 > 0){
fadeStartTime = getTimer();
fadeDuration = _arg3;
fadeEndVolume = Math.max(0, Math.min(1, _arg2));
startFade();
};
return (soundChannel);
}
protected function onSoundComplete(_arg1:Event):void{
dispatchEvent(_arg1);
}
public function get position():Number{
if (soundChannel == null){
return (0);
};
return (soundChannel.position);
}
protected function startPan():void{
if (panTimer == null){
panTimer = new Timer(TIMER_UPDATE_RATE);
panTimer.addEventListener(TimerEvent.TIMER, updatePan);
};
stopPan();
panTimer.start();
}
public function setPan(_arg1:Number):void{
var _local2:Number;
if (soundChannel != null){
_arg1 = Math.max(-1, Math.min(1, _arg1));
_local2 = soundChannel.soundTransform.volume;
transform = new SoundTransform(_local2, _arg1);
soundChannel.soundTransform = transform;
stopPan();
};
}
protected function updateFade(_arg1:TimerEvent):void{
var _local2:Number;
var _local3:Number = ((getTimer() - fadeStartTime) / fadeDuration);
if (_local3 >= 1){
stopFade();
_local2 = fadeEndVolume;
} else {
if (_local3 > 0){
_local2 = ((_local3 * (fadeEndVolume - fadeStartVolume)) + fadeStartVolume);
};
};
var _local4:Number = soundChannel.soundTransform.pan;
transform = new SoundTransform((_local2 * masterVolume), _local4);
soundChannel.soundTransform = transform;
}
public function getSoundChannel():SoundChannel{
return (soundChannel);
}
override public function toString():String{
var _local1:String = getQualifiedClassName(this);
if (soundChannel != null){
_local1 = (_local1 + ((" vol[" + (soundChannel.soundTransform.volume / masterVolume)) + "]"));
_local1 = (_local1 + ((" pan[" + soundChannel.soundTransform.pan) + "]"));
};
return (_local1);
}
public function pause():void{
if (soundChannel == null){
return;
};
pauseTime = soundChannel.position;
stop();
}
public function panTo(_arg1:Number, _arg2:Number):void{
if (_arg2 > 0){
panStartTime = getTimer();
panDuration = _arg2;
panStartPosition = soundChannel.soundTransform.pan;
panEndPosition = _arg1;
startPan();
} else {
setPan(_arg1);
};
}
public function unpause():void{
play(pauseTime, playingLoops, transform);
}
protected function startFade():void{
if (fadeTimer == null){
fadeTimer = new Timer(TIMER_UPDATE_RATE);
fadeTimer.addEventListener(TimerEvent.TIMER, updateFade);
};
stopFade();
fadeTimer.start();
}
}
}//package com.kerb.sound
Section 54
//SoundManager (com.kerb.sound.SoundManager)
package com.kerb.sound {
import flash.utils.*;
public class SoundManager {
private var sounds:Array;
private var prevMasterVolume:Number;
private var muteState:Boolean;// = false
private var masterVolume:Number;// = 1
public function SoundManager(){
prevMasterVolume = masterVolume;
sounds = new Array();
super();
}
public function unregisterSound(_arg1:String):void{
if (sounds[_arg1] != null){
sounds[_arg1].stop();
sounds[_arg1] = null;
};
}
public function stopAllSounds():void{
var _local1:String;
for (_local1 in sounds) {
sounds[_local1].stop();
};
}
public function setMasterVolume(_arg1:Number):void{
var _local2:String;
prevMasterVolume = masterVolume;
masterVolume = Math.max(0, Math.min(1, _arg1));
for (_local2 in sounds) {
sounds[_local2].setMasterVolume(masterVolume);
};
}
public function get muted():Boolean{
return (muteState);
}
public function registerSound(_arg1:ExtendedSound, _arg2:String=null, _arg3:Boolean=false):void{
if (_arg2 == null){
_arg2 = getQualifiedClassName(_arg1);
};
if (sounds[_arg2] != null){
if (_arg3){
unregisterSound(_arg2);
} else {
throw (new Error((("Class name conflict: A sound with the class name [" + _arg2) + "] already exists in SoundManager.")));
};
};
sounds[_arg2] = _arg1;
_arg1.setMasterVolume(masterVolume);
}
public function unmute():void{
if (muteState){
muteState = false;
setMasterVolume(prevMasterVolume);
};
}
public function getSoundByClassName(_arg1:String):ExtendedSound{
return (sounds[_arg1]);
}
public function mute():void{
if (!muteState){
muteState = true;
setMasterVolume(0);
};
}
public function toString():String{
var _local2:String;
var _local1 = "====================\n";
_local1 = (_local1 + "SoundManager\n");
_local1 = (_local1 + "--------------------\n");
_local1 = (_local1 + (("master vol[" + masterVolume) + "]\n"));
_local1 = (_local1 + "--------------------");
for (_local2 in sounds) {
_local1 = (_local1 + ("\n" + sounds[_local2].toString()));
};
_local1 = (_local1 + "\n====================");
return (_local1);
}
}
}//package com.kerb.sound
Section 55
//DoubleQuick (com.kerb.tracking.DoubleQuick)
package com.kerb.tracking {
import flash.events.*;
import flash.display.*;
import flash.net.*;
import flash.utils.*;
public class DoubleQuick {
private static const SO_SESSION_PROPERTY_NAME:String = "sessionkey";
private static const SO_NAME:String = "doublequick";
private static const TICKER_PERIOD:Number = 30000;
private static const TRACKER_SESSION_URL:String = "http://doublequick.kerb.co.uk/tracking/session.htm";
private static const TICKER_URL:String = "http://doublequick.kerb.co.uk/tracking/ticker.htm";
private static const TRACKER_URL:String = "http://doublequick.kerb.co.uk/tracking/trackflash.htm";
private static const SO_EXPIRY_PROPERTY_NAME:String = "expo";
private static var tickerURL:URLRequest = null;
private static var initialised:Boolean = false;
private static var queue:Array = new Array();
private static var projectId:Number;
private static var baseurl:String;
private static var dq:DoubleQuick;
private static var traceEvents:Boolean;
public function startTimer():void{
var _local1:Timer = new Timer(TICKER_PERIOD, 0);
_local1.start();
_local1.addEventListener(TimerEvent.TIMER, pingProxy);
}
public function pingProxy(_arg1:TimerEvent):void{
DoubleQuick.ping();
}
private static function doTrace(_arg1:String):void{
if (traceEvents){
trace(_arg1);
};
}
public static function event(_arg1:Number):void{
var loader:URLLoader;
var request:URLRequest;
var watchId = _arg1;
if (!initialised){
doTrace(("Queueing event " + watchId));
queue.push(watchId);
} else {
doTrace(("Tracking event " + watchId));
loader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
loader.addEventListener(IOErrorEvent.IO_ERROR, dummyListener);
request = generateURL(watchId);
request.method = URLRequestMethod.GET;
try {
loader.load(request);
} catch(error:Error) {
};
};
}
public static function click(_arg1:Number):void{
doTrace(("Tracking clickThrough " + _arg1));
navigateToURL(generateURL(_arg1));
}
private static function dummyListener(_arg1:Event):void{
}
private static function onInit(_arg1:Event):void{
var _local4:Date;
var _local2:URLLoader = URLLoader(_arg1.target);
var _local3:SharedObject = SharedObject.getLocal(DoubleQuick.SO_NAME);
if (((!((_local2.data["sessionkey"] == ""))) && (!((_local2.data["sessionkey"] == null))))){
doTrace(("acquired session key " + _local2.data["sessionkey"]));
_local3.setProperty(DoubleQuick.SO_SESSION_PROPERTY_NAME, _local2.data["sessionkey"]);
_local4 = new Date((new Date().getTime() + ((_local2.data["timeout"] * 60) * 1000)));
_local3.setProperty(DoubleQuick.SO_EXPIRY_PROPERTY_NAME, _local4);
};
DoubleQuick.initialisationFinished();
}
public static function init(_arg1:DisplayObject, _arg2:Number, _arg3:Boolean=true):void{
var loader:URLLoader;
var request:URLRequest;
var root = _arg1;
var _projectId = _arg2;
var _traceEvents = _arg3;
projectId = _projectId;
traceEvents = _traceEvents;
baseurl = root.loaderInfo.url;
doTrace(((("Tracking initialised with project " + projectId) + " and baseurl ") + baseurl));
var so:SharedObject = SharedObject.getLocal(DoubleQuick.SO_NAME);
var isExpired:Boolean;
var currentDate:Date = new Date();
if (currentDate < so.data[DoubleQuick.SO_EXPIRY_PROPERTY_NAME]){
isExpired = false;
};
if ((((so.data[DoubleQuick.SO_SESSION_PROPERTY_NAME] == undefined)) || (isExpired))){
doTrace("requesting new session key");
loader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
loader.addEventListener(Event.COMPLETE, onInit);
loader.addEventListener(IOErrorEvent.IO_ERROR, dummyListener);
request = new URLRequest(((TRACKER_SESSION_URL + "?project=") + projectId));
request.method = URLRequestMethod.GET;
try {
loader.load(request);
} catch(error:Error) {
};
} else {
DoubleQuick.initialisationFinished();
};
}
public static function initialisationFinished():void{
doTrace("Tracking initialised");
initialised = true;
var _local1:int;
while (_local1 < queue.length) {
event(queue[_local1]);
_local1++;
};
queue = new Array();
var _local2:SharedObject = SharedObject.getLocal(DoubleQuick.SO_NAME);
tickerURL = new URLRequest(((((TICKER_URL + "?project=") + projectId) + "&session=") + _local2.data[DoubleQuick.SO_SESSION_PROPERTY_NAME]));
tickerURL.method = URLRequestMethod.GET;
dq = new (DoubleQuick);
dq.startTimer();
}
public static function ping():void{
var loader:URLLoader;
if (tickerURL != null){
loader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
loader.addEventListener(IOErrorEvent.IO_ERROR, dummyListener);
doTrace("Tracking ticker");
try {
loader.load(tickerURL);
} catch(error:Error) {
};
};
}
private static function generateURL(_arg1:Number):URLRequest{
var _local2:SharedObject = SharedObject.getLocal(DoubleQuick.SO_NAME);
var _local3:String = ((((((((TRACKER_URL + "?watch=") + _arg1) + "&project=") + projectId) + "&session=") + _local2.data[DoubleQuick.SO_SESSION_PROPERTY_NAME]) + "&baseurl=") + escape(baseurl));
return (new URLRequest(_local3));
}
}
}//package com.kerb.tracking
Section 56
//SoundControl (com.kerb.ui.SoundControl)
package com.kerb.ui {
import flash.events.*;
import flash.display.*;
import com.kerb.utils.*;
import com.kerb.sound.*;
public class SoundControl extends MovieClip implements IDisposable {
protected var _musicSoundManager:SoundManager;
protected var _sfxSoundManager:SoundManager;
protected var propagateMasterChange:Boolean;
public function SoundControl(){
propagateMasterChange = true;
}
public function get musicSoundManager():SoundManager{
return (_musicSoundManager);
}
protected function onSFXChange(_arg1:Event):void{
var _local2:Toggle = (getChildByName("music_btn") as Toggle);
var _local3:Toggle = (getChildByName("sfx_btn") as Toggle);
var _local4:Toggle = (getChildByName("master_btn") as Toggle);
propagateMasterChange = false;
if (_local3.isOn){
if (_sfxSoundManager.muted){
_sfxSoundManager.unmute();
};
_local4.isOn = true;
} else {
if (!_sfxSoundManager.muted){
_sfxSoundManager.mute();
};
if (!_local2.isOn){
_local4.isOn = false;
};
};
propagateMasterChange = true;
}
public function set musicSoundManager(_arg1:SoundManager):void{
this._musicSoundManager = _arg1;
}
public function get sfxSoundManager():SoundManager{
return (_sfxSoundManager);
}
public function set sfxSoundManager(_arg1:SoundManager):void{
this._sfxSoundManager = _arg1;
}
public function dispose():void{
var _local1:Toggle = (getChildByName("music_btn") as Toggle);
var _local2:Toggle = (getChildByName("sfx_btn") as Toggle);
var _local3:Toggle = (getChildByName("master_btn") as Toggle);
removeEventListener(MouseEvent.ROLL_OUT, onRollOut);
_local3.removeEventListener(MouseEvent.ROLL_OVER, onRollOver);
_local3.removeEventListener(Event.CHANGE, onMasterChange);
if (_local1 != null){
_local1.removeEventListener(Event.CHANGE, onMusicChange);
};
if (_local2 != null){
_local2.removeEventListener(Event.CHANGE, onSFXChange);
};
}
public function init(_arg1:SoundManager, _arg2:SoundManager):void{
var _local4:int;
var _local5:int;
var _local3:Toggle = (getChildByName("master_btn") as Toggle);
_local3.isOn = true;
this.musicSoundManager = _arg1;
this.sfxSoundManager = _arg2;
_local3.addEventListener(Event.CHANGE, onMasterChange);
_local3.addEventListener(MouseEvent.ROLL_OVER, onRollOver);
addEventListener(MouseEvent.ROLL_OUT, onRollOut);
_local4 = 0;
while (_local4 < currentLabels.length) {
if (currentLabels[_local4].name == "open"){
_local5 = (currentLabels[_local4].frame - 1);
addFrameScript(_local5, initButtons);
break;
};
_local4++;
};
var _local6:MovieClip = (getChildByName("masterHit") as MovieClip);
if (_local6){
_local6.mouseEnabled = false;
_local6.visible = false;
_local3.hitArea = _local6;
};
}
protected function initButtons():void{
var _local3:MovieClip;
var _local1:Toggle = (getChildByName("music_btn") as Toggle);
var _local2:Toggle = (getChildByName("sfx_btn") as Toggle);
_local1.isOn = !(_musicSoundManager.muted);
_local1.addEventListener(Event.CHANGE, onMusicChange);
_local2.isOn = !(_sfxSoundManager.muted);
_local2.addEventListener(Event.CHANGE, onSFXChange);
_local3 = (getChildByName("musicHit") as MovieClip);
if (_local3){
_local3.mouseEnabled = false;
_local3.visible = false;
_local1.hitArea = _local3;
};
_local3 = (getChildByName("sfxHit") as MovieClip);
if (_local3){
_local3.mouseEnabled = false;
_local3.visible = false;
_local2.hitArea = _local3;
};
}
protected function onRollOut(_arg1:MouseEvent):void{
var _local2:Toggle = (getChildByName("music_btn") as Toggle);
var _local3:Toggle = (getChildByName("sfx_btn") as Toggle);
if (_local2 != null){
_local2.removeEventListener(Event.CHANGE, onMusicChange);
};
if (_local3 != null){
_local3.removeEventListener(Event.CHANGE, onSFXChange);
};
gotoAndStop("closed");
}
protected function onRollOver(_arg1:MouseEvent):void{
gotoAndStop("open");
}
protected function onMasterChange(_arg1:Event):void{
var _local2:Toggle = (getChildByName("music_btn") as Toggle);
var _local3:Toggle = (getChildByName("sfx_btn") as Toggle);
var _local4:Toggle = (getChildByName("master_btn") as Toggle);
if (propagateMasterChange){
if (_local4.isOn){
if (_musicSoundManager.muted){
_musicSoundManager.unmute();
};
if (_sfxSoundManager.muted){
_sfxSoundManager.unmute();
};
} else {
if (!_musicSoundManager.muted){
_musicSoundManager.mute();
};
if (!_sfxSoundManager.muted){
_sfxSoundManager.mute();
};
};
if (_local2 != null){
_local2.isOn = _local4.isOn;
};
if (_local3 != null){
_local3.isOn = _local4.isOn;
};
};
}
protected function onMusicChange(_arg1:Event):void{
var _local2:Toggle = (getChildByName("music_btn") as Toggle);
var _local3:Toggle = (getChildByName("sfx_btn") as Toggle);
var _local4:Toggle = (getChildByName("master_btn") as Toggle);
propagateMasterChange = false;
if (_local2.isOn){
if (_musicSoundManager.muted){
_musicSoundManager.unmute();
};
_local4.isOn = true;
} else {
if (!_musicSoundManager.muted){
_musicSoundManager.mute();
};
if (!_local3.isOn){
_local4.isOn = false;
};
};
propagateMasterChange = true;
}
}
}//package com.kerb.ui
Section 57
//Toggle (com.kerb.ui.Toggle)
package com.kerb.ui {
import flash.events.*;
import flash.display.*;
import com.kerb.utils.*;
import flash.text.*;
public class Toggle extends MovieClip implements IDisposable {
protected var _isOn:Boolean;
protected var _state:int;
protected var _label:String;
public static const STATE_DOWN:int = 2;
public static const STATE_UP:int = 0;
public static const STATE_OVER:int = 1;
protected static var stateLabels:Array = ["upOff", "overOff", "downOff", "upOn", "overOn", "downOn"];
public function Toggle(){
_state = STATE_UP;
_label = "";
isOn = false;
buttonMode = true;
mouseChildren = false;
addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
}
protected function onMouseDown(_arg1:MouseEvent):void{
_state = STATE_DOWN;
update();
}
protected function onMouseUp(_arg1:MouseEvent):void{
_state = STATE_OVER;
isOn = !(_isOn);
}
protected function onAddedToStage(_arg1:Event):void{
removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
init();
}
public function get isOn():Boolean{
return (_isOn);
}
protected function onRollOut(_arg1:MouseEvent):void{
_state = STATE_UP;
update();
}
public function set label(_arg1:String):void{
this._label = _arg1;
updateLabel();
}
public function get state():int{
return (_state);
}
public function get label():String{
return (_label);
}
protected function init():void{
var _local2:int;
var _local1:int;
while (_local1 < numChildren) {
if ((getChildAt(_local1) is TextField)){
_local2 = 0;
while (_local2 < totalFrames) {
addFrameScript(_local2, updateLabel);
_local2++;
};
break;
};
_local1++;
};
addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
addEventListener(MouseEvent.MOUSE_UP, onMouseUp);
addEventListener(MouseEvent.ROLL_OVER, onRollOver);
addEventListener(MouseEvent.ROLL_OUT, onRollOut);
}
protected function update():void{
gotoAndStop(stateLabels[((_isOn) ? 3 : 0 + state)]);
}
public function set isOn(_arg1:Boolean):void{
this._isOn = _arg1;
update();
dispatchEvent(new Event(Event.CHANGE));
}
protected function updateLabel():void{
var _local1:int;
while (_local1 < numChildren) {
if ((getChildAt(_local1) is TextField)){
(getChildAt(_local1) as TextField).text = _label;
break;
};
_local1++;
};
}
protected function onRollOver(_arg1:MouseEvent):void{
_state = STATE_OVER;
update();
}
public function dispose():void{
removeEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
removeEventListener(MouseEvent.MOUSE_UP, onMouseUp);
removeEventListener(MouseEvent.ROLL_OVER, onRollOver);
removeEventListener(MouseEvent.ROLL_OUT, onRollOut);
}
}
}//package com.kerb.ui
Section 58
//AssetFactory (com.kerb.utils.AssetFactory)
package com.kerb.utils {
import flash.events.*;
import flash.display.*;
import flash.media.*;
import com.kerb.sound.*;
public final class AssetFactory extends EventDispatcher {
private var _loader:Loader;// = null
public static const EVENT_ASSET_FACTORY_READY:String = "EVENT_ASSET_FACTORY_READY";
public function initialize(_arg1:Class):void{
_loader = new Loader();
_loader.contentLoaderInfo.addEventListener(Event.INIT, _onLibraryReady);
_loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, _onIOError);
_loader.loadBytes(new (_arg1));
}
public function createExtendedSound(_arg1:String):ExtendedSound{
var _local2:Class = Class(_loader.contentLoaderInfo.applicationDomain.getDefinition(_arg1));
return ((new (_local2) as ExtendedSound));
}
public function createDisplayObject(_arg1:String):DisplayObject{
var _local2:Class = Class(_loader.contentLoaderInfo.applicationDomain.getDefinition(_arg1));
return ((new (_local2) as DisplayObject));
}
private function _onLibraryReady(_arg1:Event):void{
_loader.contentLoaderInfo.removeEventListener(Event.INIT, _onLibraryReady);
dispatchEvent(new Event(EVENT_ASSET_FACTORY_READY));
}
public function createSound(_arg1:String):Sound{
var _local2:Class = Class(_loader.contentLoaderInfo.applicationDomain.getDefinition(_arg1));
return ((new (_local2) as Sound));
}
public function createMovieClip(_arg1:String):MovieClip{
var _local2:Class = Class(_loader.contentLoaderInfo.applicationDomain.getDefinition(_arg1));
return ((new (_local2) as MovieClip));
}
public function createBitmapDataObject(_arg1:String):BitmapData{
var _local2:Class = Class(_loader.contentLoaderInfo.applicationDomain.getDefinition(_arg1));
return ((new _local2(0, 0) as BitmapData));
}
private function _onIOError(_arg1:Event):void{
}
}
}//package com.kerb.utils
Section 59
//IDisposable (com.kerb.utils.IDisposable)
package com.kerb.utils {
public interface IDisposable {
function dispose():void;
}
}//package com.kerb.utils
Section 60
//Back (com.robertpenner.easing.Back)
package com.robertpenner.easing {
public class Back {
public static function easeOut(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number=0):Number{
_arg1 = ((_arg1 / _arg4) - 1);
return (((_arg3 * (((_arg1 * _arg1) * (((_arg5 + 1) * _arg1) + _arg5)) + 1)) + _arg2));
}
public static function easeIn(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number=0):Number{
_arg1 = (_arg1 / _arg4);
return (((((_arg3 * _arg1) * _arg1) * (((_arg5 + 1) * _arg1) - _arg5)) + _arg2));
}
public static function easeInOut(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number=0):Number{
_arg1 = (_arg1 / (_arg4 / 2));
if (_arg1 < 1){
_arg5 = (_arg5 * 1.525);
return ((((_arg3 / 2) * ((_arg1 * _arg1) * (((_arg5 + 1) * _arg1) - _arg5))) + _arg2));
};
_arg1 = (_arg1 - 2);
_arg5 = (_arg5 * 1.525);
return ((((_arg3 / 2) * (((_arg1 * _arg1) * (((_arg5 + 1) * _arg1) + _arg5)) + 2)) + _arg2));
}
}
}//package com.robertpenner.easing
Section 61
//Quad (com.robertpenner.easing.Quad)
package com.robertpenner.easing {
public class Quad {
public static function easeOut(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
_arg1 = (_arg1 / _arg4);
return ((((-(_arg3) * _arg1) * (_arg1 - 2)) + _arg2));
}
public static function easeIn(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
_arg1 = (_arg1 / _arg4);
return ((((_arg3 * _arg1) * _arg1) + _arg2));
}
public static function easeInOut(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
_arg1 = (_arg1 / (_arg4 / 2));
if (_arg1 < 1){
return (((((_arg3 / 2) * _arg1) * _arg1) + _arg2));
};
--_arg1;
return ((((-(_arg3) / 2) * ((_arg1 * (_arg1 - 2)) - 1)) + _arg2));
}
}
}//package com.robertpenner.easing
Section 62
//JConfig (jiglib.cof.JConfig)
package jiglib.cof {
public class JConfig {
public static var allowedPenetration:Number = 0.01;
public static var deactivationTime:Number = 0.5;
public static var collToll:Number = 0.05;
public static var angVelThreshold:Number = 0.4;
public static var numCollisionIterations:Number = 4;
public static var solverType:String = "ACCUMULATED";
public static var velThreshold:Number = 0.4;
public static var numContactIterations:Number = 8;
public static var orientThreshold:Number = 0.2;
public static var posThreshold:Number = 0.2;
public static var detectCollisionsType:String = "STORE";
public static var numPenetrationRelaxationTimesteps:Number = 10;
}
}//package jiglib.cof
Section 63
//CollDetectBoxBox (jiglib.collision.CollDetectBoxBox)
package jiglib.collision {
import jiglib.math.*;
import jiglib.physics.*;
import jiglib.geometry.*;
import jiglib.cof.*;
public class CollDetectBoxBox extends CollDetectFunctor {
public function CollDetectBoxBox(){
Name = "BoxBox";
Type0 = "BOX";
Type1 = "BOX";
}
override public function CollDetect(_arg1:CollDetectInfo, _arg2:Array):void{
var _local8:Number;
var _local19:JNumber3D;
var _local20:Number;
var _local21:CollPointInfo;
var _local3:JBox = (_arg1.body0 as JBox);
var _local4:JBox = (_arg1.body1 as JBox);
if (!_local3.hitTestObject3D(_local4)){
return;
};
var _local5:Array = _local3.CurrentState.Orientation.getCols();
var _local6:Array = _local4.CurrentState.Orientation.getCols();
var _local7:Array = new Array(_local5[0], _local5[1], _local5[2], _local6[0], _local6[1], _local6[2], JNumber3D.cross(_local6[0], _local5[0]), JNumber3D.cross(_local6[0], _local5[1]), JNumber3D.cross(_local6[0], _local5[2]), JNumber3D.cross(_local6[1], _local5[0]), JNumber3D.cross(_local6[1], _local5[1]), JNumber3D.cross(_local6[1], _local5[2]), JNumber3D.cross(_local6[2], _local5[0]), JNumber3D.cross(_local6[2], _local5[1]), JNumber3D.cross(_local6[2], _local5[2]));
var _local9:Array = new Array();
var _local10:uint;
while (_local10 < _local7.length) {
_local9[_local10] = new Object();
_local9[_local10].flag = false;
_local9[_local10].depth = JNumber3D.NUM_HUGE;
_local8 = _local7[_local10].modulo2;
if (_local8 < JNumber3D.NUM_TINY){
} else {
_local19 = _local7[_local10].clone();
_local19.normalize();
if (Disjoint(_local9[_local10], _local19, _local3, _local4)){
return;
};
};
_local10++;
};
var _local11:Number = JNumber3D.NUM_HUGE;
var _local12 = -1;
_local10 = 0;
while (_local10 < _local7.length) {
_local8 = _local7[_local10].modulo2;
if (_local8 < JNumber3D.NUM_TINY){
} else {
if (_local9[_local10].depth < _local11){
_local11 = _local9[_local10].depth;
_local12 = _local10;
};
};
_local10++;
};
if (_local12 == -1){
return;
};
var _local13:JNumber3D = _local7[_local12].clone();
if (JNumber3D.dot(JNumber3D.sub(_local4.CurrentState.Position, _local3.CurrentState.Position), _local13) > 0){
_local13 = JNumber3D.multiply(_local13, -1);
};
var _local14:Number = (0.5 * Math.min(Math.min(_local3.SideLengths.x, _local3.SideLengths.y, _local3.SideLengths.z), Math.min(_local4.SideLengths.x, _local4.SideLengths.y, _local4.SideLengths.z)));
var _local15:Array = new Array();
if (_local11 > -(JNumber3D.NUM_TINY)){
GetBoxBoxIntersectionPoints(_local15, _local3, _local4, _local14);
};
var _local16:Array = new Array();
if (_local15.length > 0){
_local20 = 0;
_local10 = 0;
while (_local10 < _local15.length) {
_local20 = _local11;
_local21 = new CollPointInfo();
_local21.R0 = JNumber3D.sub(_local15[_local10].pos, _local3.CurrentState.Position);
_local21.R1 = JNumber3D.sub(_local15[_local10].pos, _local4.CurrentState.Position);
_local21.Position = _local15[_local10].pos;
_local21.InitialPenetration = _local20;
_local16.push(_local21);
_local10++;
};
};
var _local17:CollisionInfo = new CollisionInfo();
_local17.ObjInfo = _arg1;
_local17.DirToBody = _local13;
_local17.PointInfo = _local16;
var _local18:MaterialProperties = new MaterialProperties();
_local18.Restitution = Math.sqrt((_local3.Material.Restitution * _local4.Material.Restitution));
_local18.StaticFriction = Math.sqrt((_local3.Material.StaticFriction * _local4.Material.StaticFriction));
_local18.DynamicFriction = Math.sqrt((_local3.Material.DynamicFriction * _local4.Material.DynamicFriction));
_local17.Mat = _local18;
_arg2.push(_local17);
_arg1.body0.Collisions.push(_local17);
_arg1.body1.Collisions.push(_local17);
}
private function GetBoxBoxIntersectionPoints(_arg1:Array, _arg2:JBox, _arg3:JBox, _arg4:Number):uint{
GetBox2BoxEdgesIntersectionPoints(_arg1, _arg2, _arg3, (_arg4 * _arg4));
GetBox2BoxEdgesIntersectionPoints(_arg1, _arg3, _arg2, (_arg4 * _arg4));
return (_arg1.length);
}
private function Disjoint(_arg1:Object, _arg2:JNumber3D, _arg3:JBox, _arg4:JBox):Boolean{
var _local5:Object = _arg3.GetSpan(_arg2);
var _local6:Object = _arg4.GetSpan(_arg2);
if ((((_local5.min > ((_local6.max + JConfig.collToll) + JNumber3D.NUM_TINY))) || ((_local6.min > ((_local5.max + JConfig.collToll) + JNumber3D.NUM_TINY))))){
_arg1.flag = true;
return (true);
};
if ((((_local5.max > _local6.max)) && ((_local6.min > _local5.min)))){
_arg1.depth = Math.min((_local5.max - _local6.min), (_local6.max - _local5.min));
} else {
if ((((_local6.max > _local5.max)) && ((_local5.min > _local6.min)))){
_arg1.depth = Math.min((_local6.max - _local5.min), (_local5.max - _local6.min));
} else {
_arg1.depth = Math.min(_local5.max, _local6.max);
_arg1.depth = (_arg1.depth - Math.max(_local5.min, _local6.min));
};
};
_arg1.flag = false;
return (false);
}
private function GetBox2BoxEdgesIntersectionPoints(_arg1:Array, _arg2:JBox, _arg3:JBox, _arg4:Number):Number{
var _local6:JSegment;
var _local9:Object;
var _local10:String;
var _local5:Number = 0;
var _local7:Array = _arg3.GetCornerPoints();
var _local8:Array = _arg3.Edges;
for (_local10 in _local8) {
_local9 = new Object();
_local6 = new JSegment(_local7[_local8[_local10].ind0], JNumber3D.sub(_local7[_local8[_local10].ind1], _local7[_local8[_local10].ind0]));
if (_arg2.SegmentIntersect(_local9, _local6)){
if (AddPoint(_arg1, _local9.posOut, _arg4)){
_local5 = (_local5 + 1);
};
};
};
return (_local5);
}
private function AddPoint(_arg1:Array, _arg2:JNumber3D, _arg3:Number):Boolean{
var _local4:String;
for (_local4 in _arg1) {
if (JNumber3D.sub(_arg1[_local4].pos, _arg2).modulo2 < _arg3){
_arg1[_local4].pos = JNumber3D.divide(JNumber3D.add(_arg1[_local4].pos, _arg2), 2);
_arg1[_local4].count = (_arg1[_local4].count + 1);
return (false);
};
};
_arg1.push({pos:_arg2, count:1});
return (true);
}
}
}//package jiglib.collision
Section 64
//CollDetectBoxPlane (jiglib.collision.CollDetectBoxPlane)
package jiglib.collision {
import jiglib.math.*;
import jiglib.physics.*;
import jiglib.geometry.*;
import jiglib.cof.*;
public class CollDetectBoxPlane extends CollDetectFunctor {
public function CollDetectBoxPlane(){
Name = "BoxPlane";
Type0 = "BOX";
Type1 = "PLANE";
}
override public function CollDetect(_arg1:CollDetectInfo, _arg2:Array):void{
var _local3:RigidBody;
var _local9:CollPointInfo;
var _local10:JNumber3D;
var _local11:Number;
var _local12:String;
var _local13:CollisionInfo;
var _local14:MaterialProperties;
if (_arg1.body0.Type == "PLANE"){
_local3 = _arg1.body0;
_arg1.body0 = _arg1.body1;
_arg1.body1 = _local3;
};
var _local4:JBox = (_arg1.body0 as JBox);
var _local5:JPlane = (_arg1.body1 as JPlane);
var _local6:Number = _local5.PointPlaneDistance(_local4.CurrentState.Position);
if (_local6 > (_local4.BoundingSphere + JConfig.collToll)){
return;
};
var _local7:Array = _local4.GetCornerPoints();
var _local8:Array = new Array();
for (_local12 in _local7) {
_local10 = _local7[_local12];
_local11 = (-1 * _local5.PointPlaneDistance(_local10));
if (_local11 > -(JConfig.collToll)){
_local9 = new CollPointInfo();
_local9.R0 = JNumber3D.sub(_local10, _local4.CurrentState.Position);
_local9.R1 = JNumber3D.sub(_local10, _local5.CurrentState.Position);
_local9.InitialPenetration = _local11;
_local8.push(_local9);
};
};
if (_local8.length > 0){
_local13 = new CollisionInfo();
_local13.ObjInfo = _arg1;
_local13.DirToBody = _local5.Normal;
_local13.PointInfo = _local8;
_local14 = new MaterialProperties();
_local14.Restitution = Math.sqrt((_local4.Material.Restitution * _local5.Material.Restitution));
_local14.StaticFriction = Math.sqrt((_local4.Material.StaticFriction * _local5.Material.StaticFriction));
_local14.DynamicFriction = Math.sqrt((_local4.Material.DynamicFriction * _local5.Material.DynamicFriction));
_local13.Mat = _local14;
_arg2.push(_local13);
_arg1.body0.Collisions.push(_local13);
_arg1.body1.Collisions.push(_local13);
};
}
}
}//package jiglib.collision
Section 65
//CollDetectFunctor (jiglib.collision.CollDetectFunctor)
package jiglib.collision {
public class CollDetectFunctor {
public var Type0:String;
public var Type1:String;
public var Name:String;
public function CollDetect(_arg1:CollDetectInfo, _arg2:Array):void{
}
}
}//package jiglib.collision
Section 66
//CollDetectInfo (jiglib.collision.CollDetectInfo)
package jiglib.collision {
import jiglib.physics.*;
public class CollDetectInfo {
public var body0:RigidBody;
public var body1:RigidBody;
}
}//package jiglib.collision
Section 67
//CollDetectSphereBox (jiglib.collision.CollDetectSphereBox)
package jiglib.collision {
import jiglib.math.*;
import jiglib.physics.*;
import jiglib.geometry.*;
import jiglib.cof.*;
public class CollDetectSphereBox extends CollDetectFunctor {
public function CollDetectSphereBox(){
Name = "SphereBox";
Type0 = "SPHERE";
Type1 = "BOX";
}
override public function CollDetect(_arg1:CollDetectInfo, _arg2:Array):void{
var _local3:RigidBody;
var _local9:JNumber3D;
var _local10:Array;
var _local11:CollPointInfo;
var _local12:CollisionInfo;
var _local13:MaterialProperties;
if (_arg1.body0.Type == "BOX"){
_local3 = _arg1.body0;
_arg1.body0 = _arg1.body1;
_arg1.body1 = _local3;
};
var _local4:JSphere = (_arg1.body0 as JSphere);
var _local5:JBox = (_arg1.body1 as JBox);
if (!_local4.hitTestObject3D(_local5)){
return;
};
var _local6:Object = new Object();
var _local7:Number = _local5.GetDistanceToPoint(_local6, _local4.CurrentState.Position);
var _local8:Number = (_local4.Radius - _local7);
if (_local8 > -(JConfig.collToll)){
_local10 = new Array();
if (_local7 < -(JNumber3D.NUM_TINY)){
_local9 = JNumber3D.sub(JNumber3D.sub(_local6.pos, _local4.CurrentState.Position), _local6.pos);
_local9.normalize();
} else {
if (_local7 > JNumber3D.NUM_TINY){
_local9 = JNumber3D.sub(_local4.CurrentState.Position, _local6.pos);
_local9.normalize();
} else {
_local9 = JNumber3D.sub(_local4.CurrentState.Position, _local5.CurrentState.Position);
_local9.normalize();
};
};
_local11 = new CollPointInfo();
_local11.R0 = JNumber3D.sub(_local6.pos, _local4.CurrentState.Position);
_local11.R1 = JNumber3D.sub(_local6.pos, _local5.CurrentState.Position);
_local11.InitialPenetration = _local8;
_local10.push(_local11);
_local12 = new CollisionInfo();
_local12.ObjInfo = _arg1;
_local12.DirToBody = _local9;
_local12.PointInfo = _local10;
_local13 = new MaterialProperties();
_local13.Restitution = Math.sqrt((_local4.Material.Restitution * _local5.Material.Restitution));
_local13.StaticFriction = Math.sqrt((_local4.Material.StaticFriction * _local5.Material.StaticFriction));
_local13.DynamicFriction = Math.sqrt((_local4.Material.DynamicFriction * _local5.Material.DynamicFriction));
_local12.Mat = _local13;
_arg2.push(_local12);
_arg1.body0.Collisions.push(_local12);
_arg1.body1.Collisions.push(_local12);
};
}
}
}//package jiglib.collision
Section 68
//CollDetectSpherePlane (jiglib.collision.CollDetectSpherePlane)
package jiglib.collision {
import jiglib.math.*;
import jiglib.physics.*;
import jiglib.geometry.*;
import jiglib.cof.*;
public class CollDetectSpherePlane extends CollDetectFunctor {
public function CollDetectSpherePlane(){
Name = "SpherePlane";
Type0 = "SPHERE";
Type1 = "PLANE";
}
override public function CollDetect(_arg1:CollDetectInfo, _arg2:Array):void{
var _local3:RigidBody;
var _local8:CollPointInfo;
if (_arg1.body0.Type == "PLANE"){
_local3 = _arg1.body0;
_arg1.body0 = _arg1.body1;
_arg1.body1 = _local3;
};
var _local4:JSphere = (_arg1.body0 as JSphere);
var _local5:JPlane = (_arg1.body1 as JPlane);
var _local6:Number = _local5.PointPlaneDistance(_local4.CurrentState.Position);
if (_local6 > (_local4.BoundingSphere + JConfig.collToll)){
return;
};
var _local7:Array = new Array();
var _local9:Number = (_local4.Radius - _local6);
var _local10:JNumber3D = JNumber3D.sub(_local4.CurrentState.Position, JNumber3D.multiply(_local5.Normal, _local4.Radius));
_local8 = new CollPointInfo();
_local8.R0 = JNumber3D.sub(_local10, _local4.CurrentState.Position);
_local8.R1 = JNumber3D.sub(_local10, _local5.CurrentState.Position);
_local8.InitialPenetration = _local9;
_local7.push(_local8);
var _local11:CollisionInfo = new CollisionInfo();
_local11.ObjInfo = _arg1;
_local11.DirToBody = _local5.Normal;
_local11.PointInfo = _local7;
var _local12:MaterialProperties = new MaterialProperties();
_local12.Restitution = Math.sqrt((_local4.Material.Restitution * _local5.Material.Restitution));
_local12.StaticFriction = Math.sqrt((_local4.Material.StaticFriction * _local5.Material.StaticFriction));
_local12.DynamicFriction = Math.sqrt((_local4.Material.DynamicFriction * _local5.Material.DynamicFriction));
_local11.Mat = _local12;
_arg2.push(_local11);
_arg1.body0.Collisions.push(_local11);
_arg1.body1.Collisions.push(_local11);
}
}
}//package jiglib.collision
Section 69
//CollDetectSphereSphere (jiglib.collision.CollDetectSphereSphere)
package jiglib.collision {
import jiglib.math.*;
import jiglib.physics.*;
import jiglib.geometry.*;
import jiglib.cof.*;
public class CollDetectSphereSphere extends CollDetectFunctor {
public function CollDetectSphereSphere(){
Name = "SphereSphere";
Type0 = "SPHERE";
Type1 = "SPHERE";
}
override public function CollDetect(_arg1:CollDetectInfo, _arg2:Array):void{
var _local8:Number;
var _local9:JNumber3D;
var _local10:Array;
var _local11:CollPointInfo;
var _local12:CollisionInfo;
var _local13:MaterialProperties;
var _local3:JSphere = (_arg1.body0 as JSphere);
var _local4:JSphere = (_arg1.body1 as JSphere);
var _local5:JNumber3D = JNumber3D.sub(_local3.CurrentState.Position, _local4.CurrentState.Position);
var _local6:Number = _local5.modulo;
var _local7:Number = (_local3.Radius + _local4.Radius);
if (_local6 < (_local7 + JConfig.collToll)){
_local8 = (_local7 - _local6);
_local5.normalize();
_local9 = JNumber3D.add(_local4.CurrentState.Position, JNumber3D.multiply(_local5, (_local4.Radius - (0.5 * _local8))));
_local10 = new Array();
_local11 = new CollPointInfo();
_local11.R0 = JNumber3D.sub(_local9, _local3.CurrentState.Position);
_local11.R1 = JNumber3D.sub(_local9, _local4.CurrentState.Position);
_local11.InitialPenetration = _local8;
_local10.push(_local11);
_local12 = new CollisionInfo();
_local12.ObjInfo = _arg1;
_local12.DirToBody = _local5;
_local12.PointInfo = _local10;
_local13 = new MaterialProperties();
_local13.Restitution = Math.sqrt((_local3.Material.Restitution * _local4.Material.Restitution));
_local13.StaticFriction = Math.sqrt((_local3.Material.StaticFriction * _local4.Material.StaticFriction));
_local13.DynamicFriction = Math.sqrt((_local3.Material.DynamicFriction * _local4.Material.DynamicFriction));
_local12.Mat = _local13;
_arg2.push(_local12);
_arg1.body0.Collisions.push(_local12);
_arg1.body1.Collisions.push(_local12);
};
}
}
}//package jiglib.collision
Section 70
//CollisionInfo (jiglib.collision.CollisionInfo)
package jiglib.collision {
import jiglib.math.*;
import jiglib.physics.*;
public class CollisionInfo {
public var Mat:MaterialProperties;
public var Satisfied:Boolean;
public var ObjInfo:CollDetectInfo;
public var DirToBody:JNumber3D;
public var PointInfo:Array;
public function CollisionInfo(){
Mat = new MaterialProperties();
super();
}
}
}//package jiglib.collision
Section 71
//CollisionSystem (jiglib.collision.CollisionSystem)
package jiglib.collision {
import jiglib.math.*;
import jiglib.physics.*;
import jiglib.geometry.*;
public class CollisionSystem {
private var detectionFunctors:Array;
private var collBody:Array;
public function CollisionSystem(){
collBody = new Array();
detectionFunctors = new Array();
detectionFunctors["BOX"] = new Array();
detectionFunctors["BOX"]["BOX"] = new CollDetectBoxBox();
detectionFunctors["BOX"]["SPHERE"] = new CollDetectSphereBox();
detectionFunctors["BOX"]["PLANE"] = new CollDetectBoxPlane();
detectionFunctors["SPHERE"] = new Array();
detectionFunctors["SPHERE"]["BOX"] = new CollDetectSphereBox();
detectionFunctors["SPHERE"]["SPHERE"] = new CollDetectSphereSphere();
detectionFunctors["SPHERE"]["PLANE"] = new CollDetectSpherePlane();
detectionFunctors["PLANE"] = new Array();
detectionFunctors["PLANE"]["BOX"] = new CollDetectBoxPlane();
detectionFunctors["PLANE"]["SPHERE"] = new CollDetectSpherePlane();
}
public function RemoveCollisionBody(_arg1:RigidBody):void{
if (findBody(_arg1)){
collBody.splice(collBody.indexOf(_arg1), 1);
};
}
public function AddCollisionBody(_arg1:RigidBody):void{
if (!findBody(_arg1)){
collBody.push(_arg1);
};
}
public function DetectCollisions(_arg1:RigidBody, _arg2:Array):void{
var _local3:CollDetectInfo;
var _local4:CollDetectFunctor;
var _local5:String;
if (!_arg1.IsActive()){
return;
};
for (_local5 in collBody) {
if (((!((_arg1 == collBody[_local5]))) && (!((detectionFunctors[_arg1.Type][collBody[_local5].Type] == undefined))))){
_local3 = new CollDetectInfo();
_local3.body0 = _arg1;
_local3.body1 = collBody[_local5];
_local4 = detectionFunctors[_local3.body0.Type][_local3.body1.Type];
_local4.CollDetect(_local3, _arg2);
};
};
}
public function SegmentBounding(_arg1:JSegment, _arg2:RigidBody):Boolean{
var _local5:Number;
var _local6:Number;
var _local3:JNumber3D = _arg1.GetPoint(0.5);
var _local4:Number = (_arg1.Delta.modulo / 2);
if (_arg2.Type != "PLANE"){
_local5 = JNumber3D.sub(_local3, _arg2.CurrentState.Position).modulo;
_local6 = (_local4 + _arg2.BoundingSphere);
if (_local5 <= _local6){
return (true);
};
return (false);
//unresolved jump
};
return (true);
}
public function SegmentIntersect(_arg1:Object, _arg2:JSegment, _arg3:RigidBody):Boolean{
var _local5:String;
_arg1.fracOut = JNumber3D.NUM_HUGE;
_arg1.posOut = new JNumber3D();
_arg1.normalOut = new JNumber3D();
var _local4:Object = new Object();
for (_local5 in collBody) {
if (((!((collBody[_local5] == _arg3))) && (SegmentBounding(_arg2, collBody[_local5])))){
if (collBody[_local5].SegmentIntersect(_local4, _arg2)){
if (_local4.fracOut < _arg1.fracOut){
_arg1.posOut = _local4.posOut;
_arg1.normalOut = _local4.normalOut;
_arg1.fracOut = _local4.fracOut;
_arg1.bodyOut = collBody[_local5];
};
};
};
};
if (_arg1.fracOut > 1){
return (false);
};
if (_arg1.fracOut < 0){
_arg1.fracOut = 0;
} else {
if (_arg1.fracOut > 1){
_arg1.fracOut = 1;
};
};
return (true);
}
private function findBody(_arg1:RigidBody):Boolean{
var _local2:String;
for (_local2 in collBody) {
if (_arg1 == collBody[_local2]){
return (true);
};
};
return (false);
}
public function DetectAllCollisions(_arg1:Array, _arg2:Array):void{
var _local3:CollDetectInfo;
var _local4:CollDetectFunctor;
var _local5:String;
var _local6:String;
for (_local5 in _arg1) {
for (_local6 in collBody) {
if (_arg1[_local5] == collBody[_local6]){
} else {
if (((collBody[_local6].IsActive()) && ((_arg1[_local5].ID > collBody[_local6].ID)))){
} else {
if (detectionFunctors[_arg1[_local5].Type][collBody[_local6].Type] != undefined){
_local3 = new CollDetectInfo();
_local3.body0 = _arg1[_local5];
_local3.body1 = collBody[_local6];
_local4 = detectionFunctors[_local3.body0.Type][_local3.body1.Type];
_local4.CollDetect(_local3, _arg2);
};
};
};
};
};
}
}
}//package jiglib.collision
Section 72
//CollPointInfo (jiglib.collision.CollPointInfo)
package jiglib.collision {
import jiglib.math.*;
public class CollPointInfo {
public var MinSeparationVel:Number;// = 0
public var Denominator:Number;// = 0
public var InitialPenetration:Number;
public var Position:JNumber3D;
public var AccumulatedNormalImpulseAux:Number;// = 0
public var AccumulatedNormalImpulse:Number;// = 0
public var AccumulatedFrictionImpulse:JNumber3D;
public var R0:JNumber3D;
public var R1:JNumber3D;
public function CollPointInfo(){
AccumulatedFrictionImpulse = new JNumber3D();
super();
}
}
}//package jiglib.collision
Section 73
//JBox (jiglib.geometry.JBox)
package jiglib.geometry {
import org.papervision3d.objects.*;
import jiglib.math.*;
import jiglib.physics.*;
public class JBox extends RigidBody {
private var _points:Array;
private var _sideLengths:JNumber3D;
private var _edges:Array;
public function JBox(_arg1:DisplayObject3D, _arg2:Boolean=true, _arg3:Number=500, _arg4:Number=500, _arg5:Number=500){
_edges = new Array({ind0:0, ind1:1}, {ind0:3, ind1:1}, {ind0:2, ind1:3}, {ind0:2, ind1:0}, {ind0:4, ind1:5}, {ind0:5, ind1:7}, {ind0:6, ind1:7}, {ind0:4, ind1:6}, {ind0:7, ind1:1}, {ind0:5, ind1:3}, {ind0:4, ind1:2}, {ind0:6, ind1:0});
super(_arg1, _arg2);
_type = "BOX";
_sideLengths = new JNumber3D(_arg3, _arg5, _arg4);
_boundingSphere = (0.5 * _sideLengths.modulo);
initPoint();
this.setMass(1);
}
private function initPoint():void{
var _local1:JNumber3D = GetHalfSideLengths();
_points = new Array();
_points[0] = new JNumber3D(_local1.x, -(_local1.y), _local1.z);
_points[1] = new JNumber3D(_local1.x, _local1.y, _local1.z);
_points[2] = new JNumber3D(-(_local1.x), -(_local1.y), _local1.z);
_points[3] = new JNumber3D(-(_local1.x), _local1.y, _local1.z);
_points[4] = new JNumber3D(-(_local1.x), -(_local1.y), -(_local1.z));
_points[5] = new JNumber3D(-(_local1.x), _local1.y, -(_local1.z));
_points[6] = new JNumber3D(_local1.x, -(_local1.y), -(_local1.z));
_points[7] = new JNumber3D(_local1.x, _local1.y, -(_local1.z));
}
public function GetCornerPoints():Array{
var _local1:JNumber3D;
var _local3:String;
var _local2:Array = new Array();
for (_local3 in _points) {
_local1 = new JNumber3D(_points[_local3].x, _points[_local3].y, _points[_local3].z);
JMatrix3D.multiplyVector(getTransform(), _local1);
_local2.push(_local1);
};
return (_local2);
}
public function GetSpan(_arg1:JNumber3D):Object{
var _local2:Object = new Object();
var _local3:Number = (Math.abs(JNumber3D.dot(_arg1, CurrentState.Orientation.getCols()[0])) * (0.5 * SideLengths.x));
var _local4:Number = (Math.abs(JNumber3D.dot(_arg1, CurrentState.Orientation.getCols()[1])) * (0.5 * SideLengths.y));
var _local5:Number = (Math.abs(JNumber3D.dot(_arg1, CurrentState.Orientation.getCols()[2])) * (0.5 * SideLengths.z));
var _local6:Number = ((_local3 + _local4) + _local5);
var _local7:Number = JNumber3D.dot(CurrentState.Position, _arg1);
_local2.min = (_local7 - _local6);
_local2.max = (_local7 + _local6);
return (_local2);
}
public function GetDistanceToPoint(_arg1:Object, _arg2:JNumber3D):Number{
return (Math.sqrt(GetSqDistanceToPoint(_arg1, _arg2)));
}
public function GetSurfaceArea():Number{
return ((2 * (((SideLengths.x * SideLengths.y) + (SideLengths.x * SideLengths.z)) + (SideLengths.y * SideLengths.z))));
}
public function set SideLengths(_arg1:JNumber3D):void{
_sideLengths = _arg1.clone();
_boundingSphere = (0.5 * _sideLengths.modulo);
initPoint();
this.setMass(this.Mass);
this.SetActive();
}
public function GetHalfSideLengths():JNumber3D{
return (JNumber3D.multiply(_sideLengths, 0.5));
}
public function PointIntersect(_arg1:JNumber3D):Boolean{
var _local4:JNumber3D;
var _local5:int;
var _local2:JNumber3D = JNumber3D.sub(_arg1, CurrentState.Position);
var _local3:JNumber3D = JNumber3D.multiply(SideLengths, 0.5);
while (_local5 < 3) {
_local4 = CurrentState.Orientation.getCols()[_local5].clone();
_local4.normalize();
if (Math.abs(JNumber3D.dot(_local4, _local2)) > (_local3.toArray()[_local5] + JNumber3D.NUM_TINY)){
return (false);
};
_local5++;
};
return (true);
}
public function GetVolume():Number{
return (((SideLengths.x * SideLengths.y) * SideLengths.z));
}
public function get Edges():Array{
return (_edges);
}
override public function SegmentIntersect(_arg1:Object, _arg2:JSegment):Boolean{
var _local11:JNumber3D;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
_arg1.fracOut = 0;
_arg1.posOut = new JNumber3D();
_arg1.normalOut = new JNumber3D();
var _local3:Number = JNumber3D.NUM_HUGE;
var _local4:Number = -(JNumber3D.NUM_HUGE);
var _local5:Number = JNumber3D.NUM_HUGE;
var _local6:Number = 0;
var _local7:Number = 0;
var _local8:Number = 0;
var _local9:JNumber3D = JNumber3D.sub(CurrentState.Position, _arg2.Origin);
var _local10:JNumber3D = JNumber3D.multiply(SideLengths, 0.5);
_local8 = 0;
while (_local8 < 3) {
_local12 = JNumber3D.dot(CurrentState.Orientation.getCols()[_local8], _local9);
_local13 = JNumber3D.dot(CurrentState.Orientation.getCols()[_local8], _arg2.Delta);
if (Math.abs(_local13) > JNumber3D.NUM_TINY){
_local15 = ((_local12 + _local10.toArray()[_local8]) / _local13);
_local16 = ((_local12 - _local10.toArray()[_local8]) / _local13);
if (_local15 > _local16){
_local14 = _local15;
_local15 = _local16;
_local16 = _local14;
};
if (_local15 > _local4){
_local4 = _local15;
_local6 = _local8;
};
if (_local16 < _local5){
_local5 = _local16;
_local7 = _local8;
};
if (_local4 > _local5){
return (false);
};
if (_local5 < 0){
return (false);
};
} else {
if (((((-(_local12) - _local10.toArray()[_local8]) > 0)) || (((-(_local12) + _local10.toArray()[_local8]) < 0)))){
return (false);
};
};
_local8++;
};
if (_local4 > 0){
_local8 = _local6;
_local3 = _local4;
} else {
_local8 = _local7;
_local3 = _local5;
};
if (_local3 < 0){
_local3 = 0;
};
if (_local3 > 1){
_local3 = 1;
};
if (_local3 > 0.999999){
return (false);
};
_arg1.fracOut = _local3;
_arg1.posOut = _arg2.GetPoint(_local3);
if (JNumber3D.dot(CurrentState.Orientation.getCols()[_local8], _arg2.Delta) < 0){
_arg1.normalOut = JNumber3D.multiply(CurrentState.Orientation.getCols()[_local8], -1);
} else {
_arg1.normalOut = CurrentState.Orientation.getCols()[_local8];
};
return (true);
}
override public function GetInertiaProperties(_arg1:Number):JMatrix3D{
var _local2:JMatrix3D = new JMatrix3D();
_local2.n11 = ((_arg1 / 12) * ((SideLengths.y * SideLengths.y) + (SideLengths.z * SideLengths.z)));
_local2.n22 = ((_arg1 / 12) * ((SideLengths.x * SideLengths.x) + (SideLengths.z * SideLengths.z)));
_local2.n33 = ((_arg1 / 12) * ((SideLengths.x * SideLengths.x) + (SideLengths.y * SideLengths.y)));
return (_local2);
}
public function GetSqDistanceToPoint(_arg1:Object, _arg2:JNumber3D):Number{
_arg1.pos = JNumber3D.sub(_arg2, CurrentState.Position);
JMatrix3D.multiplyVector(JMatrix3D.Transpose(CurrentState.Orientation), _arg1.pos);
var _local3:Number = 0;
var _local4:Number = 0;
var _local5:JNumber3D = GetHalfSideLengths();
if (_arg1.pos.x < -(_local5.x)){
_local3 = (_arg1.pos.x + _local5.x);
_local4 = (_local4 + (_local3 * _local3));
_arg1.pos.x = -(_local5.x);
} else {
if (_arg1.pos.x > _local5.x){
_local3 = (_arg1.pos.x - _local5.x);
_local4 = (_local4 + (_local3 * _local3));
_arg1.pos.x = _local5.x;
};
};
if (_arg1.pos.y < -(_local5.y)){
_local3 = (_arg1.pos.y + _local5.y);
_local4 = (_local4 + (_local3 * _local3));
_arg1.pos.y = -(_local5.y);
} else {
if (_arg1.pos.y > _local5.y){
_local3 = (_arg1.pos.y - _local5.y);
_local4 = (_local4 + (_local3 * _local3));
_arg1.pos.y = _local5.y;
};
};
if (_arg1.pos.z < -(_local5.z)){
_local3 = (_arg1.pos.z + _local5.z);
_local4 = (_local4 + (_local3 * _local3));
_arg1.pos.z = -(_local5.z);
} else {
if (_arg1.pos.z > _local5.z){
_local3 = (_arg1.pos.z - _local5.z);
_local4 = (_local4 + (_local3 * _local3));
_arg1.pos.z = _local5.z;
};
};
JMatrix3D.multiplyVector(CurrentState.Orientation, _arg1.pos);
_arg1.pos = JNumber3D.add(CurrentState.Position, _arg1.pos);
return (_local4);
}
public function get SideLengths():JNumber3D{
return (_sideLengths);
}
}
}//package jiglib.geometry
Section 74
//JPlane (jiglib.geometry.JPlane)
package jiglib.geometry {
import org.papervision3d.objects.*;
import jiglib.math.*;
import jiglib.physics.*;
public class JPlane extends RigidBody {
private var _distance:Number;
private var _normal:JNumber3D;
public function JPlane(_arg1:DisplayObject3D){
super(_arg1, false);
_type = "PLANE";
_normal = new JNumber3D(0, 0, -1);
_distance = 0;
}
public function PointPlaneDistance(_arg1:JNumber3D):Number{
return ((JNumber3D.dot(_normal, _arg1) - _distance));
}
public function get Distance():Number{
return (_distance);
}
public function get Normal():JNumber3D{
return (_normal);
}
override public function SegmentIntersect(_arg1:Object, _arg2:JSegment):Boolean{
var _local4:Number;
_arg1.fracOut = 0;
_arg1.posOut = new JNumber3D();
_arg1.normalOut = new JNumber3D();
var _local3:Number = 0;
var _local5:Number = JNumber3D.dot(_normal, _arg2.Delta);
if (Math.abs(_local5) > JNumber3D.NUM_TINY){
_local4 = ((-1 * (JNumber3D.dot(_normal, _arg2.Origin) - _distance)) / _local5);
if ((((_local4 < 0)) || ((_local4 > 1)))){
return (false);
};
_local3 = _local4;
_arg1.fracOut = _local3;
_arg1.posOut = _arg2.GetPoint(_local3);
_arg1.normalOut = _normal.clone();
return (true);
//unresolved jump
};
return (false);
}
override public function MoveTo(_arg1:JNumber3D, _arg2:JMatrix3D):void{
_arg1.copyTo(CurrentState.Position);
SetOrientation(_arg2);
CurrentState.LinVelocity = JNumber3D.ZERO;
CurrentState.RotVelocity = JNumber3D.ZERO;
CopyCurrentStateToOld();
_normal = new JNumber3D(0, 0, -1);
JMatrix3D.multiplyVector(_arg2, _normal);
_distance = JNumber3D.dot(_arg1, _normal);
}
}
}//package jiglib.geometry
Section 75
//JSegment (jiglib.geometry.JSegment)
package jiglib.geometry {
import jiglib.math.*;
public class JSegment {
private var _origin:JNumber3D;
private var _delta:JNumber3D;
public function JSegment(_arg1:JNumber3D, _arg2:JNumber3D){
_origin = _arg1;
_delta = _arg2;
}
public function set Delta(_arg1:JNumber3D):void{
_delta = _arg1;
}
public function GetPoint(_arg1:Number):JNumber3D{
return (JNumber3D.add(_origin, JNumber3D.multiply(_delta, _arg1)));
}
public function GetEnd():JNumber3D{
return (JNumber3D.add(_origin, _delta));
}
public function get Origin():JNumber3D{
return (_origin);
}
public function get Delta():JNumber3D{
return (_delta);
}
public function set Origin(_arg1:JNumber3D):void{
_origin = _arg1;
}
public function clone():JSegment{
return (new JSegment(_origin, _delta));
}
}
}//package jiglib.geometry
Section 76
//JSphere (jiglib.geometry.JSphere)
package jiglib.geometry {
import org.papervision3d.objects.*;
import jiglib.math.*;
import jiglib.physics.*;
public class JSphere extends RigidBody {
private var _radius:Number;
public function JSphere(_arg1:DisplayObject3D, _arg2:Boolean=true, _arg3:Number=100){
super(_arg1, _arg2);
_type = "SPHERE";
_radius = _arg3;
_boundingSphere = _radius;
this.setMass(1);
}
public function set Radius(_arg1:Number):void{
_radius = _arg1;
_boundingSphere = _radius;
this.setMass(this.Mass);
this.SetActive();
}
override public function GetInertiaProperties(_arg1:Number):JMatrix3D{
var _local2:JMatrix3D = new JMatrix3D();
var _local3:Number = (((0.4 * _arg1) * _radius) * _radius);
_local2.n11 = _local3;
_local2.n22 = _local3;
_local2.n33 = _local3;
return (_local2);
}
public function get Radius():Number{
return (_radius);
}
override public function SegmentIntersect(_arg1:Object, _arg2:JSegment):Boolean{
_arg1.fracOut = 0;
_arg1.posOut = new JNumber3D();
_arg1.normalOut = new JNumber3D();
var _local3:Number = 0;
var _local4:JNumber3D = _arg2.Delta;
var _local5:JNumber3D = JNumber3D.sub(_arg2.Origin, CurrentState.Position);
var _local6:Number = (_radius * _radius);
var _local7:Number = _local4.modulo2;
if (_local7 < _local6){
_arg1.fracOut = 0;
_arg1.posOut = _arg2.Origin.clone();
_arg1.normalOut = JNumber3D.sub(_arg1.posOut, CurrentState.Position);
return (true);
};
var _local8:Number = JNumber3D.dot(_local5, _local4);
var _local9:Number = _local5.modulo2;
var _local10:Number = ((_local8 * _local8) - (_local7 * (_local9 - _local6)));
if (_local10 < 0){
return (false);
};
var _local11:Number = Math.sqrt(_local10);
var _local12:Number = ((-(_local8) - _local11) / _local7);
var _local13:Number = ((-(_local8) + _local11) / _local7);
if ((((_local12 > 1)) || ((_local13 < 0)))){
return (false);
};
_local3 = Math.max(_local12, 0);
_arg1.fracOut = _local3;
_arg1.posOut = _arg2.GetPoint(_local3);
_arg1.normalOut = JNumber3D.sub(_arg1.posOut, CurrentState.Position);
return (true);
}
}
}//package jiglib.geometry
Section 77
//JMatrix3D (jiglib.math.JMatrix3D)
package jiglib.math {
public class JMatrix3D {
public var n31:Number;
public var n32:Number;
public var n11:Number;
public var n34:Number;
public var n13:Number;
public var n14:Number;
public var n33:Number;
public var n12:Number;
public var sid:String;
public var n41:Number;
public var n42:Number;
public var n21:Number;
public var n22:Number;
public var n23:Number;
public var n24:Number;
public var n44:Number;
public var type:String;// = ""
public var n43:Number;
private static var _cos:Function = Math.cos;
private static var _sin:Function = Math.sin;
private static var toDEGREES:Number = 57.2957795130823;
private static var toRADIANS:Number = 0.0174532925199433;
public function JMatrix3D(_arg1:Array=null){
if (((!(_arg1)) || ((_arg1.length < 12)))){
n11 = (n22 = (n33 = (n44 = 1)));
n12 = (n13 = (n14 = (n21 = (n23 = (n24 = (n31 = (n32 = (n34 = (n41 = (n42 = (n43 = 0)))))))))));
} else {
n11 = _arg1[0];
n12 = _arg1[1];
n13 = _arg1[2];
n14 = _arg1[3];
n21 = _arg1[4];
n22 = _arg1[5];
n23 = _arg1[6];
n24 = _arg1[7];
n31 = _arg1[8];
n32 = _arg1[9];
n33 = _arg1[10];
n34 = _arg1[11];
if (_arg1.length == 16){
n41 = _arg1[12];
n42 = _arg1[13];
n43 = _arg1[14];
n44 = _arg1[15];
};
};
}
public function calculateSub(_arg1:JMatrix3D, _arg2:JMatrix3D):void{
this.n11 = (_arg1.n11 - _arg2.n11);
this.n12 = (_arg1.n12 - _arg2.n12);
this.n13 = (_arg1.n13 - _arg2.n13);
this.n14 = (_arg1.n14 - _arg2.n14);
this.n21 = (_arg1.n21 - _arg2.n21);
this.n22 = (_arg1.n22 - _arg2.n22);
this.n23 = (_arg1.n23 - _arg2.n23);
this.n24 = (_arg1.n24 - _arg2.n24);
this.n31 = (_arg1.n31 - _arg2.n31);
this.n32 = (_arg1.n32 - _arg2.n32);
this.n33 = (_arg1.n33 - _arg2.n33);
this.n34 = (_arg1.n34 - _arg2.n34);
}
public function toString():String{
var _local1 = "";
_local1 = (_local1 + ((((((((int((n11 * 1000)) / 1000) + "\t\t") + (int((n12 * 1000)) / 1000)) + "\t\t") + (int((n13 * 1000)) / 1000)) + "\t\t") + (int((n14 * 1000)) / 1000)) + "\n"));
_local1 = (_local1 + ((((((((int((n21 * 1000)) / 1000) + "\t\t") + (int((n22 * 1000)) / 1000)) + "\t\t") + (int((n23 * 1000)) / 1000)) + "\t\t") + (int((n24 * 1000)) / 1000)) + "\n"));
_local1 = (_local1 + ((((((((int((n31 * 1000)) / 1000) + "\t\t") + (int((n32 * 1000)) / 1000)) + "\t\t") + (int((n33 * 1000)) / 1000)) + "\t\t") + (int((n34 * 1000)) / 1000)) + "\n"));
_local1 = (_local1 + ((((((((int((n41 * 1000)) / 1000) + "\t\t") + (int((n42 * 1000)) / 1000)) + "\t\t") + (int((n43 * 1000)) / 1000)) + "\t\t") + (int((n44 * 1000)) / 1000)) + "\n"));
return (_local1);
}
public function get trace():Number{
return ((((this.n11 + this.n22) + this.n33) + 1));
}
public function calculateMultiply4x4(_arg1:JMatrix3D, _arg2:JMatrix3D):void{
var _local3:Number = _arg1.n11;
var _local4:Number = _arg2.n11;
var _local5:Number = _arg1.n21;
var _local6:Number = _arg2.n21;
var _local7:Number = _arg1.n31;
var _local8:Number = _arg2.n31;
var _local9:Number = _arg1.n41;
var _local10:Number = _arg2.n41;
var _local11:Number = _arg1.n12;
var _local12:Number = _arg2.n12;
var _local13:Number = _arg1.n22;
var _local14:Number = _arg2.n22;
var _local15:Number = _arg1.n32;
var _local16:Number = _arg2.n32;
var _local17:Number = _arg1.n42;
var _local18:Number = _arg2.n42;
var _local19:Number = _arg1.n13;
var _local20:Number = _arg2.n13;
var _local21:Number = _arg1.n23;
var _local22:Number = _arg2.n23;
var _local23:Number = _arg1.n33;
var _local24:Number = _arg2.n33;
var _local25:Number = _arg1.n43;
var _local26:Number = _arg2.n43;
var _local27:Number = _arg1.n14;
var _local28:Number = _arg2.n14;
var _local29:Number = _arg1.n24;
var _local30:Number = _arg2.n24;
var _local31:Number = _arg1.n34;
var _local32:Number = _arg2.n34;
var _local33:Number = _arg1.n44;
var _local34:Number = _arg2.n44;
this.n11 = (((_local3 * _local4) + (_local11 * _local6)) + (_local19 * _local8));
this.n12 = (((_local3 * _local12) + (_local11 * _local14)) + (_local19 * _local16));
this.n13 = (((_local3 * _local20) + (_local11 * _local22)) + (_local19 * _local24));
this.n14 = ((((_local3 * _local28) + (_local11 * _local30)) + (_local19 * _local32)) + _local27);
this.n21 = (((_local5 * _local4) + (_local13 * _local6)) + (_local21 * _local8));
this.n22 = (((_local5 * _local12) + (_local13 * _local14)) + (_local21 * _local16));
this.n23 = (((_local5 * _local20) + (_local13 * _local22)) + (_local21 * _local24));
this.n24 = ((((_local5 * _local28) + (_local13 * _local30)) + (_local21 * _local32)) + _local29);
this.n31 = (((_local7 * _local4) + (_local15 * _local6)) + (_local23 * _local8));
this.n32 = (((_local7 * _local12) + (_local15 * _local14)) + (_local23 * _local16));
this.n33 = (((_local7 * _local20) + (_local15 * _local22)) + (_local23 * _local24));
this.n34 = ((((_local7 * _local28) + (_local15 * _local30)) + (_local23 * _local32)) + _local31);
this.n41 = (((_local9 * _local4) + (_local17 * _local6)) + (_local25 * _local8));
this.n42 = (((_local9 * _local12) + (_local17 * _local14)) + (_local25 * _local16));
this.n43 = (((_local9 * _local20) + (_local17 * _local22)) + (_local25 * _local24));
this.n44 = ((((_local9 * _local28) + (_local17 * _local30)) + (_local25 * _local32)) + _local33);
}
public function calculateMultiply3x3(_arg1:JMatrix3D, _arg2:JMatrix3D):void{
var _local3:Number = _arg1.n11;
var _local4:Number = _arg2.n11;
var _local5:Number = _arg1.n21;
var _local6:Number = _arg2.n21;
var _local7:Number = _arg1.n31;
var _local8:Number = _arg2.n31;
var _local9:Number = _arg1.n12;
var _local10:Number = _arg2.n12;
var _local11:Number = _arg1.n22;
var _local12:Number = _arg2.n22;
var _local13:Number = _arg1.n32;
var _local14:Number = _arg2.n32;
var _local15:Number = _arg1.n13;
var _local16:Number = _arg2.n13;
var _local17:Number = _arg1.n23;
var _local18:Number = _arg2.n23;
var _local19:Number = _arg1.n33;
var _local20:Number = _arg2.n33;
this.n11 = (((_local3 * _local4) + (_local9 * _local6)) + (_local15 * _local8));
this.n12 = (((_local3 * _local10) + (_local9 * _local12)) + (_local15 * _local14));
this.n13 = (((_local3 * _local16) + (_local9 * _local18)) + (_local15 * _local20));
this.n21 = (((_local5 * _local4) + (_local11 * _local6)) + (_local17 * _local8));
this.n22 = (((_local5 * _local10) + (_local11 * _local12)) + (_local17 * _local14));
this.n23 = (((_local5 * _local16) + (_local11 * _local18)) + (_local17 * _local20));
this.n31 = (((_local7 * _local4) + (_local13 * _local6)) + (_local19 * _local8));
this.n32 = (((_local7 * _local10) + (_local13 * _local12)) + (_local19 * _local14));
this.n33 = (((_local7 * _local16) + (_local13 * _local18)) + (_local19 * _local20));
}
public function get det():Number{
return ((((((this.n11 * this.n22) - (this.n21 * this.n12)) * this.n33) - (((this.n11 * this.n32) - (this.n31 * this.n12)) * this.n23)) + (((this.n21 * this.n32) - (this.n31 * this.n22)) * this.n13)));
}
public function copy(_arg1:JMatrix3D):JMatrix3D{
this.n11 = _arg1.n11;
this.n12 = _arg1.n12;
this.n13 = _arg1.n13;
this.n14 = _arg1.n14;
this.n21 = _arg1.n21;
this.n22 = _arg1.n22;
this.n23 = _arg1.n23;
this.n24 = _arg1.n24;
this.n31 = _arg1.n31;
this.n32 = _arg1.n32;
this.n33 = _arg1.n33;
this.n34 = _arg1.n34;
return (this);
}
public function copy3x3(_arg1:JMatrix3D):JMatrix3D{
this.n11 = _arg1.n11;
this.n12 = _arg1.n12;
this.n13 = _arg1.n13;
this.n21 = _arg1.n21;
this.n22 = _arg1.n22;
this.n23 = _arg1.n23;
this.n31 = _arg1.n31;
this.n32 = _arg1.n32;
this.n33 = _arg1.n33;
return (this);
}
public function calculateAdd(_arg1:JMatrix3D, _arg2:JMatrix3D):void{
this.n11 = (_arg1.n11 + _arg2.n11);
this.n12 = (_arg1.n12 + _arg2.n12);
this.n13 = (_arg1.n13 + _arg2.n13);
this.n14 = (_arg1.n14 + _arg2.n14);
this.n21 = (_arg1.n21 + _arg2.n21);
this.n22 = (_arg1.n22 + _arg2.n22);
this.n23 = (_arg1.n23 + _arg2.n23);
this.n24 = (_arg1.n24 + _arg2.n24);
this.n31 = (_arg1.n31 + _arg2.n31);
this.n32 = (_arg1.n32 + _arg2.n32);
this.n33 = (_arg1.n33 + _arg2.n33);
this.n34 = (_arg1.n34 + _arg2.n34);
}
public function calculateMultiply(_arg1:JMatrix3D, _arg2:JMatrix3D):void{
var _local3:Number = _arg1.n11;
var _local4:Number = _arg2.n11;
var _local5:Number = _arg1.n21;
var _local6:Number = _arg2.n21;
var _local7:Number = _arg1.n31;
var _local8:Number = _arg2.n31;
var _local9:Number = _arg1.n12;
var _local10:Number = _arg2.n12;
var _local11:Number = _arg1.n22;
var _local12:Number = _arg2.n22;
var _local13:Number = _arg1.n32;
var _local14:Number = _arg2.n32;
var _local15:Number = _arg1.n13;
var _local16:Number = _arg2.n13;
var _local17:Number = _arg1.n23;
var _local18:Number = _arg2.n23;
var _local19:Number = _arg1.n33;
var _local20:Number = _arg2.n33;
var _local21:Number = _arg1.n14;
var _local22:Number = _arg2.n14;
var _local23:Number = _arg1.n24;
var _local24:Number = _arg2.n24;
var _local25:Number = _arg1.n34;
var _local26:Number = _arg2.n34;
this.n11 = (((_local3 * _local4) + (_local9 * _local6)) + (_local15 * _local8));
this.n12 = (((_local3 * _local10) + (_local9 * _local12)) + (_local15 * _local14));
this.n13 = (((_local3 * _local16) + (_local9 * _local18)) + (_local15 * _local20));
this.n14 = ((((_local3 * _local22) + (_local9 * _local24)) + (_local15 * _local26)) + _local21);
this.n21 = (((_local5 * _local4) + (_local11 * _local6)) + (_local17 * _local8));
this.n22 = (((_local5 * _local10) + (_local11 * _local12)) + (_local17 * _local14));
this.n23 = (((_local5 * _local16) + (_local11 * _local18)) + (_local17 * _local20));
this.n24 = ((((_local5 * _local22) + (_local11 * _local24)) + (_local17 * _local26)) + _local23);
this.n31 = (((_local7 * _local4) + (_local13 * _local6)) + (_local19 * _local8));
this.n32 = (((_local7 * _local10) + (_local13 * _local12)) + (_local19 * _local14));
this.n33 = (((_local7 * _local16) + (_local13 * _local18)) + (_local19 * _local20));
this.n34 = ((((_local7 * _local22) + (_local13 * _local24)) + (_local19 * _local26)) + _local25);
}
public function calculateInverse(_arg1:JMatrix3D):void{
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local2:Number = _arg1.det;
if (Math.abs(_local2) > 0.001){
_local2 = (1 / _local2);
_local3 = _arg1.n11;
_local4 = _arg1.n21;
_local5 = _arg1.n31;
_local6 = _arg1.n12;
_local7 = _arg1.n22;
_local8 = _arg1.n32;
_local9 = _arg1.n13;
_local10 = _arg1.n23;
_local11 = _arg1.n33;
_local12 = _arg1.n14;
_local13 = _arg1.n24;
_local14 = _arg1.n34;
this.n11 = (_local2 * ((_local7 * _local11) - (_local8 * _local10)));
this.n12 = (-(_local2) * ((_local6 * _local11) - (_local8 * _local9)));
this.n13 = (_local2 * ((_local6 * _local10) - (_local7 * _local9)));
this.n14 = (-(_local2) * (((_local6 * ((_local10 * _local14) - (_local11 * _local13))) - (_local7 * ((_local9 * _local14) - (_local11 * _local12)))) + (_local8 * ((_local9 * _local13) - (_local10 * _local12)))));
this.n21 = (-(_local2) * ((_local4 * _local11) - (_local5 * _local10)));
this.n22 = (_local2 * ((_local3 * _local11) - (_local5 * _local9)));
this.n23 = (-(_local2) * ((_local3 * _local10) - (_local4 * _local9)));
this.n24 = (_local2 * (((_local3 * ((_local10 * _local14) - (_local11 * _local13))) - (_local4 * ((_local9 * _local14) - (_local11 * _local12)))) + (_local5 * ((_local9 * _local13) - (_local10 * _local12)))));
this.n31 = (_local2 * ((_local4 * _local8) - (_local5 * _local7)));
this.n32 = (-(_local2) * ((_local3 * _local8) - (_local5 * _local6)));
this.n33 = (_local2 * ((_local3 * _local7) - (_local4 * _local6)));
this.n34 = (-(_local2) * (((_local3 * ((_local7 * _local14) - (_local8 * _local13))) - (_local4 * ((_local6 * _local14) - (_local8 * _local12)))) + (_local5 * ((_local6 * _local13) - (_local7 * _local12)))));
};
}
public function getCols():Array{
var _local1:Array = new Array();
_local1[0] = new JNumber3D(n11, n21, n31);
_local1[1] = new JNumber3D(n12, n22, n32);
_local1[2] = new JNumber3D(n13, n23, n33);
return (_local1);
}
public static function sub(_arg1:JMatrix3D, _arg2:JMatrix3D):JMatrix3D{
var _local3:JMatrix3D = new (JMatrix3D);
_local3.calculateSub(_arg1, _arg2);
return (_local3);
}
public static function rotationMatrixWithReference(_arg1:JNumber3D, _arg2:Number, _arg3:JNumber3D):JMatrix3D{
var _local4:JMatrix3D = _slot1.translationMatrix(_arg3.x, -(_arg3.y), _arg3.z);
_slot1.translationMatrix(_arg3.x, -(_arg3.y), _arg3.z).calculateMultiply(_local4, _slot1.rotationMatrix(_arg1.x, _arg1.y, _arg1.z, _arg2));
_local4.calculateMultiply(_local4, _slot1.translationMatrix(-(_arg3.x), _arg3.y, -(_arg3.z)));
return (_local4);
}
public static function multiplyVector3x3(_arg1:JMatrix3D, _arg2:JNumber3D):void{
var _local3:Number = _arg2.x;
var _local4:Number = _arg2.y;
var _local5:Number = _arg2.z;
_arg2.x = (((_local3 * _arg1.n11) + (_local4 * _arg1.n12)) + (_local5 * _arg1.n13));
_arg2.y = (((_local3 * _arg1.n21) + (_local4 * _arg1.n22)) + (_local5 * _arg1.n23));
_arg2.z = (((_local3 * _arg1.n31) + (_local4 * _arg1.n32)) + (_local5 * _arg1.n33));
}
public static function multiply3x3(_arg1:JMatrix3D, _arg2:JMatrix3D):JMatrix3D{
var _local3:JMatrix3D = new (JMatrix3D);
_local3.calculateMultiply3x3(_arg1, _arg2);
return (_local3);
}
public static function normalizeQuaternion(_arg1:Object):Object{
var _local2:Number = magnitudeQuaternion(_arg1);
_arg1.x = (_arg1.x / _local2);
_arg1.y = (_arg1.y / _local2);
_arg1.z = (_arg1.z / _local2);
_arg1.w = (_arg1.w / _local2);
return (_arg1);
}
public static function multiplyVector(_arg1:JMatrix3D, _arg2:JNumber3D):void{
var _local3:Number = _arg2.x;
var _local4:Number = _arg2.y;
var _local5:Number = _arg2.z;
_arg2.x = ((((_local3 * _arg1.n11) + (_local4 * _arg1.n12)) + (_local5 * _arg1.n13)) + _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 = Math.sin((_arg4 / 2));
var _local6:Number = Math.cos((_arg4 / 2));
var _local7:Object = new Object();
_local7.x = (_arg1 * _local5);
_local7.y = (_arg2 * _local5);
_local7.z = (_arg3 * _local5);
_local7.w = _local6;
return (normalizeQuaternion(_local7));
}
public static function translationMatrix(_arg1:Number, _arg2:Number, _arg3:Number):JMatrix3D{
var _local4:JMatrix3D = IDENTITY;
_local4.n14 = _arg1;
_local4.n24 = _arg2;
_local4.n34 = _arg3;
return (_local4);
}
public static function magnitudeQuaternion(_arg1:Object):Number{
return (Math.sqrt(((((_arg1.w * _arg1.w) + (_arg1.x * _arg1.x)) + (_arg1.y * _arg1.y)) + (_arg1.z * _arg1.z))));
}
public static function euler2quaternion(_arg1:Number, _arg2:Number, _arg3:Number):Object{
var _local4:Number = Math.sin((_arg1 * 0.5));
var _local5:Number = Math.cos((_arg1 * 0.5));
var _local6:Number = Math.sin((_arg2 * 0.5));
var _local7:Number = Math.cos((_arg2 * 0.5));
var _local8:Number = Math.sin((_arg3 * 0.5));
var _local9:Number = Math.cos((_arg3 * 0.5));
var _local10:Number = (_local5 * _local7);
var _local11:Number = (_local4 * _local6);
var _local12:Object = new Object();
_local12.x = ((_local8 * _local10) - (_local9 * _local11));
_local12.y = (((_local9 * _local4) * _local7) + ((_local8 * _local5) * _local6));
_local12.z = (((_local9 * _local5) * _local6) - ((_local8 * _local4) * _local7));
_local12.w = ((_local9 * _local10) + (_local8 * _local11));
return (_local12);
}
public static function rotationX(_arg1:Number):JMatrix3D{
var _local2:JMatrix3D = IDENTITY;
var _local3:Number = Math.cos(_arg1);
var _local4:Number = Math.sin(_arg1);
_local2.n22 = _local3;
_local2.n23 = -(_local4);
_local2.n32 = _local4;
_local2.n33 = _local3;
return (_local2);
}
public static function rotationY(_arg1:Number):JMatrix3D{
var _local2:JMatrix3D = IDENTITY;
var _local3:Number = Math.cos(_arg1);
var _local4:Number = Math.sin(_arg1);
_local2.n11 = _local3;
_local2.n13 = -(_local4);
_local2.n31 = _local4;
_local2.n33 = _local3;
return (_local2);
}
public static function rotationZ(_arg1:Number):JMatrix3D{
var _local2:JMatrix3D = IDENTITY;
var _local3:Number = Math.cos(_arg1);
var _local4:Number = Math.sin(_arg1);
_local2.n11 = _local3;
_local2.n12 = -(_local4);
_local2.n21 = _local4;
_local2.n22 = _local3;
return (_local2);
}
public static function clone(_arg1:JMatrix3D):JMatrix3D{
return (new JMatrix3D([_arg1.n11, _arg1.n12, _arg1.n13, _arg1.n14, _arg1.n21, _arg1.n22, _arg1.n23, _arg1.n24, _arg1.n31, _arg1.n32, _arg1.n33, _arg1.n34]));
}
public static function rotationMatrix(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):JMatrix3D{
var _local5:JMatrix3D = IDENTITY;
var _local6:Number = Math.cos(_arg4);
var _local7:Number = Math.sin(_arg4);
var _local8:Number = (1 - _local6);
var _local9:Number = ((_arg1 * _arg2) * _local8);
var _local10:Number = ((_arg2 * _arg3) * _local8);
var _local11:Number = ((_arg1 * _arg3) * _local8);
var _local12:Number = (_local7 * _arg3);
var _local13:Number = (_local7 * _arg2);
var _local14:Number = (_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 Transpose(_arg1:JMatrix3D):JMatrix3D{
var _local2:JMatrix3D = new (JMatrix3D);
_local2.n11 = _arg1.n11;
_local2.n12 = _arg1.n21;
_local2.n13 = _arg1.n31;
_local2.n14 = _arg1.n41;
_local2.n21 = _arg1.n12;
_local2.n22 = _arg1.n22;
_local2.n23 = _arg1.n32;
_local2.n24 = _arg1.n42;
_local2.n31 = _arg1.n13;
_local2.n32 = _arg1.n23;
_local2.n33 = _arg1.n33;
_local2.n34 = _arg1.n43;
_local2.n41 = _arg1.n14;
_local2.n42 = _arg1.n24;
_local2.n43 = _arg1.n34;
_local2.n44 = _arg1.n44;
return (_local2);
}
public static function add(_arg1:JMatrix3D, _arg2:JMatrix3D):JMatrix3D{
var _local3:JMatrix3D = new (JMatrix3D);
_local3.calculateAdd(_arg1, _arg2);
return (_local3);
}
public static function rotateAxis(_arg1:JMatrix3D, _arg2:JNumber3D):void{
var _local3:Number = _arg2.x;
var _local4:Number = _arg2.y;
var _local5:Number = _arg2.z;
_arg2.x = (((_local3 * _arg1.n11) + (_local4 * _arg1.n12)) + (_local5 * _arg1.n13));
_arg2.y = (((_local3 * _arg1.n21) + (_local4 * _arg1.n22)) + (_local5 * _arg1.n23));
_arg2.z = (((_local3 * _arg1.n31) + (_local4 * _arg1.n32)) + (_local5 * _arg1.n33));
_arg2.normalize();
}
public static function multiply(_arg1:JMatrix3D, _arg2:JMatrix3D):JMatrix3D{
var _local3:JMatrix3D = new (JMatrix3D);
_local3.calculateMultiply(_arg1, _arg2);
return (_local3);
}
public static function multiplyQuaternion(_arg1:Object, _arg2:Object):Object{
var _local3:Number = _arg1.x;
var _local4:Number = _arg1.y;
var _local5:Number = _arg1.z;
var _local6:Number = _arg1.w;
var _local7:Number = _arg2.x;
var _local8:Number = _arg2.y;
var _local9:Number = _arg2.z;
var _local10:Number = _arg2.w;
var _local11:Object = new Object();
_local11.x = ((((_local6 * _local7) + (_local3 * _local10)) + (_local4 * _local9)) - (_local5 * _local8));
_local11.y = ((((_local6 * _local8) + (_local4 * _local10)) + (_local5 * _local7)) - (_local3 * _local9));
_local11.z = ((((_local6 * _local9) + (_local5 * _local10)) + (_local3 * _local8)) - (_local4 * _local7));
_local11.w = ((((_local6 * _local10) - (_local3 * _local7)) - (_local4 * _local8)) - (_local5 * _local9));
return (_local11);
}
public static function euler2matrix(_arg1:JNumber3D):JMatrix3D{
var _local2:JMatrix3D = IDENTITY;
var _local3:Number = (_arg1.x * toRADIANS);
var _local4:Number = (_arg1.y * toRADIANS);
var _local5:Number = (_arg1.z * toRADIANS);
var _local6:Number = Math.cos(_local3);
var _local7:Number = Math.sin(_local3);
var _local8:Number = Math.cos(_local4);
var _local9:Number = Math.sin(_local4);
var _local10:Number = Math.cos(_local5);
var _local11:Number = Math.sin(_local5);
var _local12:Number = (_local6 * _local9);
var _local13:Number = (_local7 * _local9);
_local2.n11 = (_local8 * _local10);
_local2.n12 = (-(_local8) * _local11);
_local2.n13 = _local9;
_local2.n21 = ((_local13 * _local10) + (_local6 * _local11));
_local2.n22 = ((-(_local13) * _local11) + (_local6 * _local10));
_local2.n23 = (-(_local7) * _local8);
_local2.n31 = ((-(_local12) * _local10) + (_local7 * _local11));
_local2.n32 = ((_local12 * _local11) + (_local7 * _local10));
_local2.n33 = (_local6 * _local8);
return (_local2);
}
public static function scaleMatrix(_arg1:Number, _arg2:Number, _arg3:Number):JMatrix3D{
var _local4:JMatrix3D = IDENTITY;
_local4.n11 = _arg1;
_local4.n22 = _arg2;
_local4.n33 = _arg3;
return (_local4);
}
public static function quaternion2matrix(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):JMatrix3D{
var _local5:Number = (_arg1 * _arg1);
var _local6:Number = (_arg1 * _arg2);
var _local7:Number = (_arg1 * _arg3);
var _local8:Number = (_arg1 * _arg4);
var _local9:Number = (_arg2 * _arg2);
var _local10:Number = (_arg2 * _arg3);
var _local11:Number = (_arg2 * _arg4);
var _local12:Number = (_arg3 * _arg3);
var _local13:Number = (_arg3 * _arg4);
var _local14:JMatrix3D = IDENTITY;
_local14.n11 = (1 - (2 * (_local9 + _local12)));
_local14.n12 = (2 * (_local6 - _local13));
_local14.n13 = (2 * (_local7 + _local11));
_local14.n21 = (2 * (_local6 + _local13));
_local14.n22 = (1 - (2 * (_local5 + _local12)));
_local14.n23 = (2 * (_local10 - _local8));
_local14.n31 = (2 * (_local7 - _local11));
_local14.n32 = (2 * (_local10 + _local8));
_local14.n33 = (1 - (2 * (_local5 + _local9)));
return (_local14);
}
public static function inverse(_arg1:JMatrix3D):JMatrix3D{
var _local2:JMatrix3D = new (JMatrix3D);
_local2.calculateInverse(_arg1);
return (_local2);
}
public static function matrix2euler(_arg1:JMatrix3D, _arg2:JNumber3D=null, _arg3:JNumber3D=null):JNumber3D{
_arg2 = ((_arg2) || (new JNumber3D()));
var _local4:Number = (((_arg3) && ((_arg3.x == 1)))) ? 1 : Math.sqrt((((_arg1.n11 * _arg1.n11) + (_arg1.n21 * _arg1.n21)) + (_arg1.n31 * _arg1.n31)));
var _local5:Number = (((_arg3) && ((_arg3.y == 1)))) ? 1 : Math.sqrt((((_arg1.n12 * _arg1.n12) + (_arg1.n22 * _arg1.n22)) + (_arg1.n32 * _arg1.n32)));
var _local6:Number = (((_arg3) && ((_arg3.z == 1)))) ? 1 : Math.sqrt((((_arg1.n13 * _arg1.n13) + (_arg1.n23 * _arg1.n23)) + (_arg1.n33 * _arg1.n33)));
var _local7:Number = (_arg1.n11 / _local4);
var _local8:Number = (_arg1.n21 / _local5);
var _local9:Number = (_arg1.n31 / _local6);
var _local10:Number = (_arg1.n32 / _local6);
var _local11:Number = (_arg1.n33 / _local6);
_local9 = ((_local9 > 1)) ? 1 : _local9;
_local9 = ((_local9 < -1)) ? -1 : _local9;
_arg2.y = Math.asin(-(_local9));
_arg2.z = Math.atan2(_local8, _local7);
_arg2.x = Math.atan2(_local10, _local11);
_arg2.x = (_arg2.x * toDEGREES);
_arg2.y = (_arg2.y * toDEGREES);
_arg2.z = (_arg2.z * toDEGREES);
return (_arg2);
}
public static function get IDENTITY():JMatrix3D{
return (new JMatrix3D([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]));
}
}
}//package jiglib.math
Section 78
//JNumber3D (jiglib.math.JNumber3D)
package jiglib.math {
public class JNumber3D {
public var y:Number;
public var x:Number;
public var z:Number;
public function JNumber3D(_arg1:Number=0, _arg2:Number=0, _arg3:Number=0){
this.x = _arg1;
this.y = _arg2;
this.z = _arg3;
}
public function setTo(_arg1:Number=0, _arg2:Number=0, _arg3:Number=0):void{
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 = this.modulo;
if (((!((_local1 == 0))) && (!((_local1 == 1))))){
this.x = (this.x / _local1);
this.y = (this.y / _local1);
this.z = (this.z / _local1);
};
}
public function get modulo():Number{
return (Math.sqrt((((this.x * this.x) + (this.y * this.y)) + (this.z * this.z))));
}
public function copyTo(_arg1:JNumber3D):void{
_arg1.x = x;
_arg1.y = y;
_arg1.z = z;
}
public function IsFinite():Boolean{
if ((((this.x > 1000000)) || ((this.x < -1000000)))){
return (true);
};
if ((((this.y > 1000000)) || ((this.y < -1000000)))){
return (true);
};
if ((((this.z > 1000000)) || ((this.z < -1000000)))){
return (true);
};
return (false);
}
public function get modulo2():Number{
return ((((this.x * this.x) + (this.y * this.y)) + (this.z * this.z)));
}
public function clone():JNumber3D{
return (new JNumber3D(this.x, this.y, this.z));
}
public function toArray():Array{
return (new Array(this.x, this.y, this.z));
}
public static function sub(_arg1:JNumber3D, _arg2:JNumber3D):JNumber3D{
return (new JNumber3D((_arg1.x - _arg2.x), (_arg1.y - _arg2.y), (_arg1.z - _arg2.z)));
}
public static function add(_arg1:JNumber3D, _arg2:JNumber3D):JNumber3D{
return (new JNumber3D((_arg1.x + _arg2.x), (_arg1.y + _arg2.y), (_arg1.z + _arg2.z)));
}
public static function multiply(_arg1:JNumber3D, _arg2:Number):JNumber3D{
return (new JNumber3D((_arg1.x * _arg2), (_arg1.y * _arg2), (_arg1.z * _arg2)));
}
public static function cross(_arg1:JNumber3D, _arg2:JNumber3D):JNumber3D{
return (new JNumber3D(((_arg2.y * _arg1.z) - (_arg2.z * _arg1.y)), ((_arg2.z * _arg1.x) - (_arg2.x * _arg1.z)), ((_arg2.x * _arg1.y) - (_arg2.y * _arg1.x))));
}
public static function get ZERO():JNumber3D{
return (new JNumber3D(0, 0, 0));
}
public static function get FRONT():JNumber3D{
return (new JNumber3D(0, 0, 1));
}
public static function get NUM_HUGE():Number{
return (100000);
}
public static function dot(_arg1:JNumber3D, _arg2:JNumber3D):Number{
return ((((_arg1.x * _arg2.x) + (_arg1.y * _arg2.y)) + (_arg2.z * _arg1.z)));
}
public static function get NUM_TINY():Number{
return (1E-5);
}
public static function divide(_arg1:JNumber3D, _arg2:Number):JNumber3D{
if (_arg2 != 0){
return (new JNumber3D((_arg1.x / _arg2), (_arg1.y / _arg2), (_arg1.z / _arg2)));
};
return (new (JNumber3D));
}
public static function get UP():JNumber3D{
return (new JNumber3D(0, 1, 0));
}
public static function get RIGHT():JNumber3D{
return (new JNumber3D(1, 0, 0));
}
}
}//package jiglib.math
Section 79
//JConstraint (jiglib.physics.constraint.JConstraint)
package jiglib.physics.constraint {
import jiglib.physics.*;
public class JConstraint {
private var _constraintEnabled:Boolean;
private var _satisfied:Boolean;
public function EnableConstraint():void{
if (_constraintEnabled){
return;
};
_constraintEnabled = true;
PhysicsSystem.getInstance().AddConstraint(this);
}
public function PreApply(_arg1:Number):void{
_satisfied = false;
}
public function get ConstraintEnabled():Boolean{
return (_constraintEnabled);
}
public function set Satisfied(_arg1:Boolean):void{
_satisfied = _arg1;
}
public function DisableConstraint():void{
if (!_constraintEnabled){
return;
};
_constraintEnabled = false;
PhysicsSystem.getInstance().RemoveConstraint(this);
}
public function Apply(_arg1:Number):Boolean{
return (false);
}
public function get Satisfied():Boolean{
return (_satisfied);
}
}
}//package jiglib.physics.constraint
Section 80
//BodyPair (jiglib.physics.BodyPair)
package jiglib.physics {
import jiglib.math.*;
public class BodyPair {
public var R:JNumber3D;
public var Body0:RigidBody;
public var Body1:RigidBody;
public function BodyPair(_arg1:RigidBody, _arg2:RigidBody, _arg3:JNumber3D, _arg4:JNumber3D){
if (_arg1.ID > _arg2.ID){
this.Body0 = _arg1;
this.Body1 = _arg2;
this.R = _arg3;
} else {
this.Body0 = _arg2;
this.Body1 = _arg1;
this.R = _arg4;
};
}
}
}//package jiglib.physics
Section 81
//CachedImpulse (jiglib.physics.CachedImpulse)
package jiglib.physics {
import jiglib.math.*;
public class CachedImpulse {
public var FrictionImpulse:JNumber3D;
public var NormalImpulseAux:Number;
public var NormalImpulse:Number;
public function CachedImpulse(_arg1:Number, _arg2:Number, _arg3:JNumber3D){
this.NormalImpulse = _arg1;
this.NormalImpulseAux = _arg2;
this.FrictionImpulse = _arg3;
}
}
}//package jiglib.physics
Section 82
//MaterialProperties (jiglib.physics.MaterialProperties)
package jiglib.physics {
public class MaterialProperties {
public var StaticFriction:Number;
public var DynamicFriction:Number;
public var Restitution:Number;
public function MaterialProperties(_arg1:Number=0.2, _arg2:Number=0.6, _arg3:Number=0.6){
Restitution = _arg1;
StaticFriction = _arg2;
DynamicFriction = _arg3;
}
}
}//package jiglib.physics
Section 83
//PhysicsState (jiglib.physics.PhysicsState)
package jiglib.physics {
import jiglib.math.*;
public class PhysicsState {
public var Orientation:JMatrix3D;
public var RotVelocity:JNumber3D;
public var Position:JNumber3D;
public var LinVelocity:JNumber3D;
public function PhysicsState(){
Position = new JNumber3D();
Orientation = new JMatrix3D();
LinVelocity = new JNumber3D();
RotVelocity = new JNumber3D();
super();
}
}
}//package jiglib.physics
Section 84
//PhysicsSystem (jiglib.physics.PhysicsSystem)
package jiglib.physics {
import jiglib.math.*;
import jiglib.collision.*;
import jiglib.physics.constraint.*;
import jiglib.cof.*;
public class PhysicsSystem {
private const _maxVelMag:Number = 0.5;
private const _minVelForProcessing:Number = 0.001;
private var PreProcessCollisionFn:Function;
private var _gravity:JNumber3D;
private var _collisions:Array;
private var DetectAllCollisionsFn:Function;
private var _cachedContacts:Array;
private var _doingIntegration:Boolean;
private var _collisionSystem:CollisionSystem;
private var _activeBodies:Array;
private var ProcessCollisionFn:Function;
private var _gravityAxis:int;
private var _bodies:Array;
private var _constraints:Array;
private var ProcessContactFn:Function;
private var PreProcessContactFn:Function;
private static var _currentPhysicsSystem:PhysicsSystem;
public function PhysicsSystem(){
SetSolverType(JConfig.solverType);
SetDetectCollisionsType(JConfig.detectCollisionsType);
_doingIntegration = false;
_bodies = new Array();
_collisions = new Array();
_activeBodies = new Array();
_constraints = new Array();
_cachedContacts = new Array();
_collisionSystem = new CollisionSystem();
SetGravity(JNumber3D.multiply(JNumber3D.UP, -10));
}
private function DampAllActiveBodies():void{
var _local1:String;
for (_local1 in _activeBodies) {
_activeBodies[_local1].DampForDeactivation();
};
}
private function UpdateAllObject3D():void{
var _local1:String;
for (_local1 in _bodies) {
_bodies[_local1].updateObject3D();
};
}
private function CopyAllCurrentStatesToOld():void{
var _local1:String;
for (_local1 in _bodies) {
if (((_bodies[_local1].IsActive()) || (_bodies[_local1].GetVelChanged()))){
_bodies[_local1].CopyCurrentStateToOld();
};
};
}
private function NotifyAllPostPhysics(_arg1:Number):void{
var _local2:String;
for (_local2 in _bodies) {
_bodies[_local2].PostPhysics(_arg1);
};
}
private function FindAllActiveBodies():void{
var _local1:String;
_activeBodies = new Array();
for (_local1 in _bodies) {
if (_bodies[_local1].IsActive()){
_activeBodies.push(_bodies[_local1]);
};
};
}
public function Integrate(_arg1:Number):void{
var _local2:String;
_doingIntegration = true;
FindAllActiveBodies();
CopyAllCurrentStatesToOld();
GetAllExternalForces(_arg1);
DetectAllCollisionsFn(_arg1);
HandleAllConstraints(_arg1, JConfig.numCollisionIterations, false);
UpdateAllVelocities(_arg1);
HandleAllConstraints(_arg1, JConfig.numContactIterations, true);
DampAllActiveBodies();
TryToFreezeAllObjects(_arg1);
ActivateAllFrozenObjectsLeftHanging();
UpdateAllPositions(_arg1);
NotifyAllPostPhysics(_arg1);
UpdateAllObject3D();
if (JConfig.solverType == "ACCUMULATED"){
UpdateContactCache();
};
for (_local2 in _bodies) {
_bodies[_local2].ClearForces();
};
_doingIntegration = false;
}
private function ProcessCollisionAccumulated(_arg1:CollisionInfo, _arg2:Number):Boolean{
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:JNumber3D;
var _local11:JNumber3D;
var _local12:JNumber3D;
var _local13:CollPointInfo;
var _local15:Number;
var _local16:Number;
var _local17:JNumber3D;
var _local18:JNumber3D;
var _local19:JNumber3D;
var _local20:Number;
var _local21:JNumber3D;
var _local22:Number;
var _local23:Number;
var _local24:JNumber3D;
var _local25:JNumber3D;
var _local26:Number;
var _local27:Number;
var _local28:JNumber3D;
_arg1.Satisfied = true;
var _local3:Boolean;
var _local4:JNumber3D = _arg1.DirToBody;
var _local5:RigidBody = _arg1.ObjInfo.body0;
var _local6:RigidBody = _arg1.ObjInfo.body1;
var _local14:uint;
while (_local14 < _arg1.PointInfo.length) {
_local13 = _arg1.PointInfo[_local14];
_local11 = _local5.GetVelocity(_local13.R0);
_local12 = _local6.GetVelocity(_local13.R1);
_local8 = JNumber3D.dot(JNumber3D.sub(_local11, _local12), _local4);
_local7 = -(_local8);
if (_local13.MinSeparationVel < 0){
_local7 = (_local7 + _local13.MinSeparationVel);
};
if (Math.abs(_local7) > _minVelForProcessing){
_local9 = (_local7 / _local13.Denominator);
_local15 = _local13.AccumulatedNormalImpulse;
_local13.AccumulatedNormalImpulse = Math.max((_local13.AccumulatedNormalImpulse + _local9), 0);
_local16 = (_local13.AccumulatedNormalImpulse - _local15);
_local10 = JNumber3D.multiply(_local4, _local16);
_local5.ApplyBodyWorldImpulse(_local10, _local13.R0);
_local6.ApplyBodyWorldImpulse(JNumber3D.multiply(_local10, -1), _local13.R1);
_local3 = true;
};
_local11 = _local5.GetVelocityAux(_local13.R0);
_local12 = _local6.GetVelocityAux(_local13.R1);
_local8 = JNumber3D.dot(JNumber3D.sub(_local11, _local12), _local4);
_local7 = -(_local8);
if (_local13.MinSeparationVel > 0){
_local7 = (_local7 + _local13.MinSeparationVel);
};
if (Math.abs(_local7) > _minVelForProcessing){
_local9 = (_local7 / _local13.Denominator);
_local15 = _local13.AccumulatedNormalImpulseAux;
_local13.AccumulatedNormalImpulseAux = Math.max((_local13.AccumulatedNormalImpulseAux + _local9), 0);
_local16 = (_local13.AccumulatedNormalImpulseAux - _local15);
_local10 = JNumber3D.multiply(_local4, _local16);
_local5.ApplyBodyWorldImpulseAux(_local10, _local13.R0);
_local6.ApplyBodyWorldImpulseAux(JNumber3D.multiply(_local10, -1), _local13.R1);
_local3 = true;
};
if (_local13.AccumulatedNormalImpulse > 0){
_local11 = _local5.GetVelocity(_local13.R0);
_local12 = _local6.GetVelocity(_local13.R1);
_local18 = JNumber3D.sub(_local11, _local12);
_local19 = JNumber3D.sub(_local18, JNumber3D.multiply(_local4, JNumber3D.dot(_local18, _local4)));
_local20 = _local19.modulo;
if (_local20 > _minVelForProcessing){
_local21 = JNumber3D.multiply(JNumber3D.divide(_local19, _local20), -1);
_local22 = 0;
if (_local5.Getmovable()){
_local17 = JNumber3D.cross(_local21, _local13.R0);
JMatrix3D.multiplyVector(_local5.WorldInvInertia, _local17);
_local22 = (_local5.InvMass + JNumber3D.dot(_local21, JNumber3D.cross(_local13.R0, _local17)));
};
if (_local6.Getmovable()){
_local17 = JNumber3D.cross(_local21, _local13.R1);
JMatrix3D.multiplyVector(_local6.WorldInvInertia, _local17);
_local22 = (_local22 + (_local6.InvMass + JNumber3D.dot(_local21, JNumber3D.cross(_local13.R1, _local17))));
};
if (_local22 > JNumber3D.NUM_TINY){
_local23 = (_local20 / _local22);
_local24 = JNumber3D.multiply(_local21, _local23);
_local25 = _local13.AccumulatedFrictionImpulse.clone();
_local13.AccumulatedFrictionImpulse = JNumber3D.add(_local13.AccumulatedFrictionImpulse, _local24);
_local26 = _local13.AccumulatedFrictionImpulse.modulo;
_local27 = (_arg1.Mat.StaticFriction * _local13.AccumulatedNormalImpulse);
if ((((_local26 > JNumber3D.NUM_TINY)) && ((_local26 > _local27)))){
_local13.AccumulatedFrictionImpulse = JNumber3D.multiply(_local13.AccumulatedFrictionImpulse, (_local27 / _local26));
};
_local28 = JNumber3D.sub(_local13.AccumulatedFrictionImpulse, _local25);
_local5.ApplyBodyWorldImpulse(_local28, _local13.R0);
_local6.ApplyBodyWorldImpulse(JNumber3D.multiply(_local28, -1), _local13.R1);
};
};
};
_local14++;
};
if (_local3){
_local5.SetConstraintsAndCollisionsUnsatisfied();
_local6.SetConstraintsAndCollisionsUnsatisfied();
};
return (_local3);
}
public function RemoveConstraint(_arg1:JConstraint):void{
if (findConstraint(_arg1)){
_constraints.splice(_constraints.indexOf(_arg1), 1);
};
}
private function PreProcessCollisionFast(_arg1:CollisionInfo, _arg2:Number):void{
var _local7:Number;
var _local8:CollPointInfo;
var _local9:JNumber3D;
var _local11:JNumber3D;
var _local12:JNumber3D;
var _local13:Number;
var _local14:uint;
_arg1.Satisfied = false;
var _local3:RigidBody = _arg1.ObjInfo.body0;
var _local4:RigidBody = _arg1.ObjInfo.body1;
var _local5:JNumber3D = _arg1.DirToBody;
var _local6:Number = (JConfig.numPenetrationRelaxationTimesteps * _arg2);
var _local10:Number = Number(_arg1.PointInfo.length);
if (_local10 > 1){
_local11 = new JNumber3D();
_local12 = new JNumber3D();
_local13 = 0;
_local14 = 0;
while (_local14 < _local10) {
_local8 = _arg1.PointInfo[_local14];
_local11 = JNumber3D.add(_local11, _local8.R0);
_local12 = JNumber3D.add(_local12, _local8.R1);
_local13 = (_local13 + _local8.InitialPenetration);
_local14++;
};
_local11 = JNumber3D.divide(_local11, _local10);
_local12 = JNumber3D.divide(_local12, _local10);
_local13 = (_local13 / _local10);
_arg1.PointInfo = new Array();
_arg1.PointInfo[0] = new CollPointInfo();
_arg1.PointInfo[0].R0 = _local11;
_arg1.PointInfo[0].R1 = _local12;
_arg1.PointInfo[0].InitialPenetration = _local13;
};
_local14 = 0;
while (_local14 < _arg1.PointInfo.length) {
_local8 = _arg1.PointInfo[_local14];
if (!_local3.Getmovable()){
_local8.Denominator = 0;
} else {
_local9 = JNumber3D.cross(_local5, _local8.R0);
JMatrix3D.multiplyVector(_local3.WorldInvInertia, _local9);
_local8.Denominator = (_local3.InvMass + JNumber3D.dot(_local5, JNumber3D.cross(_local8.R0, _local9)));
};
if (_local4.Getmovable()){
_local9 = JNumber3D.cross(_local5, _local8.R1);
JMatrix3D.multiplyVector(_local4.WorldInvInertia, _local9);
_local8.Denominator = (_local8.Denominator + (_local4.InvMass + JNumber3D.dot(_local5, JNumber3D.cross(_local8.R1, _local9))));
};
if (_local8.Denominator < JNumber3D.NUM_TINY){
_local8.Denominator = JNumber3D.NUM_TINY;
};
if (_local8.InitialPenetration > JConfig.allowedPenetration){
_local8.MinSeparationVel = ((_local8.InitialPenetration - JConfig.allowedPenetration) / _local6);
} else {
_local7 = ((-0.1 * (_local8.InitialPenetration - JConfig.allowedPenetration)) / JConfig.allowedPenetration);
if (_local7 < JNumber3D.NUM_TINY){
_local7 = JNumber3D.NUM_TINY;
} else {
if (_local7 > 1){
_local7 = 1;
};
};
_local8.MinSeparationVel = ((_local7 * (_local8.InitialPenetration - JConfig.allowedPenetration)) / Math.max(_arg2, JNumber3D.NUM_TINY));
};
if (_local8.MinSeparationVel > _maxVelMag){
_local8.MinSeparationVel = _maxVelMag;
};
_local14++;
};
}
private function ProcessCollision(_arg1:CollisionInfo, _arg2:Number):Boolean{
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:JNumber3D;
var _local12:JNumber3D;
var _local13:JNumber3D;
var _local14:CollPointInfo;
var _local16:JNumber3D;
var _local17:JNumber3D;
var _local18:JNumber3D;
var _local19:Number;
var _local20:JNumber3D;
var _local21:Number;
var _local22:Number;
var _local23:Number;
var _local24:Number;
_arg1.Satisfied = true;
var _local3:RigidBody = _arg1.ObjInfo.body0;
var _local4:RigidBody = _arg1.ObjInfo.body1;
var _local5:Boolean;
var _local6:JNumber3D = _arg1.DirToBody;
var _local15:uint;
while (_local15 < _arg1.PointInfo.length) {
_local14 = _arg1.PointInfo[_local15];
_local12 = _local3.GetVelocity(_local14.R0);
_local13 = _local4.GetVelocity(_local14.R1);
_local8 = JNumber3D.dot(JNumber3D.sub(_local12, _local13), _local6);
if (_local8 > _local14.MinSeparationVel){
} else {
_local9 = ((-1 * _arg1.Mat.Restitution) * _local8);
if (_local9 < _minVelForProcessing){
_local9 = _local14.MinSeparationVel;
};
_local7 = (_local9 - _local8);
if (_local7 <= _minVelForProcessing){
} else {
_local10 = (_local7 / _local14.Denominator);
_local5 = true;
_local11 = JNumber3D.multiply(_local6, _local10);
_local3.ApplyBodyWorldImpulse(_local11, _local14.R0);
_local4.ApplyBodyWorldImpulse(JNumber3D.multiply(_local11, -1), _local14.R1);
_local17 = JNumber3D.sub(_local12, _local13);
_local18 = JNumber3D.sub(_local17, JNumber3D.multiply(_local6, JNumber3D.dot(_local17, _local6)));
_local19 = _local18.modulo;
if (_local19 > _minVelForProcessing){
_local20 = JNumber3D.multiply(JNumber3D.divide(_local18, _local19), -1);
if (_local3.Getmovable()){
_local16 = JNumber3D.cross(_local20, _local14.R0);
JMatrix3D.multiplyVector(_local3.WorldInvInertia, _local16);
_local21 = (_local3.InvMass + JNumber3D.dot(_local20, JNumber3D.cross(_local14.R0, _local16)));
};
if (_local4.Getmovable()){
_local16 = JNumber3D.cross(_local20, _local14.R1);
JMatrix3D.multiplyVector(_local4.WorldInvInertia, _local16);
_local21 = (_local21 + (_local4.InvMass + JNumber3D.dot(_local20, JNumber3D.cross(_local14.R1, _local16))));
};
if (_local21 > JNumber3D.NUM_TINY){
_local22 = (_local19 / _local21);
_local23 = (_arg1.Mat.StaticFriction * _local10);
if (_local22 < _local23){
_local24 = _local22;
} else {
_local24 = (_arg1.Mat.DynamicFriction * _local10);
};
_local20 = JNumber3D.multiply(_local20, _local24);
_local3.ApplyBodyWorldImpulse(_local20, _local14.R0);
_local4.ApplyBodyWorldImpulse(JNumber3D.multiply(_local20, -1), _local14.R1);
};
};
};
};
_local15++;
};
if (_local5){
_local3.SetConstraintsAndCollisionsUnsatisfied();
_local4.SetConstraintsAndCollisionsUnsatisfied();
};
return (_local5);
}
private function DetectAllCollisionsStore(_arg1:Number):void{
var _local2:String;
for (_local2 in _activeBodies) {
_activeBodies[_local2].StoreState();
};
UpdateAllVelocities(_arg1);
UpdateAllPositions(_arg1);
for (_local2 in _bodies) {
_bodies[_local2].Collisions = new Array();
};
_collisions = new Array();
_collisionSystem.DetectAllCollisions(_activeBodies, _collisions);
for (_local2 in _activeBodies) {
_activeBodies[_local2].RestoreState();
};
}
public function SetGravity(_arg1:JNumber3D):void{
_gravity = _arg1;
if ((((_gravity.x == _gravity.y)) && ((_gravity.y == _gravity.z)))){
_gravityAxis = -1;
};
_gravityAxis = 0;
if (Math.abs(_gravity.y) > Math.abs(_gravity.z)){
_gravityAxis = 1;
};
if (Math.abs(_gravity.z) > Math.abs(_gravity.toArray()[_gravityAxis])){
_gravityAxis = 2;
};
}
private function PreProcessCollisionNormal(_arg1:CollisionInfo, _arg2:Number):void{
var _local7:Number;
var _local8:CollPointInfo;
var _local9:JNumber3D;
_arg1.Satisfied = false;
var _local3:RigidBody = _arg1.ObjInfo.body0;
var _local4:RigidBody = _arg1.ObjInfo.body1;
var _local5:JNumber3D = _arg1.DirToBody;
var _local6:Number = (JConfig.numPenetrationRelaxationTimesteps * _arg2);
var _local10:uint;
while (_local10 < _arg1.PointInfo.length) {
_local8 = _arg1.PointInfo[_local10];
if (!_local3.Getmovable()){
_local8.Denominator = 0;
} else {
_local9 = JNumber3D.cross(_local5, _local8.R0);
JMatrix3D.multiplyVector(_local3.WorldInvInertia, _local9);
_local8.Denominator = (_local3.InvMass + JNumber3D.dot(_local5, JNumber3D.cross(_local8.R0, _local9)));
};
if (_local4.Getmovable()){
_local9 = JNumber3D.cross(_local5, _local8.R1);
JMatrix3D.multiplyVector(_local4.WorldInvInertia, _local9);
_local8.Denominator = (_local8.Denominator + (_local4.InvMass + JNumber3D.dot(_local5, JNumber3D.cross(_local8.R1, _local9))));
};
if (_local8.Denominator < JNumber3D.NUM_TINY){
_local8.Denominator = JNumber3D.NUM_TINY;
};
if (_local8.InitialPenetration > JConfig.allowedPenetration){
_local8.MinSeparationVel = ((_local8.InitialPenetration - JConfig.allowedPenetration) / _local6);
} else {
_local7 = ((-0.1 * (_local8.InitialPenetration - JConfig.allowedPenetration)) / JConfig.allowedPenetration);
if (_local7 < JNumber3D.NUM_TINY){
_local7 = JNumber3D.NUM_TINY;
} else {
if (_local7 > 1){
_local7 = 1;
};
};
_local8.MinSeparationVel = ((_local7 * (_local8.InitialPenetration - JConfig.allowedPenetration)) / Math.max(_arg2, JNumber3D.NUM_TINY));
};
if (_local8.MinSeparationVel > _maxVelMag){
_local8.MinSeparationVel = _maxVelMag;
};
_local10++;
};
}
public function get Gravity():JNumber3D{
return (_gravity);
}
public function ActivateObject(_arg1:RigidBody):void{
var _local3:RigidBody;
var _local4:JNumber3D;
if (((!(_arg1.Getmovable())) || (_arg1.IsActive()))){
return;
};
_arg1.SetActive();
_activeBodies.push(_arg1);
var _local2:uint = _collisions.length;
_collisionSystem.DetectCollisions(_arg1, _collisions);
var _local5:uint = _local2;
while (_local5 < _collisions.length) {
_local3 = _collisions[_local5].ObjInfo.body0;
_local4 = _collisions[_local5].DirToBody;
if (_local3 == _arg1){
_local3 = _collisions[_local5].ObjInfo.body1;
_local4 = JNumber3D.multiply(_collisions[_local5].DirToBody, -1);
};
if (((!(_local3.IsActive())) && ((JNumber3D.dot(_local3.Force, _local4) < -(JNumber3D.NUM_TINY))))){
ActivateObject(_local3);
};
_local5++;
};
}
private function HandleAllConstraints(_arg1:Number, _arg2:int, _arg3:Boolean):void{
var _local5:String;
var _local6:Boolean;
var _local7:Boolean;
var _local8:uint;
var _local9:String;
var _local10:uint;
var _local4:int = _collisions.length;
for (_local5 in _constraints) {
_constraints[_local5].PreApply(_arg1);
};
if (_arg3){
for (_local9 in _collisions) {
_collisions[_local9].Mat.Restitution = 0;
_collisions[_local9].Satisfied = false;
PreProcessContactFn(_collisions[_local9], _arg1);
};
} else {
for (_local9 in _collisions) {
PreProcessCollisionFn(_collisions[_local9], _arg1);
};
};
_local8 = 0;
while (_local8 < _arg2) {
_local7 = false;
for (_local9 in _collisions) {
if (!_collisions[_local9].Satisfied){
if (_arg3){
_local6 = ProcessContactFn(_collisions[_local9], _arg1);
_local7 = ((_local7) || (_local6));
} else {
_local6 = ProcessCollisionFn(_collisions[_local9], _arg1);
_local7 = ((_local7) || (_local6));
};
};
};
for (_local5 in _constraints) {
if (!_constraints[_local5].Satisfied){
_local6 = _constraints[_local5].Apply(_arg1);
_local7 = ((_local7) || (_local6));
};
};
TryToActivateAllFrozenObjects();
if (_arg3){
_local10 = _local4;
while (_local10 < _collisions.length) {
_collisions[_local9].Mat.Restitution = 0;
_collisions[_local9].Satisfied = false;
PreProcessContactFn(_collisions[_local10], _arg1);
_local10++;
};
} else {
_local10 = _local4;
while (_local10 < _collisions.length) {
PreProcessCollisionFn(_collisions[_local10], _arg1);
_local10++;
};
};
_local4 = _collisions.length;
if (!_local7){
break;
};
_local8++;
};
}
public function AddConstraint(_arg1:JConstraint):void{
if (!findConstraint(_arg1)){
_constraints.push(_arg1);
};
}
private function PreProcessCollisionAccumulated(_arg1:CollisionInfo, _arg2:Number):void{
var _local7:JNumber3D;
var _local8:CollPointInfo;
var _local9:Number;
var _local11:Number;
var _local12:BodyPair;
var _local13:String;
var _local14:Number;
var _local15:JNumber3D;
_arg1.Satisfied = false;
var _local3:RigidBody = _arg1.ObjInfo.body0;
var _local4:RigidBody = _arg1.ObjInfo.body1;
var _local5:JNumber3D = _arg1.DirToBody;
var _local6:Number = (JConfig.numPenetrationRelaxationTimesteps * _arg2);
var _local10:uint;
while (_local10 < _arg1.PointInfo.length) {
_local8 = _arg1.PointInfo[_local10];
if (!_local3.Getmovable()){
_local8.Denominator = 0;
} else {
_local7 = JNumber3D.cross(_local5, _local8.R0);
JMatrix3D.multiplyVector(_local3.WorldInvInertia, _local7);
_local8.Denominator = (_local3.InvMass + JNumber3D.dot(_local5, JNumber3D.cross(_local8.R0, _local7)));
};
if (_local4.Getmovable()){
_local7 = JNumber3D.cross(_local5, _local8.R1);
JMatrix3D.multiplyVector(_local4.WorldInvInertia, _local7);
_local8.Denominator = (_local8.Denominator + (_local4.InvMass + JNumber3D.dot(_local5, JNumber3D.cross(_local8.R1, _local7))));
};
if (_local8.Denominator < JNumber3D.NUM_TINY){
_local8.Denominator = JNumber3D.NUM_TINY;
};
if (_local8.InitialPenetration > JConfig.allowedPenetration){
_local8.MinSeparationVel = ((_local8.InitialPenetration - JConfig.allowedPenetration) / _local6);
} else {
_local9 = ((-0.1 * (_local8.InitialPenetration - JConfig.allowedPenetration)) / JConfig.allowedPenetration);
if (_local9 < JNumber3D.NUM_TINY){
_local9 = JNumber3D.NUM_TINY;
} else {
if (_local9 > 1){
_local9 = 1;
};
};
_local8.MinSeparationVel = ((_local9 * (_local8.InitialPenetration - JConfig.allowedPenetration)) / Math.max(_arg2, JNumber3D.NUM_TINY));
};
_local8.AccumulatedNormalImpulse = 0;
_local8.AccumulatedNormalImpulseAux = 0;
_local8.AccumulatedFrictionImpulse = new JNumber3D();
_local11 = 0.04;
_local12 = new BodyPair(_local3, _local4, JNumber3D.ZERO, JNumber3D.ZERO);
for (_local13 in _cachedContacts) {
if (!(((_local12.Body0 == _cachedContacts[_local13].Pair.Body0)) && ((_local12.Body1 == _cachedContacts[_local13].Pair.Body1)))){
} else {
_local14 = ((_cachedContacts[_local13].Pair.Body0)==_local3) ? JNumber3D.sub(_cachedContacts[_local13].Pair.R, _local8.R0).modulo2 : JNumber3D.sub(_cachedContacts[_local13].Pair.R, _local8.R1).modulo2;
if (_local14 < _local11){
_local11 = _local14;
_local8.AccumulatedNormalImpulse = _cachedContacts[_local13].Impulse.NormalImpulse;
_local8.AccumulatedNormalImpulseAux = _cachedContacts[_local13].Impulse.NormalImpulseAux;
_local8.AccumulatedFrictionImpulse = _cachedContacts[_local13].Impulse.FrictionImpulse;
if (_cachedContacts[_local13].Pair.Body0 != _local3){
_local8.AccumulatedFrictionImpulse = JNumber3D.multiply(_local8.AccumulatedFrictionImpulse, -1);
};
};
};
};
if (_local8.AccumulatedNormalImpulse != 0){
_local15 = JNumber3D.multiply(_local5, _local8.AccumulatedNormalImpulse);
_local15 = JNumber3D.add(_local15, _local8.AccumulatedFrictionImpulse);
_local3.ApplyBodyWorldImpulse(_local15, _local8.R0);
_local4.ApplyBodyWorldImpulse(JNumber3D.multiply(_local15, -1), _local8.R1);
};
if (_local8.AccumulatedNormalImpulseAux != 0){
_local15 = JNumber3D.multiply(_local5, _local8.AccumulatedNormalImpulseAux);
_local3.ApplyBodyWorldImpulseAux(_local15, _local8.R0);
_local4.ApplyBodyWorldImpulseAux(JNumber3D.multiply(_local15, -1), _local8.R1);
};
_local10++;
};
}
public function SetDetectCollisionsType(_arg1:String):void{
switch (_arg1){
case "DIRECT":
DetectAllCollisionsFn = DetectAllCollisionsDirect;
return;
case "STORE":
DetectAllCollisionsFn = DetectAllCollisionsStore;
return;
default:
DetectAllCollisionsFn = DetectAllCollisionsDirect;
return;
};
}
private function DetectAllCollisionsDirect(_arg1:Number):void{
var _local2:String;
for (_local2 in _bodies) {
_bodies[_local2].Collisions = new Array();
};
_collisions = new Array();
_collisionSystem.DetectAllCollisions(_activeBodies, _collisions);
}
public function AddBody(_arg1:RigidBody):void{
if (!findBody(_arg1)){
_bodies.push(_arg1);
_collisionSystem.AddCollisionBody(_arg1);
};
}
public function SetSolverType(_arg1:String):void{
switch (_arg1){
case "FAST":
PreProcessCollisionFn = PreProcessCollisionFast;
PreProcessContactFn = PreProcessCollisionFast;
ProcessCollisionFn = ProcessCollision;
ProcessContactFn = ProcessCollision;
return;
case "NORMAL":
PreProcessCollisionFn = PreProcessCollisionNormal;
PreProcessContactFn = PreProcessCollisionNormal;
ProcessCollisionFn = ProcessCollision;
ProcessContactFn = ProcessCollision;
return;
case "ACCUMULATED":
PreProcessCollisionFn = PreProcessCollisionNormal;
PreProcessContactFn = PreProcessCollisionAccumulated;
ProcessCollisionFn = ProcessCollision;
ProcessContactFn = ProcessCollisionAccumulated;
return;
default:
PreProcessCollisionFn = PreProcessCollisionNormal;
PreProcessContactFn = PreProcessCollisionNormal;
ProcessCollisionFn = ProcessCollision;
ProcessContactFn = ProcessCollision;
return;
};
}
private function UpdateAllVelocities(_arg1:Number):void{
var _local2:String;
for (_local2 in _activeBodies) {
_activeBodies[_local2].UpdateVelocity(_arg1);
};
}
private function TryToFreezeAllObjects(_arg1:Number):void{
var _local2:String;
for (_local2 in _activeBodies) {
_activeBodies[_local2].TryToFreeze(_arg1);
};
}
private function UpdateAllPositions(_arg1:Number):void{
var _local2:String;
for (_local2 in _activeBodies) {
_activeBodies[_local2].UpdatePositionWithAux(_arg1);
};
}
private function UpdateContactCache():void{
var _local1:CollisionInfo;
var _local2:CollPointInfo;
var _local3:JNumber3D;
var _local4:Object;
var _local5:String;
var _local6:String;
_cachedContacts = new Array();
for (_local5 in _collisions) {
_local1 = _collisions[_local5];
for (_local6 in _local1.PointInfo) {
_local2 = _local1.PointInfo[_local6];
_local3 = ((_local1.ObjInfo.body0.ID)>_local1.ObjInfo.body1.ID) ? _local2.AccumulatedFrictionImpulse : JNumber3D.multiply(_local2.AccumulatedFrictionImpulse, -1);
_local4 = new Object();
_local4.Pair = new BodyPair(_local1.ObjInfo.body0, _local1.ObjInfo.body1, _local2.R0, _local2.R1);
_local4.Impulse = new CachedImpulse(_local2.AccumulatedNormalImpulse, _local2.AccumulatedNormalImpulseAux, _local2.AccumulatedFrictionImpulse);
_cachedContacts.push(_local4);
};
};
}
private function TryToActivateAllFrozenObjects():void{
var _local1:String;
for (_local1 in _bodies) {
if (!_bodies[_local1].IsActive()){
if (_bodies[_local1].GetShouldBeActive()){
ActivateObject(_bodies[_local1]);
} else {
if (_bodies[_local1].GetVelChanged()){
_bodies[_local1].SetVelocity(JNumber3D.ZERO);
_bodies[_local1].SetAngVel(JNumber3D.ZERO);
_bodies[_local1].ClearVelChanged();
};
};
};
};
}
private function LimitAllVelocities():void{
var _local1:String;
for (_local1 in _activeBodies) {
_activeBodies[_local1].LimitVel();
_activeBodies[_local1].LimitAngVel();
};
}
private function ActivateAllFrozenObjectsLeftHanging():void{
var _local1:RigidBody;
var _local2:String;
var _local3:String;
for (_local2 in _bodies) {
if (_bodies[_local2].IsActive()){
_bodies[_local2].DoMovementActivations();
if (_bodies[_local2].Collisions.length > 0){
for (_local3 in _bodies[_local2].Collisions) {
_local1 = _bodies[_local2].Collisions[_local3].ObjInfo.body0;
if (_local1 == _bodies[_local2]){
_local1 = _bodies[_local2].Collisions[_local3].ObjInfo.body1;
};
if (!_local1.IsActive()){
_bodies[_local2].AddMovementActivation(_bodies[_local2].CurrentState.Position, _local1);
};
};
};
};
};
}
public function RemoveBody(_arg1:RigidBody):void{
if (findBody(_arg1)){
_bodies.splice(_bodies.indexOf(_arg1), 1);
_collisionSystem.RemoveCollisionBody(_arg1);
};
}
public function GetCollisionSystem():CollisionSystem{
return (_collisionSystem);
}
public function get GravityAxis():int{
return (_gravityAxis);
}
public function get Bodys():Array{
return (_bodies);
}
private function findBody(_arg1:RigidBody):Boolean{
var _local2:String;
for (_local2 in _bodies) {
if (_arg1 == _bodies[_local2]){
return (true);
};
};
return (false);
}
private function findConstraint(_arg1:JConstraint):Boolean{
var _local2:String;
for (_local2 in _constraints) {
if (_arg1 == _constraints[_local2]){
return (true);
};
};
return (false);
}
private function GetAllExternalForces(_arg1:Number):void{
var _local2:String;
for (_local2 in _bodies) {
_bodies[_local2].AddExternalForces(_arg1);
};
}
public static function getInstance():PhysicsSystem{
if (!_currentPhysicsSystem){
trace("version: JigLibFlash v0.28 (2009-2-1)");
_currentPhysicsSystem = new (PhysicsSystem);
};
return (_currentPhysicsSystem);
}
}
}//package jiglib.physics
Section 85
//RigidBody (jiglib.physics.RigidBody)
package jiglib.physics {
import org.papervision3d.objects.*;
import org.papervision3d.core.math.*;
import jiglib.math.*;
import jiglib.geometry.*;
import jiglib.cof.*;
public class RigidBody {
private var _currState:PhysicsState;
private var _oldState:PhysicsState;
protected var _type:String;
private var _lastPositionForDeactivation:JNumber3D;
private var _lastOrientationForDeactivation:JMatrix3D;
private var _torque:JNumber3D;
private var _origMovable:Boolean;
private var _movable:Boolean;
private var _invOrientation:JMatrix3D;
private var _invMass:Number;
public var Material:MaterialProperties;
private var _skin:DisplayObject3D;
private var _activity:Boolean;
private var _storedPositionForActivation:JNumber3D;
private var _bodiesToBeActivatedOnMovement:Array;
private var _worldInvInertia:JMatrix3D;
public var Collisions:Array;
private var _worldInertia:JMatrix3D;
protected var _boundingSphere:Number;
private var _inactiveTime:Number;
private var _id:int;
private var _currRotVelocityAux:JNumber3D;
private var _currLinVelocityAux:JNumber3D;
private var _storeState:PhysicsState;
private var _mass:Number;
private var _bodyInvInertia:JMatrix3D;
private var _force:JNumber3D;
private var _velChanged:Boolean;
private var _bodyInertia:JMatrix3D;
private static var idCounter:int = 0;
public function RigidBody(_arg1:DisplayObject3D, _arg2:Boolean=true){
_id = idCounter++;
_skin = _arg1;
Material = new MaterialProperties();
_bodyInertia = JMatrix3D.IDENTITY;
_bodyInvInertia = JMatrix3D.inverse(_bodyInertia);
_currState = new PhysicsState();
_oldState = new PhysicsState();
_storeState = new PhysicsState();
_invOrientation = JMatrix3D.inverse(_currState.Orientation);
_currLinVelocityAux = new JNumber3D();
_currRotVelocityAux = new JNumber3D();
_force = new JNumber3D();
_torque = new JNumber3D();
_origMovable = _arg2;
_velChanged = false;
_inactiveTime = 0;
_activity = _arg2;
_movable = _arg2;
Collisions = new Array();
_storedPositionForActivation = new JNumber3D();
_bodiesToBeActivatedOnMovement = new Array();
_lastPositionForDeactivation = _currState.Position.clone();
_lastOrientationForDeactivation = JMatrix3D.clone(_currState.Orientation);
_type = "Object3D";
_boundingSphere = 0;
}
public function LimitVel():void{
if (_currState.LinVelocity.x < -100){
_currState.LinVelocity.x = -100;
} else {
if (_currState.LinVelocity.x > 100){
_currState.LinVelocity.x = 100;
};
};
if (_currState.LinVelocity.y < -100){
_currState.LinVelocity.y = -100;
} else {
if (_currState.LinVelocity.y > 100){
_currState.LinVelocity.y = 100;
};
};
if (_currState.LinVelocity.z < -100){
_currState.LinVelocity.z = -100;
} else {
if (_currState.LinVelocity.z > 100){
_currState.LinVelocity.z = 100;
};
};
}
public function SetVelocityAux(_arg1:JNumber3D):void{
_arg1.copyTo(_currLinVelocityAux);
}
public function get WorldInertia():JMatrix3D{
return (_worldInertia);
}
public function InternalSetImmovable():void{
_origMovable = _movable;
_movable = false;
}
public function get Mass():Number{
return (_mass);
}
public function get ID():int{
return (_id);
}
public function GetVelChanged():Boolean{
return (_velChanged);
}
public function SetOrientation(_arg1:JMatrix3D):void{
_currState.Orientation.copy(_arg1);
_invOrientation = JMatrix3D.Transpose(_currState.Orientation);
_worldInertia = JMatrix3D.multiply(JMatrix3D.multiply(_currState.Orientation, _bodyInertia), _invOrientation);
_worldInvInertia = JMatrix3D.multiply(JMatrix3D.multiply(_currState.Orientation, _bodyInvInertia), _invOrientation);
}
public function UpdatePosition(_arg1:Number):void{
var _local4:JMatrix3D;
if (((!(Getmovable())) || (!(IsActive())))){
return;
};
_currState.Position = JNumber3D.add(_currState.Position, JNumber3D.multiply(_currState.LinVelocity, _arg1));
var _local2:JNumber3D = _currState.RotVelocity.clone();
var _local3:Number = _local2.modulo;
if (_local3 > 0){
_local2.normalize();
_local3 = (_local3 * _arg1);
_local4 = JMatrix3D.rotationMatrix(_local2.x, _local2.y, _local2.z, _local3);
_currState.Orientation = JMatrix3D.multiply(_local4, _currState.Orientation);
};
SetOrientation(_currState.Orientation);
}
public function ApplyBodyWorldImpulse(_arg1:JNumber3D, _arg2:JNumber3D):void{
if (!Getmovable()){
return;
};
_currState.LinVelocity = JNumber3D.add(_currState.LinVelocity, JNumber3D.multiply(_arg1, _invMass));
var _local3:JNumber3D = JNumber3D.cross(_arg1, _arg2);
JMatrix3D.multiplyVector(_worldInvInertia, _local3);
_currState.RotVelocity = JNumber3D.add(_currState.RotVelocity, _local3);
_velChanged = true;
}
public function SetVelocity(_arg1:JNumber3D):void{
_arg1.copyTo(_currState.LinVelocity);
}
public function DoMovementActivations():void{
if ((((_bodiesToBeActivatedOnMovement.length == 0)) || ((JNumber3D.sub(_currState.Position, _storedPositionForActivation).modulo < JConfig.posThreshold)))){
return;
};
var _local1:int;
while (_local1 < _bodiesToBeActivatedOnMovement.length) {
PhysicsSystem.getInstance().ActivateObject(_bodiesToBeActivatedOnMovement[_local1]);
_local1++;
};
_bodiesToBeActivatedOnMovement = new Array();
}
public function SetAngVel(_arg1:JNumber3D):void{
_arg1.copyTo(_currState.RotVelocity);
}
public function GetVelocity(_arg1:JNumber3D):JNumber3D{
return (JNumber3D.add(_currState.LinVelocity, JNumber3D.cross(_arg1, _currState.RotVelocity)));
}
public function MoveTo(_arg1:JNumber3D, _arg2:JMatrix3D):void{
_arg1.copyTo(_currState.Position);
SetOrientation(_arg2);
_currState.LinVelocity = JNumber3D.ZERO;
_currState.RotVelocity = JNumber3D.ZERO;
CopyCurrentStateToOld();
}
public function StoreState():void{
_currState.Position.copyTo(_storeState.Position);
_storeState.Orientation.copy(_currState.Orientation);
_currState.LinVelocity.copyTo(_storeState.LinVelocity);
_currState.RotVelocity.copyTo(_storeState.RotVelocity);
}
public function SegmentIntersect(_arg1:Object, _arg2:JSegment):Boolean{
return (false);
}
public function SetAngVelAux(_arg1:JNumber3D):void{
_arg1.copyTo(_currRotVelocityAux);
}
public function get Type():String{
return (_type);
}
public function get BodySkin():DisplayObject3D{
return (_skin);
}
public function ClearVelChanged():void{
_velChanged = false;
}
public function get InvMass():Number{
return (_invMass);
}
public function PostPhysics(_arg1:Number):void{
}
public function ApplyWorldImpulse(_arg1:JNumber3D, _arg2:JNumber3D):void{
if (!Getmovable()){
return;
};
_currState.LinVelocity = JNumber3D.add(_currState.LinVelocity, JNumber3D.multiply(_arg1, _invMass));
var _local3:JNumber3D = JNumber3D.cross(_arg1, JNumber3D.sub(_arg2, _currState.Position));
JMatrix3D.multiplyVector(_worldInvInertia, _local3);
_currState.RotVelocity = JNumber3D.add(_currState.RotVelocity, _local3);
_velChanged = true;
}
public function AddExternalForces(_arg1:Number):void{
AddGravity();
}
public function ClearForces():void{
_force = JNumber3D.ZERO;
_torque = JNumber3D.ZERO;
}
public function setMass(_arg1:Number):void{
_mass = _arg1;
_invMass = (1 / _arg1);
setInertia(GetInertiaProperties(_arg1));
}
public function Getmovable():Boolean{
return (_movable);
}
public function AddMovementActivation(_arg1:JNumber3D, _arg2:RigidBody):void{
var _local3:int;
while (_local3 < _bodiesToBeActivatedOnMovement.length) {
if (_bodiesToBeActivatedOnMovement[_local3] == _arg2){
return;
};
_local3++;
};
if (_bodiesToBeActivatedOnMovement.length == 0){
_storedPositionForActivation = _arg1;
};
_bodiesToBeActivatedOnMovement.push(_arg2);
}
public function AddGravity():void{
if (!Getmovable()){
return;
};
_force = JNumber3D.add(_force, JNumber3D.multiply(PhysicsSystem.getInstance().Gravity, _mass));
_velChanged = true;
}
public function ApplyBodyWorldImpulseAux(_arg1:JNumber3D, _arg2:JNumber3D):void{
if (!Getmovable()){
return;
};
_currLinVelocityAux = JNumber3D.add(_currLinVelocityAux, JNumber3D.multiply(_arg1, _invMass));
var _local3:JNumber3D = JNumber3D.cross(_arg1, _arg2);
JMatrix3D.multiplyVector(_worldInvInertia, _local3);
_currRotVelocityAux = JNumber3D.add(_currRotVelocityAux, _local3);
_velChanged = true;
}
public function GetShouldBeActiveAux():Boolean{
return ((((_currLinVelocityAux.modulo > JConfig.velThreshold)) || ((_currRotVelocityAux.modulo > JConfig.angVelThreshold))));
}
public function ApplyWorldImpulseAux(_arg1:JNumber3D, _arg2:JNumber3D):void{
if (!Getmovable()){
return;
};
_currLinVelocityAux = JNumber3D.add(_currLinVelocityAux, JNumber3D.multiply(_arg1, _invMass));
var _local3:JNumber3D = JNumber3D.cross(_arg1, JNumber3D.sub(_arg2, _currState.Position));
JMatrix3D.multiplyVector(_worldInvInertia, _local3);
_currRotVelocityAux = JNumber3D.add(_currRotVelocityAux, _local3);
_velChanged = true;
}
public function GetVelocityAux(_arg1:JNumber3D):JNumber3D{
return (JNumber3D.add(_currLinVelocityAux, JNumber3D.cross(_arg1, _currRotVelocityAux)));
}
public function UpdatePositionWithAux(_arg1:Number):void{
var _local5:JMatrix3D;
if (((!(Getmovable())) || (!(IsActive())))){
_currLinVelocityAux = JNumber3D.ZERO;
_currRotVelocityAux = JNumber3D.ZERO;
return;
};
var _local2:int = PhysicsSystem.getInstance().GravityAxis;
if (_local2 != -1){
_currLinVelocityAux.toArray()[((_local2 + 1) % 3)] = (_currLinVelocityAux.toArray()[((_local2 + 1) % 3)] * 0);
_currLinVelocityAux.toArray()[((_local2 + 2) % 3)] = (_currLinVelocityAux.toArray()[((_local2 + 2) % 3)] * 0);
};
_currState.Position = JNumber3D.add(_currState.Position, JNumber3D.multiply(JNumber3D.add(_currState.LinVelocity, _currLinVelocityAux), _arg1));
var _local3:JNumber3D = JNumber3D.add(_currState.RotVelocity, _currRotVelocityAux);
var _local4:Number = _local3.modulo;
if (_local4 > 0){
_local3.normalize();
_local4 = (_local4 * _arg1);
_local5 = JMatrix3D.rotationMatrix(_local3.x, _local3.y, _local3.z, _local4);
_currState.Orientation = JMatrix3D.multiply(_local5, _currState.Orientation);
};
_currLinVelocityAux = JNumber3D.ZERO;
_currRotVelocityAux = JNumber3D.ZERO;
SetOrientation(_currState.Orientation);
}
public function SetConstraintsAndCollisionsUnsatisfied():void{
var _local1:String;
for (_local1 in Collisions) {
Collisions[_local1].Satisfied = false;
};
}
public function DampForDeactivation():void{
var _local1:Number = 0.5;
var _local2:Number = (_inactiveTime / JConfig.deactivationTime);
if (_local2 < _local1){
return;
};
var _local3:Number = (1 - ((_local2 - _local1) / (1 - _local1)));
if (_local3 < 0){
_local3 = 0;
} else {
if (_local3 > 1){
_local3 = 1;
};
};
_currState.LinVelocity = JNumber3D.multiply(_currState.LinVelocity, _local3);
_currState.RotVelocity = JNumber3D.multiply(_currState.RotVelocity, _local3);
}
public function get WorldInvInertia():JMatrix3D{
return (_worldInvInertia);
}
public function AddBodyTorque(_arg1:JNumber3D):void{
if (!Getmovable()){
return;
};
JMatrix3D.multiplyVector(_currState.Orientation, _arg1);
AddWorldTorque(_arg1);
}
public function get BoundingSphere():Number{
return (_boundingSphere);
}
public function TryToFreeze(_arg1:Number):void{
if (((!(Getmovable())) || (!(IsActive())))){
return;
};
if (JNumber3D.sub(_currState.Position, _lastPositionForDeactivation).modulo > JConfig.posThreshold){
_currState.Position.copyTo(_lastPositionForDeactivation);
_inactiveTime = 0;
return;
};
var _local2:JMatrix3D = JMatrix3D.sub(_currState.Orientation, _lastOrientationForDeactivation);
if ((((((_local2.getCols()[0].modulo > JConfig.orientThreshold)) || ((_local2.getCols()[1].modulo > JConfig.orientThreshold)))) || ((_local2.getCols()[2].modulo > JConfig.orientThreshold)))){
_lastOrientationForDeactivation.copy(_currState.Orientation);
_inactiveTime = 0;
return;
};
if (GetShouldBeActive()){
return;
};
_inactiveTime = (_inactiveTime + _arg1);
if (_inactiveTime > JConfig.deactivationTime){
_currState.Position.copyTo(_lastPositionForDeactivation);
_lastOrientationForDeactivation.copy(_currState.Orientation);
SetInactive();
};
}
public function getTransform():JMatrix3D{
var _local1:JMatrix3D = new JMatrix3D();
_local1.n11 = _skin.transform.n11;
_local1.n12 = _skin.transform.n12;
_local1.n13 = _skin.transform.n13;
_local1.n14 = _skin.transform.n14;
_local1.n21 = _skin.transform.n21;
_local1.n22 = _skin.transform.n22;
_local1.n23 = _skin.transform.n23;
_local1.n24 = _skin.transform.n24;
_local1.n31 = _skin.transform.n31;
_local1.n32 = _skin.transform.n32;
_local1.n33 = _skin.transform.n33;
_local1.n34 = _skin.transform.n34;
_local1.n41 = _skin.transform.n41;
_local1.n42 = _skin.transform.n42;
_local1.n43 = _skin.transform.n43;
_local1.n44 = _skin.transform.n44;
return (_local1);
}
public function get CurrentState():PhysicsState{
return (_currState);
}
public function RestoreState():void{
_storeState.Position.copyTo(_currState.Position);
_currState.Orientation.copy(_storeState.Orientation);
_storeState.LinVelocity.copyTo(_currState.LinVelocity);
_storeState.RotVelocity.copyTo(_currState.RotVelocity);
SetOrientation(_currState.Orientation);
}
public function get OldState():PhysicsState{
return (_oldState);
}
public function get Force():JNumber3D{
return (_force);
}
public function SetMovable(_arg1:Boolean):void{
_movable = _arg1;
}
public function SetInactive():void{
if (_movable){
_activity = false;
};
}
public function GetShouldBeActive():Boolean{
return ((((_currState.LinVelocity.modulo > JConfig.velThreshold)) || ((_currState.RotVelocity.modulo > JConfig.angVelThreshold))));
}
public function hitTestObject3D(_arg1:RigidBody):Boolean{
var _local2:Number = JNumber3D.sub(_currState.Position, _arg1.CurrentState.Position).modulo;
var _local3:Number = (_boundingSphere + _arg1.BoundingSphere);
if (_local2 <= _local3){
return (true);
};
return (false);
}
public function InternalRestoreImmovable():void{
_movable = _origMovable;
}
public function AddWorldForce(_arg1:JNumber3D, _arg2:JNumber3D):void{
if (!Getmovable()){
return;
};
_force = JNumber3D.add(_force, _arg1);
AddWorldTorque(JNumber3D.cross(_arg1, JNumber3D.sub(_arg2, _currState.Position)));
_velChanged = true;
SetActive();
}
public function LimitAngVel():void{
if (_currState.RotVelocity.x < -50){
_currState.RotVelocity.x = -50;
} else {
if (_currState.RotVelocity.x > 50){
_currState.RotVelocity.x = 50;
};
};
if (_currState.RotVelocity.y < -50){
_currState.RotVelocity.y = -50;
} else {
if (_currState.RotVelocity.y > 50){
_currState.RotVelocity.y = 50;
};
};
if (_currState.RotVelocity.z < -50){
_currState.RotVelocity.z = -50;
} else {
if (_currState.RotVelocity.z > 50){
_currState.RotVelocity.z = 50;
};
};
}
public function CopyCurrentStateToOld():void{
_currState.Position.copyTo(_oldState.Position);
_oldState.Orientation.copy(_currState.Orientation);
_currState.LinVelocity.copyTo(_oldState.LinVelocity);
_currState.RotVelocity.copyTo(_oldState.RotVelocity);
}
public function updateObject3D():void{
var _local1:Number3D = new Number3D(_currState.Position.x, _currState.Position.y, _currState.Position.z);
var _local2:Matrix3D = new Matrix3D();
_local2.n11 = _currState.Orientation.n11;
_local2.n12 = _currState.Orientation.n12;
_local2.n13 = _currState.Orientation.n13;
_local2.n14 = _currState.Orientation.n14;
_local2.n21 = _currState.Orientation.n21;
_local2.n22 = _currState.Orientation.n22;
_local2.n23 = _currState.Orientation.n23;
_local2.n24 = _currState.Orientation.n24;
_local2.n31 = _currState.Orientation.n31;
_local2.n32 = _currState.Orientation.n32;
_local2.n33 = _currState.Orientation.n33;
_local2.n34 = _currState.Orientation.n34;
_local2.n41 = _currState.Orientation.n41;
_local2.n42 = _currState.Orientation.n42;
_local2.n43 = _currState.Orientation.n43;
_local2.n44 = _currState.Orientation.n44;
_skin.transform = Matrix3D.multiply(Matrix3D.translationMatrix(_local1.x, _local1.y, _local1.z), _local2);
}
public function UpdateVelocity(_arg1:Number):void{
if (((!(Getmovable())) || (!(IsActive())))){
return;
};
_currState.LinVelocity = JNumber3D.add(_currState.LinVelocity, JNumber3D.multiply(_force, (_invMass * _arg1)));
var _local2:JNumber3D = JNumber3D.multiply(_torque, _arg1);
JMatrix3D.multiplyVector(_worldInvInertia, _local2);
_currState.RotVelocity = JNumber3D.add(_currState.RotVelocity, _local2);
_currState.LinVelocity = JNumber3D.multiply(_currState.LinVelocity, 0.995);
_currState.RotVelocity = JNumber3D.multiply(_currState.RotVelocity, 0.995);
}
public function AddBodyForce(_arg1:JNumber3D, _arg2:JNumber3D):void{
if (!Getmovable()){
return;
};
JMatrix3D.multiplyVector(_currState.Orientation, _arg1);
JMatrix3D.multiplyVector(_currState.Orientation, _arg2);
AddWorldForce(_arg1, JNumber3D.add(_currState.Position, _arg2));
}
public function IsActive():Boolean{
return (_activity);
}
public function SetActive(_arg1:Number=1):void{
if (_movable){
_activity = true;
_inactiveTime = ((1 - _arg1) * JConfig.deactivationTime);
};
}
public function AddWorldTorque(_arg1:JNumber3D):void{
if (!Getmovable()){
return;
};
_torque = JNumber3D.add(_torque, _arg1);
_velChanged = true;
SetActive();
}
public function GetInertiaProperties(_arg1:Number):JMatrix3D{
return (new JMatrix3D());
}
public function setInertia(_arg1:JMatrix3D):void{
_bodyInertia = JMatrix3D.clone(_arg1);
_bodyInvInertia = JMatrix3D.inverse(_arg1);
_worldInertia = JMatrix3D.multiply(JMatrix3D.multiply(_currState.Orientation, _bodyInertia), _invOrientation);
_worldInvInertia = JMatrix3D.multiply(JMatrix3D.multiply(_currState.Orientation, _bodyInvInertia), _invOrientation);
}
}
}//package jiglib.physics
Section 86
//BitmapAsset (mx.core.BitmapAsset)
package mx.core {
import flash.display.*;
public class BitmapAsset extends FlexBitmap implements IFlexAsset, IFlexDisplayObject {
mx_internal static const VERSION:String = "3.2.0.3958";
public function BitmapAsset(_arg1:BitmapData=null, _arg2:String="auto", _arg3:Boolean=false){
super(_arg1, _arg2, _arg3);
}
public function get measuredWidth():Number{
if (bitmapData){
return (bitmapData.width);
};
return (0);
}
public function get measuredHeight():Number{
if (bitmapData){
return (bitmapData.height);
};
return (0);
}
public function setActualSize(_arg1:Number, _arg2:Number):void{
width = _arg1;
height = _arg2;
}
public function move(_arg1:Number, _arg2:Number):void{
this.x = _arg1;
this.y = _arg2;
}
}
}//package mx.core
Section 87
//ByteArrayAsset (mx.core.ByteArrayAsset)
package mx.core {
import flash.utils.*;
public class ByteArrayAsset extends ByteArray implements IFlexAsset {
mx_internal static const VERSION:String = "3.2.0.3958";
}
}//package mx.core
Section 88
//FlexBitmap (mx.core.FlexBitmap)
package mx.core {
import flash.display.*;
import mx.utils.*;
public class FlexBitmap extends Bitmap {
mx_internal static const VERSION:String = "3.2.0.3958";
public function FlexBitmap(_arg1:BitmapData=null, _arg2:String="auto", _arg3:Boolean=false){
var bitmapData = _arg1;
var pixelSnapping = _arg2;
var smoothing = _arg3;
super(bitmapData, pixelSnapping, smoothing);
try {
name = NameUtil.createUniqueName(this);
} catch(e:Error) {
};
}
override public function toString():String{
return (NameUtil.displayObjectToString(this));
}
}
}//package mx.core
Section 89
//IFlexAsset (mx.core.IFlexAsset)
package mx.core {
public interface IFlexAsset {
}
}//package mx.core
Section 90
//IFlexDisplayObject (mx.core.IFlexDisplayObject)
package mx.core {
import flash.events.*;
import flash.display.*;
import flash.geom.*;
import flash.accessibility.*;
public interface IFlexDisplayObject extends IBitmapDrawable, IEventDispatcher {
function get visible():Boolean;
function get rotation():Number;
function localToGlobal(_arg1:Point):Point;
function get name():String;
function set width(_arg1:Number):void;
function get measuredHeight():Number;
function get blendMode():String;
function get scale9Grid():Rectangle;
function set name(_arg1:String):void;
function set scaleX(_arg1:Number):void;
function set scaleY(_arg1:Number):void;
function get measuredWidth():Number;
function get accessibilityProperties():AccessibilityProperties;
function set scrollRect(_arg1:Rectangle):void;
function get cacheAsBitmap():Boolean;
function globalToLocal(_arg1:Point):Point;
function get height():Number;
function set blendMode(_arg1:String):void;
function get parent():DisplayObjectContainer;
function getBounds(_arg1:DisplayObject):Rectangle;
function get opaqueBackground():Object;
function set scale9Grid(_arg1:Rectangle):void;
function setActualSize(_arg1:Number, _arg2:Number):void;
function set alpha(_arg1:Number):void;
function set accessibilityProperties(_arg1:AccessibilityProperties):void;
function get width():Number;
function hitTestPoint(_arg1:Number, _arg2:Number, _arg3:Boolean=false):Boolean;
function set cacheAsBitmap(_arg1:Boolean):void;
function get scaleX():Number;
function get scaleY():Number;
function get scrollRect():Rectangle;
function get mouseX():Number;
function get mouseY():Number;
function set height(_arg1:Number):void;
function set mask(_arg1:DisplayObject):void;
function getRect(_arg1:DisplayObject):Rectangle;
function get alpha():Number;
function set transform(_arg1:Transform):void;
function move(_arg1:Number, _arg2:Number):void;
function get loaderInfo():LoaderInfo;
function get root():DisplayObject;
function hitTestObject(_arg1:DisplayObject):Boolean;
function set opaqueBackground(_arg1:Object):void;
function set visible(_arg1:Boolean):void;
function get mask():DisplayObject;
function set x(_arg1:Number):void;
function set y(_arg1:Number):void;
function get transform():Transform;
function set filters(_arg1:Array):void;
function get x():Number;
function get y():Number;
function get filters():Array;
function set rotation(_arg1:Number):void;
function get stage():Stage;
}
}//package mx.core
Section 91
//IRepeaterClient (mx.core.IRepeaterClient)
package mx.core {
public interface IRepeaterClient {
function get instanceIndices():Array;
function set instanceIndices(_arg1:Array):void;
function get isDocument():Boolean;
function set repeaters(_arg1:Array):void;
function initializeRepeaterArrays(_arg1:IRepeaterClient):void;
function get repeaters():Array;
function set repeaterIndices(_arg1:Array):void;
function get repeaterIndices():Array;
}
}//package mx.core
Section 92
//mx_internal (mx.core.mx_internal)
package mx.core {
public namespace mx_internal = "http://www.adobe.com/2006/flex/mx/internal";
}//package mx.core
Section 93
//NameUtil (mx.utils.NameUtil)
package mx.utils {
import flash.display.*;
import flash.utils.*;
import mx.core.*;
public class NameUtil {
mx_internal static const VERSION:String = "3.2.0.3958";
private static var counter:int = 0;
public static function displayObjectToString(_arg1:DisplayObject):String{
var result:String;
var o:DisplayObject;
var s:String;
var indices:Array;
var displayObject = _arg1;
try {
o = displayObject;
while (o != null) {
if (((((o.parent) && (o.stage))) && ((o.parent == o.stage)))){
break;
};
s = o.name;
if ((o is IRepeaterClient)){
indices = IRepeaterClient(o).instanceIndices;
if (indices){
s = (s + (("[" + indices.join("][")) + "]"));
};
};
result = ((result == null)) ? s : ((s + ".") + result);
o = o.parent;
};
} catch(e:SecurityError) {
};
return (result);
}
public static function createUniqueName(_arg1:Object):String{
if (!_arg1){
return (null);
};
var _local2:String = getQualifiedClassName(_arg1);
var _local3:int = _local2.indexOf("::");
if (_local3 != -1){
_local2 = _local2.substr((_local3 + 2));
};
var _local4:int = _local2.charCodeAt((_local2.length - 1));
if ((((_local4 >= 48)) && ((_local4 <= 57)))){
_local2 = (_local2 + "_");
};
return ((_local2 + counter++));
}
}
}//package mx.utils
Section 94
//DaeAccessor (org.ascollada.core.DaeAccessor)
package org.ascollada.core {
import org.ascollada.*;
public class DaeAccessor extends DaeEntity {
public var offset:uint;
public var params:Object;
public var stride:uint;
public var source:String;
public var count:uint;
public function DaeAccessor(_arg1:XML=null):void{
super(_arg1);
}
override public function read(_arg1:XML):void{
var _local4:XML;
var _local5:String;
var _local6:String;
if (_arg1.localName() != ASCollada.DAE_ACCESSOR_ELEMENT){
throw (new Error((("expected a " + ASCollada.DAE_ACCESSOR_ELEMENT) + " element")));
};
super.read(_arg1);
this.count = getAttributeAsInt(_arg1, ASCollada.DAE_COUNT_ATTRIBUTE);
this.offset = getAttributeAsInt(_arg1, ASCollada.DAE_OFFSET_ATTRIBUTE);
this.source = getAttribute(_arg1, ASCollada.DAE_SOURCE_ATTRIBUTE);
this.stride = getAttributeAsInt(_arg1, ASCollada.DAE_STRIDE_ATTRIBUTE, 1);
var _local2:XMLList = getNodeList(_arg1, ASCollada.DAE_PARAMETER);
this.params = new Object();
var _local3:int;
while (_local3 < _local2.length()) {
_local4 = _local2[_local3];
_local5 = getAttribute(_local4, ASCollada.DAE_NAME_ATTRIBUTE);
_local6 = getAttribute(_local4, ASCollada.DAE_TYPE_ATTRIBUTE);
this.params[_local5] = _local6;
_local3++;
};
}
}
}//package org.ascollada.core
Section 95
//DaeAnimation (org.ascollada.core.DaeAnimation)
package org.ascollada.core {
import org.ascollada.*;
public class DaeAnimation extends DaeEntity {
public var channels:Array;
public var animations:Array;
public function DaeAnimation(_arg1:XML=null):void{
super(_arg1);
}
private function parseAnimation(_arg1:XML):void{
var _local5:XML;
var _local6:XML;
var _local7:DaeChannel;
var _local8:XML;
var _local9:XMLList;
var _local10:uint;
var _local11:XML;
var _local12:DaeInput;
var _local13:DaeSource;
var _local14:DaeSampler;
var _local2:XMLList = getNodeList(_arg1, ASCollada.DAE_ANIMATION_ELEMENT);
var _local3:XMLList = getNodeList(_arg1, ASCollada.DAE_CHANNEL_ELEMENT);
var _local4:XMLList = getNodeList(_arg1, ASCollada.DAE_SAMPLER_ELEMENT);
if (_local2.length() > 0){
for each (_local6 in _local2) {
this.animations.push(new DaeAnimation(_local6));
};
} else {
if (_local3.length() == 0){
throw (new Error("require at least one <channel> element!"));
};
};
this.channels = new Array();
for each (_local5 in _local3) {
_local7 = new DaeChannel(_local5);
_local8 = getNodeById(_arg1, ASCollada.DAE_SAMPLER_ELEMENT, _local7.source);
_local9 = getNodeList(_local8, ASCollada.DAE_INPUT_ELEMENT);
_local10 = 12;
for each (_local11 in _local9) {
_local12 = new DaeInput(_local11);
_local13 = new DaeSource(getNodeById(_arg1, ASCollada.DAE_SOURCE_ELEMENT, _local12.source));
_local14 = new DaeSampler(_local8);
_local14.type = _local12.semantic;
_local14.values = _local13.values;
switch (_local12.semantic){
case "INTERPOLATION":
_local7.interpolations = _local14.values;
break;
case "INPUT":
_local7.input = _local14.values;
break;
case "OUTPUT":
_local7.output = _local14.values;
break;
default:
break;
};
};
this.channels.push(_local7);
};
}
override public function read(_arg1:XML):void{
this.animations = new Array();
this.channels = new Array();
if (_arg1.localName() != ASCollada.DAE_ANIMATION_ELEMENT){
throw (new Error((("expected a '" + ASCollada.DAE_ANIMATION_ELEMENT) + "' element")));
};
super.read(_arg1);
parseAnimation(_arg1);
}
}
}//package org.ascollada.core
Section 96
//DaeAnimationClip (org.ascollada.core.DaeAnimationClip)
package org.ascollada.core {
import org.ascollada.*;
import org.ascollada.utils.*;
public class DaeAnimationClip extends DaeEntity {
public var start:Number;
public var instance_animation:Array;
public var end:Number;
public function DaeAnimationClip(_arg1:XML=null):void{
this.start = 0;
this.end = 0;
this.instance_animation = new Array();
super(_arg1);
}
override public function read(_arg1:XML):void{
var _local3:XML;
var _local4:String;
if (_arg1.localName() != ASCollada.DAE_ANIMCLIP_ELEMENT){
throw (new Error((("expected a '" + ASCollada.DAE_ANIMCLIP_ELEMENT) + "' element")));
};
super.read(_arg1);
Logger.log(("reading animation_clip: " + this.id));
this.instance_animation = new Array();
this.start = getAttributeAsFloat(_arg1, ASCollada.DAE_START_ATTRIBUTE);
this.end = getAttributeAsFloat(_arg1, ASCollada.DAE_START_ATTRIBUTE);
var _local2:XMLList = getNodeList(_arg1, ASCollada.DAE_INSTANCE_ANIMATION_ELEMENT);
for each (_local3 in _local2) {
_local4 = getAttribute(_local3, ASCollada.DAE_URL_ATTRIBUTE);
this.instance_animation.push(_local4);
};
}
}
}//package org.ascollada.core
Section 97
//DaeAsset (org.ascollada.core.DaeAsset)
package org.ascollada.core {
import org.ascollada.*;
public class DaeAsset extends DaeEntity {
public var yUp:String;
public var unit_name:String;
public var contributors:Array;
public var modified:String;
public var keywords:String;
public var subject:String;
public var unit_meter:Number;
public var created:String;
public var revision:String;
public var title:String;
public function DaeAsset(_arg1:XML=null):void{
super(_arg1);
}
override public function write(_arg1:String=""):String{
var _local4:DaeContributor;
var _local2:String = writeSimpleStartElement(ASCollada.DAE_ASSET_ELEMENT, _arg1);
var _local3:int;
while (_local3 < this.contributors.length) {
_local4 = this.contributors[_local3];
_local2 = (_local2 + _local4.write((_arg1 + "\t")));
_local3++;
};
_local2 = (_local2 + writeSimpleEndElement(ASCollada.DAE_ASSET_ELEMENT, _arg1));
return (_local2);
}
private function parseContributors(_arg1:XML):void{
var _local3:XML;
var _local4:DaeContributor;
this.contributors = new Array();
var _local2:XMLList = getNodeList(_arg1, ASCollada.DAE_CONTRIBUTOR_ASSET_ELEMENT);
for each (_local3 in _local2) {
this.contributors.push(new DaeContributor(_local3));
};
if (!this.contributors.length){
_local4 = new DaeContributor();
_local4.author = "Tim Knip";
_local4.authoring_tool = "ASCollada";
_local4.comment = "";
_local4.source_data = "";
this.contributors.push(_local4);
};
}
override public function read(_arg1:XML):void{
if (_arg1.localName() != ASCollada.DAE_ASSET_ELEMENT){
throw (new Error((("expected a '" + ASCollada.DAE_ASSET_ELEMENT) + "' element")));
};
super.read(_arg1);
parseContributors(_arg1);
this.created = getNodeContent(getNode(_arg1, ASCollada.DAE_CREATED_ASSET_PARAMETER));
this.keywords = getNodeContent(getNode(_arg1, ASCollada.DAE_KEYWORDS_ASSET_PARAMETER));
this.modified = getNodeContent(getNode(_arg1, ASCollada.DAE_MODIFIED_ASSET_PARAMETER));
this.revision = getNodeContent(getNode(_arg1, ASCollada.DAE_REVISION_ASSET_PARAMETER));
this.subject = getNodeContent(getNode(_arg1, ASCollada.DAE_SUBJECT_ASSET_PARAMETER));
this.title = getNodeContent(getNode(_arg1, ASCollada.DAE_TITLE_ASSET_PARAMETER));
var _local2:XML = getNode(_arg1, ASCollada.DAE_UNITS_ASSET_PARAMETER);
this.unit_meter = (_local2) ? getAttributeAsFloat(_local2, ASCollada.DAE_METERS_ATTRIBUTE, 1) : 1;
this.unit_name = (_local2) ? getAttribute(_local2, ASCollada.DAE_NAME_ATTRIBUTE) : "meter";
var _local3:XML = getNode(_arg1, ASCollada.DAE_UP);
this.yUp = (_local3) ? _local3.toString() : ASCollada.DAE_Y_UP;
}
}
}//package org.ascollada.core
Section 98
//DaeBlendWeight (org.ascollada.core.DaeBlendWeight)
package org.ascollada.core {
public class DaeBlendWeight {
public var weight:Number;
public var originalWeight:Number;
public var joint:String;
public var vertexIndex:uint;
public function DaeBlendWeight(_arg1:uint=0, _arg2:String="", _arg3:Number=0){
this.vertexIndex = _arg1;
this.joint = _arg2;
this.originalWeight = (this.weight = _arg3);
}
public function toString():String{
return ((((((("[v:" + this.vertexIndex) + " j:") + this.joint) + " w:") + this.weight) + "]"));
}
}
}//package org.ascollada.core
Section 99
//DaeCamera (org.ascollada.core.DaeCamera)
package org.ascollada.core {
import org.ascollada.*;
public class DaeCamera extends DaeEntity {
public var type:uint;// = 0
public var aspect_ratio:Number;
public var near:Number;
public var fov:Number;
public var target:String;
public var mag:Number;
public var ortho:Boolean;// = false
public var far:Number;
public static const TYPE_X:uint = 0;
public static const TYPE_Y:uint = 1;
public function DaeCamera(_arg1:XML):void{
super(_arg1);
}
private function readTechniqueCommon(_arg1:XML):void{
var _local5:XML;
var _local2:XMLList = _arg1.children();
var _local3:int = _local2.length();
var _local4:int;
while (_local4 < _local3) {
_local5 = _local2[_local4];
switch (String(_local5.localName())){
case ASCollada.DAE_CAMERA_PERSP_ELEMENT:
this.ortho = false;
readPerspective(_local5);
break;
case ASCollada.DAE_CAMERA_ORTHO_ELEMENT:
this.ortho = true;
readOrthogonal(_local5);
break;
default:
break;
};
_local4++;
};
}
private function readOrthogonal(_arg1:XML):void{
var _local5:XML;
var _local2:XMLList = _arg1.children();
var _local3:int = _local2.length();
var _local4:int;
while (_local4 < _local3) {
_local5 = _local2[_local4];
switch (String(_local5.localName())){
case ASCollada.DAE_XMAG_CAMERA_PARAMETER:
this.type = TYPE_X;
this.fov = parseFloat(getNodeContent(_local5));
break;
case ASCollada.DAE_YMAG_CAMERA_PARAMETER:
this.type = TYPE_Y;
this.fov = parseFloat(getNodeContent(_local5));
break;
case ASCollada.DAE_ASPECT_CAMERA_PARAMETER:
this.aspect_ratio = parseFloat(getNodeContent(_local5));
break;
case ASCollada.DAE_ZNEAR_CAMERA_PARAMETER:
this.near = parseFloat(getNodeContent(_local5));
break;
case ASCollada.DAE_ZFAR_CAMERA_PARAMETER:
this.far = parseFloat(getNodeContent(_local5));
break;
default:
break;
};
_local4++;
};
}
private function readExtra(_arg1:XML):void{
var _local5:XML;
var _local6:XML;
var _local2:XMLList = _arg1.children();
var _local3:int = _local2.length();
var _local4:int;
while (_local4 < _local3) {
_local5 = _local2[_local4];
switch (String(_local5.localName())){
case ASCollada.DAE_TECHNIQUE_ELEMENT:
_local6 = getNode(_local5, ASCollada.DAEMAX_TARGET_CAMERA_PARAMETER);
if (_local6){
this.target = getNodeContent(_local6);
this.target = this.target.split("#")[1];
};
break;
default:
break;
};
_local4++;
};
}
private function readPerspective(_arg1:XML):void{
var _local5:XML;
var _local2:XMLList = _arg1.children();
var _local3:int = _local2.length();
var _local4:int;
while (_local4 < _local3) {
_local5 = _local2[_local4];
switch (String(_local5.localName())){
case ASCollada.DAE_XFOV_CAMERA_PARAMETER:
this.type = TYPE_X;
this.fov = parseFloat(getNodeContent(_local5));
break;
case ASCollada.DAE_YFOV_CAMERA_PARAMETER:
this.type = TYPE_Y;
this.fov = parseFloat(getNodeContent(_local5));
break;
case ASCollada.DAE_ASPECT_CAMERA_PARAMETER:
this.aspect_ratio = parseFloat(getNodeContent(_local5));
break;
case ASCollada.DAE_ZNEAR_CAMERA_PARAMETER:
this.near = parseFloat(getNodeContent(_local5));
break;
case ASCollada.DAE_ZFAR_CAMERA_PARAMETER:
this.far = parseFloat(getNodeContent(_local5));
break;
default:
break;
};
_local4++;
};
}
override public function read(_arg1:XML):void{
var _local5:XML;
if (_arg1.localName() != ASCollada.DAE_CAMERA_ELEMENT){
throw (new Error((("expected a '" + ASCollada.DAE_CAMERA_ELEMENT) + "' element")));
};
super.read(_arg1);
this.target = null;
var _local2:XMLList = _arg1.children();
var _local3:int = _local2.length();
var _local4:int;
while (_local4 < _local3) {
_local5 = _local2[_local4];
switch (String(_local5.localName())){
case ASCollada.DAE_OPTICS_ELEMENT:
readOptics(_local5);
break;
case ASCollada.DAE_EXTRA_ELEMENT:
readExtra(_local5);
break;
default:
break;
};
_local4++;
};
}
private function readOptics(_arg1:XML):void{
var _local5:XML;
var _local2:XMLList = _arg1.children();
var _local3:int = _local2.length();
var _local4:int;
while (_local4 < _local3) {
_local5 = _local2[_local4];
switch (String(_local5.localName())){
case ASCollada.DAE_TECHNIQUE_COMMON_ELEMENT:
readTechniqueCommon(_local5);
break;
default:
break;
};
_local4++;
};
}
}
}//package org.ascollada.core
Section 100
//DaeChannel (org.ascollada.core.DaeChannel)
package org.ascollada.core {
import org.ascollada.types.*;
import org.ascollada.*;
public class DaeChannel extends DaeEntity {
public var output:Array;
public var syntax:DaeAddressSyntax;
public var curves:Array;
public var input:Array;
public var interpolations:Array;
public var target:String;
public var source:String;
public function DaeChannel(_arg1:XML):void{
super(_arg1);
this.curves = new Array();
}
public function update(_arg1:Number):Array{
if (!this.curves){
return (null);
};
var _local2:Array = new Array(this.curves.length);
var _local3:int;
while (_local3 < this.curves.length) {
_local2[_local3] = this.curves[_local3].evaluate(_arg1);
_local3++;
};
return (_local2);
}
override public function read(_arg1:XML):void{
if (_arg1.localName() != ASCollada.DAE_CHANNEL_ELEMENT){
throw (new Error((("expected a '" + ASCollada.DAE_CHANNEL_ELEMENT) + "' element")));
};
super.read(_arg1);
this.source = getAttribute(_arg1, ASCollada.DAE_SOURCE_ATTRIBUTE);
this.target = getAttribute(_arg1, ASCollada.DAE_TARGET_ATTRIBUTE);
this.syntax = DaeAddressSyntax.parseAnimationTarget(this.target);
}
}
}//package org.ascollada.core
Section 101
//DaeContributor (org.ascollada.core.DaeContributor)
package org.ascollada.core {
import org.ascollada.*;
public class DaeContributor extends DaeEntity {
public var authoring_tool:String;
public var source_data:String;
public var author:String;
public var comment:String;
public function DaeContributor(_arg1:XML=null):void{
super(_arg1);
}
override public function write(_arg1:String=""):String{
var _local2:String = writeSimpleStartElement(ASCollada.DAE_CONTRIBUTOR_ASSET_ELEMENT, _arg1);
_local2 = (_local2 + writeSimpleEndElement(ASCollada.DAE_CONTRIBUTOR_ASSET_ELEMENT, _arg1));
return (_local2);
}
override public function read(_arg1:XML):void{
super.read(_arg1);
var _local2:XML = getNode(_arg1, ASCollada.DAE_AUTHOR_ASSET_PARAMETER);
var _local3:XML = getNode(_arg1, ASCollada.DAE_AUTHORINGTOOL_ASSET_PARAMETER);
var _local4:XML = getNode(_arg1, ASCollada.DAE_COMMENTS_ASSET_PARAMETER);
var _local5:XML = getNode(_arg1, ASCollada.DAE_SOURCEDATA_ASSET_PARAMETER);
this.author = (_local2) ? _local2.toString() : "";
this.authoring_tool = (_local3) ? _local3.toString() : "";
this.comment = (_local4) ? _local4.toString() : "";
this.source_data = (_local5) ? _local5.toString() : "";
}
}
}//package org.ascollada.core
Section 102
//DaeController (org.ascollada.core.DaeController)
package org.ascollada.core {
import org.ascollada.*;
import org.ascollada.utils.*;
public class DaeController extends DaeEntity {
public var type:uint;
public var morph:DaeMorph;
public var skin:DaeSkin;
public static const TYPE_SKIN:uint = 0;
public static const TYPE_MORPH:uint = 1;
public function DaeController(_arg1:XML=null):void{
super(_arg1);
}
override public function read(_arg1:XML):void{
var _local3:XML;
if (_arg1.localName() != ASCollada.DAE_CONTROLLER_ELEMENT){
return;
};
super.read(_arg1);
Logger.log(("reading controller: " + this.id));
var _local2:XML = getNode(_arg1, ASCollada.DAE_CONTROLLER_SKIN_ELEMENT);
if (_local2){
this.skin = new DaeSkin(_local2);
this.type = TYPE_SKIN;
} else {
_local3 = getNode(_arg1, ASCollada.DAE_CONTROLLER_MORPH_ELEMENT);
if (_local3){
this.morph = new DaeMorph(_local3);
this.type = TYPE_MORPH;
};
};
if (((!(this.skin)) && (!(this.morph)))){
throw (new Error("controller element should contain a <skin> or a <morph> element!"));
};
if (this.type == TYPE_SKIN){
};
}
}
}//package org.ascollada.core
Section 103
//DaeDocument (org.ascollada.core.DaeDocument)
package org.ascollada.core {
import org.ascollada.fx.*;
import org.ascollada.physics.*;
import org.ascollada.*;
import org.ascollada.utils.*;
import org.ascollada.namespaces.*;
public class DaeDocument extends DaeEntity {
public var effects:Object;
public var geometries:Object;
public var COLLADA:XML;
public var pscene:DaePhysicsScene;
private var _waitingAnimations:Array;
public var animation_clips:Object;
public var materialSymbolToTarget:Object;
public var materials:Object;
public var nodes:Object;
public var materialTargetToSymbol:Object;
private var _waitingGeometries:Array;
public var visual_scenes:Object;
public var controllers:Object;
public var vscene:DaeVisualScene;
public var physics_scenes:Object;
public var version:String;
public var yUp:uint;
public var cameras:Object;
public var animations:Object;
public var images:Object;
public static const Z_UP:uint = 2;
public static const Y_UP:uint = 1;
public static const X_UP:uint = 0;
public function DaeDocument(_arg1:Object, _arg2:Boolean=false){
this.COLLADA = ((_arg1 is XML)) ? (_arg1 as XML) : new XML(_arg1);
XML.ignoreWhitespace = true;
super(this.COLLADA, _arg2);
}
private function readLibVisualScenes():void{
var _local2:XMLList;
var _local3:XML;
var _local4:DaeVisualScene;
this.visual_scenes = new Object();
var _local1:XML = getNode(this.COLLADA, ASCollada.DAE_LIBRARY_VSCENE_ELEMENT);
if (_local1){
_local2 = getNodeList(_local1, ASCollada.DAE_VSCENE_ELEMENT);
for each (_local3 in _local2) {
_local4 = new DaeVisualScene(_local3, yUp);
this.visual_scenes[_local4.id] = _local4;
this.vscene = _local4;
};
};
}
public function get numQueuedGeometries():uint{
return (_waitingGeometries.length);
}
private function readLibImages():void{
var _local2:XMLList;
var _local3:XML;
var _local4:DaeImage;
this.images = new Object();
var _local1:XML = getNode(this.COLLADA, ASCollada.DAE_LIBRARY_IMAGE_ELEMENT);
if (_local1){
_local2 = getNodeList(_local1, ASCollada.DAE_IMAGE_ELEMENT);
for each (_local3 in _local2) {
_local4 = new DaeImage(_local3);
this.images[_local4.id] = _local4;
};
};
}
override public function read(_arg1:XML):void{
this.version = _arg1.attribute(ASCollada.DAE_VERSION_ATTRIBUTE).toString();
Logger.log(("version: " + this.version));
this.asset = new DaeAsset(getNode(this.COLLADA, ASCollada.DAE_ASSET_ELEMENT));
if (((this.asset.contributors) && (this.asset.contributors[0].author))){
Logger.log(("author: " + this.asset.contributors[0].author));
};
Logger.log(("created: " + this.asset.created));
Logger.log(("modified: " + this.asset.modified));
Logger.log(("y-up: " + this.asset.yUp));
Logger.log(("unit_meter: " + this.asset.unit_meter));
Logger.log(("unit_name: " + this.asset.unit_name));
if (this.asset.yUp == ASCollada.DAE_Y_UP){
this.yUp = Y_UP;
} else {
this.yUp = Z_UP;
};
buildMaterialTable();
readLibAnimationClips();
readLibCameras();
readLibControllers();
readLibAnimations();
readLibImages();
readLibMaterials();
readLibEffects();
readLibGeometries(this.async);
readLibNodes();
readLibPhysicsScenes();
readLibVisualScenes();
readScene();
}
private function buildMaterialTable():void{
var _local2:XML;
var _local3:String;
var _local4:String;
materialSymbolToTarget = new Object();
materialTargetToSymbol = new Object();
var _local1:XMLList = this.COLLADA..collada::instance_material;
for each (_local2 in _local1) {
_local3 = getAttribute(_local2, ASCollada.DAE_TARGET_ATTRIBUTE);
_local4 = getAttribute(_local2, ASCollada.DAE_SYMBOL_ATTRIBUTE);
materialSymbolToTarget[_local4] = _local3;
materialTargetToSymbol[_local3] = _local4;
};
}
private function findDaeNodeById(_arg1:DaeNode, _arg2:String, _arg3:Boolean=false):DaeNode{
var _local5:DaeNode;
if (_arg3){
if (_arg1.sid == _arg2){
return (_arg1);
};
} else {
if (_arg1.id == _arg2){
return (_arg1);
};
};
var _local4:int;
while (_local4 < _arg1.nodes.length) {
_local5 = findDaeNodeById(_arg1.nodes[_local4], _arg2, _arg3);
if (_local5){
return (_local5);
};
_local4++;
};
return (null);
}
public function getDaeNodeByIdOrSID(_arg1:String):DaeNode{
var _local2:DaeNode = getDaeNodeById(_arg1, false);
if (!_local2){
_local2 = getDaeNodeById(_arg1, true);
};
return (_local2);
}
public function readNextGeometry():Boolean{
var geometry:DaeGeometry;
var geomLib:XML;
var geomNode:XML;
if (_waitingGeometries.length){
try {
geometry = (_waitingGeometries.shift() as DaeGeometry);
geomLib = getNode(this.COLLADA, ASCollada.DAE_LIBRARY_GEOMETRY_ELEMENT);
geomNode = getNodeById(geomLib, ASCollada.DAE_GEOMETRY_ELEMENT, geometry.id);
geometry.async = false;
geometry.read(geomNode);
this.geometries[geometry.id] = geometry;
} catch(e:Error) {
Logger.error(("[ERROR] DaeDocument#readNextGeometry : " + e.toString()));
};
return (true);
//unresolved jump
};
return (false);
}
private function readLibPhysicsScenes():void{
var _local2:XMLList;
var _local3:XML;
var _local4:DaePhysicsScene;
this.physics_scenes = new Object();
var _local1:XML = getNode(this.COLLADA, ASCollada.DAE_LIBRARY_PSCENE_ELEMENT);
if (_local1){
_local2 = getNodeList(_local1, ASCollada.DAE_PHYSICS_SCENE_ELEMENT);
for each (_local3 in _local2) {
_local4 = new DaePhysicsScene(_local3);
this.physics_scenes[_local4.id] = _local4;
};
};
}
private function readScene():void{
var _local2:XML;
var _local3:XML;
var _local4:String;
var _local5:String;
var _local1:XML = getNode(this.COLLADA, ASCollada.DAE_SCENE_ELEMENT);
if (_local1){
_local2 = getNode(_local1, ASCollada.DAE_INSTANCE_VSCENE_ELEMENT);
if (_local2){
_local4 = getAttribute(_local2, ASCollada.DAE_URL_ATTRIBUTE);
if ((this.visual_scenes[_local4] is DaeVisualScene)){
Logger.log(("found visual scene: " + _local4));
this.vscene = this.visual_scenes[_local4];
Logger.log((" -> frameRate: " + this.vscene.frameRate));
Logger.log((" -> startTime: " + this.vscene.startTime));
Logger.log((" -> endTime: " + this.vscene.endTime));
};
};
_local3 = getNode(_local1, ASCollada.DAE_INSTANCE_PHYSICS_SCENE_ELEMENT);
if (_local3){
_local5 = getAttribute(_local3, ASCollada.DAE_URL_ATTRIBUTE);
if ((this.physics_scenes[_local5] is DaePhysicsScene)){
Logger.log(("found physics scene: " + _local5));
this.pscene = this.physics_scenes[_local5];
};
};
};
}
private function readLibControllers():void{
var _local2:XMLList;
var _local3:XML;
var _local4:DaeController;
this.controllers = new Object();
var _local1:XML = getNode(this.COLLADA, ASCollada.DAE_LIBRARY_CONTROLLER_ELEMENT);
if (_local1){
_local2 = getNodeList(_local1, ASCollada.DAE_CONTROLLER_ELEMENT);
for each (_local3 in _local2) {
_local4 = new DaeController(_local3);
this.controllers[_local4.id] = _local4;
};
};
}
public function getDaeInstanceGeometry(_arg1:String):DaeInstanceGeometry{
var _local2:DaeNode;
var _local3:DaeInstanceGeometry;
for each (_local2 in this.vscene.nodes) {
_local3 = findDaeInstanceGeometry(_local2, _arg1);
if (_local3){
return (_local3);
};
};
return (null);
}
private function findDaeInstanceGeometry(_arg1:DaeNode, _arg2:String):DaeInstanceGeometry{
var _local3:DaeInstanceGeometry;
var _local4:DaeNode;
var _local5:DaeInstanceGeometry;
for each (_local3 in _arg1.geometries) {
if (_local3.url == _arg2){
return (_local3);
};
};
for each (_local4 in _arg1.nodes) {
_local5 = findDaeInstanceGeometry(_local4, _arg2);
if (_local5){
return (_local5);
};
};
return (null);
}
public function readNextAnimation():Boolean{
var animation:DaeAnimation;
var animLib:XML;
var animNode:XML;
if (_waitingAnimations.length){
try {
animation = (_waitingAnimations.shift() as DaeAnimation);
animLib = getNode(this.COLLADA, ASCollada.DAE_LIBRARY_ANIMATION_ELEMENT);
animNode = getNodeById(animLib, ASCollada.DAE_ANIMATION_ELEMENT, animation.id);
animation.read(animNode);
} catch(e:Error) {
Logger.error(("[ERROR] DaeDocument#readNextAnimation : " + e.toString()));
};
return (true);
//unresolved jump
};
return (false);
}
private function readLibMaterials():void{
var _local2:XMLList;
var _local3:XML;
var _local4:DaeMaterial;
this.materials = new Object();
var _local1:XML = getNode(this.COLLADA, ASCollada.DAE_LIBRARY_MATERIAL_ELEMENT);
if (_local1){
_local2 = getNodeList(_local1, ASCollada.DAE_MATERIAL_ELEMENT);
for each (_local3 in _local2) {
_local4 = new DaeMaterial(_local3);
this.materials[_local4.id] = _local4;
};
};
}
public function getDaeNodeById(_arg1:String, _arg2:Boolean=false):DaeNode{
var _local3:DaeNode;
var _local4:int;
var _local5:DaeNode;
var _local6:DaeNode;
var _local7:DaeNode;
for each (_local3 in this.nodes) {
_local5 = findDaeNodeById(_local3, _arg1, _arg2);
if (_local5){
return (_local5);
};
};
_local4 = 0;
while (_local4 < this.vscene.nodes.length) {
_local6 = this.vscene.nodes[_local4];
_local7 = findDaeNodeById(_local6, _arg1, _arg2);
if (_local7){
return (_local7);
};
_local4++;
};
return (null);
}
private function readLibNodes():void{
var _local2:XMLList;
var _local3:XML;
var _local4:DaeNode;
this.nodes = new Object();
var _local1:XML = getNode(this.COLLADA, ASCollada.DAE_LIBRARY_NODE_ELEMENT);
if (_local1){
_local2 = getNodeList(_local1, ASCollada.DAE_NODE_ELEMENT);
for each (_local3 in _local2) {
_local4 = new DaeNode(_local3);
this.nodes[_local4.id] = _local4;
};
};
}
private function readLibAnimations():void{
var _local2:XMLList;
var _local3:XML;
var _local4:DaeAnimation;
_waitingAnimations = new Array();
this.animations = new Object();
var _local1:XML = getNode(this.COLLADA, ASCollada.DAE_LIBRARY_ANIMATION_ELEMENT);
if (_local1){
_local2 = getNodeList(_local1, ASCollada.DAE_ANIMATION_ELEMENT);
for each (_local3 in _local2) {
_local4 = new DaeAnimation();
_local4.id = _local3.attribute(ASCollada.DAE_ID_ATTRIBUTE).toString();
this.animations[_local4.id] = _local4;
_waitingAnimations.push(_local4);
};
};
}
public function get numQueuedAnimations():uint{
return (_waitingAnimations.length);
}
private function readLibEffects():void{
var _local2:XMLList;
var _local3:XML;
var _local4:DaeEffect;
this.effects = new Object();
var _local1:XML = getNode(this.COLLADA, ASCollada.DAE_LIBRARY_EFFECT_ELEMENT);
if (_local1){
_local2 = getNodeList(_local1, ASCollada.DAE_EFFECT_ELEMENT);
for each (_local3 in _local2) {
_local4 = new DaeEffect(_local3);
this.effects[_local4.id] = _local4;
};
};
}
private function readLibCameras():void{
var _local2:XMLList;
var _local3:XML;
var _local4:DaeCamera;
this.cameras = new Object();
var _local1:XML = getNode(this.COLLADA, ASCollada.DAE_LIBRARY_CAMERA_ELEMENT);
if (_local1){
_local2 = getNodeList(_local1, ASCollada.DAE_CAMERA_ELEMENT);
for each (_local3 in _local2) {
_local4 = new DaeCamera(_local3);
this.cameras[_local4.id] = _local4;
};
};
}
private function readLibAnimationClips():void{
var _local2:XMLList;
var _local3:XML;
var _local4:DaeAnimationClip;
this.animation_clips = new Object();
var _local1:XML = getNode(this.COLLADA, ASCollada.DAE_LIBRARY_ANIMATION_CLIP_ELEMENT);
if (_local1){
_local2 = getNodeList(_local1, ASCollada.DAE_ANIMCLIP_ELEMENT);
for each (_local3 in _local2) {
_local4 = new DaeAnimationClip(_local3);
this.animation_clips[_local4.id] = _local4;
};
};
}
private function readLibGeometries(_arg1:Boolean=false):void{
var _local3:XMLList;
var _local4:XML;
var _local5:DaeGeometry;
_waitingGeometries = new Array();
this.geometries = new Object();
var _local2:XML = getNode(this.COLLADA, ASCollada.DAE_LIBRARY_GEOMETRY_ELEMENT);
if (_local2){
_local3 = getNodeList(_local2, ASCollada.DAE_GEOMETRY_ELEMENT);
for each (_local4 in _local3) {
_local5 = new DaeGeometry(_local4, _arg1);
if (_arg1){
_waitingGeometries.push(_local5);
} else {
this.geometries[_local5.id] = _local5;
};
};
};
}
}
}//package org.ascollada.core
Section 104
//DaeEntity (org.ascollada.core.DaeEntity)
package org.ascollada.core {
import org.ascollada.*;
import org.ascollada.utils.*;
import org.ascollada.namespaces.*;
public class DaeEntity {
public var name:String;
public var sid:String;
public var id:String;
public var extras:Object;
public var asset:DaeAsset;
public var async:Boolean;
public function DaeEntity(_arg1:XML=null, _arg2:Boolean=false){
this.async = _arg2;
if (_arg1){
read(_arg1);
};
}
public function getAttributeAsFloat(_arg1:XML, _arg2:String, _arg3:Number=0):Number{
var _local4:String = getAttribute(_arg1, _arg2);
return ((isNaN(parseFloat(_local4))) ? _arg3 : parseFloat(_local4));
}
public function getStrings(_arg1:XML):Array{
return (StringUtil.trim(_arg1.text().toString()).split(/\s+/));
}
public function getFloats(_arg1:XML):Array{
var _local2:Array = getStrings(_arg1);
var _local3:int;
while (_local3 < _local2.length) {
_local2[_local3] = parseFloat(_local2[_local3]);
_local3++;
};
return (_local2);
}
public function writeSimpleStartElement(_arg1:String, _arg2:String=""):String{
return ((((_arg2 + "<") + _arg1) + ">\n"));
}
public function getBools(_arg1:XML):Array{
var _local2:Array = getStrings(_arg1);
var _local3:int;
while (_local3 < _local2.length) {
_local2[_local3] = ((_local2[_local3] == "true")) ? true : false;
_local3++;
};
return (_local2);
}
public function getAttributeAsInt(_arg1:XML, _arg2:String, _arg3:int=0):int{
var _local4:String = getAttribute(_arg1, _arg2);
return ((isNaN(parseInt(_local4, 10))) ? _arg3 : parseInt(_local4, 10));
}
public function getInts(_arg1:XML):Array{
var _local2:Array = getStrings(_arg1);
var _local3:int;
while (_local3 < _local2.length) {
_local2[_local3] = parseInt(StringUtil.trim(_local2[_local3]), 10);
_local3++;
};
return (_local2);
}
public function read(_arg1:XML):void{
this.extras = new Object();
this.id = getAttribute(_arg1, ASCollada.DAE_ID_ATTRIBUTE);
this.name = getAttribute(_arg1, ASCollada.DAE_NAME_ATTRIBUTE);
this.sid = getAttribute(_arg1, ASCollada.DAE_SID_ATTRIBUTE);
}
public function write(_arg1:String=""):String{
return (_arg1);
}
public function getNodeContent(_arg1:XML):String{
return ((_arg1) ? _arg1.text().toString() : "");
}
public function getAttribute(_arg1:XML, _arg2:String, _arg3:Boolean=true):String{
var _local4:XMLList = _arg1.attribute(_arg2);
var _local5:String = (_local4.length()) ? _local4.toString() : "";
if (((_arg3) && ((_local5.indexOf("#") == 0)))){
_local5 = _local5.split("#")[1];
};
return (_local5);
}
public function getNodeById(_arg1:XML, _arg2:String, _arg3:String):XML{
var parent = _arg1;
var nodeName = _arg2;
var id = _arg3;
return (parentcollada::[nodeName].(@[ASCollada.DAE_ID_ATTRIBUTE] == id)[0]);
}
public function writeSimpleEndElement(_arg1:String, _arg2:String=""):String{
return ((((_arg2 + "</") + _arg1) + ">\n"));
}
public function getNodeList(_arg1:XML, _arg2:String):XMLList{
return (_arg1collada::[_arg2]);
}
public function getNode(_arg1:XML, _arg2:String):XML{
return (_arg1collada::[_arg2][0]);
}
}
}//package org.ascollada.core
Section 105
//DaeGeometry (org.ascollada.core.DaeGeometry)
package org.ascollada.core {
import org.ascollada.physics.*;
import org.ascollada.*;
import org.ascollada.utils.*;
public class DaeGeometry extends DaeEntity {
public var spline:DaeSpline;
public var splines:Array;
public var convex_mesh:DaeConvexMesh;
public var mesh:DaeMesh;
public function DaeGeometry(_arg1:XML=null, _arg2:Boolean=false){
super(_arg1, _arg2);
}
override public function read(_arg1:XML):void{
var _local3:XMLList;
var _local4:int;
var _local5:int;
super.read(_arg1);
Logger.log(("reading geometry: " + this.id));
this.mesh = null;
this.convex_mesh = null;
this.spline = null;
this.splines = new Array();
if (async){
return;
};
var _local2:XML = getNode(_arg1, ASCollada.DAE_CONVEX_MESH_ELEMENT);
if (!_local2){
_local2 = getNode(_arg1, ASCollada.DAE_MESH_ELEMENT);
if (!_local2){
_local2 = getNode(_arg1, ASCollada.DAE_SPLINE_ELEMENT);
};
};
if (!_local2){
Logger.error("expected one of <convex_mesh>, <mesh> or <spline>!");
throw (new Error("expected one of <convex_mesh>, <mesh> or <spline>!"));
};
switch (_local2.localName()){
case ASCollada.DAE_CONVEX_MESH_ELEMENT:
this.convex_mesh = new DaeConvexMesh(this, _local2);
break;
case ASCollada.DAE_MESH_ELEMENT:
this.mesh = new DaeMesh(this, _local2);
break;
case ASCollada.DAE_SPLINE_ELEMENT:
this.spline = new DaeSpline(_local2);
_local3 = getNodeList(_arg1, ASCollada.DAE_SPLINE_ELEMENT);
_local4 = _local3.length();
_local5 = 0;
while (_local5 < _local4) {
this.splines.push(new DaeSpline(_local3[_local5]));
_local5++;
};
break;
default:
break;
};
}
}
}//package org.ascollada.core
Section 106
//DaeImage (org.ascollada.core.DaeImage)
package org.ascollada.core {
import flash.display.*;
import org.ascollada.*;
import org.ascollada.utils.*;
public class DaeImage extends DaeEntity {
public var bitmapData:BitmapData;
public var init_from:String;
public function DaeImage(_arg1:XML=null){
this.init_from = "";
super(_arg1);
}
override public function read(_arg1:XML):void{
var _local5:XML;
super.read(_arg1);
var _local2:XMLList = _arg1.children();
var _local3:int = _local2.length();
var _local4:int;
while (_local4 < _local3) {
_local5 = _local2[_local4];
switch (_local5.localName()){
case ASCollada.DAE_ASSET_ELEMENT:
this.asset = new DaeAsset(_local5);
break;
case ASCollada.DAE_DATA_ELEMENT:
break;
case ASCollada.DAE_INITFROM_ELEMENT:
this.init_from = unescape(_local5.text().toString());
this.init_from.split("\\").join("/");
Logger.log((((" => " + this.id) + " init_from: ") + this.init_from));
break;
case ASCollada.DAE_EXTRA_ELEMENT:
break;
default:
break;
};
_local4++;
};
}
}
}//package org.ascollada.core
Section 107
//DaeInput (org.ascollada.core.DaeInput)
package org.ascollada.core {
import org.ascollada.*;
public class DaeInput extends DaeEntity {
public var offset:uint;
public var setId:uint;
public var semantic:String;
public var source:String;
public function DaeInput(_arg1:XML=null):void{
super(_arg1);
}
override public function read(_arg1:XML):void{
if (_arg1.localName() != ASCollada.DAE_INPUT_ELEMENT){
return;
};
super.read(_arg1);
this.semantic = getAttribute(_arg1, ASCollada.DAE_SEMANTIC_ATTRIBUTE);
this.source = getAttribute(_arg1, ASCollada.DAE_SOURCE_ATTRIBUTE);
this.offset = parseInt(getAttribute(_arg1, ASCollada.DAE_OFFSET_ATTRIBUTE), 10);
this.offset = (this.offset) ? this.offset : 0;
this.setId = parseInt(getAttribute(_arg1, ASCollada.DAE_SET_ATTRIBUTE), 10);
}
}
}//package org.ascollada.core
Section 108
//DaeInstanceController (org.ascollada.core.DaeInstanceController)
package org.ascollada.core {
import org.ascollada.fx.*;
import org.ascollada.*;
import org.ascollada.utils.*;
public class DaeInstanceController extends DaeEntity {
public var materials:Array;
public var skeletons:Array;
public var skeleton:String;
public var url:String;
public function DaeInstanceController(_arg1:XML=null){
super(_arg1);
}
override public function read(_arg1:XML):void{
var _local4:String;
var _local6:XML;
super.read(_arg1);
this.url = getAttribute(_arg1, ASCollada.DAE_URL_ATTRIBUTE);
this.materials = new Array();
Logger.log((" => " + this.url));
this.skeleton = null;
this.skeletons = new Array();
var _local2:XMLList = _arg1.children();
var _local3:int = _local2.length();
var _local5:int;
while (_local5 < _local3) {
_local6 = _local2[_local5];
switch (_local6.localName()){
case ASCollada.DAE_SKELETON_ELEMENT:
_local4 = getNodeContent(_local6).toString();
_local4 = ((_local4.indexOf("#"))!=-1) ? _local4.substr(1) : _local4;
this.skeletons.push(_local4);
if (!this.skeleton){
this.skeleton = _local4;
};
Logger.log((" => skeleton: " + _local4));
break;
case ASCollada.DAE_BINDMATERIAL_ELEMENT:
this.materials = parseBindMaterial(_local6);
break;
case ASCollada.DAE_EXTRA_ELEMENT:
break;
default:
break;
};
_local5++;
};
}
private function parseBindMaterial(_arg1:XML):Array{
var _local6:XML;
var _local7:Array;
var _local8:XMLList;
var _local9:XML;
var _local2:Array = new Array();
var _local3:XMLList = _arg1.children();
var _local4:int = _local3.length();
var _local5:int;
while (_local5 < _local4) {
_local6 = _local3[_local5];
switch (_local6.localName()){
case ASCollada.DAE_TECHNIQUE_COMMON_ELEMENT:
_local8 = _local6.children();
for each (_local9 in _local8) {
_local2.push(new DaeInstanceMaterial(_local9));
};
break;
default:
break;
};
_local5++;
};
return (_local2);
}
}
}//package org.ascollada.core
Section 109
//DaeInstanceGeometry (org.ascollada.core.DaeInstanceGeometry)
package org.ascollada.core {
import org.ascollada.fx.*;
import org.ascollada.*;
public class DaeInstanceGeometry extends DaeEntity {
public var materials:Array;
public var url:String;
public function DaeInstanceGeometry(_arg1:XML=null){
super(_arg1);
}
public function findBindVertexInput(_arg1:String, _arg2:String):DaeBindVertexInput{
var _local3:DaeInstanceMaterial;
for each (_local3 in this.materials) {
if (_arg1 == _local3.symbol){
return (_local3.findBindVertexInput(_arg2));
};
};
return (null);
}
override public function read(_arg1:XML):void{
var _local5:XML;
var _local6:Array;
super.read(_arg1);
this.url = getAttribute(_arg1, ASCollada.DAE_URL_ATTRIBUTE);
this.materials = new Array();
var _local2:XMLList = _arg1.children();
var _local3:int = _local2.length();
var _local4:int;
while (_local4 < _local3) {
_local5 = _local2[_local4];
switch (_local5.localName()){
case ASCollada.DAE_BINDMATERIAL_ELEMENT:
this.materials = parseBindMaterial(_local5);
break;
default:
break;
};
_local4++;
};
}
private function parseBindMaterial(_arg1:XML):Array{
var _local6:XML;
var _local7:Array;
var _local8:XMLList;
var _local9:XML;
var _local2:Array = new Array();
var _local3:XMLList = _arg1.children();
var _local4:int = _local3.length();
var _local5:int;
while (_local5 < _local4) {
_local6 = _local3[_local5];
switch (_local6.localName()){
case ASCollada.DAE_TECHNIQUE_COMMON_ELEMENT:
_local8 = _local6.children();
for each (_local9 in _local8) {
_local2.push(new DaeInstanceMaterial(_local9));
};
break;
default:
break;
};
_local5++;
};
return (_local2);
}
}
}//package org.ascollada.core
Section 110
//DaeInstanceNode (org.ascollada.core.DaeInstanceNode)
package org.ascollada.core {
import org.ascollada.*;
public class DaeInstanceNode extends DaeEntity {
public var url:String;
public function DaeInstanceNode(_arg1:XML=null){
super(_arg1);
}
override public function read(_arg1:XML):void{
super.read(_arg1);
this.url = getAttribute(_arg1, ASCollada.DAE_URL_ATTRIBUTE);
}
}
}//package org.ascollada.core
Section 111
//DaeMesh (org.ascollada.core.DaeMesh)
package org.ascollada.core {
import org.ascollada.*;
public class DaeMesh extends DaeEntity {
public var geometry:DaeGeometry;
public var sources:Object;
public var vertices:Array;
public var primitives:Array;
public function DaeMesh(_arg1:DaeGeometry, _arg2:XML=null){
super(_arg2);
this.geometry = _arg1;
}
override public function read(_arg1:XML):void{
var _local3:XML;
var _local4:DaeSource;
var _local5:XML;
var _local6:DaeVertices;
var _local7:DaeInput;
var _local8:XMLList;
var _local9:int;
var _local10:int;
var _local11:XML;
var _local12:DaePrimitive;
if (((!((_arg1.localName() == ASCollada.DAE_MESH_ELEMENT))) && (!((_arg1.localName() == ASCollada.DAE_CONVEX_MESH_ELEMENT))))){
throw (new Error((((("expected a '" + ASCollada.DAE_MESH_ELEMENT) + " or a '") + ASCollada.DAE_CONVEX_MESH_ELEMENT) + "' element")));
};
super.read(_arg1);
this.sources = new Object();
this.primitives = new Array();
var _local2:XMLList = getNodeList(_arg1, ASCollada.DAE_SOURCE_ELEMENT);
for each (_local3 in _local2) {
_local4 = new DaeSource(_local3);
this.sources[_local4.id] = _local4.values;
};
_local5 = getNode(_arg1, ASCollada.DAE_VERTICES_ELEMENT);
_local6 = new DaeVertices(_local5);
for each (_local7 in _local6.inputs) {
if (_local7.semantic == "POSITION"){
this.vertices = sources[_local7.source];
this.sources[_local6.id] = sources[_local7.source];
};
};
_local8 = _arg1.children();
_local9 = _local8.length();
_local10 = 0;
while (_local10 < _local9) {
_local11 = _local8[_local10];
switch (String(_local11.localName())){
case ASCollada.DAE_TRIANGLES_ELEMENT:
case ASCollada.DAE_TRIFANS_ELEMENT:
case ASCollada.DAE_TRISTRIPS_ELEMENT:
case ASCollada.DAE_LINESTRIPS_ELEMENT:
case ASCollada.DAE_LINES_ELEMENT:
case ASCollada.DAE_POLYGONS_ELEMENT:
case ASCollada.DAE_POLYLIST_ELEMENT:
_local12 = new DaePrimitive(this, _local11);
if (_local12.count > 0){
this.primitives.push(_local12);
};
break;
default:
break;
};
_local10++;
};
}
}
}//package org.ascollada.core
Section 112
//DaeMorph (org.ascollada.core.DaeMorph)
package org.ascollada.core {
import org.ascollada.*;
import org.ascollada.utils.*;
public class DaeMorph extends DaeEntity {
public var method:String;
public var targets:Array;
public var weights:Array;
public var source:String;
public static const METHOD_RELATIVE:String = "RELATIVE";
public static const METHOD_NORMALIZED:String = "NORMALIZED";
public function DaeMorph(_arg1:XML=null):void{
super(_arg1);
}
override public function read(_arg1:XML):void{
var _local5:XML;
var _local6:XMLList;
var _local7:XML;
var _local8:DaeSource;
var _local9:DaeInput;
if (_arg1.localName() != ASCollada.DAE_CONTROLLER_MORPH_ELEMENT){
return;
};
super.read(_arg1);
this.source = getAttribute(_arg1, ASCollada.DAE_SOURCE_ATTRIBUTE);
this.method = ((getAttribute(_arg1, ASCollada.DAE_METHOD_ATTRIBUTE) == METHOD_RELATIVE)) ? METHOD_RELATIVE : METHOD_NORMALIZED;
Logger.log(((("reading morph, source: " + this.source) + " method: ") + this.method));
var _local2:XML = getNode(_arg1, ASCollada.DAE_TARGETS_ELEMENT);
this.targets = (this.weights = null);
var _local3:Object = new Object();
var _local4:XMLList = getNodeList(_arg1, ASCollada.DAE_SOURCE_ELEMENT);
for each (_local5 in _local4) {
_local8 = new DaeSource(_local5);
_local3[_local8.id] = _local8;
};
_local6 = getNodeList(_local2, ASCollada.DAE_INPUT_ELEMENT);
for each (_local7 in _local6) {
_local9 = new DaeInput(_local7);
switch (_local9.semantic){
case ASCollada.DAE_TARGET_MORPH_INPUT:
this.targets = _local3[_local9.source].values;
break;
case ASCollada.DAE_WEIGHT_MORPH_INPUT:
this.weights = _local3[_local9.source].values;
break;
default:
break;
};
};
if (!this.targets){
throw (new Error("Invalid morph, could not find morph-targets"));
};
if (!this.weights){
throw (new Error("Invalid morph, could not find morhp-weights!"));
};
}
}
}//package org.ascollada.core
Section 113
//DaeNode (org.ascollada.core.DaeNode)
package org.ascollada.core {
import org.ascollada.types.*;
import org.ascollada.*;
public class DaeNode extends DaeEntity {
public var instance_cameras:Array;
public var transforms:Array;
public var geometries:Array;
public var nodes:Array;
public var instance_nodes:Array;
public var controllers:Array;
public var type:uint;
private var _yUp:uint;
public var channels:Array;
public static const TYPE_JOINT:uint = 1;
public static const TYPE_NODE:uint = 0;
public function DaeNode(_arg1:XML=null, _arg2:uint=1):void{
_yUp = _arg2;
super(_arg1);
}
override public function read(_arg1:XML):void{
var _local6:XML;
var _local7:Array;
var _local8:String;
var _local9:DaeTransform;
this.nodes = new Array();
this.controllers = new Array();
this.geometries = new Array();
this.instance_nodes = new Array();
this.instance_cameras = new Array();
this.transforms = new Array();
if (_arg1.localName() != ASCollada.DAE_NODE_ELEMENT){
throw (new Error((("expected a '" + ASCollada.DAE_NODE_ELEMENT) + "' element")));
};
super.read(_arg1);
this.name = (((this.name) && (this.name.length))) ? this.name : this.id;
this.type = ((getAttribute(_arg1, ASCollada.DAE_TYPE_ATTRIBUTE) == "JOINT")) ? TYPE_JOINT : TYPE_NODE;
var _local2 = (this._yUp == DaeDocument.Y_UP);
var _local3:XMLList = _arg1.children();
var _local4:int = _local3.length();
var _local5:int;
while (_local5 < _local4) {
_local6 = _local3[_local5];
_local8 = getAttribute(_local6, ASCollada.DAE_SID_ATTRIBUTE);
switch (_local6.localName()){
case ASCollada.DAE_ASSET_ELEMENT:
break;
case ASCollada.DAE_ROTATE_ELEMENT:
_local7 = getFloats(_local6);
_local9 = new DaeTransform(ASCollada.DAE_ROTATE_ELEMENT, _local8, _local7);
this.transforms.push(_local9);
break;
case ASCollada.DAE_TRANSLATE_ELEMENT:
_local7 = getFloats(_local6);
_local9 = new DaeTransform(ASCollada.DAE_TRANSLATE_ELEMENT, _local8, _local7);
this.transforms.push(_local9);
break;
case ASCollada.DAE_SCALE_ELEMENT:
_local7 = getFloats(_local6);
_local9 = new DaeTransform(ASCollada.DAE_SCALE_ELEMENT, _local8, _local7);
this.transforms.push(_local9);
break;
case ASCollada.DAE_SKEW_ELEMENT:
_local7 = getFloats(_local6);
break;
case ASCollada.DAE_LOOKAT_ELEMENT:
_local7 = getFloats(_local6);
break;
case ASCollada.DAE_MATRIX_ELEMENT:
_local7 = getFloats(_local6);
_local9 = new DaeTransform(ASCollada.DAE_MATRIX_ELEMENT, _local8, _local7);
this.transforms.push(_local9);
break;
case ASCollada.DAE_NODE_ELEMENT:
this.nodes.push(new DaeNode(_local6, _yUp));
break;
case ASCollada.DAE_INSTANCE_CAMERA_ELEMENT:
this.instance_cameras.push(getAttribute(_local6, ASCollada.DAE_URL_ATTRIBUTE));
break;
case ASCollada.DAE_INSTANCE_CONTROLLER_ELEMENT:
this.controllers.push(new DaeInstanceController(_local6));
break;
case ASCollada.DAE_INSTANCE_GEOMETRY_ELEMENT:
this.geometries.push(new DaeInstanceGeometry(_local6));
break;
case ASCollada.DAE_INSTANCE_LIGHT_ELEMENT:
break;
case ASCollada.DAE_INSTANCE_NODE_ELEMENT:
this.instance_nodes.push(new DaeInstanceNode(_local6));
break;
case ASCollada.DAE_EXTRA_ELEMENT:
break;
default:
break;
};
_local5++;
};
}
public function findMatrixBySID(_arg1:String):DaeTransform{
var _local2:DaeTransform;
for each (_local2 in this.transforms) {
if (_arg1 == _local2.sid){
return (_local2);
};
};
return (null);
}
public function findController(_arg1:String):DaeInstanceController{
var _local2:DaeInstanceController;
for each (_local2 in this.controllers) {
if (_arg1 == _local2.id){
return (_local2);
};
};
return (null);
}
}
}//package org.ascollada.core
Section 114
//DaePrimitive (org.ascollada.core.DaePrimitive)
package org.ascollada.core {
import flash.utils.*;
import org.ascollada.*;
public class DaePrimitive extends DaeEntity {
public var vcount:Array;
public var material:String;
public var mesh:DaeMesh;
public var count:uint;
private var _inputs:Dictionary;
public var polygons:Array;
public var type:String;
public function DaePrimitive(_arg1:DaeMesh, _arg2:XML=null):void{
this.mesh = _arg1;
super(_arg2);
}
protected function parse(_arg1:XML):void{
var _local6:DaeInput;
var _local8:XML;
var _local9:int;
var _local10:int;
var _local11:Array;
var _local2:Array = getInts(getNode(_arg1, ASCollada.DAE_POLYGON_ELEMENT));
var _local3:XML = getNode(_arg1, ASCollada.DAE_VERTEXCOUNT_ELEMENT);
var _local4:XMLList = getNodeList(_arg1, ASCollada.DAE_INPUT_ELEMENT);
var _local5:Array = new Array();
var _local7:uint;
if ((_local3 is XML)){
this.vcount = getInts(_local3);
};
for each (_local8 in _local4) {
_local6 = new DaeInput(_local8);
_local7 = Math.max(_local7, (_local6.offset + 1));
_local5.push(_local6);
_inputs[_local6] = new Array();
};
_local9 = 0;
while (_local9 < _local2.length) {
for each (_local6 in _local5) {
_local10 = _local2[(_local9 + _local6.offset)];
_local11 = mesh.sources[_local6.source];
switch (_local6.semantic){
case "VERTEX":
_inputs[_local6].push(_local10);
break;
default:
_inputs[_local6].push(_local11[_local10]);
break;
};
};
_local9 = (_local9 + _local7);
};
}
public function get vertices():Array{
return (getFirstInput("VERTEX"));
}
public function get normals():Array{
return (getFirstInput("NORMAL"));
}
private function getFirstInput(_arg1:String):Array{
var _local2:*;
for (_local2 in _inputs) {
if (_local2.semantic == _arg1){
return (_inputs[_local2]);
};
};
return (null);
}
private function checkNode(_arg1:XML):Boolean{
var _local2:String = String(_arg1.localName());
return ((((((((((((((_local2 == ASCollada.DAE_TRIANGLES_ELEMENT)) || ((_local2 == ASCollada.DAE_TRIFANS_ELEMENT)))) || ((_local2 == ASCollada.DAE_TRISTRIPS_ELEMENT)))) || ((_local2 == ASCollada.DAE_LINESTRIPS_ELEMENT)))) || ((_local2 == ASCollada.DAE_LINES_ELEMENT)))) || ((_local2 == ASCollada.DAE_POLYGONS_ELEMENT)))) || ((_local2 == ASCollada.DAE_POLYLIST_ELEMENT))));
}
public function getTexCoords(_arg1:uint=0):Array{
return (getInputBySet("TEXCOORD", _arg1));
}
private function getInputBySet(_arg1:String, _arg2:int):Array{
var _local3:*;
if (getInputCount(_arg1) == 1){
return (getFirstInput(_arg1));
};
for (_local3 in _inputs) {
if ((((_local3.semantic == _arg1)) && ((_local3.setId == _arg2)))){
return (_inputs[_local3]);
};
};
return (new Array());
}
private function parsePolygons(_arg1:XML):void{
var _local3:DaeInput;
var _local7:int;
var _local8:XML;
var _local9:Array;
var _local10:Array;
var _local11:int;
var _local12:Array;
var _local2:Array = new Array();
var _local4:uint;
var _local5:XMLList = getNodeList(_arg1, ASCollada.DAE_INPUT_ELEMENT);
var _local6:XMLList = getNodeList(_arg1, ASCollada.DAE_POLYGON_ELEMENT);
_local7 = 0;
while (_local7 < _local5.length()) {
_local3 = new DaeInput(_local5[_local7]);
_local4 = Math.max(_local4, (_local3.offset + 1));
_local2.push(_local3);
_inputs[_local3] = new Array();
_local7++;
};
for each (_local8 in _local6) {
_local9 = getInts(_local8);
_local10 = new Array();
_local7 = 0;
while (_local7 < _local9.length) {
for each (_local3 in _local2) {
_local11 = _local9[(_local7 + _local3.offset)];
_local12 = mesh.sources[_local3.source];
switch (_local3.semantic){
case "VERTEX":
_inputs[_local3].push(_local11);
_local10.push(_local11);
break;
default:
_inputs[_local3].push(_local12[_local11]);
break;
};
};
_local7 = (_local7 + _local4);
};
this.polygons.push(_local10);
};
}
override public function read(_arg1:XML):void{
if (!checkNode(_arg1)){
throw (new Error("expected a primitive element!"));
};
if (!this.mesh){
throw (new Error("parent-element 'mesh' or 'convex_mesh' not set!"));
};
super.read(_arg1);
this.type = String(_arg1.localName());
this.count = getAttributeAsInt(_arg1, ASCollada.DAE_COUNT_ATTRIBUTE);
this.material = getAttribute(_arg1, ASCollada.DAE_MATERIAL_ATTRIBUTE);
this.vcount = new Array();
this.polygons = new Array();
if (this.count == 0){
return;
};
_inputs = new Dictionary();
var _local2:XML = (_arg1.parent() as XML);
switch (String(_local2.localName())){
case ASCollada.DAE_MESH_ELEMENT:
switch (_arg1.name().localName.toString()){
case ASCollada.DAE_POLYGONS_ELEMENT:
parsePolygons(_arg1);
break;
default:
parse(_arg1);
break;
};
break;
case ASCollada.DAE_CONVEX_MESH_ELEMENT:
break;
default:
break;
};
}
private function getInputCount(_arg1:String):uint{
var _local3:*;
var _local2:uint;
for (_local3 in _inputs) {
if (_local3.semantic == _arg1){
_local2++;
};
};
return (_local2);
}
}
}//package org.ascollada.core
Section 115
//DaeSampler (org.ascollada.core.DaeSampler)
package org.ascollada.core {
import org.ascollada.*;
public class DaeSampler extends DaeEntity {
public var values:Array;
public var type:String;
public function DaeSampler(_arg1:XML):void{
super(_arg1);
}
override public function read(_arg1:XML):void{
if (_arg1.localName() != ASCollada.DAE_SAMPLER_ELEMENT){
throw (new Error((("expected a '" + ASCollada.DAE_SAMPLER_ELEMENT) + "' element")));
};
super.read(_arg1);
}
}
}//package org.ascollada.core
Section 116
//DaeSkin (org.ascollada.core.DaeSkin)
package org.ascollada.core {
import org.ascollada.*;
import org.ascollada.utils.*;
public class DaeSkin extends DaeEntity {
public var vertex_weights:Array;
public var bind_shape_matrix:Array;
public var jointsType:String;
public var blendWeightsByJointID:Object;
public var joints:Array;
public var source:String;
public var bind_matrices:Array;
public function DaeSkin(_arg1:XML=null):void{
super(_arg1);
}
public function findJointBindMatrix2(_arg1:String):Array{
var _local2:int;
while (_local2 < this.joints.length) {
if (_arg1 == this.joints[_local2]){
return (this.bind_matrices[_local2]);
};
_local2++;
};
return (null);
}
public function findJointVertexWeights(_arg1:DaeNode):Array{
var _local5:Array;
var _local6:int;
var _local2:String = ((this.jointsType == "IDREF")) ? _arg1.id : _arg1.sid;
var _local3:Array = new Array();
var _local4:int;
while (_local4 < this.vertex_weights.length) {
_local5 = this.vertex_weights[_local4];
_local6 = 0;
while (_local6 < _local5.length) {
if (_local5[_local6].joint == _local2){
_local3.push(_local5[_local6]);
};
_local6++;
};
_local4++;
};
return (_local3);
}
public function findJointBindMatrix(_arg1:DaeNode):Array{
var _local2:String = ((this.jointsType == "IDREF")) ? _arg1.id : _arg1.sid;
var _local3:int;
while (_local3 < this.joints.length) {
if (_local2 == this.joints[_local3]){
return (this.bind_matrices[_local3]);
};
_local3++;
};
return (null);
}
private function normalizeBlendWeights(_arg1:Array):void{
var _local2:int;
var _local3:int;
var _local4:Array;
var _local5:Number;
var _local6:Number;
_local2 = 0;
while (_local2 < _arg1.length) {
_local4 = _arg1[_local2];
_local5 = 0;
_local3 = 0;
while (_local3 < _local4.length) {
_local5 = (_local5 + _local4[_local3].weight);
_local4[_local3].originalWeight = _local4[_local3].weight;
_local3++;
};
if ((((_local5 == 0)) || ((_local5 == 1)))){
} else {
_local6 = (1 / _local5);
_local3 = 0;
while (_local3 < _local4.length) {
_local4[_local3].weight = (_local4[_local3].weight * _local6);
_local3++;
};
};
_local2++;
};
}
public function findJointVertexWeightsByIDOrSID(_arg1:String):Array{
var _local4:Array;
var _local5:int;
var _local2:Array = new Array();
var _local3:int;
while (_local3 < this.vertex_weights.length) {
_local4 = this.vertex_weights[_local3];
_local5 = 0;
while (_local5 < _local4.length) {
if (_local4[_local5].joint == _arg1){
_local2.push(_local4[_local5]);
};
_local5++;
};
_local3++;
};
return (_local2);
}
override public function read(_arg1:XML):void{
var _local8:XML;
var _local9:DaeInput;
var _local10:DaeSource;
var _local12:XML;
var _local13:int;
var _local14:uint;
var _local15:uint;
var _local16:Array;
var _local17:int;
var _local18:int;
var _local19:int;
var _local20:Array;
var _local21:int;
var _local22:int;
var _local23:int;
var _local24:Number;
var _local25:String;
var _local26:DaeBlendWeight;
this.joints = new Array();
this.vertex_weights = new Array();
this.bind_matrices = new Array();
if (_arg1.localName() != ASCollada.DAE_CONTROLLER_SKIN_ELEMENT){
return;
};
super.read(_arg1);
this.source = getAttribute(_arg1, ASCollada.DAE_SOURCE_ATTRIBUTE);
Logger.log(("reading skin, source: " + this.source));
var _local2:XMLList = getNodeList(_arg1, ASCollada.DAE_BINDSHAPEMX_SKIN_PARAMETER);
if (_local2.length()){
this.bind_shape_matrix = getFloats(_local2[0]);
} else {
this.bind_shape_matrix = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
};
var _local3:XMLList = getNodeList(_arg1, ASCollada.DAE_SOURCE_ELEMENT);
if (_local3.length() < 3){
throw (new Error("<skin> requires a minimum of 3 <source> elements!"));
};
var _local4:XML = getNode(_arg1, ASCollada.DAE_JOINTS_ELEMENT);
if (!_local4){
throw (new Error("need exactly one <joints> element!"));
};
var _local5:XML = getNode(_arg1, ASCollada.DAE_WEIGHTS_ELEMENT);
if (!_local5){
throw (new Error("need exactly one <vertex_weights> element!"));
};
var _local6:XMLList = getNodeList(_local4, ASCollada.DAE_INPUT_ELEMENT);
var _local7:DaeVertexWeights = new DaeVertexWeights(_local5);
var _local11:Object = new Object();
for each (_local12 in _local6) {
_local9 = new DaeInput(_local12);
_local8 = getNodeById(_arg1, ASCollada.DAE_SOURCE_ELEMENT, _local9.source);
if (!_local8){
throw (new Error((("source not found! (id='" + _local9.source) + "')")));
};
_local10 = new DaeSource(_local8);
switch (_local9.semantic){
case ASCollada.DAE_JOINT_SKIN_INPUT:
this.joints = _local10.values;
this.jointsType = _local10.accessor.params[ASCollada.DAE_JOINT_SKIN_INPUT];
break;
case ASCollada.DAE_BINDMATRIX_SKIN_INPUT:
this.bind_matrices = _local10.values;
break;
default:
break;
};
};
_local13 = 0;
_local14 = 0;
_local15 = 1;
for each (_local9 in _local7.inputs) {
_local8 = getNodeById(_arg1, ASCollada.DAE_SOURCE_ELEMENT, _local9.source);
if (!_local8){
throw (new Error((("source not found! (id='" + _local9.source) + "')")));
};
_local10 = new DaeSource(_local8);
switch (_local9.semantic){
case ASCollada.DAE_JOINT_SKIN_INPUT:
_local14 = _local9.offset;
_local13++;
break;
case ASCollada.DAE_WEIGHT_SKIN_INPUT:
_local16 = _local10.values;
_local15 = _local9.offset;
_local13++;
break;
default:
break;
};
};
_local17 = 0;
_local18 = 0;
while (_local18 < _local7.vcounts.length) {
_local19 = _local7.vcounts[_local18];
_local20 = new Array();
_local21 = 0;
while (_local21 < _local19) {
_local22 = _local7.v[(_local17 + _local14)];
_local23 = _local7.v[(_local17 + _local15)];
_local24 = _local16[_local23];
_local25 = ((_local22 < 0)) ? null : this.joints[_local22];
_local26 = new DaeBlendWeight(_local18, _local25, _local24);
_local20.push(_local26);
_local17 = (_local17 + _local13);
_local21++;
};
this.vertex_weights[_local18] = _local20;
_local18++;
};
Logger.log((" => => #vertex_weights " + vertex_weights.length));
}
}
}//package org.ascollada.core
Section 117
//DaeSource (org.ascollada.core.DaeSource)
package org.ascollada.core {
import org.ascollada.types.*;
import org.ascollada.*;
public class DaeSource extends DaeEntity {
public var values:Array;
public var accessor:DaeAccessor;
public function DaeSource(_arg1:XML):void{
super(_arg1);
}
override public function read(_arg1:XML):void{
var _local6:Array;
var _local7:int;
this.values = new Array();
if (_arg1.localName() != ASCollada.DAE_SOURCE_ELEMENT){
return;
};
super.read(_arg1);
var _local2:DaeArray = new DaeArray(_arg1);
var _local3:XML = getNode(_arg1, ASCollada.DAE_TECHNIQUE_COMMON_ELEMENT);
if (!_local3){
this.values = _local2.values;
return;
};
var _local4:XML = getNode(_local3, ASCollada.DAE_ACCESSOR_ELEMENT);
if (!_local4){
throw (new Error("As a child of <source>, this element must contain exactly one <accessor> element."));
};
this.accessor = new DaeAccessor(_local4);
var _local5:int;
while (_local5 < _local2.count) {
if (this.accessor.stride > 1){
_local6 = new Array();
_local7 = 0;
while (_local7 < this.accessor.stride) {
_local6.push(_local2.values[(_local5 + _local7)]);
_local7++;
};
this.values.push(_local6);
} else {
this.values.push(_local2.values[_local5]);
};
_local5 = (_local5 + this.accessor.stride);
};
}
}
}//package org.ascollada.core
Section 118
//DaeSpline (org.ascollada.core.DaeSpline)
package org.ascollada.core {
import org.ascollada.*;
public class DaeSpline extends DaeEntity {
public var vertices:Array;
public var closed:Boolean;
public function DaeSpline(_arg1:XML):void{
super(_arg1);
}
override public function read(_arg1:XML):void{
var _local5:XML;
var _local6:DaeInput;
var _local7:XML;
var _local8:DaeSource;
if (_arg1.localName() != ASCollada.DAE_SPLINE_ELEMENT){
throw (new Error((("expected a '" + ASCollada.DAE_SPLINE_ELEMENT) + "' element")));
};
super.read(_arg1);
this.closed = ((getAttribute(_arg1, ASCollada.DAE_CLOSED_ATTRIBUTE) == "true")) ? true : false;
var _local2:XMLList = getNodeList(_arg1, ASCollada.DAE_SOURCE_ELEMENT);
if (_local2 == new XMLList()){
throw (new Error("<spline> requires at least one <source> element!"));
};
var _local3:XML = getNode(_arg1, ASCollada.DAE_CONTROL_VERTICES_ELEMENT);
if (!_local3){
throw (new Error("<spline> requires exactly one <control_vertices> element!"));
};
var _local4:XMLList = getNodeList(_local3, ASCollada.DAE_INPUT_ELEMENT);
for each (_local5 in _local4) {
_local6 = new DaeInput(_local5);
switch (_local6.semantic){
case "POSITION":
_local7 = getNodeById(_arg1, ASCollada.DAE_SOURCE_ELEMENT, _local6.source);
if (!_local7){
throw (new Error((("source with id=" + _local6.source) + " not found!")));
};
_local8 = new DaeSource(_local7[0]);
this.vertices = _local8.values;
break;
case "INTERPOLATION":
break;
case "IN_TANGENT":
break;
case "OUT_TANGENT":
break;
case "CONTINUITY":
break;
case "LINEAR_STEPS":
break;
default:
break;
};
};
}
}
}//package org.ascollada.core
Section 119
//DaeVertexWeights (org.ascollada.core.DaeVertexWeights)
package org.ascollada.core {
import org.ascollada.*;
import org.ascollada.utils.*;
public class DaeVertexWeights extends DaeEntity {
public var v:Array;
public var inputs:Array;
public var vcounts:Array;
public var count:int;
public function DaeVertexWeights(_arg1:XML=null):void{
super(_arg1);
}
override public function read(_arg1:XML):void{
var _local6:DaeInput;
this.inputs = new Array();
if (_arg1.localName() != ASCollada.DAE_WEIGHTS_ELEMENT){
throw (new Error((("not a <" + ASCollada.DAE_WEIGHTS_ELEMENT) + "> element!")));
};
super.read(_arg1);
this.count = getAttributeAsInt(_arg1, ASCollada.DAE_COUNT_ATTRIBUTE);
Logger.log(" => reading vertex_weights");
var _local2:XMLList = getNodeList(_arg1, ASCollada.DAE_INPUT_ELEMENT);
if (_local2.length() < 2){
throw (new Error("<joints> requires at least 2 <input> elements!"));
};
var _local3:int;
while (_local3 < _local2.length()) {
_local6 = new DaeInput(_local2[_local3]);
this.inputs.push(_local6);
_local3++;
};
this.v = new Array();
this.vcounts = new Array();
var _local4:XML = getNode(_arg1, ASCollada.DAE_VERTEX_ELEMENT);
var _local5:XML = getNode(_arg1, ASCollada.DAE_VERTEXCOUNT_ELEMENT);
if (((!(_local4)) || (!(_local5)))){
return;
};
this.v = getInts(_local4);
this.vcounts = getInts(_local5);
}
}
}//package org.ascollada.core
Section 120
//DaeVertices (org.ascollada.core.DaeVertices)
package org.ascollada.core {
import org.ascollada.*;
public class DaeVertices extends DaeEntity {
public var inputs:Object;
public function DaeVertices(_arg1:XML=null):void{
super(_arg1);
}
override public function read(_arg1:XML):void{
var _local5:DaeInput;
if (_arg1.localName() != ASCollada.DAE_VERTICES_ELEMENT){
throw (new Error((("expected a '" + ASCollada.DAE_VERTICES_ELEMENT) + "' element")));
};
super.read(_arg1);
this.inputs = new Object();
var _local2:XMLList = getNodeList(_arg1, ASCollada.DAE_INPUT_ELEMENT);
var _local3:uint = _local2.length();
var _local4:int;
while (_local4 < _local3) {
_local5 = new DaeInput(_local2[_local4]);
this.inputs[_local5.semantic] = _local5;
_local4++;
};
}
}
}//package org.ascollada.core
Section 121
//DaeVisualScene (org.ascollada.core.DaeVisualScene)
package org.ascollada.core {
import org.ascollada.*;
import org.ascollada.utils.*;
public class DaeVisualScene extends DaeEntity {
public var nodes:Array;
private var _yUp:uint;
public function DaeVisualScene(_arg1:XML=null, _arg2:uint=1):void{
_yUp = _arg2;
super(_arg1);
}
override public function read(_arg1:XML):void{
var _local5:XML;
var _local6:XMLList;
var _local7:XML;
var _local8:String;
var _local9:XML;
var _local10:XML;
var _local11:XML;
this.nodes = new Array();
if (_arg1.localName() != ASCollada.DAE_VSCENE_ELEMENT){
throw (new Error((("expected a '" + ASCollada.DAE_VSCENE_ELEMENT) + "' element")));
};
super.read(_arg1);
Logger.log(("reading visual scene: " + this.id));
var _local2:XMLList = getNodeList(_arg1, ASCollada.DAE_NODE_ELEMENT);
if (!_local2.length()){
throw (new Error("require at least 1 <node> element!"));
};
var _local3:int;
while (_local3 < _local2.length()) {
this.nodes.push(new DaeNode(_local2[_local3], _yUp));
_local3++;
};
var _local4:XMLList = getNodeList(_arg1, ASCollada.DAE_EXTRA_ELEMENT);
for each (_local5 in _local4) {
_local6 = getNodeList(_local5, ASCollada.DAE_TECHNIQUE_ELEMENT);
for each (_local7 in _local6) {
_local8 = getAttribute(_local7, ASCollada.DAE_PROFILE_ATTRIBUTE);
switch (_local8){
case ASCollada.DAEMAX_MAX_PROFILE:
_local9 = getNode(_local7, ASCollada.DAEMAX_FRAMERATE_PARAMETER);
if (_local9){
this.extras[ASCollada.DAEMAX_FRAMERATE_PARAMETER] = parseFloat(getNodeContent(_local9));
};
break;
case "FCOLLADA":
_local10 = getNode(_local7, "start_time");
if (_local10){
this.extras["start_time"] = parseFloat(getNodeContent(_local10));
};
_local11 = getNode(_local7, "end_time");
if (_local11){
this.extras["end_time"] = parseFloat(getNodeContent(_local11));
};
break;
default:
break;
};
};
};
}
public function get endTime():Number{
return (this.extras["end_time"]);
}
public function get frameRate():Number{
return (this.extras[ASCollada.DAEMAX_FRAMERATE_PARAMETER]);
}
public function get startTime():Number{
return (this.extras["start_time"]);
}
}
}//package org.ascollada.core
Section 122
//DaeBindVertexInput (org.ascollada.fx.DaeBindVertexInput)
package org.ascollada.fx {
import org.ascollada.core.*;
import org.ascollada.*;
public class DaeBindVertexInput extends DaeEntity {
public var input_set:int;
public var input_semantic:String;
public var semantic:String;
public function DaeBindVertexInput(_arg1:XML=null):void{
super(_arg1);
}
override public function read(_arg1:XML):void{
super.read(_arg1);
semantic = getAttribute(_arg1, ASCollada.DAE_SEMANTIC_ATTRIBUTE);
input_semantic = getAttribute(_arg1, ASCollada.DAE_INPUT_SEMANTIC_ATTRIBUTE);
input_set = getAttributeAsInt(_arg1, ASCollada.DAE_INPUT_SET_ATTRIBUTE);
}
}
}//package org.ascollada.fx
Section 123
//DaeBlinn (org.ascollada.fx.DaeBlinn)
package org.ascollada.fx {
import org.ascollada.types.*;
import org.ascollada.*;
import org.ascollada.utils.*;
public class DaeBlinn extends DaeLambert {
public var specular:DaeColorOrTexture;
public var shininess:Number;// = 0
public function DaeBlinn(_arg1:XML=null):void{
super(_arg1);
}
override public function read(_arg1:XML):void{
var _local5:XML;
super.read(_arg1);
var _local2:XMLList = _arg1.children();
var _local3:int = _local2.length();
var _local4:int;
while (_local4 < _local3) {
_local5 = _local2[_local4];
switch (_local5.localName()){
case ASCollada.DAE_SPECULAR_MATERIAL_PARAMETER:
this.specular = new DaeColorOrTexture(_local5);
break;
case ASCollada.DAE_SHININESS_MATERIAL_PARAMETER:
this.shininess = parseFloat(getNodeContent(getNode(_local5, "float")));
Logger.log((" => shininess: " + this.shininess));
break;
default:
break;
};
_local4++;
};
}
}
}//package org.ascollada.fx
Section 124
//DaeConstant (org.ascollada.fx.DaeConstant)
package org.ascollada.fx {
import org.ascollada.core.*;
import org.ascollada.types.*;
import org.ascollada.*;
public class DaeConstant extends DaeEntity {
public var emission:DaeColorOrTexture;
public var reflectivity:Number;// = 0
public var transparent:DaeColorOrTexture;
public var index_of_refraction:Number;// = 0
public var transparency:Number;// = 0
public var reflective:DaeColorOrTexture;
public function DaeConstant(_arg1:XML=null):void{
super(_arg1);
}
override public function read(_arg1:XML):void{
var _local5:XML;
super.read(_arg1);
var _local2:XMLList = _arg1.children();
var _local3:int = _local2.length();
var _local4:int;
while (_local4 < _local3) {
_local5 = _local2[_local4];
switch (_local5.localName()){
case ASCollada.DAE_EMISSION_MATERIAL_PARAMETER:
this.emission = new DaeColorOrTexture(_local5);
break;
case ASCollada.DAE_REFLECTIVE_MATERIAL_PARAMETER:
this.reflective = new DaeColorOrTexture(_local5);
break;
case ASCollada.DAE_REFLECTIVITY_MATERIAL_PARAMETER:
this.reflectivity = parseFloat(getNodeContent(getNode(_local5, "float")));
break;
case ASCollada.DAE_TRANSPARENT_MATERIAL_PARAMETER:
this.transparent = new DaeColorOrTexture(_local5);
break;
case ASCollada.DAE_TRANSPARENCY_MATERIAL_PARAMETER:
this.transparency = parseFloat(getNodeContent(getNode(_local5, "float")));
break;
case ASCollada.DAE_INDEXOFREFRACTION_MATERIAL_PARAMETER:
this.reflectivity = parseFloat(getNodeContent(getNode(_local5, "float")));
break;
default:
break;
};
_local4++;
};
}
}
}//package org.ascollada.fx
Section 125
//DaeEffect (org.ascollada.fx.DaeEffect)
package org.ascollada.fx {
import org.ascollada.core.*;
import org.ascollada.types.*;
import org.ascollada.*;
import org.ascollada.utils.*;
public class DaeEffect extends DaeEntity {
public var color:DaeConstant;
public var wireframe:Boolean;
public var texture_url:String;
public var newparams:Object;
public var double_sided:Boolean;
public function DaeEffect(_arg1:XML=null):void{
super(_arg1);
}
private function readExtra(_arg1:XML):void{
var _local3:XML;
var _local4:XML;
var _local5:String;
var _local6:XML;
var _local7:String;
var _local2:XMLList = getNodeList(_arg1, ASCollada.DAE_EXTRA_ELEMENT);
for each (_local3 in _local2) {
_local4 = getNode(_local3, ASCollada.DAE_TECHNIQUE_ELEMENT);
_local5 = _local4.@profile.toString();
switch (_local5){
case "MAX3D":
_local6 = getNode(_local4, "double_sided");
if (_local6){
_local7 = getNodeContent(_local6);
this.double_sided = (((_local7 == "1")) || ((_local7 == "true")));
};
_local6 = getNode(_local4, "wireframe");
if (_local6){
_local7 = getNodeContent(_local6);
this.wireframe = (((_local7 == "1")) || ((_local7 == "true")));
};
break;
default:
break;
};
};
}
override public function read(_arg1:XML):void{
var _local7:XML;
var _local8:XML;
var _local9:XML;
var _local10:XML;
var _local11:XML;
var _local15:DaeNewParam;
super.read(_arg1);
this.double_sided = false;
this.wireframe = false;
var _local2:XML = getNode(_arg1, ASCollada.DAE_PROFILE_COMMON_ELEMENT);
if (!_local2){
Logger.error("Can't handle profiles other then profile_COMMON!");
return;
};
var _local3:XMLList = getNodeList(_local2, ASCollada.DAE_IMAGE_ELEMENT);
var _local4:XMLList = getNodeList(_local2, ASCollada.DAE_FXCMN_NEWPARAM_ELEMENT);
var _local5:XML = getNode(_local2, ASCollada.DAE_TECHNIQUE_ELEMENT);
var _local6:String = _local5.attribute(ASCollada.DAE_SID_ATTRIBUTE);
Logger.log(("reading effect: " + this.id));
Logger.log((" => #images: " + _local3.length()));
Logger.log((" => #newparams: " + _local4.length()));
Logger.log((" => technique sid: " + _local6));
this.newparams = new Object();
for each (_local7 in _local4) {
_local15 = new DaeNewParam(_local7);
this.newparams[_local15.type] = _local15;
};
_local8 = getNode(_local5, ASCollada.DAE_FXSTD_PHONG_ELEMENT);
_local9 = getNode(_local5, ASCollada.DAE_FXSTD_LAMBERT_ELEMENT);
_local10 = getNode(_local5, ASCollada.DAE_FXSTD_BLINN_ELEMENT);
_local11 = getNode(_local5, ASCollada.DAE_FXSTD_CONSTANT_ELEMENT);
if (_local8){
Logger.log(" => shader: phong");
this.color = new DaePhong(_local8);
} else {
if (_local9){
Logger.log(" => shader: lambert");
this.color = new DaeLambert(_local9);
} else {
if (_local10){
Logger.log(" => shader: blinn");
this.color = new DaeBlinn(_local10);
} else {
if (_local11){
Logger.log(" => shader: constant");
this.color = new DaeConstant(_local11);
};
};
};
};
var _local12:DaeNewParam = this.newparams[ASCollada.DAE_FXCMN_SURFACE_ELEMENT];
var _local13:DaeNewParam = this.newparams[ASCollada.DAE_FXCMN_SAMPLER2D_ELEMENT];
var _local14:DaeLambert = (this.color as DaeLambert);
if (((((((_local14) && ((_local14.diffuse.type == DaeColorOrTexture.TYPE_TEXTURE)))) && (_local13))) && (_local12))){
if ((((_local13.sid == _local14.diffuse.texture.texture)) && ((_local13.sampler2D.source == _local12.sid)))){
this.texture_url = _local12.surface.init_from;
};
};
readExtra(_arg1);
}
}
}//package org.ascollada.fx
Section 126
//DaeInstanceMaterial (org.ascollada.fx.DaeInstanceMaterial)
package org.ascollada.fx {
import org.ascollada.core.*;
import org.ascollada.*;
public class DaeInstanceMaterial extends DaeEntity {
public var target:String;
public var symbol:String;
private var _bindVertexInputs:Array;
public function DaeInstanceMaterial(_arg1:XML=null){
super(_arg1);
}
override public function read(_arg1:XML):void{
var _local5:XML;
super.read(_arg1);
this.symbol = getAttribute(_arg1, ASCollada.DAE_SYMBOL_ATTRIBUTE);
this.target = getAttribute(_arg1, ASCollada.DAE_TARGET_ATTRIBUTE);
_bindVertexInputs = new Array();
var _local2:XMLList = _arg1.children();
var _local3:int = _local2.length();
var _local4:int;
while (_local4 < _local3) {
_local5 = _local2[_local4];
switch (String(_local5.localName())){
case ASCollada.DAE_BIND_ELEMENT:
break;
case ASCollada.DAE_BIND_VERTEX_INPUT:
_bindVertexInputs.push(new DaeBindVertexInput(_local5));
break;
case ASCollada.DAE_EXTRA_ELEMENT:
break;
default:
break;
};
_local4++;
};
}
public function findBindVertexInput(_arg1:String, _arg2:String="TEXCOORD"):DaeBindVertexInput{
var _local3:DaeBindVertexInput;
for each (_local3 in _bindVertexInputs) {
if ((((_local3.semantic == _arg1)) && ((_local3.input_semantic == _arg2)))){
return (_local3);
};
};
return (null);
}
public function get bindVertexInputs():Array{
return (_bindVertexInputs);
}
}
}//package org.ascollada.fx
Section 127
//DaeLambert (org.ascollada.fx.DaeLambert)
package org.ascollada.fx {
import org.ascollada.types.*;
import org.ascollada.*;
public class DaeLambert extends DaeConstant {
public var ambient:DaeColorOrTexture;
public var diffuse:DaeColorOrTexture;
public function DaeLambert(_arg1:XML=null):void{
super(_arg1);
}
override public function read(_arg1:XML):void{
var _local5:XML;
super.read(_arg1);
var _local2:XMLList = _arg1.children();
var _local3:int = _local2.length();
var _local4:int;
while (_local4 < _local3) {
_local5 = _local2[_local4];
switch (_local5.localName()){
case ASCollada.DAE_AMBIENT_MATERIAL_PARAMETER:
this.ambient = new DaeColorOrTexture(_local5);
break;
case ASCollada.DAE_DIFFUSE_MATERIAL_PARAMETER:
this.diffuse = new DaeColorOrTexture(_local5);
if (this.diffuse.texture){
};
break;
default:
break;
};
_local4++;
};
}
}
}//package org.ascollada.fx
Section 128
//DaeMaterial (org.ascollada.fx.DaeMaterial)
package org.ascollada.fx {
import org.ascollada.core.*;
import org.ascollada.*;
import org.ascollada.utils.*;
public class DaeMaterial extends DaeEntity {
public var effect:String;
public function DaeMaterial(_arg1:XML=null):void{
super(_arg1);
}
override public function read(_arg1:XML):void{
var _local5:XML;
var _local6:XML;
super.read(_arg1);
Logger.log(("reading material: " + this.id));
var _local2:XML = getNode(_arg1, ASCollada.DAE_ASSET_ELEMENT);
if (_local2){
this.asset = new DaeAsset(_local2);
};
var _local3:XML = getNode(_arg1, ASCollada.DAE_INSTANCE_EFFECT_ELEMENT);
this.effect = getAttribute(_local3, ASCollada.DAE_URL_ATTRIBUTE);
Logger.log((" => effect url: " + this.effect));
return;
}
}
}//package org.ascollada.fx
Section 129
//DaeNewParam (org.ascollada.fx.DaeNewParam)
package org.ascollada.fx {
import org.ascollada.core.*;
import org.ascollada.*;
import org.ascollada.utils.*;
public class DaeNewParam extends DaeEntity {
public var type:String;
public var sampler2D:DaeSampler2D;
public var surface:DaeSurface;
public function DaeNewParam(_arg1:XML=null){
super(_arg1);
}
override public function read(_arg1:XML):void{
var _local5:XML;
if (_arg1.localName() != ASCollada.DAE_FXCMN_NEWPARAM_ELEMENT){
throw (new Error((("expected a '" + ASCollada.DAE_FXCMN_NEWPARAM_ELEMENT) + "' element")));
};
super.read(_arg1);
Logger.log((" => newparam @sid=" + this.sid));
var _local2:XMLList = _arg1.children();
var _local3:int = _local2.length();
var _local4:int;
while (_local4 < _local3) {
_local5 = _local2[_local4];
switch (_local5.localName()){
case ASCollada.DAE_FXCMN_SURFACE_ELEMENT:
this.type = ASCollada.DAE_FXCMN_SURFACE_ELEMENT;
this.surface = new DaeSurface(_local5);
break;
case ASCollada.DAE_FXCMN_SAMPLER2D_ELEMENT:
this.type = ASCollada.DAE_FXCMN_SAMPLER2D_ELEMENT;
this.sampler2D = new DaeSampler2D(_local5);
break;
default:
break;
};
_local4++;
};
}
}
}//package org.ascollada.fx
Section 130
//DaePhong (org.ascollada.fx.DaePhong)
package org.ascollada.fx {
import org.ascollada.types.*;
import org.ascollada.*;
public class DaePhong extends DaeLambert {
public var specular:DaeColorOrTexture;
public var shininess:Number;// = 0
public function DaePhong(_arg1:XML=null):void{
super(_arg1);
}
override public function read(_arg1:XML):void{
var _local5:XML;
super.read(_arg1);
var _local2:XMLList = _arg1.children();
var _local3:int = _local2.length();
var _local4:int;
while (_local4 < _local3) {
_local5 = _local2[_local4];
switch (_local5.localName()){
case ASCollada.DAE_SPECULAR_MATERIAL_PARAMETER:
this.specular = new DaeColorOrTexture(_local5);
break;
case ASCollada.DAE_SHININESS_MATERIAL_PARAMETER:
this.shininess = parseFloat(getNodeContent(getNode(_local5, "float")));
break;
default:
break;
};
_local4++;
};
}
}
}//package org.ascollada.fx
Section 131
//DaeSampler2D (org.ascollada.fx.DaeSampler2D)
package org.ascollada.fx {
import org.ascollada.core.*;
import org.ascollada.*;
import org.ascollada.utils.*;
public class DaeSampler2D extends DaeEntity {
public var source:String;
public function DaeSampler2D(_arg1:XML):void{
super(_arg1);
}
override public function read(_arg1:XML):void{
if (_arg1.localName() != ASCollada.DAE_FXCMN_SAMPLER2D_ELEMENT){
throw (new Error((("expected a '" + ASCollada.DAE_FXCMN_SAMPLER2D_ELEMENT) + "' element")));
};
super.read(_arg1);
this.source = getNodeContent(getNode(_arg1, ASCollada.DAE_SOURCE_ELEMENT));
Logger.log((" => => sampler2D source: " + this.source));
}
}
}//package org.ascollada.fx
Section 132
//DaeSurface (org.ascollada.fx.DaeSurface)
package org.ascollada.fx {
import org.ascollada.core.*;
import org.ascollada.*;
import org.ascollada.utils.*;
public class DaeSurface extends DaeEntity {
public var init_from:String;
public var type:String;
public function DaeSurface(_arg1:XML=null):void{
super(_arg1);
}
override public function read(_arg1:XML):void{
if (_arg1.localName() != ASCollada.DAE_FXCMN_SURFACE_ELEMENT){
throw (new Error((("expected a '" + ASCollada.DAE_FXCMN_SURFACE_ELEMENT) + "' element")));
};
super.read(_arg1);
this.type = getAttribute(_arg1, ASCollada.DAE_TYPE_ATTRIBUTE);
this.init_from = getNodeContent(getNode(_arg1, ASCollada.DAE_INITFROM_ELEMENT));
Logger.log((((" => => surface type: " + this.type) + " init_from: ") + this.init_from));
}
}
}//package org.ascollada.fx
Section 133
//DaeTexture (org.ascollada.fx.DaeTexture)
package org.ascollada.fx {
import org.ascollada.core.*;
import org.ascollada.*;
public class DaeTexture extends DaeEntity {
public var texture:String;
public var texcoord:String;
public function DaeTexture(_arg1:XML=null):void{
super(_arg1);
}
override public function read(_arg1:XML):void{
super.read(_arg1);
this.texture = getAttribute(_arg1, ASCollada.DAE_FXSTD_TEXTURE_ATTRIBUTE);
this.texcoord = getAttribute(_arg1, ASCollada.DAE_FXSTD_TEXTURESET_ATTRIBUTE);
}
}
}//package org.ascollada.fx
Section 134
//DaeReader (org.ascollada.io.DaeReader)
package org.ascollada.io {
import flash.events.*;
import flash.net.*;
import flash.utils.*;
import org.ascollada.core.*;
import org.ascollada.utils.*;
public class DaeReader extends EventDispatcher {
private var _numAnimations:uint;
private var _animTimer:Timer;
private var _numGeometries:uint;
private var _geomTimer:Timer;
public var document:DaeDocument;
public var async:Boolean;
public function DaeReader(_arg1:Boolean=false){
this.async = _arg1;
_animTimer = new Timer(100);
_animTimer.addEventListener(TimerEvent.TIMER, loadNextAnimation);
_geomTimer = new Timer(1);
_geomTimer.addEventListener(TimerEvent.TIMER, loadNextGeometry);
}
public function loadDocument(_arg1):DaeDocument{
this.document = new DaeDocument(_arg1, this.async);
_numAnimations = this.document.numQueuedAnimations;
_numGeometries = this.document.numQueuedGeometries;
dispatchEvent(new Event(Event.COMPLETE));
return (this.document);
}
public function readAnimations():void{
if (this.document.numQueuedAnimations > 0){
Logger.log((("START READING #" + this.document.numQueuedAnimations) + " ANIMATIONS"));
_animTimer.repeatCount = (this.document.numQueuedAnimations + 1);
_animTimer.delay = 100;
_animTimer.start();
} else {
Logger.log("NO ANIMATIONS");
};
}
public function readGeometries():void{
if (this.document.numQueuedGeometries > 0){
Logger.log((("START READING #" + this.document.numQueuedGeometries) + " GEOMETRIES"));
_geomTimer.repeatCount = (this.document.numQueuedGeometries + 1);
_geomTimer.delay = 2;
_geomTimer.start();
} else {
Logger.log("NO GEOMETRIES");
};
}
private function loadNextAnimation(_arg1:TimerEvent):void{
if (!this.document.readNextAnimation()){
_animTimer.stop();
dispatchEvent(new Event(Event.COMPLETE));
} else {
dispatchEvent(new ProgressEvent(ProgressEvent.PROGRESS, false, false, (_numAnimations - this.document.numQueuedAnimations), _numAnimations));
};
}
private function completeHandler(_arg1:Event):void{
var _local2:URLLoader = (_arg1.target as URLLoader);
Logger.log("complete!");
loadDocument(_local2.data);
}
private function loadNextGeometry(_arg1:TimerEvent):void{
_geomTimer.stop();
if (!this.document.readNextGeometry()){
Logger.log("geometries complete");
dispatchEvent(new Event(Event.COMPLETE));
} else {
Logger.log("reading next geometry");
dispatchEvent(new ProgressEvent(ProgressEvent.PROGRESS, false, false, (_numGeometries - this.document.numQueuedGeometries), _numGeometries));
_geomTimer.start();
};
}
public function read(_arg1:String):void{
Logger.log(("reading: " + _arg1));
if (_animTimer.running){
_animTimer.stop();
};
var _local2:URLLoader = new URLLoader();
_local2.addEventListener(Event.COMPLETE, completeHandler, false, 0, true);
_local2.addEventListener(ProgressEvent.PROGRESS, progressHandler, false, 0, true);
_local2.addEventListener(IOErrorEvent.IO_ERROR, handleIOError, false, 0, true);
_local2.load(new URLRequest(_arg1));
}
private function handleIOError(_arg1:IOErrorEvent):void{
dispatchEvent(_arg1);
}
private function progressHandler(_arg1:ProgressEvent):void{
if (hasEventListener(ProgressEvent.PROGRESS)){
dispatchEvent(_arg1);
};
}
}
}//package org.ascollada.io
Section 135
//collada (org.ascollada.namespaces.collada)
package org.ascollada.namespaces {
public namespace collada = "http://www.collada.org/2005/11/COLLADASchema";
}//package org.ascollada.namespaces
Section 136
//DaeConvexMesh (org.ascollada.physics.DaeConvexMesh)
package org.ascollada.physics {
import org.ascollada.core.*;
import org.ascollada.*;
public class DaeConvexMesh extends DaeMesh {
public var convex_hull_off:String;
public var isHull:Boolean;
public function DaeConvexMesh(_arg1:DaeGeometry, _arg2:XML=null):void{
super(_arg1, _arg2);
}
override public function read(_arg1:XML):void{
if (_arg1.localName() != ASCollada.DAE_CONVEX_MESH_ELEMENT){
throw (new Error((("expected a '" + ASCollada.DAE_CONVEX_MESH_ELEMENT) + "' element")));
};
this.convex_hull_off = getAttribute(_arg1, ASCollada.DAE_CONVEX_HULL_OF_ATTRIBUTE, true);
this.isHull = (this.convex_hull_off.length > 0);
if (this.isHull){
return;
};
super.read(_arg1);
}
}
}//package org.ascollada.physics
Section 137
//DaePhysicsScene (org.ascollada.physics.DaePhysicsScene)
package org.ascollada.physics {
import org.ascollada.core.*;
public class DaePhysicsScene extends DaeEntity {
public function DaePhysicsScene(_arg1:XML=null):void{
super(_arg1);
}
override public function read(_arg1:XML):void{
super.read(_arg1);
}
}
}//package org.ascollada.physics
Section 138
//DaeAddressSyntax (org.ascollada.types.DaeAddressSyntax)
package org.ascollada.types {
import org.ascollada.utils.*;
public class DaeAddressSyntax {
public var member:String;
public var arrayMember:Array;
public var isDotAccess:Boolean;
public var isFullAccess:Boolean;
public var targetID:String;
public var isArrayAccess:Boolean;
public var targetSID:String;
public function DaeAddressSyntax():void{
}
public function toString():String{
return ((((((((((((((("[target:" + targetID) + "\nSID:") + targetSID) + "\nmember:") + member) + "\narrayMember:") + arrayMember) + "\n") + isArrayAccess) + " ") + isDotAccess) + " ") + isFullAccess) + "]"));
}
public static function parseAnimationTarget(_arg1:String):DaeAddressSyntax{
var _local2:Array;
if (_arg1.indexOf("/") == -1){
Logger.error("[ERROR] invalid animation target attribute!");
throw (new Error("invalid animation target attribute!"));
};
_local2 = _arg1.split("/");
var _local3:DaeAddressSyntax = new (DaeAddressSyntax);
_local3.targetID = _local2[0];
parseFullMember(_local3, _local2[1]);
return (_local3);
}
private static function parseFullMember(_arg1:DaeAddressSyntax, _arg2:String):void{
var _local4:Array;
_arg1.isArrayAccess = (_arg1.isDotAccess = (_arg1.isFullAccess = false));
_arg1.member = "";
_arg1.arrayMember = new Array();
var _local3:RegExp = /\(\d\)/ig;
if (_local3.exec(_arg2)){
_arg1.isArrayAccess = true;
_arg1.targetSID = _arg2.split("(")[0];
_arg1.arrayMember = _arg2.match(_local3);
} else {
if (_arg2.indexOf(".") != -1){
_arg1.isDotAccess = true;
_local4 = _arg2.split(".");
_arg1.targetSID = _local4[0];
_arg1.member = _local4[1];
} else {
if (_arg2.length){
_arg1.isFullAccess = true;
_arg1.targetSID = _arg2;
} else {
Logger.error("[ERROR] can't find a SID!");
throw (new Error("can't find a SID!"));
};
};
};
}
}
}//package org.ascollada.types
Section 139
//DaeArray (org.ascollada.types.DaeArray)
package org.ascollada.types {
import org.ascollada.core.*;
import org.ascollada.*;
public class DaeArray extends DaeEntity {
public var values:Array;
public var count:int;
public function DaeArray(_arg1:XML=null):void{
super(_arg1);
}
private function getData(_arg1:XML):Array{
var _local5:XML;
var _local2:XMLList = _arg1.children();
var _local3:int = _local2.length();
var _local4:int;
while (_local4 < _local3) {
_local5 = _local2[_local4];
switch (_local5.localName()){
case ASCollada.DAE_BOOL_ARRAY_ELEMENT:
this.count = getAttributeAsInt(_local5, ASCollada.DAE_COUNT_ATTRIBUTE);
return (getBools(_local5));
case ASCollada.DAE_INT_ARRAY_ELEMENT:
this.count = getAttributeAsInt(_local5, ASCollada.DAE_COUNT_ATTRIBUTE);
return (getInts(_local5));
case ASCollada.DAE_IDREF_ARRAY_ELEMENT:
this.count = getAttributeAsInt(_local5, ASCollada.DAE_COUNT_ATTRIBUTE);
return (getStrings(_local5));
case ASCollada.DAE_FLOAT_ARRAY_ELEMENT:
this.count = getAttributeAsInt(_local5, ASCollada.DAE_COUNT_ATTRIBUTE);
return (getFloats(_local5));
case ASCollada.DAE_NAME_ARRAY_ELEMENT:
this.count = getAttributeAsInt(_local5, ASCollada.DAE_COUNT_ATTRIBUTE);
return (getStrings(_local5));
default:
break;
};
_local4++;
};
return (null);
}
override public function read(_arg1:XML):void{
super.read(_arg1);
this.count = 0;
this.values = getData(_arg1);
if (!this.values){
throw (new Error(" no data!"));
};
}
}
}//package org.ascollada.types
Section 140
//DaeColorOrTexture (org.ascollada.types.DaeColorOrTexture)
package org.ascollada.types {
import org.ascollada.core.*;
import org.ascollada.fx.*;
public class DaeColorOrTexture extends DaeEntity {
public var color:Array;
public var type:uint;
public var texture:DaeTexture;
public static const TYPE_TEXTURE:uint = 1;
public static const TYPE_PARAM:uint = 2;
public static const TYPE_COLOR:uint = 0;
public function DaeColorOrTexture(_arg1:XML=null):void{
this.type = TYPE_COLOR;
super(_arg1);
}
override public function read(_arg1:XML):void{
var _local5:XML;
super.read(_arg1);
var _local2:XMLList = _arg1.children();
var _local3:int = _local2.length();
var _local4:int;
while (_local4 < _local3) {
_local5 = _local2[_local4];
switch (_local5.localName()){
case "color":
this.type = TYPE_COLOR;
this.color = getFloats(_local5);
return;
case "texture":
this.type = TYPE_TEXTURE;
this.texture = new DaeTexture(_local5);
return;
case "param":
this.type = TYPE_PARAM;
return;
default:
break;
};
_local4++;
};
}
}
}//package org.ascollada.types
Section 141
//DaeTransform (org.ascollada.types.DaeTransform)
package org.ascollada.types {
import org.ascollada.*;
import org.ascollada.utils.*;
public class DaeTransform {
public var values:Array;
public var animated:Boolean;
public var type:String;
public var sid:String;
public function DaeTransform(_arg1:String, _arg2:String, _arg3:Array):void{
this.type = _arg1;
this.sid = _arg2;
this.values = _arg3;
this.animated = false;
if (!validateValues()){
Logger.log("[ERROR] invalid values for this transform!");
throw (new Error("[ERROR] invalid values for this transform!"));
};
}
public function validateValues():Boolean{
var _local1:Boolean;
if (((!(this.values)) || (!(this.values.length)))){
return (false);
};
switch (this.type){
case ASCollada.DAE_ROTATE_ELEMENT:
_local1 = (this.values.length == 4);
break;
case ASCollada.DAE_TRANSLATE_ELEMENT:
_local1 = (this.values.length == 3);
break;
case ASCollada.DAE_SCALE_ELEMENT:
_local1 = (this.values.length == 3);
break;
case ASCollada.DAE_MATRIX_ELEMENT:
_local1 = (this.values.length == 16);
break;
default:
break;
};
return (_local1);
}
}
}//package org.ascollada.types
Section 142
//Logger (org.ascollada.utils.Logger)
package org.ascollada.utils {
public class Logger {
public static var VERBOSE:Boolean = false;
public static function debug(_arg1:String):void{
if (VERBOSE){
trace(_arg1);
};
}
public static function error(_arg1:String):void{
trace(_arg1);
}
public static function fatal(_arg1:String):void{
trace(_arg1);
}
public static function log(_arg1:String):void{
if (VERBOSE){
trace(_arg1);
};
}
public static function info(_arg1:String):void{
if (VERBOSE){
trace(_arg1);
};
}
}
}//package org.ascollada.utils
Section 143
//StringUtil (org.ascollada.utils.StringUtil)
package org.ascollada.utils {
public class StringUtil {
public static function trim(_arg1:String):String{
var _local2:int;
while (isWhitespace(_arg1.charAt(_local2))) {
_local2++;
};
var _local3:int = (_arg1.length - 1);
while (isWhitespace(_arg1.charAt(_local3))) {
_local3--;
};
if (_local3 >= _local2){
return (_arg1.slice(_local2, (_local3 + 1)));
};
return ("");
}
public static function substitute(_arg1:String, ... _args):String{
var _local4:Array;
var _local3:uint = _args.length;
if ((((_local3 == 1)) && ((_args[0] is Array)))){
_local4 = (_args[0] as Array);
_local3 = _local4.length;
} else {
_local4 = _args;
};
var _local5:int;
while (_local5 < _local3) {
_arg1 = _arg1.replace(new RegExp((("\\{" + _local5) + "\\}"), "g"), _local4[_local5]);
_local5++;
};
return (_arg1);
}
public static function trimArrayElements(_arg1:String, _arg2:String):String{
var _local3:Array;
var _local4:int;
var _local5:int;
if (((!((_arg1 == ""))) && (!((_arg1 == null))))){
_local3 = _arg1.split(_arg2);
_local4 = _local3.length;
_local5 = 0;
while (_local5 < _local4) {
_local3[_local5] = StringUtil.trim(_local3[_local5]);
_local5++;
};
if (_local4 > 0){
_arg1 = _local3.join(_arg2);
};
};
return (_arg1);
}
public static function isWhitespace(_arg1:String):Boolean{
switch (_arg1){
case " ":
case "\t":
case "\r":
case "\n":
case "\f":
return (true);
default:
return (false);
};
}
}
}//package org.ascollada.utils
Section 144
//ASCollada (org.ascollada.ASCollada)
package org.ascollada {
public class ASCollada {
public static const DAE_GEOMETRY_ELEMENT:String = "geometry";
public static const DAE_MASS_ELEMENT:String = "mass";
public static const DAE_FXSTD_STATE_FACE_ELEMENT:String = "face";
public static const DAE_FXCMN_SAMPLER2D_ELEMENT:String = "sampler2D";
public static const DAE_EMITTER_ELEMENT:String = "emitter";
public static const DAE_INSTANCE_MATERIAL_ELEMENT:String = "instance_material";
public static const DAE_INTANGENT_ANIMATION_INPUT:String = "IN_TANGENT";
public static const DAE_SKEW_ELEMENT:String = "skew";
public static const DAE_PASS_ELEMENT:String = "pass";
public static const DAE_TRISTRIPS_ELEMENT:String = "tristrips";
public static const DAE_LIGHT_POINT_ELEMENT:String = "point";
public static const DAE_INSTANCE_PHYSICS_MATERIAL_ELEMENT:String = "instance_physics_material";
public static const DAE_SURFACE_ATTRIBUTE:String = "surface";
public static const DAE_FXCMN_FLOAT4X4_ELEMENT:String = "float4x4";
public static const DAE_BUMP_MATERIAL_PARAMETER:String = "bump";
public static const DAE_LIBRARY_ANIMATION_ELEMENT:String = "library_animations";
public static const DAE_FORMAT_ELEMENT:String = "format";
public static const DAE_FXCMN_SETPARAM_ELEMENT:String = "setparam";
public static const DAE_LIBRARY_VSCENE_ELEMENT:String = "library_visual_scenes";
public static const DAEMAX_CAMERA_MB_DISABLEFILTER_PARAMETER:String = "disable_filtering";
public static const DAE_FXCMN_FLOAT4_ELEMENT:String = "float4";
public static const DAEMAYA_TEXTURE_ROTFRAME_PARAMETER:String = "rotateFrame";
public static const DAE_OPTICS_ELEMENT:String = "optics";
public static const DAE_INITASTARGET_ELEMENT:String = "init_as_target";
public static const DAE_INSTANCE_GEOMETRY_ELEMENT:String = "instance_geometry";
public static const DAEMAYA_SHORTNAME_PARAMETER:String = "short_name";
public static const DAE_FORMAT_HINT_LOW_VALUE:String = "LOW";
public static const DAE_YFOV_CAMERA_PARAMETER:String = "yfov";
public static const DAE_MAX_ELEMENT:String = "max";
public static const DAE_VERTICES_ELEMENT:String = "vertices";
public static const DAEMAX_USERPROPERTIES_NODE_PARAMETER:String = "user_properties";
public static const DAE_FLOAT_TYPE:String = "float";
public static const DAE_SYMBOL_ATTRIBUTE:String = "symbol";
public static const DAE_STIFFNESS_ELEMENT:String = "stiffness";
public static const DAE_RADIUS2_ELEMENT:String = "radius2";
public static const DAEMAX_WIREFRAME_MATERIAL_PARAMETER:String = "wireframe";
public static const DAE_GRAVITY_ATTRIBUTE:String = "gravity";
public static const DAE_FXSTD_FLOAT_ELEMENT:String = "float";
public static const DAEMAYA_TEXTURE_OFFSETV_PARAMETER:String = "offsetV";
public static const DAE_DEGREE_ATTRIBUTE:String = "degree";
public static const DAE_ZNEAR_CAMERA_PARAMETER:String = "znear";
public static const DAE_CENTER_OF_MASS_ELEMENT:String = "center_of_mass";
public static const DAE_VIEWPORT_RATIO:String = "viewport_ratio";
public static const DAE_INSTANCE_FORCE_FIELD_ELEMENT:String = "instance_force_field";
public static const DAE_FXCMN_HALF4X4_ELEMENT:String = "half4x4";
public static const DAEMAX_CAMERA_MB_BIAS_PARAMETER:String = "bias";
public static const DAEMAX_SHADOW_MAP:String = "shadow_map";
public static const DAE_TIME_TARGET:String = "TIME";
public static const DAE_COLOR_LIGHT_PARAMETER:String = "color";
public static const DAEMAX_ASPECTRATIO_LIGHT_PARAMETER:String = "aspect_ratio";
public static const DAE_EXTRA_ELEMENT:String = "extra";
public static const DAEMAX_SKY_INTENSITY_ON:String = "intensity_on";
public static const DAE_VERTEXCOUNT_ELEMENT:String = "vcount";
public static const DAE_FXCMN_HALF_ELEMENT:String = "half";
public static const DAE_FORMAT_HINT_ELEMENT:String = "format_hint";
public static const DAE_NODE_ELEMENT:String = "node";
public static const DAE_REF_ATTRIBUTE:String = "ref";
public static const DAE_FXCMN_VERTEX_SHADER:String = "VERTEX";
public static const DAEMAYA_DROPOFF_LIGHT_PARAMETER:String = "dropoff";
public static const DAE_SLICE_ATTRIBUTE:String = "slice";
public static const DAE_INSTANCE_LIGHT_ELEMENT:String = "instance_light";
public static const DAE_FORMAT_HINT_SINT_VALUE:String = "SINT";
public static const DAEMAX_PROJ_IMAGE:String = "proj_image";
public static const DAE_RIGID_BODY_ELEMENT:String = "rigid_body";
public static const DAE_FXCMN_SAMPLER3D_ELEMENT:String = "sampler3D";
public static const DAE_LIGHT_AMBIENT_ELEMENT:String = "ambient";
public static const DAE_TRIM_GROUP:String = "trim_group";
public static const DAE_RANGE_ELEMENT:String = "range";
public static const DAEMAYA_PENUMBRA_LIGHT_PARAMETER:String = "penumbra_angle";
public static const DAE_TARGET_ATTRIBUTE:String = "target";
public static const DAE_COLOR_ELEMENT:String = "color";
public static const DAEMAX_SKY_RAYS_PER_SAMPLE_PARAMETER:String = "rays_per_sample";
public static const DAE_INT_ARRAY_ELEMENT:String = "int_array";
public static const DAEMAX_OVERSHOOT_LIGHT_PARAMETER:String = "overshoot";
public static const DAE_CVS_SPLINE_INPUT:String = "POSITION";
public static const DAEMAYA_LENSSQUEEZE_PARAMETER:String = "lens_squeeze";
public static const DAE_FXCMN_FLOAT3_ELEMENT:String = "float3";
public static const DAE_FXSTD_STATE_SRCRGB_ELEMENT:String = "src_rgb";
public static const DAE_TRANS_LIMIT_MIN_ELEMENT:String = "trans_limit_min";
public static const DAE_FXCMN_INCLUDE_ELEMENT:String = "include";
public static const DAE_FXSTD_STATE_ZFAIL_ELEMENT:String = "zfail";
public static const DAEMAX_SHADOW_TYPE_RAYTRACE:String = "type_raytrace";
public static const DAEMAYA_LONGNAME_PARAMETER:String = "long_name";
public static const DAE_VELOCITY_ELEMENT:String = "velocity";
public static const DAE_SCENE_ELEMENT:String = "scene";
public static const DAE_WEIGHT_SKIN_INPUT:String = "WEIGHT";
public static const DAE_LINEAR_ELEMENT:String = "linear";
public static const DAE_HEIGHT_ELEMENT:String = "height";
public static const DAE_SEMANTIC_ATTRIBUTE:String = "semantic";
public static const DAE_CONVEX_MESH_ELEMENT:String = "convex_mesh";
public static const DAE_CREATED_ASSET_PARAMETER:String = "created";
public static const DAE_COMMENTS_ASSET_PARAMETER:String = "comments";
public static const DAEMAX_FRAMERATE_PARAMETER:String = "frame_rate";
public static const DAEMAYA_ENDTIME_PARAMETER:String = "end_time";
public static const DAE_MIP_ATTRIBUTE:String = "mip";
public static const DAE_LIBRARY_IMAGE_ELEMENT:String = "library_images";
public static const DAE_FXSTD_STATE_MASK_ELEMENT:String = "mask";
public static const DAE_RADIUS1_ELEMENT:String = "radius1";
public static const DAE_FXCMN_SEMANTIC_ELEMENT:String = "semantic";
public static const DAE_TARGETS_ELEMENT:String = "targets";
public static const DAEMAX_OUTERCONE_LIGHT_PARAMETER:String = "outer_cone";
public static const DAE_FORMAT_HINT_RGBA_VALUE:String = "RGBA";
public static const DAE_ROTATE_ELEMENT:String = "rotate";
public static const DAEMAX_SHADOW_TYPE_MAP:String = "type_map";
public static const DAE_SCHEMA_LOCATION:String = "http://www.collada.org/2005/11/COLLADASchema";
public static const DAE_LIBRARY_ANIMATION_CLIP_ELEMENT:String = "library_animation_clips";
public static const DAE_OFFSET_ATTRIBUTE:String = "offset";
public static const DAEMAYA_TEXTURE_TRANSFRAMEV_PARAMETER:String = "translateFrameV";
public static const DAE_SCHEMA_VERSION:String = "1.4.1";
public static const DAE_HOLE_ELEMENT:String = "h";
public static const DAE_FORMAT_HINT_L_VALUE:String = "L";
public static const DAEMAX_DEFAULT_TARGET_DIST_LIGHT_PARAMETER:String = "target_default_dist";
public static const DAE_RADIUS_ELEMENT:String = "radius";
public static const DAEMAYA_PROJECTION_MATRIX_PARAMETER:String = "matrix";
public static const DAEMAX_SHADOW_LIST_CASTS:String = "casts_shadows";
public static const DAE_BOX_ELEMENT:String = "box";
public static const DAE_REFLECTIVITY_MATERIAL_PARAMETER:String = "reflectivity";
public static const DAE_FXCMN_SAMPLERCUBE_ELEMENT:String = "samplerCUBE";
public static const DAE_FALLOFFANGLE_LIGHT_PARAMETER:String = "falloff_angle";
public static const DAE_FXSTD_LAMBERT_ELEMENT:String = "lambert";
public static const DAE_FALSE_KEYWORD:String = "false";
public static const DAE_INITVOLUME_ELEMENT:String = "init_volume";
public static const DAEMAX_USE_FAR_ATTEN_PARAMETER:String = "use_far_attenuation";
public static const DAE_POLYLIST_ELEMENT:String = "polylist";
public static const DAE_PHYSICS_MODEL_ELEMENT:String = "physics_model";
public static const DAE_ATTACHMENT_ELEMENT:String = "attachment";
public static const DAE_MASS_FRAME_ELEMENT:String = "mass_frame";
public static const DAEMAYA_NOTE_PARAMETER:String = "note";
public static const DAEMAYA_TEXTURE_WRAPU_PARAMETER:String = "wrapU";
public static const DAE_SPHERE_ELEMENT:String = "sphere";
public static const DAE_RIGID_CONSTRAINT_ELEMENT:String = "rigid_constraint";
public static const DAE_TEXTURE_SURFACE_ELEMENT:String = "texture_surface";
public static const DAE_ROT_LIMIT_MAX_ELEMENT:String = "rot_limit_max";
public static const DAEMAYA_HAPERTURE_PARAMETER:String = "horizontal_aperture";
public static const DAE_FXSTD_STATE_ALPHA_ELEMENT:String = "alpha";
public static const DAEMAX_FACEMAP_MATERIAL_PARAMETER:String = "face_map";
public static const DAE_PROFILE_ATTRIBUTE:String = "profile";
public static const DAEMAX_CAMERA_MB_NORMWEIGHTS_PARAMETER:String = "normalized_weights";
public static const DAE_CONST_ATTENUATION_LIGHT_PARAMETER:String = "constant_attenuation";
public static const DAEMAX_SKY_COLOR_MAP_AMOUNT_PARAMETER:String = "color_map_amount";
public static const DAE_FXCMN_FLOAT2_ELEMENT:String = "float2";
public static const DAE_LIBRARY_LIGHT_ELEMENT:String = "library_lights";
public static const DAE_X_UP:String = "X_UP";
public static const DAEMAYA_TEXTURE_BLENDMODE_PARAMETER:String = "blend_mode";
public static const DAE_FORMAT_HINT_NORMALIZED3_VALUE:String = "NORMALIZED3";
public static const DAE_AUTHORINGTOOL_ASSET_PARAMETER:String = "authoring_tool";
public static const DAE_MIPMAP_GENERATE:String = "mipmap_generate";
public static const DAEMAX_CAMERA_MB_DISPLAYPASSES_PARAMETER:String = "display_passes";
public static const DAE_METERS_ATTRIBUTE:String = "meter";
public static const DAE_INSTANCE_VSCENE_ELEMENT:String = "instance_visual_scene";
public static const DAE_INSTANCE_RIGID_BODY_ELEMENT:String = "instance_rigid_body";
public static const DAE_TAPERED_CYLINDER_ELEMENT:String = "tapered_cylinder";
public static const DAE_LIBRARY_CAMERA_ELEMENT:String = "library_cameras";
public static const DAE_TAPERED_CAPSULE_ELEMENT:String = "tapered_capsule";
public static const DAE_SAMPLER_ELEMENT:String = "sampler";
public static const DAEMAYA_VAPERTURE_PARAMETER:String = "vertical_aperture";
public static const DAE_FXSTD_BLINN_ELEMENT:String = "blinn";
public static const DAE_DATA_ELEMENT:String = "data";
public static const DAE_INPUT_ELEMENT:String = "input";
public static const DAEMAYA_LAYER_PARAMETER:String = "layer";
public static const DAEMAYA_TEXTURE_FAST_PARAMETER:String = "fast";
public static const DAE_OPTION_ELEMENT:String = "option";
public static const DAEMAYA_DOUBLE_SIDED_PARAMETER:String = "DOUBLE_SIDED";
public static const DAE_DYNAMIC_FRICTION_ATTRIBUTE:String = "dynamic_friction";
public static const DAE_AMBIENT_MATERIAL_PARAMETER:String = "ambient";
public static const DAEMAX_LIGHT_MAP:String = "light_map";
public static const DAE_STATIC_FRICTION_ATTRIBUTE:String = "static_friction";
public static const DAEMAYA_TEXTURE_REPEATV_PARAMETER:String = "repeatV";
public static const DAE_FXCMN_COMPILEROPTIONS_ELEMENT:String = "compiler_options";
public static const DAE_COLLADA_ELEMENT:String = "COLLADA";
public static const DAE_FORMAT_HINT_UNORM_VALUE:String = "UNORM";
public static const DAE_FORMAT_HINT_LA_VALUE:String = "LA";
public static const DAE_WEIGHT_MORPH_INPUT_DEPRECATED:String = "WEIGHT";
public static const DAE_URL_ATTRIBUTE:String = "url";
public static const DAE_FORMAT_HINT_XYZW_VALUE:String = "XYZW";
public static const DAEMAYA_PREINFINITY_PARAMETER:String = "pre_infinity";
public static const DAE_REST_LENGTH_ELEMENT:String = "rest_length";
public static const DAE_XFOV_CAMERA_PARAMETER:String = "xfov";
public static const DAEMAX_SHADOW_LIST_EXCLUDES:String = "list_is_exclusive";
public static const DAEMAX_SKY_COLOR_MAP_ON_PARAMETER:String = "color_map_on";
public static const DAE_POLYGONS_ELEMENT:String = "polygons";
public static const DAE_INSTANCE_ANIMATION_ELEMENT:String = "instance_animation";
public static const DAE_NODE_NODE_TYPE:String = "NODE";
public static const DAE_Z_UP:String = "Z_UP";
public static const DAE_INSTANCE_PHYSICS_MODEL_ELEMENT:String = "instance_physics_model";
public static const DAE_FXCMN_BIND_ELEMENT:String = "bind";
public static const DAE_CONSTRAINT_ATTRIBUTE:String = "constraint";
public static const DAEMAX_AMOUNT_TEXTURE_PARAMETER:String = "amount";
public static const DAE_PHYSICS_DYNAMIC_FRICTION:String = "dynamic_friction";
public static const DAE_VSCENE_ELEMENT:String = "visual_scene";
public static const DAE_RESTITUTION_ATTRIBUTE:String = "restitution";
public static const DAE_FORMAT_HINT_COMPRESSABLE_VALUE:String = "COMPRESSABLE";
public static const DAE_IMAGE_ELEMENT:String = "image";
public static const DAE_FORMAT_HINT_FLOAT_VALUE:String = "FLOAT";
public static const DAEMAYA_TEXTURE_MIRRORU_PARAMETER:String = "mirrorU";
public static const DAE_PLANE_ELEMENT:String = "plane";
public static const DAE_QUAD_ATTENUATION_LIGHT_PARAMETER:String = "quadratic_attenuation";
public static const DAE_SOURCE_ATTRIBUTE:String = "source";
public static const DAE_FXSTD_STATE_DEST_ELEMENT:String = "dest";
public static const DAE_FORMAT_HINT_UINT_VALUE:String = "UINT";
public static const DAE_FXSTD_STATE_ZPASS_ELEMENT:String = "zpass";
public static const DAE_CLOSED_ATTRIBUTE:String = "closed";
public static const DAE_CONVEX_HULL_OF_ATTRIBUTE:String = "convex_hull_of";
public static const DAE_INERTIA_ELEMENT:String = "inertia";
public static const DAE_FXCMN_HINT_ELEMENT:String = "technique_hint";
public static const DAE_CYLINDER_ELEMENT:String = "cylinder";
public static const DAE_FXCMN_NAME_ELEMENT:String = "name";
public static const DAE_INTERPENETRATE_ELEMENT:String = "interpenetrate";
public static const DAE_CONTROLLER_ELEMENT:String = "controller";
public static const DAE_PARAMETER:String = "param";
public static const DAE_LIMITS_ELEMENT:String = "limits";
public static const DAE_LIGHT_SPOT_ELEMENT:String = "spot";
public static const DAEFC_EASE_INOUT_ANIMATION_INPUT:String = "EASE_IN_OUT";
public static const DAE_SHAPE_ELEMENT:String = "shape";
public static const DAE_TRUE_KEYWORD:String = "true";
public static const DAE_MIN_ELEMENT:String = "min";
public static const DAE_TRIFANS_ELEMENT:String = "trifans";
public static const DAE_FXSTD_TEXTURE_ATTRIBUTE:String = "texture";
public static const DAEMAX_CAMERA_TARGETDISTANCE_PARAMETER:String = "target_distance";
public static const DAE_INPUT_SET_ATTRIBUTE:String = "input_set";
public static const DAE_MATERIAL_ATTRIBUTE:String = "material";
public static const DAE_FXSTD_STATE_VALUE:String = "value";
public static const DAEMAYA_STARTTIME_PARAMETER:String = "start_time";
public static const DAEMAYA_BLINDNAME_PARAMETER:String = "BLINDNAME";
public static const DAE_FXCMN_INT_ELEMENT:String = "int";
public static const DAE_FORMAT_HINT_HIGH_VALUE:String = "HIGH";
public static const DAE_TRANSLATE_ELEMENT:String = "translate";
public static const DAE_INTERPOLATION_ANIMATION_INPUT:String = "INTERPOLATION";
public static const DAEMAX_SHADOW_PROJ_COLOR:String = "shadow_color";
public static const DAE_ID_ATTRIBUTE:String = "id";
public static const DAE_EMISSION_MATERIAL_PARAMETER:String = "emission";
public static const DAE_PHYSICS_MATERIAL_ELEMENT:String = "physics_material";
public static const DAEMAX_NEAR_ATTEN_END_PARAMETER:String = "near_attenuation_end";
public static const DAE_LIBRARY_MATERIAL_ELEMENT:String = "library_materials";
public static const DAE_DYNAMIC_ELEMENT:String = "dynamic";
public static const DAE_START_ATTRIBUTE:String = "start";
public static const DAEMAYA_PROJECTION_TYPE:String = "type";
public static const DAE_FXCMN_FRAGMENT_SHADER:String = "FRAGMENT";
public static const DAE_FXSTD_STATE_FRONT_ELEMENT:String = "front";
public static const DAE_FXSTD_STATE_SRC_ELEMENT:String = "src";
public static const DAE_LIGHT_ELEMENT:String = "light";
public static const DAE_INITPLANAR_ELEMENT:String = "init_planar";
public static const DAE_VDEGREE_ATTRIBUTE:String = "vdegree";
public static const DAEMAX_DECAY_TYPE:String = "decay_type";
public static const DAE_SIZE_ELEMENT:String = "size";
public static const DAEMAX_SHADOW_TYPE:String = "type";
public static const DAE_CONTROLLER_MORPH_ELEMENT:String = "morph";
public static const DAE_ASPECT_CAMERA_PARAMETER:String = "aspect_ratio";
public static const DAEMAYA_TEXTURE_ROTATEUV_PARAMETER:String = "rotateUV";
public static const DAEMAX_FILTERCOLOR_MATERIAL_PARAMETER:String = "filter_color";
public static const DAE_LIBRARY_GEOMETRY_ELEMENT:String = "library_geometries";
public static const DAE_OPAQUE_MATERIAL_ATTRIBUTE:String = "opaque";
public static const DAE_SCALE_ELEMENT:String = "scale";
public static const DAE_LIBRARY_PMODEL_ELEMENT:String = "library_physics_models";
public static const DAE_INSTANCE_EMITTER_ELEMENT:String = "instance_emitter";
public static const DAEMAX_CAMERA_MB_TOTALPASSES_PARAMETER:String = "total_passes";
public static const DAE_FXSTD_STATE_DESTALPHA_ELEMENT:String = "dest_alpha";
public static const DAEMAX_USE_NEAR_ATTEN_PARAMETER:String = "use_near_attenuation";
public static const DAE_INITFROM_ELEMENT:String = "init_from";
public static const DAE_CONTROL_VERTICES_ELEMENT:String = "control_vertices";
public static const DAE_BIND_ELEMENT:String = "bind";
public static const DAE_COUNT_ATTRIBUTE:String = "count";
public static const DAE_INDEX_ATTRIBUTE:String = "index";
public static const DAE_PHYSICS_SCENE_ELEMENT:String = "physics_scene";
public static const DAE_MODIFIED_ASSET_PARAMETER:String = "modified";
public static const DAE_SPRING_ELEMENT:String = "spring";
public static const DAE_FXCMN_SURFACE_ELEMENT:String = "surface";
public static const DAE_FXSTD_TEXTURESET_ATTRIBUTE:String = "texcoord";
public static const DAE_LOOKAT_ELEMENT:String = "lookat";
public static const DAE_NAME_TYPE:String = "Name";
public static const DAEMAX_CAMERA_MB_DURATION_PARAMETER:String = "duration";
public static const DAE_FORMAT_HINT_MID_VALUE:String = "MID";
public static const DAEMAX_SHADOW_ATTRIBS:String = "shadow_attributes";
public static const DAE_SOURCE_ELEMENT:String = "source";
public static const DAE_ELLIPSOID_ELEMENT:String = "ellipsoid";
public static const DAEMAX_SHADOW_PROJ_COLOR_MULT:String = "shadow_color_mult";
public static const DAEMAYA_WEIGHT_INPUT:String = "WEIGHT";
public static const DAE_BOOL_ARRAY_ELEMENT:String = "bool_array";
public static const DAE_WEIGHT_MORPH_INPUT:String = "MORPH_WEIGHT";
public static const DAE_LIGHT_DIRECTIONAL_ELEMENT:String = "directional";
public static const DAEMAYA_TEXTURE_NOISEU_PARAMETER:String = "noiseU";
public static const DAEMAYA_BLINDTYPE:String = "BLINDTYPEID";
public static const DAE_STRIDE_ATTRIBUTE:String = "stride";
public static const DAE_CAMERA_PERSP_ELEMENT:String = "perspective";
public static const DAE_METHOD_ATTRIBUTE:String = "method";
public static const DAE_SPECULAR_MATERIAL_PARAMETER:String = "specular";
public static const DAE_FXSTD_STATE_BACK_ELEMENT:String = "back";
public static const DAE_TARGET_VALUE:String = "target_value";
public static const DAE_INITASNULL_ELEMENT:String = "init_as_null";
public static const DAE_WEIGHTS_ELEMENT:String = "vertex_weights";
public static const DAE_SHADER:String = "shader";
public static const DAEMAX_SKY_LIGHT:String = "skylight";
public static const DAE_SHININESS_MATERIAL_PARAMETER:String = "shininess";
public static const DAE_CHANNEL_ELEMENT:String = "channel";
public static const DAE_WIDTH_ELEMENT:String = "width";
public static const DAE_PROFILE_COMMON_ELEMENT:String = "profile_COMMON";
public static const DAE_DEPTH_ELEMENT:String = "depth";
public static const DAE_YMAG_CAMERA_PARAMETER:String = "ymag";
public static const DAE_TEXTURE_ELEMENT:String = "texture";
public static const DAEMAX_FAR_ATTEN_END_PARAMETER:String = "far_attenuation_end";
public static const DAE_FXCMN_BOOL_ELEMENT:String = "bool";
public static const DAE_INSTANCE_CONTROLLER_ELEMENT:String = "instance_controller";
public static const DAE_FXCMN_CODE_ELEMENT:String = "code";
public static const DAE_FACE_ATTRIBUTE:String = "face";
public static const DAE_WEIGHT_SPLINE_INPUT:String = "WEIGHTS";
public static const DAE_INSTANCE_CAMERA_ELEMENT:String = "instance_camera";
public static const DAEMAYA_TEXTURE_WRAPV_PARAMETER:String = "wrapV";
public static const DAE_TRIANGLES_ELEMENT:String = "triangles";
public static const DAE_ACCESSOR_ELEMENT:String = "accessor";
public static const DAE_AUTHOR_ASSET_PARAMETER:String = "author";
public static const DAE_EQUATION_ELEMENT:String = "equation";
public static const DAE_SKELETON_ELEMENT:String = "skeleton";
public static const DAEMAX_NEAR_ATTEN_START_PARAMETER:String = "near_attenuation_start";
public static const DAEMAX_CAMERA_MB_TILESIZE_PARAMETER:String = "tile_size";
public static const DAE_LINES_ELEMENT:String = "lines";
public static const DAE_ENABLED_ELEMENT:String = "enabled";
public static const DAE_IDREF_ARRAY_ELEMENT:String = "IDREF_array";
public static const DAE_BIND_VERTEX_INPUT:String = "bind_vertex_input";
public static const DAE_VERTEX_ELEMENT:String = "v";
public static const DAE_ZFAR_CAMERA_PARAMETER:String = "zfar";
public static const DAE_KNOT_SPLINE_INPUT:String = "KNOTS";
public static const DAE_LIBRARY_EFFECT_ELEMENT:String = "library_effects";
public static const DAE_FALLOFFEXPONENT_LIGHT_PARAMETER:String = "falloff_exponent";
public static const DAE_CLOSEDU_ATTRIBUTE:String = "closed_u";
public static const DAEMAX_SKY_RAY_BIAS_PARAMETER:String = "ray_bias";
public static const DAE_NAMESPACE_ATTRIBUTE:String = "xmlns";
public static const DAE_TIME_STEP_ATTRIBUTE:String = "time_step";
public static const DAE_FXSTD_STATE_SRCALPHA_ELEMENT:String = "src_alpha";
public static const DAE_ROT_LIMIT_MIN_ELEMENT:String = "rot_limit_min";
public static const DAEMAYA_AMBIENTSHADE_LIGHT_PARAMETER:String = "ambient_shade";
public static const DAEMAYA_TEXTURE_COVERAGEU_PARAMETER:String = "coverageU";
public static const DAE_OUTTANGENT_ANIMATION_INPUT:String = "OUT_TANGENT";
public static const DAE_FXCMN_HALF4_ELEMENT:String = "half4";
public static const DAE_HOLLOW_ELEMENT:String = "hollow";
public static const DAEMAYA_MAYA_PROFILE:String = "MAYA";
public static const DAE_IMAGE_INPUT:String = "IMAGE";
public static const DAE_FXSTD_STATE_MODE_ELEMENT:String = "mode";
public static const DAE_JOINT_SKIN_INPUT:String = "JOINT";
public static const DAE_FORMAT_HINT_SNORM_VALUE:String = "SNORM";
public static const DAE_BIND_TEXTURE_SURFACE_ELEMENT:String = "bind_texture_surface";
public static const DAE_CHANNELS_ELEMENT:String = "channels";
public static const DAEFC_TCB_ANIMATION_INPUT:String = "TCB";
public static const DAE_REVISION_ASSET_PARAMETER:String = "revision";
public static const DAE_BINDMATRIX_SKIN_INPUT:String = "INV_BIND_MATRIX";
public static const DAE_FXSTD_STATE_FUNC_ELEMENT:String = "func";
public static const DAE_ANIMCLIP_ELEMENT:String = "animation_clip";
public static const DAE_CAMERA_ELEMENT:String = "camera";
public static const DAEMAX_TARGET_CAMERA_PARAMETER:String = "target";
public static const DAE_TYPE_ATTRIBUTE:String = "type";
public static const DAE_INSTANCE_PHYSICS_SCENE_ELEMENT:String = "instance_physics_scene";
public static const DAEMAX_SHADOW_AFFECTS:String = "affect_list";
public static const DAESHD_DOUBLESIDED_PARAMETER:String = "double_sided";
public static const DAEMAYA_TEXTURE_STAGGER_PARAMETER:String = "stagger";
public static const DAE_LIBRARY_FFIELDS_ELEMENT:String = "library_force_fields";
public static const DAE_REFLECTIVE_MATERIAL_PARAMETER:String = "reflective";
public static const DAEMAX_SHADOW_LIST_NODE:String = "list_nodes";
public static const DAE_DYNAMICS_ELEMENT:String = "dynamics";
public static const DAE_DAMPING_ELEMENT:String = "damping";
public static const DAE_FXSTD_TEXTURE_ELEMENT:String = "texture";
public static const DAE_VALUE:String = "value";
public static const DAE_REF_ATTACHMENT_ELEMENT:String = "ref_attachment";
public static const DAE_DIFFUSE_MATERIAL_PARAMETER:String = "diffuse";
public static const DAE_FORMAT_HINT_NORMALIZED4_VALUE:String = "NORMALIZED4";
public static const DAE_FXCMN_COMPILERTARGET_ELEMENT:String = "compiler_target";
public static const DAE_CONTRIBUTOR_ASSET_ELEMENT:String = "contributor";
public static const DAEMAX_INDEXOFREFRACTION_MATERIAL_PARAMETER:String = "index_of_refraction";
public static const DAE_FXSTD_STATE_RGB_ELEMENT:String = "rgb";
public static const DAE_INITCUBE_ELEMENT:String = "init_cube";
public static const DAE_BODY_ATTRIBUTE:String = "body";
public static const DAE_POLYGON_ELEMENT:String = "p";
public static const DAE_TRANSPARENCY_MATERIAL_PARAMETER:String = "transparency";
public static const DAEMAYA_TEXTURE_OFFSETU_PARAMETER:String = "offsetU";
public static const DAE_FXCMN_STRING_ELEMENT:String = "string";
public static const DAE_MESH_ELEMENT:String = "mesh";
public static const DAEMAYA_TEXTURE_MIRRORV_PARAMETER:String = "mirrorV";
public static const DAEMAX_SKY_SKYMODE:String = "sky_mode";
public static const DAE_CONTROLLER_SKIN_ELEMENT:String = "skin";
public static const DAE_UDEGREE_ATTRIBUTE:String = "udegree";
public static const DAEMAX_DECAY_START_PARAMETER:String = "decay_start";
public static const DAEMAYA_PROJECTION_ELEMENT:String = "projection";
public static const DAE_CAMERA_ORTHO_ELEMENT:String = "orthographic";
public static const DAE_FXCMN_FLOAT_ELEMENT:String = "float";
public static const DAE_SOURCEDATA_ASSET_PARAMETER:String = "source_data";
public static const DAEMAX_FACETED_MATERIAL_PARAMETER:String = "faceted";
public static const DAE_TARGET_MORPH_INPUT:String = "MORPH_TARGET";
public static const DAE_MATRIX_ELEMENT:String = "matrix";
public static const DAE_SPLINE_ELEMENT:String = "spline";
public static const DAE_SET_ATTRIBUTE:String = "set";
public static const DAE_LINESTRIPS_ELEMENT:String = "linestrips";
public static const DAE_COPYRIGHT_ASSET_PARAMETER:String = "copyright";
public static const DAE_ORDER_ELEMENT:String = "order";
public static const DAEMAYA_DRIVER_INPUT:String = "DRIVER";
public static const DAE_FXCMN_HALF3_ELEMENT:String = "half3";
public static const DAEMAX_DISPLACEMENT_MATERIAL_PARAMETER:String = "displacement";
public static const DAE_A_ONE_ELEMENT:String = "A_ONE";
public static const DAE_UNITS_ASSET_PARAMETER:String = "unit";
public static const DAE_TRANSPARENT_MATERIAL_PARAMETER:String = "transparent";
public static const DAE_NAME_ARRAY_ELEMENT:String = "Name_array";
public static const DAEMAX_SKY_COLOR_MAP:String = "color_map";
public static const DAEMAYA_POSTINFINITY_PARAMETER:String = "post_infinity";
public static const DAE_TRANS_LIMIT_MAX_ELEMENT:String = "trans_limit_max";
public static const DAE_FACE_ELEMENT:String = "face";
public static const DAE_BINDMATERIAL_ELEMENT:String = "bind_material";
public static const DAEMAX_SPECLEVEL_MATERIAL_PARAMETER:String = "spec_level";
public static const DAE_INSTANCE_RIGID_CONSTRAINT_ELEMENT:String = "instance_rigid_constraint";
public static const DAE_FXSTD_CONSTANT_ELEMENT:String = "constant";
public static const DAE_ANGULAR_ELEMENT:String = "angular";
public static const DAEMAX_LIGHT_AFFECTS_SHADOW:String = "light_affects_shadow";
public static const DAE_RGB_ZERO_ELEMENT:String = "RGB_ZERO";
public static const DAE_OUTPUT_ANIMATION_INPUT:String = "OUTPUT";
public static const DAE_LIBRARY_CONTROLLER_ELEMENT:String = "library_controllers";
public static const DAE_LIBRARY_PSCENE_ELEMENT:String = "library_physics_scenes";
public static const DAE_VERSION_ATTRIBUTE:String = "version";
public static const DAE_MATRIX_TYPE:String = "float4x4";
public static const DAEMAX_SHADOW_LIST_ILLUMINATES:String = "is_illuminated";
public static const DAE_LIN_ATTENUATION_LIGHT_PARAMETER:String = "linear_attenuation";
public static const DAE_PRIMARY_ELEMENT:String = "primary";
public static const DAEMAX_MAX_PROFILE:String = "MAX3D";
public static const DAE_FORCE_FIELD_ELEMENT:String = "force_field";
public static const DAE_BINDSHAPEMX_SKIN_PARAMETER:String = "bind_shape_matrix";
public static const DAE_TECHNIQUE_ELEMENT:String = "technique";
public static const DAE_Y_UP:String = "Y_UP";
public static const DAE_FXSTD_COLOR_ELEMENT:String = "color";
public static const DAE_FLOAT_ARRAY_ELEMENT:String = "float_array";
public static const DAEMAX_EMISSIONLEVEL_MATERIAL_PARAMETER:String = "emission_level";
public static const DAE_POLYGONHOLED_ELEMENT:String = "ph";
public static const DAEMAX_SKY_CAST_SHADOWS_PARAMETER:String = "cast_shadows";
public static const DAE_INDEXOFREFRACTION_MATERIAL_PARAMETER:String = "index_of_refraction";
public static const DAE_TEXTURE_INPUT:String = "TEXTURE";
public static const DAE_UP:String = "up_axis";
public static const DAE_PHYSICS_RESTITUTION:String = "restitution";
public static const DAE_IDREF_TYPE:String = "IDREF";
public static const DAE_ANNOTATE_ELEMENT:String = "annotate";
public static const DAE_INPUT_ANIMATION_INPUT:String = "INPUT";
public static const DAE_JOINT_NODE_TYPE:String = "JOINT";
public static const DAE_INPUT_SEMANTIC_ATTRIBUTE:String = "input_semantic";
public static const DAE_PRECISION_ELEMENT:String = "precision";
public static const DAE_FXCMN_SAMPLER1D_ELEMENT:String = "sampler1D";
public static const DAE_SWING_CONE_AND_TWIST_ELEMENT:String = "swing_cone_and_twist";
public static const DAEMAYA_TEXTURE_TRANSFRAMEU_PARAMETER:String = "translateFrameU";
public static const DAE_FORMAT_HINT_XYZ_VALUE:String = "XYZ";
public static const DAE_MIP_LEVELS:String = "mip_levels";
public static const DAE_TEXTURE_ATTRIBUTE:String = "texture";
public static const DAE_FXCMN_ANNOTATE_ELEMENT:String = "annotate";
public static const DAE_FXCMN_HALF2_ELEMENT:String = "half2";
public static const DAE_LIBRARY_NODE_ELEMENT:String = "library_nodes";
public static const DAE_FORMAT_HINT_SRGB_GAMMA_VALUE:String = "SRGB_GAMMA";
public static const DAE_FORMAT_HINT_RGB_VALUE:String = "RGB";
public static const DAE_INSTANCE_EFFECT_ELEMENT:String = "instance_effect";
public static const DAE_XMAG_CAMERA_PARAMETER:String = "xmag";
public static const DAEMAX_CAMERA_MB_DITHERSTRENGTH_PARAMETER:String = "dither_strength";
public static const DAEMAYA_TEXTURE_NOISEV_PARAMETER:String = "noiseV";
public static const DAE_KEYWORDS_ASSET_PARAMETER:String = "keywords";
public static const DAE_ANGULAR_VELOCITY_ELEMENT:String = "angular_velocity";
public static const DAE_TITLE_ASSET_PARAMETER:String = "title";
public static const DAE_LIBRARY_PMATERIAL_ELEMENT:String = "library_physics_materials";
public static const DAE_END_ATTRIBUTE:String = "end";
public static const DAE_TECHNIQUE_COMMON_ELEMENT:String = "technique_common";
public static const DAE_LIBRARY_EMITTER_ELEMENT:String = "library_emitters";
public static const DAE_HALF_EXTENTS_ELEMENT:String = "half_extents";
public static const DAE_INSTANCE_NODE_ELEMENT:String = "instance_node";
public static const DAE_FXSTD_STATE_DESTRGB_ELEMENT:String = "dest_rgb";
public static const DAE_JOINTS_ELEMENT:String = "joints";
public static const DAE_NAME_ATTRIBUTE:String = "name";
public static const DAEMAX_CAMERA_MOTIONBLUR_ELEMENT:String = "motion_blur";
public static const DAE_STAGE_ATTRIBUTE:String = "stage";
public static const DAEMAX_FAR_ATTEN_START_PARAMETER:String = "far_attenuation_start";
public static const DAE_SID_ATTRIBUTE:String = "sid";
public static const DAE_DENSITY_ELEMENT:String = "density";
public static const DAE_FXSTD_STATE_REF_ELEMENT:String = "ref";
public static const DAEMAX_CAMERA_MB_DISABLEANTIALIAS_PARAMETER:String = "disable_antialiasing";
public static const DAE_TARGET_MORPH_INPUT_DEPRECATED:String = "TARGET";
public static const DAEMAX_TARGET_LIGHT_PARAMETER:String = "target";
public static const DAE_MATERIAL_ELEMENT:String = "material";
public static const DAE_PHYSICS_STATIC_FRICTION:String = "static_friction";
public static const DAE_ALL_ELEMENT:String = "all";
public static const DAE_FXSTD_PHONG_ELEMENT:String = "phong";
public static const DAE_FORMAT_HINT_D_VALUE:String = "D";
public static const DAE_CLOSEDV_ATTRIBUTE:String = "closed_v";
public static const DAE_CAPSULE_ELEMENT:String = "capsule";
public static const DAE_FXCMN_NEWPARAM_ELEMENT:String = "newparam";
public static const DAE_ASSET_ELEMENT:String = "asset";
public static const DAE_FXSTD_STATE_FAIL_ELEMENT:String = "fail";
public static const DAE_SUBJECT_ASSET_PARAMETER:String = "subject";
public static const DAE_EFFECT_ELEMENT:String = "effect";
public static const DAE_PLATFORM_ATTRIBUTE:String = "platform";
public static const DAE_ANIMATION_ELEMENT:String = "animation";
public static const DAEMAYA_TEXTURE_REPEATU_PARAMETER:String = "repeatU";
public static const DAEMAYA_TEXTURE_COVERAGEV_PARAMETER:String = "coverageV";
}
}//package org.ascollada
Section 145
//Camera3D (org.papervision3d.cameras.Camera3D)
package org.papervision3d.cameras {
import flash.geom.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.culling.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.core.math.*;
import flash.utils.*;
public class Camera3D extends CameraObject3D {
protected var _focusFix:Matrix3D;
protected var _prevUseProjection:Boolean;
protected var _prevZoom:Number;
protected var _prevOrtho:Boolean;
protected var _prevWidth:Number;
protected var _prevHeight:Number;
protected var _prevFocus:Number;
protected var _prevOrthoProjection:Boolean;
protected var _projection:Matrix3D;
public function Camera3D(_arg1:Number=60, _arg2:Number=10, _arg3:Number=5000, _arg4:Boolean=false, _arg5:Boolean=false){
super(_arg2, 40);
this.fov = _arg1;
_prevFocus = 0;
_prevZoom = 0;
_prevOrtho = false;
_prevUseProjection = false;
_useCulling = _arg4;
_useProjectionMatrix = _arg5;
_far = _arg3;
_focusFix = Matrix3D.IDENTITY;
}
public function update(_arg1:Rectangle):void{
if (!_arg1){
throw (new Error(("Camera3D#update: Invalid viewport rectangle! " + _arg1)));
};
this.viewport = _arg1;
_prevFocus = this.focus;
_prevZoom = this.zoom;
_prevWidth = this.viewport.width;
_prevHeight = this.viewport.height;
if (_prevOrtho != this.ortho){
if (this.ortho){
_prevOrthoProjection = this.useProjectionMatrix;
this.useProjectionMatrix = true;
} else {
this.useProjectionMatrix = _prevOrthoProjection;
};
} else {
if (_prevUseProjection != _useProjectionMatrix){
this.useProjectionMatrix = this._useProjectionMatrix;
};
};
_prevOrtho = this.ortho;
_prevUseProjection = _useProjectionMatrix;
this.useCulling = _useCulling;
}
override public function set near(_arg1:Number):void{
if (_arg1 > 0){
this.focus = _arg1;
this.update(this.viewport);
};
}
override public function orbit(_arg1:Number, _arg2:Number, _arg3:Boolean=true, _arg4:DisplayObject3D=null):void{
var _local8:Number;
_arg4 = ((_arg4) || (_target));
_arg4 = ((_arg4) || (DisplayObject3D.ZERO));
if (_arg3){
_arg1 = (_arg1 * (Math.PI / 180));
_arg2 = (_arg2 * (Math.PI / 180));
};
var _local5:Number = (_arg4.world.n14 - this.x);
var _local6:Number = (_arg4.world.n24 - this.y);
var _local7:Number = (_arg4.world.n34 - this.z);
_local8 = Math.sqrt((((_local5 * _local5) + (_local6 * _local6)) + (_local7 * _local7)));
var _local9:Number = (Math.cos(_arg2) * Math.sin(_arg1));
var _local10:Number = (Math.sin(_arg2) * Math.sin(_arg1));
var _local11:Number = Math.cos(_arg1);
this.x = (_arg4.world.n14 + (_local9 * _local8));
this.y = (_arg4.world.n24 + (_local11 * _local8));
this.z = (_arg4.world.n34 + (_local10 * _local8));
this.lookAt(_arg4);
}
override public function set useCulling(_arg1:Boolean):void{
super.useCulling = _arg1;
if (_useCulling){
if (!this.culler){
this.culler = new FrustumCuller();
};
FrustumCuller(this.culler).initialize(this.fov, (this.viewport.width / this.viewport.height), (this.focus / this.zoom), _far);
} else {
this.culler = null;
};
}
override public function projectFaces(_arg1:Array, _arg2:DisplayObject3D, _arg3:RenderSessionData):Number{
var _local17:Number;
var _local18:Number;
var _local19:Number;
var _local20:Number;
var _local21:Number;
var _local22:Number;
var _local23:Number;
var _local24:Vertex3D;
var _local25:Vertex3DInstance;
var _local26:Number;
var _local34:Array;
var _local36:Triangle3D;
var _local4:Matrix3D = _arg2.view;
var _local5:Number = _local4.n11;
var _local6:Number = _local4.n12;
var _local7:Number = _local4.n13;
var _local8:Number = _local4.n21;
var _local9:Number = _local4.n22;
var _local10:Number = _local4.n23;
var _local11:Number = _local4.n31;
var _local12:Number = _local4.n32;
var _local13:Number = _local4.n33;
var _local14:Number = _local4.n41;
var _local15:Number = _local4.n42;
var _local16:Number = _local4.n43;
var _local27:int;
var _local28:Number = _arg3.camera.focus;
var _local29:Number = (_local28 * _arg3.camera.zoom);
var _local30:Number = (viewport.width / 2);
var _local31:Number = (viewport.height / 2);
var _local32:Number = _arg3.camera.far;
var _local33:Number = (_local32 - _local28);
var _local35:Number = getTimer();
for each (_local36 in _arg1) {
_local34 = _local36.vertices;
_local27 = _local34.length;
while ((_local24 = _local34[--_local27])) {
if (_local24.timestamp == _local35){
} else {
_local24.timestamp = _local35;
_local17 = _local24.x;
_local18 = _local24.y;
_local19 = _local24.z;
_local22 = ((((_local17 * _local11) + (_local18 * _local12)) + (_local19 * _local13)) + _local4.n34);
_local25 = _local24.vertex3DInstance;
if (_useProjectionMatrix){
_local23 = ((((_local17 * _local14) + (_local18 * _local15)) + (_local19 * _local16)) + _local4.n44);
_local22 = (_local22 / _local23);
if ((_local25.visible = (((_local22 > 0)) && ((_local22 < 1))))){
_local20 = (((((_local17 * _local5) + (_local18 * _local6)) + (_local19 * _local7)) + _local4.n14) / _local23);
_local21 = (((((_local17 * _local8) + (_local18 * _local9)) + (_local19 * _local10)) + _local4.n24) / _local23);
_local25.x = (_local20 * _local30);
_local25.y = (_local21 * _local31);
_local25.z = (_local22 * _local23);
};
} else {
if ((_local25.visible = ((_local28 + _local22) > 0))){
_local20 = ((((_local17 * _local5) + (_local18 * _local6)) + (_local19 * _local7)) + _local4.n14);
_local21 = ((((_local17 * _local8) + (_local18 * _local9)) + (_local19 * _local10)) + _local4.n24);
_local26 = (_local29 / (_local28 + _local22));
_local25.x = (_local20 * _local26);
_local25.y = (_local21 * _local26);
_local25.z = _local22;
};
};
};
};
};
return (0);
}
override public function set orthoScale(_arg1:Number):void{
super.orthoScale = _arg1;
this.useProjectionMatrix = this.useProjectionMatrix;
_prevOrtho = !(this.ortho);
this.update(this.viewport);
}
override public function set useProjectionMatrix(_arg1:Boolean):void{
var _local2:Number;
var _local3:Number;
if (_arg1){
if (this.ortho){
_local2 = (viewport.width / 2);
_local3 = (viewport.height / 2);
_projection = createOrthoMatrix(-(_local2), _local2, -(_local3), _local3, -(_far), _far);
_projection = Matrix3D.multiply(_orthoScaleMatrix, _projection);
} else {
_projection = createPerspectiveMatrix(fov, (viewport.width / viewport.height), this.focus, this.far);
};
} else {
if (this.ortho){
_arg1 = true;
};
};
super.useProjectionMatrix = _arg1;
}
override public function transformView(_arg1:Matrix3D=null):void{
if (((((((((((!((ortho == _prevOrtho))) || (!((_prevUseProjection == _useProjectionMatrix))))) || (!((focus == _prevFocus))))) || (!((zoom == _prevZoom))))) || (!((viewport.width == _prevWidth))))) || (!((viewport.height == _prevHeight))))){
update(viewport);
};
if (_target){
lookAt(_target);
} else {
if (_transformDirty){
updateTransform();
};
};
if (_useProjectionMatrix){
super.transformView();
this.eye.calculateMultiply4x4(_projection, this.eye);
} else {
_focusFix.copy(this.transform);
_focusFix.n14 = (_focusFix.n14 + (focus * this.transform.n13));
_focusFix.n24 = (_focusFix.n24 + (focus * this.transform.n23));
_focusFix.n34 = (_focusFix.n34 + (focus * this.transform.n33));
super.transformView(_focusFix);
};
if ((culler is FrustumCuller)){
FrustumCuller(culler).transform.copy(this.transform);
};
}
override public function set far(_arg1:Number):void{
if (_arg1 > this.focus){
_far = _arg1;
this.update(this.viewport);
};
}
override public function projectVertices(_arg1:Array, _arg2:DisplayObject3D, _arg3:RenderSessionData):Number{
var _local17:Number;
var _local18:Number;
var _local19:Number;
var _local20:Number;
var _local21:Number;
var _local22:Number;
var _local23:Number;
var _local24:Vertex3D;
var _local25:Vertex3DInstance;
var _local26:Number;
var _local4:Matrix3D = _arg2.view;
var _local5:Number = _local4.n11;
var _local6:Number = _local4.n12;
var _local7:Number = _local4.n13;
var _local8:Number = _local4.n21;
var _local9:Number = _local4.n22;
var _local10:Number = _local4.n23;
var _local11:Number = _local4.n31;
var _local12:Number = _local4.n32;
var _local13:Number = _local4.n33;
var _local14:Number = _local4.n41;
var _local15:Number = _local4.n42;
var _local16:Number = _local4.n43;
var _local27:int = _arg1.length;
var _local28:Number = _arg3.camera.focus;
var _local29:Number = (_local28 * _arg3.camera.zoom);
var _local30:Number = (viewport.width / 2);
var _local31:Number = (viewport.height / 2);
var _local32:Number = _arg3.camera.far;
var _local33:Number = (_local32 - _local28);
while ((_local24 = _arg1[--_local27])) {
_local17 = _local24.x;
_local18 = _local24.y;
_local19 = _local24.z;
_local22 = ((((_local17 * _local11) + (_local18 * _local12)) + (_local19 * _local13)) + _local4.n34);
_local25 = _local24.vertex3DInstance;
if (_useProjectionMatrix){
_local23 = ((((_local17 * _local14) + (_local18 * _local15)) + (_local19 * _local16)) + _local4.n44);
_local22 = (_local22 / _local23);
if ((_local25.visible = (((_local22 > 0)) && ((_local22 < 1))))){
_local20 = (((((_local17 * _local5) + (_local18 * _local6)) + (_local19 * _local7)) + _local4.n14) / _local23);
_local21 = (((((_local17 * _local8) + (_local18 * _local9)) + (_local19 * _local10)) + _local4.n24) / _local23);
_local25.x = (_local20 * _local30);
_local25.y = (_local21 * _local31);
_local25.z = (_local22 * _local23);
};
} else {
if ((_local25.visible = ((_local28 + _local22) > 0))){
_local20 = ((((_local17 * _local5) + (_local18 * _local6)) + (_local19 * _local7)) + _local4.n14);
_local21 = ((((_local17 * _local8) + (_local18 * _local9)) + (_local19 * _local10)) + _local4.n24);
_local26 = (_local29 / (_local28 + _local22));
_local25.x = (_local20 * _local26);
_local25.y = (_local21 * _local26);
_local25.z = _local22;
};
};
};
return (0);
}
public static function createPerspectiveMatrix(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Matrix3D{
var _local5:Number = ((_arg1 / 2) * (Math.PI / 180));
var _local6:Number = Math.tan(_local5);
var _local7:Number = (1 / _local6);
return (new Matrix3D([(_local7 / _arg2), 0, 0, 0, 0, _local7, 0, 0, 0, 0, -(((_arg3 + _arg4) / (_arg3 - _arg4))), (((2 * _arg4) * _arg3) / (_arg3 - _arg4)), 0, 0, 1, 0]));
}
public static function createOrthoMatrix(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:Number):Matrix3D{
var _local7:Number = ((_arg2 + _arg1) / (_arg2 - _arg1));
var _local8:Number = ((_arg4 + _arg3) / (_arg4 - _arg3));
var _local9:Number = ((_arg6 + _arg5) / (_arg6 - _arg5));
var _local10:Matrix3D = new Matrix3D([(2 / (_arg2 - _arg1)), 0, 0, _local7, 0, (2 / (_arg4 - _arg3)), 0, _local8, 0, 0, (-2 / (_arg6 - _arg5)), _local9, 0, 0, 0, 1]);
_local10.calculateMultiply(Matrix3D.scaleMatrix(1, 1, -1), _local10);
return (_local10);
}
}
}//package org.papervision3d.cameras
Section 146
//AbstractChannel3D (org.papervision3d.core.animation.channel.AbstractChannel3D)
package org.papervision3d.core.animation.channel {
import org.papervision3d.objects.*;
import org.papervision3d.core.animation.*;
public class AbstractChannel3D {
public var endTime:Number;
public var name:String;
public var startTime:Number;
public var target:DisplayObject3D;
public var duration:Number;
public var currentIndex:int;
public var nextIndex:int;
public var nextKeyFrame:AnimationKeyFrame3D;
public var keyFrames:Array;
public var currentTime:Number;
public var currentKeyFrame:AnimationKeyFrame3D;
public var frameDuration:Number;
public var frameAlpha:Number;
public function AbstractChannel3D(_arg1:DisplayObject3D, _arg2:String=null){
this.target = _arg1;
this.name = _arg2;
this.startTime = (this.endTime = 0);
this.keyFrames = new Array();
this.currentKeyFrame = (this.nextKeyFrame = null);
this.currentIndex = (this.nextIndex = -1);
this.frameAlpha = 0;
}
public function updateToTime(_arg1:Number):void{
currentIndex = Math.floor(((this.keyFrames.length - 1) * _arg1));
currentIndex = ((currentIndex < (this.keyFrames.length - 1))) ? currentIndex : 0;
nextIndex = (currentIndex + 1);
currentKeyFrame = this.keyFrames[currentIndex];
nextKeyFrame = ((nextIndex < this.keyFrames.length)) ? this.keyFrames[nextIndex] : null;
frameDuration = (nextKeyFrame) ? (nextKeyFrame.time - currentKeyFrame.time) : currentKeyFrame.time;
currentTime = (_arg1 * this.duration);
frameAlpha = ((currentTime - currentKeyFrame.time) / frameDuration);
frameAlpha = ((frameAlpha < 0)) ? 0 : frameAlpha;
frameAlpha = ((frameAlpha > 1)) ? 1 : frameAlpha;
}
public function updateToFrame(_arg1:uint):void{
if (!this.keyFrames.length){
return;
};
currentIndex = _arg1;
currentIndex = ((currentIndex < (this.keyFrames.length - 1))) ? currentIndex : 0;
nextIndex = (currentIndex + 1);
currentKeyFrame = this.keyFrames[currentIndex];
nextKeyFrame = ((nextIndex < this.keyFrames.length)) ? this.keyFrames[nextIndex] : null;
frameDuration = (nextKeyFrame) ? (nextKeyFrame.time - currentKeyFrame.time) : currentKeyFrame.time;
frameAlpha = 0;
currentTime = currentKeyFrame.time;
}
public function addKeyFrame(_arg1:AnimationKeyFrame3D):AnimationKeyFrame3D{
if (this.keyFrames.length){
this.startTime = Math.min(this.startTime, _arg1.time);
this.endTime = Math.max(this.endTime, _arg1.time);
} else {
this.startTime = (this.endTime = _arg1.time);
};
this.duration = (this.endTime - this.startTime);
this.keyFrames.push(_arg1);
this.keyFrames.sortOn("time", Array.NUMERIC);
return (_arg1);
}
}
}//package org.papervision3d.core.animation.channel
Section 147
//MatrixChannel3D (org.papervision3d.core.animation.channel.MatrixChannel3D)
package org.papervision3d.core.animation.channel {
import org.papervision3d.objects.*;
public class MatrixChannel3D extends AbstractChannel3D {
public var member:String;
public function MatrixChannel3D(_arg1:DisplayObject3D, _arg2:String=null){
super(_arg1, _arg2);
this.member = null;
}
override public function updateToTime(_arg1:Number):void{
super.updateToTime(_arg1);
target.copyTransform(currentKeyFrame.output[0]);
}
override public function updateToFrame(_arg1:uint):void{
super.updateToFrame(_arg1);
target.copyTransform(currentKeyFrame.output[0]);
}
}
}//package org.papervision3d.core.animation.channel
Section 148
//AnimationKeyFrame3D (org.papervision3d.core.animation.AnimationKeyFrame3D)
package org.papervision3d.core.animation {
public class AnimationKeyFrame3D {
public var inTangent:Array;
public var output:Array;
public var interpolation:String;
public var name:String;
public var time:Number;
public var outTangent:Array;
public static const INTERPOLATION_LINEAR:String = "LINEAR";
public static const INTERPOLATION_BEZIER:String = "BEZIER";
public function AnimationKeyFrame3D(_arg1:String, _arg2:Number, _arg3:Array=null, _arg4:String=null, _arg5:Array=null, _arg6:Array=null){
this.name = _arg1;
this.time = _arg2;
this.output = ((_arg3) || (new Array()));
this.interpolation = ((_arg4) || (INTERPOLATION_LINEAR));
this.inTangent = ((_arg5) || (new Array()));
this.outTangent = ((_arg6) || (new Array()));
}
}
}//package org.papervision3d.core.animation
Section 149
//IAnimatable (org.papervision3d.core.animation.IAnimatable)
package org.papervision3d.core.animation {
public interface IAnimatable {
function stop():void;
function play(_arg1:String=null):void;
}
}//package org.papervision3d.core.animation
Section 150
//IAnimationDataProvider (org.papervision3d.core.animation.IAnimationDataProvider)
package org.papervision3d.core.animation {
import org.papervision3d.objects.*;
import org.papervision3d.core.animation.channel.*;
public interface IAnimationDataProvider {
function get fps():uint;
function getAnimationChannelsByClip(_arg1:String):Array;
function getAnimationChannels(_arg1:DisplayObject3D=null):Array;
function getAnimationChannelByName(_arg1:String):AbstractChannel3D;
}
}//package org.papervision3d.core.animation
Section 151
//Clipping (org.papervision3d.core.clipping.draw.Clipping)
package org.papervision3d.core.clipping.draw {
import flash.display.*;
import flash.geom.*;
import org.papervision3d.core.render.command.*;
public class Clipping {
public var minX:Number;// = -1000000
public var minY:Number;// = -1000000
private var zeroPoint:Point;
private var globalPoint:Point;
private var rectangleClipping:RectangleClipping;
public var maxX:Number;// = 1000000
public var maxY:Number;// = 1000000
public function Clipping(){
zeroPoint = new Point(0, 0);
super();
}
public function rect(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Boolean{
return (true);
}
public function screen(_arg1:Sprite):Clipping{
if (!rectangleClipping){
rectangleClipping = new RectangleClipping();
};
switch (_arg1.stage.align){
case StageAlign.TOP_LEFT:
zeroPoint.x = 0;
zeroPoint.y = 0;
globalPoint = _arg1.globalToLocal(zeroPoint);
rectangleClipping.maxX = ((rectangleClipping.minX = globalPoint.x) + _arg1.stage.stageWidth);
rectangleClipping.maxY = ((rectangleClipping.minY = globalPoint.y) + _arg1.stage.stageHeight);
break;
case StageAlign.TOP_RIGHT:
zeroPoint.x = _arg1.stage.stageWidth;
zeroPoint.y = 0;
globalPoint = _arg1.globalToLocal(zeroPoint);
rectangleClipping.minX = ((rectangleClipping.maxX = globalPoint.x) - _arg1.stage.stageWidth);
rectangleClipping.maxY = ((rectangleClipping.minY = globalPoint.y) + _arg1.stage.stageHeight);
break;
case StageAlign.BOTTOM_LEFT:
zeroPoint.x = 0;
zeroPoint.y = _arg1.stage.stageHeight;
globalPoint = _arg1.globalToLocal(zeroPoint);
rectangleClipping.maxX = ((rectangleClipping.minX = globalPoint.x) + _arg1.stage.stageWidth);
rectangleClipping.minY = ((rectangleClipping.maxY = globalPoint.y) - _arg1.stage.stageHeight);
break;
case StageAlign.BOTTOM_RIGHT:
zeroPoint.x = _arg1.stage.stageWidth;
zeroPoint.y = _arg1.stage.stageHeight;
globalPoint = _arg1.globalToLocal(zeroPoint);
rectangleClipping.minX = ((rectangleClipping.maxX = globalPoint.x) - _arg1.stage.stageWidth);
rectangleClipping.minY = ((rectangleClipping.maxY = globalPoint.y) - _arg1.stage.stageHeight);
break;
case StageAlign.TOP:
zeroPoint.x = (_arg1.stage.stageWidth / 2);
zeroPoint.y = 0;
globalPoint = _arg1.globalToLocal(zeroPoint);
rectangleClipping.minX = (globalPoint.x - (_arg1.stage.stageWidth / 2));
rectangleClipping.maxX = (globalPoint.x + (_arg1.stage.stageWidth / 2));
rectangleClipping.maxY = ((rectangleClipping.minY = globalPoint.y) + _arg1.stage.stageHeight);
break;
case StageAlign.BOTTOM:
zeroPoint.x = (_arg1.stage.stageWidth / 2);
zeroPoint.y = _arg1.stage.stageHeight;
globalPoint = _arg1.globalToLocal(zeroPoint);
rectangleClipping.minX = (globalPoint.x - (_arg1.stage.stageWidth / 2));
rectangleClipping.maxX = (globalPoint.x + (_arg1.stage.stageWidth / 2));
rectangleClipping.minY = ((rectangleClipping.maxY = globalPoint.y) - _arg1.stage.stageHeight);
break;
case StageAlign.LEFT:
zeroPoint.x = 0;
zeroPoint.y = (_arg1.stage.stageHeight / 2);
globalPoint = _arg1.globalToLocal(zeroPoint);
rectangleClipping.maxX = ((rectangleClipping.minX = globalPoint.x) + _arg1.stage.stageWidth);
rectangleClipping.minY = (globalPoint.y - (_arg1.stage.stageHeight / 2));
rectangleClipping.maxY = (globalPoint.y + (_arg1.stage.stageHeight / 2));
break;
case StageAlign.RIGHT:
zeroPoint.x = _arg1.stage.stageWidth;
zeroPoint.y = (_arg1.stage.stageHeight / 2);
globalPoint = _arg1.globalToLocal(zeroPoint);
rectangleClipping.minX = ((rectangleClipping.maxX = globalPoint.x) - _arg1.stage.stageWidth);
rectangleClipping.minY = (globalPoint.y - (_arg1.stage.stageHeight / 2));
rectangleClipping.maxY = (globalPoint.y + (_arg1.stage.stageHeight / 2));
break;
default:
zeroPoint.x = (_arg1.stage.stageWidth / 2);
zeroPoint.y = (_arg1.stage.stageHeight / 2);
globalPoint = _arg1.globalToLocal(zeroPoint);
rectangleClipping.minX = (globalPoint.x - (_arg1.stage.stageWidth / 2));
rectangleClipping.maxX = (globalPoint.x + (_arg1.stage.stageWidth / 2));
rectangleClipping.minY = (globalPoint.y - (_arg1.stage.stageHeight / 2));
rectangleClipping.maxY = (globalPoint.y + (_arg1.stage.stageHeight / 2));
};
return (rectangleClipping);
}
public function check(_arg1:RenderableListItem):Boolean{
return (true);
}
public function asRectangleClipping():RectangleClipping{
if (!rectangleClipping){
rectangleClipping = new RectangleClipping();
};
rectangleClipping.minX = -1000000;
rectangleClipping.minY = -1000000;
rectangleClipping.maxX = 1000000;
rectangleClipping.maxY = 1000000;
return (rectangleClipping);
}
}
}//package org.papervision3d.core.clipping.draw
Section 152
//RectangleClipping (org.papervision3d.core.clipping.draw.RectangleClipping)
package org.papervision3d.core.clipping.draw {
import org.papervision3d.core.render.command.*;
public class RectangleClipping extends Clipping {
public function RectangleClipping(_arg1:Number=-1000000, _arg2:Number=-1000000, _arg3:Number=1000000, _arg4:Number=1000000){
this.minX = _arg1;
this.maxX = _arg3;
this.minY = _arg2;
this.maxY = _arg4;
}
override public function check(_arg1:RenderableListItem):Boolean{
if (_arg1.maxX < minX){
return (false);
};
if (_arg1.minX > maxX){
return (false);
};
if (_arg1.maxY < minY){
return (false);
};
if (_arg1.minY > maxY){
return (false);
};
return (true);
}
override public function rect(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Boolean{
if (this.maxX < _arg1){
return (false);
};
if (this.minX > _arg3){
return (false);
};
if (this.maxY < _arg2){
return (false);
};
if (this.minY > _arg4){
return (false);
};
return (true);
}
public function toString():String{
return ((((((((("{minX:" + minX) + " maxX:") + maxX) + " minY:") + minY) + " maxY:") + maxY) + "}"));
}
override public function asRectangleClipping():RectangleClipping{
return (this);
}
}
}//package org.papervision3d.core.clipping.draw
Section 153
//DefaultClipping (org.papervision3d.core.clipping.DefaultClipping)
package org.papervision3d.core.clipping {
import org.papervision3d.objects.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.proto.*;
public class DefaultClipping {
public function testFace(_arg1:Triangle3D, _arg2:DisplayObject3D, _arg3:RenderSessionData):Boolean{
return (false);
}
public function clipFace(_arg1:Triangle3D, _arg2:DisplayObject3D, _arg3:MaterialObject3D, _arg4:RenderSessionData, _arg5:Array):Number{
return (0);
}
public function setDisplayObject(_arg1:DisplayObject3D, _arg2:RenderSessionData):void{
}
public function reset(_arg1:RenderSessionData):void{
}
}
}//package org.papervision3d.core.clipping
Section 154
//IObjectController (org.papervision3d.core.controller.IObjectController)
package org.papervision3d.core.controller {
public interface IObjectController {
function update():void;
}
}//package org.papervision3d.core.controller
Section 155
//SkinController (org.papervision3d.core.controller.SkinController)
package org.papervision3d.core.controller {
import org.papervision3d.objects.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.math.*;
import org.papervision3d.objects.special.*;
public class SkinController implements IObjectController {
private var _cached:Array;
public var bindShapeMatrix:Matrix3D;
public var invBindMatrices:Array;
public var joints:Array;
public var target:Skin3D;
public var poseMatrix:Matrix3D;
public var vertexWeights:Array;
public function SkinController(_arg1:Skin3D){
this.target = _arg1;
this.joints = new Array();
this.invBindMatrices = new Array();
this.vertexWeights = new Array();
}
private function skinMesh(_arg1:DisplayObject3D, _arg2:Array, _arg3:Matrix3D, _arg4:Array, _arg5:Array):void{
var _local6:int;
var _local7:Number3D;
var _local8:Number3D;
var _local9:Vertex3D;
var _local10:Matrix3D;
var _local11:Number;
var _local12:int;
_local7 = new Number3D();
_local10 = Matrix3D.multiply(_arg1.world, _arg3);
_local6 = 0;
while (_local6 < _arg2.length) {
_local11 = _arg2[_local6].weight;
_local12 = _arg2[_local6].vertexIndex;
if ((((_local11 <= 0.0001)) || ((_local11 >= 1.0001)))){
} else {
_local8 = _arg4[_local12];
_local9 = _arg5[_local12];
_local7.x = _local8.x;
_local7.y = _local8.y;
_local7.z = _local8.z;
Matrix3D.multiplyVector(_local10, _local7);
_local9.x = (_local9.x + (_local7.x * _local11));
_local9.y = (_local9.y + (_local7.y * _local11));
_local9.z = (_local9.z + (_local7.z * _local11));
};
_local6++;
};
}
public function update():void{
var _local2:int;
if (((!(joints.length)) || (!(bindShapeMatrix)))){
return;
};
if (!_cached){
cacheVertices();
};
if (invBindMatrices.length != this.joints.length){
return;
};
var _local1:Array = target.geometry.vertices;
_local2 = 0;
while (_local2 < _local1.length) {
_local1[_local2].x = (_local1[_local2].y = (_local1[_local2].z = 0));
_local2++;
};
_local2 = 0;
while (_local2 < joints.length) {
skinMesh(joints[_local2], this.vertexWeights[_local2], invBindMatrices[_local2], _cached, _local1);
_local2++;
};
}
private function cacheVertices():void{
this.target.transformVertices(this.bindShapeMatrix);
this.target.geometry.ready = true;
var _local1:Array = this.target.geometry.vertices;
_cached = new Array(_local1.length);
var _local2:int;
while (_local2 < _local1.length) {
_cached[_local2] = new Number3D(_local1[_local2].x, _local1[_local2].y, _local1[_local2].z);
_local2++;
};
}
}
}//package org.papervision3d.core.controller
Section 156
//DefaultLineCuller (org.papervision3d.core.culling.DefaultLineCuller)
package org.papervision3d.core.culling {
import org.papervision3d.core.geom.renderables.*;
public class DefaultLineCuller implements ILineCuller {
public function testLine(_arg1:Line3D):Boolean{
return (((_arg1.v0.vertex3DInstance.visible) && (_arg1.v1.vertex3DInstance.visible)));
}
}
}//package org.papervision3d.core.culling
Section 157
//DefaultParticleCuller (org.papervision3d.core.culling.DefaultParticleCuller)
package org.papervision3d.core.culling {
import org.papervision3d.core.geom.renderables.*;
public class DefaultParticleCuller implements IParticleCuller {
public function testParticle(_arg1:Particle):Boolean{
if (_arg1.material.invisible == false){
if (_arg1.vertex3D.vertex3DInstance.visible == true){
return (true);
};
};
return (false);
}
}
}//package org.papervision3d.core.culling
Section 158
//DefaultTriangleCuller (org.papervision3d.core.culling.DefaultTriangleCuller)
package org.papervision3d.core.culling {
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.proto.*;
public class DefaultTriangleCuller implements ITriangleCuller {
protected static var y2:Number;
protected static var y1:Number;
protected static var y0:Number;
protected static var x0:Number;
protected static var x1:Number;
protected static var x2:Number;
public function testFace(_arg1:Triangle3D, _arg2:Vertex3DInstance, _arg3:Vertex3DInstance, _arg4:Vertex3DInstance):Boolean{
var _local5:MaterialObject3D;
if (((((_arg2.visible) && (_arg3.visible))) && (_arg4.visible))){
_local5 = (_arg1.material) ? _arg1.material : _arg1.instance.material;
if (_local5.invisible){
return (false);
};
x0 = _arg2.x;
y0 = _arg2.y;
x1 = _arg3.x;
y1 = _arg3.y;
x2 = _arg4.x;
y2 = _arg4.y;
if (_local5.oneSide){
if (_local5.opposite){
if ((((x2 - x0) * (y1 - y0)) - ((y2 - y0) * (x1 - x0))) > 0){
return (false);
};
} else {
if ((((x2 - x0) * (y1 - y0)) - ((y2 - y0) * (x1 - x0))) < 0){
return (false);
};
};
};
return (true);
};
return (false);
}
}
}//package org.papervision3d.core.culling
Section 159
//FrustumCuller (org.papervision3d.core.culling.FrustumCuller)
package org.papervision3d.core.culling {
import org.papervision3d.objects.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.math.*;
public class FrustumCuller implements IObjectCuller {
private var _tang:Number;
private var _near:Number;
private var _ratio:Number;
private var _fov:Number;
private var _far:Number;
private var _nh:Number;
private var _fh:Number;
private var _nw:Number;
public var transform:Matrix3D;
private var _sphereY:Number;
private var _sphereX:Number;
private var _fw:Number;
public static const OUTSIDE:int = -1;
public static const INSIDE:int = 1;
public static const INTERSECT:int = 0;
public function FrustumCuller(){
this.transform = Matrix3D.IDENTITY;
this.initialize();
}
public function get ratio():Number{
return (_ratio);
}
public function pointInFrustum(_arg1:Number, _arg2:Number, _arg3:Number):int{
var _local4:Matrix3D = this.transform;
var _local5:Number = (_arg1 - _local4.n14);
var _local6:Number = (_arg2 - _local4.n24);
var _local7:Number = (_arg3 - _local4.n34);
var _local8:Number = (((_local5 * _local4.n13) + (_local6 * _local4.n23)) + (_local7 * _local4.n33));
if ((((_local8 > _far)) || ((_local8 < _near)))){
return (OUTSIDE);
};
var _local9:Number = (((_local5 * _local4.n12) + (_local6 * _local4.n22)) + (_local7 * _local4.n32));
var _local10:Number = (_local8 * _tang);
if ((((_local9 > _local10)) || ((_local9 < -(_local10))))){
return (OUTSIDE);
};
var _local11:Number = (((_local5 * _local4.n11) + (_local6 * _local4.n21)) + (_local7 * _local4.n31));
_local10 = (_local10 * _ratio);
if ((((_local11 > _local10)) || ((_local11 < -(_local10))))){
return (OUTSIDE);
};
return (INSIDE);
}
public function get fov():Number{
return (_fov);
}
public function set ratio(_arg1:Number):void{
this.initialize(_fov, _arg1, _near, _far);
}
public function set near(_arg1:Number):void{
this.initialize(_fov, _ratio, _arg1, _far);
}
public function set fov(_arg1:Number):void{
this.initialize(_arg1, _ratio, _near, _far);
}
public function get far():Number{
return (_far);
}
public function initialize(_arg1:Number=60, _arg2:Number=1.333, _arg3:Number=1, _arg4:Number=5000):void{
_fov = _arg1;
_ratio = _arg2;
_near = _arg3;
_far = _arg4;
var _local5:Number = (((Math.PI / 180) * _fov) * 0.5);
_tang = Math.tan(_local5);
_nh = (_near * _tang);
_nw = (_nh * _ratio);
_fh = (_far * _tang);
_fw = (_fh * _ratio);
var _local6:Number = Math.atan((_tang * _ratio));
_sphereX = (1 / Math.cos(_local6));
_sphereY = (1 / Math.cos(_local5));
}
public function set far(_arg1:Number):void{
this.initialize(_fov, _ratio, _near, _arg1);
}
public function get near():Number{
return (_near);
}
public function sphereInFrustum(_arg1:DisplayObject3D, _arg2:BoundingSphere):int{
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local3:Number = (_arg2.radius * Math.max(_arg1.scaleX, Math.max(_arg1.scaleY, _arg1.scaleZ)));
var _local8:int = INSIDE;
var _local9:Matrix3D = this.transform;
var _local10:Number = (_arg1.world.n14 - _local9.n14);
var _local11:Number = (_arg1.world.n24 - _local9.n24);
var _local12:Number = (_arg1.world.n34 - _local9.n34);
_local7 = (((_local10 * _local9.n13) + (_local11 * _local9.n23)) + (_local12 * _local9.n33));
if ((((_local7 > (_far + _local3))) || ((_local7 < (_near - _local3))))){
return (OUTSIDE);
};
if ((((_local7 > (_far - _local3))) || ((_local7 < (_near + _local3))))){
_local8 = INTERSECT;
};
_local6 = (((_local10 * _local9.n12) + (_local11 * _local9.n22)) + (_local12 * _local9.n32));
_local4 = (_sphereY * _local3);
_local7 = (_local7 * _tang);
if ((((_local6 > (_local7 + _local4))) || ((_local6 < (-(_local7) - _local4))))){
return (OUTSIDE);
};
if ((((_local6 > (_local7 - _local4))) || ((_local6 < (-(_local7) + _local4))))){
_local8 = INTERSECT;
};
_local5 = (((_local10 * _local9.n11) + (_local11 * _local9.n21)) + (_local12 * _local9.n31));
_local7 = (_local7 * _ratio);
_local4 = (_sphereX * _local3);
if ((((_local5 > (_local7 + _local4))) || ((_local5 < (-(_local7) - _local4))))){
return (OUTSIDE);
};
if ((((_local5 > (_local7 - _local4))) || ((_local5 < (-(_local7) + _local4))))){
_local8 = INTERSECT;
};
return (_local8);
}
public function testObject(_arg1:DisplayObject3D):int{
var _local2:int = INSIDE;
if (((((!(_arg1.geometry)) || (!(_arg1.geometry.vertices)))) || (!(_arg1.geometry.vertices.length)))){
return (_local2);
};
switch (_arg1.frustumTestMethod){
case FrustumTestMethod.BOUNDING_SPHERE:
_local2 = sphereInFrustum(_arg1, _arg1.geometry.boundingSphere);
break;
case FrustumTestMethod.BOUNDING_BOX:
_local2 = aabbInFrustum(_arg1, _arg1.geometry.aabb);
break;
case FrustumTestMethod.NO_TESTING:
break;
default:
break;
};
return (_local2);
}
public function aabbInFrustum(_arg1:DisplayObject3D, _arg2:AxisAlignedBoundingBox, _arg3:Boolean=true):int{
var _local4:Vertex3D;
var _local5:Number3D;
var _local6:int;
var _local7:int;
var _local8:Array = _arg2.getBoxVertices();
for each (_local4 in _local8) {
_local5 = _local4.toNumber3D();
Matrix3D.multiplyVector(_arg1.world, _local5);
if (pointInFrustum(_local5.x, _local5.y, _local5.z) == INSIDE){
_local6++;
if (_arg3){
return (INSIDE);
};
} else {
_local7++;
};
if (((_local6) && (_local7))){
return (INTERSECT);
};
};
if (_local6){
return (((_local6 < 8)) ? INTERSECT : INSIDE);
//unresolved jump
};
return (OUTSIDE);
}
}
}//package org.papervision3d.core.culling
Section 160
//FrustumTestMethod (org.papervision3d.core.culling.FrustumTestMethod)
package org.papervision3d.core.culling {
public class FrustumTestMethod {
public static const BOUNDING_BOX:int = 1;
public static const NO_TESTING:int = -1;
public static const BOUNDING_SPHERE:int = 0;
}
}//package org.papervision3d.core.culling
Section 161
//ILineCuller (org.papervision3d.core.culling.ILineCuller)
package org.papervision3d.core.culling {
import org.papervision3d.core.geom.renderables.*;
public interface ILineCuller {
function testLine(_arg1:Line3D):Boolean;
}
}//package org.papervision3d.core.culling
Section 162
//IObjectCuller (org.papervision3d.core.culling.IObjectCuller)
package org.papervision3d.core.culling {
import org.papervision3d.objects.*;
public interface IObjectCuller {
function testObject(_arg1:DisplayObject3D):int;
}
}//package org.papervision3d.core.culling
Section 163
//IParticleCuller (org.papervision3d.core.culling.IParticleCuller)
package org.papervision3d.core.culling {
import org.papervision3d.core.geom.renderables.*;
public interface IParticleCuller {
function testParticle(_arg1:Particle):Boolean;
}
}//package org.papervision3d.core.culling
Section 164
//ITriangleCuller (org.papervision3d.core.culling.ITriangleCuller)
package org.papervision3d.core.culling {
import org.papervision3d.core.geom.renderables.*;
public interface ITriangleCuller {
function testFace(_arg1:Triangle3D, _arg2:Vertex3DInstance, _arg3:Vertex3DInstance, _arg4:Vertex3DInstance):Boolean;
}
}//package org.papervision3d.core.culling
Section 165
//RectangleLineCuller (org.papervision3d.core.culling.RectangleLineCuller)
package org.papervision3d.core.culling {
import flash.geom.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.math.util.*;
public class RectangleLineCuller implements ILineCuller {
private var lineBoundsRect:Rectangle;
private var rectIntersection:Rectangle;
private var cullingRectangle:Rectangle;
public function RectangleLineCuller(_arg1:Rectangle=null):void{
if (_arg1){
this.cullingRectangle = _arg1;
};
lineBoundsRect = new Rectangle();
rectIntersection = new Rectangle();
}
public function testLine(_arg1:Line3D):Boolean{
if (((!(_arg1.v0.vertex3DInstance.visible)) || (!(_arg1.v1.vertex3DInstance.visible)))){
return (false);
};
var _local2:Number = _arg1.v0.vertex3DInstance.x;
var _local3:Number = _arg1.v0.vertex3DInstance.y;
var _local4:Number = _arg1.v1.vertex3DInstance.x;
var _local5:Number = _arg1.v1.vertex3DInstance.y;
lineBoundsRect.width = Math.abs((_local4 - _local2));
lineBoundsRect.height = Math.abs((_local5 - _local3));
if (_local2 < _local4){
lineBoundsRect.x = _local2;
} else {
lineBoundsRect.x = _local4;
};
if (_local3 < _local5){
lineBoundsRect.y = _local3;
} else {
lineBoundsRect.y = _local5;
};
if (cullingRectangle.containsRect(lineBoundsRect)){
return (true);
};
if (!FastRectangleTools.intersects(lineBoundsRect, cullingRectangle)){
return (false);
};
rectIntersection = FastRectangleTools.intersection(lineBoundsRect, cullingRectangle);
var _local6:Number = ((_local5 - _local3) / (_local4 - _local2));
var _local7:Number = (_local3 - (_local6 * _local2));
var _local8:Number = ((cullingRectangle.top - _local7) / _local6);
if ((((_local8 > rectIntersection.left)) && ((_local8 < rectIntersection.right)))){
return (true);
};
_local8 = ((cullingRectangle.bottom - _local7) / _local6);
if ((((_local8 > rectIntersection.left)) && ((_local8 < rectIntersection.right)))){
return (true);
};
var _local9:Number = ((_local6 * cullingRectangle.left) + _local7);
if ((((_local9 > rectIntersection.top)) && ((_local9 < rectIntersection.bottom)))){
return (true);
};
_local9 = ((_local6 * cullingRectangle.right) + _local7);
if ((((_local9 > rectIntersection.top)) && ((_local9 < rectIntersection.bottom)))){
return (true);
};
return (false);
}
}
}//package org.papervision3d.core.culling
Section 166
//RectangleParticleCuller (org.papervision3d.core.culling.RectangleParticleCuller)
package org.papervision3d.core.culling {
import flash.geom.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.math.util.*;
public class RectangleParticleCuller implements IParticleCuller {
public var cullingRectangle:Rectangle;
private static var vInstance:Vertex3DInstance;
private static var testPoint:Point;
public function RectangleParticleCuller(_arg1:Rectangle=null){
this.cullingRectangle = _arg1;
testPoint = new Point();
}
public function testParticle(_arg1:Particle):Boolean{
vInstance = _arg1.vertex3D.vertex3DInstance;
if (_arg1.material.invisible == false){
if (vInstance.visible){
if (FastRectangleTools.intersects(_arg1.renderRect, cullingRectangle)){
return (true);
};
};
};
return (false);
}
}
}//package org.papervision3d.core.culling
Section 167
//RectangleTriangleCuller (org.papervision3d.core.culling.RectangleTriangleCuller)
package org.papervision3d.core.culling {
import flash.geom.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.math.util.*;
public class RectangleTriangleCuller extends DefaultTriangleCuller implements ITriangleCuller {
public var cullingRectangle:Rectangle;
private static const DEFAULT_RECT_X:Number = -((DEFAULT_RECT_W / 2));
private static const DEFAULT_RECT_W:Number = 640;
private static const DEFAULT_RECT_H:Number = 480;
private static const DEFAULT_RECT_Y:Number = -((DEFAULT_RECT_H / 2));
private static var hitRect:Rectangle = new Rectangle();
public function RectangleTriangleCuller(_arg1:Rectangle=null):void{
cullingRectangle = new Rectangle(DEFAULT_RECT_X, DEFAULT_RECT_Y, DEFAULT_RECT_W, DEFAULT_RECT_H);
super();
if (_arg1){
this.cullingRectangle = _arg1;
};
}
override public function testFace(_arg1:Triangle3D, _arg2:Vertex3DInstance, _arg3:Vertex3DInstance, _arg4:Vertex3DInstance):Boolean{
if (super.testFace(_arg1, _arg2, _arg3, _arg4)){
hitRect.x = Math.min(_arg4.x, Math.min(_arg3.x, _arg2.x));
hitRect.width = (Math.max(_arg4.x, Math.max(_arg3.x, _arg2.x)) + Math.abs(hitRect.x));
hitRect.y = Math.min(_arg4.y, Math.min(_arg3.y, _arg2.y));
hitRect.height = (Math.max(_arg4.y, Math.max(_arg3.y, _arg2.y)) + Math.abs(hitRect.y));
return (FastRectangleTools.intersects(cullingRectangle, hitRect));
};
return (false);
}
}
}//package org.papervision3d.core.culling
Section 168
//ViewportObjectFilter (org.papervision3d.core.culling.ViewportObjectFilter)
package org.papervision3d.core.culling {
import org.papervision3d.objects.*;
import flash.utils.*;
public class ViewportObjectFilter implements IObjectCuller {
protected var _mode:int;
protected var objects:Dictionary;
public function ViewportObjectFilter(_arg1:int):void{
this.mode = _arg1;
init();
}
public function addObject(_arg1:DisplayObject3D):void{
objects[_arg1] = _arg1;
}
public function get mode():int{
return (_mode);
}
public function set mode(_arg1:int):void{
_mode = _arg1;
}
public function removeObject(_arg1:DisplayObject3D):void{
delete objects[_arg1];
}
private function init():void{
objects = new Dictionary(true);
}
public function testObject(_arg1:DisplayObject3D):int{
if (objects[_arg1]){
return ((1 - _mode));
};
return (mode);
}
public function destroy():void{
objects = null;
}
}
}//package org.papervision3d.core.culling
Section 169
//UserData (org.papervision3d.core.data.UserData)
package org.papervision3d.core.data {
public class UserData {
public var data;
public function UserData(_arg1=null){
this.data = _arg1;
}
}
}//package org.papervision3d.core.data
Section 170
//AbstractRenderable (org.papervision3d.core.geom.renderables.AbstractRenderable)
package org.papervision3d.core.geom.renderables {
import org.papervision3d.objects.*;
import org.papervision3d.core.render.command.*;
import org.papervision3d.core.data.*;
public class AbstractRenderable implements IRenderable {
public var _userData:UserData;
public var instance:DisplayObject3D;
public function set userData(_arg1:UserData):void{
_userData = _arg1;
}
public function get userData():UserData{
return (_userData);
}
public function getRenderListItem():IRenderListItem{
return (null);
}
}
}//package org.papervision3d.core.geom.renderables
Section 171
//IRenderable (org.papervision3d.core.geom.renderables.IRenderable)
package org.papervision3d.core.geom.renderables {
import org.papervision3d.core.render.command.*;
public interface IRenderable {
function getRenderListItem():IRenderListItem;
}
}//package org.papervision3d.core.geom.renderables
Section 172
//Line3D (org.papervision3d.core.geom.renderables.Line3D)
package org.papervision3d.core.geom.renderables {
import org.papervision3d.core.render.command.*;
import org.papervision3d.core.geom.*;
import org.papervision3d.materials.special.*;
public class Line3D extends AbstractRenderable implements IRenderable {
public var size:Number;
public var material:LineMaterial;
public var cV:Vertex3D;
public var renderCommand:RenderLine;
public var v0:Vertex3D;
public var v1:Vertex3D;
public function Line3D(_arg1:Lines3D, _arg2:LineMaterial, _arg3:Number, _arg4:Vertex3D, _arg5:Vertex3D){
this.size = _arg3;
this.material = _arg2;
this.v0 = _arg4;
this.v1 = _arg5;
this.cV = _arg5;
this.instance = _arg1;
this.renderCommand = new RenderLine(this);
}
public function addControlVertex(_arg1:Number, _arg2:Number, _arg3:Number):void{
cV = new Vertex3D(_arg1, _arg2, _arg3);
if (instance.geometry.vertices.indexOf(cV) == -1){
instance.geometry.vertices.push(cV);
};
renderCommand.cV = cV.vertex3DInstance;
}
override public function getRenderListItem():IRenderListItem{
return (this.renderCommand);
}
}
}//package org.papervision3d.core.geom.renderables
Section 173
//Particle (org.papervision3d.core.geom.renderables.Particle)
package org.papervision3d.core.geom.renderables {
import flash.geom.*;
import org.papervision3d.core.render.command.*;
import org.papervision3d.materials.special.*;
public class Particle extends AbstractRenderable implements IRenderable {
public var size:Number;
public var renderScale:Number;
public var vertex3D:Vertex3D;
public var renderRect:Rectangle;
public var rotationZ:Number;// = 0
public var renderCommand:RenderParticle;
public var drawMatrix:Matrix;
public var material:ParticleMaterial;
public function Particle(_arg1:ParticleMaterial, _arg2:Number=1, _arg3:Number=0, _arg4:Number=0, _arg5:Number=0){
this.material = _arg1;
this.size = _arg2;
this.renderCommand = new RenderParticle(this);
this.renderRect = new Rectangle();
vertex3D = new Vertex3D(_arg3, _arg4, _arg5);
drawMatrix = new Matrix();
}
public function updateRenderRect():void{
material.updateRenderRect(this);
}
public function set x(_arg1:Number):void{
vertex3D.x = _arg1;
}
public function set y(_arg1:Number):void{
vertex3D.y = _arg1;
}
public function set z(_arg1:Number):void{
vertex3D.z = _arg1;
}
public function get y():Number{
return (vertex3D.y);
}
public function get z():Number{
return (vertex3D.z);
}
override public function getRenderListItem():IRenderListItem{
return (renderCommand);
}
public function get x():Number{
return (vertex3D.x);
}
}
}//package org.papervision3d.core.geom.renderables
Section 174
//Triangle3D (org.papervision3d.core.geom.renderables.Triangle3D)
package org.papervision3d.core.geom.renderables {
import org.papervision3d.objects.*;
import org.papervision3d.core.render.command.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.core.math.*;
import org.papervision3d.materials.*;
import org.papervision3d.materials.special.*;
public class Triangle3D extends AbstractRenderable implements IRenderable {
public var _uvArray:Array;
public var renderCommand:RenderTriangle;
public var id:Number;
public var material:MaterialObject3D;
public var faceNormal:Number3D;
public var screenZ:Number;
public var uv0:NumberUV;
public var uv1:NumberUV;
public var _materialName:String;
public var visible:Boolean;
public var uv2:NumberUV;
public var vertices:Array;
public var v0:Vertex3D;
public var v1:Vertex3D;
public var v2:Vertex3D;
private static var _totalFaces:Number = 0;
public function Triangle3D(_arg1:DisplayObject3D, _arg2:Array, _arg3:MaterialObject3D=null, _arg4:Array=null){
this.instance = _arg1;
faceNormal = new Number3D();
if (((_arg2) && ((_arg2.length == 3)))){
this.vertices = _arg2;
v0 = _arg2[0];
v1 = _arg2[1];
v2 = _arg2[2];
createNormal();
} else {
_arg2 = new Array();
v0 = (_arg2[0] = new Vertex3D());
v1 = (_arg2[1] = new Vertex3D());
v2 = (_arg2[2] = new Vertex3D());
};
this.material = _arg3;
this.uv = _arg4;
this.id = _totalFaces++;
this.renderCommand = new RenderTriangle(this);
}
public function set uv(_arg1:Array):void{
if (((_arg1) && ((_arg1.length == 3)))){
uv0 = NumberUV(_arg1[0]);
uv1 = NumberUV(_arg1[1]);
uv2 = NumberUV(_arg1[2]);
};
_uvArray = _arg1;
}
public function createNormal():void{
var _local1:Number3D = v0.getPosition();
var _local2:Number3D = v1.getPosition();
var _local3:Number3D = v2.getPosition();
_local2.minusEq(_local1);
_local3.minusEq(_local1);
faceNormal = Number3D.cross(_local2, _local3, faceNormal);
faceNormal.normalize();
}
override public function getRenderListItem():IRenderListItem{
return (renderCommand);
}
public function reset(_arg1:DisplayObject3D, _arg2:Array, _arg3:MaterialObject3D, _arg4:Array):void{
var _local5:MaterialObject3D;
this.instance = _arg1;
this.renderCommand.instance = _arg1;
this.renderCommand.renderer = _arg3;
this.vertices = _arg2;
updateVertices();
this.material = _arg3;
this.uv = _arg4;
if ((_arg3 is BitmapMaterial)){
BitmapMaterial(_arg3).uvMatrices[this.renderCommand] = null;
};
if ((_arg3 is CompositeMaterial)){
for each (_local5 in CompositeMaterial(_arg3).materials) {
if ((_local5 is BitmapMaterial)){
BitmapMaterial(_local5).uvMatrices[this.renderCommand] = null;
};
};
};
}
public function get uv():Array{
return (_uvArray);
}
public function updateVertices():void{
v0 = vertices[0];
v1 = vertices[1];
v2 = vertices[2];
}
}
}//package org.papervision3d.core.geom.renderables
Section 175
//Triangle3DInstance (org.papervision3d.core.geom.renderables.Triangle3DInstance)
package org.papervision3d.core.geom.renderables {
import flash.display.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.math.*;
public class Triangle3DInstance {
public var container:Sprite;
public var instance:DisplayObject3D;
public var visible:Boolean;// = false
public var faceNormal:Number3D;
public var screenZ:Number;
public function Triangle3DInstance(_arg1:Triangle3D, _arg2:DisplayObject3D){
this.instance = _arg2;
faceNormal = new Number3D();
}
}
}//package org.papervision3d.core.geom.renderables
Section 176
//Vertex3D (org.papervision3d.core.geom.renderables.Vertex3D)
package org.papervision3d.core.geom.renderables {
import org.papervision3d.core.render.command.*;
import org.papervision3d.core.math.*;
import flash.utils.*;
public class Vertex3D extends AbstractRenderable implements IRenderable {
public var z:Number;
public var vertex3DInstance:Vertex3DInstance;
public var extra:Object;
public var timestamp:Number;
public var normal:Number3D;
protected var position:Number3D;
public var connectedFaces:Dictionary;
public var x:Number;
public var y:Number;
private var persp:Number;// = 0
public function Vertex3D(_arg1:Number=0, _arg2:Number=0, _arg3:Number=0){
position = new Number3D();
super();
this.x = (position.x = _arg1);
this.y = (position.y = _arg2);
this.z = (position.z = _arg3);
this.vertex3DInstance = new Vertex3DInstance();
this.normal = new Number3D();
this.connectedFaces = new Dictionary();
}
public function perspective(_arg1:Number):Vertex3DInstance{
persp = (1 / (1 + (z / _arg1)));
return (new Vertex3DInstance((x * persp), (y * persp), z));
}
public function toNumber3D():Number3D{
return (new Number3D(x, y, z));
}
public function clone():Vertex3D{
var _local1:Vertex3D = new Vertex3D(x, y, z);
_local1.extra = extra;
_local1.vertex3DInstance = vertex3DInstance.clone();
_local1.normal = normal.clone();
return (_local1);
}
public function getPosition():Number3D{
position.x = x;
position.y = y;
position.z = z;
return (position);
}
public function calculateNormal():void{
var _local1:Triangle3D;
var _local2:Number;
var _local3:Number3D;
_local2 = 0;
normal.reset();
for each (_local1 in connectedFaces) {
if (_local1.faceNormal){
_local2++;
normal.plusEq(_local1.faceNormal);
};
};
_local3 = getPosition();
_local3.x = (_local3.x / _local2);
_local3.y = (_local3.y / _local2);
_local3.z = (_local3.z / _local2);
_local3.normalize();
normal.plusEq(_local3);
normal.normalize();
}
override public function getRenderListItem():IRenderListItem{
return (null);
}
public static function weighted(_arg1:Vertex3D, _arg2:Vertex3D, _arg3:Number, _arg4:Number):Vertex3D{
var _local5:Number = (_arg3 + _arg4);
var _local6:Number = (_arg3 / _local5);
var _local7:Number = (_arg4 / _local5);
return (new Vertex3D(((_arg1.x * _local6) + (_arg2.x * _local7)), ((_arg1.y * _local6) + (_arg2.y * _local7)), ((_arg1.z * _local6) + (_arg2.z * _local7))));
}
}
}//package org.papervision3d.core.geom.renderables
Section 177
//Vertex3DInstance (org.papervision3d.core.geom.renderables.Vertex3DInstance)
package org.papervision3d.core.geom.renderables {
import org.papervision3d.core.math.*;
public class Vertex3DInstance {
public var y:Number;
private var persp:Number;// = 0
public var normal:Number3D;
public var visible:Boolean;
public var extra:Object;
public var x:Number;
public var z:Number;
public function Vertex3DInstance(_arg1:Number=0, _arg2:Number=0, _arg3:Number=0){
this.x = _arg1;
this.y = _arg2;
this.z = _arg3;
this.visible = false;
this.normal = new Number3D();
}
public function deperspective(_arg1:Number):Vertex3D{
persp = (1 + (z / _arg1));
return (new Vertex3D((x * persp), (y * persp), z));
}
public function distance(_arg1:Vertex3DInstance):Number{
return (Math.sqrt((((x - _arg1.x) * (x - _arg1.x)) + ((y - _arg1.y) * (y - _arg1.y)))));
}
public function clone():Vertex3DInstance{
var _local1:Vertex3DInstance = new Vertex3DInstance(x, y, z);
_local1.visible = visible;
_local1.extra = extra;
return (_local1);
}
public function distanceSqr(_arg1:Vertex3DInstance):Number{
return ((((x - _arg1.x) * (x - _arg1.x)) + ((y - _arg1.y) * (y - _arg1.y))));
}
public static function cross(_arg1:Vertex3DInstance, _arg2:Vertex3DInstance):Number{
return (((_arg1.x * _arg2.y) - (_arg2.x * _arg1.y)));
}
public static function dot(_arg1:Vertex3DInstance, _arg2:Vertex3DInstance):Number{
return (((_arg1.x * _arg2.x) + (_arg1.y * _arg2.y)));
}
public static function subTo(_arg1:Vertex3DInstance, _arg2:Vertex3DInstance, _arg3:Vertex3DInstance):void{
_arg3.x = (_arg2.x - _arg1.x);
_arg3.y = (_arg2.y - _arg1.y);
}
public static function median(_arg1:Vertex3DInstance, _arg2:Vertex3DInstance, _arg3:Number):Vertex3DInstance{
var _local4:Number = ((_arg1.z + _arg2.z) / 2);
var _local5:Number = (_arg3 + _arg1.z);
var _local6:Number = (_arg3 + _arg2.z);
var _local7:Number = ((1 / (_arg3 + _local4)) / 2);
return (new Vertex3DInstance((((_arg1.x * _local5) + (_arg2.x * _local6)) * _local7), (((_arg1.y * _local5) + (_arg2.y * _local6)) * _local7), _local4));
}
public static function sub(_arg1:Vertex3DInstance, _arg2:Vertex3DInstance):Vertex3DInstance{
return (new Vertex3DInstance((_arg2.x - _arg1.x), (_arg2.y - _arg1.y)));
}
}
}//package org.papervision3d.core.geom.renderables
Section 178
//Lines3D (org.papervision3d.core.geom.Lines3D)
package org.papervision3d.core.geom {
import org.papervision3d.objects.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.render.command.*;
import org.papervision3d.core.log.*;
import org.papervision3d.materials.special.*;
import org.papervision3d.core.render.draw.*;
public class Lines3D extends Vertices3D {
private var _material:ILineDrawer;
public var lines:Array;
public function Lines3D(_arg1:LineMaterial=null, _arg2:String=null){
super(null, _arg2);
if (!_arg1){
this.material = new LineMaterial();
} else {
this.material = _arg1;
};
init();
}
private function init():void{
this.lines = new Array();
}
public function removeAllLines():void{
while (lines.length > 0) {
removeLine(lines[0]);
};
}
public function addLine(_arg1:Line3D):void{
lines.push(_arg1);
_arg1.instance = this;
if (geometry.vertices.indexOf(_arg1.v0) == -1){
geometry.vertices.push(_arg1.v0);
};
if (geometry.vertices.indexOf(_arg1.v1) == -1){
geometry.vertices.push(_arg1.v1);
};
if (_arg1.cV){
if (geometry.vertices.indexOf(_arg1.cV) == -1){
geometry.vertices.push(_arg1.cV);
};
};
}
public function addNewSegmentedLine(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:Number, _arg7:Number, _arg8:Number):Array{
var _local13:Line3D;
var _local15:Vertex3D;
var _local9:Number = ((_arg6 - _arg3) / _arg2);
var _local10:Number = ((_arg7 - _arg4) / _arg2);
var _local11:Number = ((_arg8 - _arg5) / _arg2);
var _local12:Array = new Array();
var _local14:Vertex3D = new Vertex3D(_arg3, _arg4, _arg5);
var _local16:Number = 0;
while (_local16 <= _arg2) {
_local15 = new Vertex3D((_arg3 + (_local9 * _local16)), (_arg4 + (_local10 * _local16)), (_arg5 + (_local11 * _local16)));
_local13 = new Line3D(this, (material as LineMaterial), _arg1, _local14, _local15);
addLine(_local13);
_local12.push(_local13);
_local14 = _local15;
_local16++;
};
return (_local12);
}
public function removeLine(_arg1:Line3D):void{
var _local2:int = lines.indexOf(_arg1);
if (_local2 > -1){
lines.splice(_local2, 1);
} else {
PaperLogger.warning("Papervision3D Lines3D.removeLine : WARNING removal of non-existant line attempted. ");
};
}
override public function project(_arg1:DisplayObject3D, _arg2:RenderSessionData):Number{
var _local3:Line3D;
var _local4:Number;
var _local5:RenderLine;
super.project(_arg1, _arg2);
for each (_local3 in lines) {
if (_arg2.viewPort.lineCuller.testLine(_local3)){
_local5 = _local3.renderCommand;
_local5.renderer = _local3.material;
_local5.size = _local3.size;
_local4 = (_local4 + (_local5.screenZ = ((_local3.v0.vertex3DInstance.z + _local3.v1.vertex3DInstance.z) / 2)));
_local5.v0 = _local3.v0.vertex3DInstance;
_local5.v1 = _local3.v1.vertex3DInstance;
_arg2.renderer.addToRenderList(_local5);
};
};
return ((_local4 / (lines.length + 1)));
}
public function addNewLine(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:Number, _arg7:Number):Line3D{
var _local8:Line3D = new Line3D(this, (material as LineMaterial), _arg1, new Vertex3D(_arg2, _arg3, _arg4), new Vertex3D(_arg5, _arg6, _arg7));
addLine(_local8);
return (_local8);
}
}
}//package org.papervision3d.core.geom
Section 179
//TriangleMesh3D (org.papervision3d.core.geom.TriangleMesh3D)
package org.papervision3d.core.geom {
import org.papervision3d.objects.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.render.command.*;
import org.papervision3d.core.culling.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.core.math.*;
import flash.utils.*;
import org.papervision3d.core.render.draw.*;
public class TriangleMesh3D extends Vertices3D {
private var _tri:RenderTriangle;
private var _dtStore:Array;
private var _dtActive:Array;
public function TriangleMesh3D(_arg1:MaterialObject3D, _arg2:Array, _arg3:Array, _arg4:String=null){
_dtStore = new Array();
_dtActive = new Array();
super(_arg2, _arg4);
this.geometry.faces = ((_arg3) || (new Array()));
this.material = ((_arg1) || (MaterialObject3D.DEFAULT));
}
public function projectTexture(_arg1:String="x", _arg2:String="y"):void{
var _local10:String;
var _local11:Triangle3D;
var _local12:Array;
var _local13:Vertex3D;
var _local14:Vertex3D;
var _local15:Vertex3D;
var _local16:NumberUV;
var _local17:NumberUV;
var _local18:NumberUV;
var _local3:Array = this.geometry.faces;
var _local4:Object = this.boundingBox();
var _local5:Number = _local4.min[_arg1];
var _local6:Number = _local4.size[_arg1];
var _local7:Number = _local4.min[_arg2];
var _local8:Number = _local4.size[_arg2];
var _local9:MaterialObject3D = this.material;
for (_local10 in _local3) {
_local11 = _local3[Number(_local10)];
_local12 = _local11.vertices;
_local13 = _local12[0];
_local14 = _local12[1];
_local15 = _local12[2];
_local16 = new NumberUV(((_local13[_arg1] - _local5) / _local6), ((_local13[_arg2] - _local7) / _local8));
_local17 = new NumberUV(((_local14[_arg1] - _local5) / _local6), ((_local14[_arg2] - _local7) / _local8));
_local18 = new NumberUV(((_local15[_arg1] - _local5) / _local6), ((_local15[_arg2] - _local7) / _local8));
_local11.uv = [_local16, _local17, _local18];
};
}
public function quarterFaces():void{
var _local4:Triangle3D;
var _local6:Vertex3D;
var _local7:Vertex3D;
var _local8:Vertex3D;
var _local9:Vertex3D;
var _local10:Vertex3D;
var _local11:Vertex3D;
var _local12:NumberUV;
var _local13:NumberUV;
var _local14:NumberUV;
var _local15:NumberUV;
var _local16:NumberUV;
var _local17:NumberUV;
var _local18:Triangle3D;
var _local19:Triangle3D;
var _local20:Triangle3D;
var _local21:Triangle3D;
var _local1:Array = new Array();
var _local2:Array = new Array();
var _local3:Array = this.geometry.faces;
var _local5:int = _local3.length;
while ((_local4 = _local3[--_local5])) {
_local6 = _local4.v0;
_local7 = _local4.v1;
_local8 = _local4.v2;
_local9 = new Vertex3D(((_local6.x + _local7.x) / 2), ((_local6.y + _local7.y) / 2), ((_local6.z + _local7.z) / 2));
_local10 = new Vertex3D(((_local7.x + _local8.x) / 2), ((_local7.y + _local8.y) / 2), ((_local7.z + _local8.z) / 2));
_local11 = new Vertex3D(((_local8.x + _local6.x) / 2), ((_local8.y + _local6.y) / 2), ((_local8.z + _local6.z) / 2));
this.geometry.vertices.push(_local9, _local10, _local11);
_local12 = _local4.uv[0];
_local13 = _local4.uv[1];
_local14 = _local4.uv[2];
_local15 = new NumberUV(((_local12.u + _local13.u) / 2), ((_local12.v + _local13.v) / 2));
_local16 = new NumberUV(((_local13.u + _local14.u) / 2), ((_local13.v + _local14.v) / 2));
_local17 = new NumberUV(((_local14.u + _local12.u) / 2), ((_local14.v + _local12.v) / 2));
_local18 = new Triangle3D(this, [_local6, _local9, _local11], _local4.material, [_local12, _local15, _local17]);
_local19 = new Triangle3D(this, [_local9, _local7, _local10], _local4.material, [_local15, _local13, _local16]);
_local20 = new Triangle3D(this, [_local11, _local10, _local8], _local4.material, [_local17, _local16, _local14]);
_local21 = new Triangle3D(this, [_local9, _local10, _local11], _local4.material, [_local15, _local16, _local17]);
_local2.push(_local18, _local19, _local20, _local21);
};
this.geometry.faces = _local2;
this.mergeVertices();
this.geometry.ready = true;
}
override public function set material(_arg1:MaterialObject3D):void{
var _local2:Triangle3D;
super.material = _arg1;
for each (_local2 in geometry.faces) {
_local2.material = _arg1;
};
}
public function mergeVertices():void{
var _local3:Vertex3D;
var _local4:Triangle3D;
var _local5:Vertex3D;
var _local1:Dictionary = new Dictionary();
var _local2:Array = new Array();
for each (_local3 in this.geometry.vertices) {
for each (_local5 in _local1) {
if ((((((_local3.x == _local5.x)) && ((_local3.y == _local5.y)))) && ((_local3.z == _local5.z)))){
_local1[_local3] = _local5;
break;
};
};
if (!_local1[_local3]){
_local1[_local3] = _local3;
_local2.push(_local3);
};
};
this.geometry.vertices = _local2;
for each (_local4 in geometry.faces) {
_local4.v0 = (_local4.vertices[0] = _local1[_local4.v0]);
_local4.v1 = (_local4.vertices[1] = _local1[_local4.v1]);
_local4.v2 = (_local4.vertices[2] = _local1[_local4.v2]);
};
}
override public function project(_arg1:DisplayObject3D, _arg2:RenderSessionData):Number{
var _local5:Triangle3D;
var _local6:Array;
var _local7:Number;
var _local8:Number;
var _local9:ITriangleCuller;
var _local10:Vertex3DInstance;
var _local11:Vertex3DInstance;
var _local12:Vertex3DInstance;
var _local13:Triangle3DInstance;
var _local14:Triangle3D;
var _local15:MaterialObject3D;
var _local16:RenderTriangle;
_dtStore = [];
_dtActive = new Array();
var _local3:int = this.geometry.vertices.length;
var _local4:Array = [];
if (((((((_arg2.clipping) && (this.useClipping))) && (!(this.culled)))) && ((_arg2.camera.useCulling) ? (cullTest == 0) : true))){
super.projectEmpty(_arg1, _arg2);
_arg2.clipping.setDisplayObject(this, _arg2);
for each (_local5 in this.geometry.faces) {
if (_arg2.clipping.testFace(_local5, this, _arg2)){
_arg2.clipping.clipFace(_local5, this, _local15, _arg2, _local4);
} else {
_local4.push(_local5);
};
};
super.project(_arg1, _arg2);
_arg2.camera.projectFaces(_local4, this, _arg2);
} else {
super.project(_arg1, _arg2);
_local4 = this.geometry.faces;
};
if (!this.culled){
_local6 = this.geometry.faces;
_local7 = 0;
_local8 = 0;
_local9 = _arg2.triangleCuller;
for each (_local14 in _local4) {
_local15 = (_local14.material) ? _local14.material : material;
_local10 = _local14.v0.vertex3DInstance;
_local11 = _local14.v1.vertex3DInstance;
_local12 = _local14.v2.vertex3DInstance;
if (_local9.testFace(_local14, _local10, _local11, _local12)){
_local16 = _local14.renderCommand;
_local7 = (_local7 + (_local16.screenZ = setScreenZ(meshSort, _local10, _local11, _local12)));
_local8++;
_local16.renderer = (_local15 as ITriangleDrawer);
_local16.v0 = _local10;
_local16.v1 = _local11;
_local16.v2 = _local12;
_local16.uv0 = _local14.uv0;
_local16.uv1 = _local14.uv1;
_local16.uv2 = _local14.uv2;
if (_arg2.quadrantTree){
if (_local16.create == null){
_local16.create = createRenderTriangle;
};
_local16.update();
if ((((_local16.area < 0)) && (((_local14.material.doubleSided) || (((_local14.material.oneSide) && (_local14.material.opposite))))))){
_local16.area = -(_local16.area);
};
};
_arg2.renderer.addToRenderList(_local16);
} else {
_arg2.renderStatistics.culledTriangles++;
};
};
if (_local3){
while (this.geometry.vertices.length > _local3) {
this.geometry.vertices.pop();
};
};
return ((this.screenZ = (_local7 / _local8)));
//unresolved jump
};
_arg2.renderStatistics.culledObjects++;
return (0);
}
public function createRenderTriangle(_arg1:Triangle3D, _arg2:MaterialObject3D, _arg3:Vertex3DInstance, _arg4:Vertex3DInstance, _arg5:Vertex3DInstance, _arg6:NumberUV, _arg7:NumberUV, _arg8:NumberUV):RenderTriangle{
if (_dtStore.length){
_dtActive.push((_tri = _dtStore.pop()));
} else {
_dtActive.push((_tri = new RenderTriangle(_arg1)));
};
_tri.instance = this;
_tri.triangle = _arg1;
_tri.renderableInstance = _arg1;
_tri.renderer = _arg2;
_tri.create = createRenderTriangle;
_tri.v0 = _arg3;
_tri.v1 = _arg4;
_tri.v2 = _arg5;
_tri.uv0 = _arg6;
_tri.uv1 = _arg7;
_tri.uv2 = _arg8;
_tri.update();
return (_tri);
}
protected function setScreenZ(_arg1:uint, _arg2:Vertex3DInstance, _arg3:Vertex3DInstance, _arg4:Vertex3DInstance):Number{
switch (_arg1){
case DisplayObject3D.MESH_SORT_CENTER:
return ((((_arg2.z + _arg3.z) + _arg4.z) / 3));
case DisplayObject3D.MESH_SORT_FAR:
return (Math.max(_arg2.z, _arg3.z, _arg4.z));
case DisplayObject3D.MESH_SORT_CLOSE:
return (Math.min(_arg2.z, _arg3.z, _arg4.z));
};
return (0);
}
override public function clone():DisplayObject3D{
var _local1:DisplayObject3D = super.clone();
var _local2:TriangleMesh3D = new TriangleMesh3D(this.material, [], [], _local1.name);
if (this.materials){
_local2.materials = this.materials.clone();
};
if (_local1.geometry){
_local2.geometry = _local1.geometry.clone(_local2);
};
_local2.copyTransform(this.transform);
return (_local2);
}
}
}//package org.papervision3d.core.geom
Section 180
//Vertices3D (org.papervision3d.core.geom.Vertices3D)
package org.papervision3d.core.geom {
import org.papervision3d.objects.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.culling.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.core.math.*;
public class Vertices3D extends DisplayObject3D {
public function Vertices3D(_arg1:Array, _arg2:String=null){
super(_arg2, new GeometryObject3D());
this.geometry.vertices = ((_arg1) || (new Array()));
}
override public function project(_arg1:DisplayObject3D, _arg2:RenderSessionData):Number{
super.project(_arg1, _arg2);
if (this.culled){
return (0);
};
if ((_arg2.camera is IObjectCuller)){
return (projectFrustum(_arg1, _arg2));
};
if (((!(this.geometry)) || (!(this.geometry.vertices)))){
return (0);
};
return (_arg2.camera.projectVertices(this.geometry.vertices, this, _arg2));
}
public function projectEmpty(_arg1:DisplayObject3D, _arg2:RenderSessionData):Number{
return (super.project(_arg1, _arg2));
}
public function worldBoundingBox():Object{
var _local3:Number3D;
var _local4:Vertex3D;
var _local1:Array = this.geometry.vertices;
var _local2:Object = new Object();
_local2.min = new Number3D(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
_local2.max = new Number3D(-(Number.MAX_VALUE), -(Number.MAX_VALUE), -(Number.MAX_VALUE));
_local2.size = new Number3D();
for each (_local4 in _local1) {
_local3 = _local4.getPosition();
Matrix3D.multiplyVector(this.world, _local3);
_local2.min.x = Math.min(_local3.x, _local2.min.x);
_local2.min.y = Math.min(_local3.y, _local2.min.y);
_local2.min.z = Math.min(_local3.z, _local2.min.z);
_local2.max.x = Math.max(_local3.x, _local2.max.x);
_local2.max.y = Math.max(_local3.y, _local2.max.y);
_local2.max.z = Math.max(_local3.z, _local2.max.z);
};
_local2.size.x = (_local2.max.x - _local2.min.x);
_local2.size.y = (_local2.max.y - _local2.min.y);
_local2.size.z = (_local2.max.z - _local2.min.z);
return (_local2);
}
public function boundingBox():Object{
var _local3:Vertex3D;
var _local1:Array = this.geometry.vertices;
var _local2:Object = new Object();
_local2.min = new Number3D(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
_local2.max = new Number3D(-(Number.MAX_VALUE), -(Number.MAX_VALUE), -(Number.MAX_VALUE));
_local2.size = new Number3D();
for each (_local3 in _local1) {
_local2.min.x = Math.min(_local3.x, _local2.min.x);
_local2.min.y = Math.min(_local3.y, _local2.min.y);
_local2.min.z = Math.min(_local3.z, _local2.min.z);
_local2.max.x = Math.max(_local3.x, _local2.max.x);
_local2.max.y = Math.max(_local3.y, _local2.max.y);
_local2.max.z = Math.max(_local3.z, _local2.max.z);
};
_local2.size.x = (_local2.max.x - _local2.min.x);
_local2.size.y = (_local2.max.y - _local2.min.y);
_local2.size.z = (_local2.max.z - _local2.min.z);
return (_local2);
}
public function projectFrustum(_arg1:DisplayObject3D, _arg2:RenderSessionData):Number{
return (0);
}
public function transformVertices(_arg1:Matrix3D):void{
geometry.transformVertices(_arg1);
}
override public function clone():DisplayObject3D{
var _local1:DisplayObject3D = super.clone();
var _local2:Vertices3D = new Vertices3D(null, _local1.name);
_local2.material = _local1.material;
if (_local1.materials){
_local2.materials = _local1.materials.clone();
};
if (this.geometry){
_local2.geometry = this.geometry.clone(_local2);
};
_local2.copyTransform(this.transform);
return (_local2);
}
}
}//package org.papervision3d.core.geom
Section 181
//PaperLoggerEvent (org.papervision3d.core.log.event.PaperLoggerEvent)
package org.papervision3d.core.log.event {
import flash.events.*;
import org.papervision3d.core.log.*;
public class PaperLoggerEvent extends Event {
public var paperLogVO:PaperLogVO;
public static const TYPE_LOGEVENT:String = "logEvent";
public function PaperLoggerEvent(_arg1:PaperLogVO){
super(TYPE_LOGEVENT);
this.paperLogVO = _arg1;
}
}
}//package org.papervision3d.core.log.event
Section 182
//AbstractPaperLogger (org.papervision3d.core.log.AbstractPaperLogger)
package org.papervision3d.core.log {
import org.papervision3d.core.log.event.*;
public class AbstractPaperLogger implements IPaperLogger {
public function registerWithPaperLogger(_arg1:PaperLogger):void{
_arg1.addEventListener(PaperLoggerEvent.TYPE_LOGEVENT, onLogEvent);
}
public function debug(_arg1:String, _arg2:Object=null, _arg3:Array=null):void{
}
public function warning(_arg1:String, _arg2:Object=null, _arg3:Array=null):void{
}
public function log(_arg1:String, _arg2:Object=null, _arg3:Array=null):void{
}
public function fatal(_arg1:String, _arg2:Object=null, _arg3:Array=null):void{
}
public function error(_arg1:String, _arg2:Object=null, _arg3:Array=null):void{
}
protected function onLogEvent(_arg1:PaperLoggerEvent):void{
var _local2:PaperLogVO = _arg1.paperLogVO;
switch (_local2.level){
case LogLevel.LOG:
log(_local2.msg, _local2.object, _local2.arg);
break;
case LogLevel.INFO:
info(_local2.msg, _local2.object, _local2.arg);
break;
case LogLevel.ERROR:
error(_local2.msg, _local2.object, _local2.arg);
break;
case LogLevel.DEBUG:
debug(_local2.msg, _local2.object, _local2.arg);
break;
case LogLevel.WARNING:
warning(_local2.msg, _local2.object, _local2.arg);
break;
case LogLevel.FATAL:
fatal(_local2.msg, _local2.object, _local2.arg);
break;
default:
log(_local2.msg, _local2.object, _local2.arg);
break;
};
}
public function unregisterFromPaperLogger(_arg1:PaperLogger):void{
_arg1.removeEventListener(PaperLoggerEvent.TYPE_LOGEVENT, onLogEvent);
}
public function info(_arg1:String, _arg2:Object=null, _arg3:Array=null):void{
}
}
}//package org.papervision3d.core.log
Section 183
//IPaperLogger (org.papervision3d.core.log.IPaperLogger)
package org.papervision3d.core.log {
public interface IPaperLogger {
function debug(_arg1:String, _arg2:Object=null, _arg3:Array=null):void;
function log(_arg1:String, _arg2:Object=null, _arg3:Array=null):void;
function error(_arg1:String, _arg2:Object=null, _arg3:Array=null):void;
function fatal(_arg1:String, _arg2:Object=null, _arg3:Array=null):void;
function warning(_arg1:String, _arg2:Object=null, _arg3:Array=null):void;
function info(_arg1:String, _arg2:Object=null, _arg3:Array=null):void;
}
}//package org.papervision3d.core.log
Section 184
//LogLevel (org.papervision3d.core.log.LogLevel)
package org.papervision3d.core.log {
public class LogLevel {
public static const FATAL:int = 5;
public static const ERROR:int = 4;
public static const LOG:int = 0;
public static const INFO:int = 1;
public static const DEBUG:int = 2;
public static const WARNING:int = 3;
}
}//package org.papervision3d.core.log
Section 185
//PaperLogger (org.papervision3d.core.log.PaperLogger)
package org.papervision3d.core.log {
import flash.events.*;
import org.papervision3d.core.log.event.*;
public class PaperLogger extends EventDispatcher {
public var traceLogger:PaperTraceLogger;
private static var instance:PaperLogger;
public function PaperLogger(){
if (instance){
throw (new Error("Don't call the PaperLogger constructor directly"));
};
traceLogger = new PaperTraceLogger();
registerLogger(traceLogger);
}
public function registerLogger(_arg1:AbstractPaperLogger):void{
_arg1.registerWithPaperLogger(this);
}
public function _debug(_arg1:String, _arg2:Object=null, ... _args):void{
var _local4:PaperLogVO = new PaperLogVO(LogLevel.DEBUG, _arg1, _arg2, _args);
var _local5:PaperLoggerEvent = new PaperLoggerEvent(_local4);
dispatchEvent(_local5);
}
public function _log(_arg1:String, _arg2:Object=null, ... _args):void{
var _local4:PaperLogVO = new PaperLogVO(LogLevel.LOG, _arg1, _arg2, _args);
var _local5:PaperLoggerEvent = new PaperLoggerEvent(_local4);
dispatchEvent(_local5);
}
public function _error(_arg1:String, _arg2:Object=null, ... _args):void{
var _local4:PaperLogVO = new PaperLogVO(LogLevel.ERROR, _arg1, _arg2, _args);
var _local5:PaperLoggerEvent = new PaperLoggerEvent(_local4);
dispatchEvent(_local5);
}
public function unregisterLogger(_arg1:AbstractPaperLogger):void{
_arg1.unregisterFromPaperLogger(this);
}
public function _info(_arg1:String, _arg2:Object=null, ... _args):void{
var _local4:PaperLogVO = new PaperLogVO(LogLevel.INFO, _arg1, _arg2, _args);
var _local5:PaperLoggerEvent = new PaperLoggerEvent(_local4);
dispatchEvent(_local5);
}
public function _warning(_arg1:String, _arg2:Object=null, ... _args):void{
var _local4:PaperLogVO = new PaperLogVO(LogLevel.WARNING, _arg1, _arg2, _args);
var _local5:PaperLoggerEvent = new PaperLoggerEvent(_local4);
dispatchEvent(_local5);
}
public static function debug(_arg1:String, _arg2:Object=null, ... _args):void{
getInstance()._debug(_arg1);
}
public static function log(_arg1:String, _arg2:Object=null, ... _args):void{
getInstance()._log(_arg1);
}
public static function error(_arg1:String, _arg2:Object=null, ... _args):void{
getInstance()._error(_arg1);
}
public static function getInstance():PaperLogger{
if (!instance){
instance = new (PaperLogger);
};
return (instance);
}
public static function warning(_arg1:String, _arg2:Object=null, ... _args):void{
getInstance()._warning(_arg1);
}
public static function info(_arg1:String, _arg2:Object=null, ... _args):void{
getInstance()._info(_arg1);
}
}
}//package org.papervision3d.core.log
Section 186
//PaperLogVO (org.papervision3d.core.log.PaperLogVO)
package org.papervision3d.core.log {
public class PaperLogVO {
public var msg:String;
public var level:int;
public var arg:Array;
public var object:Object;
public function PaperLogVO(_arg1:int, _arg2:String, _arg3:Object, _arg4:Array){
this.level = _arg1;
this.msg = _arg2;
this.object = _arg3;
this.arg = _arg4;
}
}
}//package org.papervision3d.core.log
Section 187
//PaperTraceLogger (org.papervision3d.core.log.PaperTraceLogger)
package org.papervision3d.core.log {
public class PaperTraceLogger extends AbstractPaperLogger implements IPaperLogger {
override public function warning(_arg1:String, _arg2:Object=null, _arg3:Array=null):void{
trace("WARNING:", _arg1, _arg3);
}
override public function log(_arg1:String, _arg2:Object=null, _arg3:Array=null):void{
trace("LOG:", _arg1, _arg3);
}
override public function error(_arg1:String, _arg2:Object=null, _arg3:Array=null):void{
trace("ERROR:", _arg1, _arg3);
}
override public function fatal(_arg1:String, _arg2:Object=null, _arg3:Array=null):void{
trace("FATAL:", _arg1, _arg3);
}
override public function info(_arg1:String, _arg2:Object=null, _arg3:Array=null):void{
trace("INFO:", _arg1, _arg3);
}
override public function debug(_arg1:String, _arg2:Object=null, _arg3:Array=null):void{
trace("DEBUG:", _arg1, _arg3);
}
}
}//package org.papervision3d.core.log
Section 188
//AbstractLightShadeMaterial (org.papervision3d.core.material.AbstractLightShadeMaterial)
package org.papervision3d.core.material {
import org.papervision3d.objects.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.core.math.*;
import flash.utils.*;
import org.papervision3d.materials.utils.*;
import org.papervision3d.core.render.material.*;
import org.papervision3d.core.render.draw.*;
public class AbstractLightShadeMaterial extends TriangleMaterial implements ITriangleDrawer, IUpdateBeforeMaterial {
public var lightMatrices:Dictionary;
private var _light:LightObject3D;
protected static var lightMatrix:Matrix3D;
public function AbstractLightShadeMaterial(){
init();
}
public function updateBeforeRender(_arg1:RenderSessionData):void{
var _local2:Object;
var _local3:DisplayObject3D;
for (_local2 in objects) {
_local3 = (_local2 as DisplayObject3D);
lightMatrices[_local2] = LightMatrix.getLightMatrix(light, _local3, _arg1, lightMatrices[_local2]);
};
}
protected function init():void{
lightMatrices = new Dictionary();
}
public function get light():LightObject3D{
return (_light);
}
public function set light(_arg1:LightObject3D):void{
_light = _arg1;
}
}
}//package org.papervision3d.core.material
Section 189
//AbstractSmoothShadeMaterial (org.papervision3d.core.material.AbstractSmoothShadeMaterial)
package org.papervision3d.core.material {
import flash.geom.*;
import org.papervision3d.core.render.material.*;
import org.papervision3d.core.render.draw.*;
public class AbstractSmoothShadeMaterial extends AbstractLightShadeMaterial implements ITriangleDrawer, IUpdateBeforeMaterial {
protected var triMatrix:Matrix;
protected var transformMatrix:Matrix;
override protected function init():void{
super.init();
transformMatrix = new Matrix();
triMatrix = new Matrix();
}
}
}//package org.papervision3d.core.material
Section 190
//TriangleMaterial (org.papervision3d.core.material.TriangleMaterial)
package org.papervision3d.core.material {
import flash.display.*;
import flash.geom.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.render.command.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.core.render.draw.*;
public class TriangleMaterial extends MaterialObject3D implements ITriangleDrawer {
override public function drawTriangle(_arg1:RenderTriangle, _arg2:Graphics, _arg3:RenderSessionData, _arg4:BitmapData=null, _arg5:Matrix=null):void{
}
override public function drawRT(_arg1:RenderTriangle, _arg2:Graphics, _arg3:RenderSessionData):void{
}
}
}//package org.papervision3d.core.material
Section 191
//FastRectangleTools (org.papervision3d.core.math.util.FastRectangleTools)
package org.papervision3d.core.math.util {
import flash.geom.*;
public class FastRectangleTools {
public static function intersection(_arg1:Rectangle, _arg2:Rectangle, _arg3:Rectangle=null):Rectangle{
if (!_arg3){
_arg3 = new Rectangle();
};
if (!intersects(_arg1, _arg2)){
_arg3.x = (_arg3.y = (_arg3.width = (_arg3.height = 0)));
return (_arg3);
};
_arg3.left = ((_arg1.left)>_arg2.left) ? _arg1.left : _arg2.left;
_arg3.right = ((_arg1.right)<_arg2.right) ? _arg1.right : _arg2.right;
_arg3.top = ((_arg1.top)>_arg2.top) ? _arg1.top : _arg2.top;
_arg3.bottom = ((_arg1.bottom)<_arg2.bottom) ? _arg1.bottom : _arg2.bottom;
return (_arg3);
}
public static function intersects(_arg1:Rectangle, _arg2:Rectangle):Boolean{
if (!(((_arg1.right < _arg2.left)) || ((_arg1.left > _arg2.right)))){
if (!(((_arg1.bottom < _arg2.top)) || ((_arg1.top > _arg2.bottom)))){
return (true);
};
};
return (false);
}
}
}//package org.papervision3d.core.math.util
Section 192
//AxisAlignedBoundingBox (org.papervision3d.core.math.AxisAlignedBoundingBox)
package org.papervision3d.core.math {
import org.papervision3d.core.geom.renderables.*;
public class AxisAlignedBoundingBox {
public var minX:Number;
public var minY:Number;
public var minZ:Number;
public var maxX:Number;
public var maxY:Number;
public var maxZ:Number;
protected var _vertices:Array;
public function AxisAlignedBoundingBox(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:Number){
this.minX = _arg1;
this.minY = _arg2;
this.minZ = _arg3;
this.maxX = _arg4;
this.maxY = _arg5;
this.maxZ = _arg6;
createBoxVertices();
}
protected function createBoxVertices():void{
_vertices = new Array();
_vertices.push(new Vertex3D(minX, minY, minZ));
_vertices.push(new Vertex3D(minX, minY, maxZ));
_vertices.push(new Vertex3D(minX, maxY, minZ));
_vertices.push(new Vertex3D(minX, maxY, maxZ));
_vertices.push(new Vertex3D(maxX, minY, minZ));
_vertices.push(new Vertex3D(maxX, minY, maxZ));
_vertices.push(new Vertex3D(maxX, maxY, minZ));
_vertices.push(new Vertex3D(maxX, maxY, maxZ));
}
public function getBoxVertices():Array{
return (_vertices);
}
public function merge(_arg1:AxisAlignedBoundingBox):void{
this.minX = Math.min(this.minX, _arg1.minX);
this.minY = Math.min(this.minY, _arg1.minY);
this.minZ = Math.min(this.minZ, _arg1.minZ);
this.maxX = Math.max(this.maxX, _arg1.maxX);
this.maxY = Math.max(this.maxY, _arg1.maxY);
this.maxZ = Math.max(this.maxZ, _arg1.maxZ);
createBoxVertices();
}
public static function createFromVertices(_arg1:Array):AxisAlignedBoundingBox{
var _local8:Vertex3D;
var _local2:Number = Number.MAX_VALUE;
var _local3:Number = Number.MAX_VALUE;
var _local4:Number = Number.MAX_VALUE;
var _local5:Number = -(_local2);
var _local6:Number = -(_local3);
var _local7:Number = -(_local4);
for each (_local8 in _arg1) {
_local2 = Math.min(_local2, _local8.x);
_local3 = Math.min(_local3, _local8.y);
_local4 = Math.min(_local4, _local8.z);
_local5 = Math.max(_local5, _local8.x);
_local6 = Math.max(_local6, _local8.y);
_local7 = Math.max(_local7, _local8.z);
};
return (new AxisAlignedBoundingBox(_local2, _local3, _local4, _local5, _local6, _local7));
}
}
}//package org.papervision3d.core.math
Section 193
//BoundingSphere (org.papervision3d.core.math.BoundingSphere)
package org.papervision3d.core.math {
import org.papervision3d.core.geom.renderables.*;
public class BoundingSphere {
public var maxDistance:Number;
public var radius:Number;
public function BoundingSphere(_arg1:Number){
this.maxDistance = _arg1;
this.radius = Math.sqrt(_arg1);
}
public static function getFromVertices(_arg1:Array):BoundingSphere{
var _local3:Number;
var _local4:Vertex3D;
var _local2:Number = 0;
for each (_local4 in _arg1) {
_local3 = (((_local4.x * _local4.x) + (_local4.y * _local4.y)) + (_local4.z * _local4.z));
_local2 = ((_local3)>_local2) ? _local3 : _local2;
};
return (new BoundingSphere(_local2));
}
}
}//package org.papervision3d.core.math
Section 194
//Matrix3D (org.papervision3d.core.math.Matrix3D)
package org.papervision3d.core.math {
import org.papervision3d.*;
public class Matrix3D {
public var n31:Number;
public var n32:Number;
public var n11:Number;
public var n34:Number;
public var n13:Number;
public var n14:Number;
public var n33:Number;
public var n12:Number;
public var n41:Number;
public var n42:Number;
public var n21:Number;
public var n22:Number;
public var n23:Number;
public var n24:Number;
public var n44:Number;
public var n43:Number;
private static var _cos:Function = Math.cos;
private static var _sin:Function = Math.sin;
private static var temp:Matrix3D = Matrix3D.IDENTITY;
private static var n3Di:Number3D = Number3D.ZERO;
private static var n3Dj:Number3D = Number3D.ZERO;
private static var n3Dk:Number3D = Number3D.ZERO;
private static var toDEGREES:Number = 57.2957795130823;
private static var toRADIANS:Number = 0.0174532925199433;
public function Matrix3D(_arg1:Array=null){
reset(_arg1);
}
public function calculateMultiply3x3(_arg1:Matrix3D, _arg2:Matrix3D):void{
var _local3:Number = _arg1.n11;
var _local4:Number = _arg2.n11;
var _local5:Number = _arg1.n21;
var _local6:Number = _arg2.n21;
var _local7:Number = _arg1.n31;
var _local8:Number = _arg2.n31;
var _local9:Number = _arg1.n12;
var _local10:Number = _arg2.n12;
var _local11:Number = _arg1.n22;
var _local12:Number = _arg2.n22;
var _local13:Number = _arg1.n32;
var _local14:Number = _arg2.n32;
var _local15:Number = _arg1.n13;
var _local16:Number = _arg2.n13;
var _local17:Number = _arg1.n23;
var _local18:Number = _arg2.n23;
var _local19:Number = _arg1.n33;
var _local20:Number = _arg2.n33;
this.n11 = (((_local3 * _local4) + (_local9 * _local6)) + (_local15 * _local8));
this.n12 = (((_local3 * _local10) + (_local9 * _local12)) + (_local15 * _local14));
this.n13 = (((_local3 * _local16) + (_local9 * _local18)) + (_local15 * _local20));
this.n21 = (((_local5 * _local4) + (_local11 * _local6)) + (_local17 * _local8));
this.n22 = (((_local5 * _local10) + (_local11 * _local12)) + (_local17 * _local14));
this.n23 = (((_local5 * _local16) + (_local11 * _local18)) + (_local17 * _local20));
this.n31 = (((_local7 * _local4) + (_local13 * _local6)) + (_local19 * _local8));
this.n32 = (((_local7 * _local10) + (_local13 * _local12)) + (_local19 * _local14));
this.n33 = (((_local7 * _local16) + (_local13 * _local18)) + (_local19 * _local20));
}
public function calculateMultiply4x4(_arg1:Matrix3D, _arg2:Matrix3D):void{
var _local3:Number = _arg1.n11;
var _local4:Number = _arg2.n11;
var _local5:Number = _arg1.n21;
var _local6:Number = _arg2.n21;
var _local7:Number = _arg1.n31;
var _local8:Number = _arg2.n31;
var _local9:Number = _arg1.n41;
var _local10:Number = _arg2.n41;
var _local11:Number = _arg1.n12;
var _local12:Number = _arg2.n12;
var _local13:Number = _arg1.n22;
var _local14:Number = _arg2.n22;
var _local15:Number = _arg1.n32;
var _local16:Number = _arg2.n32;
var _local17:Number = _arg1.n42;
var _local18:Number = _arg2.n42;
var _local19:Number = _arg1.n13;
var _local20:Number = _arg2.n13;
var _local21:Number = _arg1.n23;
var _local22:Number = _arg2.n23;
var _local23:Number = _arg1.n33;
var _local24:Number = _arg2.n33;
var _local25:Number = _arg1.n43;
var _local26:Number = _arg2.n43;
var _local27:Number = _arg1.n14;
var _local28:Number = _arg2.n14;
var _local29:Number = _arg1.n24;
var _local30:Number = _arg2.n24;
var _local31:Number = _arg1.n34;
var _local32:Number = _arg2.n34;
var _local33:Number = _arg1.n44;
var _local34:Number = _arg2.n44;
this.n11 = (((_local3 * _local4) + (_local11 * _local6)) + (_local19 * _local8));
this.n12 = (((_local3 * _local12) + (_local11 * _local14)) + (_local19 * _local16));
this.n13 = (((_local3 * _local20) + (_local11 * _local22)) + (_local19 * _local24));
this.n14 = ((((_local3 * _local28) + (_local11 * _local30)) + (_local19 * _local32)) + _local27);
this.n21 = (((_local5 * _local4) + (_local13 * _local6)) + (_local21 * _local8));
this.n22 = (((_local5 * _local12) + (_local13 * _local14)) + (_local21 * _local16));
this.n23 = (((_local5 * _local20) + (_local13 * _local22)) + (_local21 * _local24));
this.n24 = ((((_local5 * _local28) + (_local13 * _local30)) + (_local21 * _local32)) + _local29);
this.n31 = (((_local7 * _local4) + (_local15 * _local6)) + (_local23 * _local8));
this.n32 = (((_local7 * _local12) + (_local15 * _local14)) + (_local23 * _local16));
this.n33 = (((_local7 * _local20) + (_local15 * _local22)) + (_local23 * _local24));
this.n34 = ((((_local7 * _local28) + (_local15 * _local30)) + (_local23 * _local32)) + _local31);
this.n41 = (((_local9 * _local4) + (_local17 * _local6)) + (_local25 * _local8));
this.n42 = (((_local9 * _local12) + (_local17 * _local14)) + (_local25 * _local16));
this.n43 = (((_local9 * _local20) + (_local17 * _local22)) + (_local25 * _local24));
this.n44 = ((((_local9 * _local28) + (_local17 * _local30)) + (_local25 * _local32)) + _local33);
}
public function calculateSkewSymmetric(_arg1:Number3D):void{
this.n11 = 0;
this.n12 = -(_arg1.z);
this.n13 = _arg1.y;
this.n21 = _arg1.z;
this.n22 = 0;
this.n23 = -(_arg1.x);
this.n31 = -(_arg1.y);
this.n32 = _arg1.x;
this.n33 = 0;
}
public function get det():Number{
return ((((((this.n11 * this.n22) - (this.n21 * this.n12)) * this.n33) - (((this.n11 * this.n32) - (this.n31 * this.n12)) * this.n23)) + (((this.n21 * this.n32) - (this.n31 * this.n22)) * this.n13)));
}
public function copy(_arg1:Matrix3D):Matrix3D{
this.n11 = _arg1.n11;
this.n12 = _arg1.n12;
this.n13 = _arg1.n13;
this.n14 = _arg1.n14;
this.n21 = _arg1.n21;
this.n22 = _arg1.n22;
this.n23 = _arg1.n23;
this.n24 = _arg1.n24;
this.n31 = _arg1.n31;
this.n32 = _arg1.n32;
this.n33 = _arg1.n33;
this.n34 = _arg1.n34;
return (this);
}
public function copy3x3(_arg1:Matrix3D):Matrix3D{
this.n11 = _arg1.n11;
this.n12 = _arg1.n12;
this.n13 = _arg1.n13;
this.n21 = _arg1.n21;
this.n22 = _arg1.n22;
this.n23 = _arg1.n23;
this.n31 = _arg1.n31;
this.n32 = _arg1.n32;
this.n33 = _arg1.n33;
return (this);
}
public function calculateAdd(_arg1:Matrix3D, _arg2:Matrix3D):void{
this.n11 = (_arg1.n11 + _arg2.n11);
this.n12 = (_arg1.n12 + _arg2.n12);
this.n13 = (_arg1.n13 + _arg2.n13);
this.n14 = (_arg1.n14 + _arg2.n14);
this.n21 = (_arg1.n21 + _arg2.n21);
this.n22 = (_arg1.n22 + _arg2.n22);
this.n23 = (_arg1.n23 + _arg2.n23);
this.n24 = (_arg1.n24 + _arg2.n24);
this.n31 = (_arg1.n31 + _arg2.n31);
this.n32 = (_arg1.n32 + _arg2.n32);
this.n33 = (_arg1.n33 + _arg2.n33);
this.n34 = (_arg1.n34 + _arg2.n34);
}
public function calculateMultiply(_arg1:Matrix3D, _arg2:Matrix3D):void{
var _local3:Number = _arg1.n11;
var _local4:Number = _arg2.n11;
var _local5:Number = _arg1.n21;
var _local6:Number = _arg2.n21;
var _local7:Number = _arg1.n31;
var _local8:Number = _arg2.n31;
var _local9:Number = _arg1.n12;
var _local10:Number = _arg2.n12;
var _local11:Number = _arg1.n22;
var _local12:Number = _arg2.n22;
var _local13:Number = _arg1.n32;
var _local14:Number = _arg2.n32;
var _local15:Number = _arg1.n13;
var _local16:Number = _arg2.n13;
var _local17:Number = _arg1.n23;
var _local18:Number = _arg2.n23;
var _local19:Number = _arg1.n33;
var _local20:Number = _arg2.n33;
var _local21:Number = _arg1.n14;
var _local22:Number = _arg2.n14;
var _local23:Number = _arg1.n24;
var _local24:Number = _arg2.n24;
var _local25:Number = _arg1.n34;
var _local26:Number = _arg2.n34;
this.n11 = (((_local3 * _local4) + (_local9 * _local6)) + (_local15 * _local8));
this.n12 = (((_local3 * _local10) + (_local9 * _local12)) + (_local15 * _local14));
this.n13 = (((_local3 * _local16) + (_local9 * _local18)) + (_local15 * _local20));
this.n14 = ((((_local3 * _local22) + (_local9 * _local24)) + (_local15 * _local26)) + _local21);
this.n21 = (((_local5 * _local4) + (_local11 * _local6)) + (_local17 * _local8));
this.n22 = (((_local5 * _local10) + (_local11 * _local12)) + (_local17 * _local14));
this.n23 = (((_local5 * _local16) + (_local11 * _local18)) + (_local17 * _local20));
this.n24 = ((((_local5 * _local22) + (_local11 * _local24)) + (_local17 * _local26)) + _local23);
this.n31 = (((_local7 * _local4) + (_local13 * _local6)) + (_local19 * _local8));
this.n32 = (((_local7 * _local10) + (_local13 * _local12)) + (_local19 * _local14));
this.n33 = (((_local7 * _local16) + (_local13 * _local18)) + (_local19 * _local20));
this.n34 = ((((_local7 * _local22) + (_local13 * _local24)) + (_local19 * _local26)) + _local25);
}
public function reset(_arg1:Array=null):void{
if (((!(_arg1)) || ((_arg1.length < 12)))){
n11 = (n22 = (n33 = (n44 = 1)));
n12 = (n13 = (n14 = (n21 = (n23 = (n24 = (n31 = (n32 = (n34 = (n41 = (n42 = (n43 = 0)))))))))));
} else {
n11 = _arg1[0];
n12 = _arg1[1];
n13 = _arg1[2];
n14 = _arg1[3];
n21 = _arg1[4];
n22 = _arg1[5];
n23 = _arg1[6];
n24 = _arg1[7];
n31 = _arg1[8];
n32 = _arg1[9];
n33 = _arg1[10];
n34 = _arg1[11];
if (_arg1.length == 16){
n41 = _arg1[12];
n42 = _arg1[13];
n43 = _arg1[14];
n44 = _arg1[15];
} else {
n41 = (n42 = (n43 = 0));
n44 = 1;
};
};
}
public function invert():void{
temp.copy(this);
calculateInverse(temp);
}
public function calculateInverse(_arg1:Matrix3D):void{
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local2:Number = _arg1.det;
if (Math.abs(_local2) > 0.001){
_local2 = (1 / _local2);
_local3 = _arg1.n11;
_local4 = _arg1.n21;
_local5 = _arg1.n31;
_local6 = _arg1.n12;
_local7 = _arg1.n22;
_local8 = _arg1.n32;
_local9 = _arg1.n13;
_local10 = _arg1.n23;
_local11 = _arg1.n33;
_local12 = _arg1.n14;
_local13 = _arg1.n24;
_local14 = _arg1.n34;
this.n11 = (_local2 * ((_local7 * _local11) - (_local8 * _local10)));
this.n12 = (-(_local2) * ((_local6 * _local11) - (_local8 * _local9)));
this.n13 = (_local2 * ((_local6 * _local10) - (_local7 * _local9)));
this.n14 = (-(_local2) * (((_local6 * ((_local10 * _local14) - (_local11 * _local13))) - (_local7 * ((_local9 * _local14) - (_local11 * _local12)))) + (_local8 * ((_local9 * _local13) - (_local10 * _local12)))));
this.n21 = (-(_local2) * ((_local4 * _local11) - (_local5 * _local10)));
this.n22 = (_local2 * ((_local3 * _local11) - (_local5 * _local9)));
this.n23 = (-(_local2) * ((_local3 * _local10) - (_local4 * _local9)));
this.n24 = (_local2 * (((_local3 * ((_local10 * _local14) - (_local11 * _local13))) - (_local4 * ((_local9 * _local14) - (_local11 * _local12)))) + (_local5 * ((_local9 * _local13) - (_local10 * _local12)))));
this.n31 = (_local2 * ((_local4 * _local8) - (_local5 * _local7)));
this.n32 = (-(_local2) * ((_local3 * _local8) - (_local5 * _local6)));
this.n33 = (_local2 * ((_local3 * _local7) - (_local4 * _local6)));
this.n34 = (-(_local2) * (((_local3 * ((_local7 * _local14) - (_local8 * _local13))) - (_local4 * ((_local6 * _local14) - (_local8 * _local12)))) + (_local5 * ((_local6 * _local13) - (_local7 * _local12)))));
};
}
public function calculateTranspose():void{
var _local1:Number = this.n11;
var _local2:Number = this.n21;
var _local3:Number = this.n31;
var _local4:Number = this.n41;
var _local5:Number = this.n12;
var _local6:Number = this.n22;
var _local7:Number = this.n32;
var _local8:Number = this.n42;
var _local9:Number = this.n13;
var _local10:Number = this.n23;
var _local11:Number = this.n33;
var _local12:Number = this.n43;
var _local13:Number = this.n14;
var _local14:Number = this.n24;
var _local15:Number = this.n34;
var _local16:Number = this.n44;
this.n11 = _local1;
this.n12 = _local2;
this.n13 = _local3;
this.n14 = _local4;
this.n21 = _local5;
this.n22 = _local6;
this.n23 = _local7;
this.n24 = _local8;
this.n31 = _local9;
this.n32 = _local10;
this.n33 = _local11;
this.n34 = _local12;
this.n41 = _local13;
this.n42 = _local14;
this.n43 = _local15;
this.n44 = _local16;
}
public function toString():String{
var _local1 = "";
_local1 = (_local1 + ((((((((int((n11 * 1000)) / 1000) + "\t\t") + (int((n12 * 1000)) / 1000)) + "\t\t") + (int((n13 * 1000)) / 1000)) + "\t\t") + (int((n14 * 1000)) / 1000)) + "\n"));
_local1 = (_local1 + ((((((((int((n21 * 1000)) / 1000) + "\t\t") + (int((n22 * 1000)) / 1000)) + "\t\t") + (int((n23 * 1000)) / 1000)) + "\t\t") + (int((n24 * 1000)) / 1000)) + "\n"));
_local1 = (_local1 + ((((((((int((n31 * 1000)) / 1000) + "\t\t") + (int((n32 * 1000)) / 1000)) + "\t\t") + (int((n33 * 1000)) / 1000)) + "\t\t") + (int((n34 * 1000)) / 1000)) + "\n"));
_local1 = (_local1 + ((((((((int((n41 * 1000)) / 1000) + "\t\t") + (int((n42 * 1000)) / 1000)) + "\t\t") + (int((n43 * 1000)) / 1000)) + "\t\t") + (int((n44 * 1000)) / 1000)) + "\n"));
return (_local1);
}
public static function rotationMatrixWithReference(_arg1:Number3D, _arg2:Number, _arg3:Number3D):Matrix3D{
var _local4:Matrix3D = Matrix3D.translationMatrix(_arg3.x, -(_arg3.y), _arg3.z);
Matrix3D.translationMatrix(_arg3.x, -(_arg3.y), _arg3.z).calculateMultiply(_local4, Matrix3D.rotationMatrix(_arg1.x, _arg1.y, _arg1.z, _arg2));
_local4.calculateMultiply(_local4, Matrix3D.translationMatrix(-(_arg3.x), _arg3.y, -(_arg3.z)));
return (_local4);
}
public static function multiplyVector(_arg1:Matrix3D, _arg2:Number3D):void{
var _local4:Number;
var _local5:Number;
var _local3:Number = _arg2.x;
_local4 = _arg2.y;
_local5 = _arg2.z;
_arg2.x = ((((_local3 * _arg1.n11) + (_local4 * _arg1.n12)) + (_local5 * _arg1.n13)) + _arg1.n14);
_arg2.y = ((((_local3 * _arg1.n21) + (_local4 * _arg1.n22)) + (_local5 * _arg1.n23)) + _arg1.n24);
_arg2.z = ((((_local3 * _arg1.n31) + (_local4 * _arg1.n32)) + (_local5 * _arg1.n33)) + _arg1.n34);
}
public static function multiplyVector4x4(_arg1:Matrix3D, _arg2:Number3D):void{
var _local3:Number;
var _local4:Number;
var _local6:Number;
_local3 = _arg2.x;
_local4 = _arg2.y;
var _local5:Number = _arg2.z;
_local6 = (1 / ((((_local3 * _arg1.n41) + (_local4 * _arg1.n42)) + (_local5 * _arg1.n43)) + _arg1.n44));
_arg2.x = ((((_local3 * _arg1.n11) + (_local4 * _arg1.n12)) + (_local5 * _arg1.n13)) + _arg1.n14);
_arg2.y = ((((_local3 * _arg1.n21) + (_local4 * _arg1.n22)) + (_local5 * _arg1.n23)) + _arg1.n24);
_arg2.z = ((((_local3 * _arg1.n31) + (_local4 * _arg1.n32)) + (_local5 * _arg1.n33)) + _arg1.n34);
_arg2.x = (_arg2.x * _local6);
_arg2.y = (_arg2.y * _local6);
_arg2.z = (_arg2.z * _local6);
}
public static function multiply3x3(_arg1:Matrix3D, _arg2:Matrix3D):Matrix3D{
var _local3:Matrix3D = new (Matrix3D);
_local3.calculateMultiply3x3(_arg1, _arg2);
return (_local3);
}
public static function normalizeQuaternion(_arg1:Object):Object{
var _local2:Number = magnitudeQuaternion(_arg1);
_arg1.x = (_arg1.x / _local2);
_arg1.y = (_arg1.y / _local2);
_arg1.z = (_arg1.z / _local2);
_arg1.w = (_arg1.w / _local2);
return (_arg1);
}
public static function multiplyVector3x3(_arg1:Matrix3D, _arg2:Number3D):void{
var _local3:Number = _arg2.x;
var _local4:Number = _arg2.y;
var _local5:Number = _arg2.z;
_arg2.x = (((_local3 * _arg1.n11) + (_local4 * _arg1.n12)) + (_local5 * _arg1.n13));
_arg2.y = (((_local3 * _arg1.n21) + (_local4 * _arg1.n22)) + (_local5 * _arg1.n23));
_arg2.z = (((_local3 * _arg1.n31) + (_local4 * _arg1.n32)) + (_local5 * _arg1.n33));
}
public static function axis2quaternion(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Object{
var _local5:Number = Math.sin((_arg4 / 2));
var _local6:Number = Math.cos((_arg4 / 2));
var _local7:Object = new Object();
_local7.x = (_arg1 * _local5);
_local7.y = (_arg2 * _local5);
_local7.z = (_arg3 * _local5);
_local7.w = _local6;
return (normalizeQuaternion(_local7));
}
public static function translationMatrix(_arg1:Number, _arg2:Number, _arg3:Number):Matrix3D{
var _local4:Matrix3D = IDENTITY;
_local4.n14 = _arg1;
_local4.n24 = _arg2;
_local4.n34 = _arg3;
return (_local4);
}
public static function magnitudeQuaternion(_arg1:Object):Number{
return (Math.sqrt(((((_arg1.w * _arg1.w) + (_arg1.x * _arg1.x)) + (_arg1.y * _arg1.y)) + (_arg1.z * _arg1.z))));
}
public static function rotationX(_arg1:Number):Matrix3D{
var _local2:Matrix3D = IDENTITY;
var _local3:Number = Math.cos(_arg1);
var _local4:Number = Math.sin(_arg1);
_local2.n22 = _local3;
_local2.n23 = -(_local4);
_local2.n32 = _local4;
_local2.n33 = _local3;
return (_local2);
}
public static function rotationY(_arg1:Number):Matrix3D{
var _local2:Matrix3D = IDENTITY;
var _local3:Number = Math.cos(_arg1);
var _local4:Number = Math.sin(_arg1);
_local2.n11 = _local3;
_local2.n13 = -(_local4);
_local2.n31 = _local4;
_local2.n33 = _local3;
return (_local2);
}
public static function rotationZ(_arg1:Number):Matrix3D{
var _local2:Matrix3D = IDENTITY;
var _local3:Number = Math.cos(_arg1);
var _local4:Number = Math.sin(_arg1);
_local2.n11 = _local3;
_local2.n12 = -(_local4);
_local2.n21 = _local4;
_local2.n22 = _local3;
return (_local2);
}
public static function clone(_arg1:Matrix3D):Matrix3D{
return (new Matrix3D([_arg1.n11, _arg1.n12, _arg1.n13, _arg1.n14, _arg1.n21, _arg1.n22, _arg1.n23, _arg1.n24, _arg1.n31, _arg1.n32, _arg1.n33, _arg1.n34]));
}
public static function rotationMatrix(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Matrix3D=null):Matrix3D{
var _local6:Matrix3D;
if (!_arg5){
_local6 = IDENTITY;
} else {
_local6 = _arg5;
};
var _local7:Number = Math.cos(_arg4);
var _local8:Number = Math.sin(_arg4);
var _local9:Number = (1 - _local7);
var _local10:Number = ((_arg1 * _arg2) * _local9);
var _local11:Number = ((_arg2 * _arg3) * _local9);
var _local12:Number = ((_arg1 * _arg3) * _local9);
var _local13:Number = (_local8 * _arg3);
var _local14:Number = (_local8 * _arg2);
var _local15:Number = (_local8 * _arg1);
_local6.n11 = (_local7 + ((_arg1 * _arg1) * _local9));
_local6.n12 = (-(_local13) + _local10);
_local6.n13 = (_local14 + _local12);
_local6.n14 = 0;
_local6.n21 = (_local13 + _local10);
_local6.n22 = (_local7 + ((_arg2 * _arg2) * _local9));
_local6.n23 = (-(_local15) + _local11);
_local6.n24 = 0;
_local6.n31 = (-(_local14) + _local12);
_local6.n32 = (_local15 + _local11);
_local6.n33 = (_local7 + ((_arg3 * _arg3) * _local9));
_local6.n34 = 0;
return (_local6);
}
public static function add(_arg1:Matrix3D, _arg2:Matrix3D):Matrix3D{
var _local3:Matrix3D = new (Matrix3D);
_local3.calculateAdd(_arg1, _arg2);
return (_local3);
}
public static function multiply(_arg1:Matrix3D, _arg2:Matrix3D):Matrix3D{
var _local3:Matrix3D = new (Matrix3D);
_local3.calculateMultiply(_arg1, _arg2);
return (_local3);
}
public static function euler2quaternion(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Quaternion=null):Quaternion{
var _local13:Quaternion;
var _local5:Number = Math.sin((_arg1 * 0.5));
var _local6:Number = Math.cos((_arg1 * 0.5));
var _local7:Number = Math.sin((_arg2 * 0.5));
var _local8:Number = Math.cos((_arg2 * 0.5));
var _local9:Number = Math.sin((_arg3 * 0.5));
var _local10:Number = Math.cos((_arg3 * 0.5));
var _local11:Number = (_local6 * _local8);
var _local12:Number = (_local5 * _local7);
if (!_arg4){
_local13 = new Quaternion();
} else {
_local13 = _arg4;
};
_local13.x = ((_local9 * _local11) - (_local10 * _local12));
_local13.y = (((_local10 * _local5) * _local8) + ((_local9 * _local6) * _local7));
_local13.z = (((_local10 * _local6) * _local7) - ((_local9 * _local5) * _local8));
_local13.w = ((_local10 * _local11) + (_local9 * _local12));
return (_local13);
}
public static function quaternion2matrix(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Matrix3D=null):Matrix3D{
var _local15:Matrix3D;
var _local6:Number = (_arg1 * _arg1);
var _local7:Number = (_arg1 * _arg2);
var _local8:Number = (_arg1 * _arg3);
var _local9:Number = (_arg1 * _arg4);
var _local10:Number = (_arg2 * _arg2);
var _local11:Number = (_arg2 * _arg3);
var _local12:Number = (_arg2 * _arg4);
var _local13:Number = (_arg3 * _arg3);
var _local14:Number = (_arg3 * _arg4);
if (!_arg5){
_local15 = IDENTITY;
} else {
_local15 = _arg5;
};
_local15.n11 = (1 - (2 * (_local10 + _local13)));
_local15.n12 = (2 * (_local7 - _local14));
_local15.n13 = (2 * (_local8 + _local12));
_local15.n21 = (2 * (_local7 + _local14));
_local15.n22 = (1 - (2 * (_local6 + _local13)));
_local15.n23 = (2 * (_local11 - _local9));
_local15.n31 = (2 * (_local8 - _local12));
_local15.n32 = (2 * (_local11 + _local9));
_local15.n33 = (1 - (2 * (_local6 + _local10)));
return (_local15);
}
public static function inverse(_arg1:Matrix3D):Matrix3D{
var _local2:Matrix3D = new (Matrix3D);
_local2.calculateInverse(_arg1);
return (_local2);
}
public static function euler2matrix(_arg1:Number3D):Matrix3D{
temp.reset();
var _local2:Matrix3D = temp;
_local2 = temp;
var _local3:Number = (_arg1.x * toRADIANS);
var _local4:Number = (_arg1.y * toRADIANS);
var _local5:Number = (_arg1.z * toRADIANS);
var _local6:Number = Math.cos(_local3);
var _local7:Number = Math.sin(_local3);
var _local8:Number = Math.cos(_local4);
var _local9:Number = Math.sin(_local4);
var _local10:Number = Math.cos(_local5);
var _local11:Number = Math.sin(_local5);
var _local12:Number = (_local6 * _local9);
var _local13:Number = (_local7 * _local9);
_local2.n11 = (_local8 * _local10);
_local2.n12 = (-(_local8) * _local11);
_local2.n13 = _local9;
_local2.n21 = ((_local13 * _local10) + (_local6 * _local11));
_local2.n22 = ((-(_local13) * _local11) + (_local6 * _local10));
_local2.n23 = (-(_local7) * _local8);
_local2.n31 = ((-(_local12) * _local10) + (_local7 * _local11));
_local2.n32 = ((_local12 * _local11) + (_local7 * _local10));
_local2.n33 = (_local6 * _local8);
return (_local2);
}
public static function scaleMatrix(_arg1:Number, _arg2:Number, _arg3:Number):Matrix3D{
var _local4:Matrix3D = IDENTITY;
_local4.n11 = _arg1;
_local4.n22 = _arg2;
_local4.n33 = _arg3;
return (_local4);
}
public static function rotateAxis(_arg1:Matrix3D, _arg2:Number3D):void{
var _local3:Number = _arg2.x;
var _local4:Number = _arg2.y;
var _local5:Number = _arg2.z;
_arg2.x = (((_local3 * _arg1.n11) + (_local4 * _arg1.n12)) + (_local5 * _arg1.n13));
_arg2.y = (((_local3 * _arg1.n21) + (_local4 * _arg1.n22)) + (_local5 * _arg1.n23));
_arg2.z = (((_local3 * _arg1.n31) + (_local4 * _arg1.n32)) + (_local5 * _arg1.n33));
_arg2.normalize();
}
public static function matrix2euler(_arg1:Matrix3D, _arg2:Number3D=null, _arg3:Number3D=null):Number3D{
_arg2 = ((_arg2) || (new Number3D()));
var _local4:Number = (((_arg3) && ((_arg3.x == 1)))) ? 1 : Math.sqrt((((_arg1.n11 * _arg1.n11) + (_arg1.n21 * _arg1.n21)) + (_arg1.n31 * _arg1.n31)));
var _local5:Number = (((_arg3) && ((_arg3.y == 1)))) ? 1 : Math.sqrt((((_arg1.n12 * _arg1.n12) + (_arg1.n22 * _arg1.n22)) + (_arg1.n32 * _arg1.n32)));
var _local6:Number = (((_arg3) && ((_arg3.z == 1)))) ? 1 : Math.sqrt((((_arg1.n13 * _arg1.n13) + (_arg1.n23 * _arg1.n23)) + (_arg1.n33 * _arg1.n33)));
var _local7:Number = (_arg1.n11 / _local4);
var _local8:Number = (_arg1.n21 / _local5);
var _local9:Number = (_arg1.n31 / _local6);
var _local10:Number = (_arg1.n32 / _local6);
var _local11:Number = (_arg1.n33 / _local6);
_local9 = ((_local9 > 1)) ? 1 : _local9;
_local9 = ((_local9 < -1)) ? -1 : _local9;
_arg2.y = Math.asin(-(_local9));
_arg2.z = Math.atan2(_local8, _local7);
_arg2.x = Math.atan2(_local10, _local11);
if (Papervision3D.useDEGREES){
_arg2.x = (_arg2.x * toDEGREES);
_arg2.y = (_arg2.y * toDEGREES);
_arg2.z = (_arg2.z * toDEGREES);
};
return (_arg2);
}
public static function multiplyQuaternion(_arg1:Object, _arg2:Object):Object{
var _local3:Number = _arg1.x;
var _local4:Number = _arg1.y;
var _local5:Number = _arg1.z;
var _local6:Number = _arg1.w;
var _local7:Number = _arg2.x;
var _local8:Number = _arg2.y;
var _local9:Number = _arg2.z;
var _local10:Number = _arg2.w;
var _local11:Object = new Object();
_local11.x = ((((_local6 * _local7) + (_local3 * _local10)) + (_local4 * _local9)) - (_local5 * _local8));
_local11.y = ((((_local6 * _local8) + (_local4 * _local10)) + (_local5 * _local7)) - (_local3 * _local9));
_local11.z = ((((_local6 * _local9) + (_local5 * _local10)) + (_local3 * _local8)) - (_local4 * _local7));
_local11.w = ((((_local6 * _local10) - (_local3 * _local7)) - (_local4 * _local8)) - (_local5 * _local9));
return (_local11);
}
public static function get IDENTITY():Matrix3D{
return (new Matrix3D([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]));
}
}
}//package org.papervision3d.core.math
Section 195
//Number2D (org.papervision3d.core.math.Number2D)
package org.papervision3d.core.math {
import org.papervision3d.*;
public class Number2D {
public var x:Number;
public var y:Number;
public static const DEGTORAD:Number = 0.0174532925199433;
public static const RADTODEG:Number = 57.2957795130823;
public function Number2D(_arg1:Number=0, _arg2:Number=0){
this.x = _arg1;
this.y = _arg2;
}
public function isModuloLessThan(_arg1:Number):Boolean{
return ((moduloSquared < (_arg1 * _arg1)));
}
public function reverse():void{
this.x = -(this.x);
this.y = -(this.y);
}
public function divideEq(_arg1:Number):void{
x = (x / _arg1);
y = (y / _arg1);
}
public function plusEq(_arg1:Number2D):void{
x = (x + _arg1.x);
y = (y + _arg1.y);
}
public function multiplyEq(_arg1:Number):void{
x = (x * _arg1);
y = (y * _arg1);
}
public function isModuloGreaterThan(_arg1:Number):Boolean{
return ((moduloSquared > (_arg1 * _arg1)));
}
public function toString():String{
var _local1:Number = (Math.round((this.x * 1000)) / 1000);
var _local2:Number = (Math.round((this.y * 1000)) / 1000);
return ((((("[" + _local1) + ", ") + _local2) + "]"));
}
public function reset(_arg1:Number=0, _arg2:Number=0):void{
this.x = _arg1;
this.y = _arg2;
}
public function get moduloSquared():Number{
return (((this.x * this.x) + (this.y * this.y)));
}
public function normalise():void{
var _local1:Number = this.modulo;
this.x = (this.x / _local1);
this.y = (this.y / _local1);
}
public function get modulo():Number{
return (Math.sqrt(((x * x) + (y * y))));
}
public function copyTo(_arg1:Number2D):void{
_arg1.x = this.x;
_arg1.y = this.y;
}
public function angle():Number{
if (Papervision3D.useDEGREES){
return ((RADTODEG * Math.atan2(y, x)));
};
return (Math.atan2(y, x));
}
public function rotate(_arg1:Number):void{
var _local4:Number2D;
if (Papervision3D.useDEGREES){
_arg1 = (_arg1 * DEGTORAD);
};
var _local2:Number = Math.cos(_arg1);
var _local3:Number = Math.sin(_arg1);
_local4 = clone();
this.x = ((_local4.x * _local2) - (_local4.y * _local3));
this.y = ((_local4.x * _local3) + (_local4.y * _local2));
}
public function minusEq(_arg1:Number2D):void{
x = (x - _arg1.x);
y = (y - _arg1.y);
}
public function clone():Number2D{
return (new Number2D(this.x, this.y));
}
public function isModuloEqualTo(_arg1:Number):Boolean{
return ((moduloSquared == (_arg1 * _arg1)));
}
public function copyFrom(_arg1:Number2D):void{
this.x = _arg1.x;
this.y = _arg1.y;
}
public static function multiplyScalar(_arg1:Number2D, _arg2:Number):Number2D{
return (new Number2D((_arg1.x * _arg2), (_arg1.y * _arg2)));
}
public static function add(_arg1:Number2D, _arg2:Number2D):Number2D{
return (new Number2D((_arg1.x = (_arg1.x + _arg2.x)), (_arg1.y + _arg2.y)));
}
public static function dot(_arg1:Number2D, _arg2:Number2D):Number{
return (((_arg1.x * _arg2.x) + (_arg1.y * _arg2.y)));
}
public static function subtract(_arg1:Number2D, _arg2:Number2D):Number2D{
return (new Number2D((_arg1.x - _arg2.x), (_arg1.y - _arg2.y)));
}
}
}//package org.papervision3d.core.math
Section 196
//Number3D (org.papervision3d.core.math.Number3D)
package org.papervision3d.core.math {
import org.papervision3d.*;
public class Number3D {
public var x:Number;
public var y:Number;
public var z:Number;
public static var toDEGREES:Number = 57.2957795130823;
private static var temp:Number3D = Number3D.ZERO;
public static var toRADIANS:Number = 0.0174532925199433;
public function Number3D(_arg1:Number=0, _arg2:Number=0, _arg3:Number=0){
this.x = _arg1;
this.y = _arg2;
this.z = _arg3;
}
public function isModuloLessThan(_arg1:Number):Boolean{
return ((moduloSquared < (_arg1 * _arg1)));
}
public function rotateX(_arg1:Number):void{
if (Papervision3D.useDEGREES){
_arg1 = (_arg1 * toRADIANS);
};
var _local2:Number = Math.cos(_arg1);
var _local3:Number = Math.sin(_arg1);
temp.copyFrom(this);
this.y = ((temp.y * _local2) - (temp.z * _local3));
this.z = ((temp.y * _local3) + (temp.z * _local2));
}
public function rotateY(_arg1:Number):void{
if (Papervision3D.useDEGREES){
_arg1 = (_arg1 * toRADIANS);
};
var _local2:Number = Math.cos(_arg1);
var _local3:Number = Math.sin(_arg1);
temp.copyFrom(this);
this.x = ((temp.x * _local2) + (temp.z * _local3));
this.z = ((temp.x * -(_local3)) + (temp.z * _local2));
}
public function plusEq(_arg1:Number3D):void{
x = (x + _arg1.x);
y = (y + _arg1.y);
z = (z + _arg1.z);
}
public function multiplyEq(_arg1:Number):void{
x = (x * _arg1);
y = (y * _arg1);
z = (z * _arg1);
}
public function toString():String{
return (((((("x:" + (Math.round((x * 100)) / 100)) + " y:") + (Math.round((y * 100)) / 100)) + " z:") + (Math.round((z * 100)) / 100)));
}
public function normalize():void{
var _local1:Number = Math.sqrt((((this.x * this.x) + (this.y * this.y)) + (this.z * this.z)));
if (((!((_local1 == 0))) && (!((_local1 == 1))))){
_local1 = (1 / _local1);
this.x = (this.x * _local1);
this.y = (this.y * _local1);
this.z = (this.z * _local1);
};
}
public function rotateZ(_arg1:Number):void{
if (Papervision3D.useDEGREES){
_arg1 = (_arg1 * toRADIANS);
};
var _local2:Number = Math.cos(_arg1);
var _local3:Number = Math.sin(_arg1);
temp.copyFrom(this);
this.x = ((temp.x * _local2) - (temp.y * _local3));
this.y = ((temp.x * _local3) + (temp.y * _local2));
}
public function reset(_arg1:Number=0, _arg2:Number=0, _arg3:Number=0):void{
x = _arg1;
y = _arg2;
z = _arg3;
}
public function get moduloSquared():Number{
return ((((this.x * this.x) + (this.y * this.y)) + (this.z * this.z)));
}
public function get modulo():Number{
return (Math.sqrt((((this.x * this.x) + (this.y * this.y)) + (this.z * this.z))));
}
public function copyTo(_arg1:Number3D):void{
_arg1.x = x;
_arg1.y = y;
_arg1.z = z;
}
public function isModuloGreaterThan(_arg1:Number):Boolean{
return ((moduloSquared > (_arg1 * _arg1)));
}
public function minusEq(_arg1:Number3D):void{
x = (x - _arg1.x);
y = (y - _arg1.y);
z = (z - _arg1.z);
}
public function clone():Number3D{
return (new Number3D(this.x, this.y, this.z));
}
public function isModuloEqualTo(_arg1:Number):Boolean{
return ((moduloSquared == (_arg1 * _arg1)));
}
public function copyFrom(_arg1:Number3D):void{
x = _arg1.x;
y = _arg1.y;
z = _arg1.z;
}
public static function sub(_arg1:Number3D, _arg2:Number3D):Number3D{
return (new Number3D((_arg1.x - _arg2.x), (_arg1.y - _arg2.y), (_arg1.z - _arg2.z)));
}
public static function add(_arg1:Number3D, _arg2:Number3D):Number3D{
return (new Number3D((_arg1.x + _arg2.x), (_arg1.y + _arg2.y), (_arg1.z + _arg2.z)));
}
public static function cross(_arg1:Number3D, _arg2:Number3D, _arg3:Number3D=null):Number3D{
if (!_arg3){
_arg3 = ZERO;
};
_arg3.reset(((_arg2.y * _arg1.z) - (_arg2.z * _arg1.y)), ((_arg2.z * _arg1.x) - (_arg2.x * _arg1.z)), ((_arg2.x * _arg1.y) - (_arg2.y * _arg1.x)));
return (_arg3);
}
public static function dot(_arg1:Number3D, _arg2:Number3D):Number{
return ((((_arg1.x * _arg2.x) + (_arg1.y * _arg2.y)) + (_arg2.z * _arg1.z)));
}
public static function get ZERO():Number3D{
return (new Number3D(0, 0, 0));
}
}
}//package org.papervision3d.core.math
Section 197
//NumberUV (org.papervision3d.core.math.NumberUV)
package org.papervision3d.core.math {
public class NumberUV {
public var u:Number;
public var v:Number;
public function NumberUV(_arg1:Number=0, _arg2:Number=0){
this.u = _arg1;
this.v = _arg2;
}
public function toString():String{
return (((("u:" + u) + " v:") + v));
}
public function clone():NumberUV{
return (new NumberUV(this.u, this.v));
}
public static function get ZERO():NumberUV{
return (new NumberUV(0, 0));
}
public static function median(_arg1:NumberUV, _arg2:NumberUV):NumberUV{
if (_arg1 == null){
return (null);
};
if (_arg2 == null){
return (null);
};
return (new NumberUV(((_arg1.u + _arg2.u) / 2), ((_arg1.v + _arg2.v) / 2)));
}
public static function weighted(_arg1:NumberUV, _arg2:NumberUV, _arg3:Number, _arg4:Number):NumberUV{
if (_arg1 == null){
return (null);
};
if (_arg2 == null){
return (null);
};
var _local5:Number = (_arg3 + _arg4);
var _local6:Number = (_arg3 / _local5);
var _local7:Number = (_arg4 / _local5);
return (new NumberUV(((_arg1.u * _local6) + (_arg2.u * _local7)), ((_arg1.v * _local6) + (_arg2.v * _local7))));
}
}
}//package org.papervision3d.core.math
Section 198
//Quaternion (org.papervision3d.core.math.Quaternion)
package org.papervision3d.core.math {
public class Quaternion {
private var _matrix:Matrix3D;
public var w:Number;
public var x:Number;
public var y:Number;
public var z:Number;
public static const EPSILON:Number = 1E-6;
public static const DEGTORAD:Number = 0.0174532925199433;
public static const RADTODEG:Number = 57.2957795130823;
public function Quaternion(_arg1:Number=0, _arg2:Number=0, _arg3:Number=0, _arg4:Number=1){
this.x = _arg1;
this.y = _arg2;
this.z = _arg3;
this.w = _arg4;
_matrix = Matrix3D.IDENTITY;
}
public function get matrix():Matrix3D{
var _local1:Number = (x * x);
var _local2:Number = (x * y);
var _local3:Number = (x * z);
var _local4:Number = (x * w);
var _local5:Number = (y * y);
var _local6:Number = (y * z);
var _local7:Number = (y * w);
var _local8:Number = (z * z);
var _local9:Number = (z * w);
_matrix.n11 = (1 - (2 * (_local5 + _local8)));
_matrix.n12 = (2 * (_local2 - _local9));
_matrix.n13 = (2 * (_local3 + _local7));
_matrix.n21 = (2 * (_local2 + _local9));
_matrix.n22 = (1 - (2 * (_local1 + _local8)));
_matrix.n23 = (2 * (_local6 - _local4));
_matrix.n31 = (2 * (_local3 - _local7));
_matrix.n32 = (2 * (_local6 + _local4));
_matrix.n33 = (1 - (2 * (_local1 + _local5)));
return (_matrix);
}
public function setFromEuler(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Boolean=false):void{
if (_arg4){
_arg1 = (_arg1 * DEGTORAD);
_arg2 = (_arg2 * DEGTORAD);
_arg3 = (_arg3 * DEGTORAD);
};
var _local5:Number = Math.sin((_arg1 * 0.5));
var _local6:Number = Math.cos((_arg1 * 0.5));
var _local7:Number = Math.sin((_arg2 * 0.5));
var _local8:Number = Math.cos((_arg2 * 0.5));
var _local9:Number = Math.sin((_arg3 * 0.5));
var _local10:Number = Math.cos((_arg3 * 0.5));
var _local11:Number = (_local6 * _local8);
var _local12:Number = (_local5 * _local7);
this.x = ((_local9 * _local11) - (_local10 * _local12));
this.y = (((_local10 * _local5) * _local8) + ((_local9 * _local6) * _local7));
this.z = (((_local10 * _local6) * _local7) - ((_local9 * _local5) * _local8));
this.w = ((_local10 * _local11) + (_local9 * _local12));
}
public function setFromAxisAngle(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):void{
var _local5:Number = Math.sin((_arg4 / 2));
var _local6:Number = Math.cos((_arg4 / 2));
this.x = (_arg1 * _local5);
this.y = (_arg2 * _local5);
this.z = (_arg3 * _local5);
this.w = _local6;
this.normalize();
}
public function calculateMultiply(_arg1:Quaternion, _arg2:Quaternion):void{
this.x = ((((_arg1.w * _arg2.x) + (_arg1.x * _arg2.w)) + (_arg1.y * _arg2.z)) - (_arg1.z * _arg2.y));
this.y = ((((_arg1.w * _arg2.y) - (_arg1.x * _arg2.z)) + (_arg1.y * _arg2.w)) + (_arg1.z * _arg2.x));
this.z = ((((_arg1.w * _arg2.z) + (_arg1.x * _arg2.y)) - (_arg1.y * _arg2.x)) + (_arg1.z * _arg2.w));
this.w = ((((_arg1.w * _arg2.w) - (_arg1.x * _arg2.x)) - (_arg1.y * _arg2.y)) - (_arg1.z * _arg2.z));
}
public function toString():String{
return (((((((("Quaternion: x:" + this.x) + " y:") + this.y) + " z:") + this.z) + " w:") + this.w));
}
public function normalize():void{
var _local2:Number;
var _local1:Number = this.modulo;
if (Math.abs(_local1) < EPSILON){
x = (y = (z = 0));
w = 1;
} else {
_local2 = (1 / _local1);
x = (x * _local2);
y = (y * _local2);
z = (z * _local2);
w = (w * _local2);
};
}
public function toEuler():Number3D{
var _local1:Number3D = new Number3D();
var _local2:Quaternion = this;
var _local3:Number = ((_local2.x * _local2.y) + (_local2.z * _local2.w));
if (_local3 > 0.499){
_local1.x = (2 * Math.atan2(_local2.x, _local2.w));
_local1.y = (Math.PI / 2);
_local1.z = 0;
return (_local1);
};
if (_local3 < -0.499){
_local1.x = (-2 * Math.atan2(_local2.x, _local2.w));
_local1.y = (-(Math.PI) / 2);
_local1.z = 0;
return (_local1);
};
var _local4:Number = (_local2.x * _local2.x);
var _local5:Number = (_local2.y * _local2.y);
var _local6:Number = (_local2.z * _local2.z);
_local1.x = Math.atan2((((2 * _local2.y) * _local2.w) - ((2 * _local2.x) * _local2.z)), ((1 - (2 * _local5)) - (2 * _local6)));
_local1.y = Math.asin((2 * _local3));
_local1.z = Math.atan2((((2 * _local2.x) * _local2.w) - ((2 * _local2.y) * _local2.z)), ((1 - (2 * _local4)) - (2 * _local6)));
return (_local1);
}
public function get modulo():Number{
return (Math.sqrt(((((x * x) + (y * y)) + (z * z)) + (w * w))));
}
public function clone():Quaternion{
return (new Quaternion(this.x, this.y, this.z, this.w));
}
public function mult(_arg1:Quaternion):void{
var _local2:Number = this.w;
var _local3:Number = this.x;
var _local4:Number = this.y;
var _local5:Number = this.z;
x = ((((_local2 * _arg1.x) + (_local3 * _arg1.w)) + (_local4 * _arg1.z)) - (_local5 * _arg1.y));
y = ((((_local2 * _arg1.y) - (_local3 * _arg1.z)) + (_local4 * _arg1.w)) + (_local5 * _arg1.x));
z = ((((_local2 * _arg1.z) + (_local3 * _arg1.y)) - (_local4 * _arg1.x)) + (_local5 * _arg1.w));
w = ((((_local2 * _arg1.w) - (_local3 * _arg1.x)) - (_local4 * _arg1.y)) - (_local5 * _arg1.z));
}
public static function sub(_arg1:Quaternion, _arg2:Quaternion):Quaternion{
return (new Quaternion((_arg1.x - _arg2.x), (_arg1.y - _arg2.y), (_arg1.z - _arg2.z), (_arg1.w - _arg2.w)));
}
public static function add(_arg1:Quaternion, _arg2:Quaternion):Quaternion{
return (new Quaternion((_arg1.x + _arg2.x), (_arg1.y + _arg2.y), (_arg1.z + _arg2.z), (_arg1.w + _arg2.w)));
}
public static function createFromEuler(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Boolean=false):Quaternion{
if (_arg4){
_arg1 = (_arg1 * DEGTORAD);
_arg2 = (_arg2 * DEGTORAD);
_arg3 = (_arg3 * DEGTORAD);
};
var _local5:Number = Math.sin((_arg1 * 0.5));
var _local6:Number = Math.cos((_arg1 * 0.5));
var _local7:Number = Math.sin((_arg2 * 0.5));
var _local8:Number = Math.cos((_arg2 * 0.5));
var _local9:Number = Math.sin((_arg3 * 0.5));
var _local10:Number = Math.cos((_arg3 * 0.5));
var _local11:Number = (_local6 * _local8);
var _local12:Number = (_local5 * _local7);
var _local13:Quaternion = new (Quaternion);
_local13.x = ((_local9 * _local11) - (_local10 * _local12));
_local13.y = (((_local10 * _local5) * _local8) + ((_local9 * _local6) * _local7));
_local13.z = (((_local10 * _local6) * _local7) - ((_local9 * _local5) * _local8));
_local13.w = ((_local10 * _local11) + (_local9 * _local12));
return (_local13);
}
public static function createFromMatrix(_arg1:Matrix3D):Quaternion{
var _local3:Number;
var _local5:int;
var _local6:int;
var _local7:int;
var _local9:Array;
var _local10:Array;
var _local2:Quaternion = new (Quaternion);
var _local4:Array = new Array(4);
var _local8:Number = ((_arg1.n11 + _arg1.n22) + _arg1.n33);
if (_local8 > 0){
_local3 = Math.sqrt((_local8 + 1));
_local2.w = (_local3 / 2);
_local3 = (0.5 / _local3);
_local2.x = ((_arg1.n32 - _arg1.n23) * _local3);
_local2.y = ((_arg1.n13 - _arg1.n31) * _local3);
_local2.z = ((_arg1.n21 - _arg1.n12) * _local3);
} else {
_local9 = [1, 2, 0];
_local10 = [[_arg1.n11, _arg1.n12, _arg1.n13, _arg1.n14], [_arg1.n21, _arg1.n22, _arg1.n23, _arg1.n24], [_arg1.n31, _arg1.n32, _arg1.n33, _arg1.n34]];
_local5 = 0;
if (_local10[1][1] > _local10[0][0]){
_local5 = 1;
};
if (_local10[2][2] > _local10[_local5][_local5]){
_local5 = 2;
};
_local6 = _local9[_local5];
_local7 = _local9[_local6];
_local3 = Math.sqrt(((_local10[_local5][_local5] - (_local10[_local6][_local6] + _local10[_local7][_local7])) + 1));
_local4[_local5] = (_local3 * 0.5);
if (_local3 != 0){
_local3 = (0.5 / _local3);
};
_local4[3] = ((_local10[_local7][_local6] - _local10[_local6][_local7]) * _local3);
_local4[_local6] = ((_local10[_local6][_local5] + _local10[_local5][_local6]) * _local3);
_local4[_local7] = ((_local10[_local7][_local5] + _local10[_local5][_local7]) * _local3);
_local2.x = _local4[0];
_local2.y = _local4[1];
_local2.z = _local4[2];
_local2.w = _local4[3];
};
return (_local2);
}
public static function dot(_arg1:Quaternion, _arg2:Quaternion):Number{
return (((((_arg1.x * _arg2.x) + (_arg1.y * _arg2.y)) + (_arg1.z * _arg2.z)) + (_arg1.w * _arg2.w)));
}
public static function multiply(_arg1:Quaternion, _arg2:Quaternion):Quaternion{
var _local3:Quaternion = new (Quaternion);
_local3.x = ((((_arg1.w * _arg2.x) + (_arg1.x * _arg2.w)) + (_arg1.y * _arg2.z)) - (_arg1.z * _arg2.y));
_local3.y = ((((_arg1.w * _arg2.y) - (_arg1.x * _arg2.z)) + (_arg1.y * _arg2.w)) + (_arg1.z * _arg2.x));
_local3.z = ((((_arg1.w * _arg2.z) + (_arg1.x * _arg2.y)) - (_arg1.y * _arg2.x)) + (_arg1.z * _arg2.w));
_local3.w = ((((_arg1.w * _arg2.w) - (_arg1.x * _arg2.x)) - (_arg1.y * _arg2.y)) - (_arg1.z * _arg2.z));
return (_local3);
}
public static function createFromAxisAngle(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Quaternion{
var _local5:Quaternion = new (Quaternion);
_local5.setFromAxisAngle(_arg1, _arg2, _arg3, _arg4);
return (_local5);
}
public static function slerp(_arg1:Quaternion, _arg2:Quaternion, _arg3:Number):Quaternion{
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local4:Number = ((((_arg1.w * _arg2.w) + (_arg1.x * _arg2.x)) + (_arg1.y * _arg2.y)) + (_arg1.z * _arg2.z));
if (_local4 < 0){
_arg1.x = (_arg1.x * -1);
_arg1.y = (_arg1.y * -1);
_arg1.z = (_arg1.z * -1);
_arg1.w = (_arg1.w * -1);
_local4 = (_local4 * -1);
};
if ((_local4 + 1) > EPSILON){
if ((1 - _local4) >= EPSILON){
_local7 = Math.acos(_local4);
_local8 = (1 / Math.sin(_local7));
_local5 = (Math.sin((_local7 * (1 - _arg3))) * _local8);
_local6 = (Math.sin((_local7 * _arg3)) * _local8);
} else {
_local5 = (1 - _arg3);
_local6 = _arg3;
};
} else {
_arg2.y = -(_arg1.y);
_arg2.x = _arg1.x;
_arg2.w = -(_arg1.w);
_arg2.z = _arg1.z;
_local5 = Math.sin((Math.PI * (0.5 - _arg3)));
_local6 = Math.sin((Math.PI * _arg3));
};
return (new Quaternion(((_local5 * _arg1.x) + (_local6 * _arg2.x)), ((_local5 * _arg1.y) + (_local6 * _arg2.y)), ((_local5 * _arg1.z) + (_local6 * _arg2.z)), ((_local5 * _arg1.w) + (_local6 * _arg2.w))));
}
public static function createFromOrthoMatrix(_arg1:Matrix3D):Quaternion{
var _local2:Quaternion = new (Quaternion);
_local2.w = (Math.sqrt(Math.max(0, (((1 + _arg1.n11) + _arg1.n22) + _arg1.n33))) / 2);
_local2.x = (Math.sqrt(Math.max(0, (((1 + _arg1.n11) - _arg1.n22) - _arg1.n33))) / 2);
_local2.y = (Math.sqrt(Math.max(0, (((1 - _arg1.n11) + _arg1.n22) - _arg1.n33))) / 2);
_local2.z = (Math.sqrt(Math.max(0, (((1 - _arg1.n11) - _arg1.n22) + _arg1.n33))) / 2);
_local2.x = (((_arg1.n32 - _arg1.n23) < 0)) ? ((_local2.x < 0)) ? _local2.x : -(_local2.x) : ((_local2.x < 0)) ? -(_local2.x) : _local2.x;
_local2.y = (((_arg1.n13 - _arg1.n31) < 0)) ? ((_local2.y < 0)) ? _local2.y : -(_local2.y) : ((_local2.y < 0)) ? -(_local2.y) : _local2.y;
_local2.z = (((_arg1.n21 - _arg1.n12) < 0)) ? ((_local2.z < 0)) ? _local2.z : -(_local2.z) : ((_local2.z < 0)) ? -(_local2.z) : _local2.z;
return (_local2);
}
public static function conjugate(_arg1:Quaternion):Quaternion{
var _local2:Quaternion = new (Quaternion);
_local2.x = -(_arg1.x);
_local2.y = -(_arg1.y);
_local2.z = -(_arg1.z);
_local2.w = _arg1.w;
return (_local2);
}
public static function slerpOld(_arg1:Quaternion, _arg2:Quaternion, _arg3:Number):Quaternion{
var _local4:Quaternion = new (Quaternion);
var _local5:Number = ((((_arg1.w * _arg2.w) + (_arg1.x * _arg2.x)) + (_arg1.y * _arg2.y)) + (_arg1.z * _arg2.z));
if (Math.abs(_local5) >= 1){
_local4.w = _arg1.w;
_local4.x = _arg1.x;
_local4.y = _arg1.y;
_local4.z = _arg1.z;
return (_local4);
};
var _local6:Number = Math.acos(_local5);
var _local7:Number = Math.sqrt((1 - (_local5 * _local5)));
if (Math.abs(_local7) < 0.001){
_local4.w = ((_arg1.w * 0.5) + (_arg2.w * 0.5));
_local4.x = ((_arg1.x * 0.5) + (_arg2.x * 0.5));
_local4.y = ((_arg1.y * 0.5) + (_arg2.y * 0.5));
_local4.z = ((_arg1.z * 0.5) + (_arg2.z * 0.5));
return (_local4);
};
var _local8:Number = (Math.sin(((1 - _arg3) * _local6)) / _local7);
var _local9:Number = (Math.sin((_arg3 * _local6)) / _local7);
_local4.w = ((_arg1.w * _local8) + (_arg2.w * _local9));
_local4.x = ((_arg1.x * _local8) + (_arg2.x * _local9));
_local4.y = ((_arg1.y * _local8) + (_arg2.y * _local9));
_local4.z = ((_arg1.z * _local8) + (_arg2.z * _local9));
return (_local4);
}
}
}//package org.papervision3d.core.math
Section 199
//pv3dview (org.papervision3d.core.ns.pv3dview)
package org.papervision3d.core.ns {
public namespace pv3dview;
}//package org.papervision3d.core.ns
Section 200
//CameraObject3D (org.papervision3d.core.proto.CameraObject3D)
package org.papervision3d.core.proto {
import flash.geom.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.culling.*;
import org.papervision3d.core.math.*;
import org.papervision3d.core.log.*;
import org.papervision3d.*;
public class CameraObject3D extends DisplayObject3D {
protected var _orthoScale:Number;// = 1
public var culler:IObjectCuller;
public var sort:Boolean;
public var viewport:Rectangle;
protected var _target:DisplayObject3D;
protected var _orthoScaleMatrix:Matrix3D;
public var eye:Matrix3D;
protected var _ortho:Boolean;
protected var _useCulling:Boolean;
public var zoom:Number;
public var yUP:Boolean;
public var focus:Number;
protected var _useProjectionMatrix:Boolean;
protected var _far:Number;
public static var DEFAULT_VIEWPORT:Rectangle = new Rectangle(0, 0, 550, 400);
public static var DEFAULT_POS:Number3D = new Number3D(0, 0, -1000);
public static var DEFAULT_UP:Number3D = new Number3D(0, 1, 0);
private static var _flipY:Matrix3D = Matrix3D.scaleMatrix(1, -1, 1);
public function CameraObject3D(_arg1:Number=500, _arg2:Number=3){
this.x = DEFAULT_POS.x;
this.y = DEFAULT_POS.y;
this.z = DEFAULT_POS.z;
this.zoom = _arg2;
this.focus = _arg1;
this.eye = Matrix3D.IDENTITY;
this.viewport = DEFAULT_VIEWPORT;
this.sort = true;
_ortho = false;
_orthoScaleMatrix = Matrix3D.scaleMatrix(1, 1, 1);
if (Papervision3D.useRIGHTHANDED){
DEFAULT_UP.y = -1;
this.yUP = false;
this.lookAt(DisplayObject3D.ZERO);
} else {
this.yUP = true;
};
}
public function get target():DisplayObject3D{
return (_target);
}
public function get useProjectionMatrix():Boolean{
return (_useProjectionMatrix);
}
public function set fov(_arg1:Number):void{
if (((!(viewport)) || (viewport.isEmpty()))){
PaperLogger.warning("CameraObject3D#viewport not set, can't set fov!");
return;
};
var _local2:Number = 0;
var _local3:Number = 0;
var _local4:Number = 0;
if (_target){
_local2 = _target.world.n14;
_local3 = _target.world.n24;
_local4 = _target.world.n34;
};
var _local5:Number = (viewport.height / 2);
var _local6:Number = ((_arg1 / 2) * (Math.PI / 180));
this.focus = ((_local5 / Math.tan(_local6)) / this.zoom);
}
public function pan(_arg1:Number):void{
}
public function get far():Number{
return (_far);
}
public function set target(_arg1:DisplayObject3D):void{
_target = _arg1;
}
public function projectFaces(_arg1:Array, _arg2:DisplayObject3D, _arg3:RenderSessionData):Number{
return (0);
}
public function get useCulling():Boolean{
return (_useCulling);
}
public function set far(_arg1:Number):void{
if (_arg1 > this.focus){
_far = _arg1;
};
}
public function get near():Number{
return (this.focus);
}
public function transformView(_arg1:Matrix3D=null):void{
if (this.yUP){
eye.calculateMultiply(((_arg1) || (this.transform)), _flipY);
eye.invert();
} else {
eye.calculateInverse(((_arg1) || (this.transform)));
};
}
public function set useProjectionMatrix(_arg1:Boolean):void{
_useProjectionMatrix = _arg1;
}
public function tilt(_arg1:Number):void{
}
override public function lookAt(_arg1:DisplayObject3D, _arg2:Number3D=null):void{
if (this.yUP){
super.lookAt(_arg1, _arg2);
} else {
super.lookAt(_arg1, ((_arg2) || (DEFAULT_UP)));
};
}
public function get ortho():Boolean{
return (_ortho);
}
public function orbit(_arg1:Number, _arg2:Number, _arg3:Boolean=true, _arg4:DisplayObject3D=null):void{
}
public function get fov():Number{
if (((!(viewport)) || (viewport.isEmpty()))){
PaperLogger.warning("CameraObject3D#viewport not set, can't calculate fov!");
return (NaN);
};
var _local1:Number = 0;
var _local2:Number = 0;
var _local3:Number = 0;
if (_target){
_local1 = _target.world.n14;
_local2 = _target.world.n24;
_local3 = _target.world.n34;
};
var _local4:Number = (this.x - _local1);
var _local5:Number = (this.y - _local2);
var _local6:Number = (this.z - _local3);
var _local7:Number = this.focus;
var _local8:Number = this.zoom;
var _local9:Number = (Math.sqrt((((_local4 * _local4) + (_local5 * _local5)) + (_local6 * _local6))) + _local7);
var _local10:Number = (viewport.height / 2);
var _local11:Number = (180 / Math.PI);
return (((Math.atan(((((_local9 / _local7) / _local8) * _local10) / _local9)) * _local11) * 2));
}
public function set near(_arg1:Number):void{
if (_arg1 > 0){
this.focus = _arg1;
};
}
public function set useCulling(_arg1:Boolean):void{
_useCulling = _arg1;
}
public function set orthoScale(_arg1:Number):void{
_orthoScale = ((_arg1 > 0)) ? _arg1 : 0.0001;
_orthoScaleMatrix.n11 = _orthoScale;
_orthoScaleMatrix.n22 = _orthoScale;
_orthoScaleMatrix.n33 = _orthoScale;
}
public function unproject(_arg1:Number, _arg2:Number):Number3D{
var _local3:Number = ((focus * zoom) / focus);
var _local4:Number3D = new Number3D((_arg1 / _local3), (-(_arg2) / _local3), focus);
Matrix3D.multiplyVector3x3(transform, _local4);
return (_local4);
}
public function set ortho(_arg1:Boolean):void{
_ortho = _arg1;
}
public function projectVertices(_arg1:Array, _arg2:DisplayObject3D, _arg3:RenderSessionData):Number{
return (0);
}
public function get orthoScale():Number{
return (_orthoScale);
}
}
}//package org.papervision3d.core.proto
Section 201
//DisplayObjectContainer3D (org.papervision3d.core.proto.DisplayObjectContainer3D)
package org.papervision3d.core.proto {
import flash.events.*;
import org.papervision3d.objects.*;
import flash.utils.*;
import org.papervision3d.core.log.*;
public class DisplayObjectContainer3D extends EventDispatcher {
protected var _childrenByName:Object;
public var root:DisplayObjectContainer3D;
private var _childrenTotal:int;
protected var _children:Dictionary;
public function DisplayObjectContainer3D():void{
this._children = new Dictionary(false);
this._childrenByName = new Dictionary(true);
this._childrenTotal = 0;
}
private function findChildByName(_arg1:String, _arg2:DisplayObject3D=null):DisplayObject3D{
var _local3:DisplayObject3D;
var _local4:DisplayObject3D;
_arg2 = ((_arg2) || (DisplayObject3D(this)));
if (!_arg2){
return (null);
};
if (_arg2.name == _arg1){
return (_arg2);
};
for each (_local3 in _arg2.children) {
_local4 = findChildByName(_arg1, _local3);
if (_local4){
return (_local4);
};
};
return (null);
}
public function getChildByName(_arg1:String, _arg2:Boolean=false):DisplayObject3D{
if (_arg2){
return (findChildByName(_arg1));
};
return (this._childrenByName[_arg1]);
}
override public function toString():String{
return (childrenList());
}
public function addChildren(_arg1:DisplayObject3D):DisplayObjectContainer3D{
var _local2:DisplayObject3D;
for each (_local2 in _arg1.children) {
_arg1.removeChild(_local2);
this.addChild(_local2);
};
return (this);
}
public function get numChildren():int{
return (this._childrenTotal);
}
public function removeChild(_arg1:DisplayObject3D):DisplayObject3D{
if (((_arg1) && (_children[_arg1]))){
delete _childrenByName[this._children[_arg1]];
delete _children[_arg1];
_arg1.parent = null;
_arg1.root = null;
_childrenTotal--;
return (_arg1);
};
return (null);
}
public function removeChildByName(_arg1:String):DisplayObject3D{
return (removeChild(getChildByName(_arg1)));
}
public function addChild(_arg1:DisplayObject3D, _arg2:String=null):DisplayObject3D{
if (_arg1.parent){
PaperLogger.error("DisplayObjectContainer.addChild : DisplayObject3D already has a parent, ie is already added to scene.");
};
_arg2 = ((((_arg2) || (_arg1.name))) || (String(_arg1.id)));
this._children[_arg1] = _arg2;
this._childrenByName[_arg2] = _arg1;
this._childrenTotal++;
_arg1.parent = this;
_arg1.root = this.root;
return (_arg1);
}
public function childrenList():String{
var _local2:String;
var _local1 = "";
for (_local2 in this._children) {
_local1 = (_local1 + (_local2 + "\n"));
};
return (_local1);
}
public function get children():Object{
return (this._childrenByName);
}
}
}//package org.papervision3d.core.proto
Section 202
//GeometryObject3D (org.papervision3d.core.proto.GeometryObject3D)
package org.papervision3d.core.proto {
import flash.events.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.math.*;
import flash.utils.*;
public class GeometryObject3D extends EventDispatcher {
protected var _boundingSphereDirty:Boolean;// = true
public var dirty:Boolean;
protected var _aabbDirty:Boolean;// = true
public var _ready:Boolean;// = false
protected var _boundingSphere:BoundingSphere;
public var faces:Array;
private var _numInstances:uint;// = 0
public var vertices:Array;
protected var _aabb:AxisAlignedBoundingBox;
public function GeometryObject3D():void{
dirty = true;
}
public function transformVertices(_arg1:Matrix3D):void{
var _local15:Vertex3D;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:Number;
var _local20:Number;
var _local21:Number;
var _local2:Number = _arg1.n11;
var _local3:Number = _arg1.n12;
var _local4:Number = _arg1.n13;
var _local5:Number = _arg1.n21;
var _local6:Number = _arg1.n22;
var _local7:Number = _arg1.n23;
var _local8:Number = _arg1.n31;
var _local9:Number = _arg1.n32;
var _local10:Number = _arg1.n33;
var _local11:Number = _arg1.n14;
var _local12:Number = _arg1.n24;
var _local13:Number = _arg1.n34;
var _local14:int = vertices.length;
while ((_local15 = vertices[--_local14])) {
_local16 = _local15.x;
_local17 = _local15.y;
_local18 = _local15.z;
_local19 = ((((_local16 * _local2) + (_local17 * _local3)) + (_local18 * _local4)) + _local11);
_local20 = ((((_local16 * _local5) + (_local17 * _local6)) + (_local18 * _local7)) + _local12);
_local21 = ((((_local16 * _local8) + (_local17 * _local9)) + (_local18 * _local10)) + _local13);
_local15.x = _local19;
_local15.y = _local20;
_local15.z = _local21;
};
}
public function set ready(_arg1:Boolean):void{
if (_arg1){
createVertexNormals();
this.dirty = false;
};
_ready = _arg1;
}
public function flipFaces():void{
var _local1:Triangle3D;
var _local2:Vertex3D;
for each (_local1 in this.faces) {
_local2 = _local1.v0;
_local1.v0 = _local1.v2;
_local1.v2 = _local2;
_local1.uv = [_local1.uv2, _local1.uv1, _local1.uv0];
_local1.createNormal();
};
this.ready = true;
}
private function createVertexNormals():void{
var _local2:Triangle3D;
var _local3:Vertex3D;
var _local1:Dictionary = new Dictionary(true);
for each (_local2 in faces) {
_local2.v0.connectedFaces[_local2] = _local2;
_local2.v1.connectedFaces[_local2] = _local2;
_local2.v2.connectedFaces[_local2] = _local2;
_local1[_local2.v0] = _local2.v0;
_local1[_local2.v1] = _local2.v1;
_local1[_local2.v2] = _local2.v2;
};
for each (_local3 in _local1) {
_local3.calculateNormal();
};
}
public function get boundingSphere():BoundingSphere{
if (_boundingSphereDirty){
_boundingSphere = BoundingSphere.getFromVertices(vertices);
_boundingSphereDirty = false;
};
return (_boundingSphere);
}
public function clone(_arg1:DisplayObject3D=null):GeometryObject3D{
var _local5:int;
var _local6:MaterialObject3D;
var _local7:Vertex3D;
var _local8:Triangle3D;
var _local9:Vertex3D;
var _local10:Vertex3D;
var _local11:Vertex3D;
var _local2:Dictionary = new Dictionary(true);
var _local3:Dictionary = new Dictionary(true);
var _local4:GeometryObject3D = new GeometryObject3D();
_local4.vertices = new Array();
_local4.faces = new Array();
_local5 = 0;
while (_local5 < this.vertices.length) {
_local7 = this.vertices[_local5];
_local3[_local7] = _local7.clone();
_local4.vertices.push(_local3[_local7]);
_local5++;
};
_local5 = 0;
while (_local5 < this.faces.length) {
_local8 = this.faces[_local5];
_local9 = _local3[_local8.v0];
_local10 = _local3[_local8.v1];
_local11 = _local3[_local8.v2];
_local4.faces.push(new Triangle3D(_arg1, [_local9, _local10, _local11], _local8.material, _local8.uv));
_local2[_local8.material] = _local8.material;
_local5++;
};
for each (_local6 in _local2) {
if (_local6){
_local6.registerObject(_arg1);
};
};
return (_local4);
}
public function get ready():Boolean{
return (_ready);
}
public function get aabb():AxisAlignedBoundingBox{
if (_aabbDirty){
_aabb = AxisAlignedBoundingBox.createFromVertices(vertices);
_aabbDirty = false;
};
return (_aabb);
}
}
}//package org.papervision3d.core.proto
Section 203
//LightObject3D (org.papervision3d.core.proto.LightObject3D)
package org.papervision3d.core.proto {
import org.papervision3d.objects.*;
import org.papervision3d.core.math.*;
import org.papervision3d.materials.*;
import org.papervision3d.objects.primitives.*;
public class LightObject3D extends DisplayObject3D {
public var flipped:Boolean;
public var lightMatrix:Matrix3D;
private var _showLight:Boolean;
private var displaySphere:Sphere;
public function LightObject3D(_arg1:Boolean=false, _arg2:Boolean=false){
this.lightMatrix = Matrix3D.IDENTITY;
this.showLight = _arg1;
this.flipped = _arg2;
}
public function get showLight():Boolean{
return (_showLight);
}
public function set showLight(_arg1:Boolean):void{
if (_showLight){
removeChild(displaySphere);
};
if (_arg1){
displaySphere = new Sphere(new WireframeMaterial(0xFFFF00), 10, 3, 2);
addChild(displaySphere);
};
_showLight = _arg1;
}
}
}//package org.papervision3d.core.proto
Section 204
//MaterialObject3D (org.papervision3d.core.proto.MaterialObject3D)
package org.papervision3d.core.proto {
import flash.events.*;
import flash.display.*;
import flash.geom.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.render.command.*;
import flash.utils.*;
import org.papervision3d.materials.*;
import org.papervision3d.core.render.material.*;
import org.papervision3d.core.render.draw.*;
public class MaterialObject3D extends EventDispatcher implements ITriangleDrawer {
public var widthOffset:Number;// = 0
public var name:String;
public var heightOffset:Number;// = 0
public var fillAlpha:Number;// = 0
public var fillColor:Number;
public var id:Number;
protected var objects:Dictionary;
public var baked:Boolean;// = false
public var invisible:Boolean;// = false
public var smooth:Boolean;// = false
public var bitmap:BitmapData;
public var lineAlpha:Number;// = 0
public var lineColor:Number;
public var lineThickness:Number;// = 1
public var interactive:Boolean;// = false
public var oneSide:Boolean;// = true
public var opposite:Boolean;// = false
public var maxU:Number;
public var tiled:Boolean;// = false
public var maxV:Number;
public static var DEFAULT_COLOR:int = 0;
public static var DEBUG_COLOR:int = 0xFF00FF;
private static var _totalMaterialObjects:Number = 0;
public function MaterialObject3D(){
lineColor = DEFAULT_COLOR;
fillColor = DEFAULT_COLOR;
super();
this.id = _totalMaterialObjects++;
MaterialManager.registerMaterial(this);
objects = new Dictionary(true);
}
public function getObjectList():Dictionary{
return (objects);
}
override public function toString():String{
return (((((("[MaterialObject3D] bitmap:" + this.bitmap) + " lineColor:") + this.lineColor) + " fillColor:") + fillColor));
}
public function drawRT(_arg1:RenderTriangle, _arg2:Graphics, _arg3:RenderSessionData):void{
}
public function get doubleSided():Boolean{
return (!(this.oneSide));
}
public function unregisterObject(_arg1:DisplayObject3D):void{
if (((objects) && (objects[_arg1]))){
objects[_arg1] = null;
};
}
public function set doubleSided(_arg1:Boolean):void{
this.oneSide = !(_arg1);
}
public function registerObject(_arg1:DisplayObject3D):void{
objects[_arg1] = true;
}
public function updateBitmap():void{
}
public function clone():MaterialObject3D{
var _local1:MaterialObject3D = new MaterialObject3D();
_local1.copy(this);
return (_local1);
}
public function isUpdateable():Boolean{
return (!(baked));
}
public function copy(_arg1:MaterialObject3D):void{
this.bitmap = _arg1.bitmap;
this.smooth = _arg1.smooth;
this.lineColor = _arg1.lineColor;
this.lineAlpha = _arg1.lineAlpha;
this.fillColor = _arg1.fillColor;
this.fillAlpha = _arg1.fillAlpha;
this.oneSide = _arg1.oneSide;
this.opposite = _arg1.opposite;
this.invisible = _arg1.invisible;
this.name = _arg1.name;
this.maxU = _arg1.maxU;
this.maxV = _arg1.maxV;
}
public function destroy():void{
objects = null;
bitmap = null;
MaterialManager.unRegisterMaterial(this);
}
public function drawTriangle(_arg1:RenderTriangle, _arg2:Graphics, _arg3:RenderSessionData, _arg4:BitmapData=null, _arg5:Matrix=null):void{
}
public static function get DEFAULT():MaterialObject3D{
var _local1:MaterialObject3D = new WireframeMaterial();
_local1.lineColor = (0xFFFFFF * Math.random());
_local1.lineAlpha = 1;
_local1.fillColor = DEFAULT_COLOR;
_local1.fillAlpha = 1;
_local1.doubleSided = false;
return (_local1);
}
public static function get DEBUG():MaterialObject3D{
var _local1:MaterialObject3D = new (MaterialObject3D);
_local1.lineColor = (0xFFFFFF * Math.random());
_local1.lineAlpha = 1;
_local1.fillColor = DEBUG_COLOR;
_local1.fillAlpha = 0.37;
_local1.doubleSided = true;
return (_local1);
}
}
}//package org.papervision3d.core.proto
Section 205
//SceneObject3D (org.papervision3d.core.proto.SceneObject3D)
package org.papervision3d.core.proto {
import org.papervision3d.objects.*;
import org.papervision3d.materials.utils.*;
import org.papervision3d.core.log.*;
import org.papervision3d.*;
public class SceneObject3D extends DisplayObjectContainer3D {
public var objects:Array;
public var materials:MaterialsList;
public function SceneObject3D(){
this.objects = new Array();
this.materials = new MaterialsList();
PaperLogger.info((((((Papervision3D.NAME + " ") + Papervision3D.VERSION) + " (") + Papervision3D.DATE) + ")\n"));
this.root = this;
}
override public function removeChild(_arg1:DisplayObject3D):DisplayObject3D{
super.removeChild(_arg1);
var _local2:int;
while (_local2 < this.objects.length) {
if (this.objects[_local2] === _arg1){
this.objects.splice(_local2, 1);
return (_arg1);
};
_local2++;
};
return (_arg1);
}
override public function addChild(_arg1:DisplayObject3D, _arg2:String=null):DisplayObject3D{
var _local3:DisplayObject3D = super.addChild(_arg1, (_arg2) ? _arg2 : _arg1.name);
_arg1.scene = this;
_arg1.parent = null;
this.objects.push(_local3);
return (_local3);
}
}
}//package org.papervision3d.core.proto
Section 206
//AbstractRenderListItem (org.papervision3d.core.render.command.AbstractRenderListItem)
package org.papervision3d.core.render.command {
import flash.display.*;
import org.papervision3d.core.render.data.*;
public class AbstractRenderListItem implements IRenderListItem {
public var screenZ:Number;
public function render(_arg1:RenderSessionData, _arg2:Graphics):void{
}
}
}//package org.papervision3d.core.render.command
Section 207
//IRenderListItem (org.papervision3d.core.render.command.IRenderListItem)
package org.papervision3d.core.render.command {
import flash.display.*;
import org.papervision3d.core.render.data.*;
public interface IRenderListItem {
function render(_arg1:RenderSessionData, _arg2:Graphics):void;
}
}//package org.papervision3d.core.render.command
Section 208
//RenderableListItem (org.papervision3d.core.render.command.RenderableListItem)
package org.papervision3d.core.render.command {
import flash.geom.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.render.data.*;
public class RenderableListItem extends AbstractRenderListItem {
public var minX:Number;
public var minY:Number;
public var minZ:Number;
public var area:Number;
public var instance:DisplayObject3D;
public var renderableInstance:AbstractRenderable;
public var renderable:Class;
public var maxX:Number;
public var maxY:Number;
public var maxZ:Number;
public var quadrant:QuadTreeNode;
public function getZ(_arg1:Number, _arg2:Number, _arg3:Number):Number{
return (screenZ);
}
public function update():void{
}
public function hitTestPoint2D(_arg1:Point, _arg2:RenderHitData):RenderHitData{
return (_arg2);
}
public function quarter(_arg1:Number):Array{
return ([]);
}
}
}//package org.papervision3d.core.render.command
Section 209
//RenderLine (org.papervision3d.core.render.command.RenderLine)
package org.papervision3d.core.render.command {
import flash.display.*;
import flash.geom.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.math.*;
import org.papervision3d.materials.special.*;
public class RenderLine extends RenderableListItem implements IRenderListItem {
public var size:Number;
private var fbz:Number;
private var db:Number;
private var bzf:Number;
private var axf:Number;
public var v1:Vertex3DInstance;
private var dx:Number;
private var dy:Number;
private var faz:Number;
private var det:Number;
private var ayf:Number;
private var da:Number;
private var ax:Number;
private var ay:Number;
private var az:Number;
public var renderer:LineMaterial;
private var l1:Number2D;
private var l2:Number2D;
private var azf:Number;
private var bxf:Number;
public var cV:Vertex3DInstance;
private var bx:Number;
private var by:Number;
private var bz:Number;
public var length:Number;
private var xfocus:Number;
private var cp3d:Number3D;
private var byf:Number;
private var p:Number2D;
private var v:Number2D;
public var v0:Vertex3DInstance;
public var line:Line3D;
private var yfocus:Number;
private static var mouseVector:Number3D = Number3D.ZERO;
private static var lineVector:Number3D = Number3D.ZERO;
public function RenderLine(_arg1:Line3D){
this.renderable = Line3D;
this.renderableInstance = _arg1;
this.line = _arg1;
this.instance = _arg1.instance;
v0 = _arg1.v0.vertex3DInstance;
v1 = _arg1.v1.vertex3DInstance;
cV = _arg1.cV.vertex3DInstance;
p = new Number2D();
l1 = new Number2D();
l2 = new Number2D();
v = new Number2D();
cp3d = new Number3D();
}
override public function render(_arg1:RenderSessionData, _arg2:Graphics):void{
renderer.drawLine(this, _arg2, _arg1);
}
override public function getZ(_arg1:Number, _arg2:Number, _arg3:Number):Number{
ax = v0.x;
ay = v0.y;
az = v0.z;
bx = v1.x;
by = v1.y;
bz = v1.z;
if ((((ax == _arg1)) && ((ay == _arg2)))){
return (az);
};
if ((((bx == _arg1)) && ((by == _arg2)))){
return (bz);
};
dx = (bx - ax);
dy = (by - ay);
azf = (az / _arg3);
bzf = (bz / _arg3);
faz = (1 + azf);
fbz = (1 + bzf);
xfocus = _arg1;
yfocus = _arg2;
axf = ((ax * faz) - (_arg1 * azf));
bxf = ((bx * fbz) - (_arg1 * bzf));
ayf = ((ay * faz) - (_arg2 * azf));
byf = ((by * fbz) - (_arg2 * bzf));
det = ((dx * (axf - bxf)) + (dy * (ayf - byf)));
db = ((dx * (axf - _arg1)) + (dy * (ayf - _arg2)));
da = ((dx * (_arg1 - bxf)) + (dy * (_arg2 - byf)));
return ((((da * az) + (db * bz)) / det));
}
override public function hitTestPoint2D(_arg1:Point, _arg2:RenderHitData):RenderHitData{
var _local3:Number;
var _local4:Number;
var _local5:Number;
if (renderer.interactive){
_local3 = line.size;
p.reset(_arg1.x, _arg1.y);
l1.reset(line.v0.vertex3DInstance.x, line.v0.vertex3DInstance.y);
l2.reset(line.v1.vertex3DInstance.x, line.v1.vertex3DInstance.y);
v.copyFrom(l2);
v.minusEq(l1);
_local4 = ((((p.x - l1.x) * (l2.x - l1.x)) + ((p.y - l1.y) * (l2.y - l1.y))) / ((v.x * v.x) + (v.y * v.y)));
if ((((_local4 > 0)) && ((_local4 < 1)))){
v.multiplyEq(_local4);
v.plusEq(l1);
v.minusEq(p);
_local5 = ((v.x * v.x) + (v.y * v.y));
if (_local5 < (_local3 * _local3)){
_arg2.displayObject3D = line.instance;
_arg2.material = renderer;
_arg2.renderable = line;
_arg2.hasHit = true;
cp3d.reset((line.v1.x - line.v0.x), (line.v1.y - line.v0.y), (line.v1.x - line.v0.x));
cp3d.x = (cp3d.x * _local4);
cp3d.y = (cp3d.y * _local4);
cp3d.z = (cp3d.z * _local4);
cp3d.x = (cp3d.x + line.v0.x);
cp3d.y = (cp3d.y + line.v0.y);
cp3d.z = (cp3d.z + line.v0.z);
_arg2.x = cp3d.x;
_arg2.y = cp3d.y;
_arg2.z = cp3d.z;
_arg2.u = 0;
_arg2.v = 0;
return (_arg2);
};
};
};
return (_arg2);
}
}
}//package org.papervision3d.core.render.command
Section 210
//RenderParticle (org.papervision3d.core.render.command.RenderParticle)
package org.papervision3d.core.render.command {
import flash.display.*;
import flash.geom.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.materials.special.*;
public class RenderParticle extends RenderableListItem implements IRenderListItem {
public var renderMat:ParticleMaterial;
public var particle:Particle;
public function RenderParticle(_arg1:Particle){
this.particle = _arg1;
this.renderableInstance = _arg1;
this.renderable = Particle;
this.instance = _arg1.instance;
}
override public function render(_arg1:RenderSessionData, _arg2:Graphics):void{
particle.material.drawParticle(particle, _arg2, _arg1);
}
override public function hitTestPoint2D(_arg1:Point, _arg2:RenderHitData):RenderHitData{
renderMat = particle.material;
if (renderMat.interactive){
if (particle.renderRect.contains(_arg1.x, _arg1.y)){
_arg2.displayObject3D = particle.instance;
_arg2.material = renderMat;
_arg2.renderable = particle;
_arg2.hasHit = true;
_arg2.x = particle.x;
_arg2.y = particle.y;
_arg2.z = particle.z;
_arg2.u = 0;
_arg2.v = 0;
return (_arg2);
};
};
return (_arg2);
}
}
}//package org.papervision3d.core.render.command
Section 211
//RenderTriangle (org.papervision3d.core.render.command.RenderTriangle)
package org.papervision3d.core.render.command {
import flash.display.*;
import flash.geom.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.core.math.*;
import org.papervision3d.materials.*;
import org.papervision3d.core.render.draw.*;
public class RenderTriangle extends RenderableListItem implements IRenderListItem {
public var triangle:Triangle3D;
private var bzf:Number;
private var axf:Number;
private var det:Number;
private var v12:Vertex3DInstance;
private var faz:Number;
private var position:Number3D;
private var ayf:Number;
private var au:Number;
private var av:Number;
private var ax:Number;
private var ay:Number;
private var az:Number;
private var v20:Vertex3DInstance;
private var fbz:Number;
private var azf:Number;
private var bu:Number;
private var bv:Number;
private var bx:Number;
private var by:Number;
private var bz:Number;
private var fcz:Number;
private var uv01:NumberUV;
private var cu:Number;
private var cv:Number;
private var cx:Number;
private var cy:Number;
private var cz:Number;
public var v0:Vertex3DInstance;
public var v1:Vertex3DInstance;
private var da:Number;
private var db:Number;
private var dc:Number;
public var container:Sprite;
private var uv12:NumberUV;
public var v2:Vertex3DInstance;
private var cxf:Number;
private var uv20:NumberUV;
protected var vx0:Vertex3DInstance;
public var uv0:NumberUV;
public var uv1:NumberUV;
public var uv2:NumberUV;
protected var vx1:Vertex3DInstance;
protected var vx2:Vertex3DInstance;
public var renderer:ITriangleDrawer;
private var cyf:Number;
private var czf:Number;
private var bxf:Number;
protected var vPointL:Vertex3DInstance;
public var renderMat:MaterialObject3D;
private var byf:Number;
private var v01:Vertex3DInstance;
public var create:Function;
protected static var resPA:Vertex3DInstance = new Vertex3DInstance();
protected static var resBA:Vertex3DInstance = new Vertex3DInstance();
protected static var vPoint:Vertex3DInstance = new Vertex3DInstance();
protected static var resRA:Vertex3DInstance = new Vertex3DInstance();
public function RenderTriangle(_arg1:Triangle3D):void{
position = new Number3D();
super();
this.triangle = _arg1;
this.instance = _arg1.instance;
renderableInstance = _arg1;
renderable = Triangle3D;
this.v0 = _arg1.v0.vertex3DInstance;
this.v1 = _arg1.v1.vertex3DInstance;
this.v2 = _arg1.v2.vertex3DInstance;
this.uv0 = _arg1.uv0;
this.uv1 = _arg1.uv1;
this.uv2 = _arg1.uv2;
this.renderer = _arg1.material;
update();
}
private function deepHitTest(_arg1:Triangle3D, _arg2:Vertex3DInstance, _arg3:RenderHitData):RenderHitData{
var _local44:MovieMaterial;
var _local45:Rectangle;
var _local4:Vertex3DInstance = _arg1.v0.vertex3DInstance;
var _local5:Vertex3DInstance = _arg1.v1.vertex3DInstance;
var _local6:Vertex3DInstance = _arg1.v2.vertex3DInstance;
var _local7:Number = (_local6.x - _local4.x);
var _local8:Number = (_local6.y - _local4.y);
var _local9:Number = (_local5.x - _local4.x);
var _local10:Number = (_local5.y - _local4.y);
var _local11:Number = (_arg2.x - _local4.x);
var _local12:Number = (_arg2.y - _local4.y);
var _local13:Number = ((_local7 * _local7) + (_local8 * _local8));
var _local14:Number = ((_local7 * _local9) + (_local8 * _local10));
var _local15:Number = ((_local7 * _local11) + (_local8 * _local12));
var _local16:Number = ((_local9 * _local9) + (_local10 * _local10));
var _local17:Number = ((_local9 * _local11) + (_local10 * _local12));
var _local18:Number = (1 / ((_local13 * _local16) - (_local14 * _local14)));
var _local19:Number = (((_local16 * _local15) - (_local14 * _local17)) * _local18);
var _local20:Number = (((_local13 * _local17) - (_local14 * _local15)) * _local18);
var _local21:Number = (_arg1.v2.x - _arg1.v0.x);
var _local22:Number = (_arg1.v2.y - _arg1.v0.y);
var _local23:Number = (_arg1.v2.z - _arg1.v0.z);
var _local24:Number = (_arg1.v1.x - _arg1.v0.x);
var _local25:Number = (_arg1.v1.y - _arg1.v0.y);
var _local26:Number = (_arg1.v1.z - _arg1.v0.z);
var _local27:Number = ((_arg1.v0.x + (_local21 * _local19)) + (_local24 * _local20));
var _local28:Number = ((_arg1.v0.y + (_local22 * _local19)) + (_local25 * _local20));
var _local29:Number = ((_arg1.v0.z + (_local23 * _local19)) + (_local26 * _local20));
var _local30:Array = _arg1.uv;
var _local31:Number = _local30[0].u;
var _local32:Number = _local30[1].u;
var _local33:Number = _local30[2].u;
var _local34:Number = _local30[0].v;
var _local35:Number = _local30[1].v;
var _local36:Number = _local30[2].v;
var _local37:Number = ((((_local32 - _local31) * _local20) + ((_local33 - _local31) * _local19)) + _local31);
var _local38:Number = ((((_local35 - _local34) * _local20) + ((_local36 - _local34) * _local19)) + _local34);
if (triangle.material){
renderMat = _arg1.material;
} else {
renderMat = _arg1.instance.material;
};
var _local39:BitmapData = renderMat.bitmap;
var _local40:Number = 1;
var _local41:Number = 1;
var _local42:Number = 0;
var _local43:Number = 0;
if ((renderMat is MovieMaterial)){
_local44 = (renderMat as MovieMaterial);
_local45 = _local44.rect;
if (_local45){
_local42 = _local45.x;
_local43 = _local45.y;
_local40 = _local45.width;
_local41 = _local45.height;
};
} else {
if (_local39){
_local40 = (BitmapMaterial.AUTO_MIP_MAPPING) ? renderMat.widthOffset : _local39.width;
_local41 = (BitmapMaterial.AUTO_MIP_MAPPING) ? renderMat.heightOffset : _local39.height;
};
};
_arg3.displayObject3D = _arg1.instance;
_arg3.material = renderMat;
_arg3.renderable = _arg1;
_arg3.hasHit = true;
position.x = _local27;
position.y = _local28;
position.z = _local29;
Matrix3D.multiplyVector(_arg1.instance.world, position);
_arg3.x = position.x;
_arg3.y = position.y;
_arg3.z = position.z;
_arg3.u = ((_local37 * _local40) + _local42);
_arg3.v = ((_local41 - (_local38 * _local41)) + _local43);
return (_arg3);
}
override public function hitTestPoint2D(_arg1:Point, _arg2:RenderHitData):RenderHitData{
renderMat = triangle.material;
if (!renderMat){
renderMat = triangle.instance.material;
};
if (((renderMat) && (renderMat.interactive))){
vPointL = RenderTriangle.vPoint;
vPointL.x = _arg1.x;
vPointL.y = _arg1.y;
vx0 = triangle.v0.vertex3DInstance;
vx1 = triangle.v1.vertex3DInstance;
vx2 = triangle.v2.vertex3DInstance;
if (sameSide(vPointL, vx0, vx1, vx2)){
if (sameSide(vPointL, vx1, vx0, vx2)){
if (sameSide(vPointL, vx2, vx0, vx1)){
return (deepHitTest(triangle, vPointL, _arg2));
};
};
};
};
return (_arg2);
}
public function fivepointcut(_arg1:Vertex3DInstance, _arg2:Vertex3DInstance, _arg3:Vertex3DInstance, _arg4:Vertex3DInstance, _arg5:Vertex3DInstance, _arg6:NumberUV, _arg7:NumberUV, _arg8:NumberUV, _arg9:NumberUV, _arg10:NumberUV):Array{
if (_arg1.distanceSqr(_arg4) < _arg2.distanceSqr(_arg5)){
return ([create(renderableInstance, renderer, _arg1, _arg2, _arg4, _arg6, _arg7, _arg9), create(renderableInstance, renderer, _arg2, _arg3, _arg4, _arg7, _arg8, _arg9), create(renderableInstance, renderer, _arg1, _arg4, _arg5, _arg6, _arg9, _arg10)]);
};
return ([create(renderableInstance, renderer, _arg1, _arg2, _arg5, _arg6, _arg7, _arg10), create(renderableInstance, renderer, _arg2, _arg3, _arg4, _arg7, _arg8, _arg9), create(renderableInstance, renderer, _arg2, _arg4, _arg5, _arg7, _arg9, _arg10)]);
}
override public function render(_arg1:RenderSessionData, _arg2:Graphics):void{
renderer.drawTriangle(this, _arg2, _arg1);
}
final override public function quarter(_arg1:Number):Array{
if (area < 20){
return (null);
};
v01 = Vertex3DInstance.median(v0, v1, _arg1);
v12 = Vertex3DInstance.median(v1, v2, _arg1);
v20 = Vertex3DInstance.median(v2, v0, _arg1);
uv01 = NumberUV.median(uv0, uv1);
uv12 = NumberUV.median(uv1, uv2);
uv20 = NumberUV.median(uv2, uv0);
return ([create(renderableInstance, renderer, v0, v01, v20, uv0, uv01, uv20), create(renderableInstance, renderer, v1, v12, v01, uv1, uv12, uv01), create(renderableInstance, renderer, v2, v20, v12, uv2, uv20, uv12), create(renderableInstance, renderer, v01, v12, v20, uv01, uv12, uv20)]);
}
final override public function getZ(_arg1:Number, _arg2:Number, _arg3:Number):Number{
ax = v0.x;
ay = v0.y;
az = v0.z;
bx = v1.x;
by = v1.y;
bz = v1.z;
cx = v2.x;
cy = v2.y;
cz = v2.z;
if ((((ax == _arg1)) && ((ay == _arg2)))){
return (az);
};
if ((((bx == _arg1)) && ((by == _arg2)))){
return (bz);
};
if ((((cx == _arg1)) && ((cy == _arg2)))){
return (cz);
};
azf = (az / _arg3);
bzf = (bz / _arg3);
czf = (cz / _arg3);
faz = (1 + azf);
fbz = (1 + bzf);
fcz = (1 + czf);
axf = ((ax * faz) - (_arg1 * azf));
bxf = ((bx * fbz) - (_arg1 * bzf));
cxf = ((cx * fcz) - (_arg1 * czf));
ayf = ((ay * faz) - (_arg2 * azf));
byf = ((by * fbz) - (_arg2 * bzf));
cyf = ((cy * fcz) - (_arg2 * czf));
det = (((axf * (byf - cyf)) + (bxf * (cyf - ayf))) + (cxf * (ayf - byf)));
da = (((_arg1 * (byf - cyf)) + (bxf * (cyf - _arg2))) + (cxf * (_arg2 - byf)));
db = (((axf * (_arg2 - cyf)) + (_arg1 * (cyf - ayf))) + (cxf * (ayf - _arg2)));
dc = (((axf * (byf - _arg2)) + (bxf * (_arg2 - ayf))) + (_arg1 * (ayf - byf)));
return (((((da * az) + (db * bz)) + (dc * cz)) / det));
}
override public function update():void{
if (v0.x > v1.x){
if (v0.x > v2.x){
maxX = v0.x;
} else {
maxX = v2.x;
};
} else {
if (v1.x > v2.x){
maxX = v1.x;
} else {
maxX = v2.x;
};
};
if (v0.x < v1.x){
if (v0.x < v2.x){
minX = v0.x;
} else {
minX = v2.x;
};
} else {
if (v1.x < v2.x){
minX = v1.x;
} else {
minX = v2.x;
};
};
if (v0.y > v1.y){
if (v0.y > v2.y){
maxY = v0.y;
} else {
maxY = v2.y;
};
} else {
if (v1.y > v2.y){
maxY = v1.y;
} else {
maxY = v2.y;
};
};
if (v0.y < v1.y){
if (v0.y < v2.y){
minY = v0.y;
} else {
minY = v2.y;
};
} else {
if (v1.y < v2.y){
minY = v1.y;
} else {
minY = v2.y;
};
};
if (v0.z > v1.z){
if (v0.z > v2.z){
maxZ = v0.z;
} else {
maxZ = v2.z;
};
} else {
if (v1.z > v2.z){
maxZ = v1.z;
} else {
maxZ = v2.z;
};
};
if (v0.z < v1.z){
if (v0.z < v2.z){
minZ = v0.z;
} else {
minZ = v2.z;
};
} else {
if (v1.z < v2.z){
minZ = v1.z;
} else {
minZ = v2.z;
};
};
screenZ = (((v0.z + v1.z) + v2.z) / 3);
area = (0.5 * (((v0.x * (v2.y - v1.y)) + (v1.x * (v0.y - v2.y))) + (v2.x * (v1.y - v0.y))));
}
public function sameSide(_arg1:Vertex3DInstance, _arg2:Vertex3DInstance, _arg3:Vertex3DInstance, _arg4:Vertex3DInstance):Boolean{
Vertex3DInstance.subTo(_arg4, _arg3, resBA);
Vertex3DInstance.subTo(_arg1, _arg3, resPA);
Vertex3DInstance.subTo(_arg2, _arg3, resRA);
return (((Vertex3DInstance.cross(resBA, resPA) * Vertex3DInstance.cross(resBA, resRA)) >= 0));
}
}
}//package org.papervision3d.core.render.command
Section 212
//QuadTree (org.papervision3d.core.render.data.QuadTree)
package org.papervision3d.core.render.data {
import flash.display.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.render.command.*;
import org.papervision3d.core.clipping.draw.*;
public final class QuadTree {
private var _root:QuadTreeNode;
private var _rect:RectangleClipping;
private var _result:Array;
private var _maxlevel:uint;// = 4
private var _maxX:Number;
private var _maxY:Number;
private var _child:RenderableListItem;
private var _children:Array;
private var _minX:Number;
private var _minY:Number;
private var i:int;
private var _clip:Clipping;
private var _center:Array;
private var _except:DisplayObject3D;
public function get maxLevel():uint{
return (_maxlevel);
}
public function remove(_arg1:RenderableListItem):void{
_center = _arg1.quadrant.center;
_center.splice(_center.indexOf(_arg1), 1);
}
public function set maxLevel(_arg1:uint):void{
_maxlevel = _arg1;
if (_root){
_root.maxlevel = _maxlevel;
};
}
public function getOverlaps(_arg1:RenderableListItem, _arg2:DisplayObject3D=null):Array{
_result = [];
_minX = _arg1.minX;
_minY = _arg1.minY;
_maxX = _arg1.maxX;
_maxY = _arg1.maxY;
_except = _arg2;
getList(_arg1.quadrant);
getParent(_arg1.quadrant);
return (_result);
}
public function get clip():Clipping{
return (_clip);
}
public function render(_arg1:RenderSessionData, _arg2:Graphics):void{
_root.render(-(Infinity), _arg1, _arg2);
}
public function list():Array{
_result = [];
_minX = -1000000;
_minY = -1000000;
_maxX = 1000000;
_maxY = 1000000;
_except = null;
getList(_root);
return (_result);
}
public function getRoot():QuadTreeNode{
return (_root);
}
private function getList(_arg1:QuadTreeNode):void{
if (!_arg1){
return;
};
if (((_arg1.onlysourceFlag) && ((_except == _arg1.onlysource)))){
return;
};
if (_minX < _arg1.xdiv){
if (((_arg1.lefttopFlag) && ((_minY < _arg1.ydiv)))){
getList(_arg1.lefttop);
};
if (((_arg1.leftbottomFlag) && ((_maxY > _arg1.ydiv)))){
getList(_arg1.leftbottom);
};
};
if (_maxX > _arg1.xdiv){
if (((_arg1.righttopFlag) && ((_minY < _arg1.ydiv)))){
getList(_arg1.righttop);
};
if (((_arg1.rightbottomFlag) && ((_maxY > _arg1.ydiv)))){
getList(_arg1.rightbottom);
};
};
_children = _arg1.center;
if (_children != null){
i = _children.length;
while (i--) {
_child = _children[i];
if ((((((((((((_except == null)) || (!((_child.instance == _except))))) && ((_child.maxX > _minX)))) && ((_child.minX < _maxX)))) && ((_child.maxY > _minY)))) && ((_child.minY < _maxY)))){
_result.push(_child);
};
};
};
}
private function getParent(_arg1:QuadTreeNode=null):void{
if (!_arg1){
return;
};
_arg1 = _arg1.parent;
if ((((_arg1 == null)) || (((_arg1.onlysourceFlag) && ((_except == _arg1.onlysource)))))){
return;
};
_children = _arg1.center;
if (_children != null){
i = _children.length;
while (i--) {
_child = _children[i];
if ((((((((((((_except == null)) || (!((_child.instance == _except))))) && ((_child.maxX > _minX)))) && ((_child.minX < _maxX)))) && ((_child.maxY > _minY)))) && ((_child.minY < _maxY)))){
_result.push(_child);
};
};
};
getParent(_arg1);
}
public function add(_arg1:RenderableListItem):void{
if (_clip.check(_arg1)){
_root.push(_arg1);
};
}
public function set clip(_arg1:Clipping):void{
_clip = _arg1;
_rect = _clip.asRectangleClipping();
if (!_root){
_root = new QuadTreeNode(((_rect.minX + _rect.maxX) / 2), ((_rect.minY + _rect.maxY) / 2), (_rect.maxX - _rect.minX), (_rect.maxY - _rect.minY), 0, null, _maxlevel);
} else {
_root.reset(((_rect.minX + _rect.maxX) / 2), ((_rect.minY + _rect.maxY) / 2), (_rect.maxX - _rect.minX), (_rect.maxY - _rect.minY), _maxlevel);
};
}
}
}//package org.papervision3d.core.render.data
Section 213
//QuadTreeNode (org.papervision3d.core.render.data.QuadTreeNode)
package org.papervision3d.core.render.data {
import flash.display.*;
import flash.geom.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.render.command.*;
public final class QuadTreeNode {
public var parent:QuadTreeNode;
public var create:Function;
private var level:int;
public var righttopFlag:Boolean;
public var hasContent:Boolean;// = false
public var rightbottom:QuadTreeNode;
public var righttop:QuadTreeNode;
public var rightbottomFlag:Boolean;
public var onlysource:DisplayObject3D;
public var xdiv:Number;
private var halfheight:Number;
public var center:Array;
public var maxlevel:int;// = 4
private var render_center_length:int;// = -1
public var onlysourceFlag:Boolean;// = true
private var render_center_index:int;// = -1
private var halfwidth:Number;
public var lefttop:QuadTreeNode;
public var ydiv:Number;
public var leftbottom:QuadTreeNode;
public var lefttopFlag:Boolean;
public var leftbottomFlag:Boolean;
public function QuadTreeNode(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:int, _arg6:QuadTreeNode=null, _arg7:uint=4){
this.level = _arg5;
this.xdiv = _arg1;
this.ydiv = _arg2;
halfwidth = (_arg3 / 2);
halfheight = (_arg4 / 2);
this.parent = _arg6;
this.maxlevel = _arg7;
}
public function reset(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:uint):void{
this.xdiv = _arg1;
this.ydiv = _arg2;
halfwidth = (_arg3 / 2);
halfheight = (_arg4 / 2);
lefttopFlag = false;
leftbottomFlag = false;
righttopFlag = false;
rightbottomFlag = false;
onlysourceFlag = true;
onlysource = null;
render_center_length = -1;
render_center_index = -1;
hasContent = false;
maxlevel = _arg5;
}
public function push(_arg1:RenderableListItem):void{
hasContent = true;
if (onlysourceFlag){
if (((!((onlysource == null))) && (!((onlysource == _arg1.instance))))){
onlysourceFlag = false;
};
onlysource = _arg1.instance;
};
if (level < maxlevel){
if (_arg1.maxX <= xdiv){
if (_arg1.maxY <= ydiv){
if (lefttop == null){
lefttopFlag = true;
lefttop = new QuadTreeNode((xdiv - (halfwidth / 2)), (ydiv - (halfheight / 2)), halfwidth, halfheight, (level + 1), this, maxlevel);
} else {
if (!lefttopFlag){
lefttopFlag = true;
lefttop.reset((xdiv - (halfwidth / 2)), (ydiv - (halfheight / 2)), halfwidth, halfheight, maxlevel);
};
};
lefttop.push(_arg1);
return;
} else {
if (_arg1.minY >= ydiv){
if (leftbottom == null){
leftbottomFlag = true;
leftbottom = new QuadTreeNode((xdiv - (halfwidth / 2)), (ydiv + (halfheight / 2)), halfwidth, halfheight, (level + 1), this, maxlevel);
} else {
if (!leftbottomFlag){
leftbottomFlag = true;
leftbottom.reset((xdiv - (halfwidth / 2)), (ydiv + (halfheight / 2)), halfwidth, halfheight, maxlevel);
};
};
leftbottom.push(_arg1);
return;
};
};
} else {
if (_arg1.minX >= xdiv){
if (_arg1.maxY <= ydiv){
if (righttop == null){
righttopFlag = true;
righttop = new QuadTreeNode((xdiv + (halfwidth / 2)), (ydiv - (halfheight / 2)), halfwidth, halfheight, (level + 1), this, maxlevel);
} else {
if (!righttopFlag){
righttopFlag = true;
righttop.reset((xdiv + (halfwidth / 2)), (ydiv - (halfheight / 2)), halfwidth, halfheight, maxlevel);
};
};
righttop.push(_arg1);
return;
} else {
if (_arg1.minY >= ydiv){
if (rightbottom == null){
rightbottomFlag = true;
rightbottom = new QuadTreeNode((xdiv + (halfwidth / 2)), (ydiv + (halfheight / 2)), halfwidth, halfheight, (level + 1), this, maxlevel);
} else {
if (!rightbottomFlag){
rightbottomFlag = true;
rightbottom.reset((xdiv + (halfwidth / 2)), (ydiv + (halfheight / 2)), halfwidth, halfheight, maxlevel);
};
};
rightbottom.push(_arg1);
return;
};
};
};
};
};
if (center == null){
center = new Array();
};
center.push(_arg1);
_arg1.quadrant = this;
}
public function render(_arg1:Number, _arg2:RenderSessionData, _arg3:Graphics):void{
var _local4:RenderableListItem;
if (render_center_length == -1){
if (center != null){
render_center_length = center.length;
if (render_center_length > 1){
center.sortOn("screenZ", (Array.DESCENDING | Array.NUMERIC));
};
} else {
render_center_length = 0;
};
render_center_index = 0;
};
while (render_center_index < render_center_length) {
_local4 = center[render_center_index];
if (_local4.screenZ < _arg1){
break;
};
render_other(_local4.screenZ, _arg2, _arg3);
_local4.render(_arg2, _arg3);
_arg2.viewPort.lastRenderList.push(_local4);
render_center_index++;
};
if (render_center_index == render_center_length){
center = null;
};
render_other(_arg1, _arg2, _arg3);
}
public function getRect():Rectangle{
return (new Rectangle(xdiv, ydiv, (halfwidth * 2), (halfheight * 2)));
}
private function render_other(_arg1:Number, _arg2:RenderSessionData, _arg3:Graphics):void{
if (lefttopFlag){
lefttop.render(_arg1, _arg2, _arg3);
};
if (leftbottomFlag){
leftbottom.render(_arg1, _arg2, _arg3);
};
if (righttopFlag){
righttop.render(_arg1, _arg2, _arg3);
};
if (rightbottomFlag){
rightbottom.render(_arg1, _arg2, _arg3);
};
}
}
}//package org.papervision3d.core.render.data
Section 214
//RenderHitData (org.papervision3d.core.render.data.RenderHitData)
package org.papervision3d.core.render.data {
import org.papervision3d.objects.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.proto.*;
public class RenderHitData {
public var y:Number;
public var z:Number;
public var endTime:int;// = 0
public var startTime:int;// = 0
public var displayObject3D:DisplayObject3D;
public var hasHit:Boolean;// = false
public var material:MaterialObject3D;
public var renderable:IRenderable;
public var u:Number;
public var v:Number;
public var x:Number;
public function RenderHitData():void{
}
public function clear():void{
startTime = 0;
endTime = 0;
hasHit = false;
displayObject3D = null;
material = null;
renderable = null;
u = 0;
v = 0;
x = 0;
y = 0;
z = 0;
}
public function clone():RenderHitData{
var _local1:RenderHitData = new RenderHitData();
_local1.startTime = startTime;
_local1.endTime = endTime;
_local1.hasHit = hasHit;
_local1.displayObject3D = displayObject3D;
_local1.material = material;
_local1.renderable = renderable;
_local1.u = u;
_local1.v = v;
_local1.x = x;
_local1.y = y;
_local1.z = z;
return (_local1);
}
public function toString():String{
return (((displayObject3D + " ") + renderable));
}
}
}//package org.papervision3d.core.render.data
Section 215
//RenderSessionData (org.papervision3d.core.render.data.RenderSessionData)
package org.papervision3d.core.render.data {
import flash.display.*;
import org.papervision3d.view.*;
import org.papervision3d.core.culling.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.core.render.*;
import org.papervision3d.core.clipping.*;
public class RenderSessionData {
public var container:Sprite;
public var renderer:IRenderEngine;
public var particleCuller:IParticleCuller;
public var viewPort:Viewport3D;
public var triangleCuller:ITriangleCuller;
public var clipping:DefaultClipping;
public var scene:SceneObject3D;
public var renderStatistics:RenderStatistics;
public var renderObjects:Array;
public var camera:CameraObject3D;
public var renderLayers:Array;
public var quadrantTree:QuadTree;
public var sorted:Boolean;
public function RenderSessionData():void{
this.renderStatistics = new RenderStatistics();
}
public function destroy():void{
triangleCuller = null;
particleCuller = null;
viewPort = null;
container = null;
scene = null;
camera = null;
renderer = null;
renderStatistics = null;
renderObjects = null;
renderLayers = null;
clipping = null;
quadrantTree = null;
}
public function clone():RenderSessionData{
var _local1:RenderSessionData = new RenderSessionData();
_local1.triangleCuller = triangleCuller;
_local1.particleCuller = particleCuller;
_local1.viewPort = viewPort;
_local1.container = container;
_local1.scene = scene;
_local1.camera = camera;
_local1.renderer = renderer;
_local1.renderStatistics = renderStatistics.clone();
_local1.clipping = clipping;
_local1.quadrantTree = quadrantTree;
return (_local1);
}
}
}//package org.papervision3d.core.render.data
Section 216
//RenderStatistics (org.papervision3d.core.render.data.RenderStatistics)
package org.papervision3d.core.render.data {
public class RenderStatistics {
public var renderTime:int;// = 0
public var culledObjects:int;// = 0
public var shadedTriangles:int;// = 0
public var culledParticles:int;// = 0
public var culledTriangles:int;// = 0
public var triangles:int;// = 0
public var particles:int;// = 0
public var rendered:int;// = 0
public var projectionTime:int;// = 0
public var filteredObjects:int;// = 0
public var lines:int;// = 0
public function clear():void{
projectionTime = 0;
renderTime = 0;
rendered = 0;
particles = 0;
triangles = 0;
culledTriangles = 0;
culledParticles = 0;
lines = 0;
shadedTriangles = 0;
filteredObjects = 0;
culledObjects = 0;
}
public function clone():RenderStatistics{
var _local1:RenderStatistics = new RenderStatistics();
_local1.projectionTime = projectionTime;
_local1.renderTime = renderTime;
_local1.rendered = rendered;
_local1.particles = particles;
_local1.triangles = triangles;
_local1.culledTriangles = culledTriangles;
_local1.lines = lines;
_local1.shadedTriangles = shadedTriangles;
_local1.filteredObjects = filteredObjects;
_local1.culledObjects = culledObjects;
return (_local1);
}
public function toString():String{
return (new String((((((((((((((((((("ProjectionTime:" + projectionTime) + " RenderTime:") + renderTime) + " Particles:") + particles) + " CulledParticles :") + culledParticles) + " Triangles:") + triangles) + " ShadedTriangles :") + shadedTriangles) + " CulledTriangles:") + culledTriangles) + " FilteredObjects:") + filteredObjects) + " CulledObjects:") + culledObjects) + "")));
}
}
}//package org.papervision3d.core.render.data
Section 217
//ILineDrawer (org.papervision3d.core.render.draw.ILineDrawer)
package org.papervision3d.core.render.draw {
import flash.display.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.render.command.*;
public interface ILineDrawer {
function drawLine(_arg1:RenderLine, _arg2:Graphics, _arg3:RenderSessionData):void;
}
}//package org.papervision3d.core.render.draw
Section 218
//IParticleDrawer (org.papervision3d.core.render.draw.IParticleDrawer)
package org.papervision3d.core.render.draw {
import flash.display.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.render.data.*;
public interface IParticleDrawer {
function drawParticle(_arg1:Particle, _arg2:Graphics, _arg3:RenderSessionData):void;
function updateRenderRect(_arg1:Particle):void;
}
}//package org.papervision3d.core.render.draw
Section 219
//ITriangleDrawer (org.papervision3d.core.render.draw.ITriangleDrawer)
package org.papervision3d.core.render.draw {
import flash.display.*;
import flash.geom.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.render.command.*;
public interface ITriangleDrawer {
function drawTriangle(_arg1:RenderTriangle, _arg2:Graphics, _arg3:RenderSessionData, _arg4:BitmapData=null, _arg5:Matrix=null):void;
function drawRT(_arg1:RenderTriangle, _arg2:Graphics, _arg3:RenderSessionData):void;
}
}//package org.papervision3d.core.render.draw
Section 220
//BasicRenderFilter (org.papervision3d.core.render.filter.BasicRenderFilter)
package org.papervision3d.core.render.filter {
public class BasicRenderFilter implements IRenderFilter {
public function filter(_arg1:Array):int{
return (0);
}
}
}//package org.papervision3d.core.render.filter
Section 221
//IRenderFilter (org.papervision3d.core.render.filter.IRenderFilter)
package org.papervision3d.core.render.filter {
public interface IRenderFilter {
function filter(_arg1:Array):int;
}
}//package org.papervision3d.core.render.filter
Section 222
//IUpdateAfterMaterial (org.papervision3d.core.render.material.IUpdateAfterMaterial)
package org.papervision3d.core.render.material {
import org.papervision3d.core.render.data.*;
public interface IUpdateAfterMaterial {
function updateAfterRender(_arg1:RenderSessionData):void;
}
}//package org.papervision3d.core.render.material
Section 223
//IUpdateBeforeMaterial (org.papervision3d.core.render.material.IUpdateBeforeMaterial)
package org.papervision3d.core.render.material {
import org.papervision3d.core.render.data.*;
public interface IUpdateBeforeMaterial {
function isUpdateable():Boolean;
function updateBeforeRender(_arg1:RenderSessionData):void;
}
}//package org.papervision3d.core.render.material
Section 224
//MaterialManager (org.papervision3d.core.render.material.MaterialManager)
package org.papervision3d.core.render.material {
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.proto.*;
import flash.utils.*;
public class MaterialManager {
private var materials:Dictionary;
private static var instance:MaterialManager;
public function MaterialManager():void{
if (instance){
throw (new Error("Only 1 instance of materialmanager allowed"));
};
init();
}
private function init():void{
materials = new Dictionary(true);
}
private function _unRegisterMaterial(_arg1:MaterialObject3D):void{
delete materials[_arg1];
}
public function updateMaterialsAfterRender(_arg1:RenderSessionData):void{
var _local2:IUpdateAfterMaterial;
var _local3:*;
for (_local3 in materials) {
if ((_local3 is IUpdateAfterMaterial)){
_local2 = (_local3 as IUpdateAfterMaterial);
_local2.updateAfterRender(_arg1);
};
};
}
private function _registerMaterial(_arg1:MaterialObject3D):void{
materials[_arg1] = true;
}
public function updateMaterialsBeforeRender(_arg1:RenderSessionData):void{
var _local2:IUpdateBeforeMaterial;
var _local3:*;
for (_local3 in materials) {
if ((_local3 is IUpdateBeforeMaterial)){
_local2 = (_local3 as IUpdateBeforeMaterial);
if (_local2.isUpdateable()){
_local2.updateBeforeRender(_arg1);
};
};
};
}
public static function getInstance():MaterialManager{
if (!instance){
instance = new (MaterialManager);
};
return (instance);
}
public static function unRegisterMaterial(_arg1:MaterialObject3D):void{
getInstance()._unRegisterMaterial(_arg1);
}
public static function registerMaterial(_arg1:MaterialObject3D):void{
getInstance()._registerMaterial(_arg1);
}
}
}//package org.papervision3d.core.render.material
Section 225
//BasicProjectionPipeline (org.papervision3d.core.render.project.BasicProjectionPipeline)
package org.papervision3d.core.render.project {
import org.papervision3d.objects.*;
import org.papervision3d.core.render.data.*;
public class BasicProjectionPipeline extends ProjectionPipeline {
public function BasicProjectionPipeline(){
init();
}
protected function init():void{
}
override public function project(_arg1:RenderSessionData):void{
var _local3:DisplayObject3D;
var _local5:Number;
_arg1.camera.transformView();
var _local2:Array = _arg1.renderObjects;
var _local4:Number = _local2.length;
if (_arg1.camera.useProjectionMatrix){
for each (_local3 in _local2) {
if (_local3.visible){
if (_arg1.viewPort.viewportObjectFilter){
_local5 = _arg1.viewPort.viewportObjectFilter.testObject(_local3);
if (_local5){
projectObject(_local3, _arg1, _local5);
} else {
_arg1.renderStatistics.filteredObjects++;
};
} else {
projectObject(_local3, _arg1, 1);
};
};
};
} else {
for each (_local3 in _local2) {
if (_local3.visible){
if (_arg1.viewPort.viewportObjectFilter){
_local5 = _arg1.viewPort.viewportObjectFilter.testObject(_local3);
if (_local5){
projectObject(_local3, _arg1, _local5);
} else {
_arg1.renderStatistics.filteredObjects++;
};
} else {
projectObject(_local3, _arg1, 1);
};
};
};
};
}
protected function projectObject(_arg1:DisplayObject3D, _arg2:RenderSessionData, _arg3:Number):void{
_arg1.cullTest = _arg3;
if (_arg1.parent){
_arg1.project((_arg1.parent as DisplayObject3D), _arg2);
} else {
_arg1.project(_arg2.camera, _arg2);
};
}
}
}//package org.papervision3d.core.render.project
Section 226
//ProjectionPipeline (org.papervision3d.core.render.project.ProjectionPipeline)
package org.papervision3d.core.render.project {
import org.papervision3d.core.render.data.*;
public class ProjectionPipeline {
public function project(_arg1:RenderSessionData):void{
}
}
}//package org.papervision3d.core.render.project
Section 227
//IShaderRenderer (org.papervision3d.core.render.shader.IShaderRenderer)
package org.papervision3d.core.render.shader {
import flash.display.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.materials.shaders.*;
public interface IShaderRenderer {
function destroy():void;
function getLayerForShader(_arg1:Shader):Sprite;
function clear():void;
function render(_arg1:RenderSessionData):void;
}
}//package org.papervision3d.core.render.shader
Section 228
//ShaderObjectData (org.papervision3d.core.render.shader.ShaderObjectData)
package org.papervision3d.core.render.shader {
import flash.display.*;
import flash.geom.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.geom.renderables.*;
import flash.utils.*;
import org.papervision3d.materials.*;
import org.papervision3d.materials.shaders.*;
public class ShaderObjectData {
public var shaderRenderer:ShaderRenderer;
public var triangleUVS:Dictionary;
public var renderTriangleUVS:Dictionary;
public var lightMatrices:Dictionary;
public var shadedMaterial:ShadedMaterial;
public var uvMatrices:Dictionary;
private var origin:Point;
public var material:BitmapMaterial;
public var triangleRects:Dictionary;
protected var triangleBitmaps:Dictionary;
public var object:DisplayObject3D;
public function ShaderObjectData(_arg1:DisplayObject3D, _arg2:BitmapMaterial, _arg3:ShadedMaterial):void{
origin = new Point(0, 0);
super();
shaderRenderer = new ShaderRenderer();
lightMatrices = new Dictionary();
uvMatrices = new Dictionary();
this.object = _arg1;
this.material = _arg2;
this.shadedMaterial = _arg3;
triangleUVS = new Dictionary();
renderTriangleUVS = new Dictionary();
triangleBitmaps = new Dictionary();
triangleRects = new Dictionary();
}
public function getPerTriUVForDraw(_arg1:Triangle3D):Matrix{
var _local2:Matrix;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Rectangle;
if (!triangleUVS[_arg1]){
_local2 = (triangleUVS[_arg1] = new Matrix());
_local3 = material.bitmap.width;
_local4 = material.bitmap.height;
_local5 = (_arg1.uv[0].u * _local3);
_local6 = ((1 - _arg1.uv[0].v) * _local4);
_local7 = (_arg1.uv[1].u * _local3);
_local8 = ((1 - _arg1.uv[1].v) * _local4);
_local9 = (_arg1.uv[2].u * _local3);
_local10 = ((1 - _arg1.uv[2].v) * _local4);
_local11 = getRectFor(_arg1);
_local2.tx = (_local5 - _local11.x);
_local2.ty = (_local6 - _local11.y);
_local2.a = (_local7 - _local5);
_local2.b = (_local8 - _local6);
_local2.c = (_local9 - _local5);
_local2.d = (_local10 - _local6);
_local2.invert();
};
return (triangleUVS[_arg1]);
}
public function getRectFor(_arg1:Triangle3D):Rectangle{
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
if (!triangleRects[_arg1]){
_local2 = material.bitmap.width;
_local3 = material.bitmap.height;
_local4 = (_arg1.uv[0].u * _local2);
_local5 = ((1 - _arg1.uv[0].v) * _local3);
_local6 = (_arg1.uv[1].u * _local2);
_local7 = ((1 - _arg1.uv[1].v) * _local3);
_local8 = (_arg1.uv[2].u * _local2);
_local9 = ((1 - _arg1.uv[2].v) * _local3);
_local10 = Math.min(Math.min(_local4, _local6), _local8);
_local11 = Math.min(Math.min(_local5, _local7), _local9);
_local12 = Math.max(Math.max(_local4, _local6), _local8);
_local13 = Math.max(Math.max(_local5, _local7), _local9);
_local14 = (_local12 - _local10);
_local15 = (_local13 - _local11);
if (_local14 <= 0){
_local14 = 1;
};
if (_local15 <= 0){
_local15 = 1;
};
return ((triangleRects[_arg1] = new Rectangle(_local10, _local11, _local14, _local15)));
};
return (triangleRects[_arg1]);
}
private function perturbUVMatrix(_arg1:Matrix, _arg2:Triangle3D, _arg3:Number=2):void{
var _local4:Number = material.bitmap.width;
var _local5:Number = material.bitmap.height;
var _local6:Number = _arg2.uv[0].u;
var _local7:Number = (1 - _arg2.uv[0].v);
var _local8:Number = _arg2.uv[1].u;
var _local9:Number = (1 - _arg2.uv[1].v);
var _local10:Number = _arg2.uv[2].u;
var _local11:Number = (1 - _arg2.uv[2].v);
var _local12:Number = (_local6 * _local4);
var _local13:Number = (_local7 * _local5);
var _local14:Number = (_local8 * _local4);
var _local15:Number = (_local9 * _local5);
var _local16:Number = (_local10 * _local4);
var _local17:Number = (_local11 * _local5);
var _local18:Number = (((_local10 + _local8) + _local6) / 3);
var _local19:Number = (((_local11 + _local9) + _local7) / 3);
var _local20:Number = (_local6 - _local18);
var _local21:Number = (_local7 - _local19);
var _local22:Number = (_local8 - _local18);
var _local23:Number = (_local9 - _local19);
var _local24:Number = (_local10 - _local18);
var _local25:Number = (_local11 - _local19);
var _local26:Number = ((_local20)<0) ? -(_local20) : _local20;
var _local27:Number = ((_local21)<0) ? -(_local21) : _local21;
var _local28:Number = ((_local22)<0) ? -(_local22) : _local22;
var _local29:Number = ((_local23)<0) ? -(_local23) : _local23;
var _local30:Number = ((_local24)<0) ? -(_local24) : _local24;
var _local31:Number = ((_local25)<0) ? -(_local25) : _local25;
var _local32:Number = ((_local26)>_local27) ? (1 / _local26) : (1 / _local27);
var _local33:Number = ((_local28)>_local29) ? (1 / _local28) : (1 / _local29);
var _local34:Number = ((_local30)>_local31) ? (1 / _local30) : (1 / _local31);
_local12 = (_local12 - ((-(_local20) * _local32) * _arg3));
_local13 = (_local13 - ((-(_local21) * _local32) * _arg3));
_local14 = (_local14 - ((-(_local22) * _local33) * _arg3));
_local15 = (_local15 - ((-(_local23) * _local33) * _arg3));
_local16 = (_local16 - ((-(_local24) * _local34) * _arg3));
_local17 = (_local17 - ((-(_local25) * _local34) * _arg3));
_arg1.tx = _local12;
_arg1.ty = _local13;
_arg1.a = (_local14 - _local12);
_arg1.b = (_local15 - _local13);
_arg1.c = (_local16 - _local12);
_arg1.d = (_local17 - _local13);
}
public function getOutputBitmapFor(_arg1:Triangle3D):BitmapData{
var _local2:Rectangle;
var _local3:BitmapData;
var _local4:Rectangle;
if (!triangleBitmaps[_arg1]){
_local2 = getRectFor(_arg1);
_local3 = (triangleBitmaps[_arg1] = new BitmapData(Math.ceil(_local2.width), Math.ceil(_local2.height), false, 0));
_local4 = new Rectangle(0, 0, _local3.width, _local3.height);
_local3.copyPixels(material.bitmap, _local4, origin);
} else {
_local2 = getRectFor(_arg1);
};
if (((material.bitmap) && (_local2))){
triangleBitmaps[_arg1].copyPixels(material.bitmap, _local2, origin);
};
return (triangleBitmaps[_arg1]);
}
public function updateBeforeRender():void{
}
public function getPerTriUVForShader(_arg1:Triangle3D):Matrix{
var _local2:Matrix;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Rectangle;
if (!renderTriangleUVS[_arg1]){
_local2 = (renderTriangleUVS[_arg1] = new Matrix());
_local3 = material.bitmap.width;
_local4 = material.bitmap.height;
_local5 = (_arg1.uv[0].u * _local3);
_local6 = ((1 - _arg1.uv[0].v) * _local4);
_local7 = (_arg1.uv[1].u * _local3);
_local8 = ((1 - _arg1.uv[1].v) * _local4);
_local9 = (_arg1.uv[2].u * _local3);
_local10 = ((1 - _arg1.uv[2].v) * _local4);
_local11 = getRectFor(_arg1);
_local2.tx = (_local5 - _local11.x);
_local2.ty = (_local6 - _local11.y);
_local2.a = (_local7 - _local5);
_local2.b = (_local8 - _local6);
_local2.c = (_local9 - _local5);
_local2.d = (_local10 - _local6);
};
return (renderTriangleUVS[_arg1]);
}
public function getUVMatrixForTriangle(_arg1:Triangle3D, _arg2:Boolean=false):Matrix{
var _local3:Matrix;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
_local3 = uvMatrices[_arg1];
if (!_local3){
_local3 = new Matrix();
if (_arg2){
perturbUVMatrix(_local3, _arg1, 2);
} else {
if (material.bitmap){
_local4 = material.bitmap.width;
_local5 = material.bitmap.height;
_local6 = (_arg1.uv[0].u * _local4);
_local7 = ((1 - _arg1.uv[0].v) * _local5);
_local8 = (_arg1.uv[1].u * _local4);
_local9 = ((1 - _arg1.uv[1].v) * _local5);
_local10 = (_arg1.uv[2].u * _local4);
_local11 = ((1 - _arg1.uv[2].v) * _local5);
_local3.tx = _local6;
_local3.ty = _local7;
_local3.a = (_local8 - _local6);
_local3.b = (_local9 - _local7);
_local3.c = (_local10 - _local6);
_local3.d = (_local11 - _local7);
};
};
if (material.bitmap){
uvMatrices[_arg1] = _local3;
};
};
return (_local3);
}
public function destroy():void{
var _local1:Object;
for each (_local1 in uvMatrices) {
uvMatrices[_local1] = null;
};
uvMatrices = null;
shaderRenderer.destroy();
shaderRenderer = null;
lightMatrices = null;
}
}
}//package org.papervision3d.core.render.shader
Section 229
//ShaderRenderer (org.papervision3d.core.render.shader.ShaderRenderer)
package org.papervision3d.core.render.shader {
import flash.events.*;
import flash.display.*;
import flash.geom.*;
import org.papervision3d.core.render.data.*;
import flash.utils.*;
import org.papervision3d.materials.shaders.*;
public class ShaderRenderer extends EventDispatcher implements IShaderRenderer {
public var container:Sprite;
public var shadeLayers:Dictionary;
public var outputBitmap:BitmapData;
public var bitmapContainer:Bitmap;
public var resizedInput:Boolean;// = false
public var bitmapLayer:Sprite;
private var _inputBitmapData:BitmapData;
public function ShaderRenderer(){
container = new Sprite();
bitmapLayer = new Sprite();
bitmapContainer = new Bitmap();
bitmapLayer.addChild(bitmapContainer);
bitmapLayer.blendMode = BlendMode.NORMAL;
shadeLayers = new Dictionary();
container.addChild(bitmapLayer);
}
public function clear():void{
var _local1:Sprite;
for each (_local1 in shadeLayers) {
if (((((inputBitmap) && ((inputBitmap.width > 0)))) && ((inputBitmap.height > 0)))){
_local1.graphics.clear();
_local1.graphics.beginFill(0, 1);
_local1.graphics.drawRect(0, 0, inputBitmap.width, inputBitmap.height);
_local1.graphics.endFill();
};
};
}
public function render(_arg1:RenderSessionData):void{
if (outputBitmap){
outputBitmap.fillRect(outputBitmap.rect, 0);
bitmapContainer.bitmapData = inputBitmap;
outputBitmap.draw(container, null, null, null, outputBitmap.rect, false);
if (outputBitmap.transparent){
outputBitmap.copyChannel(inputBitmap, outputBitmap.rect, new Point(0, 0), BitmapDataChannel.ALPHA, BitmapDataChannel.ALPHA);
};
};
}
public function get inputBitmap():BitmapData{
return (_inputBitmapData);
}
public function set inputBitmap(_arg1:BitmapData):void{
if (_arg1 != null){
if (_inputBitmapData != _arg1){
_inputBitmapData = _arg1;
if (outputBitmap){
if (((!((_inputBitmapData.width == outputBitmap.width))) || (!((_inputBitmapData.height == outputBitmap.height))))){
resizedInput = true;
outputBitmap.dispose();
outputBitmap = _inputBitmapData.clone();
};
} else {
resizedInput = true;
outputBitmap = _inputBitmapData.clone();
};
};
};
}
public function getLayerForShader(_arg1:Shader):Sprite{
var _local2:Sprite = new Sprite();
shadeLayers[_arg1] = _local2;
var _local3:Sprite = new Sprite();
_local2.addChild(_local3);
if (inputBitmap != null){
_local3.graphics.beginFill(0, 0);
_local3.graphics.drawRect(0, 0, inputBitmap.width, inputBitmap.height);
_local3.graphics.endFill();
};
container.addChild(_local2);
_local2.blendMode = _arg1.layerBlendMode;
return (_local2);
}
public function destroy():void{
bitmapLayer = null;
outputBitmap.dispose();
}
}
}//package org.papervision3d.core.render.shader
Section 230
//BasicRenderSorter (org.papervision3d.core.render.sort.BasicRenderSorter)
package org.papervision3d.core.render.sort {
public class BasicRenderSorter implements IRenderSorter {
public function sort(_arg1:Array):void{
_arg1.sortOn("screenZ", Array.NUMERIC);
}
}
}//package org.papervision3d.core.render.sort
Section 231
//IRenderSorter (org.papervision3d.core.render.sort.IRenderSorter)
package org.papervision3d.core.render.sort {
public interface IRenderSorter {
function sort(_arg1:Array):void;
}
}//package org.papervision3d.core.render.sort
Section 232
//AbstractRenderEngine (org.papervision3d.core.render.AbstractRenderEngine)
package org.papervision3d.core.render {
import flash.events.*;
import org.papervision3d.view.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.render.command.*;
import org.papervision3d.core.proto.*;
public class AbstractRenderEngine extends EventDispatcher implements IRenderEngine {
public function AbstractRenderEngine(_arg1:IEventDispatcher=null){
super(_arg1);
}
public function addToRenderList(_arg1:RenderableListItem):int{
return (0);
}
public function removeFromRenderList(_arg1:IRenderListItem):int{
return (0);
}
public function renderScene(_arg1:SceneObject3D, _arg2:CameraObject3D, _arg3:Viewport3D):RenderStatistics{
return (null);
}
}
}//package org.papervision3d.core.render
Section 233
//IRenderEngine (org.papervision3d.core.render.IRenderEngine)
package org.papervision3d.core.render {
import org.papervision3d.view.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.render.command.*;
import org.papervision3d.core.proto.*;
public interface IRenderEngine {
function addToRenderList(_arg1:RenderableListItem):int;
function removeFromRenderList(_arg1:IRenderListItem):int;
function renderScene(_arg1:SceneObject3D, _arg2:CameraObject3D, _arg3:Viewport3D):RenderStatistics;
}
}//package org.papervision3d.core.render
Section 234
//IVirtualMouseEvent (org.papervision3d.core.utils.virtualmouse.IVirtualMouseEvent)
package org.papervision3d.core.utils.virtualmouse {
public interface IVirtualMouseEvent {
}
}//package org.papervision3d.core.utils.virtualmouse
Section 235
//VirtualMouse (org.papervision3d.core.utils.virtualmouse.VirtualMouse)
package org.papervision3d.core.utils.virtualmouse {
import flash.events.*;
import flash.display.*;
import flash.geom.*;
import flash.utils.*;
import org.papervision3d.core.log.*;
public class VirtualMouse extends EventDispatcher {
private var _container:Sprite;
private var _stage:Stage;
private var lastDownTarget:DisplayObject;
private var target:InteractiveObject;
private var updateMouseDown:Boolean;// = false
private var eventEvent:Class;
private var _lastEvent:Event;
private var mouseEventEvent:Class;
private var location:Point;
private var delta:int;// = 0
private var disabledEvents:Object;
private var ignoredInstances:Dictionary;
private var isLocked:Boolean;// = false
private var lastWithinStage:Boolean;// = true
private var lastLocation:Point;
private var isDoubleClickEvent:Boolean;// = false
private var lastMouseDown:Boolean;// = false
private var ctrlKey:Boolean;// = false
private var altKey:Boolean;// = false
private var _useNativeEvents:Boolean;// = false
private var shiftKey:Boolean;// = false
public static const UPDATE:String = "update";
private static var _mouseIsDown:Boolean = false;
public function VirtualMouse(_arg1:Stage=null, _arg2:Sprite=null, _arg3:Number=0, _arg4:Number=0){
disabledEvents = new Object();
ignoredInstances = new Dictionary(true);
eventEvent = VirtualMouseEvent;
mouseEventEvent = VirtualMouseMouseEvent;
super();
this.stage = _arg1;
this.container = _arg2;
location = new Point(_arg3, _arg4);
lastLocation = location.clone();
addEventListener(UPDATE, handleUpdate);
update();
}
public function get mouseIsDown():Boolean{
return (_mouseIsDown);
}
public function get container():Sprite{
return (_container);
}
public function exitContainer():void{
if (!container){
return;
};
var _local1:Point = target.globalToLocal(location);
if (!disabledEvents[MouseEvent.MOUSE_OUT]){
_lastEvent = new mouseEventEvent(MouseEvent.MOUSE_OUT, true, false, _local1.x, _local1.y, container, ctrlKey, altKey, shiftKey, _mouseIsDown, delta);
container.dispatchEvent(new mouseEventEvent(MouseEvent.MOUSE_OUT, true, false, _local1.x, _local1.y, container, ctrlKey, altKey, shiftKey, _mouseIsDown, delta));
dispatchEvent(new mouseEventEvent(MouseEvent.MOUSE_OUT, true, false, _local1.x, _local1.y, container, ctrlKey, altKey, shiftKey, _mouseIsDown, delta));
};
if (!disabledEvents[MouseEvent.ROLL_OUT]){
_lastEvent = new mouseEventEvent(MouseEvent.ROLL_OUT, false, false, _local1.x, _local1.y, container, ctrlKey, altKey, shiftKey, _mouseIsDown, delta);
container.dispatchEvent(new mouseEventEvent(MouseEvent.ROLL_OUT, false, false, _local1.x, _local1.y, container, ctrlKey, altKey, shiftKey, _mouseIsDown, delta));
dispatchEvent(new mouseEventEvent(MouseEvent.ROLL_OUT, false, false, _local1.x, _local1.y, container, ctrlKey, altKey, shiftKey, _mouseIsDown, delta));
};
if (target != container){
if (!disabledEvents[MouseEvent.MOUSE_OUT]){
_lastEvent = new mouseEventEvent(MouseEvent.MOUSE_OUT, true, false, _local1.x, _local1.y, container, ctrlKey, altKey, shiftKey, _mouseIsDown, delta);
target.dispatchEvent(new mouseEventEvent(MouseEvent.MOUSE_OUT, true, false, _local1.x, _local1.y, container, ctrlKey, altKey, shiftKey, _mouseIsDown, delta));
dispatchEvent(new mouseEventEvent(MouseEvent.MOUSE_OUT, true, false, _local1.x, _local1.y, container, ctrlKey, altKey, shiftKey, _mouseIsDown, delta));
};
if (!disabledEvents[MouseEvent.ROLL_OUT]){
_lastEvent = new mouseEventEvent(MouseEvent.ROLL_OUT, false, false, _local1.x, _local1.y, container, ctrlKey, altKey, shiftKey, _mouseIsDown, delta);
target.dispatchEvent(new mouseEventEvent(MouseEvent.ROLL_OUT, false, false, _local1.x, _local1.y, container, ctrlKey, altKey, shiftKey, _mouseIsDown, delta));
dispatchEvent(new mouseEventEvent(MouseEvent.ROLL_OUT, false, false, _local1.x, _local1.y, container, ctrlKey, altKey, shiftKey, _mouseIsDown, delta));
};
};
target = _stage;
}
public function release():void{
updateMouseDown = true;
_mouseIsDown = false;
if (!isLocked){
update();
};
}
private function keyHandler(_arg1:KeyboardEvent):void{
altKey = _arg1.altKey;
ctrlKey = _arg1.ctrlKey;
shiftKey = _arg1.shiftKey;
}
public function click():void{
press();
release();
}
public function disableEvent(_arg1:String):void{
disabledEvents[_arg1] = true;
}
public function set container(_arg1:Sprite):void{
_container = _arg1;
}
public function get lastEvent():Event{
return (_lastEvent);
}
private function handleUpdate(_arg1:Event):void{
var _local4:InteractiveObject;
var _local5:DisplayObject;
var _local9:Boolean;
if (!container){
return;
};
if (container.scrollRect){
PaperLogger.warning("The container that virtualMouse is trying to test against has a scrollRect defined, and may cause an issue with finding objects under a defined point. Use MovieMaterial.rect to set a rectangle area instead");
};
var _local2:Point = new Point();
_local2.x = container.x;
_local2.y = container.y;
container.x = (container.y = 0);
var _local3:Array = container.getObjectsUnderPoint(location);
container.x = _local2.x;
container.y = _local2.y;
var _local6:int = _local3.length;
while (_local6--) {
_local5 = _local3[_local6];
while (_local5) {
if (ignoredInstances[_local5]){
_local4 = null;
break;
};
if (((_local4) && ((_local5 is SimpleButton)))){
_local4 = null;
} else {
if (((_local4) && (!(DisplayObjectContainer(_local5).mouseChildren)))){
_local4 = null;
};
};
if (((((!(_local4)) && ((_local5 is InteractiveObject)))) && (InteractiveObject(_local5).mouseEnabled))){
_local4 = InteractiveObject(_local5);
};
_local5 = _local5.parent;
};
if (_local4){
break;
};
};
if (!_local4){
_local4 = _stage;
};
var _local7:Point = target.globalToLocal(location);
var _local8:Point = _local4.globalToLocal(location);
if (((!((lastLocation.x == location.x))) || (!((lastLocation.y == location.y))))){
_local9 = false;
if (stage){
_local9 = (((((((location.x >= 0)) && ((location.y >= 0)))) && ((location.x <= stage.stageWidth)))) && ((location.y <= stage.stageHeight)));
};
if (((((!(_local9)) && (lastWithinStage))) && (!(disabledEvents[Event.MOUSE_LEAVE])))){
_lastEvent = new eventEvent(Event.MOUSE_LEAVE, false, false);
stage.dispatchEvent(_lastEvent);
dispatchEvent(_lastEvent);
};
if (((_local9) && (!(disabledEvents[MouseEvent.MOUSE_MOVE])))){
_lastEvent = new mouseEventEvent(MouseEvent.MOUSE_MOVE, true, false, _local8.x, _local8.y, _local4, ctrlKey, altKey, shiftKey, _mouseIsDown, delta);
_local4.dispatchEvent(_lastEvent);
dispatchEvent(_lastEvent);
};
lastWithinStage = _local9;
};
if (_local4 != target){
if (!disabledEvents[MouseEvent.MOUSE_OUT]){
_lastEvent = new mouseEventEvent(MouseEvent.MOUSE_OUT, true, false, _local7.x, _local7.y, _local4, ctrlKey, altKey, shiftKey, _mouseIsDown, delta);
target.dispatchEvent(_lastEvent);
dispatchEvent(_lastEvent);
};
if (!disabledEvents[MouseEvent.ROLL_OUT]){
_lastEvent = new mouseEventEvent(MouseEvent.ROLL_OUT, false, false, _local7.x, _local7.y, _local4, ctrlKey, altKey, shiftKey, _mouseIsDown, delta);
target.dispatchEvent(_lastEvent);
dispatchEvent(_lastEvent);
};
if (!disabledEvents[MouseEvent.MOUSE_OVER]){
_lastEvent = new mouseEventEvent(MouseEvent.MOUSE_OVER, true, false, _local8.x, _local8.y, target, ctrlKey, altKey, shiftKey, _mouseIsDown, delta);
_local4.dispatchEvent(_lastEvent);
dispatchEvent(_lastEvent);
};
if (!disabledEvents[MouseEvent.ROLL_OVER]){
_lastEvent = new mouseEventEvent(MouseEvent.ROLL_OVER, false, false, _local8.x, _local8.y, target, ctrlKey, altKey, shiftKey, _mouseIsDown, delta);
_local4.dispatchEvent(_lastEvent);
dispatchEvent(_lastEvent);
};
};
if (updateMouseDown){
if (_mouseIsDown){
if (!disabledEvents[MouseEvent.MOUSE_DOWN]){
_lastEvent = new mouseEventEvent(MouseEvent.MOUSE_DOWN, true, false, _local8.x, _local8.y, _local4, ctrlKey, altKey, shiftKey, _mouseIsDown, delta);
_local4.dispatchEvent(_lastEvent);
dispatchEvent(_lastEvent);
};
lastDownTarget = _local4;
updateMouseDown = false;
} else {
if (!disabledEvents[MouseEvent.MOUSE_UP]){
_lastEvent = new mouseEventEvent(MouseEvent.MOUSE_UP, true, false, _local8.x, _local8.y, _local4, ctrlKey, altKey, shiftKey, _mouseIsDown, delta);
_local4.dispatchEvent(_lastEvent);
dispatchEvent(_lastEvent);
};
if (((!(disabledEvents[MouseEvent.CLICK])) && ((_local4 == lastDownTarget)))){
_lastEvent = new mouseEventEvent(MouseEvent.CLICK, true, false, _local8.x, _local8.y, _local4, ctrlKey, altKey, shiftKey, _mouseIsDown, delta);
_local4.dispatchEvent(_lastEvent);
dispatchEvent(_lastEvent);
};
lastDownTarget = null;
updateMouseDown = false;
};
};
if (((((isDoubleClickEvent) && (!(disabledEvents[MouseEvent.DOUBLE_CLICK])))) && (_local4.doubleClickEnabled))){
_lastEvent = new mouseEventEvent(MouseEvent.DOUBLE_CLICK, true, false, _local8.x, _local8.y, _local4, ctrlKey, altKey, shiftKey, _mouseIsDown, delta);
_local4.dispatchEvent(_lastEvent);
dispatchEvent(_lastEvent);
};
lastLocation = location.clone();
lastMouseDown = _mouseIsDown;
target = _local4;
}
public function getLocation():Point{
return (location.clone());
}
public function lock():void{
isLocked = true;
}
public function get useNativeEvents():Boolean{
return (_useNativeEvents);
}
public function setLocation(_arg1, _arg2=null):void{
var _local3:Point;
if ((_arg1 is Point)){
_local3 = (_arg1 as Point);
location.x = _local3.x;
location.y = _local3.y;
} else {
location.x = Number(_arg1);
location.y = Number(_arg2);
};
if (!isLocked){
update();
};
}
public function unignore(_arg1:DisplayObject):void{
if ((_arg1 in ignoredInstances)){
delete ignoredInstances[_arg1];
};
}
public function doubleClick():void{
if (isLocked){
release();
} else {
click();
press();
isDoubleClickEvent = true;
release();
isDoubleClickEvent = false;
};
}
public function update():void{
dispatchEvent(new Event(UPDATE, false, false));
}
public function unlock():void{
isLocked = false;
update();
}
public function ignore(_arg1:DisplayObject):void{
ignoredInstances[_arg1] = true;
}
public function enableEvent(_arg1:String):void{
if ((_arg1 in disabledEvents)){
delete disabledEvents[_arg1];
};
}
public function press():void{
updateMouseDown = true;
_mouseIsDown = true;
if (!isLocked){
update();
};
}
public function set useNativeEvents(_arg1:Boolean):void{
if (_arg1 == _useNativeEvents){
return;
};
_useNativeEvents = _arg1;
if (_useNativeEvents){
eventEvent = VirtualMouseEvent;
mouseEventEvent = VirtualMouseMouseEvent;
} else {
eventEvent = Event;
mouseEventEvent = MouseEvent;
};
}
public function set x(_arg1:Number):void{
location.x = _arg1;
if (!isLocked){
update();
};
}
public function set y(_arg1:Number):void{
location.y = _arg1;
if (!isLocked){
update();
};
}
public function get y():Number{
return (location.y);
}
public function set stage(_arg1:Stage):void{
var _local2:Boolean;
if (_stage){
_local2 = true;
_stage.removeEventListener(KeyboardEvent.KEY_DOWN, keyHandler);
_stage.removeEventListener(KeyboardEvent.KEY_UP, keyHandler);
} else {
_local2 = false;
};
_stage = _arg1;
if (_stage){
_stage.addEventListener(KeyboardEvent.KEY_DOWN, keyHandler);
_stage.addEventListener(KeyboardEvent.KEY_UP, keyHandler);
target = _stage;
if (!_local2){
update();
};
};
}
public function get stage():Stage{
return (_stage);
}
public function get x():Number{
return (location.x);
}
}
}//package org.papervision3d.core.utils.virtualmouse
Section 236
//VirtualMouseEvent (org.papervision3d.core.utils.virtualmouse.VirtualMouseEvent)
package org.papervision3d.core.utils.virtualmouse {
import flash.events.*;
public class VirtualMouseEvent extends Event implements IVirtualMouseEvent {
public function VirtualMouseEvent(_arg1:String, _arg2:Boolean=false, _arg3:Boolean=false){
super(_arg1, _arg2, _arg3);
}
}
}//package org.papervision3d.core.utils.virtualmouse
Section 237
//VirtualMouseMouseEvent (org.papervision3d.core.utils.virtualmouse.VirtualMouseMouseEvent)
package org.papervision3d.core.utils.virtualmouse {
import flash.events.*;
import flash.display.*;
public class VirtualMouseMouseEvent extends MouseEvent implements IVirtualMouseEvent {
public function VirtualMouseMouseEvent(_arg1:String, _arg2:Boolean=false, _arg3:Boolean=false, _arg4:Number=NaN, _arg5:Number=NaN, _arg6:InteractiveObject=null, _arg7:Boolean=false, _arg8:Boolean=false, _arg9:Boolean=false, _arg10:Boolean=false, _arg11:int=0){
super(_arg1, _arg2, _arg3, _arg4, _arg5, _arg6, _arg7, _arg8, _arg9, _arg10, _arg11);
}
}
}//package org.papervision3d.core.utils.virtualmouse
Section 238
//InteractiveSceneManager (org.papervision3d.core.utils.InteractiveSceneManager)
package org.papervision3d.core.utils {
import flash.events.*;
import flash.display.*;
import org.papervision3d.events.*;
import flash.geom.*;
import org.papervision3d.view.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.materials.*;
import org.papervision3d.core.utils.virtualmouse.*;
public class InteractiveSceneManager extends EventDispatcher {
public var currentMaterial:MaterialObject3D;
public var container:Sprite;
public var currentMousePos:Point;
public var debug:Boolean;// = false
public var mouse3D:Mouse3D;
public var enableOverOut:Boolean;// = true
public var currentDisplayObject3D:DisplayObject3D;
public var _viewportRendered:Boolean;// = false
public var virtualMouse:VirtualMouse;
public var lastMousePos:Point;
public var viewport:Viewport3D;
public var renderHitData:RenderHitData;
public var currentMouseDO3D:DisplayObject3D;// = null
public static var MOUSE_IS_DOWN:Boolean = false;
public function InteractiveSceneManager(_arg1:Viewport3D){
virtualMouse = new VirtualMouse();
mouse3D = new Mouse3D();
currentMousePos = new Point();
lastMousePos = new Point();
super();
this.viewport = _arg1;
this.container = _arg1.containerSprite;
init();
}
protected function handleMouseClick(_arg1:MouseEvent):void{
if ((_arg1 is IVirtualMouseEvent)){
return;
};
if (((renderHitData) && (renderHitData.hasHit))){
dispatchObjectEvent(InteractiveScene3DEvent.OBJECT_CLICK, currentDisplayObject3D);
};
}
protected function handleEnterFrame(_arg1:Event):void{
var _local3:MovieMaterial;
currentMousePos.x = container.mouseX;
currentMousePos.y = container.mouseY;
var _local2 = !(currentMousePos.equals(lastMousePos));
if (((_local2) || (_viewportRendered))){
updateRenderHitData();
_viewportRendered = false;
if ((_arg1 is IVirtualMouseEvent)){
return;
};
if (((virtualMouse) && (renderHitData))){
_local3 = (currentMaterial as MovieMaterial);
if (_local3){
virtualMouse.container = (_local3.movie as Sprite);
};
if (virtualMouse.container){
virtualMouse.setLocation(renderHitData.u, renderHitData.v);
};
if (((((Mouse3D.enabled) && (renderHitData))) && (renderHitData.hasHit))){
mouse3D.updatePosition(renderHitData);
};
dispatchObjectEvent(InteractiveScene3DEvent.OBJECT_MOVE, currentDisplayObject3D);
} else {
if (((renderHitData) && (renderHitData.hasHit))){
dispatchObjectEvent(InteractiveScene3DEvent.OBJECT_MOVE, currentDisplayObject3D);
};
};
};
lastMousePos.x = currentMousePos.x;
lastMousePos.y = currentMousePos.y;
}
public function updateAfterRender():void{
_viewportRendered = true;
}
public function initListeners():void{
if (viewport.interactive){
container.addEventListener(MouseEvent.MOUSE_DOWN, handleMousePress, false, 0, true);
container.addEventListener(MouseEvent.MOUSE_UP, handleMouseRelease, false, 0, true);
container.addEventListener(MouseEvent.CLICK, handleMouseClick, false, 0, true);
container.addEventListener(MouseEvent.DOUBLE_CLICK, handleMouseDoubleClick, false, 0, true);
container.stage.addEventListener(Event.ENTER_FRAME, handleEnterFrame);
};
}
protected function initVirtualMouse():void{
virtualMouse.stage = container.stage;
virtualMouse.container = container;
}
protected function handleMouseOver(_arg1:DisplayObject3D):void{
dispatchObjectEvent(InteractiveScene3DEvent.OBJECT_OVER, _arg1);
}
protected function resolveRenderHitData():void{
renderHitData = (viewport.hitTestPoint2D(currentMousePos) as RenderHitData);
}
public function updateRenderHitData():void{
resolveRenderHitData();
currentDisplayObject3D = renderHitData.displayObject3D;
currentMaterial = renderHitData.material;
manageOverOut();
}
protected function dispatchObjectEvent(_arg1:String, _arg2:DisplayObject3D):void{
var _local3:Number;
var _local4:Number;
var _local5:InteractiveScene3DEvent;
if (((renderHitData) && (renderHitData.hasHit))){
_local3 = (renderHitData.u) ? renderHitData.u : 0;
_local4 = (renderHitData.v) ? renderHitData.v : 0;
_local5 = new InteractiveScene3DEvent(_arg1, _arg2, container, (renderHitData.renderable as Triangle3D), _local3, _local4, renderHitData);
_local5.renderHitData = renderHitData;
dispatchEvent(_local5);
_arg2.dispatchEvent(_local5);
} else {
dispatchEvent(new InteractiveScene3DEvent(_arg1, _arg2, container));
if (_arg2){
_arg2.dispatchEvent(new InteractiveScene3DEvent(_arg1, _arg2, container));
};
};
}
protected function handleMouseDoubleClick(_arg1:MouseEvent):void{
if ((_arg1 is IVirtualMouseEvent)){
return;
};
if (((renderHitData) && (renderHitData.hasHit))){
dispatchObjectEvent(InteractiveScene3DEvent.OBJECT_DOUBLE_CLICK, currentDisplayObject3D);
};
}
protected function handleMouseRelease(_arg1:MouseEvent):void{
if ((_arg1 is IVirtualMouseEvent)){
return;
};
MOUSE_IS_DOWN = false;
if (virtualMouse){
virtualMouse.release();
};
if (((((Mouse3D.enabled) && (renderHitData))) && (!((renderHitData.renderable == null))))){
mouse3D.updatePosition(renderHitData);
};
if (((renderHitData) && (renderHitData.hasHit))){
dispatchObjectEvent(InteractiveScene3DEvent.OBJECT_RELEASE, currentDisplayObject3D);
};
}
protected function handleAddedToStage(_arg1:Event):void{
initVirtualMouse();
initListeners();
}
protected function handleMouseOut(_arg1:DisplayObject3D):void{
var _local2:MovieMaterial;
if (_arg1){
_local2 = (_arg1.material as MovieMaterial);
if (_local2){
virtualMouse.exitContainer();
};
};
dispatchObjectEvent(InteractiveScene3DEvent.OBJECT_OUT, _arg1);
}
protected function manageOverOut():void{
if (!enableOverOut){
return;
};
if (((renderHitData) && (renderHitData.hasHit))){
if (((!(currentMouseDO3D)) && (currentDisplayObject3D))){
handleMouseOver(currentDisplayObject3D);
currentMouseDO3D = currentDisplayObject3D;
} else {
if (((currentMouseDO3D) && (!((currentMouseDO3D == currentDisplayObject3D))))){
handleMouseOut(currentMouseDO3D);
handleMouseOver(currentDisplayObject3D);
currentMouseDO3D = currentDisplayObject3D;
};
};
} else {
if (currentMouseDO3D != null){
handleMouseOut(currentMouseDO3D);
currentMouseDO3D = null;
};
};
}
public function destroy():void{
viewport = null;
renderHitData = null;
currentDisplayObject3D = null;
currentMaterial = null;
currentMouseDO3D = null;
virtualMouse.stage = null;
virtualMouse.container = null;
container.removeEventListener(MouseEvent.MOUSE_DOWN, handleMousePress);
container.removeEventListener(MouseEvent.MOUSE_UP, handleMouseRelease);
container.removeEventListener(MouseEvent.CLICK, handleMouseClick);
container.removeEventListener(MouseEvent.DOUBLE_CLICK, handleMouseDoubleClick);
if (container.stage){
container.stage.removeEventListener(Event.ENTER_FRAME, handleEnterFrame);
};
container = null;
}
public function init():void{
if (container){
if (container.stage){
initVirtualMouse();
initListeners();
} else {
container.addEventListener(Event.ADDED_TO_STAGE, handleAddedToStage);
};
};
}
protected function handleMousePress(_arg1:MouseEvent):void{
if ((_arg1 is IVirtualMouseEvent)){
return;
};
MOUSE_IS_DOWN = true;
if (virtualMouse){
virtualMouse.press();
};
if (((((Mouse3D.enabled) && (renderHitData))) && (!((renderHitData.renderable == null))))){
mouse3D.updatePosition(renderHitData);
};
if (((renderHitData) && (renderHitData.hasHit))){
dispatchObjectEvent(InteractiveScene3DEvent.OBJECT_PRESS, currentDisplayObject3D);
};
}
}
}//package org.papervision3d.core.utils
Section 239
//Mouse3D (org.papervision3d.core.utils.Mouse3D)
package org.papervision3d.core.utils {
import org.papervision3d.objects.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.math.*;
public class Mouse3D extends DisplayObject3D {
private var target:Number3D;
public static var enabled:Boolean = false;
private static var UP:Number3D = new Number3D(0, 1, 0);
public function Mouse3D():void{
target = new Number3D();
super();
}
public function updatePosition(_arg1:RenderHitData):void{
var _local5:Number3D;
var _local6:Number3D;
var _local7:Matrix3D;
var _local2:Triangle3D = (_arg1.renderable as Triangle3D);
target.x = _local2.faceNormal.x;
target.y = _local2.faceNormal.y;
target.z = _local2.faceNormal.z;
var _local3:Number3D = Number3D.sub(target, position);
_local3.normalize();
if (_local3.modulo > 0.1){
_local5 = Number3D.cross(_local3, UP);
_local5.normalize();
_local6 = Number3D.cross(_local3, _local5);
_local6.normalize();
_local7 = this.transform;
_local7.n11 = _local5.x;
_local7.n21 = _local5.y;
_local7.n31 = _local5.z;
_local7.n12 = -(_local6.x);
_local7.n22 = -(_local6.y);
_local7.n32 = -(_local6.z);
_local7.n13 = _local3.x;
_local7.n23 = _local3.y;
_local7.n33 = _local3.z;
};
var _local4:Matrix3D = Matrix3D.IDENTITY;
this.transform = Matrix3D.multiply(_local2.instance.world, _local7);
x = _arg1.x;
y = _arg1.y;
z = _arg1.z;
}
}
}//package org.papervision3d.core.utils
Section 240
//StopWatch (org.papervision3d.core.utils.StopWatch)
package org.papervision3d.core.utils {
import flash.events.*;
import flash.utils.*;
public class StopWatch extends EventDispatcher {
private var startTime:int;
private var elapsedTime:int;
private var isRunning:Boolean;
private var stopTime:int;
public function start():void{
if (!isRunning){
startTime = getTimer();
isRunning = true;
};
}
public function stop():int{
if (isRunning){
stopTime = getTimer();
elapsedTime = (stopTime - startTime);
isRunning = false;
return (elapsedTime);
};
return (0);
}
public function reset():void{
isRunning = false;
}
}
}//package org.papervision3d.core.utils
Section 241
//IViewport3D (org.papervision3d.core.view.IViewport3D)
package org.papervision3d.core.view {
import org.papervision3d.core.render.data.*;
public interface IViewport3D {
function updateAfterRender(_arg1:RenderSessionData):void;
function updateBeforeRender(_arg1:RenderSessionData):void;
}
}//package org.papervision3d.core.view
Section 242
//AnimationEvent (org.papervision3d.events.AnimationEvent)
package org.papervision3d.events {
import flash.events.*;
public class AnimationEvent extends Event {
public var message:String;// = ""
public var totalFrames:uint;
public var currentFrame:uint;
public var dataObj:Object;// = null
public static const ANIMATION_COMPLETE:String = "animationComplete";
public static const ANIMATION_NEXT_FRAME:String = "animationNextFrame";
public static const ANIMATION_ERROR:String = "animationError";
public function AnimationEvent(_arg1:String, _arg2:uint, _arg3:uint, _arg4:String="", _arg5:Object=null, _arg6:Boolean=false, _arg7:Boolean=false){
super(_arg1, _arg6, _arg7);
this.currentFrame = _arg2;
this.totalFrames = _arg3;
this.message = _arg4;
this.dataObj = _arg5;
}
override public function clone():Event{
return (new AnimationEvent(type, currentFrame, totalFrames, message, dataObj, bubbles, cancelable));
}
}
}//package org.papervision3d.events
Section 243
//FileLoadEvent (org.papervision3d.events.FileLoadEvent)
package org.papervision3d.events {
import flash.events.*;
public class FileLoadEvent extends Event {
public var bytesLoaded:Number;// = -1
public var bytesTotal:Number;// = -1
public var file:String;// = ""
public var dataObj:Object;// = null
public var message:String;// = ""
public static const COLLADA_MATERIALS_DONE:String = "colladaMaterialsDone";
public static const LOAD_PROGRESS:String = "loadProgress";
public static const ANIMATIONS_COMPLETE:String = "animationsComplete";
public static const SECURITY_LOAD_ERROR:String = "securityLoadError";
public static const LOAD_ERROR:String = "loadError";
public static const LOAD_COMPLETE:String = "loadComplete";
public static const ANIMATIONS_PROGRESS:String = "animationsProgress";
public function FileLoadEvent(_arg1:String, _arg2:String="", _arg3:Number=-1, _arg4:Number=-1, _arg5:String="", _arg6:Object=null, _arg7:Boolean=false, _arg8:Boolean=false){
super(_arg1, _arg7, _arg8);
this.file = _arg2;
this.bytesLoaded = _arg3;
this.bytesTotal = _arg4;
this.message = _arg5;
this.dataObj = _arg6;
}
override public function clone():Event{
return (new FileLoadEvent(type, file, bytesLoaded, bytesTotal, message, dataObj, bubbles, cancelable));
}
}
}//package org.papervision3d.events
Section 244
//InteractiveScene3DEvent (org.papervision3d.events.InteractiveScene3DEvent)
package org.papervision3d.events {
import flash.events.*;
import flash.display.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.render.data.*;
public class InteractiveScene3DEvent extends Event {
public var y:Number;// = 0
public var sprite:Sprite;// = null
public var renderHitData:RenderHitData;
public var face3d:Triangle3D;// = null
public var x:Number;// = 0
public var displayObject3D:DisplayObject3D;// = null
public static const OBJECT_ADDED:String = "objectAdded";
public static const OBJECT_PRESS:String = "mousePress";
public static const OBJECT_RELEASE:String = "mouseRelease";
public static const OBJECT_CLICK:String = "mouseClick";
public static const OBJECT_RELEASE_OUTSIDE:String = "mouseReleaseOutside";
public static const OBJECT_OUT:String = "mouseOut";
public static const OBJECT_MOVE:String = "mouseMove";
public static const OBJECT_OVER:String = "mouseOver";
public static const OBJECT_DOUBLE_CLICK:String = "mouseDoubleClick";
public function InteractiveScene3DEvent(_arg1:String, _arg2:DisplayObject3D=null, _arg3:Sprite=null, _arg4:Triangle3D=null, _arg5:Number=0, _arg6:Number=0, _arg7:RenderHitData=null, _arg8:Boolean=false, _arg9:Boolean=false){
super(_arg1, _arg8, _arg9);
this.displayObject3D = _arg2;
this.sprite = _arg3;
this.face3d = _arg4;
this.x = _arg5;
this.y = _arg6;
this.renderHitData = _arg7;
}
override public function toString():String{
return (((((((("Type : " + type) + ", DO3D : ") + displayObject3D) + " Sprite : ") + sprite) + " Face : ") + face3d));
}
}
}//package org.papervision3d.events
Section 245
//RendererEvent (org.papervision3d.events.RendererEvent)
package org.papervision3d.events {
import flash.events.*;
import org.papervision3d.core.render.data.*;
public class RendererEvent extends Event {
public var renderSessionData:RenderSessionData;
public static const PROJECTION_DONE:String = "projectionDone";
public static const RENDER_DONE:String = "renderDone";
public function RendererEvent(_arg1:String, _arg2:RenderSessionData){
super(_arg1);
this.renderSessionData = _arg2;
}
public function clear():void{
renderSessionData = null;
}
override public function clone():Event{
return (new RendererEvent(type, renderSessionData));
}
}
}//package org.papervision3d.events
Section 246
//PointLight3D (org.papervision3d.lights.PointLight3D)
package org.papervision3d.lights {
import org.papervision3d.core.proto.*;
import org.papervision3d.core.math.*;
public class PointLight3D extends LightObject3D {
public static var DEFAULT_POS:Number3D = new Number3D(0, 0, -1000);
public function PointLight3D(_arg1:Boolean=false, _arg2:Boolean=false){
super(_arg1, _arg2);
x = DEFAULT_POS.x;
y = DEFAULT_POS.y;
z = DEFAULT_POS.z;
}
}
}//package org.papervision3d.lights
Section 247
//FlatShadeMaterial (org.papervision3d.materials.shadematerials.FlatShadeMaterial)
package org.papervision3d.materials.shadematerials {
import flash.display.*;
import flash.geom.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.render.command.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.core.math.*;
import org.papervision3d.materials.utils.*;
import org.papervision3d.core.render.draw.*;
import org.papervision3d.core.material.*;
public class FlatShadeMaterial extends AbstractLightShadeMaterial implements ITriangleDrawer {
protected var _colors:Array;
private static var zd:Number;
private static var y0:Number;
private static var x0:Number;
private static var zAngle:int;
private static var currentColor:int;
public function FlatShadeMaterial(_arg1:LightObject3D, _arg2:uint=0xFFFFFF, _arg3:uint=0, _arg4:uint=0){
this.fillAlpha = 1;
this.light = _arg1;
_colors = LightMaps.getFlatMapArray(_arg2, _arg3, _arg4);
}
override public function drawTriangle(_arg1:RenderTriangle, _arg2:Graphics, _arg3:RenderSessionData, _arg4:BitmapData=null, _arg5:Matrix=null):void{
var _local6:Triangle3D;
_local6 = _arg1.triangle;
lightMatrix = Matrix3D(lightMatrices[_local6.instance]);
zd = (((_local6.faceNormal.x * lightMatrix.n31) + (_local6.faceNormal.y * lightMatrix.n32)) + (_local6.faceNormal.z * lightMatrix.n33));
if (zd < 0){
if (doubleSided == false){
zd = 0;
} else {
zd = Math.abs(zd);
};
};
x0 = _arg1.v0.x;
y0 = _arg1.v0.y;
zAngle = (zd * 0xFF);
currentColor = _colors[zAngle];
_arg2.beginFill(currentColor, fillAlpha);
_arg2.moveTo(x0, y0);
_arg2.lineTo(_arg1.v1.x, _arg1.v1.y);
_arg2.lineTo(_arg1.v2.x, _arg1.v2.y);
_arg2.lineTo(x0, y0);
_arg2.endFill();
_arg3.renderStatistics.shadedTriangles++;
}
}
}//package org.papervision3d.materials.shadematerials
Section 248
//GouraudMaterial (org.papervision3d.materials.shadematerials.GouraudMaterial)
package org.papervision3d.materials.shadematerials {
import flash.display.*;
import flash.geom.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.render.command.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.core.math.*;
import org.papervision3d.materials.utils.*;
import org.papervision3d.core.render.material.*;
import org.papervision3d.core.render.draw.*;
import org.papervision3d.core.material.*;
public class GouraudMaterial extends AbstractSmoothShadeMaterial implements ITriangleDrawer, IUpdateBeforeMaterial {
private var gouraudMap:BitmapData;
public function GouraudMaterial(_arg1:LightObject3D, _arg2:uint=0xFFFFFF, _arg3:uint=0, _arg4:uint=0){
this.light = _arg1;
gouraudMap = LightMaps.getGouraudMaterialMap(_arg2, _arg3, _arg4);
}
override public function drawTriangle(_arg1:RenderTriangle, _arg2:Graphics, _arg3:RenderSessionData, _arg4:BitmapData=null, _arg5:Matrix=null):void{
var _local6:Triangle3D = _arg1.triangle;
lightMatrix = Matrix3D(lightMatrices[_local6.instance]);
var _local7:Number = ((((_local6.v0.normal.x * lightMatrix.n31) + (_local6.v0.normal.y * lightMatrix.n32)) + (_local6.v0.normal.z * lightMatrix.n33)) + 1);
var _local8:Number = ((((_local6.v1.normal.x * lightMatrix.n31) + (_local6.v1.normal.y * lightMatrix.n32)) + (_local6.v1.normal.z * lightMatrix.n33)) + 1);
var _local9:Number = ((((_local6.v2.normal.x * lightMatrix.n31) + (_local6.v2.normal.y * lightMatrix.n32)) + (_local6.v2.normal.z * lightMatrix.n33)) + 1);
_local7 = (_local7 * 127);
_local8 = (_local8 * 127);
_local9 = (_local9 * 127);
transformMatrix.tx = _local7;
transformMatrix.ty = 1;
transformMatrix.a = (_local8 - _local7);
transformMatrix.c = (_local9 - _local7);
transformMatrix.b = 2;
transformMatrix.d = 3;
transformMatrix.invert();
var _local10:Number = _arg1.v0.x;
var _local11:Number = _arg1.v0.y;
var _local12:Number = _arg1.v1.x;
var _local13:Number = _arg1.v1.y;
var _local14:Number = _arg1.v2.x;
var _local15:Number = _arg1.v2.y;
triMatrix.a = (_local12 - _local10);
triMatrix.b = (_local13 - _local11);
triMatrix.c = (_local14 - _local10);
triMatrix.d = (_local15 - _local11);
triMatrix.tx = _local10;
triMatrix.ty = _local11;
transformMatrix.concat(triMatrix);
_arg2.beginBitmapFill(gouraudMap, transformMatrix, true, false);
_arg2.moveTo(_local10, _local11);
_arg2.lineTo(_local12, _local13);
_arg2.lineTo(_local14, _local15);
_arg2.lineTo(_local10, _local11);
_arg2.endFill();
_arg3.renderStatistics.shadedTriangles++;
}
}
}//package org.papervision3d.materials.shadematerials
Section 249
//ILightShader (org.papervision3d.materials.shaders.ILightShader)
package org.papervision3d.materials.shaders {
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.render.shader.*;
public interface ILightShader {
function updateLightMatrix(_arg1:ShaderObjectData, _arg2:RenderSessionData):void;
}
}//package org.papervision3d.materials.shaders
Section 250
//IShader (org.papervision3d.materials.shaders.IShader)
package org.papervision3d.materials.shaders {
import flash.display.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.render.shader.*;
public interface IShader {
function updateAfterRender(_arg1:RenderSessionData, _arg2:ShaderObjectData):void;
function destroy():void;
function renderLayer(_arg1:Triangle3D, _arg2:RenderSessionData, _arg3:ShaderObjectData):void;
function renderTri(_arg1:Triangle3D, _arg2:RenderSessionData, _arg3:ShaderObjectData, _arg4:BitmapData):void;
}
}//package org.papervision3d.materials.shaders
Section 251
//ShadedMaterial (org.papervision3d.materials.shaders.ShadedMaterial)
package org.papervision3d.materials.shaders {
import flash.display.*;
import flash.geom.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.render.command.*;
import flash.utils.*;
import org.papervision3d.core.log.*;
import org.papervision3d.materials.*;
import org.papervision3d.core.render.material.*;
import org.papervision3d.core.render.shader.*;
import org.papervision3d.core.render.draw.*;
import org.papervision3d.core.material.*;
public class ShadedMaterial extends TriangleMaterial implements ITriangleDrawer, IUpdateBeforeMaterial, IUpdateAfterMaterial {
public var shader:Shader;
private var _shaderCompositeMode:int;
public var material:BitmapMaterial;
public var shaderObjectData:Dictionary;
private static var bmp:BitmapData;
public function ShadedMaterial(_arg1:BitmapMaterial, _arg2:Shader, _arg3:int=0){
this.shader = _arg2;
this.material = _arg1;
shaderCompositeMode = _arg3;
init();
}
override public function registerObject(_arg1:DisplayObject3D):void{
super.registerObject(_arg1);
var _local2:ShaderObjectData = (shaderObjectData[_arg1] = new ShaderObjectData(_arg1, material, this));
_local2.shaderRenderer.inputBitmap = material.bitmap;
shader.setContainerForObject(_arg1, _local2.shaderRenderer.getLayerForShader(shader));
}
public function updateAfterRender(_arg1:RenderSessionData):void{
var _local2:ShaderObjectData;
for each (_local2 in shaderObjectData) {
shader.updateAfterRender(_arg1, _local2);
if (shaderCompositeMode == ShaderCompositeModes.PER_LAYER){
_local2.shaderRenderer.render(_arg1);
};
};
}
override public function drawTriangle(_arg1:RenderTriangle, _arg2:Graphics, _arg3:RenderSessionData, _arg4:BitmapData=null, _arg5:Matrix=null):void{
var _local6:ShaderObjectData = ShaderObjectData(shaderObjectData[_arg1.renderableInstance.instance]);
if (shaderCompositeMode == ShaderCompositeModes.PER_LAYER){
material.drawTriangle(_arg1, _arg2, _arg3, _local6.shaderRenderer.outputBitmap);
shader.renderLayer(_arg1.triangle, _arg3, _local6);
} else {
if (shaderCompositeMode == ShaderCompositeModes.PER_TRIANGLE_IN_BITMAP){
bmp = _local6.getOutputBitmapFor(_arg1.triangle);
material.drawTriangle(_arg1, _arg2, _arg3, bmp, (_local6.triangleUVS[_arg1.triangle]) ? _local6.triangleUVS[_arg1.triangle] : _local6.getPerTriUVForDraw(_arg1.triangle));
shader.renderTri(_arg1.triangle, _arg3, _local6, bmp);
};
};
}
private function init():void{
shaderObjectData = new Dictionary();
}
public function set shaderCompositeMode(_arg1:int):void{
_shaderCompositeMode = _arg1;
}
public function get shaderCompositeMode():int{
return (_shaderCompositeMode);
}
public function getOutputBitmapDataFor(_arg1:DisplayObject3D):BitmapData{
var _local2:ShaderObjectData;
if (shaderCompositeMode == ShaderCompositeModes.PER_LAYER){
if (shaderObjectData[_arg1]){
_local2 = ShaderObjectData(shaderObjectData[_arg1]);
return (_local2.shaderRenderer.outputBitmap);
};
PaperLogger.warning("object not registered with shaded material");
} else {
PaperLogger.warning("getOutputBitmapDataFor only works on per layer mode");
};
return (null);
}
override public function destroy():void{
var _local1:ShaderObjectData;
super.destroy();
for each (_local1 in shaderObjectData) {
_local1.destroy();
};
material = null;
shader = null;
}
override public function unregisterObject(_arg1:DisplayObject3D):void{
super.unregisterObject(_arg1);
var _local2:ShaderObjectData = shaderObjectData[_arg1];
_local2.destroy();
delete shaderObjectData[_arg1];
}
public function updateBeforeRender(_arg1:RenderSessionData):void{
var _local2:ShaderObjectData;
var _local3:ILightShader;
for each (_local2 in shaderObjectData) {
_local2.shaderRenderer.inputBitmap = material.bitmap;
if (shaderCompositeMode == ShaderCompositeModes.PER_LAYER){
if (_local2.shaderRenderer.resizedInput){
_local2.shaderRenderer.resizedInput = false;
_local2.uvMatrices = new Dictionary();
};
_local2.shaderRenderer.clear();
};
if ((shader is ILightShader)){
_local3 = (shader as ILightShader);
_local3.updateLightMatrix(_local2, _arg1);
};
};
}
}
}//package org.papervision3d.materials.shaders
Section 252
//Shader (org.papervision3d.materials.shaders.Shader)
package org.papervision3d.materials.shaders {
import flash.events.*;
import flash.display.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.render.data.*;
import flash.utils.*;
import org.papervision3d.core.render.shader.*;
import flash.filters.*;
public class Shader extends EventDispatcher implements IShader {
protected var layers:Dictionary;
protected var _blendMode:String;// = "multiply"
protected var _filter:BitmapFilter;
protected var _object:DisplayObject3D;
public function Shader(){
this.layers = new Dictionary(true);
}
public function set layerBlendMode(_arg1:String):void{
_blendMode = _arg1;
}
public function setContainerForObject(_arg1:DisplayObject3D, _arg2:Sprite):void{
layers[_arg1] = _arg2;
}
public function updateAfterRender(_arg1:RenderSessionData, _arg2:ShaderObjectData):void{
}
public function set filter(_arg1:BitmapFilter):void{
_filter = _arg1;
}
public function get layerBlendMode():String{
return (_blendMode);
}
public function get filter():BitmapFilter{
return (_filter);
}
public function destroy():void{
}
public function renderTri(_arg1:Triangle3D, _arg2:RenderSessionData, _arg3:ShaderObjectData, _arg4:BitmapData):void{
}
public function renderLayer(_arg1:Triangle3D, _arg2:RenderSessionData, _arg3:ShaderObjectData):void{
}
}
}//package org.papervision3d.materials.shaders
Section 253
//ShaderCompositeModes (org.papervision3d.materials.shaders.ShaderCompositeModes)
package org.papervision3d.materials.shaders {
public class ShaderCompositeModes {
public static var PER_TRIANGLE_IN_BITMAP:int = 1;
public static var PER_LAYER:int = 0;
}
}//package org.papervision3d.materials.shaders
Section 254
//CompositeMaterial (org.papervision3d.materials.special.CompositeMaterial)
package org.papervision3d.materials.special {
import flash.display.*;
import flash.geom.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.render.command.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.core.render.draw.*;
import org.papervision3d.core.material.*;
public class CompositeMaterial extends TriangleMaterial implements ITriangleDrawer {
public var materials:Array;
public function CompositeMaterial(){
init();
}
private function init():void{
materials = new Array();
}
override public function registerObject(_arg1:DisplayObject3D):void{
var _local2:MaterialObject3D;
super.registerObject(_arg1);
for each (_local2 in materials) {
_local2.registerObject(_arg1);
};
}
override public function drawTriangle(_arg1:RenderTriangle, _arg2:Graphics, _arg3:RenderSessionData, _arg4:BitmapData=null, _arg5:Matrix=null):void{
var _local6:MaterialObject3D;
for each (_local6 in materials) {
if (!_local6.invisible){
_local6.drawTriangle(_arg1, _arg2, _arg3);
};
};
}
public function removeAllMaterials():void{
materials = new Array();
}
override public function unregisterObject(_arg1:DisplayObject3D):void{
var _local2:MaterialObject3D;
super.unregisterObject(_arg1);
for each (_local2 in materials) {
_local2.unregisterObject(_arg1);
};
}
public function removeMaterial(_arg1:MaterialObject3D):void{
materials.splice(materials.indexOf(_arg1), 1);
}
public function addMaterial(_arg1:MaterialObject3D):void{
var _local2:Object;
var _local3:DisplayObject3D;
materials.push(_arg1);
for (_local2 in objects) {
_local3 = (_local2 as DisplayObject3D);
_arg1.registerObject(_local3);
};
}
}
}//package org.papervision3d.materials.special
Section 255
//LineMaterial (org.papervision3d.materials.special.LineMaterial)
package org.papervision3d.materials.special {
import flash.display.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.render.command.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.core.render.draw.*;
public class LineMaterial extends MaterialObject3D implements ILineDrawer {
public function LineMaterial(_arg1:Number=0xFF0000, _arg2:Number=1){
this.lineColor = _arg1;
this.lineAlpha = _arg2;
}
public function drawLine(_arg1:RenderLine, _arg2:Graphics, _arg3:RenderSessionData):void{
_arg2.lineStyle(_arg1.size, lineColor, lineAlpha);
_arg2.moveTo(_arg1.v0.x, _arg1.v0.y);
if (_arg1.cV){
_arg2.curveTo(_arg1.cV.x, _arg1.cV.y, _arg1.v1.x, _arg1.v1.y);
} else {
_arg2.lineTo(_arg1.v1.x, _arg1.v1.y);
};
_arg2.moveTo(0, 0);
_arg2.lineStyle();
}
}
}//package org.papervision3d.materials.special
Section 256
//ParticleMaterial (org.papervision3d.materials.special.ParticleMaterial)
package org.papervision3d.materials.special {
import flash.display.*;
import flash.geom.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.core.log.*;
import org.papervision3d.core.render.draw.*;
public class ParticleMaterial extends MaterialObject3D implements IParticleDrawer {
public var shape:int;
public var scale:Number;
public static var SHAPE_SQUARE:int = 0;
public static var SHAPE_CIRCLE:int = 1;
public function ParticleMaterial(_arg1:Number, _arg2:Number, _arg3:int=0, _arg4:Number=1){
this.shape = _arg3;
this.fillAlpha = _arg2;
this.fillColor = _arg1;
this.scale = _arg4;
}
public function drawParticle(_arg1:Particle, _arg2:Graphics, _arg3:RenderSessionData):void{
_arg2.beginFill(fillColor, fillAlpha);
var _local4:Rectangle = _arg1.renderRect;
if (shape == SHAPE_SQUARE){
_arg2.drawRect(_local4.x, _local4.y, _local4.width, _local4.height);
} else {
if (shape == SHAPE_CIRCLE){
_arg2.drawCircle((_local4.x + (_local4.width / 2)), (_local4.y + (_local4.width / 2)), (_local4.width / 2));
} else {
PaperLogger.warning("Particle material has no valid shape - Must be ParticleMaterial.SHAPE_SQUARE or ParticleMaterial.SHAPE_CIRCLE");
};
};
_arg2.endFill();
_arg3.renderStatistics.particles++;
}
public function updateRenderRect(_arg1:Particle):void{
var _local2:Rectangle = _arg1.renderRect;
if (_arg1.size == 0){
_local2.width = 1;
_local2.height = 1;
} else {
_local2.width = ((_arg1.renderScale * _arg1.size) * scale);
_local2.height = ((_arg1.renderScale * _arg1.size) * scale);
};
_local2.x = (_arg1.vertex3D.vertex3DInstance.x - (_local2.width / 2));
_local2.y = (_arg1.vertex3D.vertex3DInstance.y - (_local2.width / 2));
}
}
}//package org.papervision3d.materials.special
Section 257
//BitmapMaterialTools (org.papervision3d.materials.utils.BitmapMaterialTools)
package org.papervision3d.materials.utils {
import flash.display.*;
import flash.geom.*;
import org.papervision3d.materials.*;
public class BitmapMaterialTools {
public static function createBitmapMaterial(_arg1:Class, _arg2:Boolean=true):BitmapMaterial{
var _local3:BitmapData = getTexture(_arg1);
var _local4:BitmapMaterial = new BitmapMaterial(_local3);
_local4.oneSide = _arg2;
return (_local4);
}
public static function mirrorBitmapY(_arg1:BitmapData):void{
var _local2:Bitmap = new Bitmap(_arg1.clone());
_local2.scaleY = -1;
_local2.y = _arg1.height;
_arg1.draw(_local2, _local2.transform.matrix);
_local2.bitmapData.dispose();
}
public static function mirrorBitmapX(_arg1:BitmapData):void{
var _local2:Bitmap = new Bitmap(_arg1.clone());
_local2.scaleX = -1;
_local2.x = _arg1.width;
_arg1.draw(_local2, _local2.transform.matrix);
_local2.bitmapData.dispose();
}
public static function getTexture(_arg1:Class):BitmapData{
var _local2:Bitmap = Bitmap(new (_arg1));
var _local3:BitmapData = new BitmapData(_local2.width, _local2.height, true, 0xFFFFFF);
_local3.draw(_local2, new Matrix());
return (_local3);
}
}
}//package org.papervision3d.materials.utils
Section 258
//LightMaps (org.papervision3d.materials.utils.LightMaps)
package org.papervision3d.materials.utils {
import flash.display.*;
import flash.geom.*;
import flash.filters.*;
public class LightMaps {
private static var origin:Point = new Point();
public static function getGouraudMaterialMap(_arg1:uint, _arg2:uint, _arg3:uint):BitmapData{
var _local4:BitmapData = new BitmapData(0x0100, 3, false, 0xFFFFFF);
var _local5:Sprite = new Sprite();
var _local6:Matrix = new Matrix();
_local6.createGradientBox(0x0100, 3, 0, 0, 0);
_local5.graphics.beginGradientFill(GradientType.LINEAR, [_arg2, _arg2, _arg1], [1, 1, 1], [0, _arg3, 0xFF], _local6);
_local5.graphics.drawRect(0, 0, 0x0100, 3);
_local5.graphics.endFill();
_local4.draw(_local5);
return (_local4);
}
public static function getPhongMap(_arg1:uint, _arg2:uint, _arg3:uint, _arg4:int=0xFF, _arg5:int=0xFF):BitmapData{
var _local6:Number = _arg4;
var _local7:Number = _arg5;
var _local8:Sprite = new Sprite();
var _local9:Matrix = new Matrix();
_local9.createGradientBox(_local6, _local6, 0, 0, 0);
_local8.graphics.beginGradientFill(GradientType.RADIAL, [_arg1, _arg2, _arg2], [1, 1, 1], [0, (0xFF - _arg3), 0xFF], _local9);
_local8.graphics.drawRect(0, 0, _local6, _local6);
_local8.graphics.endFill();
var _local10:BitmapData = new BitmapData(_local6, _local6, false, 0xFF);
_local10.draw(_local8);
return (_local10);
}
public static function getCellMap(_arg1:uint, _arg2:uint, _arg3:int):BitmapData{
var _local4:BitmapData = LightMaps.getPhongMap(_arg1, _arg2, 0, 0xFF, 0xFF);
var _local5:Number = 0;
var _local6 = ((_arg1 & 0xFF0000) >> 16);
var _local7 = ((_arg2 & 0xFF0000) >> 16);
var _local8:int = (_local7 - _local6);
var _local9:Array = new Array();
var _local10:Array = new Array();
var _local11:Array = new Array();
var _local12:int;
while (_local12 <= 0xFF) {
_local9[_local12] = ((_local12 - (_local12 % Math.round((0x0100 / _arg3)))) << 16);
_local10[_local12] = ((_local12 - (_local12 % Math.round((0x0100 / _arg3)))) << 8);
_local11[_local12] = (_local12 - (_local12 % Math.round((0x0100 / _arg3))));
_local12++;
};
_local4.paletteMap(_local4, _local4.rect, origin, _local9, _local10, _local11);
_local4.applyFilter(_local4, _local4.rect, origin, new BlurFilter(2, 2, 2));
return (_local4);
}
public static function getGouraudMap(_arg1:uint, _arg2:uint, _arg3:uint):BitmapData{
var _local4:BitmapData = new BitmapData(0xFF, 3, false, 0xFFFFFF);
var _local5:Sprite = new Sprite();
var _local6:Matrix = new Matrix();
_local6.createGradientBox(0xFF, 3, 0, 0, 0);
_local5.graphics.beginGradientFill(GradientType.LINEAR, [_arg2, _arg2, _arg1], [1, 1, 1], [0, _arg3, 0xFF], _local6);
_local5.graphics.drawRect(0, 0, 0xFF, 3);
_local5.graphics.endFill();
_local4.draw(_local5);
return (_local4);
}
public static function getFlatMapArray(_arg1:uint, _arg2:uint, _arg3:uint):Array{
var _local4:Array = new Array();
var _local5:BitmapData = new BitmapData(0x0100, 1, false, 0);
var _local6:Sprite = new Sprite();
var _local7:Matrix = new Matrix();
_local7.createGradientBox(0x0100, 1, 0, 0, 0);
_local6.graphics.beginGradientFill(GradientType.LINEAR, [_arg1, _arg2, _arg2], [1, 1, 1], [0, (0xFF - _arg3), 0xFF], _local7);
_local6.graphics.drawRect(0, 0, 0x0100, 1);
_local6.graphics.endFill();
_local5.draw(_local6);
var _local8 = 0x0100;
while (_local8--) {
_local4.push(_local5.getPixel(_local8, 0));
};
_local5.dispose();
return (_local4);
}
public static function getFlatMap(_arg1:uint, _arg2:uint, _arg3:uint):BitmapData{
var _local4:BitmapData = new BitmapData(0xFF, 1, false, 0);
var _local5:Sprite = new Sprite();
var _local6:Matrix = new Matrix();
_local6.createGradientBox(0xFF, 1, 0, 0, 0);
_local5.graphics.beginGradientFill(GradientType.LINEAR, [_arg2, _arg2, _arg1], [1, 1, 1], [0, (0xFF - _arg3), 0xFF], _local6);
_local5.graphics.drawRect(0, 0, 0xFF, 1);
_local5.graphics.endFill();
_local4.draw(_local5);
return (_local4);
}
}
}//package org.papervision3d.materials.utils
Section 259
//LightMatrix (org.papervision3d.materials.utils.LightMatrix)
package org.papervision3d.materials.utils {
import org.papervision3d.objects.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.core.math.*;
import org.papervision3d.lights.*;
import org.papervision3d.*;
public class LightMatrix {
private static var _targetPos:Number3D = new Number3D();
private static var _lightUp:Number3D = new Number3D();
private static var _lightSide:Number3D = new Number3D();
private static var _lightDir:Number3D = new Number3D();
private static var lightMatrix:Matrix3D = Matrix3D.IDENTITY;
private static var invMatrix:Matrix3D = Matrix3D.IDENTITY;
protected static var UP:Number3D = new Number3D(0, 1, 0);
private static var _lightPos:Number3D = new Number3D();
public static function getLightMatrix(_arg1:LightObject3D, _arg2:DisplayObject3D, _arg3:RenderSessionData, _arg4:Matrix3D):Matrix3D{
var _local6:Matrix3D;
var _local7:Matrix3D;
var _local5:Matrix3D = (_arg4) ? _arg4 : Matrix3D.IDENTITY;
if (_arg1 == null){
_arg1 = new PointLight3D();
_arg1.copyPosition(_arg3.camera);
};
_targetPos.reset();
_lightPos.reset();
_lightDir.reset();
_lightUp.reset();
_lightSide.reset();
_local6 = _arg1.transform;
_local7 = _arg2.world;
_lightPos.x = -(_local6.n14);
_lightPos.y = -(_local6.n24);
_lightPos.z = -(_local6.n34);
_targetPos.x = -(_local7.n14);
_targetPos.y = -(_local7.n24);
_targetPos.z = -(_local7.n34);
_lightDir.x = (_targetPos.x - _lightPos.x);
_lightDir.y = (_targetPos.y - _lightPos.y);
_lightDir.z = (_targetPos.z - _lightPos.z);
invMatrix.calculateInverse(_arg2.world);
Matrix3D.multiplyVector3x3(invMatrix, _lightDir);
_lightDir.normalize();
_lightSide.x = ((_lightDir.y * UP.z) - (_lightDir.z * UP.y));
_lightSide.y = ((_lightDir.z * UP.x) - (_lightDir.x * UP.z));
_lightSide.z = ((_lightDir.x * UP.y) - (_lightDir.y * UP.x));
_lightSide.normalize();
_lightUp.x = ((_lightSide.y * _lightDir.z) - (_lightSide.z * _lightDir.y));
_lightUp.y = ((_lightSide.z * _lightDir.x) - (_lightSide.x * _lightDir.z));
_lightUp.z = ((_lightSide.x * _lightDir.y) - (_lightSide.y * _lightDir.x));
_lightUp.normalize();
if (((Papervision3D.useRIGHTHANDED) || (_arg2.flipLightDirection))){
_lightDir.x = -(_lightDir.x);
_lightDir.y = -(_lightDir.y);
_lightDir.z = -(_lightDir.z);
};
_local5.n11 = _lightSide.x;
_local5.n12 = _lightSide.y;
_local5.n13 = _lightSide.z;
_local5.n21 = _lightUp.x;
_local5.n22 = _lightUp.y;
_local5.n23 = _lightUp.z;
_local5.n31 = _lightDir.x;
_local5.n32 = _lightDir.y;
_local5.n33 = _lightDir.z;
return (_local5);
}
}
}//package org.papervision3d.materials.utils
Section 260
//MaterialsList (org.papervision3d.materials.utils.MaterialsList)
package org.papervision3d.materials.utils {
import org.papervision3d.core.proto.*;
import flash.utils.*;
public class MaterialsList {
protected var _materials:Dictionary;
public var materialsByName:Dictionary;
private var _materialsTotal:int;
public function MaterialsList(_arg1=null):void{
var _local2:String;
var _local3:String;
super();
this.materialsByName = new Dictionary(true);
this._materials = new Dictionary(false);
this._materialsTotal = 0;
if (_arg1){
if ((_arg1 is Array)){
for (_local2 in _arg1) {
this.addMaterial(_arg1[_local2]);
};
} else {
if ((_arg1 is Object)){
for (_local3 in _arg1) {
this.addMaterial(_arg1[_local3], _local3);
};
};
};
};
}
public function get numMaterials():int{
return (_materialsTotal);
}
public function addMaterial(_arg1:MaterialObject3D, _arg2:String=null):MaterialObject3D{
_arg2 = ((((_arg2) || (_arg1.name))) || (String(_arg1.id)));
this._materials[_arg1] = _arg2;
this.materialsByName[_arg2] = _arg1;
this._materialsTotal++;
return (_arg1);
}
public function removeMaterial(_arg1:MaterialObject3D):MaterialObject3D{
if (this._materials[_arg1]){
delete this.materialsByName[this._materials[_arg1]];
delete this._materials[_arg1];
_materialsTotal--;
};
return (_arg1);
}
public function toString():String{
var _local2:MaterialObject3D;
var _local1 = "";
for each (_local2 in this.materialsByName) {
_local1 = (_local1 + (this._materials[_local2] + "\n"));
};
return (_local1);
}
public function removeMaterialByName(_arg1:String):MaterialObject3D{
return (removeMaterial(getMaterialByName(_arg1)));
}
public function clone():MaterialsList{
var _local2:MaterialObject3D;
var _local1:MaterialsList = new MaterialsList();
for each (_local2 in this.materialsByName) {
_local1.addMaterial(_local2.clone(), this._materials[_local2]);
};
return (_local1);
}
public function getMaterialByName(_arg1:String):MaterialObject3D{
return ((this.materialsByName[_arg1]) ? this.materialsByName[_arg1] : this.materialsByName["all"]);
}
}
}//package org.papervision3d.materials.utils
Section 261
//PrecisionMode (org.papervision3d.materials.utils.PrecisionMode)
package org.papervision3d.materials.utils {
public class PrecisionMode {
public static var ORIGINAL:int = 0;
public static var STABLE:int = 1;
}
}//package org.papervision3d.materials.utils
Section 262
//RenderRecStorage (org.papervision3d.materials.utils.RenderRecStorage)
package org.papervision3d.materials.utils {
import flash.geom.*;
import org.papervision3d.core.geom.renderables.*;
public class RenderRecStorage {
public var mat:Matrix;
public var v0:Vertex3DInstance;
public var v1:Vertex3DInstance;
public var v2:Vertex3DInstance;
public function RenderRecStorage(){
v0 = new Vertex3DInstance();
v1 = new Vertex3DInstance();
v2 = new Vertex3DInstance();
mat = new Matrix();
super();
}
}
}//package org.papervision3d.materials.utils
Section 263
//BitmapFileMaterial (org.papervision3d.materials.BitmapFileMaterial)
package org.papervision3d.materials {
import flash.events.*;
import flash.display.*;
import flash.net.*;
import org.papervision3d.events.*;
import flash.geom.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.render.command.*;
import org.papervision3d.core.proto.*;
import flash.utils.*;
import org.papervision3d.core.log.*;
import org.papervision3d.core.render.draw.*;
import flash.system.*;
public class BitmapFileMaterial extends BitmapMaterial implements ITriangleDrawer {
public var loaded:Boolean;
protected var errorLoading:Boolean;// = false
protected var bitmapLoader:Loader;
public var url:String;// = ""
public var checkPolicyFile:Boolean;// = false
public static var LOADING_COLOR:int = MaterialObject3D.DEFAULT_COLOR;
public static var callback:Function;
public static var loadingBitmap:BitmapData = new BitmapData(1, 1, false, 0);
protected static var _loaderUrls:Dictionary = new Dictionary(true);
protected static var _loadingIdle:Boolean = true;
public static var ERROR_COLOR:int = MaterialObject3D.DEBUG_COLOR;
protected static var _subscribedMaterials:Object = new Object();
protected static var _waitingBitmaps:Array = new Array();
protected static var _bitmapMaterials:Dictionary = new Dictionary(true);
public function BitmapFileMaterial(_arg1:String="", _arg2:Boolean=false){
super(null, _arg2);
this.url = _arg1;
this.loaded = false;
this.fillAlpha = 1;
this.fillColor = LOADING_COLOR;
if (_arg1.length > 0){
texture = _arg1;
};
}
protected function loadBitmapProgressHandler(_arg1:ProgressEvent):void{
var _local2:FileLoadEvent = new FileLoadEvent(FileLoadEvent.LOAD_PROGRESS, url, _arg1.bytesLoaded, _arg1.bytesTotal);
dispatchEvent(_local2);
}
protected function setupAsyncLoadCompleteCallback():void{
var _local1:Timer = new Timer(1, 1);
_local1.addEventListener(TimerEvent.TIMER_COMPLETE, dispatchAsyncLoadCompleteEvent);
_local1.start();
}
protected function removeLoaderListeners():void{
bitmapLoader.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS, loadBitmapProgressHandler);
bitmapLoader.contentLoaderInfo.removeEventListener(Event.COMPLETE, loadBitmapCompleteHandler);
bitmapLoader.contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR, loadBitmapErrorHandler);
}
protected function getBitmapForFilename(_arg1:String):BitmapData{
var _local2:*;
var _local3:BitmapFileMaterial;
for (_local2 in _bitmapMaterials) {
_local3 = (_local2 as BitmapFileMaterial);
if (_local3.url == _arg1){
return (_local3.bitmap);
};
};
return (null);
}
public function get bitmapMaterials():Dictionary{
return (_bitmapMaterials);
}
protected function loadNextBitmap():void{
var loaderContext:LoaderContext;
var file:String = _waitingBitmaps[0];
var request:URLRequest = new URLRequest(file);
bitmapLoader = new Loader();
bitmapLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loadBitmapProgressHandler);
bitmapLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadBitmapCompleteHandler);
bitmapLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, loadBitmapErrorHandler);
try {
loaderContext = new LoaderContext();
loaderContext.checkPolicyFile = checkPolicyFile;
bitmapLoader.load(request, loaderContext);
_loaderUrls[bitmapLoader] = file;
_loadingIdle = false;
PaperLogger.info(("BitmapFileMaterial: Loading bitmap from " + file));
} catch(error:Error) {
_waitingBitmaps.shift();
_loadingIdle = true;
PaperLogger.info(("[ERROR] BitmapFileMaterial: Unable to load file " + error.message));
};
}
protected function dispatchAsyncLoadCompleteEvent(_arg1:TimerEvent):void{
loadComplete();
}
protected function createBitmapFromURL(_arg1:String):BitmapData{
var _local2:BitmapData;
if (_arg1 == ""){
return (null);
};
_local2 = getBitmapForFilename(_arg1);
if (_local2){
bitmap = super.createBitmap(_local2);
setupAsyncLoadCompleteCallback();
return (_local2);
};
queueBitmap(_arg1);
return (loadingBitmap);
}
override public function get texture():Object{
return (this._texture);
}
protected function loadBitmapCompleteHandler(_arg1:Event):void{
var _local5:BitmapFileMaterial;
var _local2:Bitmap = Bitmap(bitmapLoader.content);
removeLoaderListeners();
var _local3:String = _loaderUrls[bitmapLoader];
var _local4:BitmapData = super.createBitmap(_local2.bitmapData);
for each (_local5 in _subscribedMaterials[_local3]) {
_local5.bitmap = _local4;
_local5.maxU = this.maxU;
_local5.maxV = this.maxV;
_local5.resetMapping();
_local5.loadComplete();
};
_subscribedMaterials[_local3] = null;
_bitmapMaterials[this] = true;
_waitingBitmaps.shift();
if (_waitingBitmaps.length > 0){
loadNextBitmap();
} else {
_loadingIdle = true;
if (Boolean(callback)){
callback();
};
};
}
private function queueBitmap(_arg1:String):void{
if (!_subscribedMaterials[_arg1]){
_waitingBitmaps.push(_arg1);
_subscribedMaterials[_arg1] = new Array();
};
_subscribedMaterials[_arg1].push(this);
if (_loadingIdle){
loadNextBitmap();
};
}
override public function drawTriangle(_arg1:RenderTriangle, _arg2:Graphics, _arg3:RenderSessionData, _arg4:BitmapData=null, _arg5:Matrix=null):void{
if ((((bitmap == null)) || (errorLoading))){
if (errorLoading){
_arg2.lineStyle(lineThickness, lineColor, lineAlpha);
};
_arg2.beginFill(fillColor, fillAlpha);
_arg2.moveTo(_arg1.v0.x, _arg1.v0.y);
_arg2.lineTo(_arg1.v1.x, _arg1.v1.y);
_arg2.lineTo(_arg1.v2.x, _arg1.v2.y);
_arg2.lineTo(_arg1.v0.x, _arg1.v0.y);
_arg2.endFill();
if (errorLoading){
_arg2.lineStyle();
};
_arg3.renderStatistics.triangles++;
};
super.drawTriangle(_arg1, _arg2, _arg3);
}
public function get subscribedMaterials():Object{
return (_subscribedMaterials);
}
protected function loadBitmapErrorHandler(_arg1:IOErrorEvent):void{
var _local2:String = String(_waitingBitmaps.shift());
_subscribedMaterials[_local2] = null;
this.errorLoading = true;
this.lineColor = ERROR_COLOR;
this.lineAlpha = 1;
this.lineThickness = 1;
PaperLogger.error(("BitmapFileMaterial: Unable to load file " + _local2));
removeLoaderListeners();
if (_waitingBitmaps.length > 0){
loadNextBitmap();
} else {
_loadingIdle = true;
if (Boolean(callback)){
callback();
};
};
var _local3:FileLoadEvent = new FileLoadEvent(FileLoadEvent.LOAD_ERROR, _local2, -1, -1, _arg1.text);
dispatchEvent(_local3);
}
override public function set texture(_arg1:Object):void{
if ((_arg1 is String) == false){
PaperLogger.error("BitmapFileMaterial.texture requires a String for the texture");
return;
};
bitmap = createBitmapFromURL(String(_arg1));
_texture = _arg1;
}
protected function loadComplete():void{
this.fillAlpha = 0;
this.fillColor = 0;
this.loaded = true;
var _local1:FileLoadEvent = new FileLoadEvent(FileLoadEvent.LOAD_COMPLETE, this.url);
this.dispatchEvent(_local1);
}
}
}//package org.papervision3d.materials
Section 264
//BitmapMaterial (org.papervision3d.materials.BitmapMaterial)
package org.papervision3d.materials {
import flash.display.*;
import flash.geom.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.render.command.*;
import org.papervision3d.core.proto.*;
import flash.utils.*;
import org.papervision3d.materials.utils.*;
import org.papervision3d.core.log.*;
import org.papervision3d.core.render.draw.*;
import org.papervision3d.core.material.*;
import org.papervision3d.*;
public class BitmapMaterial extends TriangleMaterial implements ITriangleDrawer {
protected var renderRecStorage:Array;
protected var dsbc:Number;
private var d2bc:Number;
private var b2:Number;
public var uvMatrices:Dictionary;
protected var _precise:Boolean;
protected var faz:Number;
protected var dsca:Number;
protected var ax:Number;
protected var ay:Number;
protected var az:Number;
private var d2ca:Number;
protected var tempPreGrp:Graphics;
public var precisionMode:int;
protected var fbz:Number;
private var c2:Number;
protected var mcax:Number;
protected var mcay:Number;
protected var mcaz:Number;
private var d2:Number;
protected var bx:Number;
protected var by:Number;
protected var bz:Number;
protected var fcz:Number;
public var minimumRenderSize:Number;// = 4
protected var dbcx:Number;
protected var dbcy:Number;
protected var cx:Number;
protected var cullRect:Rectangle;
protected var cz:Number;
protected var cy:Number;
protected var dmax:Number;
protected var dabx:Number;
private var dy:Number;
protected var _perPixelPrecision:int;// = 8
protected var daby:Number;
protected var tempPreRSD:RenderSessionData;
private var dx:Number;
private var x0:Number;
private var x1:Number;
private var x2:Number;
protected var mbcy:Number;
protected var mbcz:Number;
protected var mbcx:Number;
private var y0:Number;
protected var focus:Number;// = 200
private var y2:Number;
protected var _texture:Object;
protected var tempPreBmp:BitmapData;
private var y1:Number;
protected var tempTriangleMatrix:Matrix;
protected var maby:Number;
protected var mabz:Number;
private var d2ab:Number;
protected var dsab:Number;
protected var mabx:Number;
protected var dcax:Number;
protected var dcay:Number;
private var a2:Number;
protected var _precision:int;// = 8
protected static const DEFAULT_FOCUS:Number = 200;
protected static var _triMatrix:Matrix = new Matrix();
protected static var _triMap:Matrix;
public static var AUTO_MIP_MAPPING:Boolean = false;
public static var MIP_MAP_DEPTH:Number = 8;
protected static var hitRect:Rectangle = new Rectangle();
protected static var _localMatrix:Matrix = new Matrix();
public function BitmapMaterial(_arg1:BitmapData=null, _arg2:Boolean=false){
precisionMode = PrecisionMode.ORIGINAL;
uvMatrices = new Dictionary();
tempTriangleMatrix = new Matrix();
super();
if (_arg1){
texture = _arg1;
};
this.precise = _arg2;
createRenderRecStorage();
}
public function transformUV(_arg1:Triangle3D):Matrix{
var _local2:Array;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Matrix;
var _local16:Matrix;
if (!_arg1.uv){
PaperLogger.error("MaterialObject3D: transformUV() uv not found!");
} else {
if (bitmap){
_local2 = _arg1.uv;
_local3 = (bitmap.width * maxU);
_local4 = (bitmap.height * maxV);
_local5 = (_local3 * _arg1.uv0.u);
_local6 = (_local4 * (1 - _arg1.uv0.v));
_local7 = (_local3 * _arg1.uv1.u);
_local8 = (_local4 * (1 - _arg1.uv1.v));
_local9 = (_local3 * _arg1.uv2.u);
_local10 = (_local4 * (1 - _arg1.uv2.v));
if ((((((_local5 == _local7)) && ((_local6 == _local8)))) || ((((_local5 == _local9)) && ((_local6 == _local10)))))){
_local5 = (_local5 - ((_local5)>0.05) ? 0.05 : -0.05);
_local6 = (_local6 - ((_local6)>0.07) ? 0.07 : -0.07);
};
if ((((_local9 == _local7)) && ((_local10 == _local8)))){
_local9 = (_local9 - ((_local9)>0.05) ? 0.04 : -0.04);
_local10 = (_local10 - ((_local10)>0.06) ? 0.06 : -0.06);
};
_local11 = (_local7 - _local5);
_local12 = (_local8 - _local6);
_local13 = (_local9 - _local5);
_local14 = (_local10 - _local6);
_local15 = new Matrix(_local11, _local12, _local13, _local14, _local5, _local6);
if (Papervision3D.useRIGHTHANDED){
_local15.scale(-1, 1);
_local15.translate(_local3, 0);
};
_local15.invert();
_local16 = (uvMatrices[_arg1] = _local15.clone());
_local16.a = _local15.a;
_local16.b = _local15.b;
_local16.c = _local15.c;
_local16.d = _local15.d;
_local16.tx = _local15.tx;
_local16.ty = _local15.ty;
} else {
PaperLogger.error("MaterialObject3D: transformUV() material.bitmap not found!");
};
};
return (_local16);
}
public function transformUVRT(_arg1:RenderTriangle):Matrix{
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Matrix;
var _local15:Matrix;
if (bitmap){
_local2 = (bitmap.width * maxU);
_local3 = (bitmap.height * maxV);
_local4 = (_local2 * _arg1.uv0.u);
_local5 = (_local3 * (1 - _arg1.uv0.v));
_local6 = (_local2 * _arg1.uv1.u);
_local7 = (_local3 * (1 - _arg1.uv1.v));
_local8 = (_local2 * _arg1.uv2.u);
_local9 = (_local3 * (1 - _arg1.uv2.v));
if ((((((_local4 == _local6)) && ((_local5 == _local7)))) || ((((_local4 == _local8)) && ((_local5 == _local9)))))){
_local4 = (_local4 - ((_local4)>0.05) ? 0.05 : -0.05);
_local5 = (_local5 - ((_local5)>0.07) ? 0.07 : -0.07);
};
if ((((_local8 == _local6)) && ((_local9 == _local7)))){
_local8 = (_local8 - ((_local8)>0.05) ? 0.04 : -0.04);
_local9 = (_local9 - ((_local9)>0.06) ? 0.06 : -0.06);
};
_local10 = (_local6 - _local4);
_local11 = (_local7 - _local5);
_local12 = (_local8 - _local4);
_local13 = (_local9 - _local5);
_local14 = new Matrix(_local10, _local11, _local12, _local13, _local4, _local5);
if (Papervision3D.useRIGHTHANDED){
_local14.scale(-1, 1);
_local14.translate(_local2, 0);
};
_local14.invert();
_local15 = (uvMatrices[_arg1] = _local14.clone());
_local15.a = _local14.a;
_local15.b = _local14.b;
_local15.c = _local14.c;
_local15.d = _local14.d;
_local15.tx = _local14.tx;
_local15.ty = _local14.ty;
} else {
PaperLogger.error("MaterialObject3D: transformUV() material.bitmap not found!");
};
return (_local15);
}
protected function renderRec(_arg1:Matrix, _arg2:Vertex3DInstance, _arg3:Vertex3DInstance, _arg4:Vertex3DInstance, _arg5:Number):void{
az = _arg2.z;
bz = _arg3.z;
cz = _arg4.z;
if ((((((az <= 0)) && ((bz <= 0)))) && ((cz <= 0)))){
return;
};
cx = _arg4.x;
cy = _arg4.y;
bx = _arg3.x;
by = _arg3.y;
ax = _arg2.x;
ay = _arg2.y;
if (cullRect){
hitRect.x = ((bx < ax)) ? ((bx < cx)) ? bx : cx : ((ax < cx)) ? ax : cx;
hitRect.width = (((bx > ax)) ? ((bx > cx)) ? bx : cx : ((ax > cx)) ? ax : cx + ((hitRect.x < 0)) ? -(hitRect.x) : hitRect.x);
hitRect.y = ((by < ay)) ? ((by < cy)) ? by : cy : ((ay < cy)) ? ay : cy;
hitRect.height = (((by > ay)) ? ((by > cy)) ? by : cy : ((ay > cy)) ? ay : cy + ((hitRect.y < 0)) ? -(hitRect.y) : hitRect.y);
if (!(((hitRect.right < cullRect.left)) || ((hitRect.left > cullRect.right)))){
if (!(((hitRect.bottom < cullRect.top)) || ((hitRect.top > cullRect.bottom)))){
} else {
return;
};
} else {
return;
};
};
if ((((((((_arg5 >= 100)) || ((hitRect.width < minimumRenderSize)))) || ((hitRect.height < minimumRenderSize)))) || ((focus == Infinity)))){
a2 = (_arg3.x - _arg2.x);
b2 = (_arg3.y - _arg2.y);
c2 = (_arg4.x - _arg2.x);
d2 = (_arg4.y - _arg2.y);
tempTriangleMatrix.a = ((_arg1.a * a2) + (_arg1.b * c2));
tempTriangleMatrix.b = ((_arg1.a * b2) + (_arg1.b * d2));
tempTriangleMatrix.c = ((_arg1.c * a2) + (_arg1.d * c2));
tempTriangleMatrix.d = ((_arg1.c * b2) + (_arg1.d * d2));
tempTriangleMatrix.tx = (((_arg1.tx * a2) + (_arg1.ty * c2)) + _arg2.x);
tempTriangleMatrix.ty = (((_arg1.tx * b2) + (_arg1.ty * d2)) + _arg2.y);
if (lineAlpha){
tempPreGrp.lineStyle(lineThickness, lineColor, lineAlpha);
};
tempPreGrp.beginBitmapFill(tempPreBmp, tempTriangleMatrix, tiled, smooth);
tempPreGrp.moveTo(_arg2.x, _arg2.y);
tempPreGrp.lineTo(_arg3.x, _arg3.y);
tempPreGrp.lineTo(_arg4.x, _arg4.y);
tempPreGrp.endFill();
if (lineAlpha){
tempPreGrp.lineStyle();
};
tempPreRSD.renderStatistics.triangles++;
return;
};
faz = (focus + az);
fbz = (focus + bz);
fcz = (focus + cz);
mabz = (2 / (faz + fbz));
mbcz = (2 / (fbz + fcz));
mcaz = (2 / (fcz + faz));
mabx = (((ax * faz) + (bx * fbz)) * mabz);
maby = (((ay * faz) + (by * fbz)) * mabz);
mbcx = (((bx * fbz) + (cx * fcz)) * mbcz);
mbcy = (((by * fbz) + (cy * fcz)) * mbcz);
mcax = (((cx * fcz) + (ax * faz)) * mcaz);
mcay = (((cy * fcz) + (ay * faz)) * mcaz);
dabx = ((ax + bx) - mabx);
daby = ((ay + by) - maby);
dbcx = ((bx + cx) - mbcx);
dbcy = ((by + cy) - mbcy);
dcax = ((cx + ax) - mcax);
dcay = ((cy + ay) - mcay);
dsab = ((dabx * dabx) + (daby * daby));
dsbc = ((dbcx * dbcx) + (dbcy * dbcy));
dsca = ((dcax * dcax) + (dcay * dcay));
var _local6:int = (_arg5 + 1);
var _local7:RenderRecStorage = RenderRecStorage(renderRecStorage[int(_arg5)]);
var _local8:Matrix = _local7.mat;
if ((((((dsab <= _precision)) && ((dsca <= _precision)))) && ((dsbc <= _precision)))){
a2 = (_arg3.x - _arg2.x);
b2 = (_arg3.y - _arg2.y);
c2 = (_arg4.x - _arg2.x);
d2 = (_arg4.y - _arg2.y);
tempTriangleMatrix.a = ((_arg1.a * a2) + (_arg1.b * c2));
tempTriangleMatrix.b = ((_arg1.a * b2) + (_arg1.b * d2));
tempTriangleMatrix.c = ((_arg1.c * a2) + (_arg1.d * c2));
tempTriangleMatrix.d = ((_arg1.c * b2) + (_arg1.d * d2));
tempTriangleMatrix.tx = (((_arg1.tx * a2) + (_arg1.ty * c2)) + _arg2.x);
tempTriangleMatrix.ty = (((_arg1.tx * b2) + (_arg1.ty * d2)) + _arg2.y);
if (lineAlpha){
tempPreGrp.lineStyle(lineThickness, lineColor, lineAlpha);
};
tempPreGrp.beginBitmapFill(tempPreBmp, tempTriangleMatrix, tiled, smooth);
tempPreGrp.moveTo(_arg2.x, _arg2.y);
tempPreGrp.lineTo(_arg3.x, _arg3.y);
tempPreGrp.lineTo(_arg4.x, _arg4.y);
tempPreGrp.endFill();
if (lineAlpha){
tempPreGrp.lineStyle();
};
tempPreRSD.renderStatistics.triangles++;
return;
};
if ((((((dsab > _precision)) && ((dsca > _precision)))) && ((dsbc > _precision)))){
_local8.a = (_arg1.a * 2);
_local8.b = (_arg1.b * 2);
_local8.c = (_arg1.c * 2);
_local8.d = (_arg1.d * 2);
_local8.tx = (_arg1.tx * 2);
_local8.ty = (_arg1.ty * 2);
_local7.v0.x = (mabx * 0.5);
_local7.v0.y = (maby * 0.5);
_local7.v0.z = ((az + bz) * 0.5);
_local7.v1.x = (mbcx * 0.5);
_local7.v1.y = (mbcy * 0.5);
_local7.v1.z = ((bz + cz) * 0.5);
_local7.v2.x = (mcax * 0.5);
_local7.v2.y = (mcay * 0.5);
_local7.v2.z = ((cz + az) * 0.5);
renderRec(_local8, _arg2, _local7.v0, _local7.v2, _local6);
_local8.tx = (_local8.tx - 1);
renderRec(_local8, _local7.v0, _arg3, _local7.v1, _local6);
_local8.ty = (_local8.ty - 1);
_local8.tx = (_arg1.tx * 2);
renderRec(_local8, _local7.v2, _local7.v1, _arg4, _local6);
_local8.a = (-(_arg1.a) * 2);
_local8.b = (-(_arg1.b) * 2);
_local8.c = (-(_arg1.c) * 2);
_local8.d = (-(_arg1.d) * 2);
_local8.tx = ((-(_arg1.tx) * 2) + 1);
_local8.ty = ((-(_arg1.ty) * 2) + 1);
renderRec(_local8, _local7.v1, _local7.v2, _local7.v0, _local6);
return;
};
if (precisionMode == PrecisionMode.ORIGINAL){
d2ab = dsab;
d2bc = dsbc;
d2ca = dsca;
dmax = ((dsca > dsbc)) ? ((dsca > dsab)) ? dsca : dsab : ((dsbc > dsab)) ? dsbc : dsab;
} else {
dx = (_arg2.x - _arg3.x);
dy = (_arg2.y - _arg3.y);
d2ab = ((dx * dx) + (dy * dy));
dx = (_arg3.x - _arg4.x);
dy = (_arg3.y - _arg4.y);
d2bc = ((dx * dx) + (dy * dy));
dx = (_arg4.x - _arg2.x);
dy = (_arg4.y - _arg2.y);
d2ca = ((dx * dx) + (dy * dy));
dmax = ((d2ca > d2bc)) ? ((d2ca > d2ab)) ? d2ca : d2ab : ((d2bc > d2ab)) ? d2bc : d2ab;
};
if (d2ab == dmax){
_local8.a = (_arg1.a * 2);
_local8.b = _arg1.b;
_local8.c = (_arg1.c * 2);
_local8.d = _arg1.d;
_local8.tx = (_arg1.tx * 2);
_local8.ty = _arg1.ty;
_local7.v0.x = (mabx * 0.5);
_local7.v0.y = (maby * 0.5);
_local7.v0.z = ((az + bz) * 0.5);
renderRec(_local8, _arg2, _local7.v0, _arg4, _local6);
_local8.a = ((_arg1.a * 2) + _arg1.b);
_local8.c = ((2 * _arg1.c) + _arg1.d);
_local8.tx = (((_arg1.tx * 2) + _arg1.ty) - 1);
renderRec(_local8, _local7.v0, _arg3, _arg4, _local6);
return;
};
if (d2ca == dmax){
_local8.a = _arg1.a;
_local8.b = (_arg1.b * 2);
_local8.c = _arg1.c;
_local8.d = (_arg1.d * 2);
_local8.tx = _arg1.tx;
_local8.ty = (_arg1.ty * 2);
_local7.v2.x = (mcax * 0.5);
_local7.v2.y = (mcay * 0.5);
_local7.v2.z = ((cz + az) * 0.5);
renderRec(_local8, _arg2, _arg3, _local7.v2, _local6);
_local8.b = (_local8.b + _arg1.a);
_local8.d = (_local8.d + _arg1.c);
_local8.ty = (_local8.ty + (_arg1.tx - 1));
renderRec(_local8, _local7.v2, _arg3, _arg4, _local6);
return;
};
_local8.a = (_arg1.a - _arg1.b);
_local8.b = (_arg1.b * 2);
_local8.c = (_arg1.c - _arg1.d);
_local8.d = (_arg1.d * 2);
_local8.tx = (_arg1.tx - _arg1.ty);
_local8.ty = (_arg1.ty * 2);
_local7.v1.x = (mbcx * 0.5);
_local7.v1.y = (mbcy * 0.5);
_local7.v1.z = ((bz + cz) * 0.5);
renderRec(_local8, _arg2, _arg3, _local7.v1, _local6);
_local8.a = (_arg1.a * 2);
_local8.b = (_arg1.b - _arg1.a);
_local8.c = (_arg1.c * 2);
_local8.d = (_arg1.d - _arg1.c);
_local8.tx = (_arg1.tx * 2);
_local8.ty = (_arg1.ty - _arg1.tx);
renderRec(_local8, _arg2, _local7.v1, _arg4, _local6);
}
protected function createRenderRecStorage():void{
this.renderRecStorage = new Array();
var _local1:int;
while (_local1 <= 100) {
this.renderRecStorage[_local1] = new RenderRecStorage();
_local1++;
};
}
public function get texture():Object{
return (this._texture);
}
public function resetUVS():void{
uvMatrices = new Dictionary(false);
}
public function set pixelPrecision(_arg1:int):void{
_precision = ((_arg1 * _arg1) * 1.4);
_perPixelPrecision = _arg1;
}
protected function correctBitmap(_arg1:BitmapData):BitmapData{
var _local2:BitmapData;
var _local3:Number = (1 << MIP_MAP_DEPTH);
var _local4:Number = (_arg1.width / _local3);
_local4 = ((_local4 == uint(_local4))) ? _local4 : (uint(_local4) + 1);
var _local5:Number = (_arg1.height / _local3);
_local5 = ((_local5 == uint(_local5))) ? _local5 : (uint(_local5) + 1);
var _local6:Number = (_local3 * _local4);
var _local7:Number = (_local3 * _local5);
var _local8:Boolean;
if (_local6 > 2880){
_local6 = _arg1.width;
_local8 = false;
};
if (_local7 > 2880){
_local7 = _arg1.height;
_local8 = false;
};
if (!_local8){
PaperLogger.warning((("Material " + this.name) + ": Texture too big for mip mapping. Resizing recommended for better performance and quality."));
};
if (((_arg1) && (((!(((_arg1.width % _local3) == 0))) || (!(((_arg1.height % _local3) == 0))))))){
_local2 = new BitmapData(_local6, _local7, _arg1.transparent, 0);
widthOffset = _arg1.width;
heightOffset = _arg1.height;
this.maxU = (_arg1.width / _local6);
this.maxV = (_arg1.height / _local7);
_local2.draw(_arg1);
extendBitmapEdges(_local2, _arg1.width, _arg1.height);
} else {
this.maxU = (this.maxV = 1);
_local2 = _arg1;
};
return (_local2);
}
protected function createBitmap(_arg1:BitmapData):BitmapData{
var _local2:BitmapData;
resetMapping();
if (AUTO_MIP_MAPPING){
_local2 = correctBitmap(_arg1);
} else {
this.maxU = (this.maxV = 1);
_local2 = _arg1;
};
return (_local2);
}
public function get precise():Boolean{
return (_precise);
}
public function set texture(_arg1:Object):void{
if ((_arg1 is BitmapData) == false){
PaperLogger.error("BitmapMaterial.texture requires a BitmapData object for the texture");
return;
};
bitmap = createBitmap(BitmapData(_arg1));
_texture = _arg1;
}
override public function clone():MaterialObject3D{
var _local1:MaterialObject3D = super.clone();
_local1.maxU = this.maxU;
_local1.maxV = this.maxV;
return (_local1);
}
override public function drawTriangle(_arg1:RenderTriangle, _arg2:Graphics, _arg3:RenderSessionData, _arg4:BitmapData=null, _arg5:Matrix=null):void{
_triMap = (_arg5) ? _arg5 : ((uvMatrices[_arg1]) || (transformUVRT(_arg1)));
if (((!(_precise)) || (!(_triMap)))){
if (lineAlpha){
_arg2.lineStyle(lineThickness, lineColor, lineAlpha);
};
if (bitmap){
x0 = _arg1.v0.x;
y0 = _arg1.v0.y;
x1 = _arg1.v1.x;
y1 = _arg1.v1.y;
x2 = _arg1.v2.x;
y2 = _arg1.v2.y;
_triMatrix.a = (x1 - x0);
_triMatrix.b = (y1 - y0);
_triMatrix.c = (x2 - x0);
_triMatrix.d = (y2 - y0);
_triMatrix.tx = x0;
_triMatrix.ty = y0;
_localMatrix.a = _triMap.a;
_localMatrix.b = _triMap.b;
_localMatrix.c = _triMap.c;
_localMatrix.d = _triMap.d;
_localMatrix.tx = _triMap.tx;
_localMatrix.ty = _triMap.ty;
_localMatrix.concat(_triMatrix);
_arg2.beginBitmapFill((_arg4) ? _arg4 : bitmap, _localMatrix, tiled, smooth);
};
_arg2.moveTo(x0, y0);
_arg2.lineTo(x1, y1);
_arg2.lineTo(x2, y2);
_arg2.lineTo(x0, y0);
if (bitmap){
_arg2.endFill();
};
if (lineAlpha){
_arg2.lineStyle();
};
_arg3.renderStatistics.triangles++;
} else {
if (bitmap){
focus = _arg3.camera.focus;
tempPreBmp = (_arg4) ? _arg4 : bitmap;
tempPreRSD = _arg3;
tempPreGrp = _arg2;
cullRect = _arg3.viewPort.cullingRectangle;
renderRec(_triMap, _arg1.v0, _arg1.v1, _arg1.v2, 0);
};
};
}
public function get precision():int{
return (_precision);
}
public function resetMapping():void{
uvMatrices = new Dictionary();
}
override public function copy(_arg1:MaterialObject3D):void{
super.copy(_arg1);
this.maxU = _arg1.maxU;
this.maxV = _arg1.maxV;
}
override public function toString():String{
return (((((("Texture:" + this.texture) + " lineColor:") + this.lineColor) + " lineAlpha:") + this.lineAlpha));
}
public function get pixelPrecision():int{
return (_perPixelPrecision);
}
public function set precise(_arg1:Boolean):void{
_precise = _arg1;
}
protected function extendBitmapEdges(_arg1:BitmapData, _arg2:Number, _arg3:Number):void{
var _local6:int;
var _local4:Rectangle = new Rectangle();
var _local5:Point = new Point();
if (_arg1.width > _arg2){
_local4.x = (_arg2 - 1);
_local4.y = 0;
_local4.width = 1;
_local4.height = _arg3;
_local5.y = 0;
_local6 = _arg2;
while (_local6 < _arg1.width) {
_local5.x = _local6;
_arg1.copyPixels(_arg1, _local4, _local5);
_local6++;
};
};
if (_arg1.height > _arg3){
_local4.x = 0;
_local4.y = (_arg3 - 1);
_local4.width = _arg1.width;
_local4.height = 1;
_local5.x = 0;
_local6 = _arg3;
while (_local6 < _arg1.height) {
_local5.y = _local6;
_arg1.copyPixels(_arg1, _local4, _local5);
_local6++;
};
};
}
override public function destroy():void{
super.destroy();
if (uvMatrices){
uvMatrices = null;
};
if (bitmap){
bitmap.dispose();
};
this.renderRecStorage = null;
}
public function set precision(_arg1:int):void{
_precision = _arg1;
}
}
}//package org.papervision3d.materials
Section 265
//ColorMaterial (org.papervision3d.materials.ColorMaterial)
package org.papervision3d.materials {
import flash.display.*;
import flash.geom.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.render.command.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.core.render.draw.*;
import org.papervision3d.core.material.*;
public class ColorMaterial extends TriangleMaterial implements ITriangleDrawer {
public function ColorMaterial(_arg1:Number=0xFF00FF, _arg2:Number=1, _arg3:Boolean=false){
this.fillColor = _arg1;
this.fillAlpha = _arg2;
this.interactive = _arg3;
}
override public function toString():String{
return (((("ColorMaterial - color:" + this.fillColor) + " alpha:") + this.fillAlpha));
}
override public function drawTriangle(_arg1:RenderTriangle, _arg2:Graphics, _arg3:RenderSessionData, _arg4:BitmapData=null, _arg5:Matrix=null):void{
var _local6:Number = _arg1.v0.x;
var _local7:Number = _arg1.v0.y;
var _local8:Number = _arg1.v1.x;
var _local9:Number = _arg1.v1.y;
var _local10:Number = _arg1.v2.x;
var _local11:Number = _arg1.v2.y;
_arg2.beginFill(fillColor, fillAlpha);
_arg2.moveTo(_local6, _local7);
_arg2.lineTo(_local8, _local9);
_arg2.lineTo(_local10, _local11);
_arg2.lineTo(_local6, _local7);
_arg2.endFill();
_arg3.renderStatistics.triangles++;
}
override public function clone():MaterialObject3D{
var _local1:MaterialObject3D = new ColorMaterial();
_local1.copy(this);
return (_local1);
}
}
}//package org.papervision3d.materials
Section 266
//MovieMaterial (org.papervision3d.materials.MovieMaterial)
package org.papervision3d.materials {
import flash.display.*;
import flash.geom.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.render.command.*;
import org.papervision3d.core.log.*;
import org.papervision3d.core.render.material.*;
import org.papervision3d.core.render.draw.*;
public class MovieMaterial extends BitmapMaterial implements ITriangleDrawer, IUpdateBeforeMaterial, IUpdateAfterMaterial {
public var movieTransparent:Boolean;
private var quality:String;
private var materialIsUsed:Boolean;// = false
private var stage:Stage;
private var autoClipRect:Rectangle;
public var allowAutoResize:Boolean;// = false
public var movie:DisplayObject;
private var movieAnimated:Boolean;
protected var recreateBitmapInSuper:Boolean;
private var userClipRect:Rectangle;
public function MovieMaterial(_arg1:DisplayObject=null, _arg2:Boolean=false, _arg3:Boolean=false, _arg4:Boolean=false, _arg5:Rectangle=null){
movieTransparent = _arg2;
this.animated = _arg3;
this.precise = _arg4;
userClipRect = _arg5;
if (_arg1){
texture = _arg1;
};
}
protected function createBitmapFromSprite(_arg1:DisplayObject):BitmapData{
movie = _arg1;
initBitmap(movie);
drawBitmap();
bitmap = super.createBitmap(bitmap);
return (bitmap);
}
public function set rect(_arg1:Rectangle):void{
userClipRect = _arg1;
createBitmapFromSprite(movie);
}
public function updateAfterRender(_arg1:RenderSessionData):void{
if ((((movieAnimated == true)) && ((materialIsUsed == true)))){
drawBitmap();
if (recreateBitmapInSuper){
bitmap = super.createBitmap(bitmap);
recreateBitmapInSuper = false;
};
};
}
public function set animated(_arg1:Boolean):void{
movieAnimated = _arg1;
}
public function drawBitmap():void{
var _local3:String;
bitmap.fillRect(bitmap.rect, fillColor);
if (((stage) && (quality))){
_local3 = stage.quality;
stage.quality = quality;
};
var _local1:Rectangle = rect;
var _local2:Matrix = new Matrix(1, 0, 0, 1, -(_local1.x), -(_local1.y));
bitmap.draw(movie, _local2, movie.transform.colorTransform, null);
if (!userClipRect){
autoClipRect = movie.getBounds(movie);
};
if (((stage) && (quality))){
stage.quality = _local3;
};
}
override public function get texture():Object{
return (this._texture);
}
public function updateBeforeRender(_arg1:RenderSessionData):void{
var _local2:int;
var _local3:int;
materialIsUsed = false;
if (movieAnimated){
if (userClipRect){
_local2 = int((userClipRect.width + 0.5));
_local3 = int((userClipRect.height + 0.5));
} else {
_local2 = int((movie.width + 0.5));
_local3 = int((movie.height + 0.5));
};
if (((allowAutoResize) && (((!((_local2 == bitmap.width))) || (!((_local3 == bitmap.height))))))){
initBitmap(movie);
recreateBitmapInSuper = true;
};
};
}
protected function initBitmap(_arg1:DisplayObject):void{
if (bitmap){
bitmap.dispose();
};
if (userClipRect){
bitmap = new BitmapData(int((userClipRect.width + 0.5)), int((userClipRect.height + 0.5)), movieTransparent, fillColor);
} else {
if ((((_arg1.width == 0)) || ((_arg1.height == 0)))){
bitmap = new BitmapData(0x0100, 0x0100, movieTransparent, fillColor);
} else {
bitmap = new BitmapData(int((_arg1.width + 0.5)), int((_arg1.height + 0.5)), movieTransparent, fillColor);
};
};
}
public function get animated():Boolean{
return (movieAnimated);
}
public function get rect():Rectangle{
var _local1:Rectangle = ((userClipRect) || (autoClipRect));
if (((!(_local1)) && (movie))){
_local1 = movie.getBounds(movie);
};
return (_local1);
}
override public function set texture(_arg1:Object):void{
if ((_arg1 is DisplayObject) == false){
PaperLogger.error("MovieMaterial.texture requires a Sprite to be passed as the object");
return;
};
bitmap = createBitmapFromSprite(DisplayObject(_arg1));
_texture = _arg1;
}
override public function drawTriangle(_arg1:RenderTriangle, _arg2:Graphics, _arg3:RenderSessionData, _arg4:BitmapData=null, _arg5:Matrix=null):void{
materialIsUsed = true;
super.drawTriangle(_arg1, _arg2, _arg3, _arg4, _arg5);
}
public function setQuality(_arg1:String, _arg2:Stage, _arg3:Boolean=true):void{
this.quality = _arg1;
this.stage = _arg2;
if (_arg3){
createBitmapFromSprite(movie);
};
}
}
}//package org.papervision3d.materials
Section 267
//WireframeMaterial (org.papervision3d.materials.WireframeMaterial)
package org.papervision3d.materials {
import flash.display.*;
import flash.geom.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.render.command.*;
import org.papervision3d.core.render.draw.*;
import org.papervision3d.core.material.*;
public class WireframeMaterial extends TriangleMaterial implements ITriangleDrawer {
public function WireframeMaterial(_arg1:Number=0xFF00FF, _arg2:Number=100, _arg3:Number=0){
this.lineColor = _arg1;
this.lineAlpha = _arg2;
this.lineThickness = _arg3;
this.doubleSided = false;
}
override public function toString():String{
return (((("WireframeMaterial - color:" + this.lineColor) + " alpha:") + this.lineAlpha));
}
override public function drawTriangle(_arg1:RenderTriangle, _arg2:Graphics, _arg3:RenderSessionData, _arg4:BitmapData=null, _arg5:Matrix=null):void{
var _local6:Number = _arg1.v0.x;
var _local7:Number = _arg1.v0.y;
if (lineAlpha){
_arg2.lineStyle(lineThickness, lineColor, lineAlpha);
_arg2.moveTo(_local6, _local7);
_arg2.lineTo(_arg1.v1.x, _arg1.v1.y);
_arg2.lineTo(_arg1.v2.x, _arg1.v2.y);
_arg2.lineTo(_local6, _local7);
_arg2.lineStyle();
_arg3.renderStatistics.triangles++;
};
}
}
}//package org.papervision3d.materials
Section 268
//DAE (org.papervision3d.objects.parsers.DAE)
package org.papervision3d.objects.parsers {
import flash.events.*;
import org.papervision3d.events.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.core.math.*;
import flash.utils.*;
import org.papervision3d.materials.utils.*;
import org.papervision3d.core.animation.channel.*;
import org.ascollada.core.*;
import org.ascollada.types.*;
import org.papervision3d.objects.special.*;
import org.papervision3d.core.log.*;
import org.papervision3d.materials.*;
import org.papervision3d.materials.shaders.*;
import org.papervision3d.core.animation.*;
import org.papervision3d.core.geom.*;
import org.papervision3d.materials.special.*;
import org.ascollada.fx.*;
import org.papervision3d.core.material.*;
import org.ascollada.io.*;
import org.papervision3d.*;
import org.ascollada.*;
import org.papervision3d.core.controller.*;
import org.ascollada.namespaces.*;
import flash.system.*;
public class DAE extends DisplayObject3D implements IAnimationDataProvider, IAnimatable {
public var filename:String;
protected var _colladaIDToObject:Object;
protected var _endTime:Number;
protected var _numSkins:uint;
public var COLLADA:XML;
protected var _channelsByTarget:Dictionary;
public var document:DaeDocument;
public var parser:DaeReader;
protected var _objectToNode:Object;
protected var _isPlaying:Boolean;// = false
protected var _currentTime:int;
public var useMaterialTargetName:Boolean;// = false
protected var _channels:Array;
public var forceCoordSet:int;// = 0
public var fileTitle:String;
protected var _geometries:Object;
protected var _totalFrames:int;// = 0
protected var _textureSets:Object;
protected var _colladaID:Dictionary;
protected var _currentFrame:int;// = 0
protected var _playerType:String;
protected var _rootNode:DisplayObject3D;
protected var _loop:Boolean;// = false
protected var _isAnimated:Boolean;// = false
protected var _colladaSIDToObject:Object;
protected var _skins:Dictionary;
protected var _controllers:Array;
protected var _queuedMaterials:Array;
protected var _rightHanded:Boolean;
protected var _startTime:Number;
protected var _colladaSID:Dictionary;
public var baseUrl:String;
public var texturePath:String;
protected var _autoPlay:Boolean;
protected var _bindVertexInputs:Dictionary;
public static const ROOTNODE_NAME:String = "COLLADA_Scene";
public static var DEFAULT_LINE_COLOR:uint = 0xFFFF00;
public static var DEFAULT_LINE_WIDTH:Number = 0;
public static var DEFAULT_TGA_ALTERNATIVE:String = "png";
public function DAE(_arg1:Boolean=true, _arg2:String=null, _arg3:Boolean=false){
super(_arg2);
_autoPlay = _arg1;
_rightHanded = Papervision3D.useRIGHTHANDED;
_loop = _arg3;
_playerType = Capabilities.playerType;
}
public function stop():void{
trace("STOP CALLED ON DAE");
_isPlaying = false;
dispatchEvent(new AnimationEvent(AnimationEvent.ANIMATION_COMPLETE, _currentFrame, _totalFrames));
}
protected function buildSkin(_arg1:Skin3D, _arg2:DaeSkin, _arg3:Array, _arg4:DaeNode):void{
var _local6:DaeController;
var _local7:DaeMorph;
var _local8:int;
var _local9:GeometryObject3D;
var _local5:GeometryObject3D = _geometries[_arg2.source];
if (!_local5){
_local6 = this.document.controllers[_arg2.source];
if (((_local6) && (_local6.morph))){
_local7 = _local6.morph;
_local5 = _geometries[_local7.source];
_local8 = 0;
while (_local8 < _local7.targets.length) {
_local9 = _geometries[_local7.targets[_local8]];
_local8++;
};
};
if (!_local5){
throw (new Error(("no geometry for source: " + _arg2.source)));
};
};
mergeGeometries(_arg1.geometry, _local5.clone(_arg1));
_skins[_arg1] = _arg2;
}
protected function onParseGeometriesComplete(_arg1:Event):void{
if (this.parser.hasEventListener(Event.COMPLETE)){
this.parser.removeEventListener(Event.COMPLETE, onParseGeometriesComplete);
};
buildScene();
}
override public function project(_arg1:DisplayObject3D, _arg2:RenderSessionData):Number{
var _local3:IObjectController;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:AbstractChannel3D;
for each (_local3 in _controllers) {
_local3.update();
};
if (((_isPlaying) && (_channels))){
_local4 = (_currentTime / 1000);
_local5 = (_endTime - _startTime);
_local6 = ((getTimer() / 1000) - _local4);
if (_local6 > _local5){
_currentTime = getTimer();
_local4 = (_currentTime / 1000);
_local6 = 0;
};
_local7 = (_local6 / _local5);
if ((((_local7 == 0)) && (!(_loop)))){
stop();
} else {
for each (_local8 in _channels) {
_local8.updateToTime(_local7);
};
};
};
return (super.project(_arg1, _arg2));
}
public function play(_arg1:String=null):void{
_currentFrame = 0;
_currentTime = getTimer();
_isPlaying = ((((_isAnimated) && (_channels))) && (_channels.length));
}
public function getAnimationChannelByName(_arg1:String):AbstractChannel3D{
return (null);
}
protected function getSymbolName(_arg1:String):String{
var _local2:DaeEffect;
var _local3:DaeEffect;
for each (_local3 in this.document.effects) {
if (_local3.id == _arg1){
return (_local3.texture_url);
};
};
return (null);
}
protected function loadNextMaterial(_arg1:FileLoadEvent=null):void{
var _local2:BitmapFileMaterial;
var _local3:Object;
var _local4:String;
var _local5:String;
var _local6:String;
var _local7:BitmapFileMaterial;
if (_arg1){
_local2 = (_arg1.target as BitmapFileMaterial);
if (((_rightHanded) && (_local2))){
BitmapMaterialTools.mirrorBitmapX(_local2.bitmap);
};
};
if (_queuedMaterials.length){
_local3 = _queuedMaterials.shift();
_local4 = _local3.url;
_local5 = _local3.symbol;
_local6 = _local3.target;
_local4 = _local4.replace(/\.tga/i, ("." + DEFAULT_TGA_ALTERNATIVE));
_local7 = _local3.material;
_local7.addEventListener(FileLoadEvent.LOAD_COMPLETE, loadNextMaterial);
_local7.addEventListener(FileLoadEvent.LOAD_ERROR, onMaterialError);
_local7.texture = _local4;
if (useMaterialTargetName){
_local7.name = _local6;
this.materials.addMaterial(_local7, _local6);
} else {
_local7.name = _local5;
this.materials.addMaterial(_local7, _local5);
};
} else {
dispatchEvent(new FileLoadEvent(FileLoadEvent.COLLADA_MATERIALS_DONE, this.filename));
onMaterialsLoaded();
};
}
protected function findChildByID(_arg1:String, _arg2:DisplayObject3D=null):DisplayObject3D{
var _local3:DisplayObject3D;
var _local4:DisplayObject3D;
_arg2 = ((_arg2) || (this));
if (_colladaID[_arg2] == _arg1){
return (_arg2);
};
for each (_local3 in _arg2.children) {
_local4 = findChildByID(_arg1, _local3);
if (_local4){
return (_local4);
};
};
return (null);
}
protected function buildImagePath(_arg1:String, _arg2:String):String{
if (texturePath != null){
_arg2 = (texturePath + _arg2.slice((_arg2.lastIndexOf("/") + 1)));
};
var _local3:Array = _arg1.split("/");
var _local4:Array = _arg2.split("/");
while (_local3[0] == ".") {
_local3.shift();
};
while (_local4[0] == ".") {
_local4.shift();
};
while (_local4[0] == "..") {
_local4.shift();
_local3.pop();
};
var _local5:String = ((_local3.length > 1)) ? _local3.join("/") : (_local3.length) ? _local3[0] : "";
_local5 = ((_local5)!="") ? ((_local5 + "/") + _local4.join("/")) : _local4.join("/");
return (_local5);
}
protected function onParseProgress(_arg1:ProgressEvent):void{
dispatchEvent(new FileLoadEvent(FileLoadEvent.LOAD_PROGRESS, this.filename, _arg1.bytesLoaded, _arg1.bytesTotal, null, null, true, false));
}
protected function buildMatrixFromTransform(_arg1:DaeTransform):Matrix3D{
var _local2:Matrix3D;
var _local3:Number = (Math.PI / 180);
var _local4:Array = _arg1.values;
switch (_arg1.type){
case ASCollada.DAE_ROTATE_ELEMENT:
_local2 = Matrix3D.rotationMatrix(_local4[0], _local4[1], _local4[2], (_local4[3] * _local3));
break;
case ASCollada.DAE_SCALE_ELEMENT:
_local2 = Matrix3D.scaleMatrix(_local4[0], _local4[1], _local4[2]);
break;
case ASCollada.DAE_TRANSLATE_ELEMENT:
_local2 = Matrix3D.translationMatrix(_local4[0], _local4[1], _local4[2]);
break;
case ASCollada.DAE_MATRIX_ELEMENT:
_local2 = new Matrix3D(_local4);
break;
default:
throw (new Error(("Unknown transform type: " + _arg1.type)));
};
return (_local2);
}
protected function buildMaterials():void{
var _local1:String;
var _local2:MaterialObject3D;
var _local3:DaeMaterial;
var _local4:String;
var _local5:MaterialObject3D;
var _local6:DaeEffect;
var _local7:DaeLambert;
var _local8:String;
var _local9:DaeImage;
var _local10:String;
_queuedMaterials = new Array();
for (_local1 in this.document.materials) {
_local2 = null;
_local3 = this.document.materials[_local1];
_local4 = this.document.materialTargetToSymbol[_local3.id];
if (useMaterialTargetName){
_local5 = this.materials.getMaterialByName(_local1);
} else {
_local5 = this.materials.getMaterialByName(_local4);
};
if (_local5 == null){
_local8 = getSymbolName(_local3.effect);
_local5 = this.materials.getMaterialByName(_local8);
this.materials.removeMaterial(_local5);
if (_local5){
if (useMaterialTargetName){
this.materials.addMaterial(_local5, _local1);
} else {
this.materials.addMaterial(_local5, _local4);
};
};
};
_local6 = document.effects[_local3.effect];
_local7 = (_local6.color as DaeLambert);
if (((_local7) && (_local7.diffuse.texture))){
_textureSets[_local4] = _local7.diffuse.texture.texcoord;
};
if (_local5){
} else {
if (((_local6) && (_local6.texture_url))){
_local9 = document.images[_local6.texture_url];
//unresolved if
_local10 = buildImagePath(this.baseUrl, _local9.init_from);
_local2 = new BitmapFileMaterial();
_local2.doubleSided = _local6.double_sided;
_queuedMaterials.push({symbol:_local4, url:_local10, material:_local2, target:_local1});
} else {
if (((_local7) && (_local7.diffuse.color))){
if (_local6.wireframe){
_local2 = new WireframeMaterial(buildColor(_local7.diffuse.color));
} else {
_local2 = new ColorMaterial(buildColor(_local7.diffuse.color));
};
} else {
_local2 = MaterialObject3D.DEFAULT;
};
_local2.doubleSided = _local6.double_sided;
if (useMaterialTargetName){
this.materials.addMaterial(_local2, _local1);
} else {
this.materials.addMaterial(_local2, _local4);
};
};
};
};
}
protected function onMaterialsLoaded():void{
if (this.parser.hasEventListener(Event.COMPLETE)){
this.parser.removeEventListener(Event.COMPLETE, onParseComplete);
};
if (this.parser.hasEventListener(ProgressEvent.PROGRESS)){
this.parser.removeEventListener(ProgressEvent.PROGRESS, onParseProgress);
};
if (document.numQueuedGeometries){
this.parser.addEventListener(Event.COMPLETE, onParseGeometriesComplete);
this.parser.readGeometries();
} else {
buildScene();
};
}
protected function buildAnimationChannel(_arg1:DisplayObject3D, _arg2:DaeChannel):MatrixChannel3D{
var _local6:Matrix3D;
var _local7:String;
var _local8:String;
var _local9:Array;
var _local10:Number;
var _local11:int;
var _local12:Number;
var _local3:DaeNode = _objectToNode[_arg1];
if (!_local3){
throw (new Error("Couldn't find the targeted object!"));
};
var _local4:MatrixChannel3D = new MatrixChannel3D(_arg1, _arg2.syntax.targetSID);
var _local5:DaeTransform = _local3.findMatrixBySID(_arg2.syntax.targetSID);
if (!_local5){
PaperLogger.warning(("Couldn't find the targeted object's transform: " + _arg2.syntax.targetSID));
return (null);
};
if (_arg2.syntax.isArrayAccess){
_local8 = _arg2.syntax.arrayMember.join("");
switch (_local8){
case "(0)(0)":
_local7 = "n11";
break;
case "(1)(0)":
_local7 = "n12";
break;
case "(2)(0)":
_local7 = "n13";
break;
case "(3)(0)":
_local7 = "n14";
break;
case "(0)(1)":
_local7 = "n21";
break;
case "(1)(1)":
_local7 = "n22";
break;
case "(2)(1)":
_local7 = "n23";
break;
case "(3)(1)":
_local7 = "n24";
break;
case "(0)(2)":
_local7 = "n31";
break;
case "(1)(2)":
_local7 = "n32";
break;
case "(2)(2)":
_local7 = "n33";
break;
case "(3)(2)":
_local7 = "n34";
break;
case "(0)(3)":
_local7 = "n41";
break;
case "(1)(3)":
_local7 = "n42";
break;
case "(2)(3)":
_local7 = "n43";
break;
case "(3)(3)":
_local7 = "n44";
break;
default:
throw (new Error(_local8));
};
};
switch (_local5.type){
case "matrix":
if (_arg2.syntax.isFullAccess){
_local11 = 0;
while (_local11 < _arg2.input.length) {
_local9 = _arg2.output[_local11];
_local6 = new Matrix3D(_local9);
_local4.addKeyFrame(new AnimationKeyFrame3D(("keyframe_" + _local11), _arg2.input[_local11], [_local6]));
_local11++;
};
} else {
if (_arg2.syntax.isArrayAccess){
_local6 = Matrix3D.clone(_arg1.transform);
_local11 = 0;
while (_local11 < _arg2.input.length) {
_local6[_local7] = _arg2.output[_local11];
_local4.addKeyFrame(new AnimationKeyFrame3D(("keyframe_" + _local11), _arg2.input[_local11], [_local6]));
_local11++;
};
} else {
throw (new Error(("Don't know how to handle this channel: " + _arg2.syntax)));
};
};
break;
case "rotate":
if (_arg2.syntax.isFullAccess){
_local11 = 0;
while (_local11 < _arg2.input.length) {
_local9 = _arg2.output[_local11];
_local6 = Matrix3D.rotationMatrix(_local9[0], _local9[1], _local9[2], (_local9[3] * (Math.PI / 180)));
_local4.addKeyFrame(new AnimationKeyFrame3D(("keyframe_" + _local11), _arg2.input[_local11], [_local6]));
_local11++;
};
} else {
if (_arg2.syntax.isDotAccess){
switch (_arg2.syntax.member){
case "ANGLE":
_local11 = 0;
while (_local11 < _arg2.input.length) {
_local12 = (_arg2.output[_local11] * (Math.PI / 180));
_local6 = Matrix3D.rotationMatrix(_local5.values[0], _local5.values[1], _local5.values[2], _local12);
_local4.addKeyFrame(new AnimationKeyFrame3D(("keyframe_" + _local11), _arg2.input[_local11], [_local6]));
_local11++;
};
break;
default:
throw (new Error(("Don't know how to handle this channel: " + _arg2.syntax)));
};
} else {
throw (new Error(("Don't know how to handle this channel: " + _arg2.syntax)));
};
};
break;
case "scale":
if (_arg2.syntax.isFullAccess){
_local11 = 0;
while (_local11 < _arg2.input.length) {
_local9 = _arg2.output[_local11];
_local6 = Matrix3D.scaleMatrix(_local9[0], _local9[1], _local9[2]);
_local4.addKeyFrame(new AnimationKeyFrame3D(("keyframe_" + _local11), _arg2.input[_local11], [_local6]));
_local11++;
};
} else {
if (_arg2.syntax.isDotAccess){
_local11 = 0;
while (_local11 < _arg2.input.length) {
_local10 = _arg2.output[_local11];
switch (_arg2.syntax.member){
case "X":
_local6 = Matrix3D.scaleMatrix(_local10, 0, 0);
_local4.addKeyFrame(new AnimationKeyFrame3D(("keyframe_" + _local11), _arg2.input[_local11], [_local6]));
break;
case "Y":
_local6 = Matrix3D.scaleMatrix(0, _local10, 0);
_local4.addKeyFrame(new AnimationKeyFrame3D(("keyframe_" + _local11), _arg2.input[_local11], [_local6]));
break;
case "Z":
_local6 = Matrix3D.scaleMatrix(0, 0, _local10);
_local4.addKeyFrame(new AnimationKeyFrame3D(("keyframe_" + _local11), _arg2.input[_local11], [_local6]));
break;
default:
break;
};
_local11++;
};
} else {
throw (new Error(("Don't know how to handle this channel: " + _arg2.syntax)));
};
};
break;
case "translate":
if (_arg2.syntax.isFullAccess){
_local11 = 0;
while (_local11 < _arg2.input.length) {
_local9 = _arg2.output[_local11];
_local6 = Matrix3D.translationMatrix(_local9[0], _local9[1], _local9[2]);
_local4.addKeyFrame(new AnimationKeyFrame3D(("keyframe_" + _local11), _arg2.input[_local11], [_local6]));
_local11++;
};
} else {
if (_arg2.syntax.isDotAccess){
_local11 = 0;
while (_local11 < _arg2.input.length) {
_local10 = _arg2.output[_local11];
switch (_arg2.syntax.member){
case "X":
_local6 = Matrix3D.translationMatrix(_local10, 0, 0);
_local4.addKeyFrame(new AnimationKeyFrame3D(("keyframe_" + _local11), _arg2.input[_local11], [_local6]));
break;
case "Y":
_local6 = Matrix3D.translationMatrix(0, _local10, 0);
_local4.addKeyFrame(new AnimationKeyFrame3D(("keyframe_" + _local11), _arg2.input[_local11], [_local6]));
break;
case "Z":
_local6 = Matrix3D.translationMatrix(0, 0, _local10);
_local4.addKeyFrame(new AnimationKeyFrame3D(("keyframe_" + _local11), _arg2.input[_local11], [_local6]));
break;
default:
break;
};
_local11++;
};
} else {
throw (new Error(("Don't know how to handle this channel: " + _arg2.syntax)));
};
};
break;
default:
throw (new Error("Unknown transform type!"));
};
return (_local4);
}
protected function onMaterialError(_arg1:Event):void{
loadNextMaterial();
}
protected function onParseComplete(_arg1:Event):void{
var _local2:DaeReader = (_arg1.target as DaeReader);
this.document = _local2.document;
_textureSets = new Object();
_colladaID = new Dictionary(true);
_colladaSID = new Dictionary(true);
_colladaIDToObject = new Object();
_colladaSIDToObject = new Object();
_objectToNode = new Object();
_skins = new Dictionary(true);
buildMaterials();
loadNextMaterial();
}
protected function buildVertices(_arg1:DaeMesh):Array{
var _local2:Array = new Array();
var _local3:int;
while (_local3 < _arg1.vertices.length) {
_local2.push(new Vertex3D(_arg1.vertices[_local3][0], _arg1.vertices[_local3][1], _arg1.vertices[_local3][2]));
_local3++;
};
return (_local2);
}
protected function buildNode(_arg1:DaeNode, _arg2:DisplayObject3D):void{
var _local3:DisplayObject3D;
var _local4:MaterialObject3D;
var _local5:int;
var _local6:DaeInstanceController;
var _local7:DaeController;
var _local8:DaeInstanceGeometry;
var _local9:GeometryObject3D;
var _local10:Array;
var _local11:DaeInstanceMaterial;
var _local12:DaeNode;
if (_arg1.controllers.length){
_local5 = 0;
while (_local5 < _arg1.controllers.length) {
_local6 = _arg1.controllers[_local5];
_local7 = document.controllers[_local6.url];
if (_local7.skin){
_local3 = new Skin3D(null, [], [], _arg1.name);
buildSkin((_local3 as Skin3D), _local7.skin, _local6.skeletons, _arg1);
} else {
if (_local7.morph){
throw (new Error("morph!"));
};
throw (new Error("A COLLADA controller should be of type <skin> or <morph>!"));
};
break;
_local5++;
};
} else {
if (_arg1.geometries.length){
_local3 = new TriangleMesh3D(null, [], [], _arg1.name);
for each (_local8 in _arg1.geometries) {
_local9 = _geometries[_local8.url];
if (!_local9){
} else {
if ((_geometries[_local8.url] is Lines3D)){
_local3.addChild(_geometries[_local8.url]);
} else {
_local10 = new Array();
if (_local8.materials){
for each (_local11 in _local8.materials) {
if (useMaterialTargetName){
_local4 = this.materials.getMaterialByName(_local11.target);
} else {
_local4 = this.materials.getMaterialByName(_local11.symbol);
};
if (_local4){
_bindVertexInputs[_local4] = _local11;
if ((((_local4 is AbstractLightShadeMaterial)) || ((_local4 is ShadedMaterial)))){
_local4.registerObject(_local3);
};
_local10.push(_local4);
};
};
};
mergeGeometries(_local3.geometry, _local9.clone(_local3), _local10);
};
};
};
} else {
_local3 = new DisplayObject3D(_arg1.name);
};
};
_local5 = 0;
while (_local5 < _arg1.instance_nodes.length) {
_local12 = document.getDaeNodeById(_arg1.instance_nodes[_local5].url);
buildNode(_local12, _local3);
_local5++;
};
_local3.copyTransform(buildMatrix(_arg1));
_local5 = 0;
while (_local5 < _arg1.nodes.length) {
buildNode(_arg1.nodes[_local5], _local3);
_local5++;
};
_colladaID[_local3] = _arg1.id;
_colladaSID[_local3] = _arg1.sid;
_colladaIDToObject[_arg1.id] = _local3;
_colladaSIDToObject[_arg1.sid] = _local3;
_objectToNode[_local3] = _arg1;
_local3.flipLightDirection = true;
_arg2.addChild(_local3);
}
protected function buildGeometries():void{
var _local1:int;
var _local2:int;
var _local3:int;
var _local4:DaeGeometry;
var _local5:GeometryObject3D;
var _local6:Lines3D;
var _local7:DaeSpline;
var _local8:Vertex3D;
var _local9:Vertex3D;
var _local10:Line3D;
_geometries = new Object();
for each (_local4 in this.document.geometries) {
if (_local4.mesh){
_local5 = new GeometryObject3D();
_local5.vertices = buildVertices(_local4.mesh);
_local5.faces = new Array();
if (!_local5.vertices.length){
continue;
};
_local1 = 0;
while (_local1 < _local4.mesh.primitives.length) {
buildFaces(_local4.mesh.primitives[_local1], _local5, 0);
_local1++;
};
_geometries[_local4.id] = _local5;
} else {
if (((_local4.spline) && (_local4.splines))){
_local6 = new Lines3D(new LineMaterial(DEFAULT_LINE_COLOR), _local4.id);
_local1 = 0;
while (_local1 < _local4.splines.length) {
_local7 = _local4.splines[_local1];
_local2 = 0;
while (_local2 < _local7.vertices.length) {
_local3 = ((_local2 + 1) % _local7.vertices.length);
_local8 = new Vertex3D(_local7.vertices[_local2][0], _local7.vertices[_local2][1], _local7.vertices[_local2][2]);
_local9 = new Vertex3D(_local7.vertices[_local3][0], _local7.vertices[_local3][1], _local7.vertices[_local3][2]);
_local10 = new Line3D(_local6, (_local6.material as LineMaterial), DEFAULT_LINE_WIDTH, _local8, _local9);
_local6.addLine(_local10);
_local2++;
};
_local1++;
};
_geometries[_local4.id] = _local6;
};
};
};
}
protected function buildColor(_arg1:Array):uint{
var _local2:uint = (_arg1[0] * 0xFF);
var _local3:uint = (_arg1[1] * 0xFF);
var _local4:uint = (_arg1[2] * 0xFF);
return ((((_local2 << 16) | (_local3 << 8)) | _local4));
}
public function getAnimationChannelsByClip(_arg1:String):Array{
return (null);
}
protected function buildAnimationChannels():void{
var _local1:DisplayObject3D;
var _local2:DaeChannel;
var _local4:int;
var _local5:DaeAnimation;
var _local6:*;
var _local7:Array;
var _local8:DaeNode;
var _local9:DaeTransform;
var _local10:Array;
var _local11:Array;
var _local12:Number;
var _local13:Object;
var _local14:MatrixChannel3D;
var _local15:Number;
var _local16:MatrixChannel3D;
var _local17:Number;
var _local18:Matrix3D;
var _local19:int;
var _local20:MatrixChannel3D;
var _local21:Number;
var _local3:Dictionary = new Dictionary(true);
_channelsByTarget = new Dictionary(true);
for each (_local5 in this.document.animations) {
_local4 = 0;
while (_local4 < _local5.channels.length) {
_local2 = _local5.channels[_local4];
_local1 = _colladaIDToObject[_local2.syntax.targetID];
if (!_local1){
throw (new Error("damn"));
};
if (!_local3[_local1]){
_local3[_local1] = new Array();
};
_local3[_local1].push(_local2);
_local4++;
};
};
for (_local6 in _local3) {
_local1 = (_local6 as DisplayObject3D);
_local7 = _local3[_local6];
_local8 = _objectToNode[_local1];
if (!_local8){
throw (new Error((("Couldn't find the targeted object with name '" + _local8.name) + "'")));
};
_local8.channels = _local7;
if (!_local7.length){
} else {
_local2 = _local7[0];
_local9 = _local8.findMatrixBySID(_local2.syntax.targetSID);
if (!_local9){
PaperLogger.warning(("Could not find a transform with SID=" + _local2.syntax.targetSID));
} else {
if ((((_local7.length == 1)) && ((_local9.type == ASCollada.DAE_MATRIX_ELEMENT)))){
_channelsByTarget[_local1] = [buildAnimationChannel(_local1, _local2)];
} else {
_local10 = new Array();
_local11 = new Array();
for each (_local2 in _local7) {
_local10 = _local10.concat(_local2.input);
};
_local10.sort(Array.NUMERIC);
_local4 = 0;
while (_local4 < _local10.length) {
_local15 = _local10[_local4];
if (_local4 == 0){
_local11.push(_local15);
} else {
if ((_local15 - _local12) > 0.01){
_local11.push(_local15);
};
};
_local12 = _local15;
_local4++;
};
_local13 = new Object();
for each (_local2 in _local7) {
_local16 = buildAnimationChannel(_local1, _local2);
if (_local16){
_local13[_local2.syntax.targetSID] = buildAnimationChannel(_local1, _local2);
};
};
_local14 = new MatrixChannel3D(_local1);
_local4 = 0;
while (_local4 < _local11.length) {
_local17 = _local11[_local4];
_local18 = Matrix3D.IDENTITY;
_local19 = 0;
while (_local19 < _local8.transforms.length) {
_local9 = _local8.transforms[_local19];
_local20 = _local13[_local9.sid];
if (_local20){
if (_local17 < _local20.startTime){
_local21 = 0;
} else {
if (_local17 > _local20.endTime){
_local21 = 1;
} else {
_local21 = (_local17 / (_local20.endTime - _local20.startTime));
};
};
_local20.updateToTime(_local21);
_local18 = Matrix3D.multiply(_local18, _local1.transform);
} else {
_local18 = Matrix3D.multiply(_local18, buildMatrixFromTransform(_local9));
};
_local19++;
};
_local14.addKeyFrame(new AnimationKeyFrame3D(("frame_" + _local4), _local17, [_local18]));
_local4++;
};
_channelsByTarget[_local1] = [_local14];
};
};
};
};
}
protected function linkSkin(_arg1:DisplayObject3D, _arg2:DaeSkin):void{
var _local3:int;
var _local6:String;
var _local7:DisplayObject3D;
var _local8:Array;
var _local9:Array;
var _local4:Object = new Object();
var _local5:SkinController = new SkinController((_arg1 as Skin3D));
_local5.bindShapeMatrix = new Matrix3D(_arg2.bind_shape_matrix);
_local5.joints = new Array();
_local5.vertexWeights = new Array();
_local5.invBindMatrices = new Array();
_local3 = 0;
while (_local3 < _arg2.joints.length) {
_local6 = _arg2.joints[_local3];
if (_local4[_local6]){
} else {
_local7 = _colladaIDToObject[_local6];
if (!_local7){
_local7 = _colladaSIDToObject[_local6];
};
if (!_local7){
throw (new Error(("Couldn't find the joint id = " + _local6)));
};
_local8 = _arg2.findJointVertexWeightsByIDOrSID(_local6);
if (!_local8){
throw (new Error(("Could not find vertex weights for joint with id = " + _local6)));
};
_local9 = _arg2.findJointBindMatrix2(_local6);
if (((!(_local9)) || (!((_local9.length == 16))))){
throw (new Error(("Could not find inverse bind matrix for joint with id = " + _local6)));
};
_local5.joints.push(_local7);
_local5.invBindMatrices.push(new Matrix3D(_local9));
_local5.vertexWeights.push(_local8);
_local4[_local6] = true;
};
_local3++;
};
_controllers.push(_local5);
}
protected function buildScene():void{
_controllers = new Array();
buildGeometries();
_rootNode = new DisplayObject3D(ROOTNODE_NAME);
var _local1:int;
while (_local1 < this.document.vscene.nodes.length) {
buildNode(this.document.vscene.nodes[_local1], _rootNode);
_local1++;
};
linkSkins();
this.addChild(_rootNode);
if (this.yUp){
} else {
_rootNode.rotationX = -90;
_rootNode.rotationY = 180;
};
if (!_rightHanded){
_rootNode.scaleX = -(_rootNode.scaleX);
};
_currentFrame = 0;
_totalFrames = 0;
_startTime = (_endTime = 0);
_channels = new Array();
_isAnimated = false;
_isPlaying = false;
if (document.numQueuedAnimations){
_isAnimated = true;
this.parser.addEventListener(Event.COMPLETE, onParseAnimationsComplete);
this.parser.addEventListener(ProgressEvent.PROGRESS, onParseAnimationsProgress);
this.parser.readAnimations();
};
dispatchEvent(new FileLoadEvent(FileLoadEvent.LOAD_COMPLETE, this.filename));
}
protected function isBakedMatrix(_arg1:DaeNode):Boolean{
if (((!(_arg1.transforms.length)) || ((_arg1.transforms.length > 1)))){
return (false);
};
var _local2:DaeTransform = _arg1.transforms[0];
return ((_local2.type == ASCollada.DAE_MATERIAL_ELEMENT));
}
protected function linkSkins():void{
var _local1:*;
var _local2:TriangleMesh3D;
_numSkins = 0;
for (_local1 in _skins) {
_local2 = (_local1 as TriangleMesh3D);
if (!_local2){
throw (new Error("Not a Skin3D?"));
};
linkSkin(_local2, _skins[_local1]);
_numSkins++;
};
}
public function getAnimationChannels(_arg1:DisplayObject3D=null):Array{
var _local3:Array;
var _local2:Array = new Array();
if (_arg1 == null){
for each (_local3 in _channelsByTarget) {
_local2 = _local2.concat(_local3);
};
} else {
if (_channelsByTarget[_arg1]){
_local2 = _local2.concat(_channelsByTarget[_arg1]);
} else {
return (null);
};
};
return (_local2);
}
protected function buildMatrix(_arg1:DaeNode):Matrix3D{
var _local2:Array = buildMatrixStack(_arg1);
var _local3:Matrix3D = Matrix3D.IDENTITY;
var _local4:int;
while (_local4 < _local2.length) {
_local3.calculateMultiply4x4(_local3, _local2[_local4]);
_local4++;
};
return (_local3);
}
protected function findChildBySID(_arg1:String, _arg2:DisplayObject3D=null):DisplayObject3D{
var _local3:DisplayObject3D;
var _local4:DisplayObject3D;
_arg2 = ((_arg2) || (this));
if (_colladaSID[_arg2] == _arg1){
return (_arg2);
};
for each (_local3 in _arg2.children) {
_local4 = findChildBySID(_arg1, _local3);
if (_local4){
return (_local4);
};
};
return (null);
}
protected function buildFileInfo(_arg1):void{
var _local2:Array;
this.filename = ((_arg1 is String)) ? String(_arg1) : "./meshes/rawdata_dae";
this.filename = this.filename.split("\\").join("/");
if (this.filename.indexOf("/") != -1){
_local2 = this.filename.split("/");
this.fileTitle = String(_local2.pop());
this.baseUrl = _local2.join("/");
} else {
this.fileTitle = this.filename;
this.baseUrl = "";
};
}
public function load(_arg1, _arg2:MaterialsList=null, _arg3:Boolean=false):void{
this.materials = ((_arg2) || (new MaterialsList()));
buildFileInfo(_arg1);
_bindVertexInputs = new Dictionary(true);
this.parser = new DaeReader(_arg3);
this.parser.addEventListener(Event.COMPLETE, onParseComplete);
this.parser.addEventListener(ProgressEvent.PROGRESS, onParseProgress);
if ((_arg1 is XML)){
this.COLLADA = (_arg1 as XML);
this.parser.loadDocument(_arg1);
} else {
if ((_arg1 is ByteArray)){
this.COLLADA = new XML(ByteArray(_arg1));
this.parser.loadDocument(_arg1);
} else {
if ((_arg1 is String)){
this.filename = String(_arg1);
this.parser.read(this.filename);
} else {
throw (new Error("load : unknown asset type!"));
};
};
};
}
protected function buildFaces(_arg1:DaePrimitive, _arg2:GeometryObject3D, _arg3:uint):void{
var _local12:int;
var _local14:int;
var _local19:DaeInstanceGeometry;
var _local20:DaeBindVertexInput;
var _local21:Array;
var _local22:Array;
var _local23:Array;
var _local24:Array;
var _local25:Array;
var _local4:Array = new Array();
var _local5:MaterialObject3D = this.materials.getMaterialByName(_arg1.material);
_local5 = ((_local5) || (MaterialObject3D.DEFAULT));
var _local6:DaeInstanceMaterial = _bindVertexInputs[_local5];
var _local7:int = this.forceCoordSet;
var _local8:String = _textureSets[_arg1.material];
var _local9:DaeGeometry = _arg1.mesh.geometry;
if (((((_local8) && (_local8.length))) && (_local9))){
_local19 = this.document.getDaeInstanceGeometry(_local9.id);
if (_local19){
_local20 = _local19.findBindVertexInput(_arg1.material, _local8);
if (_local20){
PaperLogger.info(((("using input set #" + _local20.input_set) + " for material ") + _arg1.material));
_local7 = _local20.input_set;
};
};
};
var _local10:Array = _arg1.getTexCoords(_local7);
var _local11:Array = new Array();
var _local13:int;
_local12 = 0;
while (_local12 < _local10.length) {
_local11.push(new NumberUV(_local10[_local12][0], _local10[_local12][1]));
_local12++;
};
var _local15 = (_local11.length == _arg1.vertices.length);
var _local16:Array = new Array();
var _local17:Array = new Array();
var _local18:Array = new Array();
switch (_arg1.type){
case ASCollada.DAE_LINES_ELEMENT:
_local12 = 0;
while (_local12 < _arg1.vertices.length) {
_local17[0] = _arg2.vertices[_arg1.vertices[_local12]];
_local17[1] = _arg2.vertices[_arg1.vertices[(_local12 + 1)]];
_local18[0] = (_local15) ? _local11[_local12] : new NumberUV();
_local18[1] = (_local15) ? _local11[(_local12 + 1)] : new NumberUV();
_local12 = (_local12 + 2);
};
break;
case ASCollada.DAE_TRIANGLES_ELEMENT:
_local12 = 0;
_local13 = 0;
while (_local12 < _arg1.vertices.length) {
_local16[0] = (_arg3 + _arg1.vertices[_local12]);
_local16[1] = (_arg3 + _arg1.vertices[(_local12 + 1)]);
_local16[2] = (_arg3 + _arg1.vertices[(_local12 + 2)]);
_local17[0] = _arg2.vertices[_local16[0]];
_local17[1] = _arg2.vertices[_local16[1]];
_local17[2] = _arg2.vertices[_local16[2]];
_local18[0] = (_local15) ? _local11[(_local12 + 0)] : new NumberUV();
_local18[1] = (_local15) ? _local11[(_local12 + 1)] : new NumberUV();
_local18[2] = (_local15) ? _local11[(_local12 + 2)] : new NumberUV();
_arg2.faces.push(new Triangle3D(null, [_local17[0], _local17[1], _local17[2]], _local5, [_local18[0], _local18[1], _local18[2]]));
_local12 = (_local12 + 3);
_local13++;
};
break;
case ASCollada.DAE_POLYLIST_ELEMENT:
_local12 = 0;
_local14 = 0;
while (_local12 < _arg1.vcount.length) {
_local21 = new Array();
_local22 = new Array();
_local13 = 0;
while (_local13 < _arg1.vcount[_local12]) {
_local22.push((_local15) ? _local11[_local14] : new NumberUV());
var _temp1 = _local14;
_local14 = (_local14 + 1);
_local21.push(_arg2.vertices[_arg1.vertices[_temp1]]);
_local13++;
};
if (((((!(_arg2)) || (!(_arg2.faces)))) || (!(_arg2.vertices)))){
throw (new Error("no geometry"));
};
_local17[0] = _local21[0];
_local18[0] = _local22[0];
_local13 = 1;
while (_local13 < (_local21.length - 1)) {
_local17[1] = _local21[_local13];
_local17[2] = _local21[(_local13 + 1)];
_local18[1] = _local22[_local13];
_local18[2] = _local22[(_local13 + 1)];
if ((((((_local17[0] is Vertex3D)) && ((_local17[1] is Vertex3D)))) && ((_local17[2] is Vertex3D)))){
_arg2.faces.push(new Triangle3D(null, [_local17[0], _local17[1], _local17[2]], _local5, [_local18[0], _local18[1], _local18[2]]));
};
_local13++;
};
_local12++;
};
break;
case ASCollada.DAE_POLYGONS_ELEMENT:
_local12 = 0;
_local14 = 0;
while (_local12 < _arg1.polygons.length) {
_local23 = _arg1.polygons[_local12];
_local24 = new Array();
_local25 = new Array();
_local13 = 0;
while (_local13 < _local23.length) {
_local25.push((_local15) ? _local11[_local14] : new NumberUV());
var _temp2 = _local14;
_local14 = (_local14 + 1);
_local24.push(_arg2.vertices[_arg1.vertices[_temp2]]);
_local13++;
};
_local17[0] = _local24[0];
_local18[0] = _local25[0];
_local13 = 1;
while (_local13 < (_local24.length - 1)) {
_local17[1] = _local24[_local13];
_local17[2] = _local24[(_local13 + 1)];
_local18[1] = _local25[_local13];
_local18[2] = _local25[(_local13 + 1)];
_arg2.faces.push(new Triangle3D(null, [_local17[0], _local17[1], _local17[2]], _local5, [_local18[0], _local18[1], _local18[2]]));
_local13++;
};
_local12++;
};
break;
default:
throw (new Error(("Don't know how to create face for a DaePrimitive with type = " + _arg1.type)));
};
}
public function get fps():uint{
return (20);
}
protected function mergeGeometries(_arg1:GeometryObject3D, _arg2:GeometryObject3D, _arg3:Array=null):void{
var _local4:MaterialObject3D;
var _local5:Triangle3D;
var _local6:Boolean;
var _local7:MaterialObject3D;
if (((_arg3) && (_arg3.length))){
_local4 = _arg3[0];
for each (_local5 in _arg2.faces) {
_local6 = false;
for each (_local7 in _arg3) {
if (_local7 === _local5.material){
_local6 = true;
break;
};
};
_local5.material = (_local6) ? _local5.material : _local4;
};
};
_arg1.vertices = _arg1.vertices.concat(_arg2.vertices);
_arg1.faces = _arg1.faces.concat(_arg2.faces);
_arg1.ready = true;
}
public function get yUp():Boolean{
if (this.document){
return ((this.document.asset.yUp == ASCollada.DAE_Y_UP));
};
return (false);
}
protected function onParseAnimationsProgress(_arg1:ProgressEvent):void{
PaperLogger.info(((("animations #" + _arg1.bytesLoaded) + " of ") + _arg1.bytesTotal));
}
protected function buildMatrixStack(_arg1:DaeNode):Array{
var _local2:Array = new Array();
var _local3:int;
while (_local3 < _arg1.transforms.length) {
_local2.push(buildMatrixFromTransform(_arg1.transforms[_local3]));
_local3++;
};
return (_local2);
}
protected function onParseAnimationsComplete(_arg1:Event):void{
var _local2:AbstractChannel3D;
buildAnimationChannels();
_channels = ((this.getAnimationChannels()) || (new Array()));
_currentFrame = (_totalFrames = 0);
_startTime = (_endTime = 0);
for each (_local2 in _channels) {
_totalFrames = Math.max(_totalFrames, _local2.keyFrames.length);
_startTime = Math.min(_startTime, _local2.startTime);
_endTime = Math.max(_endTime, _local2.endTime);
_local2.updateToTime(0);
};
PaperLogger.info((((((((("animations COMPLETE (#channels: " + _channels.length) + " #frames: ") + _totalFrames) + ", startTime: ") + _startTime) + " endTime: ") + _endTime) + ")"));
dispatchEvent(new FileLoadEvent(FileLoadEvent.ANIMATIONS_COMPLETE, this.filename));
if (_autoPlay){
play();
};
}
override public function removeChild(_arg1:DisplayObject3D):DisplayObject3D{
var _local3:DisplayObject3D;
var _local4:DisplayObject3D;
var _local2:DisplayObject3D = getChildByName(_arg1.name, true);
if (_local2){
_local3 = DisplayObject3D(_local2.parent);
if (_local3){
_local4 = _local3.removeChild(_local2);
if (_local4){
return (_local4);
};
};
};
return (null);
}
}
}//package org.papervision3d.objects.parsers
Section 269
//Cube (org.papervision3d.objects.primitives.Cube)
package org.papervision3d.objects.primitives {
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.core.math.*;
import org.papervision3d.materials.utils.*;
import org.papervision3d.core.log.*;
import org.papervision3d.core.geom.*;
import org.papervision3d.*;
public class Cube extends TriangleMesh3D {
public var segments:Number3D;
private var insideFaces:int;
private var excludeFaces:int;
public static var ALL:int = (((((FRONT + BACK) + RIGHT) + LEFT) + TOP) + BOTTOM);
public static var LEFT:int = 8;
public static var FRONT:int = 1;
public static var BOTTOM:int = 32;
public static var TOP:int = 16;
public static var BACK:int = 2;
public static var NONE:int = 0;
public static var RIGHT:int = 4;
public function Cube(_arg1:MaterialsList, _arg2:Number=500, _arg3:Number=500, _arg4:Number=500, _arg5:int=1, _arg6:int=1, _arg7:int=1, _arg8:int=0, _arg9:int=0){
super(_arg1.getMaterialByName("all"), new Array(), new Array(), null);
this.materials = _arg1;
this.insideFaces = _arg8;
this.excludeFaces = _arg9;
segments = new Number3D(_arg5, _arg6, _arg7);
buildCube(_arg2, _arg4, _arg3);
}
public function destroy():void{
var _local1:MaterialObject3D;
for each (_local1 in materials) {
_local1.unregisterObject(this);
};
}
protected function buildCube(_arg1:Number, _arg2:Number, _arg3:Number):void{
var _local7:Triangle3D;
var _local4:Number = (_arg1 / 2);
var _local5:Number = (_arg2 / 2);
var _local6:Number = (_arg3 / 2);
if (!(excludeFaces & FRONT)){
buildPlane("front", "x", "y", _arg1, _arg2, _local6, !(Boolean((insideFaces & FRONT))));
};
if (!(excludeFaces & BACK)){
buildPlane("back", "x", "y", _arg1, _arg2, -(_local6), Boolean((insideFaces & BACK)));
};
if (!(excludeFaces & RIGHT)){
buildPlane("right", "z", "y", _arg3, _arg2, _local4, Boolean((insideFaces & RIGHT)));
};
if (!(excludeFaces & LEFT)){
buildPlane("left", "z", "y", _arg3, _arg2, -(_local4), !(Boolean((insideFaces & LEFT))));
};
if (!(excludeFaces & TOP)){
buildPlane("top", "x", "z", _arg1, _arg3, _local5, Boolean((insideFaces & TOP)));
};
if (!(excludeFaces & BOTTOM)){
buildPlane("bottom", "x", "z", _arg1, _arg3, -(_local5), !(Boolean((insideFaces & BOTTOM))));
};
mergeVertices();
for each (_local7 in this.geometry.faces) {
_local7.renderCommand.create = createRenderTriangle;
};
this.geometry.ready = true;
if (Papervision3D.useRIGHTHANDED){
this.geometry.flipFaces();
};
}
protected function buildPlane(_arg1:String, _arg2:String, _arg3:String, _arg4:Number, _arg5:Number, _arg6:Number, _arg7:Boolean=false):void{
var _local8:MaterialObject3D;
var _local9:String;
var _local23:NumberUV;
var _local24:NumberUV;
var _local25:NumberUV;
var _local26:int;
var _local27:Vertex3D;
var _local28:Vertex3D;
var _local29:Vertex3D;
var _local30:Vertex3D;
_local8 = materials.getMaterialByName(_arg1);
if (!_local8){
_local8 = materials.getMaterialByName("all");
if (!_local8){
PaperLogger.warning("Required material not found in given materials list. Supported materials are: front, back, right, left, top, bottom & all.");
return;
};
};
_local8.registerObject(this);
if ((((((_arg2 == "x")) && ((_arg3 == "y")))) || ((((_arg2 == "y")) && ((_arg3 == "x")))))){
_local9 = "z";
} else {
if ((((((_arg2 == "x")) && ((_arg3 == "z")))) || ((((_arg2 == "z")) && ((_arg3 == "x")))))){
_local9 = "y";
} else {
if ((((((_arg2 == "z")) && ((_arg3 == "y")))) || ((((_arg2 == "y")) && ((_arg3 == "z")))))){
_local9 = "x";
};
};
};
var _local10:Number = (_arg7) ? -1 : 1;
var _local11:Number = this.segments[_arg2];
var _local12:Number = this.segments[_arg3];
var _local13:Number = (_local11 + 1);
var _local14:Number = (_local12 + 1);
var _local15:Array = this.geometry.vertices;
var _local16:Array = this.geometry.faces;
var _local17:Array = new Array();
var _local18:Number = (_arg4 / 2);
var _local19:Number = (_arg5 / 2);
var _local20:Number = (_arg4 / _local11);
var _local21:Number = (_arg5 / _local12);
var _local22:int;
while (_local22 < _local13) {
_local26 = 0;
while (_local26 < _local14) {
_local27 = new Vertex3D();
_local27[_arg2] = (((_local22 * _local20) - _local18) * _local10);
_local27[_arg3] = ((_local26 * _local21) - _local19);
_local27[_local9] = _arg6;
_local15.push(_local27);
_local17.push(_local27);
_local26++;
};
_local22++;
};
_local22 = 0;
while (_local22 < _local11) {
_local26 = 0;
while (_local26 < _local12) {
_local28 = _local17[((_local22 * _local14) + _local26)];
_local29 = _local17[((_local22 * _local14) + (_local26 + 1))];
_local30 = _local17[(((_local22 + 1) * _local14) + _local26)];
_local23 = new NumberUV((_local22 / _local11), (_local26 / _local12));
_local24 = new NumberUV((_local22 / _local11), ((_local26 + 1) / _local12));
_local25 = new NumberUV(((_local22 + 1) / _local11), (_local26 / _local12));
_local16.push(new Triangle3D(this, [_local28, _local30, _local29], _local8, [_local23, _local25, _local24]));
_local28 = _local17[(((_local22 + 1) * _local14) + (_local26 + 1))];
_local29 = _local17[(((_local22 + 1) * _local14) + _local26)];
_local30 = _local17[((_local22 * _local14) + (_local26 + 1))];
_local23 = new NumberUV(((_local22 + 1) / _local11), ((_local26 + 1) / _local12));
_local24 = new NumberUV(((_local22 + 1) / _local11), (_local26 / _local12));
_local25 = new NumberUV((_local22 / _local11), ((_local26 + 1) / _local12));
_local16.push(new Triangle3D(this, [_local29, _local28, _local30], _local8, [_local24, _local23, _local25]));
_local26++;
};
_local22++;
};
}
}
}//package org.papervision3d.objects.primitives
Section 270
//Plane (org.papervision3d.objects.primitives.Plane)
package org.papervision3d.objects.primitives {
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.core.math.*;
import org.papervision3d.core.geom.*;
import org.papervision3d.*;
public class Plane extends TriangleMesh3D {
public var segmentsH:Number;
public var segmentsW:Number;
public static var DEFAULT_SCALE:Number = 1;
public static var DEFAULT_SEGMENTS:Number = 1;
public static var DEFAULT_SIZE:Number = 500;
public function Plane(_arg1:MaterialObject3D=null, _arg2:Number=0, _arg3:Number=0, _arg4:Number=0, _arg5:Number=0){
super(_arg1, new Array(), new Array(), null);
this.segmentsW = ((_arg4) || (DEFAULT_SEGMENTS));
this.segmentsH = ((_arg5) || (this.segmentsW));
var _local6:Number = DEFAULT_SCALE;
if (!_arg3){
if (_arg2){
_local6 = _arg2;
};
if (((_arg1) && (_arg1.bitmap))){
_arg2 = (_arg1.bitmap.width * _local6);
_arg3 = (_arg1.bitmap.height * _local6);
} else {
_arg2 = (DEFAULT_SIZE * _local6);
_arg3 = (DEFAULT_SIZE * _local6);
};
};
buildPlane(_arg2, _arg3);
}
private function buildPlane(_arg1:Number, _arg2:Number):void{
var _local14:NumberUV;
var _local15:NumberUV;
var _local16:NumberUV;
var _local17:int;
var _local18:Number;
var _local19:Number;
var _local20:Vertex3D;
var _local21:Vertex3D;
var _local22:Vertex3D;
var _local3:Number = this.segmentsW;
var _local4:Number = this.segmentsH;
var _local5:Number = (_local3 + 1);
var _local6:Number = (_local4 + 1);
var _local7:Array = this.geometry.vertices;
var _local8:Array = this.geometry.faces;
var _local9:Number = (_arg1 / 2);
var _local10:Number = (_arg2 / 2);
var _local11:Number = (_arg1 / _local3);
var _local12:Number = (_arg2 / _local4);
var _local13:int;
while (_local13 < (_local3 + 1)) {
_local17 = 0;
while (_local17 < _local6) {
_local18 = ((_local13 * _local11) - _local9);
_local19 = ((_local17 * _local12) - _local10);
_local7.push(new Vertex3D(_local18, _local19, 0));
_local17++;
};
_local13++;
};
_local13 = 0;
while (_local13 < _local3) {
_local17 = 0;
while (_local17 < _local4) {
_local20 = _local7[((_local13 * _local6) + _local17)];
_local21 = _local7[((_local13 * _local6) + (_local17 + 1))];
_local22 = _local7[(((_local13 + 1) * _local6) + _local17)];
_local14 = new NumberUV((_local13 / _local3), (_local17 / _local4));
_local15 = new NumberUV((_local13 / _local3), ((_local17 + 1) / _local4));
_local16 = new NumberUV(((_local13 + 1) / _local3), (_local17 / _local4));
_local8.push(new Triangle3D(this, [_local20, _local22, _local21], material, [_local14, _local16, _local15]));
_local20 = _local7[(((_local13 + 1) * _local6) + (_local17 + 1))];
_local21 = _local7[(((_local13 + 1) * _local6) + _local17)];
_local22 = _local7[((_local13 * _local6) + (_local17 + 1))];
_local14 = new NumberUV(((_local13 + 1) / _local3), ((_local17 + 1) / _local4));
_local15 = new NumberUV(((_local13 + 1) / _local3), (_local17 / _local4));
_local16 = new NumberUV((_local13 / _local3), ((_local17 + 1) / _local4));
_local8.push(new Triangle3D(this, [_local20, _local22, _local21], material, [_local14, _local16, _local15]));
_local17++;
};
_local13++;
};
this.geometry.ready = true;
if (Papervision3D.useRIGHTHANDED){
this.geometry.flipFaces();
};
}
}
}//package org.papervision3d.objects.primitives
Section 271
//Sphere (org.papervision3d.objects.primitives.Sphere)
package org.papervision3d.objects.primitives {
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.core.math.*;
import org.papervision3d.core.geom.*;
import org.papervision3d.*;
public class Sphere extends TriangleMesh3D {
private var segmentsH:Number;
private var segmentsW:Number;
public static var MIN_SEGMENTSW:Number = 3;
public static var DEFAULT_SCALE:Number = 1;
public static var DEFAULT_RADIUS:Number = 100;
public static var DEFAULT_SEGMENTSH:Number = 6;
public static var MIN_SEGMENTSH:Number = 2;
public static var DEFAULT_SEGMENTSW:Number = 8;
public function Sphere(_arg1:MaterialObject3D=null, _arg2:Number=100, _arg3:int=8, _arg4:int=6){
super(_arg1, new Array(), new Array(), null);
this.segmentsW = Math.max(MIN_SEGMENTSW, ((_arg3) || (DEFAULT_SEGMENTSW)));
this.segmentsH = Math.max(MIN_SEGMENTSH, ((_arg4) || (DEFAULT_SEGMENTSH)));
if (_arg2 == 0){
_arg2 = DEFAULT_RADIUS;
};
var _local5:Number = DEFAULT_SCALE;
buildSphere(_arg2);
}
private function buildSphere(_arg1:Number):void{
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local11:Triangle3D;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Array;
var _local16:Vertex3D;
var _local17:Number;
var _local18:Number;
var _local19:Number;
var _local20:int;
var _local21:Boolean;
var _local22:Vertex3D;
var _local23:Vertex3D;
var _local24:Vertex3D;
var _local25:Vertex3D;
var _local26:Number;
var _local27:Number;
var _local28:Number;
var _local29:Number;
var _local30:NumberUV;
var _local31:NumberUV;
var _local32:NumberUV;
var _local33:NumberUV;
var _local5:Number = Math.max(3, this.segmentsW);
var _local6:Number = Math.max(2, this.segmentsH);
var _local7:Array = this.geometry.vertices;
var _local8:Array = this.geometry.faces;
var _local9:Array = new Array();
_local3 = 0;
while (_local3 < (_local6 + 1)) {
_local12 = Number((_local3 / _local6));
_local13 = (-(_arg1) * Math.cos((_local12 * Math.PI)));
_local14 = (_arg1 * Math.sin((_local12 * Math.PI)));
_local15 = new Array();
_local2 = 0;
while (_local2 < _local5) {
_local17 = Number(((2 * _local2) / _local5));
_local18 = (_local14 * Math.sin((_local17 * Math.PI)));
_local19 = (_local14 * Math.cos((_local17 * Math.PI)));
if (!(((((_local3 == 0)) || ((_local3 == _local6)))) && ((_local2 > 0)))){
_local16 = new Vertex3D(_local19, _local13, _local18);
_local7.push(_local16);
};
_local15.push(_local16);
_local2++;
};
_local9.push(_local15);
_local3++;
};
var _local10:int = _local9.length;
_local3 = 0;
while (_local3 < _local10) {
_local20 = _local9[_local3].length;
if (_local3 > 0){
_local2 = 0;
while (_local2 < _local20) {
_local21 = (_local2 == (_local20 - 1));
_local22 = _local9[_local3][(_local21) ? 0 : (_local2 + 1)];
_local23 = _local9[_local3][(_local21) ? (_local20 - 1) : _local2];
_local24 = _local9[(_local3 - 1)][(_local21) ? (_local20 - 1) : _local2];
_local25 = _local9[(_local3 - 1)][(_local21) ? 0 : (_local2 + 1)];
_local26 = (_local3 / (_local10 - 1));
_local27 = ((_local3 - 1) / (_local10 - 1));
_local28 = ((_local2 + 1) / _local20);
_local29 = (_local2 / _local20);
_local30 = new NumberUV(_local28, _local27);
_local31 = new NumberUV(_local28, _local26);
_local32 = new NumberUV(_local29, _local26);
_local33 = new NumberUV(_local29, _local27);
if (_local3 < (_local9.length - 1)){
_local8.push(new Triangle3D(this, new Array(_local22, _local23, _local24), material, new Array(_local31, _local32, _local33)));
};
if (_local3 > 1){
_local8.push(new Triangle3D(this, new Array(_local22, _local24, _local25), material, new Array(_local31, _local33, _local30)));
};
_local2++;
};
};
_local3++;
};
for each (_local11 in _local8) {
_local11.renderCommand.create = createRenderTriangle;
};
this.geometry.ready = true;
if (Papervision3D.useRIGHTHANDED){
this.geometry.flipFaces();
};
}
}
}//package org.papervision3d.objects.primitives
Section 272
//Skin3D (org.papervision3d.objects.special.Skin3D)
package org.papervision3d.objects.special {
import org.papervision3d.objects.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.core.geom.*;
public class Skin3D extends TriangleMesh3D {
public function Skin3D(_arg1:MaterialObject3D, _arg2:Array, _arg3:Array, _arg4:String=null){
super(_arg1, _arg2, _arg3, _arg4);
}
override public function project(_arg1:DisplayObject3D, _arg2:RenderSessionData):Number{
this.transform.copy(_arg1.world);
this.transform.invert();
return (super.project(_arg1, _arg2));
}
}
}//package org.papervision3d.objects.special
Section 273
//DisplayObject3D (org.papervision3d.objects.DisplayObject3D)
package org.papervision3d.objects {
import org.papervision3d.view.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.view.layer.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.core.data.*;
import org.papervision3d.core.math.*;
import org.papervision3d.materials.utils.*;
import org.papervision3d.core.log.*;
import org.papervision3d.materials.shaders.*;
import org.papervision3d.core.material.*;
import org.papervision3d.*;
public class DisplayObject3D extends DisplayObjectContainer3D {
public var extra:Object;
public var frustumTestMethod:int;// = 0
private var _rot:Quaternion;
public var id:int;
private var _rotationY:Number;
private var _rotationZ:Number;
public var cullTest:Number;// = 0
private var _lookatTarget:Number3D;
public var materials:MaterialsList;
public var meshSort:uint;// = 1
private var _rotationX:Number;
private var _qYaw:Quaternion;
private var _xAxis:Number3D;
private var _zAxis:Number3D;
private var _scaleDirty:Boolean;// = false
private var _autoCalcScreenCoords:Boolean;// = false
private var _tempScale:Number3D;
private var _numClones:uint;// = 0
public var alpha:Number;// = 1
public var useClipping:Boolean;// = true
public var screen:Number3D;
private var _scaleX:Number;
private var _scaleY:Number;
private var _scaleZ:Number;
public var geometry:GeometryObject3D;
private var _qPitch:Quaternion;
public var visible:Boolean;
protected var _userData:UserData;
public var screenZ:Number;
public var container:ViewportLayer;
protected var _useOwnContainer:Boolean;// = false
public var transform:Matrix3D;
private var _material:MaterialObject3D;
private var _position:Number3D;
public var name:String;
protected var _scene:SceneObject3D;// = null
private var _qRoll:Quaternion;
private var _localRotationZ:Number;// = 0
public var culled:Boolean;
public var world:Matrix3D;
public var blendMode:String;// = "normal"
private var _localRotationX:Number;// = 0
private var _localRotationY:Number;// = 0
public var view:Matrix3D;
public var parent:DisplayObjectContainer3D;
public var faces:Array;
private var _yAxis:Number3D;
public var flipLightDirection:Boolean;// = false
private var _rotation:Number3D;
protected var _transformDirty:Boolean;// = false
protected var _sorted:Array;
private var _rotationDirty:Boolean;// = false
public var parentContainer:DisplayObject3D;
public var testQuad:Boolean;// = true
public var filters:Array;
public static const MESH_SORT_CENTER:uint = 1;
private static const LEFT:Number3D = new Number3D(-1, 0, 0);
public static const MESH_SORT_CLOSE:uint = 3;
private static const BACKWARD:Number3D = new Number3D(0, 0, -1);
private static const FORWARD:Number3D = new Number3D(0, 0, 1);
public static const MESH_SORT_FAR:uint = 2;
private static const DOWN:Number3D = new Number3D(0, -1, 0);
private static const UP:Number3D = new Number3D(0, 1, 0);
private static const RIGHT:Number3D = new Number3D(1, 0, 0);
private static var entry_count:uint = 0;
private static var _newID:int = 0;
private static var _tempMatrix:Matrix3D = Matrix3D.IDENTITY;
public static var sortedArray:Array = new Array();
public static var faceLevelMode:Boolean;
private static var _tempQuat:Quaternion = new Quaternion();
private static var toRADIANS:Number = 0.0174532925199433;
private static var toDEGREES:Number = 57.2957795130823;
public function DisplayObject3D(_arg1:String=null, _arg2:GeometryObject3D=null):void{
faces = new Array();
filters = [];
screen = new Number3D();
_position = Number3D.ZERO;
_lookatTarget = Number3D.ZERO;
_zAxis = Number3D.ZERO;
_xAxis = Number3D.ZERO;
_yAxis = Number3D.ZERO;
_rotation = Number3D.ZERO;
_rot = new Quaternion();
_qPitch = new Quaternion();
_qYaw = new Quaternion();
_qRoll = new Quaternion();
super();
if (_arg1 != null){
PaperLogger.info(("DisplayObject3D: " + _arg1));
};
this.culled = false;
this.transform = Matrix3D.IDENTITY;
this.world = Matrix3D.IDENTITY;
this.view = Matrix3D.IDENTITY;
this.x = 0;
this.y = 0;
this.z = 0;
rotationX = 0;
rotationY = 0;
rotationZ = 0;
_localRotationX = (_localRotationY = (_localRotationZ = 0));
var _local3:Number = (Papervision3D.usePERCENT) ? 100 : 1;
scaleX = _local3;
scaleY = _local3;
scaleZ = _local3;
_tempScale = new Number3D();
this.visible = true;
this.id = _newID++;
this.name = ((_arg1) || (String(this.id)));
_numClones = 0;
if (_arg2){
addGeometry(_arg2);
};
}
public function set localRotationX(_arg1:Number):void{
_arg1 = (Papervision3D.useDEGREES) ? (_arg1 * toRADIANS) : _arg1;
if (this._transformDirty){
updateTransform();
};
_qPitch.setFromAxisAngle(transform.n11, transform.n21, transform.n31, (_localRotationX - _arg1));
this.transform.calculateMultiply3x3(_qPitch.matrix, transform);
_localRotationX = _arg1;
_rotationDirty = true;
}
public function set y(_arg1:Number):void{
this.transform.n24 = _arg1;
}
public function set z(_arg1:Number):void{
this.transform.n34 = _arg1;
}
override public function addChild(_arg1:DisplayObject3D, _arg2:String=null):DisplayObject3D{
_arg1 = super.addChild(_arg1, _arg2);
if (_arg1.scene == null){
_arg1.scene = scene;
};
if (this.useOwnContainer){
_arg1.parentContainer = this;
};
return (_arg1);
}
public function setChildMaterialByName(_arg1:String, _arg2:MaterialObject3D):void{
setChildMaterial(getChildByName(_arg1, true), _arg2);
}
public function moveDown(_arg1:Number):void{
translate(_arg1, DOWN);
}
public function project(_arg1:DisplayObject3D, _arg2:RenderSessionData):Number{
var _local5:DisplayObject3D;
if (this._transformDirty){
updateTransform();
};
this.world.calculateMultiply(_arg1.world, this.transform);
if (_arg2.camera.culler){
if (this === _arg2.camera){
this.culled = true;
} else {
this.culled = (_arg2.camera.culler.testObject(this) < 0);
};
if (this.culled){
_arg2.renderStatistics.culledObjects++;
return (0);
};
} else {
this.culled = false;
};
if (_arg1 !== _arg2.camera){
if (_arg2.camera.useProjectionMatrix){
this.view.calculateMultiply4x4(_arg1.view, this.transform);
} else {
this.view.calculateMultiply(_arg1.view, this.transform);
};
} else {
if (_arg2.camera.useProjectionMatrix){
this.view.calculateMultiply4x4(_arg2.camera.eye, this.transform);
} else {
this.view.calculateMultiply(_arg2.camera.eye, this.transform);
};
};
if (_autoCalcScreenCoords){
calculateScreenCoords(_arg2.camera);
};
var _local3:Number = 0;
var _local4:Number = 0;
for each (_local5 in this._childrenByName) {
if (_local5.visible){
_local3 = (_local3 + _local5.project(this, _arg2));
_local4++;
};
};
return ((this.screenZ = (_local3 / _local4)));
}
public function set scene(_arg1:SceneObject3D):void{
var _local2:DisplayObject3D;
_scene = _arg1;
for each (_local2 in this._childrenByName) {
if (_local2.scene == null){
_local2.scene = _scene;
};
};
}
public function setChildMaterial(_arg1:DisplayObject3D, _arg2:MaterialObject3D, _arg3:MaterialObject3D=null):void{
var _local4:Triangle3D;
if (!_arg1){
return;
};
if (((!(_arg3)) || ((_arg1.material === _arg3)))){
_arg1.material = _arg2;
};
if (((_arg1.geometry) && (_arg1.geometry.faces))){
for each (_local4 in _arg1.geometry.faces) {
if (((!(_arg3)) || ((_local4.material === _arg3)))){
_local4.material = _arg2;
};
};
};
}
public function get userData():UserData{
return (_userData);
}
public function get material():MaterialObject3D{
return (_material);
}
public function set userData(_arg1:UserData):void{
_userData = _arg1;
}
public function set rotationX(_arg1:Number):void{
this._rotationX = (Papervision3D.useDEGREES) ? (_arg1 * toRADIANS) : _arg1;
this._transformDirty = true;
}
public function calculateScreenCoords(_arg1:CameraObject3D):void{
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
if (_arg1.useProjectionMatrix){
_local2 = 0;
_local3 = 0;
_local4 = 0;
_local5 = ((((_local2 * view.n41) + (_local3 * view.n42)) + (_local4 * view.n43)) + view.n44);
_local6 = (_arg1.viewport.width / 2);
_local7 = (_arg1.viewport.height / 2);
screen.x = (((((_local2 * view.n11) + (_local3 * view.n12)) + (_local4 * view.n13)) + view.n14) / _local5);
screen.y = (((((_local2 * view.n21) + (_local3 * view.n22)) + (_local4 * view.n23)) + view.n24) / _local5);
screen.z = ((((_local2 * view.n31) + (_local3 * view.n32)) + (_local4 * view.n33)) + view.n34);
screen.x = (screen.x * _local6);
screen.y = (screen.y * _local7);
} else {
_local8 = ((_arg1.focus * _arg1.zoom) / (_arg1.focus + view.n34));
screen.x = (view.n14 * _local8);
screen.y = (view.n24 * _local8);
screen.z = view.n34;
};
}
public function lookAt(_arg1:DisplayObject3D, _arg2:Number3D=null):void{
var _local3:DisplayObject3D;
var _local4:Matrix3D;
if ((this is CameraObject3D)){
_position.reset(this.x, this.y, this.z);
} else {
_local3 = (this.parent as DisplayObject3D);
if (_local3){
world.calculateMultiply(_local3.world, transform);
} else {
world.copy(transform);
};
_position.reset(world.n14, world.n24, world.n34);
};
if ((_arg1 is CameraObject3D)){
_lookatTarget.reset(_arg1.x, _arg1.y, _arg1.z);
} else {
_local3 = (_arg1.parent as DisplayObject3D);
if (_local3){
_arg1.world.calculateMultiply(_local3.world, _arg1.transform);
} else {
_arg1.world.copy(_arg1.transform);
};
_lookatTarget.reset(_arg1.world.n14, _arg1.world.n24, _arg1.world.n34);
};
_zAxis.copyFrom(_lookatTarget);
_zAxis.minusEq(_position);
_zAxis.normalize();
if (_zAxis.modulo > 0.1){
_xAxis = Number3D.cross(_zAxis, ((_arg2) || (UP)), _xAxis);
_xAxis.normalize();
_yAxis = Number3D.cross(_zAxis, _xAxis, _yAxis);
_yAxis.normalize();
_local4 = this.transform;
_local4.n11 = (_xAxis.x * _scaleX);
_local4.n21 = (_xAxis.y * _scaleX);
_local4.n31 = (_xAxis.z * _scaleX);
_local4.n12 = (-(_yAxis.x) * _scaleY);
_local4.n22 = (-(_yAxis.y) * _scaleY);
_local4.n32 = (-(_yAxis.z) * _scaleY);
_local4.n13 = (_zAxis.x * _scaleZ);
_local4.n23 = (_zAxis.y * _scaleZ);
_local4.n33 = (_zAxis.z * _scaleZ);
_localRotationX = (_localRotationY = (_localRotationZ = 0));
this._transformDirty = false;
this._rotationDirty = true;
} else {
PaperLogger.error("lookAt error");
};
}
public function set rotationZ(_arg1:Number):void{
this._rotationZ = (Papervision3D.useDEGREES) ? (_arg1 * toRADIANS) : _arg1;
this._transformDirty = true;
}
public function pitch(_arg1:Number):void{
_arg1 = (Papervision3D.useDEGREES) ? (_arg1 * toRADIANS) : _arg1;
if (this._transformDirty){
updateTransform();
};
_qPitch.setFromAxisAngle(transform.n11, transform.n21, transform.n31, _arg1);
this.transform.calculateMultiply3x3(_qPitch.matrix, transform);
_localRotationX = (_localRotationX + _arg1);
_rotationDirty = true;
}
public function set rotationY(_arg1:Number):void{
this._rotationY = (Papervision3D.useDEGREES) ? (_arg1 * toRADIANS) : _arg1;
this._transformDirty = true;
}
public function get position():Number3D{
_position.reset(this.x, this.y, this.z);
return (_position);
}
public function get sceneX():Number{
return (this.world.n14);
}
public function get scaleX():Number{
if (Papervision3D.usePERCENT){
return ((this._scaleX * 100));
};
return (this._scaleX);
}
public function get scaleY():Number{
if (Papervision3D.usePERCENT){
return ((this._scaleY * 100));
};
return (this._scaleY);
}
public function get scaleZ():Number{
if (Papervision3D.usePERCENT){
return ((this._scaleZ * 100));
};
return (this._scaleZ);
}
public function get scale():Number{
if ((((this._scaleX == this._scaleY)) && ((this._scaleX == this._scaleZ)))){
if (Papervision3D.usePERCENT){
return ((this._scaleX * 100));
};
return (this._scaleX);
//unresolved jump
};
return (NaN);
}
public function set position(_arg1:Number3D):void{
this.x = _arg1.x;
this.y = _arg1.y;
this.z = _arg1.z;
}
public function moveUp(_arg1:Number):void{
translate(_arg1, UP);
}
public function get sceneZ():Number{
return (this.world.n34);
}
public function get sceneY():Number{
return (this.world.n24);
}
public function distanceTo(_arg1:DisplayObject3D):Number{
var _local2:Number = (this.x - _arg1.x);
var _local3:Number = (this.y - _arg1.y);
var _local4:Number = (this.z - _arg1.z);
return (Math.sqrt((((_local2 * _local2) + (_local3 * _local3)) + (_local4 * _local4))));
}
public function addGeometry(_arg1:GeometryObject3D=null):void{
if (_arg1){
this.geometry = _arg1;
};
}
protected function setParentContainer(_arg1:DisplayObject3D, _arg2:Boolean=true):void{
var _local3:DisplayObject3D;
if (((_arg2) && (!((_arg1 == this))))){
parentContainer = _arg1;
};
for each (_local3 in children) {
_local3.setParentContainer(_arg1, _arg2);
};
}
private function updateMaterials(_arg1:DisplayObject3D, _arg2:MaterialObject3D, _arg3:MaterialObject3D):void{
var _local4:DisplayObject3D;
var _local5:Triangle3D;
_arg2.unregisterObject(_arg1);
if ((((_arg3 is AbstractLightShadeMaterial)) || ((_arg3 is ShadedMaterial)))){
_arg3.registerObject(_arg1);
};
if (_arg1.material === _arg2){
_arg1.material = _arg3;
};
if (((((_arg1.geometry) && (_arg1.geometry.faces))) && (_arg1.geometry.faces.length))){
for each (_local5 in _arg1.geometry.faces) {
if (_local5.material === _arg2){
_local5.material = _arg3;
};
};
};
for each (_local4 in _arg1.children) {
updateMaterials(_local4, _arg2, _arg3);
};
}
public function clone():DisplayObject3D{
var _local3:DisplayObject3D;
var _local1:String = ((this.name + "_") + _numClones++);
var _local2:DisplayObject3D = new DisplayObject3D(_local1);
if (this.material){
_local2.material = this.material;
};
if (this.materials){
_local2.materials = this.materials.clone();
};
if (this.geometry){
_local2.geometry = this.geometry.clone(_local2);
_local2.geometry.ready = true;
};
_local2.copyTransform(this.transform);
for each (_local3 in this.children) {
_local2.addChild(_local3.clone());
};
return (_local2);
}
public function set material(_arg1:MaterialObject3D):void{
if (_material){
_material.unregisterObject(this);
};
_material = _arg1;
if (_material){
_material.registerObject(this);
};
}
private function updateRotation():void{
_tempScale.x = (Papervision3D.usePERCENT) ? (_scaleX * 100) : _scaleX;
_tempScale.y = (Papervision3D.usePERCENT) ? (_scaleY * 100) : _scaleY;
_tempScale.z = (Papervision3D.usePERCENT) ? (_scaleZ * 100) : _scaleZ;
_rotation = Matrix3D.matrix2euler(this.transform, _rotation, _tempScale);
this._rotationX = (_rotation.x * toRADIANS);
this._rotationY = (_rotation.y * toRADIANS);
this._rotationZ = (_rotation.z * toRADIANS);
this._rotationDirty = false;
}
public function hitTestObject(_arg1:DisplayObject3D, _arg2:Number=1):Boolean{
var _local3:Number = (this.x - _arg1.x);
var _local4:Number = (this.y - _arg1.y);
var _local5:Number = (this.z - _arg1.z);
var _local6:Number = (((_local3 * _local3) + (_local4 * _local4)) + (_local5 * _local5));
var _local7:Number = (this.geometry) ? this.geometry.boundingSphere.maxDistance : 0;
var _local8:Number = (_arg1.geometry) ? _arg1.geometry.boundingSphere.maxDistance : 0;
_local7 = (_local7 * _arg2);
return (((_local7 + _local8) > _local6));
}
public function translate(_arg1:Number, _arg2:Number3D):void{
var _local3:Number3D = _arg2.clone();
if (this._transformDirty){
updateTransform();
};
Matrix3D.rotateAxis(transform, _local3);
this.x = (this.x + (_arg1 * _local3.x));
this.y = (this.y + (_arg1 * _local3.y));
this.z = (this.z + (_arg1 * _local3.z));
}
public function get localRotationZ():Number{
return ((Papervision3D.useDEGREES) ? (_localRotationZ * toDEGREES) : _localRotationZ);
}
public function get localRotationY():Number{
return ((Papervision3D.useDEGREES) ? (_localRotationY * toDEGREES) : _localRotationY);
}
public function get z():Number{
return (this.transform.n34);
}
public function get localRotationX():Number{
return ((Papervision3D.useDEGREES) ? (_localRotationX * toDEGREES) : _localRotationX);
}
public function get x():Number{
return (this.transform.n14);
}
public function get y():Number{
return (this.transform.n24);
}
public function moveLeft(_arg1:Number):void{
translate(_arg1, LEFT);
}
public function replaceMaterialByName(_arg1:MaterialObject3D, _arg2:String):void{
if (!this.materials){
return;
};
var _local3:MaterialObject3D = this.materials.getMaterialByName(_arg2);
if (!_local3){
return;
};
if (this.material === _local3){
this.material = _arg1;
};
_local3 = this.materials.removeMaterial(_local3);
_arg1 = this.materials.addMaterial(_arg1, _arg2);
updateMaterials(this, _local3, _arg1);
}
public function get scene():SceneObject3D{
return (_scene);
}
public function set useOwnContainer(_arg1:Boolean):void{
_useOwnContainer = _arg1;
setParentContainer(this, true);
}
public function getMaterialByName(_arg1:String):MaterialObject3D{
var _local3:DisplayObject3D;
var _local2:MaterialObject3D = (this.materials) ? this.materials.getMaterialByName(_arg1) : null;
if (_local2){
return (_local2);
};
for each (_local3 in this._childrenByName) {
_local2 = _local3.getMaterialByName(_arg1);
if (_local2){
return (_local2);
};
};
return (null);
}
public function copyTransform(_arg1):void{
var _local4:DisplayObject3D;
if ((_arg1 is DisplayObject3D)){
_local4 = DisplayObject3D(_arg1);
if (_local4._transformDirty){
_local4.updateTransform();
};
};
var _local2:Matrix3D = this.transform;
var _local3:Matrix3D = ((_arg1 is DisplayObject3D)) ? _arg1.transform : _arg1;
_local2.n11 = _local3.n11;
_local2.n12 = _local3.n12;
_local2.n13 = _local3.n13;
_local2.n14 = _local3.n14;
_local2.n21 = _local3.n21;
_local2.n22 = _local3.n22;
_local2.n23 = _local3.n23;
_local2.n24 = _local3.n24;
_local2.n31 = _local3.n31;
_local2.n32 = _local3.n32;
_local2.n33 = _local3.n33;
_local2.n34 = _local3.n34;
this._transformDirty = false;
this._rotationDirty = true;
}
public function get rotationY():Number{
if (this._rotationDirty){
updateRotation();
};
return ((Papervision3D.useDEGREES) ? (this._rotationY * toDEGREES) : this._rotationY);
}
public function get rotationZ():Number{
if (this._rotationDirty){
updateRotation();
};
return ((Papervision3D.useDEGREES) ? (this._rotationZ * toDEGREES) : this._rotationZ);
}
public function set scaleY(_arg1:Number):void{
if (this._rotationDirty){
updateRotation();
};
if (Papervision3D.usePERCENT){
this._scaleY = (_arg1 / 100);
} else {
this._scaleY = _arg1;
};
this._transformDirty = true;
}
public function roll(_arg1:Number):void{
_arg1 = (Papervision3D.useDEGREES) ? (_arg1 * toRADIANS) : _arg1;
if (_transformDirty){
updateTransform();
};
_qRoll.setFromAxisAngle(transform.n13, transform.n23, transform.n33, _arg1);
transform.calculateMultiply3x3(_qRoll.matrix, transform);
_localRotationZ = (_localRotationZ + _arg1);
_rotationDirty = true;
}
public function set scaleZ(_arg1:Number):void{
if (this._rotationDirty){
updateRotation();
};
if (Papervision3D.usePERCENT){
this._scaleZ = (_arg1 / 100);
} else {
this._scaleZ = _arg1;
};
this._transformDirty = true;
}
public function get rotationX():Number{
if (this._rotationDirty){
updateRotation();
};
return ((Papervision3D.useDEGREES) ? (this._rotationX * toDEGREES) : this._rotationX);
}
public function set scale(_arg1:Number):void{
if (this._rotationDirty){
updateRotation();
};
if (Papervision3D.usePERCENT){
_arg1 = (_arg1 / 100);
};
this._scaleX = (this._scaleY = (this._scaleZ = _arg1));
this._transformDirty = true;
}
public function get autoCalcScreenCoords():Boolean{
return (_autoCalcScreenCoords);
}
public function yaw(_arg1:Number):void{
_arg1 = (Papervision3D.useDEGREES) ? (_arg1 * toRADIANS) : _arg1;
if (_transformDirty){
updateTransform();
};
_qYaw.setFromAxisAngle(transform.n12, transform.n22, transform.n32, _arg1);
transform.calculateMultiply3x3(_qYaw.matrix, transform);
_localRotationY = (_localRotationY + _arg1);
_rotationDirty = true;
}
public function set scaleX(_arg1:Number):void{
if (this._rotationDirty){
updateRotation();
};
if (Papervision3D.usePERCENT){
this._scaleX = (_arg1 / 100);
} else {
this._scaleX = _arg1;
};
this._transformDirty = true;
}
public function createViewportLayer(_arg1:Viewport3D, _arg2:Boolean=true):ViewportLayer{
var _local3:ViewportLayer = _arg1.getChildLayer(this, true);
if (_arg2){
addChildrenToLayer(this, _local3);
};
return (_local3);
}
override public function toString():String{
return (((((((this.name + ": x:") + Math.round(this.x)) + " y:") + Math.round(this.y)) + " z:") + Math.round(this.z)));
}
public function moveForward(_arg1:Number):void{
translate(_arg1, FORWARD);
}
public function addChildrenToLayer(_arg1:DisplayObject3D, _arg2:ViewportLayer):void{
var _local3:DisplayObject3D;
for each (_local3 in _arg1.children) {
_arg2.addDisplayObject3D(_local3);
_local3.addChildrenToLayer(_local3, _arg2);
};
}
public function copyPosition(_arg1):void{
var _local2:Matrix3D = this.transform;
var _local3:Matrix3D = ((_arg1 is DisplayObject3D)) ? _arg1.transform : _arg1;
_local2.n14 = _local3.n14;
_local2.n24 = _local3.n24;
_local2.n34 = _local3.n34;
}
public function get useOwnContainer():Boolean{
return (_useOwnContainer);
}
public function updateTransform():void{
_rot.setFromEuler(_rotationY, _rotationZ, _rotationX);
this.transform.copy3x3(_rot.matrix);
_tempMatrix.reset();
_tempMatrix.n11 = this._scaleX;
_tempMatrix.n22 = this._scaleY;
_tempMatrix.n33 = this._scaleZ;
this.transform.calculateMultiply(this.transform, _tempMatrix);
_transformDirty = false;
}
public function hitTestPoint(_arg1:Number, _arg2:Number, _arg3:Number):Boolean{
var _local4:Number = (this.x - _arg1);
var _local5:Number = (this.y - _arg2);
var _local6:Number = (this.z - _arg3);
var _local7:Number = (((_local4 * _local4) + (_local5 * _local5)) + (_local6 * _local6));
var _local8:Number = (this.geometry) ? this.geometry.boundingSphere.maxDistance : 0;
return ((_local8 > _local7));
}
public function moveBackward(_arg1:Number):void{
translate(_arg1, BACKWARD);
}
public function set localRotationY(_arg1:Number):void{
_arg1 = (Papervision3D.useDEGREES) ? (_arg1 * toRADIANS) : _arg1;
if (_transformDirty){
updateTransform();
};
_qYaw.setFromAxisAngle(transform.n12, transform.n22, transform.n32, (_localRotationY - _arg1));
transform.calculateMultiply3x3(_qYaw.matrix, transform);
_localRotationY = _arg1;
_rotationDirty = true;
}
public function set localRotationZ(_arg1:Number):void{
_arg1 = (Papervision3D.useDEGREES) ? (_arg1 * toRADIANS) : _arg1;
if (_transformDirty){
updateTransform();
};
_qRoll.setFromAxisAngle(transform.n13, transform.n23, transform.n33, (_localRotationZ - _arg1));
transform.calculateMultiply3x3(_qRoll.matrix, transform);
_localRotationZ = _arg1;
_rotationDirty = true;
}
public function moveRight(_arg1:Number):void{
translate(_arg1, RIGHT);
}
public function set x(_arg1:Number):void{
this.transform.n14 = _arg1;
}
public function materialsList():String{
var _local2:String;
var _local3:DisplayObject3D;
var _local1 = "";
for (_local2 in this.materials) {
_local1 = (_local1 + (_local2 + "\n"));
};
for each (_local3 in this._childrenByName) {
for (_local2 in _local3.materials.materialsByName) {
_local1 = (_local1 + (("+ " + _local2) + "\n"));
};
};
return (_local1);
}
public function set autoCalcScreenCoords(_arg1:Boolean):void{
_autoCalcScreenCoords = _arg1;
}
public static function get ZERO():DisplayObject3D{
return (new (DisplayObject3D));
}
}
}//package org.papervision3d.objects
Section 274
//BasicRenderEngine (org.papervision3d.render.BasicRenderEngine)
package org.papervision3d.render {
import org.papervision3d.events.*;
import flash.geom.*;
import org.papervision3d.view.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.view.layer.*;
import org.papervision3d.core.render.command.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.core.render.material.*;
import org.papervision3d.core.utils.*;
import org.papervision3d.core.render.*;
import org.papervision3d.core.clipping.*;
import org.papervision3d.core.render.sort.*;
import org.papervision3d.core.render.project.*;
import org.papervision3d.core.render.filter.*;
public class BasicRenderEngine extends AbstractRenderEngine implements IRenderEngine {
public var clipping:DefaultClipping;
protected var renderDoneEvent:RendererEvent;
public var sorter:IRenderSorter;
public var projectionPipeline:ProjectionPipeline;
protected var renderList:Array;
protected var renderStatistics:RenderStatistics;
protected var cleanRHD:RenderHitData;
protected var projectionDoneEvent:RendererEvent;
protected var renderSessionData:RenderSessionData;
protected var stopWatch:StopWatch;
public var filter:IRenderFilter;
public function BasicRenderEngine():void{
cleanRHD = new RenderHitData();
super();
init();
}
protected function doRender(_arg1:RenderSessionData, _arg2:Array=null):RenderStatistics{
var _local3:RenderableListItem;
var _local5:ViewportLayer;
stopWatch.reset();
stopWatch.start();
MaterialManager.getInstance().updateMaterialsBeforeRender(_arg1);
filter.filter(renderList);
sorter.sort(renderList);
var _local4:Viewport3D = _arg1.viewPort;
while ((_local3 = renderList.pop())) {
_local5 = _local4.accessLayerFor(_local3, true);
_local3.render(_arg1, _local5.graphicsChannel);
_local4.lastRenderList.push(_local3);
_local5.processRenderItem(_local3);
};
MaterialManager.getInstance().updateMaterialsAfterRender(_arg1);
_arg1.renderStatistics.renderTime = stopWatch.stop();
_arg1.viewPort.updateAfterRender(_arg1);
return (renderStatistics);
}
protected function init():void{
renderStatistics = new RenderStatistics();
projectionPipeline = new BasicProjectionPipeline();
stopWatch = new StopWatch();
sorter = new BasicRenderSorter();
filter = new BasicRenderFilter();
renderList = new Array();
clipping = null;
renderSessionData = new RenderSessionData();
renderSessionData.renderer = this;
projectionDoneEvent = new RendererEvent(RendererEvent.PROJECTION_DONE, renderSessionData);
renderDoneEvent = new RendererEvent(RendererEvent.RENDER_DONE, renderSessionData);
}
override public function renderScene(_arg1:SceneObject3D, _arg2:CameraObject3D, _arg3:Viewport3D):RenderStatistics{
_arg2.viewport = _arg3.sizeRectangle;
renderSessionData.scene = _arg1;
renderSessionData.camera = _arg2;
renderSessionData.viewPort = _arg3;
renderSessionData.container = _arg3.containerSprite;
renderSessionData.triangleCuller = _arg3.triangleCuller;
renderSessionData.particleCuller = _arg3.particleCuller;
renderSessionData.renderObjects = _arg1.objects;
renderSessionData.renderLayers = null;
renderSessionData.renderStatistics.clear();
renderSessionData.clipping = clipping;
if (clipping){
clipping.reset(renderSessionData);
};
_arg3.updateBeforeRender(renderSessionData);
projectionPipeline.project(renderSessionData);
if (hasEventListener(RendererEvent.PROJECTION_DONE)){
dispatchEvent(projectionDoneEvent);
};
doRender(renderSessionData, null);
if (hasEventListener(RendererEvent.RENDER_DONE)){
dispatchEvent(renderDoneEvent);
};
return (renderSessionData.renderStatistics);
}
public function hitTestPoint2D(_arg1:Point, _arg2:Viewport3D):RenderHitData{
return (_arg2.hitTestPoint2D(_arg1));
}
override public function removeFromRenderList(_arg1:IRenderListItem):int{
return (renderList.splice(renderList.indexOf(_arg1), 1));
}
override public function addToRenderList(_arg1:RenderableListItem):int{
return (renderList.push(_arg1));
}
private function getLayerObjects(_arg1:Array):Array{
var _local3:ViewportLayer;
var _local2:Array = new Array();
for each (_local3 in _arg1) {
_local2 = _local2.concat(_local3.getLayerObjects());
};
return (_local2);
}
public function destroy():void{
renderDoneEvent = null;
projectionDoneEvent = null;
projectionPipeline = null;
sorter = null;
filter = null;
renderStatistics = null;
renderList = null;
renderSessionData.destroy();
renderSessionData = null;
cleanRHD = null;
stopWatch = null;
clipping = null;
}
public function renderLayers(_arg1:SceneObject3D, _arg2:CameraObject3D, _arg3:Viewport3D, _arg4:Array=null):RenderStatistics{
renderSessionData.scene = _arg1;
renderSessionData.camera = _arg2;
renderSessionData.viewPort = _arg3;
renderSessionData.container = _arg3.containerSprite;
renderSessionData.triangleCuller = _arg3.triangleCuller;
renderSessionData.particleCuller = _arg3.particleCuller;
renderSessionData.renderObjects = getLayerObjects(_arg4);
renderSessionData.renderLayers = _arg4;
renderSessionData.renderStatistics.clear();
renderSessionData.clipping = clipping;
_arg3.updateBeforeRender(renderSessionData);
projectionPipeline.project(renderSessionData);
if (hasEventListener(RendererEvent.PROJECTION_DONE)){
dispatchEvent(projectionDoneEvent);
};
doRender(renderSessionData);
if (hasEventListener(RendererEvent.RENDER_DONE)){
dispatchEvent(renderDoneEvent);
};
return (renderSessionData.renderStatistics);
}
}
}//package org.papervision3d.render
Section 275
//Scene3D (org.papervision3d.scenes.Scene3D)
package org.papervision3d.scenes {
import org.papervision3d.core.proto.*;
public class Scene3D extends SceneObject3D {
}
}//package org.papervision3d.scenes
Section 276
//ViewportLayerSortMode (org.papervision3d.view.layer.util.ViewportLayerSortMode)
package org.papervision3d.view.layer.util {
public class ViewportLayerSortMode {
public static var Z_SORT:String = "z";
public static var ORIGIN_SORT:String = "origin";
public static var INDEX_SORT:String = "index";
}
}//package org.papervision3d.view.layer.util
Section 277
//ViewportBaseLayer (org.papervision3d.view.layer.ViewportBaseLayer)
package org.papervision3d.view.layer {
import org.papervision3d.view.*;
import org.papervision3d.objects.*;
public class ViewportBaseLayer extends ViewportLayer {
public function ViewportBaseLayer(_arg1:Viewport3D){
super(_arg1, null);
}
override public function getChildLayer(_arg1:DisplayObject3D, _arg2:Boolean=true, _arg3:Boolean=false):ViewportLayer{
if (layers[_arg1]){
return (layers[_arg1]);
};
if (((_arg2) || (_arg1.useOwnContainer))){
return (getChildLayerFor(_arg1, _arg3));
};
return (this);
}
override public function updateBeforeRender():void{
clear();
var _local1:int = (childLayers.length - 1);
while (_local1 >= 0) {
if (childLayers[_local1].dynamicLayer){
removeLayerAt(_local1);
};
_local1--;
};
super.updateBeforeRender();
}
}
}//package org.papervision3d.view.layer
Section 278
//ViewportLayer (org.papervision3d.view.layer.ViewportLayer)
package org.papervision3d.view.layer {
import flash.display.*;
import org.papervision3d.view.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.render.command.*;
import flash.utils.*;
import org.papervision3d.core.log.*;
import org.papervision3d.view.layer.util.*;
public class ViewportLayer extends Sprite {
public var layerIndex:Number;
public var layers:Dictionary;
public var childLayers:Array;
public var weight:Number;// = 0
public var dynamicLayer:Boolean;// = false
public var forceDepth:Boolean;// = false
public var displayObject3D:DisplayObject3D;
public var sortMode:String;
protected var viewport:Viewport3D;
public var displayObjects:Dictionary;
public var graphicsChannel:Graphics;
public var originDepth:Number;// = 0
public var screenDepth:Number;// = 0
public function ViewportLayer(_arg1:Viewport3D, _arg2:DisplayObject3D, _arg3:Boolean=false){
layers = new Dictionary(true);
displayObjects = new Dictionary(true);
sortMode = ViewportLayerSortMode.Z_SORT;
super();
this.viewport = _arg1;
this.displayObject3D = _arg2;
this.dynamicLayer = _arg3;
this.graphicsChannel = this.graphics;
if (_arg3){
this.filters = _arg2.filters;
this.blendMode = _arg2.blendMode;
this.alpha = _arg2.alpha;
};
if (_arg2){
addDisplayObject3D(_arg2);
_arg2.container = this;
};
init();
}
public function removeLayerAt(_arg1:Number):void{
var _local2:DisplayObject3D;
for each (_local2 in childLayers[_arg1].displayObjects) {
unlinkChild(_local2);
};
removeChild(childLayers[_arg1]);
childLayers.splice(_arg1, 1);
}
private function onChildAdded(_arg1:ViewportLayerEvent):void{
if (_arg1.do3d){
linkChild(_arg1.do3d, _arg1.layer, _arg1);
};
}
public function addLayer(_arg1:ViewportLayer):void{
var _local2:DisplayObject3D;
var _local3:ViewportLayer;
if (childLayers.indexOf(_arg1) != -1){
PaperLogger.warning("Child layer already exists in ViewportLayer");
return;
};
childLayers.push(_arg1);
addChild(_arg1);
_arg1.addEventListener(ViewportLayerEvent.CHILD_ADDED, onChildAdded);
_arg1.addEventListener(ViewportLayerEvent.CHILD_REMOVED, onChildRemoved);
for each (_local2 in _arg1.displayObjects) {
linkChild(_local2, _arg1);
};
for each (_local3 in _arg1.layers) {
for each (_local2 in _local3.displayObjects) {
linkChild(_local2, _local3);
};
};
}
protected function getChildLayerFor(_arg1:DisplayObject3D, _arg2:Boolean=false):ViewportLayer{
var _local3:ViewportLayer;
if (_arg1){
_local3 = new ViewportLayer(viewport, _arg1, _arg1.useOwnContainer);
addLayer(_local3);
if (_arg2){
_arg1.addChildrenToLayer(_arg1, _local3);
};
return (_local3);
} else {
PaperLogger.warning("Needs to be a do3d");
};
return (null);
}
public function updateAfterRender():void{
var _local1:ViewportLayer;
for each (_local1 in childLayers) {
_local1.updateAfterRender();
};
}
protected function init():void{
childLayers = new Array();
}
public function clear():void{
graphicsChannel.clear();
reset();
}
public function childLayerIndex(_arg1:DisplayObject3D):Number{
_arg1 = (_arg1.parentContainer) ? _arg1.parentContainer : _arg1;
var _local2:int;
while (_local2 < childLayers.length) {
if (childLayers[_local2].hasDisplayObject3D(_arg1)){
return (_local2);
};
_local2++;
};
return (-1);
}
protected function reset():void{
if (!forceDepth){
screenDepth = 0;
originDepth = 0;
};
this.weight = 0;
}
public function updateInfo():void{
var _local1:ViewportLayer;
for each (_local1 in childLayers) {
_local1.updateInfo();
if (!forceDepth){
if (!isNaN(_local1.screenDepth)){
this.weight = (this.weight + _local1.weight);
this.screenDepth = (this.screenDepth + (_local1.screenDepth * _local1.weight));
this.originDepth = (this.originDepth + (_local1.originDepth * _local1.weight));
};
};
};
if (!forceDepth){
this.screenDepth = (this.screenDepth / this.weight);
this.originDepth = (this.originDepth / this.weight);
};
}
public function getChildLayer(_arg1:DisplayObject3D, _arg2:Boolean=true, _arg3:Boolean=false):ViewportLayer{
_arg1 = (_arg1.parentContainer) ? _arg1.parentContainer : _arg1;
if (layers[_arg1]){
return (layers[_arg1]);
};
if (_arg2){
return (getChildLayerFor(_arg1, _arg3));
};
return (null);
}
protected function orderLayers():void{
var _local2:ViewportLayer;
var _local1:int;
while (_local1 < childLayers.length) {
_local2 = childLayers[_local1];
if (this.getChildIndex(_local2) != _local1){
this.setChildIndex(_local2, _local1);
};
_local2.sortChildLayers();
_local1++;
};
}
public function updateBeforeRender():void{
var _local1:ViewportLayer;
clear();
for each (_local1 in childLayers) {
_local1.updateBeforeRender();
};
}
public function hasDisplayObject3D(_arg1:DisplayObject3D):Boolean{
return (!((displayObjects[_arg1] == null)));
}
public function sortChildLayers():void{
switch (sortMode){
case ViewportLayerSortMode.Z_SORT:
childLayers.sortOn("screenDepth", (Array.DESCENDING | Array.NUMERIC));
break;
case ViewportLayerSortMode.INDEX_SORT:
childLayers.sortOn("layerIndex", Array.NUMERIC);
break;
case ViewportLayerSortMode.ORIGIN_SORT:
childLayers.sortOn(["originDepth", "screenDepth"], [(Array.DESCENDING | Array.NUMERIC), (Array.DESCENDING | Array.NUMERIC)]);
break;
};
orderLayers();
}
private function onChildRemoved(_arg1:ViewportLayerEvent):void{
if (_arg1.do3d){
unlinkChild(_arg1.do3d, _arg1);
};
}
public function removeAllLayers():void{
var _local1:int = (childLayers.length - 1);
while (_local1 >= 0) {
removeLayerAt(_local1);
_local1--;
};
}
public function processRenderItem(_arg1:RenderableListItem):void{
if (!forceDepth){
if (!isNaN(_arg1.screenZ)){
this.screenDepth = (this.screenDepth + _arg1.screenZ);
if (_arg1.instance){
this.originDepth = (this.originDepth + _arg1.instance.world.n34);
this.originDepth = (this.originDepth + _arg1.instance.screen.z);
};
this.weight++;
};
};
}
public function removeLayer(_arg1:ViewportLayer):void{
var _local2:int = getChildIndex(_arg1);
if (_local2 > -1){
removeLayerAt(_local2);
} else {
PaperLogger.error("Layer not found for removal.");
};
}
private function linkChild(_arg1:DisplayObject3D, _arg2:ViewportLayer, _arg3:ViewportLayerEvent=null):void{
layers[_arg1] = _arg2;
dispatchEvent(new ViewportLayerEvent(ViewportLayerEvent.CHILD_ADDED, _arg1, _arg2));
}
public function addDisplayObject3D(_arg1:DisplayObject3D, _arg2:Boolean=false):void{
if (!_arg1){
return;
};
displayObjects[_arg1] = _arg1;
dispatchEvent(new ViewportLayerEvent(ViewportLayerEvent.CHILD_ADDED, _arg1, this));
if (_arg2){
_arg1.addChildrenToLayer(_arg1, this);
};
}
public function removeDisplayObject3D(_arg1:DisplayObject3D):void{
displayObjects[_arg1] = null;
dispatchEvent(new ViewportLayerEvent(ViewportLayerEvent.CHILD_REMOVED, _arg1, this));
}
private function unlinkChild(_arg1:DisplayObject3D, _arg2:ViewportLayerEvent=null):void{
layers[_arg1] = null;
dispatchEvent(new ViewportLayerEvent(ViewportLayerEvent.CHILD_REMOVED, _arg1));
}
public function getLayerObjects(_arg1:Array=null):Array{
var _local2:DisplayObject3D;
var _local3:ViewportLayer;
if (!_arg1){
_arg1 = new Array();
};
for each (_local2 in this.displayObjects) {
if (_local2){
_arg1.push(_local2);
};
};
for each (_local3 in childLayers) {
_local3.getLayerObjects(_arg1);
};
return (_arg1);
}
}
}//package org.papervision3d.view.layer
Section 279
//ViewportLayerEvent (org.papervision3d.view.layer.ViewportLayerEvent)
package org.papervision3d.view.layer {
import flash.events.*;
import org.papervision3d.objects.*;
public class ViewportLayerEvent extends Event {
public var layer:ViewportLayer;
public var do3d:DisplayObject3D;
public static const CHILD_REMOVED:String = "childRemoved";
public static const CHILD_ADDED:String = "childAdded";
public function ViewportLayerEvent(_arg1:String, _arg2:DisplayObject3D=null, _arg3:ViewportLayer=null){
super(_arg1, false, false);
this.do3d = _arg2;
this.layer = _arg3;
}
}
}//package org.papervision3d.view.layer
Section 280
//Viewport3D (org.papervision3d.view.Viewport3D)
package org.papervision3d.view {
import flash.events.*;
import flash.display.*;
import flash.geom.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.view.layer.*;
import org.papervision3d.core.render.command.*;
import org.papervision3d.core.culling.*;
import flash.utils.*;
import org.papervision3d.core.log.*;
import org.papervision3d.core.view.*;
import org.papervision3d.core.utils.*;
import org.papervision3d.core.render.*;
public class Viewport3D extends Sprite implements IViewport3D {
public var interactiveSceneManager:InteractiveSceneManager;
public var lastRenderList:Array;
public var cullingRectangle:Rectangle;
protected var _interactive:Boolean;
private var stageScaleModeSet:Boolean;// = false
protected var _autoCulling:Boolean;
protected var _viewportObjectFilter:ViewportObjectFilter;
public var particleCuller:IParticleCuller;
protected var _height:Number;
protected var _width:Number;
public var lineCuller:ILineCuller;
protected var _layerInstances:Dictionary;
protected var _autoScaleToStage:Boolean;
public var triangleCuller:ITriangleCuller;
protected var _lastRenderer:IRenderEngine;
protected var _hWidth:Number;
protected var _containerSprite:ViewportBaseLayer;
protected var _hHeight:Number;
public var sizeRectangle:Rectangle;
protected var renderHitData:RenderHitData;
protected var _autoClipping:Boolean;
public function Viewport3D(_arg1:Number=640, _arg2:Number=480, _arg3:Boolean=false, _arg4:Boolean=false, _arg5:Boolean=true, _arg6:Boolean=true){
init();
this.interactive = _arg4;
this.viewportWidth = _arg1;
this.viewportHeight = _arg2;
this.autoClipping = _arg5;
this.autoCulling = _arg6;
this.autoScaleToStage = _arg3;
this._layerInstances = new Dictionary(true);
}
public function set viewportWidth(_arg1:Number):void{
_width = _arg1;
_hWidth = (_arg1 / 2);
containerSprite.x = _hWidth;
cullingRectangle.x = -(_hWidth);
cullingRectangle.width = _arg1;
sizeRectangle.width = _arg1;
if (_autoClipping){
scrollRect = sizeRectangle;
};
}
public function get autoCulling():Boolean{
return (_autoCulling);
}
protected function onStageResize(_arg1:Event=null):void{
if (_autoScaleToStage){
viewportWidth = stage.stageWidth;
viewportHeight = stage.stageHeight;
};
}
public function set autoCulling(_arg1:Boolean):void{
if (_arg1){
triangleCuller = new RectangleTriangleCuller(cullingRectangle);
particleCuller = new RectangleParticleCuller(cullingRectangle);
lineCuller = new RectangleLineCuller(cullingRectangle);
} else {
if (!_arg1){
triangleCuller = new DefaultTriangleCuller();
particleCuller = new DefaultParticleCuller();
lineCuller = new DefaultLineCuller();
};
};
_autoCulling = _arg1;
}
public function getChildLayer(_arg1:DisplayObject3D, _arg2:Boolean=true, _arg3:Boolean=true):ViewportLayer{
return (containerSprite.getChildLayer(_arg1, _arg2, _arg3));
}
protected function init():void{
this.renderHitData = new RenderHitData();
lastRenderList = new Array();
sizeRectangle = new Rectangle();
cullingRectangle = new Rectangle();
_containerSprite = new ViewportBaseLayer(this);
_containerSprite.doubleClickEnabled = true;
addChild(_containerSprite);
addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
addEventListener(Event.REMOVED_FROM_STAGE, onRemovedFromStage);
}
public function get autoClipping():Boolean{
return (_autoClipping);
}
public function updateAfterRender(_arg1:RenderSessionData):void{
var _local2:ViewportLayer;
if (interactive){
interactiveSceneManager.updateAfterRender();
};
if (_arg1.renderLayers){
for each (_local2 in _arg1.renderLayers) {
_local2.updateInfo();
_local2.sortChildLayers();
_local2.updateAfterRender();
};
} else {
containerSprite.updateInfo();
containerSprite.updateAfterRender();
};
containerSprite.sortChildLayers();
}
protected function onAddedToStage(_arg1:Event):void{
if (_autoScaleToStage){
setStageScaleMode();
};
stage.addEventListener(Event.RESIZE, onStageResize);
onStageResize();
}
public function get containerSprite():ViewportLayer{
return (_containerSprite);
}
public function set autoClipping(_arg1:Boolean):void{
if (_arg1){
scrollRect = sizeRectangle;
} else {
scrollRect = null;
};
_autoClipping = _arg1;
}
protected function setStageScaleMode():void{
if (!stageScaleModeSet){
PaperLogger.info("Viewport autoScaleToStage : Papervision has changed the Stage scale mode.");
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
stageScaleModeSet = true;
};
}
public function accessLayerFor(_arg1:RenderableListItem, _arg2:Boolean=false):ViewportLayer{
var _local3:DisplayObject3D;
if (_arg1.renderableInstance){
_local3 = _arg1.renderableInstance.instance;
_local3 = (_local3.parentContainer) ? _local3.parentContainer : _local3;
if (containerSprite.layers[_local3]){
if (_arg2){
_local3.container = containerSprite.layers[_local3];
};
return (containerSprite.layers[_local3]);
} else {
if (_local3.useOwnContainer){
return (containerSprite.getChildLayer(_local3, true, true));
};
};
};
return (containerSprite);
}
public function get viewportWidth():Number{
return (_width);
}
public function set interactive(_arg1:Boolean):void{
if (_arg1 != _interactive){
if (((_interactive) && (interactiveSceneManager))){
interactiveSceneManager.destroy();
interactiveSceneManager = null;
};
_interactive = _arg1;
if (_arg1){
interactiveSceneManager = new InteractiveSceneManager(this);
};
};
}
public function set viewportObjectFilter(_arg1:ViewportObjectFilter):void{
_viewportObjectFilter = _arg1;
}
public function set autoScaleToStage(_arg1:Boolean):void{
_autoScaleToStage = _arg1;
if (((_arg1) && (!((stage == null))))){
setStageScaleMode();
onStageResize();
};
}
public function set viewportHeight(_arg1:Number):void{
_height = _arg1;
_hHeight = (_arg1 / 2);
containerSprite.y = _hHeight;
cullingRectangle.y = -(_hHeight);
cullingRectangle.height = _arg1;
sizeRectangle.height = _arg1;
if (_autoClipping){
scrollRect = sizeRectangle;
};
}
public function updateBeforeRender(_arg1:RenderSessionData):void{
var _local2:ViewportLayer;
lastRenderList.length = 0;
if (_arg1.renderLayers){
for each (_local2 in _arg1.renderLayers) {
_local2.updateBeforeRender();
};
} else {
_containerSprite.updateBeforeRender();
};
_layerInstances = new Dictionary(true);
}
public function hitTestMouse():RenderHitData{
var _local1:Point = new Point(containerSprite.mouseX, containerSprite.mouseY);
return (hitTestPoint2D(_local1));
}
public function get interactive():Boolean{
return (_interactive);
}
public function get autoScaleToStage():Boolean{
return (_autoScaleToStage);
}
public function hitTestPointObject(_arg1:Point, _arg2:DisplayObject3D):RenderHitData{
var _local3:RenderableListItem;
var _local4:RenderHitData;
var _local5:IRenderListItem;
var _local6:uint;
if (interactive){
_local4 = new RenderHitData();
_local6 = lastRenderList.length;
while ((_local5 = lastRenderList[--_local6])) {
if ((_local5 is RenderableListItem)){
_local3 = (_local5 as RenderableListItem);
if ((_local3.renderableInstance is Triangle3D)){
if (Triangle3D(_local3.renderableInstance).instance != _arg2){
continue;
};
} else {
continue;
};
_local4 = _local3.hitTestPoint2D(_arg1, _local4);
if (_local4.hasHit){
return (_local4);
};
};
};
};
return (new RenderHitData());
}
public function hitTestPoint2D(_arg1:Point):RenderHitData{
var _local2:RenderableListItem;
var _local3:RenderHitData;
var _local4:IRenderListItem;
var _local5:uint;
renderHitData.clear();
if (interactive){
_local3 = renderHitData;
_local5 = lastRenderList.length;
while ((_local4 = lastRenderList[--_local5])) {
if ((_local4 is RenderableListItem)){
_local2 = (_local4 as RenderableListItem);
_local3 = _local2.hitTestPoint2D(_arg1, _local3);
if (_local3.hasHit){
return (_local3);
};
};
};
};
return (renderHitData);
}
protected function onRemovedFromStage(_arg1:Event):void{
stage.removeEventListener(Event.RESIZE, onStageResize);
}
public function get viewportHeight():Number{
return (_height);
}
public function destroy():void{
if (interactiveSceneManager){
interactiveSceneManager.destroy();
interactiveSceneManager = null;
};
lastRenderList = null;
}
public function get viewportObjectFilter():ViewportObjectFilter{
return (_viewportObjectFilter);
}
}
}//package org.papervision3d.view
Section 281
//Papervision3D (org.papervision3d.Papervision3D)
package org.papervision3d {
import org.papervision3d.core.log.*;
public class Papervision3D {
public static var useDEGREES:Boolean = true;
public static var useRIGHTHANDED:Boolean = false;
public static var PAPERLOGGER:PaperLogger = PaperLogger.getInstance();
public static var NAME:String = "Papervision3D";
public static var DATE:String = "December 3rd, 2008";
public static var AUTHOR:String = "(c) 2006-2008 Copyright by Carlos Ulloa | John Grden | Ralph Hauwert | Tim Knip | Andy Zupko";
public static var VERSION:String = "Public Beta 2.0 - Great White";
public static var usePERCENT:Boolean = false;
}
}//package org.papervision3d
Section 282
//FreeKickGame (FreeKickGame)
package {
import flash.events.*;
import flash.display.*;
import com.kerb.utils.*;
import com.kerb.logger.*;
import com.kerb.sokator.freekick.*;
import com.kerb.tracking.*;
public class FreeKickGame extends Sprite {
private const swfBytes:Class;
private var _af:AssetFactory;// = null
public function FreeKickGame(){
swfBytes = FreeKickGame_swfBytes;
super();
addEventListener(Event.ADDED_TO_STAGE, _onAddedToStage);
}
private function _onAddedToStage(_arg1:Event):void{
removeEventListener(Event.ADDED_TO_STAGE, _onAddedToStage);
KerbLog.instance().stage = stage;
KerbLog.instance().level = KerbLogLevel.None;
DoubleQuick.init(root, 36);
DoubleQuick.event(100);
_af = new AssetFactory();
_af.addEventListener(AssetFactory.EVENT_ASSET_FACTORY_READY, _onAssetFactoryReady);
_af.initialize(swfBytes);
}
private function _onAssetFactoryReady(_arg1:Event):void{
addChild(new Main(_af));
}
}
}//package
Section 283
//FreeKickGame_swfBytes (FreeKickGame_swfBytes)
package {
import mx.core.*;
public class FreeKickGame_swfBytes extends ByteArrayAsset {
}
}//package