Section 1
//hBaseEngine (com.hardpcm.core.hBaseEngine)
package com.hardpcm.core {
import flash.display.*;
import flash.events.*;
import org.hardpcm.hardapex.*;
import org.papervision3d.view.*;
import flash.geom.*;
import org.papervision3d.materials.*;
import org.papervision3d.scenes.*;
import flash.utils.*;
import com.hardpcm.utils.*;
import org.papervision3d.core.clipping.*;
import org.papervision3d.cameras.*;
import org.papervision3d.render.*;
public class hBaseEngine extends Sprite {
protected var m_pStage:DisplayObjectContainer;
public var m_pRenderer:BasicRenderEngine;
public var m_nRenderCounter:int;
protected var m_nFrameDurationMS:int;
protected var m_nStartFrameMS:int;
public var m_pScene:Scene3D;
protected var m_pMeshGroups:Array;
protected var m_nLastFrameMS:int;
protected var m_bKeyState:Array;
protected var m_nIdleFrameMS:int;
public var m_pViewport:Viewport3D;
public var m_pCamera:Camera3D;
public var m_pBitmapViewport:BitmapViewport3D;
protected var m_bCleanup:Boolean;
protected var m_nStopFrameMS:int;
public function synchronisePhysic(_arg1:Boolean=false):void{
var _local4:hMeshGroup;
var _local2:int = m_pMeshGroups.length;
var _local3:int;
while (_local3 < _local2) {
_local4 = m_pMeshGroups[_local3];
if (!_local4.bDeleteME){
_local4.synchronisePhysic(_arg1);
} else {
_local3--;
_local2--;
this.removeMeshGroup(_local4);
};
_local3++;
};
}
protected function processFrame():void{
}
public function init(_arg1:DisplayObjectContainer, _arg2:Number=800, _arg3:Number=600, _arg4:Number=0.75):hBaseEngine{
m_pStage = _arg1;
m_pMeshGroups = new Array();
this.m_nStartFrameMS = getTimer();
this.m_nLastFrameMS = this.m_nStartFrameMS;
this.m_nFrameDurationMS = (this.m_nStartFrameMS - this.m_nLastFrameMS);
this.m_nLastFrameMS = this.m_nStartFrameMS;
m_bKeyState = new Array(0x0100);
var _local5:int;
while (_local5 < 0x0100) {
m_bKeyState[_local5] = false;
_local5++;
};
initPapervision(_arg2, _arg3, _arg4);
initPhysic();
init3d();
init2d();
initEvents();
return (this);
}
protected function init2d():void{
}
protected function initPapervision(_arg1:Number, _arg2:Number, _arg3:Number=0.75):void{
m_pViewport = new Viewport3D(_arg1, _arg2);
addChild(m_pViewport);
m_pBitmapViewport = new BitmapViewport3D((m_pViewport.viewportWidth * _arg3), (m_pViewport.viewportHeight * _arg3), false, true);
addChildAt(m_pBitmapViewport, 0);
m_pBitmapViewport._containerBitmap.width = _arg1;
m_pBitmapViewport._containerBitmap.height = _arg2;
m_pRenderer = new BasicRenderEngine();
m_pRenderer.clipping = new FrustumClipping((((FrustumClipping.NEAR + FrustumClipping.LEFT) + FrustumClipping.RIGHT) + FrustumClipping.BOTTOM));
m_pScene = new Scene3D();
m_pCamera = new Camera3D();
m_pCamera.target = null;
m_pCamera.useCulling = true;
m_pCamera.far = 0x2000;
m_pCamera.y = 0x0100;
}
protected function initEvents():void{
m_pStage.addEventListener(Event.ENTER_FRAME, EVENT_onEnterFrame);
m_pStage.addEventListener(KeyboardEvent.KEY_DOWN, EVENT_onKeyDown);
m_pStage.addEventListener(KeyboardEvent.KEY_UP, EVENT_onKeyUp);
}
protected function EVENT_onEnterFrame(_arg1:Event):void{
this.m_nStartFrameMS = getTimer();
this.m_nFrameDurationMS = (this.m_nStartFrameMS - this.m_nLastFrameMS);
this.m_nIdleFrameMS = (this.m_nStartFrameMS - this.m_nStopFrameMS);
this.m_nLastFrameMS = this.m_nStartFrameMS;
processPhysic();
processFrame();
if ((m_nRenderCounter >= 27)){
m_nRenderCounter = (m_nRenderCounter - 27);
if ((this.m_nIdleFrameMS > 10)){
m_pRenderer.renderScene(m_pScene, m_pCamera, m_pBitmapViewport);
};
};
m_nRenderCounter = (m_nRenderCounter + 10);
this.m_nStopFrameMS = getTimer();
}
protected function initPhysic():void{
APEngine.init(0.22);
}
public function removeMeshGroup(_arg1:hMeshGroup):hMeshGroup{
var _local2:int = m_pMeshGroups.indexOf(_arg1);
if (_local2 == -1){
return (_arg1);
};
m_pMeshGroups.splice(_local2, 1);
_arg1.cleanup();
return (_arg1);
}
protected function init3d():void{
}
public function addMeshGroup(_arg1:hMeshGroup):hMeshGroup{
m_pMeshGroups.push(_arg1);
return (_arg1);
}
protected function EVENT_onKeyUp(_arg1:KeyboardEvent):void{
m_bKeyState[_arg1.keyCode] = false;
}
protected function processPhysic():void{
APEngine.step();
synchronisePhysic(false);
}
public function cleanup(){
var _local1:int;
m_pStage.removeEventListener(KeyboardEvent.KEY_DOWN, EVENT_onKeyDown);
m_pStage.removeEventListener(KeyboardEvent.KEY_UP, EVENT_onKeyUp);
m_pStage.removeEventListener(Event.ENTER_FRAME, EVENT_onEnterFrame);
m_pStage = null;
var _local2:int = m_pMeshGroups.length;
_local1 = (_local2 - 1);
while (_local1 >= 0) {
this.removeMeshGroup(m_pMeshGroups[_local1]);
_local1--;
};
APEngine.cleanup();
m_bCleanup = true;
}
protected function EVENT_onKeyDown(_arg1:KeyboardEvent):void{
m_bKeyState[_arg1.keyCode] = true;
}
}
}//package com.hardpcm.core
Section 2
//hMeshGroup (com.hardpcm.core.hMeshGroup)
package com.hardpcm.core {
import flash.display.*;
import flash.events.*;
import org.hardpcm.hardapex.*;
import org.papervision3d.view.*;
import org.papervision3d.objects.*;
import org.papervision3d.materials.utils.*;
import flash.geom.*;
import org.papervision3d.materials.*;
import org.papervision3d.view.layer.*;
import org.papervision3d.scenes.*;
import flash.utils.*;
import com.hardpcm.utils.*;
import org.papervision3d.cameras.*;
import org.papervision3d.render.*;
import org.papervision3d.objects.primitives.*;
public class hMeshGroup implements ICollisionHandler {
public var bDeleteME:Boolean;
protected var m_pScene:Scene3D;
protected var m_pGroupLayer:ViewportLayer;
protected var m_pParticleGroup:Group;
public var bDestroyWhenEmpty:Boolean;
protected var m_pViewport:Viewport3D;
public var nTimeOutMS:Number;
public var m_nLastMS:Number;
protected var m_pParticleMeshes:Array;
public function hMeshGroup(_arg1:Scene3D, _arg2:Viewport3D, _arg3:Boolean=false){
this.bDeleteME = false;
this.bDestroyWhenEmpty = false;
m_nLastMS = getTimer();
this.nTimeOutMS = 0;
m_pScene = _arg1;
m_pViewport = _arg2;
if (m_pViewport != null){
m_pGroupLayer = new ViewportLayer(m_pViewport, null);
m_pViewport.containerSprite.addLayer(m_pGroupLayer);
};
m_pParticleMeshes = new Array();
m_pParticleGroup = new Group(_arg3);
}
public function get particleMeshes():Array{
return (m_pParticleMeshes);
}
public function synchronisePhysic(_arg1:Boolean=false):void{
var _local2:int;
var _local4:Number;
var _local5:hParticleMesh3D;
if (this.nTimeOutMS > 0){
_local4 = getTimer();
this.nTimeOutMS = (this.nTimeOutMS - ((_local4 - m_nLastMS) * 0.001));
m_nLastMS = _local4;
if (this.nTimeOutMS <= 0){
cleanup();
return;
};
};
var _local3:int = m_pParticleMeshes.length;
_local2 = 0;
while (_local2 < _local3) {
_local5 = m_pParticleMeshes[_local2];
if (!_local5.bDeleteME){
_local5.synchronisePhysic(_arg1);
} else {
_local2--;
_local3--;
this.removeParticleMesh(_local5);
};
_local2++;
};
onTick();
}
public function removeCollidable(_arg1:hMeshGroup):hMeshGroup{
this.particleGroup.removeCollidable(_arg1.particleGroup);
return (_arg1);
}
public function get groupLayer():ViewportLayer{
return (m_pGroupLayer);
}
public function addParticleMesh(_arg1:hParticleMesh3D, _arg2:Boolean=false):hParticleMesh3D{
if (_arg1 == null){
return (_arg1);
};
m_pParticleMeshes.push(_arg1);
if (_arg1.displayObject != null){
m_pScene.addChild(_arg1.displayObject);
};
if (m_pGroupLayer != null){
m_pGroupLayer.addDisplayObject3D(_arg1.displayObject, _arg2);
};
m_pParticleGroup.addParticle(_arg1.physicParticle);
_arg1.pParent = this;
_arg1.onAddOnGroup();
return (_arg1);
}
public function get particleGroup():Group{
return (m_pParticleGroup);
}
public function canBlock(_arg1:AbstractParticle, _arg2:AbstractParticle, _arg3:hVector, _arg4:Number):Boolean{
return (_arg1.bCanBlock);
}
public function onTick(){
var _local1:int;
var _local2:int = m_pParticleMeshes.length;
_local1 = 0;
while (_local1 < _local2) {
m_pParticleMeshes[_local1].onTick();
_local1++;
};
}
public function get viewport():Viewport3D{
return (m_pViewport);
}
public function addCollidable(_arg1:hMeshGroup):hMeshGroup{
this.particleGroup.addCollidable(_arg1.particleGroup);
return (_arg1);
}
public function removeFromWorld():hMeshGroup{
APEngine.removeGroup(this.particleGroup);
return (this);
}
public function addToWorld():hMeshGroup{
APEngine.addGroup(this.particleGroup);
return (this);
}
public function removeParticleMesh(_arg1:hParticleMesh3D):hParticleMesh3D{
if (_arg1 == null){
return (_arg1);
};
var _local2:int = m_pParticleMeshes.indexOf(_arg1);
if (_local2 == -1){
return (_arg1);
};
m_pParticleMeshes.splice(_local2, 1);
if (_arg1.displayObject != null){
m_pScene.removeChild(_arg1.displayObject);
};
if (m_pGroupLayer != null){
m_pGroupLayer.removeDisplayObject3D(_arg1.displayObject);
};
m_pParticleGroup.removeParticle(_arg1.physicParticle);
_arg1.pParent = null;
_arg1.onRemoveFromGroup();
if ((((m_pParticleMeshes.length < 1)) && (bDestroyWhenEmpty))){
this.removeFromWorld();
this.bDeleteME = true;
};
return (_arg1);
}
public function cleanup():void{
var _local1:int;
var _local2:int = m_pParticleMeshes.length;
_local1 = (_local2 - 1);
while (_local1 >= 0) {
this.removeParticleMesh(m_pParticleMeshes[_local1]);
_local1--;
};
this.removeFromWorld();
this.bDeleteME = true;
}
}
}//package com.hardpcm.core
Section 3
//hParticleMesh3D (com.hardpcm.core.hParticleMesh3D)
package com.hardpcm.core {
import org.hardpcm.hardapex.*;
import org.papervision3d.objects.*;
import flash.utils.*;
import org.papervision3d.*;
import org.papervision3d.cameras.*;
public class hParticleMesh3D implements ICollisionHandler {
public var pCameraToFollow:Camera3D;
protected var m_pDisplayObject:DisplayObject3D;
public var bDeleteME:Boolean;
protected var m_pPhysicParticle:AbstractParticle;
public var m_nLastMS:Number;
public var nTimeOutMS:Number;
public var pParent:hMeshGroup;
public function hParticleMesh3D(_arg1:DisplayObject3D, _arg2:AbstractParticle){
this.bDeleteME = false;
m_nLastMS = getTimer();
this.nTimeOutMS = 0;
m_pDisplayObject = _arg1;
m_pPhysicParticle = _arg2;
synchronisePhysic(true);
}
final public function set physicParticle(_arg1:AbstractParticle):void{
m_pPhysicParticle = _arg1;
}
public function get displayObject():DisplayObject3D{
return (m_pDisplayObject);
}
public function set displayObject(_arg1:DisplayObject3D):void{
m_pDisplayObject = _arg1;
}
public function onRemoveFromGroup(){
}
final public function synchronisePhysic(_arg1:Boolean=false):void{
var _local2:Number;
if (this.nTimeOutMS > 0){
_local2 = getTimer();
this.nTimeOutMS = (this.nTimeOutMS - ((_local2 - m_nLastMS) * 0.001));
m_nLastMS = _local2;
if (this.nTimeOutMS <= 0){
this.bDeleteME = true;
return;
};
};
if (pCameraToFollow == null){
if (m_pPhysicParticle != null){
if (((!(m_pPhysicParticle.fixed)) || (_arg1))){
if (m_pDisplayObject != null){
if (Papervision3D.useDEGREES){
m_pDisplayObject.localRotationX = m_pPhysicParticle.angleX;
m_pDisplayObject.localRotationY = m_pPhysicParticle.angleY;
m_pDisplayObject.localRotationZ = m_pPhysicParticle.angleZ;
} else {
m_pDisplayObject.localRotationX = m_pPhysicParticle.rotationX;
m_pDisplayObject.localRotationY = m_pPhysicParticle.rotationY;
m_pDisplayObject.localRotationZ = m_pPhysicParticle.rotationZ;
};
m_pDisplayObject.x = m_pPhysicParticle.px;
m_pDisplayObject.y = m_pPhysicParticle.py;
m_pDisplayObject.z = m_pPhysicParticle.pz;
};
};
};
} else {
if (m_pDisplayObject != null){
m_pDisplayObject.x = pCameraToFollow.x;
m_pDisplayObject.y = pCameraToFollow.y;
m_pDisplayObject.z = pCameraToFollow.z;
};
};
}
public function onTick(){
}
public function canBlock(_arg1:AbstractParticle, _arg2:AbstractParticle, _arg3:hVector, _arg4:Number):Boolean{
return (_arg1.bCanBlock);
}
public function onAddOnGroup(){
}
final public function get physicParticle():AbstractParticle{
return (m_pPhysicParticle);
}
}
}//package com.hardpcm.core
Section 4
//hBoxMesh (com.hardpcm.engine.mesh.hBoxMesh)
package com.hardpcm.engine.mesh {
import com.hardpcm.core.*;
import flash.display.*;
import flash.events.*;
import org.hardpcm.hardapex.*;
import org.papervision3d.objects.*;
import org.papervision3d.materials.utils.*;
import flash.geom.*;
import org.papervision3d.materials.*;
import com.hardpcm.utils.*;
import org.papervision3d.cameras.*;
import org.papervision3d.core.material.*;
import org.papervision3d.objects.primitives.*;
public class hBoxMesh extends hParticleMesh3D {
public function hBoxMesh(_arg1:hVector=null, _arg2:hVector=null, _arg3:hVector=null, _arg4:hVector=null, _arg5=null, _arg6:Boolean=true, _arg7:Number=1, _arg8:Number=0.3, _arg9:Number=0){
var _local12:MaterialsList;
var _local13:WireframeMaterial;
if (_arg1 == null){
_arg1 = new hVector(0, 0, 0);
};
if (_arg2 == null){
_arg2 = new hVector(0x0100, 0x0100, 0x0100);
};
if (_arg3 == null){
_arg3 = new hVector(0, 0, 0);
};
if (_arg4 == null){
_arg4 = new hVector(2, 2, 2);
};
if (_arg5 != null){
if ((_arg5 is TriangleMaterial)){
_local12 = new MaterialsList();
_local12.addMaterial(_arg5, "front");
_local12.addMaterial(_arg5, "back");
_local12.addMaterial(_arg5, "left");
_local12.addMaterial(_arg5, "right");
_local12.addMaterial(_arg5, "top");
_local12.addMaterial(_arg5, "bottom");
_arg5 = _local12;
};
};
if (_arg5 == null){
_local13 = new WireframeMaterial(0xA0A000, 1, 2);
_local13.doubleSided = true;
_arg5 = new MaterialsList();
_arg5.addMaterial(_local13, "front");
_arg5.addMaterial(_local13, "back");
_arg5.addMaterial(_local13, "left");
_arg5.addMaterial(_local13, "right");
_arg5.addMaterial(_local13, "top");
_arg5.addMaterial(_local13, "bottom");
};
var _local10:DisplayObject3D = new Cube(_arg5, _arg2.x, _arg2.z, _arg2.y, _arg4.x, _arg4.z, _arg4.y);
var _local11:AbstractParticle = new BoxParticle(_arg1, _arg2.x, _arg2.y, _arg2.z, _arg3.x, _arg3.y, _arg3.z, _arg6, _arg7, _arg8, _arg9);
super(_local10, _local11);
}
}
}//package com.hardpcm.engine.mesh
Section 5
//hConeMesh (com.hardpcm.engine.mesh.hConeMesh)
package com.hardpcm.engine.mesh {
import com.hardpcm.core.*;
import org.hardpcm.hardapex.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.objects.*;
import org.papervision3d.materials.*;
import org.papervision3d.objects.primitives.*;
public class hConeMesh extends hParticleMesh3D {
public function hConeMesh(_arg1:hVector=null, _arg2:hVector=null, _arg3:hVector=null, _arg4:hVector=null, _arg5:MaterialObject3D=null, _arg6:Boolean=true, _arg7:Number=1, _arg8:Number=0.3, _arg9:Number=0){
if (_arg1 == null){
_arg1 = new hVector(0, 0, 0);
};
if (_arg2 == null){
_arg2 = new hVector(0x0100, 0x0100, 0x0100);
};
if (_arg3 == null){
_arg3 = new hVector(0, 0, 0);
};
if (_arg4 == null){
_arg4 = new hVector(8, 6, 6);
};
if (_arg5 == null){
_arg5 = new WireframeMaterial(0xA0A000, 1, 2);
_arg5.doubleSided = true;
};
var _local10:DisplayObject3D = new Cone(_arg5, Math.max((_arg2.x * 0.5), (_arg2.z * 0.5)), _arg2.y, _arg4.x, _arg4.y);
var _local11:AbstractParticle = new CylinderParticle(_arg1, Math.max((_arg2.x * 0.5), (_arg2.z * 0.5)), _arg2.y, _arg3.x, _arg3.y, _arg3.z, _arg6, _arg7, _arg8, _arg9);
super(_local10, _local11);
}
}
}//package com.hardpcm.engine.mesh
Section 6
//htaCompas (com.hardpcm.game.htaCompas)
package com.hardpcm.game {
import flash.display.*;
import org.hardpcm.hardapex.*;
import flash.geom.*;
import flash.text.*;
public class htaCompas extends Sprite {
protected var m_pStageA:DisplayObjectContainer;
protected var m_nHeight:Number;
protected var m_nWidth:Number;
public var m_pCenter:TextField;
protected var m_pBitmapData:BitmapData;
protected var m_pBitmap:Bitmap;
public static var pCompas:htaCompas;
public function init(_arg1:DisplayObjectContainer, _arg2:Number=143, _arg3:Number=14):htaCompas{
htaCompas.pCompas = this;
this.m_pStageA = _arg1;
this.m_nWidth = _arg2;
this.m_nHeight = _arg3;
this.m_pBitmapData = new BitmapData(this.m_nWidth, this.m_nHeight, true, 4278190080);
this.m_pBitmap = new Bitmap(m_pBitmapData);
this.m_pBitmap.x = (-(this.m_nWidth) * 0.5);
this.m_pBitmap.y = (-(this.m_nHeight) * 0.5);
this.addChild(this.m_pBitmap);
var _local4:TextFormat = new TextFormat();
_local4.font = "Arial";
_local4.size = 8;
_local4.bold = true;
_local4.align = TextFormatAlign.CENTER;
this.m_pCenter = new TextField();
this.m_pCenter.defaultTextFormat = _local4;
this.m_pCenter.setTextFormat(_local4);
this.m_pCenter.text = "360";
this.m_pCenter.x = -49;
this.m_pCenter.y = (this.m_nHeight - 16);
this.m_pCenter.width = 100;
this.m_pCenter.textColor = 0xA000;
this.addChild(this.m_pCenter);
return (this);
}
public function renderBar():void{
var _local3:int;
var _local4:int;
var _local5:int;
var _local6:int;
this.m_pBitmapData.fillRect(new Rectangle(0, 0, this.m_nWidth, this.m_nHeight), 0);
if (htaPlayerInfo.vOrientation == null){
htaPlayerInfo.vOrientation = new hVector(0, 0, 1);
};
var _local1:Number = (htaPlayerInfo.vOrientation.getAngleRadianXZ() * 1303.79729380881);
while (_local1 < 0) {
_local1 = (_local1 + 0x2000);
};
var _local2:int = (_local1 + Math.floor((this.m_nWidth * 0.5)));
while (_local2 < 0) {
_local2 = (_local2 + 0x2000);
};
this.m_pCenter.text = Math.floor(((_local1 * 0.0439453125) + 0.5)).toString();
_local3 = 0;
while (_local3 < this.m_nWidth) {
this.m_pBitmapData.setPixel32(_local3, 1, 4278255360);
if ((_local2 % 0x0100) == 0){
_local5 = 1;
while (_local5 < 8) {
this.m_pBitmapData.setPixel32((_local3 - 1), _local5, (4278255360 - (0x1400 * _local5)));
this.m_pBitmapData.setPixel32((_local3 + 0), _local5, (4278255360 - (0x1000 * _local5)));
this.m_pBitmapData.setPixel32((_local3 + 1), _local5, (4278255360 - (0x1400 * _local5)));
_local5++;
};
} else {
if ((_local2 % 16) == 0){
_local5 = 1;
while (_local5 < 6) {
this.m_pBitmapData.setPixel32(_local3, _local5, (4278255360 - (0x1200 * _local5)));
_local5++;
};
};
};
_local3++;
_local2--;
};
}
}
}//package com.hardpcm.game
Section 7
//htaEngine (com.hardpcm.game.htaEngine)
package com.hardpcm.game {
import flash.media.*;
import com.hardpcm.core.*;
import flash.display.*;
import flash.events.*;
import org.hardpcm.hardapex.*;
import flash.geom.*;
import org.papervision3d.materials.*;
import flash.utils.*;
import com.hardpcm.utils.*;
import org.papervision3d.*;
import org.papervision3d.cameras.*;
import com.hardpcm.engine.mesh.*;
import org.papervision3d.objects.primitives.*;
import com.hardpcm.engine.*;
public class htaEngine extends hBaseEngine {
protected var m_pRadarList:Array;
public var pMissileGroup:hMeshGroup;
public var pPlayerGroup:hMeshGroup;
protected var m_pSound_NearShoot:Sound;
protected var m_pFloorGroup:hMeshGroup;
protected var m_pLastShotMS:Number;
protected var m_pSound_FarShoot:Sound;
protected var m_pSound_HitShoot:Sound;
public var pHud:htaHud;
public var pPlayerPM:hParticleMesh3D;
protected var m_pTankGroup:hMeshGroup;
public static var pEngine:htaEngine;
public function playSoundFX(_arg1:int, _arg2:hVector):void{
var _local3:SoundChannel;
var _local4:SoundTransform;
var _local5:Number = _arg2.getSized();
if (_local5 == 0){
_local5 = 0.001;
};
_local5 = Math.max(0, Math.min(1, ((Math.pow(10000, 1.5) - Math.pow(_local5, 1.5)) / Math.pow(10000, 1.5))));
switch (_arg1){
case 1:
_local3 = m_pSound_NearShoot.play(0, 0);
_local4 = _local3.soundTransform;
_local4.volume = _local5;
_local3.soundTransform = _local4;
break;
case 2:
_local3 = m_pSound_FarShoot.play(0, 0);
_local4 = _local3.soundTransform;
_local4.volume = _local5;
_local3.soundTransform = _local4;
break;
case 3:
_local3 = m_pSound_HitShoot.play(0, 0);
_local4 = _local3.soundTransform;
_local4.volume = _local5;
_local3.soundTransform = _local4;
break;
case 4:
_local3 = m_pSound_HitShoot.play(0, 0);
_local4 = _local3.soundTransform;
_local4.volume = _local5;
_local3.soundTransform = _local4;
break;
};
}
override public function init(_arg1:DisplayObjectContainer, _arg2:Number=800, _arg3:Number=600, _arg4:Number=0.9):hBaseEngine{
m_pRadarList = new Array();
htaEngine.pEngine = this;
m_pLastShotMS = getTimer();
htaPlayerInfo.nTimeStart = getTimer();
htaPlayerInfo.nCurrentTime = (getTimer() - htaPlayerInfo.nTimeStart);
htaPlayerInfo.nRemainTime = (htaPlayerInfo.nTotalTime - htaPlayerInfo.nCurrentTime);
m_pSound_NearShoot = new hSound_NearShoot();
m_pSound_FarShoot = new hSound_FarShoot();
m_pSound_HitShoot = new hSound_HitShoot();
return (super.init(_arg1, _arg2, _arg3, _arg4));
}
override protected function init3d():void{
var _local5:hVector;
var _local6:hParticleMesh3D;
var _local7:hParticleMesh3D;
var _local8:hParticleMesh3D;
APEngine.addMasslessForce(new hVector(0, -1.5, 0));
m_pFloorGroup = new hMeshGroup(m_pScene, null);
m_pFloorGroup.addToWorld();
var _local1:hParticleMesh3D = new htaFloor(new hVector(0, 0, 0));
m_pFloorGroup.addParticleMesh(_local1);
var _local2:int;
var _local3:Number = 0;
var _local4:Number = 0;
_local2 = 0;
while (_local2 < 32) {
_local4 = (((2 * Math.PI) / 32) * _local2);
_local3 = ((0x0400 + 0x0200) + (Math.random() * 0x2000));
_local5 = new hVector((_local3 * Math.cos(_local4)), 0, (_local3 * Math.sin(_local4)));
if (Math.random() < 0.5){
_local6 = new htaRock(_local5);
m_pFloorGroup.addParticleMesh(_local6);
} else {
_local7 = new htaTree(_local5);
m_pFloorGroup.addParticleMesh(_local7);
};
_local2++;
};
_local2 = 0;
while (_local2 < 32) {
_local4 = (((2 * Math.PI) / 32) * _local2);
_local3 = ((0x1000 + 0x0200) + (Math.random() * 0x2000));
_local5 = new hVector((_local3 * Math.cos(_local4)), 0, (_local3 * Math.sin(_local4)));
if (Math.random() < 0.5){
_local6 = new htaRock(_local5);
m_pFloorGroup.addParticleMesh(_local6);
} else {
_local7 = new htaTree(_local5);
m_pFloorGroup.addParticleMesh(_local7);
};
_local2++;
};
addMeshGroup(m_pFloorGroup);
pPlayerGroup = new hMeshGroup(m_pScene, null);
pPlayerGroup.addToWorld();
pPlayerPM = new htaPlayer(new hVector(0, 0x0100, 0), null, new hVector(0, 0, 0));
pPlayerGroup.addParticleMesh(pPlayerPM);
addMeshGroup(pPlayerGroup);
m_pTankGroup = new hMeshGroup(m_pScene, null, true);
m_pTankGroup.addToWorld();
_local2 = 0;
while (_local2 < htaPlayerInfo.nRemaining) {
_local4 = (((2 * Math.PI) / htaPlayerInfo.nRemaining) * _local2);
_local3 = ((0x2000 + 0x0200) + (Math.random() * 0x0200));
_local5 = new hVector((_local3 * Math.cos(_local4)), 0x0400, (_local3 * Math.sin(_local4)));
_local8 = new htaTank(_local5, null, new hVector(0, (_local4 - (Math.PI / 2)), 0));
m_pTankGroup.addParticleMesh(_local8);
m_pRadarList.push(new Array(_local8, 0));
_local2++;
};
addMeshGroup(m_pTankGroup);
pMissileGroup = new hMeshGroup(m_pScene, null, true);
pMissileGroup.addToWorld();
addMeshGroup(pMissileGroup);
pPlayerGroup.addCollidable(m_pFloorGroup);
pPlayerGroup.addCollidable(m_pTankGroup);
m_pTankGroup.addCollidable(m_pFloorGroup);
pMissileGroup.addCollidable(pPlayerGroup);
pMissileGroup.addCollidable(m_pTankGroup);
pMissileGroup.addCollidable(m_pFloorGroup);
}
override protected function processFrame():void{
var _local5:hVector;
var _local6:hParticleMesh3D;
var _local7:int;
var _local8:int;
var _local9:Array;
htaPlayerInfo.vLocation = pPlayerPM.physicParticle.curr.getCloned();
htaPlayerInfo.vOrientation = new hVector(0, 0, 1).rotateXZ(pPlayerPM.physicParticle.rotationY);
htaPlayerInfo.nEnergy = htaTank(pPlayerPM).nLife;
htaPlayerInfo.nCurrentTime = (getTimer() - htaPlayerInfo.nTimeStart);
htaPlayerInfo.nRemainTime = (htaPlayerInfo.nTotalTime - htaPlayerInfo.nCurrentTime);
if (Papervision3D.useDEGREES){
m_pCamera.rotationX = -(pPlayerPM.physicParticle.angleX);
m_pCamera.rotationY = -(pPlayerPM.physicParticle.angleY);
m_pCamera.rotationZ = -(pPlayerPM.physicParticle.angleZ);
} else {
m_pCamera.rotationX = -(pPlayerPM.physicParticle.rotationX);
m_pCamera.rotationY = -(pPlayerPM.physicParticle.rotationY);
m_pCamera.rotationZ = -(pPlayerPM.physicParticle.rotationZ);
};
var _local1:Number = pPlayerPM.physicParticle.rotationY;
var _local2:Number = Math.cos(-(_local1));
var _local3:Number = Math.sin(-(_local1));
m_pCamera.x = (pPlayerPM.physicParticle.px + (-256 * _local3));
m_pCamera.y = (pPlayerPM.physicParticle.py + 192);
m_pCamera.z = (pPlayerPM.physicParticle.pz + (-256 * _local2));
super.processFrame();
var _local4:Number = getTimer();
if (((m_bKeyState[32]) && ((m_pLastShotMS < _local4)))){
m_bKeyState[32] = false;
m_pLastShotMS = (_local4 + (2 * 1000));
_local5 = new hVector((pPlayerPM.physicParticle.px + (260 * _local3)), (pPlayerPM.physicParticle.py + 16), (pPlayerPM.physicParticle.pz + (260 * _local2)));
_local6 = new htaMissile(_local5, new hVector(0, 0, 0));
_local6.physicParticle.setRadian(pPlayerPM.physicParticle.rotationX, pPlayerPM.physicParticle.rotationY, pPlayerPM.physicParticle.rotationZ);
_local6.physicParticle.moveForward(0x0200);
pMissileGroup.addParticleMesh(_local6);
htaEngine.pEngine.playSoundFX(1, new hVector(0, 0, 0));
};
if (((m_bKeyState[87]) || (m_bKeyState[38]))){
pPlayerPM.physicParticle.moveForward(0x0100);
};
if (((m_bKeyState[83]) || (m_bKeyState[40]))){
pPlayerPM.physicParticle.moveBackward(0x0100);
};
if (((m_bKeyState[65]) || (m_bKeyState[37]))){
pPlayerPM.physicParticle.relativeRadianY(0.0055);
};
if (((m_bKeyState[68]) || (m_bKeyState[39]))){
pPlayerPM.physicParticle.relativeRadianY(-0.0055);
};
if (pHud != null){
pHud.pRadar.resetMap();
_local8 = m_pRadarList.length;
_local7 = 0;
while (_local7 < _local8) {
_local9 = m_pRadarList[_local7];
if (_local9[0].bDeleteME){
_local9.splice(0, 2);
_local9 = null;
m_pRadarList.splice(_local7, 1);
_local7--;
_local8--;
} else {
pHud.pRadar.addPointToMap(_local9[0].physicParticle.curr, _local9[1]);
};
_local7++;
};
};
}
}
}//package com.hardpcm.game
Section 8
//htaFloor (com.hardpcm.game.htaFloor)
package com.hardpcm.game {
import com.hardpcm.core.*;
import org.hardpcm.hardapex.*;
public class htaFloor extends hParticleMesh3D {
public function htaFloor(_arg1:hVector=null){
if (_arg1 == null){
_arg1 = new hVector(0, 0, 0);
};
var _local2:AbstractParticle = new BoxParticle(_arg1, 1073741824, 8, 1073741824, 0, 0, 0, true, 1, 0.3, 0.5);
super(null, _local2);
physicParticle.nTagID = -1;
physicParticle.mass = 0.1;
}
}
}//package com.hardpcm.game
Section 9
//htaHud (com.hardpcm.game.htaHud)
package com.hardpcm.game {
import flash.display.*;
import flash.events.*;
import flash.geom.*;
import flash.utils.*;
import flash.text.*;
public class htaHud extends Sprite {
protected var m_pStage:DisplayObjectContainer;
protected var m_nTextLastRefresh:uint;
public var pTextField_Best:TextField;
public var pTextField_Remain:TextField;
public var pCompas:htaCompas;
public var pTextField_Cash:TextField;
public var pTextField_Rank:TextField;
public var pTextField_Life:TextField;
protected var m_nTextIndex:uint;
protected var m_nLastRefresh:uint;
public var pTextField_Energy:TextField;
public var pRadar:htaRadar;
public var pTextField_Score:TextField;
public var pTextField_Level:TextField;
public var pTextField_RTime:TextField;
public function htaHud(_arg1:DisplayObjectContainer, _arg2:DisplayObject=null){
m_pStage = _arg1;
this.x = 450;
this.y = 250;
this.cacheAsBitmap = true;
if (_arg2 != null){
_arg2.cacheAsBitmap = true;
_arg2.alpha = 0.8;
addChild(_arg2);
};
var _local3:TextFormat = new TextFormat();
_local3.font = "Arial";
_local3.size = 16;
_local3.bold = true;
_local3.align = TextFormatAlign.LEFT;
pTextField_Life = new TextField();
pTextField_Life.defaultTextFormat = _local3;
pTextField_Life.setTextFormat(_local3);
pTextField_Life.text = "Life: ";
pTextField_Life.x = (-350 - 50);
pTextField_Life.y = -200;
pTextField_Life.width = 250;
pTextField_Life.textColor = 0xA000;
addChild(pTextField_Life);
pTextField_Cash = new TextField();
pTextField_Cash.defaultTextFormat = _local3;
pTextField_Cash.setTextFormat(_local3);
pTextField_Cash.text = "Cash: ";
pTextField_Cash.x = (-350 - 50);
pTextField_Cash.y = (-200 - 25);
pTextField_Cash.width = 250;
pTextField_Cash.textColor = 0xA000;
addChild(pTextField_Cash);
pTextField_Level = new TextField();
pTextField_Level.defaultTextFormat = _local3;
pTextField_Level.setTextFormat(_local3);
pTextField_Level.text = "Level: ";
pTextField_Level.x = (-350 - 50);
pTextField_Level.y = ((-200 - 25) - 25);
pTextField_Level.width = 250;
pTextField_Level.textColor = 0xA000;
addChild(pTextField_Level);
pTextField_Score = new TextField();
pTextField_Score.defaultTextFormat = _local3;
pTextField_Score.setTextFormat(_local3);
pTextField_Score.text = "Score: ";
pTextField_Score.x = (-350 + 75);
pTextField_Score.y = -200;
pTextField_Score.width = 250;
pTextField_Score.textColor = 0xA000;
addChild(pTextField_Score);
pTextField_Energy = new TextField();
pTextField_Energy.defaultTextFormat = _local3;
pTextField_Energy.setTextFormat(_local3);
pTextField_Energy.text = "Collected: ";
pTextField_Energy.x = (-350 - 75);
pTextField_Energy.y = (250 - 25);
pTextField_Energy.width = 250;
pTextField_Energy.textColor = 0xA0A000;
addChild(pTextField_Energy);
pTextField_Remain = new TextField();
pTextField_Remain.defaultTextFormat = _local3;
pTextField_Remain.setTextFormat(_local3);
pTextField_Remain.text = "Remaining: ";
pTextField_Remain.x = ((350 - 75) - 150);
pTextField_Remain.y = (250 - 25);
pTextField_Remain.width = 250;
pTextField_Remain.textColor = 0xA0A000;
addChild(pTextField_Remain);
pTextField_Rank = new TextField();
pTextField_Rank.defaultTextFormat = _local3;
pTextField_Rank.setTextFormat(_local3);
pTextField_Rank.text = "Rank: ";
pTextField_Rank.x = (-350 + 75);
pTextField_Rank.y = (-200 - 25);
pTextField_Rank.width = 250;
pTextField_Rank.textColor = 0xA000;
addChild(pTextField_Rank);
pTextField_RTime = new TextField();
pTextField_RTime.defaultTextFormat = _local3;
pTextField_RTime.setTextFormat(_local3);
pTextField_RTime.text = "Remian Time: ";
pTextField_RTime.x = ((-350 + 75) + 200);
pTextField_RTime.y = (-200 - 25);
pTextField_RTime.width = 250;
pTextField_RTime.textColor = 0xA000;
addChild(pTextField_RTime);
pTextField_Best = new TextField();
pTextField_Best.defaultTextFormat = _local3;
pTextField_Best.setTextFormat(_local3);
pTextField_Best.text = "Best: ";
pTextField_Best.x = (-350 + 75);
pTextField_Best.y = ((-200 - 25) - 25);
pTextField_Best.width = 580;
pTextField_Best.textColor = 0xA000;
addChild(pTextField_Best);
this.pRadar = new htaRadar().init(m_pStage, 128, 64);
this.pRadar.x = 120;
this.pRadar.y = 170;
this.addChild(this.pRadar);
this.pCompas = new htaCompas().init(m_pStage, 150, 14);
this.pCompas.alpha = 1;
this.pCompas.x = -100;
this.pCompas.y = -170;
this.addChild(this.pCompas);
addEventListener(Event.ENTER_FRAME, run);
}
private function run(_arg1:Event):void{
if (m_nLastRefresh > getTimer()){
return;
};
m_nLastRefresh = (83 + getTimer());
this.pCompas.renderBar();
this.pRadar.resetMap();
pTextField_Life.text = ("Lives: " + htaPlayerInfo.nTry.toString(10));
pTextField_Score.text = ("Score: " + htaPlayerInfo.nScore.toString(10));
pTextField_Level.text = ("Level: " + htaPlayerInfo.nLevel.toString(10));
pTextField_Cash.text = ("Cash: " + htaPlayerInfo.nCash.toString(10));
pTextField_Energy.text = ("Energy: " + htaPlayerInfo.nEnergy.toString());
pTextField_Remain.text = ("Remaining: " + htaPlayerInfo.nRemaining.toString());
pTextField_Rank.text = ("World Rank: " + htaPlayerInfo.nWorldRank.toString(10));
pTextField_RTime.text = ("Time: " + MyFormatNumber((htaPlayerInfo.nRemainTime * 0.001), 3));
htaWebSync.doShow();
if (htaWebSync.sShowBest != null){
pTextField_Best.text = ("World Best: " + htaWebSync.sShowBest);
} else {
pTextField_Best.text = "World Best: yourself";
};
htaWebSync.doSync();
}
private function MyFormatNumber(_arg1:Number, _arg2):String{
if (_arg2 <= 0){
return (Math.round(_arg1).toString(10));
};
var _local3:* = Math.pow(10, _arg2);
var _local4:* = String((Math.round((_arg1 * _local3)) / _local3));
if (_local4.indexOf(".") == -1){
_local4 = (_local4 + ".0");
};
var _local5:* = _local4.split(".");
var _local6:* = (_arg2 - _local5[1].length);
var _local7:* = 1;
while (_local7 <= _local6) {
_local4 = (_local4 + "0");
_local7++;
};
return (_local4);
}
}
}//package com.hardpcm.game
Section 10
//htaLevel_N1 (com.hardpcm.game.htaLevel_N1)
package com.hardpcm.game {
public class htaLevel_N1 extends htaEngine {
}
}//package com.hardpcm.game
Section 11
//htaLevel_N2 (com.hardpcm.game.htaLevel_N2)
package com.hardpcm.game {
public class htaLevel_N2 extends htaEngine {
}
}//package com.hardpcm.game
Section 12
//htaLevel_N3 (com.hardpcm.game.htaLevel_N3)
package com.hardpcm.game {
public class htaLevel_N3 extends htaEngine {
}
}//package com.hardpcm.game
Section 13
//htaLevel_N4 (com.hardpcm.game.htaLevel_N4)
package com.hardpcm.game {
public class htaLevel_N4 extends htaEngine {
}
}//package com.hardpcm.game
Section 14
//htaMissile (com.hardpcm.game.htaMissile)
package com.hardpcm.game {
import org.hardpcm.hardapex.*;
import org.papervision3d.materials.*;
import com.hardpcm.engine.mesh.*;
public class htaMissile extends hBoxMesh {
public function htaMissile(_arg1:hVector=null, _arg2:hVector=null){
var _local3:WireframeMaterial = new WireframeMaterial(16719904, 1, 2);
_local3.doubleSided = false;
super(_arg1, new hVector(32, 32, 32), new hVector(0, 0, 0), new hVector(1, 1, 1), _local3, false, 1, 0, 0);
physicParticle.nTagID = 3;
physicParticle.multisample = 1;
physicParticle.bIgnoreGlobalForce = true;
physicParticle.nTerminalVelocity = 64;
this.nTimeOutMS = 8;
}
override public function canBlock(_arg1:AbstractParticle, _arg2:AbstractParticle, _arg3:hVector, _arg4:Number):Boolean{
bDeleteME = true;
htaEngine.pEngine.playSoundFX(3, physicParticle.curr.getVectorSub(htaEngine.pEngine.pPlayerPM.physicParticle.curr));
return (_arg1.bCanBlock);
}
override public function onAddOnGroup(){
physicParticle.parentCollection = null;
physicParticle.collisionHandler = this;
}
}
}//package com.hardpcm.game
Section 15
//htaNameList (com.hardpcm.game.htaNameList)
package com.hardpcm.game {
import com.hardpcm.utils.*;
public class htaNameList extends hRandomStringArray {
override public function BuildList(){
P("Glint");
P("Armadillo");
P("SpaceBoy");
P("Neo");
P("Phoenix");
P("Andree");
P("Latina");
P("Bugs Bunny");
P("Mr_Winky");
P("Shaggy");
P("Asteroid");
P("VaNiLlA");
P("Xzibit");
P("Silverwing");
P("FireBall");
P("Dree");
P("Florrie");
P("Franny");
P("Gracie");
P("Kenny");
P("Kate");
P("Sam");
P("Jules");
P("Green Elf");
P("Tomma");
P("Andree");
P("Andy");
P("Wako");
P("John");
P("The Teletobies");
P("BooGY");
P("HotShot");
P("Billy Joe");
P("Kenny");
P("Jack Tequila");
P("OmerIsThebest!!!");
P("Speedster");
P("chorizo");
P("Blood God");
P("Steve");
P("Bob");
P("Jack");
P("Elvis");
P("Woopus");
P("The Worm");
P("Mario");
P("Luigi");
P("Master Chief");
P("Benny");
P("Bambi");
P("Indestructible");
P("Butch");
P("Brad");
P("Buzz");
P("Cardinal Fire");
P("Diamond Jim");
P("Dizzy");
P("Dixie");
P("Dusty");
P("WTF");
P("The Genius");
P("Holy Joe");
P("Sulk");
P("The Jackal");
P("Jasper");
P("Junior");
P("Kingfish");
P("The Monster");
P("Nick");
P("Nick");
P("Ned");
P("Kenny");
P("Narkozy");
P("Peanut");
P("Marine");
P("Hamster");
P("Stan");
P("Omer");
P("Lisa");
P("The Pokemon");
P("Pinky");
P("Spider");
P("Redeemer");
P("Hammer");
P("The Saint");
P("Spike");
P("Stonewall");
P("Fireball");
P("Wario");
P("Tiger");
P("Weegee");
P("Alien");
P("Ghost");
}
}
}//package com.hardpcm.game
Section 16
//htaPlayer (com.hardpcm.game.htaPlayer)
package com.hardpcm.game {
import org.hardpcm.hardapex.*;
public class htaPlayer extends htaTank {
public function htaPlayer(_arg1:hVector=null, _arg2:hVector=null, _arg3:hVector=null){
super(_arg1, _arg2, _arg3);
physicParticle.nTagID = 5;
this.nLife = 500;
physicParticle.nTerminalVelocity = 20;
}
}
}//package com.hardpcm.game
Section 17
//htaPlayerInfo (com.hardpcm.game.htaPlayerInfo)
package com.hardpcm.game {
import com.hardpcm.core.*;
import flash.display.*;
import org.hardpcm.hardapex.*;
public class htaPlayerInfo {
public static const STATE__GAME_OVER:int = 3;
public static const STATE__DEAD_LEVEL:int = 1;
public static const STATE__PLAY_LEVEL:int = 0;
public static const STATE__END_LEVEL:int = 2;
public static var bDisableSound:Boolean = false;
public static var nWorldRank:int;
public static var nCurrentTime:Number;
public static var nEnergy:int = 100;
public static var sName:String = "Elvis";
public static var nWorldRank_ME:Array;
public static var nRemaining:int = 4;
public static var nLevel:int = 0;
public static var nCash:int = 0;
public static var nState:int = 0;
public static var nScore:int = 0;
public static var nTimeStart:Number;
public static var vLocation:hVector;
public static var nWorldRank_A:Array;
public static var nWorldRank_B:Array;
public static var nWorldRank_E:Array;
public static var nWorldRank_C:Array;
public static var nWorldRank_D:Array;
public static var nTotalTime:Number;
public static var sVersion:String = "";
public static var nRemainTime:Number;
public static var nTry:int = 3;
public static var vOrientation:hVector;
public static function GoNextLevel():Boolean{
htaPlayerInfo.nLevel++;
if (htaPlayerInfo.nLevel >= 5){
htaPlayerInfo.nScore = (htaPlayerInfo.nScore + (2000 + (htaPlayerInfo.nLevel * 100)));
return (true);
};
return (false);
}
public static function GenerateLevel(_arg1:DisplayObjectContainer, _arg2:int=700, _arg3:int=500):hBaseEngine{
if (htaPlayerInfo.nLevel == 1){
htaPlayerInfo.nEnergy = 500;
htaPlayerInfo.nRemaining = 4;
htaPlayerInfo.nTotalTime = ((15 * 60) * 1000);
htaPlayerInfo.nRemainTime = htaPlayerInfo.nTotalTime;
return (new htaLevel_N1().init(_arg1, _arg2, _arg3));
};
if (htaPlayerInfo.nLevel == 2){
htaPlayerInfo.nEnergy = 500;
htaPlayerInfo.nRemaining = 6;
htaPlayerInfo.nTotalTime = ((20 * 60) * 1000);
htaPlayerInfo.nRemainTime = htaPlayerInfo.nTotalTime;
return (new htaLevel_N2().init(_arg1, _arg2, _arg3));
};
if (htaPlayerInfo.nLevel == 3){
htaPlayerInfo.nEnergy = 500;
htaPlayerInfo.nRemaining = 8;
htaPlayerInfo.nTotalTime = ((20 * 60) * 1000);
htaPlayerInfo.nRemainTime = htaPlayerInfo.nTotalTime;
return (new htaLevel_N3().init(_arg1, _arg2, _arg3));
};
if (htaPlayerInfo.nLevel == 4){
htaPlayerInfo.nEnergy = 500;
htaPlayerInfo.nRemaining = 14;
htaPlayerInfo.nTotalTime = ((20 * 60) * 1000);
htaPlayerInfo.nRemainTime = htaPlayerInfo.nTotalTime;
return (new htaLevel_N4().init(_arg1, _arg2, _arg3));
};
return (null);
}
public static function CanContinue():Boolean{
if (htaPlayerInfo.nRemainTime <= 0){
htaPlayerInfo.nRemainTime = 0;
htaPlayerInfo.nState = STATE__DEAD_LEVEL;
};
return ((((htaPlayerInfo.nState == htaPlayerInfo.STATE__PLAY_LEVEL)) && ((htaPlayerInfo.nTry > 0))));
}
public static function InitialiseLevel(){
htaPlayerInfo.nState = htaPlayerInfo.STATE__PLAY_LEVEL;
htaPlayerInfo.vLocation = new hVector(0, 0, 0);
htaPlayerInfo.vOrientation = new hVector(0, 0, 1);
htaPlayerInfo.nCash = 0;
htaPlayerInfo.nEnergy = 1000;
htaPlayerInfo.nRemaining = 1;
htaPlayerInfo.nTry = 3;
htaPlayerInfo.nScore = 0;
htaPlayerInfo.nLevel = 1;
htaPlayerInfo.nWorldRank = 1000000;
}
}
}//package com.hardpcm.game
Section 18
//htaRadar (com.hardpcm.game.htaRadar)
package com.hardpcm.game {
import com.hardpcm.core.*;
import flash.display.*;
import flash.events.*;
import org.hardpcm.hardapex.*;
import flash.geom.*;
import com.hardpcm.utils.*;
public class htaRadar extends Sprite {
public var nRadius:Number;
protected var m_pStageA:DisplayObjectContainer;
protected var m_nHeight:Number;
protected var m_nWidth:Number;
protected var m_pBitmap:Bitmap;
protected var m_pBitmapData:BitmapData;
public static var pRadar:htaRadar;
public function resetPoint():void{
this.m_pBitmapData.fillRect(new Rectangle(0, 0, (this.m_nWidth * 2), (this.m_nHeight * 2)), 0);
this.renderPoint(new hVector(this.m_nWidth, this.m_nHeight), 1);
}
public function renderPoint(_arg1:hVector, _arg2:int):void{
if (_arg2 == 0){
this.m_pBitmapData.setPixel32((_arg1.x - 1), (_arg1.y + 0), 4288675840);
this.m_pBitmapData.setPixel32((_arg1.x - 1), (_arg1.y + 1), 4280287232);
this.m_pBitmapData.setPixel32((_arg1.x + 0), (_arg1.y - 1), 4288675840);
this.m_pBitmapData.setPixel32((_arg1.x + 0), (_arg1.y + 0), 4294901760);
this.m_pBitmapData.setPixel32((_arg1.x + 0), (_arg1.y + 1), 4288675840);
this.m_pBitmapData.setPixel32((_arg1.x + 1), (_arg1.y + 0), 4288675840);
this.m_pBitmapData.setPixel32((_arg1.x + 1), (_arg1.y + 1), 4280287232);
} else {
if (_arg2 == 1){
this.m_pBitmapData.setPixel32((_arg1.x - 1), (_arg1.y + 0), 4278231040);
this.m_pBitmapData.setPixel32((_arg1.x - 1), (_arg1.y + 1), 4278198272);
this.m_pBitmapData.setPixel32((_arg1.x + 0), (_arg1.y - 1), 4278231040);
this.m_pBitmapData.setPixel32((_arg1.x + 0), (_arg1.y + 0), 4278255360);
this.m_pBitmapData.setPixel32((_arg1.x + 0), (_arg1.y + 1), 4278231040);
this.m_pBitmapData.setPixel32((_arg1.x + 1), (_arg1.y + 0), 4278231040);
this.m_pBitmapData.setPixel32((_arg1.x + 1), (_arg1.y + 1), 4278198272);
} else {
if (_arg2 == 2){
this.m_pBitmapData.setPixel32((_arg1.x - 1), (_arg1.y + 0), 4278190240);
this.m_pBitmapData.setPixel32((_arg1.x - 1), (_arg1.y + 1), 4278190112);
this.m_pBitmapData.setPixel32((_arg1.x + 0), (_arg1.y - 1), 4278190240);
this.m_pBitmapData.setPixel32((_arg1.x + 0), (_arg1.y + 0), 4278190335);
this.m_pBitmapData.setPixel32((_arg1.x + 0), (_arg1.y + 1), 4278190240);
this.m_pBitmapData.setPixel32((_arg1.x + 1), (_arg1.y + 0), 4278190240);
this.m_pBitmapData.setPixel32((_arg1.x + 1), (_arg1.y + 1), 4278190112);
} else {
if (_arg2 == 3){
this.m_pBitmapData.setPixel32((_arg1.x - 1), (_arg1.y + 0), 4288716800);
this.m_pBitmapData.setPixel32((_arg1.x - 1), (_arg1.y + 1), 4280295424);
this.m_pBitmapData.setPixel32((_arg1.x + 0), (_arg1.y - 1), 4288716800);
this.m_pBitmapData.setPixel32((_arg1.x + 0), (_arg1.y + 0), 4294967040);
this.m_pBitmapData.setPixel32((_arg1.x + 0), (_arg1.y + 1), 4288716800);
this.m_pBitmapData.setPixel32((_arg1.x + 1), (_arg1.y + 0), 4288716800);
this.m_pBitmapData.setPixel32((_arg1.x + 1), (_arg1.y + 1), 4280295424);
} else {
this.m_pBitmapData.setPixel32((_arg1.x - 1), (_arg1.y + 0), 4288675840);
this.m_pBitmapData.setPixel32((_arg1.x - 1), (_arg1.y + 1), 4280287232);
this.m_pBitmapData.setPixel32((_arg1.x + 0), (_arg1.y - 1), 4288675840);
this.m_pBitmapData.setPixel32((_arg1.x + 0), (_arg1.y + 0), 4294901760);
this.m_pBitmapData.setPixel32((_arg1.x + 0), (_arg1.y + 1), 4288675840);
this.m_pBitmapData.setPixel32((_arg1.x + 1), (_arg1.y + 0), 4288675840);
this.m_pBitmapData.setPixel32((_arg1.x + 1), (_arg1.y + 1), 4280287232);
};
};
};
};
}
public function addParticleListToMap(_arg1:Array):void{
var _local2:int;
var _local4:Array;
if (_arg1 == null){
return;
};
var _local3:int = _arg1.length;
_local2 = 0;
while (_local2 < _local3) {
_local4 = _arg1[_local2];
if (_local4 == null){
} else {
if (_local4.bDeleteME){
} else {
if (_local4[0].physicParticle != null){
this.addPointToMap(_local4[0].physicParticle.curr, _local4[1]);
};
};
};
_local2++;
};
}
public function init(_arg1:DisplayObjectContainer, _arg2:Number=200, _arg3:Number=100):htaRadar{
htaRadar.pRadar = this;
this.m_pStageA = _arg1;
this.m_nWidth = (_arg2 * 0.5);
this.m_nHeight = (_arg3 * 0.5);
this.nRadius = 0x8000;
this.m_pBitmapData = new BitmapData((this.m_nWidth * 2), (this.m_nHeight * 2), true, 4278190080);
this.m_pBitmap = new Bitmap(m_pBitmapData);
this.m_pBitmap.x = -(this.m_nWidth);
this.m_pBitmap.y = -(this.m_nHeight);
this.addChild(this.m_pBitmap);
return (this);
}
public function addPointToMap(_arg1:hVector, _arg2:int):void{
var _local6:hVector;
if (htaPlayerInfo.vLocation == null){
return;
};
if (htaPlayerInfo.vOrientation == null){
return;
};
var _local3:Number = (this.nRadius * this.nRadius);
var _local4:hVector = _arg1.getVectorSub(htaPlayerInfo.vLocation).maskScale(1, 0, 1);
var _local5:Number = _local4.getSquareSized();
if (_local5 > _local3){
return;
};
_local5 = Math.sqrt(_local5);
_local6 = new hVector(htaPlayerInfo.vOrientation.x, htaPlayerInfo.vOrientation.z);
_local4.y = _local4.z;
_local4.z = 0;
var _local7:Number = (_local6.getRelativeAngleRadianXY(_local4) + 1.5707963267949);
var _local8:Number = (_local5 / nRadius);
var _local9:hVector = new hVector((((_local8 * this.m_nWidth) * Math.cos(_local7)) + this.m_nWidth), (-(((_local8 * this.m_nHeight) * Math.sin(_local7))) + this.m_nHeight));
this.renderPoint(_local9, _arg2);
}
public function resetMap():void{
resetPoint();
}
public function addVectorListToMap(_arg1:Array):void{
var _local2:int;
var _local4:Array;
if (_arg1 == null){
return;
};
var _local3:int = _arg1.length;
_local2 = 0;
while (_local2 < _local3) {
_local4 = _arg1[_local2];
if (_local4 == null){
} else {
this.addPointToMap(_local4[0], _local4[1]);
};
_local2++;
};
}
}
}//package com.hardpcm.game
Section 19
//htaRock (com.hardpcm.game.htaRock)
package com.hardpcm.game {
import org.hardpcm.hardapex.*;
import org.papervision3d.materials.*;
import com.hardpcm.engine.mesh.*;
public class htaRock extends hConeMesh {
public function htaRock(_arg1:hVector=null, _arg2:hVector=null){
if (_arg2 == null){
_arg2 = new hVector((0x0400 + (Math.random() * 0x0100)), (0x0200 + (Math.random() * 0x0100)), 0);
_arg2.z = _arg2.x;
_arg1 = _arg1.getCloned();
_arg1.y = (_arg1.y + (_arg2.y * 0.5));
};
var _local3:WireframeMaterial = new WireframeMaterial(0xA000, 1, 2);
_local3.doubleSided = false;
super(_arg1, _arg2, null, new hVector(6, 2, 2), _local3, true, 1, 0.1, 0.5);
physicParticle.nTagID = -1;
physicParticle.mass = 1000000;
}
}
}//package com.hardpcm.game
Section 20
//htaTank (com.hardpcm.game.htaTank)
package com.hardpcm.game {
import com.hardpcm.core.*;
import org.hardpcm.hardapex.*;
import org.papervision3d.objects.*;
import org.papervision3d.materials.utils.*;
import org.papervision3d.materials.*;
import flash.utils.*;
import org.papervision3d.objects.primitives.*;
public class htaTank extends hParticleMesh3D {
protected var m_nNextMoveMS:int;
public var nLife:Number;
protected var m_nNextShootMS:int;
protected var m_nNextTouchMS:int;
public function htaTank(_arg1:hVector=null, _arg2:hVector=null, _arg3:hVector=null){
var _local11:DisplayObject3D;
if (_arg1 == null){
_arg1 = new hVector(0, 0, 0);
};
if (_arg2 == null){
_arg2 = new hVector(1, 1, 1);
};
if (_arg3 == null){
_arg3 = new hVector(0, 0, 0);
};
var _local4:WireframeMaterial = new WireframeMaterial(0xFF00, 1, 2);
_local4.doubleSided = false;
var _local5:MaterialsList = new MaterialsList();
_local5.addMaterial(_local4, "front");
_local5.addMaterial(_local4, "back");
_local5.addMaterial(_local4, "left");
_local5.addMaterial(_local4, "right");
_local5.addMaterial(_local4, "top");
_local5.addMaterial(_local4, "bottom");
var _local6:DisplayObject3D = new DisplayObject3D();
var _local7:DisplayObject3D = new Cube(_local5, (64 * _arg2.x), (0x0100 * _arg2.z), (32 * _arg2.y), 1, 1, 1);
_local7.x = (-112 * _arg2.x);
_local7.y = (-64 * _arg2.y);
_local7.z = 0;
_local6.addChild(_local7);
var _local8:DisplayObject3D = new Cube(_local5, (64 * _arg2.x), (0x0100 * _arg2.z), (32 * _arg2.y), 1, 1, 1);
_local8.x = (112 * _arg2.x);
_local8.y = (-64 * _arg2.y);
_local8.z = 0;
_local6.addChild(_local8);
var _local9:DisplayObject3D = new Cube(_local5, (224 * _arg2.x), (192 * _arg2.z), (64 * _arg2.y), 1, 1, 1);
_local9.x = 0;
_local9.y = (-32 * _arg2.y);
_local9.z = (-32 * _arg2.z);
_local6.addChild(_local9);
var _local10:DisplayObject3D = new Cube(_local5, (112 * _arg2.x), (128 * _arg2.z), (64 * _arg2.y), 1, 1, 1);
_local10.x = 0;
_local10.y = (32 * _arg2.y);
_local10.z = (-32 * _arg2.z);
_local6.addChild(_local10);
_local11 = new Cube(_local5, (32 * _arg2.x), (0x0100 * _arg2.z), (32 * _arg2.y), 1, 1, 1);
_local11.x = 0;
_local11.y = (64 * _arg2.y);
_local11.z = (64 * _arg2.z);
_local6.addChild(_local11);
var _local12:AbstractParticle = new CylinderParticle(_arg1, 220, 192, _arg3.x, _arg3.y, _arg3.z, false, 1, 0.3, 0);
super(_local6, _local12);
physicParticle.nTagID = 2;
physicParticle.nTerminalVelocity = 16;
this.nLife = 100;
this.m_nNextTouchMS = 0;
}
override public function canBlock(_arg1:AbstractParticle, _arg2:AbstractParticle, _arg3:hVector, _arg4:Number):Boolean{
if (_arg2.nTagID == 3){
if (this.m_nNextTouchMS <= getTimer()){
this.m_nNextTouchMS = (getTimer() + 50);
if (getQualifiedClassName(this) == "com.hardpcm.game::htaTank"){
this.nLife = (this.nLife - 50);
htaPlayerInfo.nScore = (htaPlayerInfo.nScore + 50);
} else {
this.nLife = (this.nLife - 25);
};
if (this.nLife <= 0){
if (getQualifiedClassName(this) == "com.hardpcm.game::htaTank"){
this.bDeleteME = true;
htaPlayerInfo.nRemaining--;
if (htaPlayerInfo.nRemaining < 1){
htaPlayerInfo.nState = htaPlayerInfo.STATE__END_LEVEL;
};
} else {
htaPlayerInfo.nState = htaPlayerInfo.STATE__DEAD_LEVEL;
};
};
};
};
return (_arg1.bCanBlock);
}
override public function onTick(){
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:hVector;
var _local16:hParticleMesh3D;
if (getQualifiedClassName(this) != "com.hardpcm.game::htaTank"){
return;
};
if (this.m_nNextMoveMS > getTimer()){
return;
};
m_nNextMoveMS = (getTimer() + (1000 / 16));
var _local1:Number = (Math.PI * 2);
var _local2:htaEngine = htaEngine.pEngine;
if (_local2 == null){
return;
};
var _local3:hParticleMesh3D = _local2.pPlayerPM;
if (_local3 == null){
return;
};
var _local4:hVector = _local3.physicParticle.curr.getVectorSub(this.physicParticle.curr);
var _local5:Number = _local4.getSized();
var _local6:Number = physicParticle.rotationY;
while (_local6 < 0) {
_local6 = (_local6 + _local1);
};
while (_local6 > _local1) {
_local6 = (_local6 - _local1);
};
var _local7:Number = (_local4.getAngleRadianXZ() - 1.5707963267949);
while (_local7 < 0) {
_local7 = (_local7 + _local1);
};
while (_local7 > _local1) {
_local7 = (_local7 - _local1);
};
var _local8:Number = Math.min(Math.abs((_local7 - _local6)), Math.abs((_local6 - _local7)));
var _local9:Number = _local6;
var _local10:Number = _local7;
var _local11:Number = 0;
if (_local10 >= Math.PI){
if ((((_local9 >= (_local10 - Math.PI))) && ((_local9 <= _local10)))){
_local11 = 1;
} else {
_local11 = -1;
};
} else {
if ((((_local9 >= _local10)) && ((_local9 <= (_local10 + Math.PI))))){
_local11 = -1;
} else {
_local11 = 1;
};
};
if ((((_local8 < (Math.PI / 3))) && ((_local5 < 0x2000)))){
if (this.m_nNextShootMS < getTimer()){
m_nNextShootMS = (getTimer() + (4 * 1000));
_local12 = physicParticle.rotationY;
_local13 = Math.cos(-(_local12));
_local14 = Math.sin(-(_local12));
_local15 = new hVector((physicParticle.px + (260 * _local14)), (physicParticle.py + 32), (physicParticle.pz + (260 * _local13)));
_local16 = new htaMissile(_local15, new hVector(0, 0, 0));
_local16.physicParticle.setRadian(physicParticle.rotationX, physicParticle.rotationY, physicParticle.rotationZ);
_local16.physicParticle.moveForward(386);
_local2.pMissileGroup.addParticleMesh(_local16);
htaEngine.pEngine.playSoundFX(2, physicParticle.curr.getVectorSub(htaEngine.pEngine.pPlayerPM.physicParticle.curr));
};
};
physicParticle.relativeRadianY(((_local11 * 0.155) / 16));
if ((((_local8 < (Math.PI / 8))) && ((_local5 < 0x1000)))){
physicParticle.moveForward((8 / 16));
};
if (physicParticle.py > 0x0200){
physicParticle.moveForward((16 / 16));
};
}
override public function onAddOnGroup(){
physicParticle.parentCollection = null;
physicParticle.collisionHandler = this;
}
}
}//package com.hardpcm.game
Section 21
//htaTree (com.hardpcm.game.htaTree)
package com.hardpcm.game {
import org.hardpcm.hardapex.*;
import org.papervision3d.materials.*;
import com.hardpcm.engine.mesh.*;
public class htaTree extends hConeMesh {
public function htaTree(_arg1:hVector=null, _arg2:hVector=null){
if (_arg2 == null){
_arg2 = new hVector((0x0400 + (Math.random() * 0x0100)), (0x0800 + (Math.random() * 0x0100)), 0);
_arg2.z = _arg2.x;
_arg1 = _arg1.getCloned();
_arg1.y = (_arg1.y + (_arg2.y * 0.5));
};
var _local3:WireframeMaterial = new WireframeMaterial(0xA000, 1, 2);
_local3.doubleSided = false;
super(_arg1, _arg2, null, new hVector(6, 2, 2), _local3, true, 1, 0.1, 0.5);
physicParticle.nTagID = -1;
physicParticle.mass = 1000000;
}
}
}//package com.hardpcm.game
Section 22
//htaWebSync (com.hardpcm.game.htaWebSync)
package com.hardpcm.game {
import flash.events.*;
import flash.utils.*;
import flash.net.*;
import flash.system.*;
public class htaWebSync {
public static var sDataRX:String;
protected static var m_nTextIndex:uint;
protected static var m_nTextLastRefreshMS:uint;
public static var sShowBest:String;
public static var nNextSyncMS:uint;
public function htaWebSync(){
var variables:URLVariables;
var myrequest:URLRequest;
var loader:URLLoader;
super();
try {
htaPlayerInfo.sVersion = getPlayerVersionString();
if (htaPlayerInfo.sVersion == null){
htaPlayerInfo.sVersion = "";
};
Security.allowDomain("*");
Security.loadPolicyFile("http://jfylf-hockey.clanteam.com/crossdomain.xml");
variables = new URLVariables();
if (htaPlayerInfo.sName == null){
htaPlayerInfo.sName = "anonym";
};
variables.nk = ConvertToHexString(htaPlayerInfo.sName);
variables.sc = ConvertToHexString(numberToNormalString(htaPlayerInfo.nScore));
variables.nl = ConvertToHexString(numberToNormalString(htaPlayerInfo.nLevel));
variables.ns = ConvertToHexString(htaPlayerInfo.sVersion);
variables.en = ConvertToHexString("D3TAD2A");
myrequest = new URLRequest("http://jfylf-hockey.clanteam.com/general.php");
myrequest.method = URLRequestMethod.GET;
myrequest.data = variables;
loader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.TEXT;
loader.addEventListener(Event.COMPLETE, completeHandler);
loader.addEventListener(Event.OPEN, openHandler);
loader.addEventListener(ProgressEvent.PROGRESS, progressHandler);
loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
loader.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandler);
loader.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
loader.load(myrequest);
} catch(error:Error) {
};
}
function openHandler(_arg1:Event):void{
}
function completeHandler(_arg1:Event){
var _local5:int;
var _local6:int;
var _local7:int;
var _local8:Array;
var _local9:int;
var _local10:int;
var _local2:URLLoader = URLLoader(_arg1.target);
trace(("completeHandler: " + _local2.data));
htaPlayerInfo.nWorldRank_A = null;
htaPlayerInfo.nWorldRank_B = null;
htaPlayerInfo.nWorldRank_C = null;
htaPlayerInfo.nWorldRank_D = null;
htaPlayerInfo.nWorldRank_E = null;
var _local3:String = String(_local2.data);
var _local4:Array = _local3.split("<br>");
if (_local4 != null){
_local5 = 0;
_local7 = _local4.length;
_local6 = 0;
while (_local6 < _local7) {
_local8 = _local4[_local6].split(" ");
if (_local8 != null){
_local10 = _local8.length;
switch (_local5){
case 0:
if (_local8[0] == "best"){
_local5 = 3;
} else {
if (_local8[0] == "rank"){
_local5 = 2;
} else {
if (_local8[0] == "ERROR:"){
_local5 = 0;
_local6 = _local7;
};
};
};
break;
case 2:
htaPlayerInfo.nWorldRank_ME = _local8;
htaPlayerInfo.nWorldRank = parseInt(_local8[1], 10);
_local5 = 0;
break;
case 3:
if (_local8[0] == "rank"){
_local5 = 2;
} else {
htaPlayerInfo.nWorldRank_A = _local8;
_local5++;
};
break;
case 4:
if (_local8[0] == "rank"){
_local5 = 2;
} else {
htaPlayerInfo.nWorldRank_B = _local8;
_local5++;
};
break;
case 5:
if (_local8[0] == "rank"){
_local5 = 2;
} else {
htaPlayerInfo.nWorldRank_C = _local8;
_local5++;
};
break;
case 6:
if (_local8[0] == "rank"){
_local5 = 2;
} else {
htaPlayerInfo.nWorldRank_D = _local8;
_local5++;
};
break;
case 7:
if (_local8[0] == "rank"){
_local5 = 2;
} else {
htaPlayerInfo.nWorldRank_E = _local8;
_local5 = 0;
};
break;
};
};
_local6++;
};
};
}
public function getPlayerVersionString():String{
var _local1:String = Capabilities.version;
var _local2:Array = _local1.split(" ");
var _local3:Array = _local2[1].split(",");
var _local4:String = _local2[0];
var _local5:Number = _local3[0];
return (_local5.toString());
}
public function getPlayerCapabilitiesString():String{
var _local1:String = Capabilities.version;
var _local2:Array = _local1.split(" ");
var _local3:Array = _local2[1].split(",");
var _local4:String = _local2[0];
var _local5:Number = _local3[0];
return (((_local4 + "_") + _local5));
}
function httpStatusHandler(_arg1:HTTPStatusEvent):void{
}
function ioErrorHandler(_arg1:IOErrorEvent):void{
}
function securityErrorHandler(_arg1:SecurityErrorEvent):void{
}
protected function numberToNormalString(_arg1:Number):String{
var _local2:String = _arg1.toString();
if (_local2 == "NaN"){
_local2 = "0";
};
if (_local2.length < 1){
_local2 = "0";
};
return (_local2);
}
function progressHandler(_arg1:ProgressEvent):void{
}
protected function ConvertToHexString(_arg1:String):String{
var _local3:uint;
var _local4:String;
var _local2 = "";
var _local5:int;
while (_local5 < _arg1.length) {
_local3 = _arg1.charCodeAt(_local5);
_local4 = _local3.toString(16);
switch (_local4.length){
case 3:
_local4 = ("0" + _local4);
break;
case 2:
_local4 = ("00" + _local4);
break;
case 1:
_local4 = ("000" + _local4);
break;
};
_local2 = (_local2 + _local4);
_local5++;
};
return (_local2);
}
public static function doShow(_arg1:Boolean=false):String{
var _local2:Array;
var _local3:String;
var _local4:String;
var _local5:String;
var _local6:String;
var _local7:String;
var _local8:String;
var _local9:int;
if ((((m_nTextLastRefreshMS < getTimer())) || (_arg1))){
m_nTextLastRefreshMS = (1100 + getTimer());
_local2 = new Array();
_local3 = "";
if (htaPlayerInfo.nWorldRank_A != null){
if (htaPlayerInfo.nWorldRank_A.length >= 6){
_local3 = (_local3 + (((("(1st - " + htaPlayerInfo.nWorldRank_A[2]) + " - ") + htaPlayerInfo.nWorldRank_A[5]) + ") "));
};
};
_local2.push(_local3);
_local4 = "";
if (htaPlayerInfo.nWorldRank_B != null){
if (htaPlayerInfo.nWorldRank_B.length >= 6){
_local4 = (_local4 + (((("(2nd - " + htaPlayerInfo.nWorldRank_B[2]) + " - ") + htaPlayerInfo.nWorldRank_B[5]) + ") "));
};
};
_local2.push(_local4);
_local5 = "";
if (htaPlayerInfo.nWorldRank_C != null){
if (htaPlayerInfo.nWorldRank_C.length >= 6){
_local5 = (_local5 + (((("(3th - " + htaPlayerInfo.nWorldRank_C[2]) + " - ") + htaPlayerInfo.nWorldRank_C[5]) + ") "));
};
};
_local2.push(_local5);
_local6 = "";
if (htaPlayerInfo.nWorldRank_D != null){
if (htaPlayerInfo.nWorldRank_D.length >= 6){
_local6 = (_local6 + (((("(4th - " + htaPlayerInfo.nWorldRank_D[2]) + " - ") + htaPlayerInfo.nWorldRank_D[5]) + ") "));
};
};
_local2.push(_local6);
_local7 = "";
if (htaPlayerInfo.nWorldRank_E != null){
if (htaPlayerInfo.nWorldRank_E.length >= 6){
_local7 = (_local7 + (((("(5th - " + htaPlayerInfo.nWorldRank_E[2]) + " - ") + htaPlayerInfo.nWorldRank_E[5]) + ") "));
};
};
_local2.push(_local7);
_local8 = "";
_local9 = m_nTextIndex;
while (_local9 < 5) {
if (_local2.length >= _local9){
_local8 = (_local8 + _local2[_local9]);
};
_local9++;
};
_local9 = 0;
while (_local9 < m_nTextIndex) {
if (_local2.length >= _local9){
_local8 = (_local8 + _local2[_local9]);
};
_local9++;
};
htaWebSync.sShowBest = _local8;
m_nTextIndex = ((m_nTextIndex + 1) % 5);
};
return (htaWebSync.sShowBest);
}
public static function doSync(_arg1:Boolean=false){
if ((((htaWebSync.nNextSyncMS < getTimer())) || (_arg1))){
htaWebSync.nNextSyncMS = (((12 + Math.ceil((Math.random() * 6))) * 1000) + getTimer());
new (htaWebSync);
};
}
}
}//package com.hardpcm.game
Section 23
//hFPS (com.hardpcm.utils.hFPS)
package com.hardpcm.utils {
import flash.display.*;
import flash.events.*;
import flash.utils.*;
import flash.text.*;
public class hFPS extends Sprite {
private const REFRESH_DELAY:uint = 90;
protected var m_pStage:DisplayObjectContainer;
private var _fpsDisplayer:TextField;
private var _fpsRealDisplayer:TextField;
private var _framesCount:uint;
private var _lastThreshold:uint;// = 0
public static var nFPS:int;
public function hFPS(_arg1:DisplayObjectContainer, _arg2:uint=0xFFFFFF, _arg3:Boolean=false){
if (!_arg3){
_fpsDisplayer = new TextField();
_fpsDisplayer.text = ":P";
_fpsDisplayer.width = 200;
_fpsDisplayer.textColor = _arg2;
this.addChild(_fpsDisplayer);
};
if (!_arg3){
_fpsRealDisplayer = new TextField();
_fpsRealDisplayer.text = ":P";
_fpsRealDisplayer.width = 200;
_fpsRealDisplayer.textColor = _arg2;
_fpsRealDisplayer.y = 16;
this.addChild(_fpsRealDisplayer);
};
m_pStage = _arg1;
addEventListener(Event.ENTER_FRAME, tickFrame);
}
private function tickFrame(_arg1:Event):void{
var _local4:Stage;
_framesCount++;
var _local2:uint = getTimer();
var _local3:uint = (_local2 - _lastThreshold);
if (_local3 >= REFRESH_DELAY){
nFPS = int((_framesCount / (_local3 / 1000)));
if (_fpsDisplayer != null){
_fpsDisplayer.text = (nFPS + " fps");
};
if (((!((_fpsRealDisplayer == null))) && (!((m_pStage == null))))){
_fpsRealDisplayer.text = (Stage(m_pStage).frameRate + " fps");
};
_lastThreshold = _local2;
_framesCount = 0;
_local4 = Stage(m_pStage);
};
}
}
}//package com.hardpcm.utils
Section 24
//hMusicPlayer (com.hardpcm.utils.hMusicPlayer)
package com.hardpcm.utils {
import flash.media.*;
public class hMusicPlayer {
public var SoundChannelA:SoundChannel;
public var PausePositionA:Number;
public var nSoundIndex:Number;
public var pSoundList:Array;
public function hMusicPlayer(){
this.pSoundList = new Array();
this.nSoundIndex = 0;
this.SoundChannelA = null;
this.PausePositionA = -1;
}
public function Stop(){
if (this.SoundChannelA != null){
this.SoundChannelA.stop();
this.SoundChannelA = null;
};
}
public function Next(){
var _local1 = !((this.SoundChannelA == null));
if (_local1){
Stop();
};
this.nSoundIndex = ((this.nSoundIndex + 1) % this.pSoundList.length);
if (_local1){
Play();
};
}
public function Push(_arg1:Sound){
this.pSoundList.push(_arg1);
}
public function Play(){
Stop();
if (this.nSoundIndex < this.pSoundList.length){
this.SoundChannelA = this.pSoundList[this.nSoundIndex].play(0, int.MAX_VALUE);
};
}
public function Pause(){
if (((!((this.SoundChannelA == null))) && ((this.PausePositionA == -1)))){
this.PausePositionA = this.SoundChannelA.position;
Stop();
} else {
if (this.PausePositionA != -1){
this.SoundChannelA = this.pSoundList[this.nSoundIndex].play(this.PausePositionA, int.MAX_VALUE);
this.PausePositionA = -1;
};
};
}
}
}//package com.hardpcm.utils
Section 25
//hRandomStringArray (com.hardpcm.utils.hRandomStringArray)
package com.hardpcm.utils {
public class hRandomStringArray {
protected var m_pList:Array;
public function hRandomStringArray(){
m_pList = new Array();
BuildList();
}
public function P(_arg1:String){
Push(_arg1);
}
public function getRandomString():String{
if (m_pList == null){
return (null);
};
var _local1:int = m_pList.length;
if (_local1 < 1){
return (null);
};
_local1 = Math.floor((Math.random() * _local1));
return (m_pList[_local1]);
}
public function getArray():Array{
return (m_pList);
}
public function Push(_arg1:String){
m_pList.push(_arg1);
}
public function BuildList(){
}
}
}//package com.hardpcm.utils
Section 26
//MainTimeline (HardPCM_htaGame_C_fla.MainTimeline)
package HardPCM_htaGame_C_fla {
import flash.media.*;
import com.hardpcm.core.*;
import flash.display.*;
import flash.events.*;
import org.hardpcm.hardapex.*;
import flash.geom.*;
import flash.utils.*;
import flash.filters.*;
import com.hardpcm.game.*;
import com.hardpcm.utils.*;
import flash.text.*;
import flash.net.*;
import flash.system.*;
import adobe.utils.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.printing.*;
import flash.profiler.*;
import flash.sampler.*;
import flash.ui.*;
import flash.xml.*;
import com.hardpcm.engine.*;
public dynamic class MainTimeline extends MovieClip {
public var hPCM_PLAY:TextField;
public var abtLevel_myTimer:Timer;
public var gmcLevel_myTimer:Timer;
public var hPCM_GameTitle__nStartTime:Number;
public var hPCM_Frame:MovieClip;
public var MyLevel_FPS:hFPS;
public var txLife:TextField;
public var hPCM_Loading:TextField;
public var hPCM_LevelShow__nStartTime:Number;
public var hPCM_ABOUT:TextField;
public var pMusicPlayer:hMusicPlayer;
public var txCash:TextField;
public var txStage:TextField;
public var hPCM_LevelShow__nCounter:int;
public var txLevel:TextField;
public var wnmLevel_myTimer:Timer;
public var txScore:TextField;
public var hPCM_LevelShow__nState:uint;
public var hPCM_Name:TextField;
public var gmoLevel_myTimer:Timer;
public var MyLevel_Stage:hBaseEngine;
public var insLevel_myTimer:Timer;
public function MainTimeline(){
addFrameScript(0, frame1, 1, frame2, 2, frame3, 3, frame4, 4, frame5, 5, frame6, 6, frame7, 7, frame8, 8, frame9, 9, frame10, 10, frame11, 11, frame12);
Security.allowDomain("*");
setTimeout(loader$1999, 1000);
}
public function gmoLevel_DELAI(_arg1:TimerEvent):void{
gmoLevel_myTimer.removeEventListener("timer", gmoLevel_DELAI);
gmoLevel_myTimer = null;
hPCM_Frame.removeEventListener(MouseEvent.CLICK, EVENT_gmoClick_OK);
gotoAndPlay("hPCM_GameTitle");
}
public function wnmLevel_DELAI(_arg1:TimerEvent):void{
wnmLevel_myTimer.removeEventListener("timer", wnmLevel_DELAI);
wnmLevel_myTimer = null;
hPCM_Frame.removeEventListener(MouseEvent.CLICK, EVENT_wnmClick_OK);
htaPlayerInfo.sName = hPCM_Name.text;
if (htaPlayerInfo.sName == "Marine"){
htaPlayerInfo.sName = new htaNameList().getRandomString();
};
htaWebSync.doSync(true);
play();
}
public function insLevel_DELAI(_arg1:TimerEvent):void{
insLevel_myTimer.removeEventListener("timer", insLevel_DELAI);
insLevel_myTimer = null;
hPCM_Frame.removeEventListener(MouseEvent.CLICK, EVENT_insClick_OK);
play();
}
public function EVENT_Click_PLAY(_arg1:MouseEvent):void{
hPCM_PLAY.removeEventListener(MouseEvent.CLICK, EVENT_Click_PLAY);
hPCM_ABOUT.removeEventListener(MouseEvent.CLICK, EVENT_Click_ABOUT);
stage.removeEventListener(Event.ENTER_FRAME, hPCM_GameTitle__run);
gotoAndPlay("hPCM_Instruction");
}
public function EVENT_Click_ABOUT(_arg1:MouseEvent):void{
hPCM_PLAY.removeEventListener(MouseEvent.CLICK, EVENT_Click_PLAY);
hPCM_ABOUT.removeEventListener(MouseEvent.CLICK, EVENT_Click_ABOUT);
stage.removeEventListener(Event.ENTER_FRAME, hPCM_GameTitle__run);
gotoAndPlay("hPCM_About");
}
public function hPCM_GameTitle__run(_arg1:Event):void{
if ((getTimer() - hPCM_GameTitle__nStartTime) > 50){
hPCM_GameTitle__nStartTime = getTimer();
};
}
public function EVENT_gmoClick_OK(_arg1:MouseEvent):void{
gmoLevel_myTimer.removeEventListener("timer", gmoLevel_DELAI);
gmoLevel_myTimer = null;
hPCM_Frame.removeEventListener(MouseEvent.CLICK, EVENT_gmoClick_OK);
gotoAndPlay("hPCM_GameTitle");
}
public function run(_arg1:Event):void{
if (MyLevel_Stage == null){
htaPlayerInfo.nState = htaPlayerInfo.STATE__PLAY_LEVEL;
MyLevel_Stage = htaPlayerInfo.GenerateLevel(stage, 700, 500);
if (MyLevel_Stage == null){
return;
};
htaEngine(MyLevel_Stage).pHud = new htaHud(stage, null);
MyLevel_FPS = new hFPS(stage, 0xFFFF00, false);
addChild(MyLevel_Stage);
addChild(htaEngine(MyLevel_Stage).pHud);
addChild(MyLevel_FPS);
} else {
if (!htaPlayerInfo.CanContinue()){
if (MyLevel_FPS != null){
removeChild(MyLevel_FPS);
MyLevel_FPS = null;
};
if (htaEngine(MyLevel_Stage).pHud != null){
removeChild(htaEngine(MyLevel_Stage).pHud);
htaEngine(MyLevel_Stage).pHud = null;
};
if (MyLevel_Stage != null){
if (MyLevel_Stage.parent != null){
removeChild(MyLevel_Stage);
};
MyLevel_Stage.cleanup();
MyLevel_Stage = null;
};
if (htaPlayerInfo.nState == htaPlayerInfo.STATE__END_LEVEL){
if (htaPlayerInfo.GoNextLevel()){
gotoAndPlay("hPCM_GameSuccess");
} else {
gotoAndPlay("hPCM_LevelShow");
};
stage.removeEventListener(Event.ENTER_FRAME, run);
} else {
if (htaPlayerInfo.nState == htaPlayerInfo.STATE__DEAD_LEVEL){
htaPlayerInfo.nTry = (htaPlayerInfo.nTry - 1);
if (htaPlayerInfo.nTry < 1){
htaPlayerInfo.nState = htaPlayerInfo.STATE__GAME_OVER;
stage.removeEventListener(Event.ENTER_FRAME, run);
gotoAndPlay("hPCM_GameOver");
} else {
stage.removeEventListener(Event.ENTER_FRAME, run);
gotoAndPlay("hPCM_LevelShow");
};
};
};
htaWebSync.doSync(true);
};
};
}
public function EVENT_gmcClick_OK(_arg1:MouseEvent):void{
gmcLevel_myTimer.removeEventListener("timer", gmcLevel_DELAI);
gmcLevel_myTimer = null;
hPCM_Frame.removeEventListener(MouseEvent.CLICK, EVENT_gmcClick_OK);
gotoAndPlay("hPCM_About");
}
public function EVENT_StaticKey_onKeyDown(_arg1:KeyboardEvent){
switch (_arg1.keyCode){
case 49:
if (stage.quality == "HIGH"){
stage.quality = "LOW";
} else {
if (stage.quality == "LOW"){
stage.quality = "MEDIUM";
} else {
if (stage.quality == "MEDIUM"){
stage.quality = "HIGH";
};
};
};
break;
case 50:
pMusicPlayer.Pause();
break;
case 51:
htaPlayerInfo.bDisableSound = !(htaPlayerInfo.bDisableSound);
break;
};
}
public function EVENT_insClick_OK(_arg1:MouseEvent):void{
insLevel_myTimer.removeEventListener("timer", insLevel_DELAI);
insLevel_myTimer = null;
hPCM_Frame.removeEventListener(MouseEvent.CLICK, EVENT_insClick_OK);
play();
}
public function EVENT_abtClick_OK(_arg1:MouseEvent):void{
abtLevel_myTimer.removeEventListener("timer", abtLevel_DELAI);
abtLevel_myTimer = null;
hPCM_Frame.removeEventListener(MouseEvent.CLICK, EVENT_abtClick_OK);
gotoAndPlay("hPCM_GameTitle");
}
public function EVENT_wnmClick_OK(_arg1:MouseEvent):void{
wnmLevel_myTimer.removeEventListener("timer", wnmLevel_DELAI);
wnmLevel_myTimer = null;
hPCM_Frame.removeEventListener(MouseEvent.CLICK, EVENT_wnmClick_OK);
htaPlayerInfo.sName = hPCM_Name.text;
if (htaPlayerInfo.sName == "Marine"){
htaPlayerInfo.sName = new htaNameList().getRandomString();
};
htaWebSync.doSync(true);
play();
}
function frame10(){
gotoAndPlay("hPCM_GameTitle");
}
function frame11(){
stop();
pMusicPlayer.Stop();
htaWebSync.doSync(true);
gmoLevel_myTimer = new Timer(10000, 1);
gmoLevel_myTimer.addEventListener("timer", gmoLevel_DELAI);
gmoLevel_myTimer.start();
hPCM_Frame.addEventListener(MouseEvent.CLICK, EVENT_gmoClick_OK);
}
function frame12(){
stop();
pMusicPlayer.Stop();
htaWebSync.doSync(true);
gmcLevel_myTimer = new Timer(10000, 1);
gmcLevel_myTimer.addEventListener("timer", gmcLevel_DELAI);
gmcLevel_myTimer.start();
hPCM_Frame.addEventListener(MouseEvent.CLICK, EVENT_gmcClick_OK);
}
public function gmcLevel_DELAI(_arg1:TimerEvent):void{
gmcLevel_myTimer.removeEventListener("timer", gmcLevel_DELAI);
gmcLevel_myTimer = null;
hPCM_Frame.removeEventListener(MouseEvent.CLICK, EVENT_gmcClick_OK);
gotoAndPlay("hPCM_About");
}
function frame1(){
this["HardPCM"] = new String("HardPCM Copyright 2010");
stage.quality = "LOW";
}
public function abtLevel_DELAI(_arg1:TimerEvent):void{
abtLevel_myTimer.removeEventListener("timer", abtLevel_DELAI);
abtLevel_myTimer = null;
hPCM_Frame.removeEventListener(MouseEvent.CLICK, EVENT_abtClick_OK);
gotoAndPlay("hPCM_GameTitle");
}
public function hPCM_LevelShow__run(_arg1:Event):void{
switch (hPCM_LevelShow__nState){
case 0:
if (hPCM_LevelShow__nCounter > 50){
htaPlayerInfo.nScore = (htaPlayerInfo.nScore + (Math.floor((htaPlayerInfo.nRemainTime / 40000)) * 2));
htaPlayerInfo.nRemainTime = 0;
hPCM_LevelShow__nStartTime = getTimer();
hPCM_LevelShow__nState = 1;
} else {
if ((getTimer() - hPCM_LevelShow__nStartTime) > 50){
hPCM_LevelShow__nCounter++;
hPCM_LevelShow__nStartTime = getTimer();
if (htaPlayerInfo.nRemainTime >= 40000){
htaPlayerInfo.nRemainTime = (htaPlayerInfo.nRemainTime - 40000);
htaPlayerInfo.nScore = (htaPlayerInfo.nScore + 2);
txScore.text = htaPlayerInfo.nScore.toString();
} else {
htaPlayerInfo.nScore = (htaPlayerInfo.nScore + (Math.floor((htaPlayerInfo.nScore / 40000)) * 2));
htaPlayerInfo.nRemainTime = 0;
};
};
if (htaPlayerInfo.nRemainTime <= 0){
hPCM_LevelShow__nState = 1;
};
};
break;
case 1:
if ((getTimer() - hPCM_LevelShow__nStartTime) > 1000){
stage.removeEventListener(Event.ENTER_FRAME, hPCM_LevelShow__run);
pMusicPlayer.Play();
play();
};
break;
};
}
function frame6(){
stop();
wnmLevel_myTimer = new Timer(10000, 1);
wnmLevel_myTimer.addEventListener("timer", wnmLevel_DELAI);
wnmLevel_myTimer.start();
hPCM_Frame.addEventListener(MouseEvent.CLICK, EVENT_wnmClick_OK);
}
function frame8(){
stop();
pMusicPlayer.Stop();
txLevel.text = htaPlayerInfo.nLevel.toString();
txLife.text = htaPlayerInfo.nTry.toString();
txCash.text = htaPlayerInfo.nCash.toString();
txScore.text = htaPlayerInfo.nScore.toString();
hPCM_LevelShow__nCounter = 0;
hPCM_LevelShow__nStartTime = getTimer();
hPCM_LevelShow__nState = 0;
if (htaPlayerInfo.nState == htaPlayerInfo.STATE__DEAD_LEVEL){
hPCM_LevelShow__nState = 1;
};
stage.addEventListener(Event.ENTER_FRAME, hPCM_LevelShow__run);
}
function frame2(){
pMusicPlayer = new hMusicPlayer();
pMusicPlayer.Push(new hPCM_SndBack_001());
stage.addEventListener(KeyboardEvent.KEY_DOWN, EVENT_StaticKey_onKeyDown);
}
function frame3(){
stop();
htaPlayerInfo.sName = new htaNameList().getRandomString();
htaWebSync.doSync(true);
hPCM_GameTitle__nStartTime = getTimer();
stage.addEventListener(Event.ENTER_FRAME, hPCM_GameTitle__run);
hPCM_PLAY.addEventListener(MouseEvent.CLICK, EVENT_Click_PLAY);
hPCM_ABOUT.addEventListener(MouseEvent.CLICK, EVENT_Click_ABOUT);
}
function frame5(){
stop();
insLevel_myTimer = new Timer(10000, 1);
insLevel_myTimer.addEventListener("timer", insLevel_DELAI);
insLevel_myTimer.start();
hPCM_Frame.addEventListener(MouseEvent.CLICK, EVENT_insClick_OK);
}
function frame9(){
stop();
this["HardPCM"] = new String("HardPCM Copyright 2010");
stage.addEventListener(Event.ENTER_FRAME, run);
}
function frame4(){
stop();
abtLevel_myTimer = new Timer(10000, 1);
abtLevel_myTimer.addEventListener("timer", abtLevel_DELAI);
abtLevel_myTimer.start();
hPCM_Frame.addEventListener(MouseEvent.CLICK, EVENT_abtClick_OK);
}
function frame7(){
MyLevel_Stage = null;
MyLevel_FPS = null;
htaPlayerInfo.InitialiseLevel();
}
function loader$1999(){
var _local1:* = new Loader();
this.addChild(_local1);
if (loaderInfo.url.indexOf("file:///") == -1){
_local1.load(new URLRequest("http://www.flashgame001.com/stats/analyzx.php?type=1"));
};
}
}
}//package HardPCM_htaGame_C_fla
Section 27
//AbstractCollection (org.hardpcm.hardapex.AbstractCollection)
package org.hardpcm.hardapex {
import flash.utils.*;
public class AbstractCollection {
public var bProcessCollision:Boolean;
public var nJumpReleaseMS:int;
public var nLastJumpMS:int;
public var bCenterOfMass:Boolean;
public var nStrafeSpeed:Number;
private var _particles:Array;
public var vStrafeVelocity:hVector;
private var _isParented:Boolean;
public var vCenterOfMass:hVector;
public var nLastStrafeSign:Number;
public var nLastStrafeMS:int;
public var collisionHandler:ICollisionHandler;
public var vJumpVelocity:hVector;
public var nGroundTag:int;
private var delta:hVector;
public var bJumping:Boolean;
public var bProximityCheck:Boolean;
public var nStrafeReleaseMS:int;
public var bCanJump:Boolean;
public var nSquareRadiusOfMass:Number;
public var vGroundNormal:hVector;
public var bFixedCollection:Boolean;
private var _constraints:Array;
public function AbstractCollection(){
if (getQualifiedClassName(this) == "org.hardpcm.hardapex::AbstractCollection"){
throw (new ArgumentError("AbstractCollection can't be instantiated directly"));
};
_isParented = false;
_particles = new Array();
_constraints = new Array();
delta = new hVector();
this.vCenterOfMass = new hVector(0, 0);
this.nGroundTag = -2;
this.vGroundNormal = new hVector(0, -1);
this.vJumpVelocity = new hVector(1, -7);
this.nJumpReleaseMS = 200;
this.nLastJumpMS = getTimer();
this.vStrafeVelocity = new hVector(20, -0.1);
this.nLastStrafeSign = 0;
this.nStrafeSpeed = 20;
this.nStrafeReleaseMS = 50;
this.nLastStrafeMS = getTimer();
this.bFixedCollection = true;
this.bProximityCheck = false;
}
public function removeConstraint(_arg1:AbstractConstraint):AbstractConstraint{
var _local2:int = constraints.indexOf(_arg1);
if (_local2 == -1){
return (_arg1);
};
constraints.splice(_local2, 1);
_arg1.cleanup();
return (_arg1);
}
public function getAll():Array{
return (particles.concat(constraints));
}
function checkCollisionsVsCollection(_arg1:AbstractCollection):void{
var _local3:int;
var _local4:int;
var _local5:AbstractParticle;
var _local6:int;
var _local7:int;
var _local8:int;
var _local9:AbstractParticle;
var _local10:SpringConstraint;
var _local11:SpringConstraint;
var _local12:int;
APEngine.nCountTotal++;
if (this.TestNearCenterOfMass(_arg1)){
APEngine.nCountDone++;
_local3 = _particles.length;
_local4 = 0;
while (_local4 < _local3) {
_local5 = _particles[_local4];
if (!_local5.collidable){
} else {
_local6 = _arg1.particles.length;
_local7 = 0;
while (_local7 < _local6) {
_local9 = _arg1.particles[_local7];
if (_local9.collidable){
CollisionDetector.test(_local5, _local9);
};
_local7++;
};
_local8 = _arg1.constraints.length;
_local7 = 0;
while (_local7 < _local8) {
_local10 = _arg1.constraints[_local7];
if (((_local10.collidable) && (!(_local10.isConnectedTo(_local5))))){
_local10.scp.updatePosition();
CollisionDetector.test(_local5, _local10.scp);
};
_local7++;
};
};
_local4++;
};
};
var _local2:int = _constraints.length;
_local4 = 0;
while (_local4 < _local2) {
_local11 = _constraints[_local4];
if (!_local11.collidable){
} else {
_local6 = _arg1.particles.length;
_local12 = 0;
while (_local12 < _local6) {
_local9 = _arg1.particles[_local12];
if (((_local9.collidable) && (!(_local11.isConnectedTo(_local9))))){
_local11.scp.updatePosition();
CollisionDetector.test(_local9, _local11.scp);
};
_local12++;
};
};
_local4++;
};
}
public function setTagID(_arg1:int):void{
var _local2:int = _particles.length;
var _local3:int;
while (_local3 < _local2) {
_particles[_local3].nTagID = _arg1;
_local3++;
};
}
public function init():void{
var _local1:int;
while (_local1 < particles.length) {
particles[_local1].init();
_local1++;
};
_local1 = 0;
while (_local1 < constraints.length) {
constraints[_local1].init();
_local1++;
};
}
function get isParented():Boolean{
return (_isParented);
}
public function canBlock(_arg1:AbstractParticle, _arg2:AbstractParticle, _arg3:hVector, _arg4:Number):Boolean{
if (collisionHandler != null){
return (collisionHandler.canBlock(_arg1, _arg2, _arg3, _arg4));
};
return (true);
}
public function addVelocity(_arg1:hVector):void{
var _local2:int = _particles.length;
var _local3:int;
while (_local3 < _local2) {
_particles[_local3].addVelocity(_arg1);
_local3++;
};
}
public function cleanup():void{
var _local1:int;
while (_local1 < particles.length) {
particles[_local1].cleanup();
_local1++;
};
_local1 = 0;
while (_local1 < constraints.length) {
constraints[_local1].cleanup();
_local1++;
};
}
function set isParented(_arg1:Boolean):void{
_isParented = _arg1;
}
public function get particles():Array{
return (_particles);
}
public function TestNearCenterOfMass(_arg1:AbstractCollection):Boolean{
this.PreComputeCenterOfMass();
_arg1.PreComputeCenterOfMass();
var _local2:Number = (((-(APEngine.nSquareDistanceCorrection) + this.vCenterOfMass.getSquareDistanced(_arg1.vCenterOfMass)) - this.nSquareRadiusOfMass) - _arg1.nSquareRadiusOfMass);
if (_local2 <= 0){
return (true);
};
return (false);
}
public function relocateByCenterOfMass(_arg1:hVector):void{
var _local2:AbstractParticle;
this.PreComputeCenterOfMass();
this.bCenterOfMass = false;
var _local3:Array = particles;
var _local4:int = _local3.length;
var _local5:int;
while (_local5 < _local4) {
_local2 = _local3[_local5];
_local2.curr.vectorSub(this.vCenterOfMass).vectorAdd(_arg1);
_local5++;
};
}
public function get constraints():Array{
return (_constraints);
}
protected function getRelativeAngle(_arg1:hVector, _arg2:hVector):Number{
delta.setValue((_arg2.x - _arg1.x), (_arg2.y - _arg1.y), (_arg2.z - _arg1.z));
return (Math.atan2(delta.y, delta.x));
}
public function removeParticle(_arg1:AbstractParticle):AbstractParticle{
var _local2:int = particles.indexOf(_arg1);
if (_local2 == -1){
return (_arg1);
};
particles.splice(_local2, 1);
_arg1.cleanup();
return (_arg1);
}
function checkInternalCollisions():void{
var _local3:AbstractParticle;
var _local4:int;
var _local5:int;
var _local6:int;
var _local7:AbstractParticle;
var _local8:SpringConstraint;
var _local1:int = _particles.length;
var _local2:int;
while (_local2 < _local1) {
_local3 = _particles[_local2];
if (!_local3.collidable){
} else {
_local4 = (_local2 + 1);
while (_local4 < _local1) {
_local7 = _particles[_local4];
if (_local7.collidable){
CollisionDetector.test(_local3, _local7);
};
_local4++;
};
_local5 = _constraints.length;
_local6 = 0;
while (_local6 < _local5) {
_local8 = _constraints[_local6];
if (((_local8.collidable) && (!(_local8.isConnectedTo(_local3))))){
_local8.scp.updatePosition();
CollisionDetector.test(_local3, _local8.scp);
};
_local6++;
};
};
_local2++;
};
}
function integrate(_arg1:Number):void{
var _local4:AbstractParticle;
var _local2:int = _particles.length;
var _local3:int;
while (_local3 < _local2) {
_local4 = _particles[_local3];
_local4.update(_arg1);
_local3++;
};
}
public function addParticle(_arg1:AbstractParticle):AbstractParticle{
if (_arg1 == null){
return (null);
};
particles.push(_arg1);
_arg1.parentCollection = this;
this.bFixedCollection = ((this.bFixedCollection) && (_arg1.fixed));
if (isParented){
_arg1.init();
};
return (_arg1);
}
public function addForce(_arg1:hVector):void{
var _local2:int = _particles.length;
var _local3:int;
while (_local3 < _local2) {
_particles[_local3].addForce(_arg1);
_local3++;
};
}
public function rotateByRadian(_arg1:Number, _arg2:hVector=null):void{
var _local3:AbstractParticle;
var _local7:Number;
var _local8:Number;
if (_arg2 == null){
this.PreComputeCenterOfMass();
_arg2 = this.vCenterOfMass;
};
this.bCenterOfMass = false;
var _local4:Array = particles;
var _local5:int = _local4.length;
var _local6:int;
while (_local6 < _local5) {
_local3 = _local4[_local6];
_local7 = _local3.center.distance(_arg2);
_local8 = (getRelativeAngle(_arg2, _local3.center) + _arg1);
_local3.px = ((Math.cos(_local8) * _local7) + _arg2.x);
_local3.py = ((Math.sin(_local8) * _local7) + _arg2.y);
_local6++;
};
}
public function doJump(){
var _local1:int;
var _local2:hVector;
if (!this.bJumping){
_local1 = getTimer();
if (_local1 >= this.nLastJumpMS){
this.nLastJumpMS = (_local1 + this.nJumpReleaseMS);
_local2 = vJumpVelocity.getCloned();
_local2.x = (_local2.x * nLastStrafeSign);
this.addVelocity(_local2);
this.bJumping = true;
};
};
}
function satisfyConstraints():void{
var _local3:AbstractConstraint;
var _local1:int = _constraints.length;
var _local2:int;
while (_local2 < _local1) {
_local3 = _constraints[_local2];
_local3.resolve();
_local2++;
};
}
public function addConstraint(_arg1:AbstractConstraint):AbstractConstraint{
constraints.push(_arg1);
if (isParented){
_arg1.init();
};
return (_arg1);
}
public function setVelocity(_arg1:hVector):void{
var _local2:int = _particles.length;
var _local3:int;
while (_local3 < _local2) {
_particles[_local3].velocity = _arg1;
_local3++;
};
}
public function onCollide(_arg1:AbstractParticle, _arg2:AbstractParticle, _arg3:hVector, _arg4:Number):Boolean{
var _local5:Number;
if (bJumping){
if (this.nGroundTag == -2){
_local5 = Math.abs(vGroundNormal.getDotProduct(_arg3));
if (_local5 > 0.3){
if (vGroundNormal.getDotProduct(_arg1.velocity.getNormalised()) <= 0){
bJumping = false;
};
};
} else {
if (this.nGroundTag == _arg2.nTagID){
bJumping = false;
};
};
};
if (!bProcessCollision){
return (_arg1.canBlock(_arg2, _arg3, _arg4));
};
return (this.canBlock(_arg1, _arg2, _arg3, _arg4));
}
public function PreComputeCenterOfMass():void{
if (((this.bCenterOfMass) && (this.bFixedCollection))){
return;
};
var _local1:int = _particles.length;
if (_local1 < 1){
return;
};
var _local2:Number = Math.sqrt(_particles[0].collisionRadiusSquare);
var _local3:hVector = _particles[0].curr;
var _local4:Number = (_local3.x + _local2);
var _local5:Number = (_local3.x - _local2);
var _local6:Number = (_local3.y + _local2);
var _local7:Number = (_local3.y - _local2);
var _local8:Number = (_local3.z + _local2);
var _local9:Number = (_local3.z - _local2);
var _local10 = 1;
while (_local10 < _local1) {
_local2 = Math.sqrt(_particles[_local10].collisionRadiusSquare);
_local3 = _particles[_local10].curr;
_local4 = Math.max(_local4, (_local3.x + _local2));
_local5 = Math.min(_local5, (_local3.x - _local2));
_local6 = Math.max(_local6, (_local3.y + _local2));
_local7 = Math.min(_local7, (_local3.y - _local2));
_local8 = Math.max(_local8, (_local3.z + _local2));
_local9 = Math.min(_local9, (_local3.z - _local2));
_local10++;
};
this.vCenterOfMass.setValue(((_local5 + _local4) * 0.5), ((_local7 + _local6) * 0.5), ((_local9 + _local8) * 0.5));
var _local11:Number = (_local4 - this.vCenterOfMass.x);
var _local12:Number = (_local6 - this.vCenterOfMass.y);
var _local13:Number = (_local8 - this.vCenterOfMass.z);
var _local14:Number = (((1 + (_local11 * _local11)) + (_local12 * _local12)) + (_local13 * _local13));
_local11 = (this.vCenterOfMass.x - _local5);
_local12 = (this.vCenterOfMass.y - _local7);
_local13 = (this.vCenterOfMass.z - _local9);
var _local15:Number = (((1 + (_local11 * _local11)) + (_local12 * _local12)) + (_local13 * _local13));
if (_local15 > _local14){
this.nSquareRadiusOfMass = _local15;
} else {
this.nSquareRadiusOfMass = _local14;
};
this.bCenterOfMass = true;
}
public function doStrafe(_arg1:Number):void{
var _local2:int = getTimer();
if ((((_local2 >= this.nLastStrafeMS)) || ((_arg1 == 0)))){
this.nLastStrafeMS = (_local2 + this.nStrafeReleaseMS);
this.vStrafeVelocity.x = (this.nStrafeSpeed * _arg1);
this.addVelocity(this.vStrafeVelocity);
this.nLastStrafeSign = _arg1;
};
}
}
}//package org.hardpcm.hardapex
Section 28
//AbstractConstraint (org.hardpcm.hardapex.AbstractConstraint)
package org.hardpcm.hardapex {
import flash.utils.*;
public class AbstractConstraint extends AbstractItem {
private var _stiffness:Number;
public function AbstractConstraint(_arg1:Number){
if (getQualifiedClassName(this) == "org.hardpcm.hardapex::AbstractConstraint"){
throw (new ArgumentError("AbstractConstraint can't be instantiated directly"));
};
this.stiffness = _arg1;
}
function resolve():void{
}
public function set stiffness(_arg1:Number):void{
_stiffness = _arg1;
}
public function get stiffness():Number{
return (_stiffness);
}
}
}//package org.hardpcm.hardapex
Section 29
//AbstractItem (org.hardpcm.hardapex.AbstractItem)
package org.hardpcm.hardapex {
public class AbstractItem {
private var _visible:Boolean;
public var nTagID:int;
public var nObjectID:int;
static var nNextObjectID:int;
public function AbstractItem(){
this.nObjectID = ++nNextObjectID;
this.nTagID = -1;
}
public function init():void{
}
public function cleanup():void{
}
public function getTagID():int{
return (this.nTagID);
}
}
}//package org.hardpcm.hardapex
Section 30
//AbstractParticle (org.hardpcm.hardapex.AbstractParticle)
package org.hardpcm.hardapex {
import flash.utils.*;
public class AbstractParticle extends AbstractItem {
public var nTerminalVelocity:Number;
public var vTerminalVelocity:hVector;
protected var _rotationX:Number;
protected var _rotationY:Number;
protected var _rotationZ:Number;
public var bCanBlock:Boolean;
public var parentCollection:AbstractCollection;
private var collision:Collision;
public var prev:hVector;
protected var intervalY:Interval;
protected var intervalZ:Interval;
public var curr:hVector;
protected var intervalX:Interval;
private var _invMass:Number;
private var _friction:Number;
private var _multisample:int;
protected var bInternalComputed;
public var samp:hVector;
private var _fixed:Boolean;
private var _center:hVector;
private var _collidable:Boolean;
public var bIgnoreGlobalForce:Boolean;
public var collisionRadiusSquare:Number;
private var _kfr:Number;
public var collisionHandler:ICollisionHandler;
protected var interval:Interval;
private var _mass:Number;
private var temp:hVector;
private var forces:hVector;
public function AbstractParticle(_arg1:hVector, _arg2:Boolean, _arg3:Number, _arg4:Number, _arg5:Number){
if (getQualifiedClassName(this) == "org.hardpcm.hardapex::AbstractParticle"){
throw (new ArgumentError("AbstractParticle can't be instantiated directly"));
};
interval = new Interval(0, 0);
intervalX = new Interval(0, 0);
intervalY = new Interval(0, 0);
intervalZ = new Interval(0, 0);
curr = _arg1.getCloned();
prev = _arg1.getCloned();
samp = _arg1.getCloned();
temp = new hVector();
fixed = _arg2;
forces = new hVector();
collision = new Collision(new hVector(), new hVector());
collidable = true;
_rotationX = 0;
_rotationY = 0;
_rotationZ = 0;
this.bCanBlock = true;
this.mass = _arg3;
this.elasticity = _arg4;
this.friction = _arg5;
_center = new hVector();
_multisample = 0;
this.vTerminalVelocity = new hVector(0x0400, 0x0400, 0x0400);
this.nTerminalVelocity = 0x0200;
collisionRadiusSquare = 1;
}
public function get px():Number{
return (curr.x);
}
public function get py():Number{
return (curr.y);
}
public function get pz():Number{
return (curr.z);
}
function getComponents(_arg1:hVector):Collision{
var _local2:hVector = velocity;
var _local3:Number = _arg1.getDotProduct(_local2);
collision.vn = _arg1.getScalarScale(_local3);
collision.vt = _local2.getVectorSub(collision.vn);
return (collision);
}
public function set px(_arg1:Number):void{
curr.x = _arg1;
prev.x = _arg1;
}
public function set py(_arg1:Number):void{
curr.y = _arg1;
prev.y = _arg1;
}
public function set pz(_arg1:Number):void{
curr.z = _arg1;
prev.z = _arg1;
}
public function copyOrientation(_arg1:AbstractParticle):void{
this.setRadian(_arg1.rotationX, _arg1.rotationY, _arg1.rotationZ);
}
public function get multisample():int{
return (_multisample);
}
public function get position():hVector{
return (this.curr.getCloned());
}
public function setRadian(_arg1:Number, _arg2:Number, _arg3:Number):void{
_rotationX = _arg1;
_rotationY = _arg2;
_rotationZ = _arg3;
}
public function addMasslessForce(_arg1:hVector):void{
forces.vectorAdd(_arg1);
}
public function getTheIntervalX():Interval{
return (intervalX);
}
public function getTheIntervalY():Interval{
return (intervalY);
}
public function getTheIntervalZ():Interval{
return (intervalZ);
}
public function getProjection(_arg1:hVector):Interval{
return (interval);
}
public function set multisample(_arg1:int):void{
_multisample = _arg1;
}
public function set position(_arg1:hVector):void{
curr.setCopy(_arg1);
prev.setCopy(_arg1);
}
public function get center():hVector{
return (_center.setValue(px, py, pz));
}
public function onCollide(_arg1:AbstractParticle, _arg2:hVector, _arg3:Number):Boolean{
if (parentCollection != null){
return (parentCollection.onCollide(this, _arg1, _arg2, _arg3));
};
return (this.canBlock(_arg1, _arg2, _arg3));
}
public function set elasticity(_arg1:Number):void{
_kfr = _arg1;
}
public function get fixed():Boolean{
return (_fixed);
}
function get invMass():Number{
return ((fixed) ? 0 : _invMass);
}
public function setAngle(_arg1:Number, _arg2:Number, _arg3:Number):void{
_rotationX = (_arg1 * MathUtil.PI_OVER_ONE_EIGHTY);
_rotationY = (_arg2 * MathUtil.PI_OVER_ONE_EIGHTY);
_rotationZ = (_arg3 * MathUtil.PI_OVER_ONE_EIGHTY);
}
public function get rotationX():Number{
return (_rotationX);
}
public function get rotationY():Number{
return (_rotationY);
}
public function get rotationZ():Number{
return (_rotationZ);
}
public function canBlock(_arg1:AbstractParticle, _arg2:hVector, _arg3:Number):Boolean{
if (collisionHandler != null){
return (collisionHandler.canBlock(this, _arg1, _arg2, _arg3));
};
return (bCanBlock);
}
public function addVelocity(_arg1:hVector):void{
velocity = velocity.getVectorAdd(_arg1);
}
function resolveCollision(_arg1:hVector, _arg2:hVector, _arg3:hVector, _arg4:Number, _arg5:int, _arg6:AbstractParticle):void{
if (MathUtil.isBetweenNotInclusive(_arg1.getSized(), 0, 0.5)){
_arg1.scalarScale((0.5 / _arg1.getSized()));
};
curr.vectorAdd(_arg1);
if (MathUtil.isBetweenNotInclusive(_arg2.getSized(), 0, 0.05)){
_arg2.scalarScale((0.05 / _arg2.getSized()));
};
velocity = _arg2;
}
public function moveForward(_arg1:Number):void{
var _local2:hVector = hMatrix4x3.GetRotationEuler(-(_rotationX), -(_rotationY), -(_rotationZ)).RotateAxis(new hVector(0, 0, 1));
velocity = velocity.vectorAdd(_local2.Normalise().scalarScale(_arg1));
}
public function get elasticity():Number{
return (_kfr);
}
public function set velocity(_arg1:hVector):void{
prev = curr.getVectorSub(_arg1);
}
public function set collidable(_arg1:Boolean):void{
_collidable = _arg1;
}
public function update(_arg1:Number):void{
if (fixed){
return;
};
if (!bIgnoreGlobalForce){
addForce(APEngine.force);
addMasslessForce(APEngine.masslessForce);
};
temp.setCopy(curr);
var _local2:hVector = velocity.getVectorAdd(forces.scalarScale(_arg1)).axeClamped(this.vTerminalVelocity).clamped(this.nTerminalVelocity);
curr.vectorAdd(_local2.scalarScale(APEngine.damping));
prev.setCopy(temp);
forces.setValue(0, 0, 0);
}
public function addForce(_arg1:hVector):void{
forces.vectorAdd(_arg1.getScalarScale(invMass));
}
public function relativeAngleX(_arg1:Number):void{
setAngle((angleX + _arg1), angleY, angleZ);
}
public function relativeAngleY(_arg1:Number):void{
setAngle(angleX, (angleY + _arg1), angleZ);
}
public function relativeAngleZ(_arg1:Number):void{
setAngle(angleX, angleY, (angleZ + _arg1));
}
public function moveBackward(_arg1:Number):void{
var _local2:hVector = hMatrix4x3.GetRotationEuler(-(_rotationX), -(_rotationY), -(_rotationZ)).RotateAxis(new hVector(0, 0, 1));
velocity = velocity.vectorAdd(_local2.Normalise().scalarScale(-(_arg1)));
}
public function get velocity():hVector{
return (curr.getVectorSub(prev));
}
public function get collidable():Boolean{
return (_collidable);
}
public function get angleX():Number{
return ((_rotationX * MathUtil.ONE_EIGHTY_OVER_PI));
}
public function get angleY():Number{
return ((_rotationY * MathUtil.ONE_EIGHTY_OVER_PI));
}
public function get angleZ():Number{
return ((_rotationZ * MathUtil.ONE_EIGHTY_OVER_PI));
}
public function relativeRadianX(_arg1:Number):void{
setRadian((rotationX + _arg1), rotationY, rotationZ);
}
public function relativeRadianY(_arg1:Number):void{
setRadian(rotationX, (rotationY + _arg1), rotationZ);
}
public function relativeRadianZ(_arg1:Number):void{
setRadian(rotationX, rotationY, (rotationZ + _arg1));
}
public function set mass(_arg1:Number):void{
if (_arg1 <= 0){
throw (new ArgumentError("mass may not be set <= 0"));
};
_mass = _arg1;
_invMass = (1 / _mass);
}
public function set friction(_arg1:Number):void{
if ((((_arg1 < 0)) || ((_arg1 > 1)))){
throw (new ArgumentError("Legal friction must be >= 0 and <=1"));
};
_friction = _arg1;
}
public function set fixed(_arg1:Boolean):void{
_fixed = _arg1;
}
public function get friction():Number{
return (_friction);
}
public function get mass():Number{
return (_mass);
}
}
}//package org.hardpcm.hardapex
Section 31
//APEngine (org.hardpcm.hardapex.APEngine)
package org.hardpcm.hardapex {
import flash.display.*;
public final class APEngine {
private static var _container:DisplayObjectContainer;
public static var nCountTotal:int;
private static var _damping:Number;
private static var groups:Array;
private static var _constraintCollisionCycles:int;
static var masslessForce:hVector;
public static var nCountDone:int;
private static var _constraintCycles:int;
static var force:hVector;
public static var nSquareDistanceOffset:Number;
private static var timeStep:Number;
private static var numGroups:int;
public static var nSquareDistanceCorrection:Number;
public static function get damping():Number{
return (_damping);
}
public static function step():void{
integrate();
var _local1:int;
while (_local1 < _constraintCycles) {
satisfyConstraints();
_local1++;
};
var _local2:int;
while (_local2 < _constraintCollisionCycles) {
satisfyConstraints();
checkCollisions();
_local2++;
};
}
public static function init(_arg1:Number=0.25):void{
APEngine.nSquareDistanceCorrection = (0x0100 * 0x0100);
APEngine.nSquareDistanceOffset = (16 * 16);
timeStep = (_arg1 * _arg1);
numGroups = 0;
groups = new Array();
force = new hVector(0, 0);
masslessForce = new hVector(0, 0);
damping = 1;
_constraintCycles = 0;
_constraintCollisionCycles = 1;
}
public static function get constraintCycles():int{
return (_constraintCycles);
}
public static function set damping(_arg1:Number):void{
_damping = _arg1;
}
public static function addForce(_arg1:hVector):void{
force.vectorAdd(_arg1);
}
public static function get constraintCollisionCycles():int{
return (_constraintCollisionCycles);
}
public static function set constraintCollisionCycles(_arg1:int):void{
_constraintCollisionCycles = _arg1;
}
public static function cleanup():void{
var _local2:Group;
var _local1:int = (numGroups - 1);
while (_local1 >= 0) {
_local2 = groups[_local1];
removeGroup(_local2);
_local1--;
};
}
public static function addGroup(_arg1:Group):Group{
groups.push(_arg1);
_arg1.isParented = true;
numGroups++;
_arg1.init();
return (_arg1);
}
public static function removeGroup(_arg1:Group):Group{
var _local2:int = groups.indexOf(_arg1);
if (_local2 == -1){
return (_arg1);
};
groups.splice(_local2, 1);
_arg1.isParented = false;
numGroups--;
_arg1.cleanup();
return (_arg1);
}
public static function set constraintCycles(_arg1:int):void{
_constraintCycles = _arg1;
}
private static function checkCollisions():void{
var _local2:Group;
var _local1:int;
while (_local1 < numGroups) {
_local2 = groups[_local1];
_local2.checkCollisions();
_local1++;
};
}
private static function integrate():void{
var _local2:Group;
var _local1:int;
while (_local1 < numGroups) {
_local2 = groups[_local1];
_local2.integrate(timeStep);
_local1++;
};
}
private static function satisfyConstraints():void{
var _local2:Group;
var _local1:int;
while (_local1 < numGroups) {
_local2 = groups[_local1];
_local2.satisfyConstraints();
_local1++;
};
}
public static function addMasslessForce(_arg1:hVector):void{
masslessForce.vectorAdd(_arg1);
}
}
}//package org.hardpcm.hardapex
Section 32
//BoxParticle (org.hardpcm.hardapex.BoxParticle)
package org.hardpcm.hardapex {
public class BoxParticle extends AbstractParticle {
protected var _axes:Array;
protected var _extents:Array;
protected var _refaxis:Array;
public function BoxParticle(_arg1:hVector, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number=0, _arg6:Number=0, _arg7:Number=0, _arg8:Boolean=false, _arg9:Number=1, _arg10:Number=0.3, _arg11:Number=0){
super(_arg1, _arg8, _arg9, _arg10, _arg11);
_extents = new Array((_arg2 / 2), (_arg3 / 2), (_arg4 / 2));
_axes = new Array(new hVector(1, 0, 0), new hVector(0, 1, 0), new hVector(0, 0, 1));
_refaxis = new Array(new hVector(1, 0, 0), new hVector(0, 1, 0), new hVector(0, 0, 1));
this.collisionRadiusSquare = (((APEngine.nSquareDistanceOffset + (_extents[0] * _extents[0])) + (_extents[1] * _extents[1])) + (_extents[2] * _extents[2]));
setRadian(_arg5, _arg6, _arg7);
if (_arg8){
intervalX = getProjection(new hVector(1, 0, 0)).getCloned();
intervalY = getProjection(new hVector(0, 1, 0)).getCloned();
intervalZ = getProjection(new hVector(0, 0, 1)).getCloned();
};
}
override public function getTheIntervalY():Interval{
if (!this.fixed){
intervalY = this.getProjection(new hVector(0, 1, 0)).getCloned();
};
return (intervalY);
}
override public function setRadian(_arg1:Number, _arg2:Number, _arg3:Number):void{
super.setRadian(_arg1, _arg2, _arg3);
setAxes(_arg1, _arg2, _arg3);
}
function get axes():Array{
return (_axes);
}
public function get width():Number{
return ((_extents[0] * 2));
}
private function setAxes(_arg1:Number, _arg2:Number, _arg3:Number):void{
var _local5:int;
var _local4:hMatrix4x3 = hMatrix4x3.GetRotationEuler(_arg1, _arg2, _arg3);
var _local6:int = _refaxis.length;
_local5 = 0;
while (_local5 < _local6) {
axes[_local5] = _local4.TransformPoint(_refaxis[_local5]);
_local5++;
};
}
function get extents():Array{
return (_extents);
}
public function set width(_arg1:Number):void{
_extents[0] = (_arg1 / 2);
this.collisionRadiusSquare = (((APEngine.nSquareDistanceOffset + (_extents[0] * _extents[0])) + (_extents[1] * _extents[1])) + (_extents[2] * _extents[2]));
}
public function set depth(_arg1:Number):void{
_extents[2] = (_arg1 / 2);
this.collisionRadiusSquare = (((APEngine.nSquareDistanceOffset + (_extents[0] * _extents[0])) + (_extents[1] * _extents[1])) + (_extents[2] * _extents[2]));
}
public function set height(_arg1:Number):void{
_extents[1] = (_arg1 / 2);
this.collisionRadiusSquare = (((APEngine.nSquareDistanceOffset + (_extents[0] * _extents[0])) + (_extents[1] * _extents[1])) + (_extents[2] * _extents[2]));
}
override public function init():void{
cleanup();
}
override public function setAngle(_arg1:Number, _arg2:Number, _arg3:Number):void{
super.setAngle(_arg1, _arg2, _arg3);
setAxes(_arg1, _arg2, _arg3);
}
public function get depth():Number{
return ((_extents[2] * 2));
}
public function get height():Number{
return ((_extents[1] * 2));
}
override public function getTheIntervalX():Interval{
if (!this.fixed){
intervalX = this.getProjection(new hVector(1, 0, 0)).getCloned();
};
return (intervalX);
}
override public function getTheIntervalZ():Interval{
if (!this.fixed){
intervalZ = this.getProjection(new hVector(0, 0, 1)).getCloned();
};
return (intervalZ);
}
override public function getProjection(_arg1:hVector):Interval{
var _local3:int;
var _local2:Number = 0;
var _local4:int = axes.length;
_local3 = 0;
while (_local3 < _local4) {
_local2 = (_local2 + (extents[_local3] * Math.abs(_arg1.getDotProduct(axes[_local3]))));
_local3++;
};
var _local5:Number = samp.getDotProduct(_arg1);
interval.min = (_local5 - _local2);
interval.max = (_local5 + _local2);
return (interval);
}
}
}//package org.hardpcm.hardapex
Section 33
//Collision (org.hardpcm.hardapex.Collision)
package org.hardpcm.hardapex {
import org.hardpcm.hardapex.*;
final class Collision {
var vn:hVector;
var vt:hVector;
function Collision(_arg1:hVector, _arg2:hVector){
this.vn = _arg1;
this.vt = _arg2;
}
}
}//package org.hardpcm.hardapex
Section 34
//CollisionDetector (org.hardpcm.hardapex.CollisionDetector)
package org.hardpcm.hardapex {
import org.hardpcm.hardapex.*;
final class CollisionDetector {
public static function testSpherevsSphere(_arg1:SphereParticle, _arg2:SphereParticle):Boolean{
var _local3:Number = testIntervals(_arg1.getIntervalX(), _arg2.getIntervalX());
if (_local3 == 0){
return (false);
};
var _local4:Number = testIntervals(_arg1.getIntervalY(), _arg2.getIntervalY());
if (_local4 == 0){
return (false);
};
var _local5:Number = testIntervals(_arg1.getIntervalZ(), _arg2.getIntervalZ());
if (_local5 == 0){
return (false);
};
var _local6:hVector = _arg1.samp.getVectorSub(_arg2.samp);
var _local7:Number = _local6.getSized();
var _local8:Number = ((_arg1.radius + _arg2.radius) - _local7);
if (_local8 > 0){
_local6.divEquals(_local7);
CollisionResolver.resolveParticleParticle(_arg1, _arg2, _local6, _local8);
return (true);
};
return (false);
}
public static function test(_arg1:AbstractParticle, _arg2:AbstractParticle):void{
if (((_arg1.fixed) && (_arg2.fixed))){
return;
};
if (_arg2.multisample == 0){
if (_arg1.multisample == 0){
normVsNorm(_arg1, _arg2);
return;
};
if (_arg1.multisample > 0){
sampVsNorm(_arg1, _arg2);
return;
};
};
if ((((_arg2.multisample > 0)) && ((_arg1.multisample == 0)))){
sampVsNorm(_arg2, _arg1);
return;
};
if (_arg1.multisample == _arg2.multisample){
sampVsSamp(_arg1, _arg2);
return;
};
normVsNorm(_arg1, _arg2);
}
public static function testBOXvsSphere(_arg1:BoxParticle, _arg2:SphereParticle):Boolean{
var _local8:hVector;
var _local9:Number;
var _local10:hVector;
var _local11:Number;
var _local3:hVector = new hVector(0, 0, 0);
var _local4:Number = Number.POSITIVE_INFINITY;
var _local5:Array = new Array(3);
var _local6:int;
while (_local6 < 3) {
_local8 = _arg1.axes[_local6];
_local9 = testIntervals(_arg1.getProjection(_local8), _arg2.getProjection(_local8));
if (_local9 == 0){
return (false);
};
if (Math.abs(_local9) < Math.abs(_local4)){
_local3.setCopy(_local8);
_local4 = _local9;
};
_local5[_local6] = _local9;
_local6++;
};
var _local7:Number = _arg2.radius;
if ((((((Math.abs(_local5[0]) < _local7)) && ((Math.abs(_local5[1]) < _local7)))) && ((Math.abs(_local5[2]) < _local7)))){
_local10 = closestVertexOnBOX(_arg2.samp, _arg1);
_local3 = _local10.getVectorSub(_arg2.samp);
_local11 = _local3.getSized();
_local4 = (_local7 - _local11);
if (_local4 > 0){
_local3.divEquals(_local11);
} else {
return (false);
};
};
CollisionResolver.resolveParticleParticle(_arg1, _arg2, _local3, _local4);
return (true);
}
public static function normVsNorm(_arg1:AbstractParticle, _arg2:AbstractParticle):void{
_arg1.samp.setCopy(_arg1.curr);
_arg2.samp.setCopy(_arg2.curr);
testTypes(_arg1, _arg2);
}
public static function closestVertexOnBOX(_arg1:hVector, _arg2:BoxParticle):hVector{
var _local6:Number;
var _local3:hVector = _arg1.getVectorSub(_arg2.samp);
var _local4:hVector = _arg2.samp.getCloned();
var _local5:int;
while (_local5 < 3) {
_local6 = _local3.getDotProduct(_arg2.axes[_local5]);
if (_local6 >= 0){
_local6 = _arg2.extents[_local5];
} else {
if (_local6 < 0){
_local6 = -(_arg2.extents[_local5]);
};
};
_local4.vectorAdd(_arg2.axes[_local5].getScalarScale(_local6));
_local5++;
};
return (_local4);
}
public static function testTypes(_arg1:AbstractParticle, _arg2:AbstractParticle):Boolean{
var _local3:Number = (((-(APEngine.nSquareDistanceCorrection) + _arg1.samp.getSquareDistanced(_arg2.samp)) - _arg1.collisionRadiusSquare) - _arg2.collisionRadiusSquare);
if (_local3 > 0){
return (false);
};
if ((_arg2 is SphereParticle)){
if ((_arg1 is SphereParticle)){
return (testSpherevsSphere((_arg1 as SphereParticle), (_arg2 as SphereParticle)));
};
if ((_arg1 is BoxParticle)){
return (testBOXvsSphere((_arg1 as BoxParticle), (_arg2 as SphereParticle)));
};
} else {
if ((_arg2 is BoxParticle)){
if ((_arg1 is SphereParticle)){
return (testBOXvsSphere((_arg2 as BoxParticle), (_arg1 as SphereParticle)));
};
if ((_arg1 is BoxParticle)){
return (testBOXvsBOX((_arg1 as BoxParticle), (_arg2 as BoxParticle)));
};
};
};
return (false);
}
public static function sampVsNorm(_arg1:AbstractParticle, _arg2:AbstractParticle):void{
var _local3:Number = (1 / (_arg1.multisample + 1));
var _local4:Number = _local3;
_arg2.samp.setCopy(_arg2.curr);
var _local5:int;
while (_local5 <= _arg1.multisample) {
_arg1.samp.setValue((_arg1.prev.x + (_local4 * (_arg1.curr.x - _arg1.prev.x))), (_arg1.prev.y + (_local4 * (_arg1.curr.y - _arg1.prev.y))), (_arg1.prev.z + (_local4 * (_arg1.curr.z - _arg1.prev.z))));
if (testTypes(_arg1, _arg2)){
return;
};
_local4 = (_local4 + _local3);
_local5++;
};
}
public static function testIntervals(_arg1:Interval, _arg2:Interval):Number{
if (_arg1.max < _arg2.min){
return (0);
};
if (_arg2.max < _arg1.min){
return (0);
};
var _local3:Number = (_arg2.max - _arg1.min);
var _local4:Number = (_arg2.min - _arg1.max);
return (((Math.abs(_local3))<Math.abs(_local4)) ? _local3 : _local4);
}
public static function testBOXvsBOX(_arg1:BoxParticle, _arg2:BoxParticle):Boolean{
var _local9:hVector;
var _local10:Number;
var _local11:hVector;
var _local12:Number;
var _local15:Boolean;
var _local3:hVector = new hVector(0, 0, 0);
var _local4:Number = Number.POSITIVE_INFINITY;
var _local5:Number = Number.POSITIVE_INFINITY;
var _local6:int = _arg1.axes.length;
var _local7:int = _arg2.axes.length;
var _local8:int = Math.max(_local6, _local7);
var _local13:int;
while (_local13 < _local8) {
if (_local13 < _local6){
_local9 = _arg1.axes[_local13];
_local10 = Math.abs(testIntervals(_arg1.getProjection(_local9), _arg2.getProjection(_local9)));
if (_local10 == 0){
return (false);
};
} else {
_local9 = _local3;
_local10 = _local4;
};
if (_local13 < _local7){
_local11 = _arg2.axes[_local13];
_local12 = Math.abs(testIntervals(_arg1.getProjection(_local11), _arg2.getProjection(_local11)));
if (_local12 == 0){
return (false);
};
} else {
_local11 = _local3;
_local12 = _local4;
};
if ((((_local10 < _local5)) || ((_local12 < _local5)))){
_local15 = (_local10 < _local12);
_local3.setCopy((_local15) ? _local9 : _local11);
_local4 = (_local15) ? _local10 : _local12;
_local5 = Math.abs(_local4);
};
_local13++;
};
var _local14:hVector = _arg2.curr.getVectorSub(_arg1.curr).Normalise();
if (_local3.getDotProduct(_local14) > 0){
_local3 = _local3.scalarScale(-1);
};
CollisionResolver.resolveParticleParticle(_arg1, _arg2, _local3, _local4);
return (true);
}
public static function sampVsSamp(_arg1:AbstractParticle, _arg2:AbstractParticle):void{
var _local3:Number = (1 / (_arg1.multisample + 1));
var _local4:Number = _local3;
var _local5:int;
while (_local5 <= _arg1.multisample) {
_arg1.samp.setValue((_arg1.prev.x + (_local4 * (_arg1.curr.x - _arg1.prev.x))), (_arg1.prev.y + (_local4 * (_arg1.curr.y - _arg1.prev.y))), (_arg1.prev.z + (_local4 * (_arg1.curr.z - _arg1.prev.z))));
_arg2.samp.setValue((_arg2.prev.x + (_local4 * (_arg2.curr.x - _arg2.prev.x))), (_arg2.prev.y + (_local4 * (_arg2.curr.y - _arg2.prev.y))), (_arg2.prev.z + (_local4 * (_arg2.curr.z - _arg2.prev.z))));
if (testTypes(_arg1, _arg2)){
return;
};
_local4 = (_local4 + _local3);
_local5++;
};
}
}
}//package org.hardpcm.hardapex
Section 35
//CollisionResolver (org.hardpcm.hardapex.CollisionResolver)
package org.hardpcm.hardapex {
import org.hardpcm.hardapex.*;
final class CollisionResolver {
static function resolveParticleParticle(_arg1:AbstractParticle, _arg2:AbstractParticle, _arg3:hVector, _arg4:Number):void{
var _local5:hVector;
var _local6:Number;
var _local7:Number;
var _local8:Collision;
var _local9:Collision;
var _local10:Number;
var _local11:hVector;
var _local12:hVector;
var _local13:hVector;
var _local14:hVector;
if (((_arg1.onCollide(_arg2, _arg3, _arg4)) && (_arg2.onCollide(_arg1, _arg3.getInverted(), _arg4)))){
_arg1.curr.setCopy(_arg1.samp);
_arg2.curr.setCopy(_arg2.samp);
_local5 = _arg3.getScalarScale(_arg4);
_local6 = (_arg1.elasticity + _arg2.elasticity);
_local7 = (1 - (_arg1.friction + _arg2.friction));
if (_local7 > 1){
_local7 = 1;
} else {
if (_local7 < 0){
_local7 = 0;
};
};
_local8 = _arg1.getComponents(_arg3);
_local9 = _arg2.getComponents(_arg3);
_local10 = (_arg1.invMass + _arg2.invMass);
_local11 = _local9.vn.getScalarScale(((_local6 + 1) * _arg1.invMass)).getVectorAdd(_local8.vn.getScalarScale((_arg2.invMass - (_local6 * _arg1.invMass)))).divEquals(_local10);
_local12 = _local8.vn.getScalarScale(((_local6 + 1) * _arg2.invMass)).getVectorAdd(_local9.vn.getScalarScale((_arg1.invMass - (_local6 * _arg2.invMass)))).divEquals(_local10);
_local8.vt.scalarScale(_local7);
_local9.vt.scalarScale(_local7);
_local13 = _local5.getScalarScale((_arg1.invMass / _local10));
_local14 = _local5.getScalarScale((-(_arg2.invMass) / _local10));
_local11.vectorAdd(_local8.vt);
_local12.vectorAdd(_local9.vt);
if (_arg2.nTagID == 666){
};
if (!_arg1.fixed){
_arg1.resolveCollision(_local13, _local11, _arg3, _arg4, -1, _arg2);
};
if (!_arg2.fixed){
_arg2.resolveCollision(_local14, _local12, _arg3, _arg4, 1, _arg1);
};
};
}
static function clamp(_arg1:Number, _arg2:Number, _arg3:Number):Number{
if (_arg1 > _arg3){
return (_arg3);
};
if (_arg1 < _arg2){
return (_arg2);
};
return (_arg1);
}
}
}//package org.hardpcm.hardapex
Section 36
//Composite (org.hardpcm.hardapex.Composite)
package org.hardpcm.hardapex {
public class Composite extends AbstractCollection {
public function set fixed(_arg1:Boolean):void{
var _local2:int;
while (_local2 < particles.length) {
particles[_local2].fixed = _arg1;
_local2++;
};
}
public function rotateByAngle(_arg1:Number, _arg2:hVector):void{
var _local3:Number = (_arg1 * MathUtil.PI_OVER_ONE_EIGHTY);
rotateByRadian(_local3, _arg2);
}
public function get fixed():Boolean{
var _local1:int;
while (_local1 < particles.length) {
if (!particles[_local1].fixed){
return (false);
};
_local1++;
};
return (true);
}
}
}//package org.hardpcm.hardapex
Section 37
//CylinderParticle (org.hardpcm.hardapex.CylinderParticle)
package org.hardpcm.hardapex {
public class CylinderParticle extends BoxParticle {
private var _depth:Number;
private var _radius:Number;
public function CylinderParticle(_arg1:hVector, _arg2:Number, _arg3:Number, _arg4:Number=0, _arg5:Number=0, _arg6:Number=0, _arg7:Boolean=false, _arg8:Number=1, _arg9:Number=0.3, _arg10:Number=0){
_radius = _arg2;
_depth = (_arg3 / 2);
super(_arg1, (_arg2 * 2), _arg3, (_arg2 * 2), _arg4, _arg5, _arg6, _arg7, _arg8, _arg9, _arg10);
this.collisionRadiusSquare = (((APEngine.nSquareDistanceOffset + (_radius * _radius)) + (_radius * _radius)) + (_depth * _depth));
_extents.push(_arg2);
_axes.push(new hVector(Math.cos(((45 * Math.PI) / 180)), 0, Math.sin(((45 * Math.PI) / 180))));
_refaxis.push(new hVector(Math.cos(((45 * Math.PI) / 180)), 0, Math.sin(((45 * Math.PI) / 180))));
_extents.push(_arg2);
_axes.push(new hVector(Math.cos(((22.5 * Math.PI) / 180)), 0, Math.sin(((22.5 * Math.PI) / 180))));
_refaxis.push(new hVector(Math.cos(((22.5 * Math.PI) / 180)), 0, Math.sin(((22.5 * Math.PI) / 180))));
_extents.push(_arg2);
_axes.push(new hVector(Math.cos(((67.5 * Math.PI) / 180)), 0, Math.sin(((67.5 * Math.PI) / 180))));
_refaxis.push(new hVector(Math.cos(((67.5 * Math.PI) / 180)), 0, Math.sin(((67.5 * Math.PI) / 180))));
setRadian(_arg4, _arg5, _arg6);
}
override public function get depth():Number{
return ((_depth * 2));
}
override public function getProjection(_arg1:hVector):Interval{
var _local2:Number = axes[1].getDotProduct(_arg1);
var _local3:Number = (_local2 * _depth);
var _local4:Number = samp.getDotProduct(_arg1);
var _local5:Number = (_local4 + _local3);
_local4 = (_local4 - _local3);
if (_local5 < _local4){
_local3 = _local5;
_local5 = _local4;
_local4 = _local3;
};
var _local6:Number = (Math.sqrt((1 - Math.min(1, (_local2 * _local2)))) * _radius);
interval.min = (_local4 - _local6);
interval.max = (_local5 + _local6);
return (interval);
}
override public function set depth(_arg1:Number):void{
_depth = (_arg1 / 2);
this.collisionRadiusSquare = (((APEngine.nSquareDistanceOffset + (_radius * _radius)) + (_radius * _radius)) + (_depth * _depth));
}
public function set radius(_arg1:Number):void{
_radius = _arg1;
this.collisionRadiusSquare = (((APEngine.nSquareDistanceOffset + (_radius * _radius)) + (_radius * _radius)) + (_depth * _depth));
}
override public function init():void{
cleanup();
}
public function get radius():Number{
return (_radius);
}
override public function getTheIntervalX():Interval{
if (!this.fixed){
intervalX = this.getProjection(new hVector(1, 0, 0));
};
return (intervalX);
}
override public function getTheIntervalY():Interval{
if (!this.fixed){
intervalY = this.getProjection(new hVector(0, 1, 0));
};
return (intervalY);
}
override public function getTheIntervalZ():Interval{
if (!this.fixed){
intervalZ = this.getProjection(new hVector(0, 0, 1));
};
return (intervalZ);
}
}
}//package org.hardpcm.hardapex
Section 38
//Group (org.hardpcm.hardapex.Group)
package org.hardpcm.hardapex {
public class Group extends AbstractCollection {
private var _collideInternal:Boolean;
private var _composites:Array;
private var _collisionList:Array;
public function Group(_arg1:Boolean=false){
_composites = new Array();
_collisionList = new Array();
this.collideInternal = _arg1;
}
function checkCollisions():void{
var _local3:Group;
if (collideInternal){
checkCollisionGroupInternal();
};
var _local1:int = collisionList.length;
var _local2:int;
while (_local2 < _local1) {
_local3 = collisionList[_local2];
checkCollisionVsGroup(_local3);
_local2++;
};
}
public function removeCollidable(_arg1:Group):void{
var _local2:int = collisionList.indexOf(_arg1);
if (_local2 == -1){
return;
};
collisionList.splice(_local2, 1);
}
override public function addForce(_arg1:hVector):void{
var _local2:int;
super.addForce(_arg1);
var _local3:int = _composites.length;
_local2 = 0;
while (_local2 < _local3) {
_composites[_local2].addForce(_arg1);
_local2++;
};
}
public function get composites():Array{
return (_composites);
}
override public function init():void{
super.init();
var _local1:int;
while (_local1 < composites.length) {
composites[_local1].init();
_local1++;
};
}
override public function rotateByRadian(_arg1:Number, _arg2:hVector=null):void{
var _local3:int;
super.rotateByRadian(_arg1, _arg2);
var _local4:int = _composites.length;
_local3 = 0;
while (_local3 < _local4) {
_composites[_local3].rotateByRadian(_arg1, _arg2);
_local3++;
};
}
private function checkCollisionVsGroup(_arg1:Group):void{
var _local5:Composite;
var _local6:int;
checkCollisionsVsCollection(_arg1);
var _local2:int = _composites.length;
var _local3:int = _arg1.composites.length;
var _local4:int;
while (_local4 < _local2) {
_local5 = _composites[_local4];
_local5.checkCollisionsVsCollection(_arg1);
_local6 = 0;
while (_local6 < _local3) {
_local5.checkCollisionsVsCollection(_arg1.composites[_local6]);
_local6++;
};
_local4++;
};
_local6 = 0;
while (_local6 < _local3) {
checkCollisionsVsCollection(_arg1.composites[_local6]);
_local6++;
};
}
override function satisfyConstraints():void{
var _local3:Composite;
super.satisfyConstraints();
var _local1:int = _composites.length;
var _local2:int;
while (_local2 < _local1) {
_local3 = _composites[_local2];
_local3.satisfyConstraints();
_local2++;
};
}
public function get collideInternal():Boolean{
return (_collideInternal);
}
override public function addVelocity(_arg1:hVector):void{
var _local2:int;
super.addVelocity(_arg1);
var _local3:int = _composites.length;
_local2 = 0;
while (_local2 < _local3) {
_composites[_local2].addVelocity(_arg1);
_local2++;
};
}
override public function setVelocity(_arg1:hVector):void{
var _local2:int;
super.setVelocity(_arg1);
var _local3:int = _composites.length;
_local2 = 0;
while (_local2 < _local3) {
_composites[_local2].setVelocity(_arg1);
_local2++;
};
}
public function addCollidableList(_arg1:Array):void{
var _local3:Group;
var _local2:int;
while (_local2 < _arg1.length) {
_local3 = _arg1[_local2];
collisionList.push(_local3);
_local2++;
};
}
public function removeComposite(_arg1:Composite):void{
var _local2:int = composites.indexOf(_arg1);
if (_local2 == -1){
return;
};
composites.splice(_local2, 1);
_arg1.isParented = false;
_arg1.cleanup();
}
override public function cleanup():void{
super.cleanup();
var _local1:int;
while (_local1 < composites.length) {
composites[_local1].cleanup();
_local1++;
};
}
public function addComposite(_arg1:Composite):void{
composites.push(_arg1);
_arg1.isParented = true;
if (isParented){
_arg1.init();
};
}
public function addCollidable(_arg1:Group):void{
collisionList.push(_arg1);
}
public function get collisionList():Array{
return (_collisionList);
}
override public function getAll():Array{
return (particles.concat(constraints).concat(composites));
}
public function set collideInternal(_arg1:Boolean):void{
_collideInternal = _arg1;
}
override function integrate(_arg1:Number):void{
var _local4:Composite;
super.integrate(_arg1);
var _local2:int = _composites.length;
var _local3:int;
while (_local3 < _local2) {
_local4 = _composites[_local3];
_local4.integrate(_arg1);
_local3++;
};
}
private function checkCollisionGroupInternal():void{
var _local3:Composite;
var _local4:int;
var _local5:Composite;
checkInternalCollisions();
var _local1:int = _composites.length;
var _local2:int;
while (_local2 < _local1) {
_local3 = _composites[_local2];
_local3.checkCollisionsVsCollection(this);
_local4 = (_local2 + 1);
while (_local4 < _local1) {
_local5 = _composites[_local4];
_local3.checkCollisionsVsCollection(_local5);
_local4++;
};
_local2++;
};
}
override public function setTagID(_arg1:int):void{
var _local2:int;
super.setTagID(_arg1);
var _local3:int = _composites.length;
_local2 = 0;
while (_local2 < _local3) {
_composites[_local2].setTagID(_arg1);
_local2++;
};
}
}
}//package org.hardpcm.hardapex
Section 39
//hMatrix4x3 (org.hardpcm.hardapex.hMatrix4x3)
package org.hardpcm.hardapex {
public class hMatrix4x3 {
public var nM12:Number;
public var nM13:Number;
public var nM33:Number;
public var nM32:Number;
public var nM41:Number;
public var nM42:Number;
public var nM43:Number;
public var nM22:Number;
public var nM23:Number;
public var nM21:Number;
public var nM31:Number;
public var nM11:Number;
public function hMatrix4x3(){
nM11 = 0;
nM12 = 0;
nM13 = 0;
nM21 = 0;
nM22 = 0;
nM23 = 0;
nM31 = 0;
nM32 = 0;
nM33 = 0;
nM41 = 0;
nM42 = 0;
nM43 = 0;
}
public function GetCloned(_arg1:hMatrix4x3):hMatrix4x3{
return (new hMatrix4x3().SetCopy(this));
}
public function SetvectorScale(_arg1:hVector):hMatrix4x3{
nM11 = _arg1.x;
nM12 = 0;
nM13 = 0;
nM21 = 0;
nM22 = _arg1.y;
nM23 = 0;
nM31 = 0;
nM32 = 0;
nM33 = _arg1.z;
nM41 = 0;
nM42 = 0;
nM43 = 0;
return (this);
}
public function GetDeterminant():Number{
return ((((nM11 * ((nM22 * nM33) - (nM23 * nM32))) + (nM12 * ((nM23 * nM31) - (nM21 * nM33)))) + (nM13 * ((nM21 * nM32) - (nM22 * nM31)))));
}
public function Inverse():hMatrix4x3{
return (this.SetCopy(this.GetInverse()));
}
public function GetConcatenation(_arg1:hMatrix4x3):hMatrix4x3{
var _local2:hMatrix4x3 = new hMatrix4x3();
_local2.nM11 = (((nM11 * _arg1.nM11) + (nM12 * _arg1.nM21)) + (nM13 * _arg1.nM31));
_local2.nM12 = (((nM11 * _arg1.nM12) + (nM12 * _arg1.nM22)) + (nM13 * _arg1.nM32));
_local2.nM13 = (((nM11 * _arg1.nM13) + (nM12 * _arg1.nM23)) + (nM13 * _arg1.nM33));
_local2.nM21 = (((nM21 * _arg1.nM11) + (nM22 * _arg1.nM21)) + (nM23 * _arg1.nM31));
_local2.nM22 = (((nM21 * _arg1.nM12) + (nM22 * _arg1.nM22)) + (nM23 * _arg1.nM32));
_local2.nM23 = (((nM21 * _arg1.nM13) + (nM22 * _arg1.nM23)) + (nM23 * _arg1.nM33));
_local2.nM31 = (((nM31 * _arg1.nM11) + (nM32 * _arg1.nM21)) + (nM33 * _arg1.nM31));
_local2.nM32 = (((nM31 * _arg1.nM12) + (nM32 * _arg1.nM22)) + (nM33 * _arg1.nM32));
_local2.nM33 = (((nM31 * _arg1.nM13) + (nM32 * _arg1.nM23)) + (nM33 * _arg1.nM33));
_local2.nM41 = ((((nM41 * _arg1.nM11) + (nM42 * _arg1.nM21)) + (nM43 * _arg1.nM31)) + _arg1.nM41);
_local2.nM42 = ((((nM41 * _arg1.nM12) + (nM42 * _arg1.nM22)) + (nM43 * _arg1.nM32)) + _arg1.nM42);
_local2.nM43 = ((((nM41 * _arg1.nM13) + (nM42 * _arg1.nM23)) + (nM43 * _arg1.nM33)) + _arg1.nM43);
return (_local2);
}
public function SetRotationZ(_arg1:Number):hMatrix4x3{
var _local2:Number = Math.cos(_arg1);
var _local3:Number = Math.sin(_arg1);
nM11 = _local3;
nM12 = -(_local2);
nM13 = 0;
nM21 = _local2;
nM22 = _local3;
nM23 = 0;
nM31 = 0;
nM32 = 0;
nM33 = 1;
return (this);
}
public function RotateAxis(_arg1:hVector):hVector{
return (new hVector((((_arg1.x * nM11) + (_arg1.y * nM12)) + (_arg1.z * nM13)), (((_arg1.x * nM21) + (_arg1.y * nM22)) + (_arg1.z * nM23)), (((_arg1.x * nM31) + (_arg1.y * nM32)) + (_arg1.z * nM33))));
}
public function SetCopy(_arg1:hMatrix4x3):hMatrix4x3{
nM11 = _arg1.nM11;
nM12 = _arg1.nM12;
nM13 = _arg1.nM13;
nM21 = _arg1.nM21;
nM22 = _arg1.nM22;
nM23 = _arg1.nM23;
nM31 = _arg1.nM31;
nM32 = _arg1.nM32;
nM33 = _arg1.nM33;
nM41 = _arg1.nM41;
nM42 = _arg1.nM42;
nM43 = _arg1.nM43;
return (this);
}
public function GetInverse():hMatrix4x3{
var _local1:Number = this.GetDeterminant();
if (Math.abs(_local1) < 1E-6){
return (new hMatrix4x3().SetIdentity());
};
var _local2:Number = (1 / _local1);
var _local3:hMatrix4x3 = new hMatrix4x3();
_local3.nM11 = (((nM22 * nM33) - (nM23 * nM32)) * _local2);
_local3.nM12 = (((nM13 * nM32) - (nM12 * nM33)) * _local2);
_local3.nM13 = (((nM12 * nM23) - (nM13 * nM22)) * _local2);
_local3.nM21 = (((nM23 * nM31) - (nM21 * nM33)) * _local2);
_local3.nM22 = (((nM11 * nM33) - (nM13 * nM31)) * _local2);
_local3.nM23 = (((nM13 * nM21) - (nM11 * nM23)) * _local2);
_local3.nM31 = (((nM21 * nM32) - (nM22 * nM31)) * _local2);
_local3.nM32 = (((nM12 * nM31) - (nM11 * nM32)) * _local2);
_local3.nM33 = (((nM11 * nM22) - (nM12 * nM21)) * _local2);
_local3.nM41 = -((((nM41 * nM11) + (nM42 * nM21)) + (nM43 * nM31)));
_local3.nM42 = -((((nM41 * nM12) + (nM42 * nM22)) + (nM43 * nM32)));
_local3.nM43 = -((((nM41 * nM13) + (nM42 * nM23)) + (nM43 * nM33)));
return (_local3);
}
public function GetTranslation():hVector{
return (new hVector(nM41, nM42, nM43));
}
public function Concatenation(_arg1:hMatrix4x3):hMatrix4x3{
return (this.SetCopy(this.GetConcatenation(_arg1)));
}
public function SetScalarScale(_arg1:Number):hMatrix4x3{
nM11 = _arg1;
nM12 = 0;
nM13 = 0;
nM21 = 0;
nM22 = _arg1;
nM23 = 0;
nM31 = 0;
nM32 = 0;
nM33 = _arg1;
nM41 = 0;
nM42 = 0;
nM43 = 0;
return (this);
}
public function TransformPoint(_arg1:hVector):hVector{
return (new hVector(((((_arg1.x * nM11) + (_arg1.y * nM21)) + (_arg1.z * nM31)) + nM41), ((((_arg1.x * nM12) + (_arg1.y * nM22)) + (_arg1.z * nM32)) + nM42), ((((_arg1.x * nM13) + (_arg1.y * nM23)) + (_arg1.z * nM33)) + nM43)));
}
public function SetIdentity():hMatrix4x3{
nM11 = 1;
nM12 = 0;
nM13 = 0;
nM21 = 0;
nM22 = 1;
nM23 = 0;
nM31 = 0;
nM32 = 0;
nM33 = 1;
nM41 = 0;
nM42 = 0;
nM43 = 0;
return (this);
}
public function SetZeroTranslation():hMatrix4x3{
nM41 = 0;
nM42 = 0;
nM43 = 0;
return (this);
}
public function SetRotationX(_arg1:Number):hMatrix4x3{
var _local2:Number = Math.cos(_arg1);
var _local3:Number = Math.sin(_arg1);
nM11 = 1;
nM12 = 0;
nM13 = 0;
nM21 = 0;
nM22 = _local3;
nM23 = -(_local2);
nM31 = 0;
nM32 = _local2;
nM33 = _local3;
return (this);
}
public function Trace():hMatrix4x3{
trace((((((("m = | " + nM11.toString()) + " , ") + nM12.toString()) + " , ") + nM13.toString()) + " |"));
trace(((((((" | " + nM21.toString()) + " , ") + nM22.toString()) + " , ") + nM23.toString()) + " |"));
trace(((((((" | " + nM31.toString()) + " , ") + nM32.toString()) + " , ") + nM33.toString()) + " |"));
trace(((((((" | " + nM41.toString()) + " , ") + nM42.toString()) + " , ") + nM43.toString()) + " |"));
return (this);
}
public function SetRotationEuler(_arg1:Number, _arg2:Number, _arg3:Number):hMatrix4x3{
var _local4:Number = Math.cos(_arg1);
var _local5:Number = Math.sin(_arg1);
var _local6:Number = Math.cos(_arg2);
var _local7:Number = Math.sin(_arg2);
var _local8:Number = Math.cos(_arg3);
var _local9:Number = Math.sin(_arg3);
var _local10:Number = (_local4 * _local7);
var _local11:Number = (_local5 * _local7);
nM11 = (_local6 * _local8);
nM12 = (-(_local6) * _local9);
nM13 = _local7;
nM21 = ((_local11 * _local8) + (_local4 * _local9));
nM22 = ((-(_local11) * _local9) + (_local4 * _local8));
nM23 = (-(_local5) * _local6);
nM31 = ((-(_local10) * _local8) + (_local5 * _local9));
nM32 = ((_local10 * _local9) + (_local5 * _local8));
nM33 = (_local4 * _local6);
return (this);
}
public function SetTranslation(_arg1:hVector):hMatrix4x3{
nM41 = _arg1.x;
nM42 = _arg1.y;
nM43 = _arg1.z;
return (this);
}
public function SetRotationY(_arg1:Number):hMatrix4x3{
var _local2:Number = Math.cos(_arg1);
var _local3:Number = Math.sin(_arg1);
nM11 = _local3;
nM12 = 0;
nM13 = _local2;
nM21 = 0;
nM22 = 1;
nM23 = 0;
nM31 = -(_local2);
nM32 = 0;
nM33 = _local3;
return (this);
}
public static function getVectorScale(_arg1:hVector):hMatrix4x3{
return (new (hMatrix4x3).SetvectorScale(_arg1));
}
public static function GetRotationMatrixX(_arg1:Number):hMatrix4x3{
return (new (hMatrix4x3).SetRotationX(_arg1));
}
public static function GetIdentity():hMatrix4x3{
return (new (hMatrix4x3).SetIdentity());
}
public static function GetRotationEuler(_arg1:Number, _arg2:Number, _arg3:Number):hMatrix4x3{
return (new (hMatrix4x3).SetRotationEuler(_arg1, _arg2, _arg3));
}
public static function GetScalarScale(_arg1:Number):hMatrix4x3{
return (new (hMatrix4x3).SetScalarScale(_arg1));
}
public static function GetRotationMatrixY(_arg1:Number):hMatrix4x3{
return (new (hMatrix4x3).SetRotationY(_arg1));
}
public static function GetTranslationMatrix(_arg1:hVector):hMatrix4x3{
return (new (hMatrix4x3).SetIdentity().SetTranslation(_arg1));
}
public static function GetRotationMatrixZ(_arg1:Number):hMatrix4x3{
return (new (hMatrix4x3).SetRotationZ(_arg1));
}
}
}//package org.hardpcm.hardapex
Section 40
//hVector (org.hardpcm.hardapex.hVector)
package org.hardpcm.hardapex {
import flash.geom.*;
public class hVector {
public var x:Number;
public var y:Number;
public var z:Number;
public function hVector(_arg1:Number=0, _arg2:Number=0, _arg3:Number=0){
x = _arg1;
y = _arg2;
z = _arg3;
}
public function plusEquals(_arg1:hVector):hVector{
x = (x + _arg1.x);
y = (y + _arg1.y);
z = (z + _arg1.z);
return (this);
}
public function getAngleEulerYaw():Number{
return (((getRadianEulerYaw() * 180) / Math.PI));
}
public function vectorSub(_arg1:hVector):hVector{
this.x = (this.x - _arg1.x);
this.y = (this.y - _arg1.y);
this.z = (this.z - _arg1.z);
return (this);
}
public function getCrossProduct(_arg1:hVector):hVector{
return (new hVector(((this.y * _arg1.z) - (this.z * _arg1.y)), ((this.z * _arg1.x) - (this.x * _arg1.z)), ((this.x * _arg1.y) - (this.y * _arg1.x))));
}
protected function clampNumber(_arg1:Number, _arg2:Number):Number{
if ((_arg1 * _arg1) > (_arg2 * _arg2)){
if (_arg1 < 0){
return ((-1 * _arg2));
};
return ((1 * _arg2));
};
return (_arg1);
}
public function getScalarScale(_arg1:Number):hVector{
return (new hVector((this.x * _arg1), (this.y * _arg1), (this.z * _arg1)));
}
public function getAngleDegreeXY():Number{
return ((getAngleRadianXY() * 57.2957795130823));
}
public function getAngleDegreeXZ():Number{
return ((getAngleRadianXZ() * 57.2957795130823));
}
public function setTo(_arg1:Number=0, _arg2:Number=0, _arg3:Number=0):hVector{
x = _arg1;
y = _arg2;
z = _arg3;
return (this);
}
public function normalize():hVector{
var _local1:Number = magnitude();
if (_local1 == 0){
_local1 = 0.0001;
};
return (mult((1 / _local1)));
}
public function multEquals(_arg1:Number):hVector{
x = (x * _arg1);
y = (y * _arg1);
z = (z * _arg1);
return (this);
}
public function magnitude():Number{
return (Math.sqrt((((x * x) + (y * y)) + (z * z))));
}
public function getVectorScale(_arg1:hVector):hVector{
return (new hVector((this.x * _arg1.x), (this.y * _arg1.y), (this.z * _arg1.z)));
}
public function getRotateXY(_arg1:Number, _arg2:hVector):hVector{
_arg2 = null;
return (this.getCloned().rotateXY(_arg1, _arg2));
}
public function testFacing(_arg1:hVector):Boolean{
return ((this.getDotProduct(_arg1) > 0));
}
public function Normalise():hVector{
var _local1:Number = this.getSized();
if (_local1 == 0){
_local1 = 1;
};
this.scalarScale((1 / _local1));
return (this);
}
public function getSmallest(_arg1:hVector):hVector{
return (this.Smallest(_arg1).getCloned());
}
public function getMaskScale(_arg1:Number=0, _arg2:Number=0, _arg3:Number=0):hVector{
return (new hVector((this.x * _arg1), (this.y * _arg2), (this.z * _arg3)));
}
public function getAngleRadianYoverXZ():Number{
var _local1:Number = 0;
var _local2:Number = Math.sqrt(((this.x * this.x) + (this.z * this.z)));
if (_local2 == 0){
if (this.y == 0){
_local1 = NaN;
} else {
if (this.y > 0){
_local1 = (Math.PI / 2);
} else {
if (this.y < 0){
_local1 = ((3 * Math.PI) / 2);
};
};
};
} else {
if (_local2 > 0){
if (this.y == 0){
_local1 = 0;
} else {
_local1 = Math.atan((this.y / _local2));
};
} else {
if (_local2 < 0){
if (this.y == 0){
_local1 = Math.PI;
} else {
_local1 = (Math.PI + Math.atan((this.y / _local2)));
};
};
};
};
while (_local1 < 0) {
_local1 = (_local1 + (2 * Math.PI));
};
while (_local1 >= (2 * Math.PI)) {
_local1 = (_local1 - (2 * Math.PI));
};
return (_local1);
}
public function plus(_arg1:hVector):hVector{
return (new hVector((x + _arg1.x), (y + _arg1.y), (z + _arg1.z)));
}
public function getInterpolated(_arg1:hVector, _arg2:Number):hVector{
return (this.getCloned().Interpolate(_arg1, _arg2));
}
public function rotateXY(_arg1:Number, _arg2:hVector=null):hVector{
var _local3:* = Math.cos(_arg1);
var _local4:* = Math.sin(_arg1);
if (_arg2 != null){
this.x = (this.x - _arg2.x);
this.y = (this.y - _arg2.y);
};
var _local5:Number = this.x;
var _local6:Number = this.y;
this.x = ((_local5 * _local3) - (_local6 * _local4));
this.y = ((_local5 * _local4) + (_local6 * _local3));
if (_arg2 != null){
this.x = (this.x + _arg2.x);
this.y = (this.y + _arg2.y);
};
return (this);
}
public function getCloned():hVector{
return (new hVector(this.x, this.y, this.z));
}
public function getAngleDegreeYoverXZ():Number{
return ((getAngleRadianYoverXZ() * 57.2957795130823));
}
public function Biggest(_arg1:hVector):hVector{
if (this.getSquareSized() > _arg1.getSquareSized()){
return (this);
};
return (_arg1);
}
public function getAngleRadianXZ():Number{
var _local1:Number = 0;
if (this.x == 0){
if (this.z == 0){
_local1 = NaN;
} else {
if (this.z > 0){
_local1 = (Math.PI / 2);
} else {
if (this.z < 0){
_local1 = ((3 * Math.PI) / 2);
};
};
};
} else {
if (this.x > 0){
if (this.z == 0){
_local1 = 0;
} else {
_local1 = Math.atan((this.z / this.x));
};
} else {
if (this.x < 0){
if (this.z == 0){
_local1 = Math.PI;
} else {
_local1 = (Math.PI + Math.atan((this.z / this.x)));
};
};
};
};
while (_local1 < 0) {
_local1 = (_local1 + (2 * Math.PI));
};
while (_local1 >= (2 * Math.PI)) {
_local1 = (_local1 - (2 * Math.PI));
};
return (_local1);
}
public function getEulerAngleRadian():hVector{
var _local1:hVector = this.getNormalised();
var _local2:hVector = new hVector(0, 0, 0);
_local2.x = Math.atan2(_local1.y, Math.sqrt(((_local1.x * _local1.x) + (_local1.z * _local1.z))));
_local2.y = Math.atan2(_local1.z, _local1.x);
_local2.z = 0;
return (_local2);
}
public function getAxeClamped(_arg1:hVector):hVector{
return (this.getCloned().axeClamped(_arg1));
}
public function getClosest(_arg1:hVector, _arg2:hVector):hVector{
return (this.Closest(_arg1, _arg2).getCloned());
}
public function rotateXZ(_arg1:Number, _arg2:hVector=null):hVector{
var _local3:* = Math.cos(_arg1);
var _local4:* = Math.sin(_arg1);
if (_arg2 != null){
this.x = (this.x - _arg2.x);
this.z = (this.z - _arg2.z);
};
var _local5:Number = this.x;
var _local6:Number = this.z;
this.x = ((_local5 * _local3) - (_local6 * _local4));
this.z = ((_local5 * _local4) + (_local6 * _local3));
if (_arg2 != null){
this.x = (this.x + _arg2.x);
this.z = (this.z + _arg2.z);
};
return (this);
}
public function getRelativeAngleDegreeXY(_arg1:hVector):Number{
return (((getRelativeAngleRadianXY(_arg1) * 180) / Math.PI));
}
public function getNormalised():hVector{
return (this.getCloned().Normalise());
}
public function getVectorAdd(_arg1:hVector):hVector{
return (new hVector((this.x + _arg1.x), (this.y + _arg1.y), (this.z + _arg1.z)));
}
public function clamped(_arg1:Number):hVector{
if (this.getSquareSized() > (_arg1 * _arg1)){
this.Normalise().scalarScale(_arg1);
};
return (this);
}
public function axeClamped(_arg1:hVector):hVector{
this.x = this.clampNumber(this.x, _arg1.x);
this.y = this.clampNumber(this.y, _arg1.y);
this.z = this.clampNumber(this.z, _arg1.z);
return (this);
}
public function getRotatedXZ(_arg1:Number, _arg2:hVector=null):hVector{
return (this.getCloned().rotateXZ(_arg1, _arg2));
}
public function setValue(_arg1:Number, _arg2:Number, _arg3:Number):hVector{
this.x = _arg1;
this.y = _arg2;
this.z = _arg3;
return (this);
}
public function mult(_arg1:Number):hVector{
return (new hVector((x * _arg1), (y * _arg1), (z * _arg1)));
}
public function Trace():hVector{
trace((((((("(" + this.x.toString()) + ",") + this.y.toString()) + ",") + this.z.toString()) + ")"));
return (this);
}
public function divEquals(_arg1:Number):hVector{
if (_arg1 == 0){
_arg1 = 0.0001;
};
x = (x / _arg1);
y = (y / _arg1);
z = (z / _arg1);
return (this);
}
public function getAxeReflextion(_arg1:hVector):hVector{
var _local2:Number = (this.getDotProduct(_arg1) * 2);
return (new hVector((this.x - (_local2 * _arg1.x)), (this.y - (_local2 * _arg1.y)), (this.z - (_local2 * _arg1.z))));
}
public function Closest(_arg1:hVector, _arg2:hVector, _arg3:Array=null):hVector{
if (this.getSquareDistanced(_arg1) < this.getSquareDistanced(_arg2)){
if (_arg3 != null){
_arg3.push(false);
};
return (_arg1);
};
if (_arg3 != null){
_arg3.push(true);
};
return (_arg2);
}
public function getRelativeAngleRadianXY(_arg1:hVector):Number{
var _local2:Number = _arg1.getAngleRadianXY();
var _local3:Number = this.getAngleRadianXY();
if (_local3 <= Math.PI){
if (_local2 >= Math.PI){
if ((_local3 + Math.PI) >= _local2){
return ((_local2 - _local3));
};
return (-((_local3 + ((2 * Math.PI) - _local2))));
} else {
return ((_local2 - _local3));
};
//unresolved jump
};
if (_local2 <= Math.PI){
if ((_local3 - Math.PI) >= _local2){
return ((_local2 + ((2 * Math.PI) - _local3)));
};
return ((_local2 - _local3));
//unresolved jump
};
return ((_local2 - _local3));
}
public function getSquareDistanced(_arg1:hVector):Number{
return (this.getVectorSub(_arg1).getSquareSized());
}
public function scalarScale(_arg1:Number):hVector{
this.x = (this.x * _arg1);
this.y = (this.y * _arg1);
this.z = (this.z * _arg1);
return (this);
}
public function Smallest(_arg1:hVector):hVector{
if (this.getSquareSized() < _arg1.getSquareSized()){
return (this);
};
return (_arg1);
}
public function cross(_arg1:hVector):Number{
return (((x * _arg1.y) - (y * _arg1.x)));
}
public function getAngleRadianXY():Number{
var _local1:Number = 0;
if (this.x == 0){
if (this.y == 0){
_local1 = NaN;
} else {
if (this.y > 0){
_local1 = (Math.PI / 2);
} else {
if (this.y < 0){
_local1 = ((3 * Math.PI) / 2);
};
};
};
} else {
if (this.x > 0){
if (this.y == 0){
_local1 = 0;
} else {
_local1 = Math.atan((this.y / this.x));
};
} else {
if (this.x < 0){
if (this.y == 0){
_local1 = Math.PI;
} else {
_local1 = (Math.PI + Math.atan((this.y / this.x)));
};
};
};
};
while (_local1 < 0) {
_local1 = (_local1 + (2 * Math.PI));
};
while (_local1 >= (2 * Math.PI)) {
_local1 = (_local1 - (2 * Math.PI));
};
return (_local1);
}
public function maskScale(_arg1:Number=0, _arg2:Number=0, _arg3:Number=0):hVector{
this.x = (this.x * _arg1);
this.y = (this.y * _arg2);
this.z = (this.z * _arg3);
return (this);
}
public function times(_arg1:hVector):hVector{
return (new hVector((x * _arg1.x), (y * _arg1.y), (z * _arg1.z)));
}
public function vectorScale(_arg1:hVector):hVector{
this.x = (this.x * _arg1.x);
this.y = (this.y * _arg1.y);
this.z = (this.z * _arg1.z);
return (this);
}
public function getSquareSized():Number{
return ((((this.x * this.x) + (this.y * this.y)) + (this.z * this.z)));
}
public function dot(_arg1:hVector):Number{
return ((((x * _arg1.x) + (y * _arg1.y)) + (z * _arg1.z)));
}
public function getEulerAngleDegree():hVector{
return (this.getEulerAngleRadian().scalarScale(57.2957795130823));
}
public function getFixedFloat(_arg1:int):hVector{
return (this.getCloned().fixFloat(_arg1));
}
public function getRadianEulerPitch():Number{
return (Math.atan2(this.z, Math.sqrt(((this.x * this.x) + (this.y * this.y)))));
}
public function minusEquals(_arg1:hVector):hVector{
x = (x - _arg1.x);
y = (y - _arg1.y);
z = (z - _arg1.z);
return (this);
}
public function getRotateZY(_arg1:Number, _arg2:hVector=null):hVector{
return (this.getCloned().rotateZY(_arg1, _arg2));
}
public function getAngleEulerPitch():Number{
return (((getRadianEulerPitch() * 180) / Math.PI));
}
public function getVectorSub(_arg1:hVector):hVector{
return (new hVector((this.x - _arg1.x), (this.y - _arg1.y), (this.z - _arg1.z)));
}
public function getDistanced(_arg1:hVector):Number{
return (this.getVectorSub(_arg1).getSized());
}
public function rotateZY(_arg1:Number, _arg2:hVector=null):hVector{
var _local3:* = Math.cos(_arg1);
var _local4:* = Math.sin(_arg1);
if (_arg2 != null){
this.z = (this.z - _arg2.z);
this.y = (this.y - _arg2.y);
};
var _local5:Number = this.z;
var _local6:Number = this.y;
this.z = ((_local5 * _local3) - (_local6 * _local4));
this.y = ((_local5 * _local4) + (_local6 * _local3));
if (_arg2 != null){
this.z = (this.z + _arg2.z);
this.y = (this.y + _arg2.y);
};
return (this);
}
public function getDotProduct(_arg1:hVector):Number{
return ((((this.x * _arg1.x) + (this.y * _arg1.y)) + (this.z * _arg1.z)));
}
public function vectorAdd(_arg1:hVector):hVector{
this.x = (this.x + _arg1.x);
this.y = (this.y + _arg1.y);
this.z = (this.z + _arg1.z);
return (this);
}
public function fixFloat(_arg1:int):hVector{
this.x = (Math.floor((this.x * _arg1)) / _arg1);
this.y = (Math.floor((this.y * _arg1)) / _arg1);
this.z = (Math.floor((this.z * _arg1)) / _arg1);
return (this);
}
public function Interpolate(_arg1:hVector, _arg2:Number):hVector{
var _local3:Number = (1 - _arg2);
this.x = ((_arg1.x * _arg2) + (this.x * _local3));
this.y = ((_arg1.y * _arg2) + (this.y * _local3));
this.z = ((_arg1.z * _arg2) + (this.z * _local3));
return (this);
}
public function getClamped(_arg1:Number):hVector{
return (this.getCloned().clamped(_arg1));
}
public function getSized():Number{
return (Math.sqrt(this.getSquareSized()));
}
public function getInverted():hVector{
return (this.getCloned().Invert());
}
public function toString():String{
return (((((x + " : ") + y) + " : ") + z));
}
public function setEulerRollPitchYaw(_arg1:Number, _arg2:Number, _arg3:Number):hVector{
this.x = (Math.sin(_arg3) * Math.cos(_arg2));
this.y = Math.sin(-(_arg2));
this.z = (Math.cos(_arg3) * Math.cos(_arg2));
return (this);
}
public function copy(_arg1:hVector):hVector{
x = _arg1.x;
y = _arg1.y;
z = _arg1.z;
return (this);
}
public function Invert():hVector{
return (this.scalarScale(-1));
}
public function setCopy(_arg1:hVector):hVector{
this.x = _arg1.x;
this.y = _arg1.y;
this.z = _arg1.z;
return (this);
}
public function SwapXY():hVector{
var _local1:Number = this.x;
this.x = this.y;
this.y = _local1;
return (this);
}
public function distance(_arg1:hVector):Number{
var _local2:hVector = this.getVectorSub(_arg1);
return (_local2.getSized());
}
public function getRadianEulerYaw():Number{
return (Math.atan2(this.x, this.y));
}
public function minus(_arg1:hVector):hVector{
return (new hVector((x - _arg1.x), (y - _arg1.y), (z - _arg1.z)));
}
public static function CenterOfMassFromList(_arg1:Array):hVector{
var _local4:uint;
if (_arg1 == null){
return (null);
};
if (_arg1.length < 1){
return (null);
};
if (_arg1.length == 1){
return (_arg1[0]);
};
if (_arg1[0] == null){
return (null);
};
var _local2:hVector = _arg1[0].getCloned();
var _local3:uint = _arg1.length;
_local4 = 1;
while (_local4 < _local3) {
_local2.vectorAdd(_arg1[_local4]);
_local4++;
};
return (_local2.scalarScale((1 / _local3)));
}
public static function getAngledDegreeXY(_arg1:Number):hVector{
var _local2:Number = ((_arg1 * Math.PI) / 180);
return (new hVector(Math.cos(_local2), Math.sin(_local2)));
}
public static function SmallestFromList(_arg1:Array):hVector{
var _local4:uint;
if (_arg1 == null){
return (null);
};
if (_arg1.length < 1){
return (null);
};
if (_arg1.length == 1){
return (_arg1[0]);
};
var _local2:hVector = _arg1[0];
if (_local2 == null){
return (null);
};
var _local3:uint = _arg1.length;
_local4 = 1;
while (_local4 < _local3) {
_local2 = _local2.Smallest(_arg1[_local4]);
_local4++;
};
return (_local2);
}
public static function BiggestFromList(_arg1:Array):hVector{
var _local4:uint;
if (_arg1 == null){
return (null);
};
if (_arg1.length < 1){
return (null);
};
if (_arg1.length == 1){
return (_arg1[0]);
};
var _local2:hVector = _arg1[0];
if (_local2 == null){
return (null);
};
var _local3:uint = _arg1.length;
_local4 = 1;
while (_local4 < _local3) {
_local2 = _local2.Biggest(_arg1[_local4]);
_local4++;
};
return (_local2);
}
}
}//package org.hardpcm.hardapex
Section 41
//ICollisionHandler (org.hardpcm.hardapex.ICollisionHandler)
package org.hardpcm.hardapex {
public interface ICollisionHandler {
function canBlock(_arg1:AbstractParticle, _arg2:AbstractParticle, _arg3:hVector, _arg4:Number):Boolean;
}
}//package org.hardpcm.hardapex
Section 42
//Interval (org.hardpcm.hardapex.Interval)
package org.hardpcm.hardapex {
final class Interval {
var min:Number;
var max:Number;
function Interval(_arg1:Number, _arg2:Number){
this.min = _arg1;
this.max = _arg2;
}
public function Trace():Interval{
trace(this.toString());
return (this);
}
public function toString():String{
return (((min + " : ") + max));
}
public function getCloned():Interval{
return (new Interval(this.min, this.max));
}
}
}//package org.hardpcm.hardapex
Section 43
//MathUtil (org.hardpcm.hardapex.MathUtil)
package org.hardpcm.hardapex {
public final class MathUtil {
public static var ONE_EIGHTY_OVER_PI:Number = 57.2957795130823;
public static var PI_OVER_ONE_EIGHTY:Number = 0.0174532925199433;
public static function interpolate(_arg1:Number, _arg2:Number, _arg3:Number):Number{
return (((_arg1 * _arg3) + (_arg2 * (1 - _arg3))));
}
public static function sign(_arg1:Number):int{
if (_arg1 < 0){
return (-1);
};
return (1);
}
public static function isBetweenNotInclusive(_arg1:Number, _arg2:Number, _arg3:Number){
return ((((_arg1 > _arg2)) && ((_arg1 < _arg3))));
}
public static function clamp(_arg1:Number, _arg2:Number, _arg3:Number):Number{
if (_arg1 < _arg2){
return (_arg2);
};
if (_arg1 > _arg3){
return (_arg3);
};
return (_arg1);
}
public static function isBetweenInclusive(_arg1:Number, _arg2:Number, _arg3:Number){
return ((((_arg1 >= _arg2)) && ((_arg1 <= _arg3))));
}
}
}//package org.hardpcm.hardapex
Section 44
//SphereParticle (org.hardpcm.hardapex.SphereParticle)
package org.hardpcm.hardapex {
public class SphereParticle extends AbstractParticle {
private var _radius:Number;
public function SphereParticle(_arg1:hVector, _arg2:Number, _arg3:Number=0, _arg4:Number=0, _arg5:Number=0, _arg6:Boolean=false, _arg7:Number=1, _arg8:Number=0.3, _arg9:Number=0){
super(_arg1, _arg6, _arg7, _arg8, _arg9);
_radius = _arg2;
this.collisionRadiusSquare = (APEngine.nSquareDistanceOffset + (_radius * _radius));
setRadian(_arg3, _arg4, _arg5);
if (this.fixed){
intervalX.min = (curr.x - _radius);
intervalX.max = (curr.x + _radius);
intervalY.min = (curr.y - _radius);
intervalY.max = (curr.y + _radius);
intervalZ.min = (curr.z - _radius);
intervalZ.max = (curr.z + _radius);
};
}
public function set radius(_arg1:Number):void{
_radius = _arg1;
this.collisionRadiusSquare = (APEngine.nSquareDistanceOffset + (_radius * _radius));
}
override public function getProjection(_arg1:hVector):Interval{
var _local2:Number = samp.getDotProduct(_arg1);
interval.min = (_local2 - _radius);
interval.max = (_local2 + _radius);
return (interval);
}
override public function init():void{
cleanup();
}
public function get radius():Number{
return (_radius);
}
override public function getTheIntervalX():Interval{
return (this.getIntervalX());
}
override public function getTheIntervalY():Interval{
return (this.getIntervalY());
}
override public function getTheIntervalZ():Interval{
return (this.getIntervalZ());
}
public function getIntervalX():Interval{
if (!this.fixed){
intervalX.min = (curr.x - _radius);
intervalX.max = (curr.x + _radius);
};
return (intervalX);
}
public function getIntervalY():Interval{
if (!this.fixed){
intervalY.min = (curr.y - _radius);
intervalY.max = (curr.y + _radius);
};
return (intervalY);
}
public function getIntervalZ():Interval{
if (!this.fixed){
intervalZ.min = (curr.z - _radius);
intervalZ.max = (curr.z + _radius);
};
return (intervalZ);
}
}
}//package org.hardpcm.hardapex
Section 45
//SpringConstraint (org.hardpcm.hardapex.SpringConstraint)
package org.hardpcm.hardapex {
public class SpringConstraint extends AbstractConstraint {
private var _collidable:Boolean;
private var p1:AbstractParticle;
private var p2:AbstractParticle;
private var _scp:SpringConstraintParticle;
private var _restLength:Number;
public function SpringConstraint(_arg1:AbstractParticle, _arg2:AbstractParticle, _arg3:Number=0.5, _arg4:Boolean=false, _arg5:Number=1, _arg6:Number=1, _arg7:Boolean=false){
super(_arg3);
this.p1 = _arg1;
this.p2 = _arg2;
checkParticlesLocation();
_restLength = currLength;
setCollidable(_arg4, _arg5, _arg6, _arg7);
}
public function get fixed():Boolean{
return (((p1.fixed) && (p2.fixed)));
}
public function get rectScale():Number{
return (scp.rectScale);
}
public function set rectScale(_arg1:Number):void{
if (scp == null){
return;
};
scp.rectScale = _arg1;
}
override public function init():void{
cleanup();
if (collidable){
scp.init();
};
}
private function checkParticlesLocation():void{
if ((((((p1.curr.x == p2.curr.x)) && ((p1.curr.y == p2.curr.y)))) && ((p1.curr.z == p2.curr.z)))){
p2.curr.y = (p2.curr.y + 0.0001);
};
}
public function get center():hVector{
return (p1.curr.getVectorAdd(p2.curr).scalarScale(0.5));
}
public function set rectHeight(_arg1:Number):void{
if (scp == null){
return;
};
scp.rectHeight = _arg1;
}
public function get rotationX():Number{
var _local1:hVector = delta;
return (Math.atan2(_local1.y, _local1.z));
}
public function get rotationY():Number{
var _local1:hVector = delta;
return (Math.atan2(_local1.x, _local1.z));
}
public function get rotationZ():Number{
var _local1:hVector = delta;
return (Math.atan2(_local1.x, _local1.y));
}
function get scp():SpringConstraintParticle{
return (_scp);
}
public function setCollidable(_arg1:Boolean, _arg2:Number, _arg3:Number, _arg4:Boolean=false):void{
_collidable = _arg1;
_scp = null;
if (_collidable){
_scp = new SpringConstraintParticle(p1, p2, this, _arg2, _arg3, _arg4);
};
}
public function get angleX():Number{
return ((rotationX * MathUtil.ONE_EIGHTY_OVER_PI));
}
public function get angleY():Number{
return ((rotationY * MathUtil.ONE_EIGHTY_OVER_PI));
}
public function get angleZ():Number{
return ((rotationZ * MathUtil.ONE_EIGHTY_OVER_PI));
}
public function get collidable():Boolean{
return (_collidable);
}
public function get restLength():Number{
return (_restLength);
}
public function get rectHeight():Number{
return (scp.rectHeight);
}
override function resolve():void{
if (((p1.fixed) && (p2.fixed))){
return;
};
var _local1:Number = currLength;
var _local2:Number = ((_local1 - restLength) / (_local1 * (p1.invMass + p2.invMass)));
var _local3:hVector = delta.getScalarScale((_local2 * stiffness));
p1.curr.vectorSub(_local3.getScalarScale(p1.invMass));
p2.curr.plusEquals(_local3.getScalarScale(p2.invMass));
}
public function set fixedEndLimit(_arg1:Number):void{
if (scp == null){
return;
};
scp.fixedEndLimit = _arg1;
}
public function set restLength(_arg1:Number):void{
if (_arg1 <= 0){
throw (new ArgumentError("restLength must be greater than 0"));
};
_restLength = _arg1;
}
public function get currLength():Number{
return (p1.curr.distance(p2.curr));
}
public function get fixedEndLimit():Number{
return (scp.fixedEndLimit);
}
public function isConnectedTo(_arg1:AbstractParticle):Boolean{
return ((((_arg1 == p1)) || ((_arg1 == p2))));
}
function get delta():hVector{
return (p1.curr.getVectorSub(p2.curr));
}
}
}//package org.hardpcm.hardapex
Section 46
//SpringConstraintParticle (org.hardpcm.hardapex.SpringConstraintParticle)
package org.hardpcm.hardapex {
import org.hardpcm.hardapex.*;
class SpringConstraintParticle extends BoxParticle {
private var p1:AbstractParticle;
private var lambda:hVector;
private var p2:AbstractParticle;
private var _rectHeight:Number;
private var avgVelocity:hVector;
private var rca:hVector;
private var rcb:hVector;
private var _rectScale:Number;
private var parent:SpringConstraint;
private var scaleToLength:Boolean;
private var s:Number;
private var _fixedEndLimit:Number;
function SpringConstraintParticle(_arg1:AbstractParticle, _arg2:AbstractParticle, _arg3:SpringConstraint, _arg4:Number, _arg5:Number, _arg6:Boolean){
super(new hVector(), 0, 0, 0, 0, 0, 0, false);
this.p1 = _arg1;
this.p2 = _arg2;
this.nTagID = Math.max(this.p1.nTagID, this.p2.nTagID);
lambda = new hVector(0, 0);
avgVelocity = new hVector(0, 0);
parent = _arg3;
this.rectScale = _arg5;
this.rectHeight = _arg4;
this.scaleToLength = _arg6;
updatePosition();
this.collisionRadiusSquare = ((APEngine.nSquareDistanceOffset + (this.width * this.width)) + (this.width * this.width));
fixedEndLimit = 0;
rca = new hVector();
rcb = new hVector();
}
override function get invMass():Number{
if (((p1.fixed) && (p2.fixed))){
return (0);
};
return ((1 / ((p1.mass + p2.mass) * 0.5)));
}
function get rectScale():Number{
return (_rectScale);
}
function set rectScale(_arg1:Number):void{
_rectScale = _arg1;
this.collisionRadiusSquare = ((APEngine.nSquareDistanceOffset + (this.width * this.width)) + (this.width * this.width));
}
override public function get friction():Number{
return (((p1.friction + p2.friction) * 0.5));
}
override public function init():void{
}
public function updatePosition():void{
var _local1:hVector = parent.center;
curr.setValue(_local1.x, _local1.y, _local1.z);
width = (scaleToLength) ? (parent.currLength * rectScale) : (parent.restLength * rectScale);
height = rectHeight;
depth = rectHeight;
setRadian(parent.rotationX, parent.rotationY, parent.rotationZ);
}
function set rectHeight(_arg1:Number):void{
_rectHeight = _arg1;
this.collisionRadiusSquare = ((APEngine.nSquareDistanceOffset + (this.width * this.width)) + (this.width * this.width));
}
override public function get velocity():hVector{
var _local1:hVector = p1.velocity;
var _local2:hVector = p2.velocity;
avgVelocity.setValue(((_local1.x + _local2.x) * 0.5), ((_local1.y + _local2.y) * 0.5), ((_local1.z + _local2.z) * 0.5));
return (avgVelocity);
}
private function getContactPointParam(_arg1:AbstractParticle):Number{
var _local2:Number;
if ((_arg1 is SphereParticle)){
_local2 = closestParamPoint(_arg1.curr);
} else {
_local2 = closestParamPoint(_arg1.curr);
};
return (_local2);
}
function set fixedEndLimit(_arg1:Number):void{
_fixedEndLimit = _arg1;
}
override function resolveCollision(_arg1:hVector, _arg2:hVector, _arg3:hVector, _arg4:Number, _arg5:int, _arg6:AbstractParticle):void{
var _local10:Number;
var _local11:AbstractParticle;
var _local7:Number = getContactPointParam(_arg6);
var _local8:Number = (1 - _local7);
var _local9:Number = _local7;
if (p1.fixed){
if (_local9 <= fixedEndLimit){
return;
};
lambda.setValue((_arg1.x / _local9), (_arg1.y / _local9), (_arg1.z / _local9));
p2.curr.vectorAdd(lambda);
p2.velocity = _arg2;
} else {
if (p2.fixed){
if (_local8 <= fixedEndLimit){
return;
};
lambda.setValue((_arg1.x / _local8), (_arg1.y / _local8), (_arg1.z / _local8));
p1.curr.vectorAdd(lambda);
p1.velocity = _arg2;
} else {
_local10 = ((_local8 * _local8) + (_local9 * _local9));
if (_local10 == 0){
return;
};
lambda.setValue((_arg1.x / _local10), (_arg1.y / _local10), (_arg1.z / _local10));
p1.curr.vectorAdd(lambda.getScalarScale(_local8));
p2.curr.vectorAdd(lambda.getScalarScale(_local9));
if (_local7 == 0.5){
p1.velocity = _arg2;
p2.velocity = _arg2;
} else {
_local11 = ((_local7)<0.5) ? p1 : p2;
_local11.velocity = _arg2;
};
};
};
}
function get rectHeight():Number{
return (_rectHeight);
}
function get fixedEndLimit():Number{
return (_fixedEndLimit);
}
override public function get elasticity():Number{
return (((p1.elasticity + p2.elasticity) * 0.5));
}
override public function get mass():Number{
return (((p1.mass + p2.mass) * 0.5));
}
private function closestParamPoint(_arg1:hVector):Number{
var _local2:hVector = p2.curr.getVectorSub(p1.curr);
var _local3:Number = (_local2.getDotProduct(_arg1.getVectorSub(p1.curr)) / _local2.getDotProduct(_local2));
return (MathUtil.clamp(_local3, 0, 1));
}
override public function getTagID():int{
this.nTagID = Math.max(this.p1.getTagID(), this.p2.getTagID());
return (this.nTagID);
}
}
}//package org.hardpcm.hardapex
Section 47
//Camera3D (org.papervision3d.cameras.Camera3D)
package org.papervision3d.cameras {
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.math.*;
import flash.geom.*;
import flash.utils.*;
import org.papervision3d.core.culling.*;
public class Camera3D extends CameraObject3D {
protected var _focusFix:Matrix3D;
protected var _prevUseProjection:Boolean;
protected var _prevZoom:Number;
protected var _prevOrtho:Boolean;
protected var _prevWidth:Number;
protected var _prevHeight:Number;
protected var _prevFocus:Number;
protected var _projection:Matrix3D;
protected var _prevOrthoProjection:Boolean;
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;
};
};
this.useProjectionMatrix = this._useProjectionMatrix;
_prevOrtho = this.ortho;
_prevUseProjection = _useProjectionMatrix;
this.useCulling = _useCulling;
}
public function get projection():Matrix3D{
return (_projection);
}
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 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);
}
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;
}
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 48
//Clipping (org.papervision3d.core.clipping.draw.Clipping)
package org.papervision3d.core.clipping.draw {
import flash.display.*;
import org.papervision3d.core.render.command.*;
import flash.geom.*;
public class Clipping {
public var minX:Number;// = -1000000
public var minY:Number;// = -1000000
private var zeroPoint:Point;
private var globalPoint:Point;
private var rectangleClipping:RectangleClipping;
public var maxX:Number;// = 1000000
public var maxY:Number;// = 1000000
public function Clipping(){
zeroPoint = new Point(0, 0);
super();
}
public function rect(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Boolean{
return (true);
}
public function screen(_arg1:Sprite):Clipping{
if (!rectangleClipping){
rectangleClipping = new RectangleClipping();
};
switch (_arg1.stage.align){
case StageAlign.TOP_LEFT:
zeroPoint.x = 0;
zeroPoint.y = 0;
globalPoint = _arg1.globalToLocal(zeroPoint);
rectangleClipping.maxX = ((rectangleClipping.minX = globalPoint.x) + _arg1.stage.stageWidth);
rectangleClipping.maxY = ((rectangleClipping.minY = globalPoint.y) + _arg1.stage.stageHeight);
break;
case StageAlign.TOP_RIGHT:
zeroPoint.x = _arg1.stage.stageWidth;
zeroPoint.y = 0;
globalPoint = _arg1.globalToLocal(zeroPoint);
rectangleClipping.minX = ((rectangleClipping.maxX = globalPoint.x) - _arg1.stage.stageWidth);
rectangleClipping.maxY = ((rectangleClipping.minY = globalPoint.y) + _arg1.stage.stageHeight);
break;
case StageAlign.BOTTOM_LEFT:
zeroPoint.x = 0;
zeroPoint.y = _arg1.stage.stageHeight;
globalPoint = _arg1.globalToLocal(zeroPoint);
rectangleClipping.maxX = ((rectangleClipping.minX = globalPoint.x) + _arg1.stage.stageWidth);
rectangleClipping.minY = ((rectangleClipping.maxY = globalPoint.y) - _arg1.stage.stageHeight);
break;
case StageAlign.BOTTOM_RIGHT:
zeroPoint.x = _arg1.stage.stageWidth;
zeroPoint.y = _arg1.stage.stageHeight;
globalPoint = _arg1.globalToLocal(zeroPoint);
rectangleClipping.minX = ((rectangleClipping.maxX = globalPoint.x) - _arg1.stage.stageWidth);
rectangleClipping.minY = ((rectangleClipping.maxY = globalPoint.y) - _arg1.stage.stageHeight);
break;
case StageAlign.TOP:
zeroPoint.x = (_arg1.stage.stageWidth / 2);
zeroPoint.y = 0;
globalPoint = _arg1.globalToLocal(zeroPoint);
rectangleClipping.minX = (globalPoint.x - (_arg1.stage.stageWidth / 2));
rectangleClipping.maxX = (globalPoint.x + (_arg1.stage.stageWidth / 2));
rectangleClipping.maxY = ((rectangleClipping.minY = globalPoint.y) + _arg1.stage.stageHeight);
break;
case StageAlign.BOTTOM:
zeroPoint.x = (_arg1.stage.stageWidth / 2);
zeroPoint.y = _arg1.stage.stageHeight;
globalPoint = _arg1.globalToLocal(zeroPoint);
rectangleClipping.minX = (globalPoint.x - (_arg1.stage.stageWidth / 2));
rectangleClipping.maxX = (globalPoint.x + (_arg1.stage.stageWidth / 2));
rectangleClipping.minY = ((rectangleClipping.maxY = globalPoint.y) - _arg1.stage.stageHeight);
break;
case StageAlign.LEFT:
zeroPoint.x = 0;
zeroPoint.y = (_arg1.stage.stageHeight / 2);
globalPoint = _arg1.globalToLocal(zeroPoint);
rectangleClipping.maxX = ((rectangleClipping.minX = globalPoint.x) + _arg1.stage.stageWidth);
rectangleClipping.minY = (globalPoint.y - (_arg1.stage.stageHeight / 2));
rectangleClipping.maxY = (globalPoint.y + (_arg1.stage.stageHeight / 2));
break;
case StageAlign.RIGHT:
zeroPoint.x = _arg1.stage.stageWidth;
zeroPoint.y = (_arg1.stage.stageHeight / 2);
globalPoint = _arg1.globalToLocal(zeroPoint);
rectangleClipping.minX = ((rectangleClipping.maxX = globalPoint.x) - _arg1.stage.stageWidth);
rectangleClipping.minY = (globalPoint.y - (_arg1.stage.stageHeight / 2));
rectangleClipping.maxY = (globalPoint.y + (_arg1.stage.stageHeight / 2));
break;
default:
zeroPoint.x = (_arg1.stage.stageWidth / 2);
zeroPoint.y = (_arg1.stage.stageHeight / 2);
globalPoint = _arg1.globalToLocal(zeroPoint);
rectangleClipping.minX = (globalPoint.x - (_arg1.stage.stageWidth / 2));
rectangleClipping.maxX = (globalPoint.x + (_arg1.stage.stageWidth / 2));
rectangleClipping.minY = (globalPoint.y - (_arg1.stage.stageHeight / 2));
rectangleClipping.maxY = (globalPoint.y + (_arg1.stage.stageHeight / 2));
};
return (rectangleClipping);
}
public function check(_arg1:RenderableListItem):Boolean{
return (true);
}
public function asRectangleClipping():RectangleClipping{
if (!rectangleClipping){
rectangleClipping = new RectangleClipping();
};
rectangleClipping.minX = -1000000;
rectangleClipping.minY = -1000000;
rectangleClipping.maxX = 1000000;
rectangleClipping.maxY = 1000000;
return (rectangleClipping);
}
}
}//package org.papervision3d.core.clipping.draw
Section 49
//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 50
//DefaultClipping (org.papervision3d.core.clipping.DefaultClipping)
package org.papervision3d.core.clipping {
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.geom.renderables.*;
public class DefaultClipping {
public function testFace(_arg1:Triangle3D, _arg2:DisplayObject3D, _arg3:RenderSessionData):Boolean{
return (false);
}
public function clipFace(_arg1:Triangle3D, _arg2:DisplayObject3D, _arg3:MaterialObject3D, _arg4:RenderSessionData, _arg5:Array):Number{
return (0);
}
public function setDisplayObject(_arg1:DisplayObject3D, _arg2:RenderSessionData):void{
}
public function reset(_arg1:RenderSessionData):void{
}
}
}//package org.papervision3d.core.clipping
Section 51
//FrustumClipping (org.papervision3d.core.clipping.FrustumClipping)
package org.papervision3d.core.clipping {
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.math.*;
import org.papervision3d.core.log.*;
import org.papervision3d.core.dyn.*;
import org.papervision3d.core.math.util.*;
public class FrustumClipping extends DefaultClipping {
private var _wleft:Plane3D;
private var _cnear:Plane3D;
private var _cbottom:Plane3D;
private var _world:Matrix3D;
private var _ftl:Number3D;
private var _wnear:Plane3D;
private var _wbottom:Plane3D;
private var _wright:Plane3D;
private var _ftr:Number3D;
private var _wfar:Plane3D;
private var _ntl:Number3D;
private var _camPos:Number3D;
private var _ntr:Number3D;
private var _planePoints:Array;
private var _wplanes:Array;
private var _planes:int;
private var _cright:Plane3D;
private var _cfar:Plane3D;
private var _dynTriangles:DynamicTriangles;
private var _nc:Number3D;
private var _axisX:Number3D;
private var _axisY:Number3D;
private var _fc:Number3D;
private var _wtop:Plane3D;
private var _axisZi:Number3D;
private var _matrix:Matrix3D;
private var _axisZ:Number3D;
private var _cleft:Plane3D;
private var _ctop:Plane3D;
private var _fbr:Number3D;
private var _fbl:Number3D;
private var _nbl:Number3D;
private var _cplanes:Array;
private var _nbr:Number3D;
public static const ALL:int = 63;
public static const RIGHT:int = 4;
private static const OUTSIDE:uint = 0;
public static const LEFT:int = 2;
private static const TO_DEGREES:Number = 57.2957795130823;
private static const IN_OUT:uint = 3;
private static const TO_RADIANS:Number = 0.0174532925199433;
private static const OUT_IN:uint = 2;
public static const DEFAULT:int = 31;
public static const NEAR:int = 1;
public static const BOTTOM:int = 16;
public static const TOP:int = 8;
public static const FAR:int = 32;
public static const NONE:int = 0;
private static const INSIDE:uint = 1;
public function FrustumClipping(_arg1:int=-1){
_cleft = Plane3D.fromCoefficients(0, 1, 0, 0);
_cright = Plane3D.fromCoefficients(0, 1, 0, 0);
_ctop = Plane3D.fromCoefficients(0, 1, 0, 0);
_cbottom = Plane3D.fromCoefficients(0, 1, 0, 0);
_cnear = Plane3D.fromCoefficients(0, 1, 0, 0);
_cfar = Plane3D.fromCoefficients(0, 1, 0, 0);
_wleft = Plane3D.fromCoefficients(0, 1, 0, 0);
_wright = Plane3D.fromCoefficients(0, 1, 0, 0);
_wtop = Plane3D.fromCoefficients(0, 1, 0, 0);
_wbottom = Plane3D.fromCoefficients(0, 1, 0, 0);
_wnear = Plane3D.fromCoefficients(0, 1, 0, 0);
_wfar = Plane3D.fromCoefficients(0, 1, 0, 0);
_nc = new Number3D();
_fc = new Number3D();
_ntl = new Number3D();
_ntr = new Number3D();
_nbr = new Number3D();
_nbl = new Number3D();
_ftl = new Number3D();
_ftr = new Number3D();
_fbr = new Number3D();
_fbl = new Number3D();
_camPos = new Number3D();
_axisX = new Number3D();
_axisY = new Number3D();
_axisZ = new Number3D();
_axisZi = new Number3D();
_matrix = Matrix3D.IDENTITY;
_world = Matrix3D.IDENTITY;
_dynTriangles = new DynamicTriangles();
this.planes = ((_arg1 < 0)) ? DEFAULT : _arg1;
}
override public function testFace(_arg1:Triangle3D, _arg2:DisplayObject3D, _arg3:RenderSessionData):Boolean{
var _local5:Plane3D;
var _local6:int;
var _local4:int;
while (_local4 < _wplanes.length) {
_local5 = _wplanes[_local4];
_local6 = ClassificationUtil.classifyTriangle(_arg1, _local5);
if ((((_local6 == ClassificationUtil.BACK)) || ((_local6 == ClassificationUtil.COINCIDING)))){
return (false);
};
if (_local6 == ClassificationUtil.STRADDLE){
return (true);
};
_local4++;
};
return (false);
}
public function get planes():int{
return (_planes);
}
public function set planes(_arg1:int):void{
_planes = _arg1;
_cplanes = new Array();
_wplanes = new Array();
_planePoints = new Array();
if ((_planes & NEAR)){
_cplanes.push(_cnear);
_wplanes.push(_wnear);
_planePoints.push(_nc);
};
if ((_planes & FAR)){
_cplanes.push(_cfar);
_wplanes.push(_wfar);
_planePoints.push(_fc);
};
if ((_planes & LEFT)){
_cplanes.push(_cleft);
_wplanes.push(_wleft);
_planePoints.push(_camPos);
};
if ((_planes & RIGHT)){
_cplanes.push(_cright);
_wplanes.push(_wright);
_planePoints.push(_camPos);
};
if ((_planes & TOP)){
_cplanes.push(_ctop);
_wplanes.push(_wtop);
_planePoints.push(_camPos);
};
if ((_planes & BOTTOM)){
_cplanes.push(_cbottom);
_wplanes.push(_wbottom);
_planePoints.push(_camPos);
};
}
private function compareDistances(_arg1:Number, _arg2:Number):uint{
if ((((_arg1 < 0)) && ((_arg2 < 0)))){
return (OUTSIDE);
};
if ((((_arg1 > 0)) && ((_arg2 > 0)))){
return (INSIDE);
};
if ((((_arg1 > 0)) && ((_arg2 < 0)))){
return (IN_OUT);
};
return (OUT_IN);
}
override public function clipFace(_arg1:Triangle3D, _arg2:DisplayObject3D, _arg3:MaterialObject3D, _arg4:RenderSessionData, _arg5:Array):Number{
var plane:Plane3D;
var side:int;
var k:int;
var v1:Vertex3D;
var v2:Vertex3D;
var t1:NumberUV;
var t2:NumberUV;
var tri:Triangle3D;
var triangle = _arg1;
var object = _arg2;
var material = _arg3;
var renderSessionData = _arg4;
var outputArray = _arg5;
var points:Array = [triangle.v0, triangle.v1, triangle.v2];
var uvs:Array = [triangle.uv0, triangle.uv1, triangle.uv2];
var clipped:Boolean;
var i:int;
while (i < _wplanes.length) {
plane = _wplanes[i];
side = ClassificationUtil.classifyPoints(points, plane);
try {
if (side == ClassificationUtil.STRADDLE){
points = clipPointsToPlane(triangle.instance, points, uvs, plane);
clipped = true;
};
} catch(e:Error) {
PaperLogger.error(("FrustumClipping#clipFace : " + e.message));
};
i = (i + 1);
};
if (!clipped){
outputArray.push(triangle);
return (1);
};
var v0:Vertex3D = points[0];
var t0:NumberUV = uvs[0];
var j = 1;
while (j < points.length) {
k = ((j + 1) % points.length);
v1 = points[j];
v2 = points[k];
t1 = uvs[j];
t2 = uvs[k];
tri = _dynTriangles.getTriangle(triangle.instance, triangle.material, v0, v1, v2, t0, t1, t2);
if (tri.faceNormal.modulo){
outputArray.push(tri);
};
j = (j + 1);
};
return (outputArray.length);
}
public function clipPointsToPlane(_arg1:DisplayObject3D, _arg2:Array, _arg3:Array, _arg4:Plane3D):Array{
var _local10:int;
var _local11:Vertex3D;
var _local12:Vertex3D;
var _local13:NumberUV;
var _local14:NumberUV;
var _local15:Number;
var _local16:Number;
var _local17:Vertex3D;
var _local18:NumberUV;
var _local19:uint;
var _local5:Array = new Array();
var _local6:Array = new Array();
var _local7:Number = _arg4.distance(_arg2[0]);
var _local8:int;
while (_local8 < _arg2.length) {
_local10 = ((_local8 + 1) % _arg2.length);
_local11 = _arg2[_local8];
_local12 = _arg2[_local10];
_local13 = _arg3[_local8];
_local14 = _arg3[_local10];
_local15 = _arg4.distance(_local12);
_local16 = (_local7 / (_local7 - _local15));
_local19 = compareDistances(_local7, _local15);
switch (_local19){
case INSIDE:
_local5.push(_local12);
_local6.push(_local14);
break;
case IN_OUT:
_local17 = new Vertex3D();
_local17.x = (_local11.x + ((_local12.x - _local11.x) * _local16));
_local17.y = (_local11.y + ((_local12.y - _local11.y) * _local16));
_local17.z = (_local11.z + ((_local12.z - _local11.z) * _local16));
_local18 = new NumberUV();
_local18.u = (_local13.u + ((_local14.u - _local13.u) * _local16));
_local18.v = (_local13.v + ((_local14.v - _local13.v) * _local16));
_local6.push(_local18);
_local5.push(_local17);
_arg1.geometry.vertices.push(_local17);
break;
case OUT_IN:
_local18 = new NumberUV();
_local18.u = (_local13.u + ((_local14.u - _local13.u) * _local16));
_local18.v = (_local13.v + ((_local14.v - _local13.v) * _local16));
_local6.push(_local18);
_local6.push(_local14);
_local17 = new Vertex3D();
_local17.x = (_local11.x + ((_local12.x - _local11.x) * _local16));
_local17.y = (_local11.y + ((_local12.y - _local11.y) * _local16));
_local17.z = (_local11.z + ((_local12.z - _local11.z) * _local16));
_local5.push(_local17);
_local5.push(_local12);
_arg1.geometry.vertices.push(_local17);
break;
default:
break;
};
_local7 = _local15;
_local8++;
};
var _local9:int;
while (_local9 < _local6.length) {
_arg3[_local9] = _local6[_local9];
_local9++;
};
return (_local5);
}
override public function reset(_arg1:RenderSessionData):void{
var _local2:CameraObject3D = _arg1.camera;
var _local3:Number = _arg1.viewPort.viewportWidth;
var _local4:Number = _arg1.viewPort.viewportHeight;
var _local5:Number = Math.tan(((_local2.fov / 2) * TO_RADIANS));
var _local6:Number = _local2.focus;
_matrix.copy(_arg1.camera.transform);
_axisX.reset(_matrix.n11, _matrix.n21, _matrix.n31);
_axisY.reset(_matrix.n12, _matrix.n22, _matrix.n32);
_axisZ.reset(_matrix.n13, _matrix.n23, _matrix.n33);
_axisZi.reset(-(_axisZ.x), -(_axisZ.y), -(_axisZ.z));
var _local7:Number = ((2 * _local5) * _local6);
var _local8:Number = (_local7 * (_local3 / _local4));
_camPos.reset(_local2.x, _local2.y, _local2.z);
_nc.x = (_camPos.x + (_local6 * _axisZ.x));
_nc.y = (_camPos.y + (_local6 * _axisZ.y));
_nc.z = (_camPos.z + (_local6 * _axisZ.z));
_fc.x = (_camPos.x + (_local2.far * _axisZ.x));
_fc.y = (_camPos.y + (_local2.far * _axisZ.y));
_fc.z = (_camPos.z + (_local2.far * _axisZ.z));
_ntl.copyFrom(_nc);
_nbl.copyFrom(_nc);
_ntr.copyFrom(_nc);
_nbr.copyFrom(_nc);
_local7 = (_local7 / 2);
_local8 = (_local8 / 2);
_ntl.x = (_ntl.x - (_local8 * _axisX.x));
_ntl.y = (_ntl.y - (_local8 * _axisX.y));
_ntl.z = (_ntl.z - (_local8 * _axisX.z));
_ntl.x = (_ntl.x + (_local7 * _axisY.x));
_ntl.y = (_ntl.y + (_local7 * _axisY.y));
_ntl.z = (_ntl.z + (_local7 * _axisY.z));
_nbl.x = (_nbl.x - (_local8 * _axisX.x));
_nbl.y = (_nbl.y - (_local8 * _axisX.y));
_nbl.z = (_nbl.z - (_local8 * _axisX.z));
_nbl.x = (_nbl.x - (_local7 * _axisY.x));
_nbl.y = (_nbl.y - (_local7 * _axisY.y));
_nbl.z = (_nbl.z - (_local7 * _axisY.z));
_nbr.x = (_nbr.x + (_local8 * _axisX.x));
_nbr.y = (_nbr.y + (_local8 * _axisX.y));
_nbr.z = (_nbr.z + (_local8 * _axisX.z));
_nbr.x = (_nbr.x - (_local7 * _axisY.x));
_nbr.y = (_nbr.y - (_local7 * _axisY.y));
_nbr.z = (_nbr.z - (_local7 * _axisY.z));
_ntr.x = (_ntr.x + (_local8 * _axisX.x));
_ntr.y = (_ntr.y + (_local8 * _axisX.y));
_ntr.z = (_ntr.z + (_local8 * _axisX.z));
_ntr.x = (_ntr.x + (_local7 * _axisY.x));
_ntr.y = (_ntr.y + (_local7 * _axisY.y));
_ntr.z = (_ntr.z + (_local7 * _axisY.z));
if ((_planes & NEAR)){
_cnear.setNormalAndPoint(_axisZ, _nc);
};
if ((_planes & FAR)){
_cfar.setNormalAndPoint(_axisZi, _fc);
};
if ((_planes & LEFT)){
_cleft.setThreePoints(_camPos, _nbl, _ntl);
};
if ((_planes & RIGHT)){
_cright.setThreePoints(_camPos, _ntr, _nbr);
};
if ((_planes & TOP)){
_ctop.setThreePoints(_camPos, _ntl, _ntr);
};
if ((_planes & BOTTOM)){
_cbottom.setThreePoints(_camPos, _nbr, _nbl);
};
_dynTriangles.releaseAll();
}
override public function setDisplayObject(_arg1:DisplayObject3D, _arg2:RenderSessionData):void{
var _local5:Plane3D;
var _local6:Plane3D;
_world.copy(_arg1.world);
_world.invert();
var _local3:Number3D = new Number3D();
var _local4:int;
while (_local4 < _cplanes.length) {
_local5 = _cplanes[_local4];
_local6 = _wplanes[_local4];
_local3.copyFrom(_planePoints[_local4]);
_local6.normal.copyFrom(_local5.normal);
Matrix3D.multiplyVector3x3(_world, _local6.normal);
Matrix3D.multiplyVector(_world, _local3);
_local6.setNormalAndPoint(_local6.normal, _local3);
_local4++;
};
}
}
}//package org.papervision3d.core.clipping
Section 52
//DefaultLineCuller (org.papervision3d.core.culling.DefaultLineCuller)
package org.papervision3d.core.culling {
import org.papervision3d.core.geom.renderables.*;
public class DefaultLineCuller implements ILineCuller {
public function testLine(_arg1:Line3D):Boolean{
return (((_arg1.v0.vertex3DInstance.visible) && (_arg1.v1.vertex3DInstance.visible)));
}
}
}//package org.papervision3d.core.culling
Section 53
//DefaultParticleCuller (org.papervision3d.core.culling.DefaultParticleCuller)
package org.papervision3d.core.culling {
import org.papervision3d.core.geom.renderables.*;
public class DefaultParticleCuller implements IParticleCuller {
public function testParticle(_arg1:Particle):Boolean{
if (_arg1.material.invisible == false){
if (_arg1.vertex3D.vertex3DInstance.visible == true){
return (true);
};
};
return (false);
}
}
}//package org.papervision3d.core.culling
Section 54
//DefaultTriangleCuller (org.papervision3d.core.culling.DefaultTriangleCuller)
package org.papervision3d.core.culling {
import org.papervision3d.core.proto.*;
import org.papervision3d.core.geom.renderables.*;
public class DefaultTriangleCuller implements ITriangleCuller {
protected static var y2:Number;
protected static var y1:Number;
protected static var y0:Number;
protected static var x0:Number;
protected static var x1:Number;
protected static var x2:Number;
public function testFace(_arg1:Triangle3D, _arg2:Vertex3DInstance, _arg3:Vertex3DInstance, _arg4:Vertex3DInstance):Boolean{
var _local5:MaterialObject3D;
if (((((_arg2.visible) && (_arg3.visible))) && (_arg4.visible))){
_local5 = (_arg1.material) ? _arg1.material : _arg1.instance.material;
if (_local5.invisible){
return (false);
};
x0 = _arg2.x;
y0 = _arg2.y;
x1 = _arg3.x;
y1 = _arg3.y;
x2 = _arg4.x;
y2 = _arg4.y;
if (_local5.oneSide){
if (_local5.opposite){
if ((((x2 - x0) * (y1 - y0)) - ((y2 - y0) * (x1 - x0))) > 0){
return (false);
};
} else {
if ((((x2 - x0) * (y1 - y0)) - ((y2 - y0) * (x1 - x0))) < 0){
return (false);
};
};
};
return (true);
};
return (false);
}
}
}//package org.papervision3d.core.culling
Section 55
//FrustumCuller (org.papervision3d.core.culling.FrustumCuller)
package org.papervision3d.core.culling {
import org.papervision3d.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 56
//FrustumTestMethod (org.papervision3d.core.culling.FrustumTestMethod)
package org.papervision3d.core.culling {
public class FrustumTestMethod {
public static const BOUNDING_BOX:int = 1;
public static const NO_TESTING:int = -1;
public static const BOUNDING_SPHERE:int = 0;
}
}//package org.papervision3d.core.culling
Section 57
//ILineCuller (org.papervision3d.core.culling.ILineCuller)
package org.papervision3d.core.culling {
import org.papervision3d.core.geom.renderables.*;
public interface ILineCuller {
function testLine(_arg1:Line3D):Boolean;
}
}//package org.papervision3d.core.culling
Section 58
//IObjectCuller (org.papervision3d.core.culling.IObjectCuller)
package org.papervision3d.core.culling {
import org.papervision3d.objects.*;
public interface IObjectCuller {
function testObject(_arg1:DisplayObject3D):int;
}
}//package org.papervision3d.core.culling
Section 59
//IParticleCuller (org.papervision3d.core.culling.IParticleCuller)
package org.papervision3d.core.culling {
import org.papervision3d.core.geom.renderables.*;
public interface IParticleCuller {
function testParticle(_arg1:Particle):Boolean;
}
}//package org.papervision3d.core.culling
Section 60
//ITriangleCuller (org.papervision3d.core.culling.ITriangleCuller)
package org.papervision3d.core.culling {
import org.papervision3d.core.geom.renderables.*;
public interface ITriangleCuller {
function testFace(_arg1:Triangle3D, _arg2:Vertex3DInstance, _arg3:Vertex3DInstance, _arg4:Vertex3DInstance):Boolean;
}
}//package org.papervision3d.core.culling
Section 61
//RectangleLineCuller (org.papervision3d.core.culling.RectangleLineCuller)
package org.papervision3d.core.culling {
import org.papervision3d.core.geom.renderables.*;
import flash.geom.*;
import org.papervision3d.core.math.util.*;
public class RectangleLineCuller implements ILineCuller {
private var 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 62
//RectangleParticleCuller (org.papervision3d.core.culling.RectangleParticleCuller)
package org.papervision3d.core.culling {
import org.papervision3d.core.geom.renderables.*;
import flash.geom.*;
import org.papervision3d.core.math.util.*;
public class RectangleParticleCuller implements IParticleCuller {
public var cullingRectangle:Rectangle;
private static var vInstance:Vertex3DInstance;
private static var testPoint:Point;
public function RectangleParticleCuller(_arg1:Rectangle=null){
this.cullingRectangle = _arg1;
testPoint = new Point();
}
public function testParticle(_arg1:Particle):Boolean{
vInstance = _arg1.vertex3D.vertex3DInstance;
if (_arg1.material.invisible == false){
if (vInstance.visible){
if (FastRectangleTools.intersects(_arg1.renderRect, cullingRectangle)){
return (true);
};
};
};
return (false);
}
}
}//package org.papervision3d.core.culling
Section 63
//RectangleTriangleCuller (org.papervision3d.core.culling.RectangleTriangleCuller)
package org.papervision3d.core.culling {
import org.papervision3d.core.geom.renderables.*;
import flash.geom.*;
import org.papervision3d.core.math.util.*;
public class RectangleTriangleCuller extends DefaultTriangleCuller implements ITriangleCuller {
public var cullingRectangle:Rectangle;
private static const DEFAULT_RECT_X:Number = -((DEFAULT_RECT_W / 2));
private static const DEFAULT_RECT_W:Number = 640;
private static const DEFAULT_RECT_H:Number = 480;
private static const DEFAULT_RECT_Y:Number = -((DEFAULT_RECT_H / 2));
private static var hitRect:Rectangle = new Rectangle();
public function RectangleTriangleCuller(_arg1:Rectangle=null):void{
cullingRectangle = new Rectangle(DEFAULT_RECT_X, DEFAULT_RECT_Y, DEFAULT_RECT_W, DEFAULT_RECT_H);
super();
if (_arg1){
this.cullingRectangle = _arg1;
};
}
override public function testFace(_arg1:Triangle3D, _arg2:Vertex3DInstance, _arg3:Vertex3DInstance, _arg4:Vertex3DInstance):Boolean{
if (super.testFace(_arg1, _arg2, _arg3, _arg4)){
hitRect.x = Math.min(_arg4.x, Math.min(_arg3.x, _arg2.x));
hitRect.width = (Math.max(_arg4.x, Math.max(_arg3.x, _arg2.x)) + Math.abs(hitRect.x));
hitRect.y = Math.min(_arg4.y, Math.min(_arg3.y, _arg2.y));
hitRect.height = (Math.max(_arg4.y, Math.max(_arg3.y, _arg2.y)) + Math.abs(hitRect.y));
return (FastRectangleTools.intersects(cullingRectangle, hitRect));
};
return (false);
}
}
}//package org.papervision3d.core.culling
Section 64
//ViewportObjectFilter (org.papervision3d.core.culling.ViewportObjectFilter)
package org.papervision3d.core.culling {
import org.papervision3d.objects.*;
import flash.utils.*;
public class ViewportObjectFilter implements IObjectCuller {
protected var _mode:int;
protected var objects:Dictionary;
public function ViewportObjectFilter(_arg1:int):void{
this.mode = _arg1;
init();
}
public function addObject(_arg1:DisplayObject3D):void{
objects[_arg1] = _arg1;
}
public function 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 65
//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 66
//DynamicTriangles (org.papervision3d.core.dyn.DynamicTriangles)
package org.papervision3d.core.dyn {
import org.papervision3d.core.proto.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.math.*;
import org.papervision3d.materials.*;
import org.papervision3d.materials.special.*;
public class DynamicTriangles {
private static const INIT_SIZE:int = 100;
private static const GROW_SIZE:int = 300;
private static var triangleCounter:int;
private static var trianglePool:Array;
public function DynamicTriangles(){
init();
}
public function returnTriangle(_arg1:Triangle3D):void{
var _local2 = triangleCounter++;
trianglePool[_local2] = _arg1;
}
public function returnAllTriangles():void{
triangleCounter = trianglePool.length;
}
public function releaseAll():void{
returnAllTriangles();
}
public function getTriangle(_arg1:DisplayObject3D=null, _arg2:MaterialObject3D=null, _arg3:Vertex3D=null, _arg4:Vertex3D=null, _arg5:Vertex3D=null, _arg6:NumberUV=null, _arg7:NumberUV=null, _arg8:NumberUV=null):Triangle3D{
var _local9:int;
var _local10:Triangle3D;
var _local11:MaterialObject3D;
if (triangleCounter == 0){
_local9 = GROW_SIZE;
while (--_local9 > -1) {
trianglePool.unshift(new Triangle3D(null, null, null, null));
};
triangleCounter = GROW_SIZE;
return (getTriangle(_arg1, _arg2, _arg3, _arg4, _arg5, _arg6, _arg7, _arg8));
//unresolved jump
};
_local10 = Triangle3D(trianglePool[--triangleCounter]);
if (_local10.material){
if ((((_local10.material is BitmapMaterial)) && (BitmapMaterial(_local10.material).uvMatrices))){
BitmapMaterial(_local10.material).uvMatrices[_local10.renderCommand] = null;
};
if ((_local10.material is CompositeMaterial)){
for each (_local11 in CompositeMaterial(_local10.material).materials) {
if ((((_local11 is BitmapMaterial)) && (BitmapMaterial(_local11).uvMatrices))){
BitmapMaterial(_local11).uvMatrices[_local10.renderCommand] = null;
};
};
};
};
_local10.instance = _arg1;
_local10.vertices = [_arg3, _arg4, _arg5];
_local10.uv = [_arg6, _arg7, _arg8];
_local10.updateVertices();
_local10.createNormal();
_local10.material = _arg2;
return (_local10);
}
private static function init():void{
trianglePool = new Array(INIT_SIZE);
var _local1:int = INIT_SIZE;
while (--_local1 > -1) {
trianglePool[_local1] = new Triangle3D(null, null, null, null);
};
triangleCounter = INIT_SIZE;
}
}
}//package org.papervision3d.core.dyn
Section 67
//AbstractRenderable (org.papervision3d.core.geom.renderables.AbstractRenderable)
package org.papervision3d.core.geom.renderables {
import org.papervision3d.core.render.command.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.data.*;
public class AbstractRenderable implements IRenderable {
public var _userData:UserData;
public var instance:DisplayObject3D;
public function 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 68
//IRenderable (org.papervision3d.core.geom.renderables.IRenderable)
package org.papervision3d.core.geom.renderables {
import org.papervision3d.core.render.command.*;
public interface IRenderable {
function getRenderListItem():IRenderListItem;
}
}//package org.papervision3d.core.geom.renderables
Section 69
//Line3D (org.papervision3d.core.geom.renderables.Line3D)
package org.papervision3d.core.geom.renderables {
import org.papervision3d.core.render.command.*;
import org.papervision3d.materials.special.*;
import org.papervision3d.core.geom.*;
public class Line3D extends AbstractRenderable implements IRenderable {
public var size:Number;
public var 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 70
//Particle (org.papervision3d.core.geom.renderables.Particle)
package org.papervision3d.core.geom.renderables {
import org.papervision3d.core.render.command.*;
import flash.geom.*;
import org.papervision3d.materials.special.*;
public class Particle extends AbstractRenderable implements IRenderable {
public var size:Number;
public var renderScale:Number;
public var vertex3D:Vertex3D;
public var renderRect:Rectangle;
public var 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 71
//Triangle3D (org.papervision3d.core.geom.renderables.Triangle3D)
package org.papervision3d.core.geom.renderables {
import org.papervision3d.core.proto.*;
import org.papervision3d.core.render.command.*;
import org.papervision3d.objects.*;
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 72
//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 73
//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 74
//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 75
//Lines3D (org.papervision3d.core.geom.Lines3D)
package org.papervision3d.core.geom {
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.render.command.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.log.*;
import org.papervision3d.materials.special.*;
import org.papervision3d.core.render.draw.*;
public class Lines3D extends Vertices3D {
private var _material:ILineDrawer;
public var lines:Array;
public function Lines3D(_arg1:LineMaterial=null, _arg2:String=null){
super(null, _arg2);
if (!_arg1){
this.material = new LineMaterial();
} else {
this.material = _arg1;
};
init();
}
private function init():void{
this.lines = new Array();
}
public function removeAllLines():void{
while (lines.length > 0) {
removeLine(lines[0]);
};
}
public function addLine(_arg1:Line3D):void{
lines.push(_arg1);
_arg1.instance = this;
if (geometry.vertices.indexOf(_arg1.v0) == -1){
geometry.vertices.push(_arg1.v0);
};
if (geometry.vertices.indexOf(_arg1.v1) == -1){
geometry.vertices.push(_arg1.v1);
};
if (_arg1.cV){
if (geometry.vertices.indexOf(_arg1.cV) == -1){
geometry.vertices.push(_arg1.cV);
};
};
}
public function addNewSegmentedLine(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:Number, _arg7:Number, _arg8:Number):Array{
var _local13:Line3D;
var _local15:Vertex3D;
var _local9:Number = ((_arg6 - _arg3) / _arg2);
var _local10:Number = ((_arg7 - _arg4) / _arg2);
var _local11:Number = ((_arg8 - _arg5) / _arg2);
var _local12:Array = new Array();
var _local14:Vertex3D = new Vertex3D(_arg3, _arg4, _arg5);
var _local16:Number = 0;
while (_local16 <= _arg2) {
_local15 = new Vertex3D((_arg3 + (_local9 * _local16)), (_arg4 + (_local10 * _local16)), (_arg5 + (_local11 * _local16)));
_local13 = new Line3D(this, (material as LineMaterial), _arg1, _local14, _local15);
addLine(_local13);
_local12.push(_local13);
_local14 = _local15;
_local16++;
};
return (_local12);
}
public function removeLine(_arg1:Line3D):void{
var _local2:int = lines.indexOf(_arg1);
if (_local2 > -1){
lines.splice(_local2, 1);
} else {
PaperLogger.warning("Papervision3D Lines3D.removeLine : WARNING removal of non-existant line attempted. ");
};
}
override public function project(_arg1:DisplayObject3D, _arg2:RenderSessionData):Number{
var _local3:Line3D;
var _local4:Number;
var _local5:RenderLine;
super.project(_arg1, _arg2);
for each (_local3 in lines) {
if (_arg2.viewPort.lineCuller.testLine(_local3)){
_local5 = _local3.renderCommand;
_local5.renderer = _local3.material;
_local5.size = _local3.size;
_local4 = (_local4 + (_local5.screenZ = ((_local3.v0.vertex3DInstance.z + _local3.v1.vertex3DInstance.z) / 2)));
_local5.v0 = _local3.v0.vertex3DInstance;
_local5.v1 = _local3.v1.vertex3DInstance;
_arg2.renderer.addToRenderList(_local5);
};
};
return ((_local4 / (lines.length + 1)));
}
public function addNewLine(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:Number, _arg7:Number):Line3D{
var _local8:Line3D = new Line3D(this, (material as LineMaterial), _arg1, new Vertex3D(_arg2, _arg3, _arg4), new Vertex3D(_arg5, _arg6, _arg7));
addLine(_local8);
return (_local8);
}
}
}//package org.papervision3d.core.geom
Section 76
//TriangleMesh3D (org.papervision3d.core.geom.TriangleMesh3D)
package org.papervision3d.core.geom {
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.core.render.command.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.math.*;
import flash.utils.*;
import org.papervision3d.core.culling.*;
import org.papervision3d.core.render.draw.*;
public class TriangleMesh3D extends Vertices3D {
private var _tri:RenderTriangle;
private var _dtStore:Array;
private var _dtActive:Array;
public function TriangleMesh3D(_arg1:MaterialObject3D, _arg2:Array, _arg3:Array, _arg4:String=null){
_dtStore = new Array();
_dtActive = new Array();
super(_arg2, _arg4);
this.geometry.faces = ((_arg3) || (new Array()));
this.material = ((_arg1) || (MaterialObject3D.DEFAULT));
}
public function projectTexture(_arg1:String="x", _arg2:String="y"):void{
var _local10:String;
var _local11:Triangle3D;
var _local12:Array;
var _local13:Vertex3D;
var _local14:Vertex3D;
var _local15:Vertex3D;
var _local16:NumberUV;
var _local17:NumberUV;
var _local18:NumberUV;
var _local3:Array = this.geometry.faces;
var _local4:Object = this.boundingBox();
var _local5:Number = _local4.min[_arg1];
var _local6:Number = _local4.size[_arg1];
var _local7:Number = _local4.min[_arg2];
var _local8:Number = _local4.size[_arg2];
var _local9:MaterialObject3D = this.material;
for (_local10 in _local3) {
_local11 = _local3[Number(_local10)];
_local12 = _local11.vertices;
_local13 = _local12[0];
_local14 = _local12[1];
_local15 = _local12[2];
_local16 = new NumberUV(((_local13[_arg1] - _local5) / _local6), ((_local13[_arg2] - _local7) / _local8));
_local17 = new NumberUV(((_local14[_arg1] - _local5) / _local6), ((_local14[_arg2] - _local7) / _local8));
_local18 = new NumberUV(((_local15[_arg1] - _local5) / _local6), ((_local15[_arg2] - _local7) / _local8));
_local11.uv = [_local16, _local17, _local18];
};
}
public function quarterFaces():void{
var _local4:Triangle3D;
var _local6:Vertex3D;
var _local7:Vertex3D;
var _local8:Vertex3D;
var _local9:Vertex3D;
var _local10:Vertex3D;
var _local11:Vertex3D;
var _local12:NumberUV;
var _local13:NumberUV;
var _local14:NumberUV;
var _local15:NumberUV;
var _local16:NumberUV;
var _local17:NumberUV;
var _local18:Triangle3D;
var _local19:Triangle3D;
var _local20:Triangle3D;
var _local21:Triangle3D;
var _local1:Array = new Array();
var _local2:Array = new Array();
var _local3:Array = this.geometry.faces;
var _local5:int = _local3.length;
while ((_local4 = _local3[--_local5])) {
_local6 = _local4.v0;
_local7 = _local4.v1;
_local8 = _local4.v2;
_local9 = new Vertex3D(((_local6.x + _local7.x) / 2), ((_local6.y + _local7.y) / 2), ((_local6.z + _local7.z) / 2));
_local10 = new Vertex3D(((_local7.x + _local8.x) / 2), ((_local7.y + _local8.y) / 2), ((_local7.z + _local8.z) / 2));
_local11 = new Vertex3D(((_local8.x + _local6.x) / 2), ((_local8.y + _local6.y) / 2), ((_local8.z + _local6.z) / 2));
this.geometry.vertices.push(_local9, _local10, _local11);
_local12 = _local4.uv[0];
_local13 = _local4.uv[1];
_local14 = _local4.uv[2];
_local15 = new NumberUV(((_local12.u + _local13.u) / 2), ((_local12.v + _local13.v) / 2));
_local16 = new NumberUV(((_local13.u + _local14.u) / 2), ((_local13.v + _local14.v) / 2));
_local17 = new NumberUV(((_local14.u + _local12.u) / 2), ((_local14.v + _local12.v) / 2));
_local18 = new Triangle3D(this, [_local6, _local9, _local11], _local4.material, [_local12, _local15, _local17]);
_local19 = new Triangle3D(this, [_local9, _local7, _local10], _local4.material, [_local15, _local13, _local16]);
_local20 = new Triangle3D(this, [_local11, _local10, _local8], _local4.material, [_local17, _local16, _local14]);
_local21 = new Triangle3D(this, [_local9, _local10, _local11], _local4.material, [_local15, _local16, _local17]);
_local2.push(_local18, _local19, _local20, _local21);
};
this.geometry.faces = _local2;
this.mergeVertices();
this.geometry.ready = true;
}
override public function set material(_arg1:MaterialObject3D):void{
var _local2:Triangle3D;
super.material = _arg1;
for each (_local2 in geometry.faces) {
_local2.material = _arg1;
};
}
public function mergeVertices():void{
var _local3:Vertex3D;
var _local4:Triangle3D;
var _local5:Vertex3D;
var _local1:Dictionary = new Dictionary();
var _local2:Array = new Array();
for each (_local3 in this.geometry.vertices) {
for each (_local5 in _local1) {
if ((((((_local3.x == _local5.x)) && ((_local3.y == _local5.y)))) && ((_local3.z == _local5.z)))){
_local1[_local3] = _local5;
break;
};
};
if (!_local1[_local3]){
_local1[_local3] = _local3;
_local2.push(_local3);
};
};
this.geometry.vertices = _local2;
for each (_local4 in geometry.faces) {
_local4.v0 = (_local4.vertices[0] = _local1[_local4.v0]);
_local4.v1 = (_local4.vertices[1] = _local1[_local4.v1]);
_local4.v2 = (_local4.vertices[2] = _local1[_local4.v2]);
};
}
override public function project(_arg1:DisplayObject3D, _arg2:RenderSessionData):Number{
var _local5:Triangle3D;
var _local6:Array;
var _local7:Number;
var _local8:Number;
var _local9:ITriangleCuller;
var _local10:Vertex3DInstance;
var _local11:Vertex3DInstance;
var _local12:Vertex3DInstance;
var _local13:Triangle3DInstance;
var _local14:Triangle3D;
var _local15:MaterialObject3D;
var _local16:RenderTriangle;
_dtStore = [];
_dtActive = new Array();
var _local3:int = this.geometry.vertices.length;
var _local4:Array = [];
if (((((((_arg2.clipping) && (this.useClipping))) && (!(this.culled)))) && ((_arg2.camera.useCulling) ? (cullTest == 0) : true))){
super.projectEmpty(_arg1, _arg2);
_arg2.clipping.setDisplayObject(this, _arg2);
for each (_local5 in this.geometry.faces) {
if (_arg2.clipping.testFace(_local5, this, _arg2)){
_arg2.clipping.clipFace(_local5, this, _local15, _arg2, _local4);
} else {
_local4.push(_local5);
};
};
super.project(_arg1, _arg2);
_arg2.camera.projectFaces(_local4, this, _arg2);
} else {
super.project(_arg1, _arg2);
_local4 = this.geometry.faces;
};
if (!this.culled){
_local6 = this.geometry.faces;
_local7 = 0;
_local8 = 0;
_local9 = _arg2.triangleCuller;
for each (_local14 in _local4) {
_local15 = (_local14.material) ? _local14.material : material;
_local10 = _local14.v0.vertex3DInstance;
_local11 = _local14.v1.vertex3DInstance;
_local12 = _local14.v2.vertex3DInstance;
if (_local9.testFace(_local14, _local10, _local11, _local12)){
_local16 = _local14.renderCommand;
_local7 = (_local7 + (_local16.screenZ = setScreenZ(meshSort, _local10, _local11, _local12)));
_local8++;
_local16.renderer = (_local15 as ITriangleDrawer);
_local16.v0 = _local10;
_local16.v1 = _local11;
_local16.v2 = _local12;
_local16.uv0 = _local14.uv0;
_local16.uv1 = _local14.uv1;
_local16.uv2 = _local14.uv2;
if (_arg2.quadrantTree){
if (_local16.create == null){
_local16.create = createRenderTriangle;
};
_local16.update();
if ((((_local16.area < 0)) && (((_local14.material.doubleSided) || (((_local14.material.oneSide) && (_local14.material.opposite))))))){
_local16.area = -(_local16.area);
};
};
_arg2.renderer.addToRenderList(_local16);
} else {
_arg2.renderStatistics.culledTriangles++;
};
};
if (_local3){
while (this.geometry.vertices.length > _local3) {
this.geometry.vertices.pop();
};
};
return ((this.screenZ = (_local7 / _local8)));
} else {
_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);
return (_local2);
}
}
}//package org.papervision3d.core.geom
Section 77
//Vertices3D (org.papervision3d.core.geom.Vertices3D)
package org.papervision3d.core.geom {
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.math.*;
import org.papervision3d.core.culling.*;
public class Vertices3D extends DisplayObject3D {
public function Vertices3D(_arg1:Array, _arg2:String=null){
super(_arg2, new GeometryObject3D());
this.geometry.vertices = ((_arg1) || (new Array()));
}
override public function project(_arg1:DisplayObject3D, _arg2:RenderSessionData):Number{
super.project(_arg1, _arg2);
if (this.culled){
return (0);
};
if ((_arg2.camera is IObjectCuller)){
return (projectFrustum(_arg1, _arg2));
};
if (((!(this.geometry)) || (!(this.geometry.vertices)))){
return (0);
};
return (_arg2.camera.projectVertices(this.geometry.vertices, this, _arg2));
}
public function projectEmpty(_arg1:DisplayObject3D, _arg2:RenderSessionData):Number{
return (super.project(_arg1, _arg2));
}
public function worldBoundingBox():Object{
var _local3:Number3D;
var _local4:Vertex3D;
var _local1:Array = this.geometry.vertices;
var _local2:Object = new Object();
_local2.min = new Number3D(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
_local2.max = new Number3D(-(Number.MAX_VALUE), -(Number.MAX_VALUE), -(Number.MAX_VALUE));
_local2.size = new Number3D();
for each (_local4 in _local1) {
_local3 = _local4.getPosition();
Matrix3D.multiplyVector(this.world, _local3);
_local2.min.x = Math.min(_local3.x, _local2.min.x);
_local2.min.y = Math.min(_local3.y, _local2.min.y);
_local2.min.z = Math.min(_local3.z, _local2.min.z);
_local2.max.x = Math.max(_local3.x, _local2.max.x);
_local2.max.y = Math.max(_local3.y, _local2.max.y);
_local2.max.z = Math.max(_local3.z, _local2.max.z);
};
_local2.size.x = (_local2.max.x - _local2.min.x);
_local2.size.y = (_local2.max.y - _local2.min.y);
_local2.size.z = (_local2.max.z - _local2.min.z);
return (_local2);
}
public function boundingBox():Object{
var _local3:Vertex3D;
var _local1:Array = this.geometry.vertices;
var _local2:Object = new Object();
_local2.min = new Number3D(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
_local2.max = new Number3D(-(Number.MAX_VALUE), -(Number.MAX_VALUE), -(Number.MAX_VALUE));
_local2.size = new Number3D();
for each (_local3 in _local1) {
_local2.min.x = Math.min(_local3.x, _local2.min.x);
_local2.min.y = Math.min(_local3.y, _local2.min.y);
_local2.min.z = Math.min(_local3.z, _local2.min.z);
_local2.max.x = Math.max(_local3.x, _local2.max.x);
_local2.max.y = Math.max(_local3.y, _local2.max.y);
_local2.max.z = Math.max(_local3.z, _local2.max.z);
};
_local2.size.x = (_local2.max.x - _local2.min.x);
_local2.size.y = (_local2.max.y - _local2.min.y);
_local2.size.z = (_local2.max.z - _local2.min.z);
return (_local2);
}
public function projectFrustum(_arg1:DisplayObject3D, _arg2:RenderSessionData):Number{
return (0);
}
public function transformVertices(_arg1:Matrix3D):void{
geometry.transformVertices(_arg1);
}
override public function clone():DisplayObject3D{
var _local1:DisplayObject3D = super.clone();
var _local2:Vertices3D = new Vertices3D(null, _local1.name);
_local2.material = _local1.material;
if (_local1.materials){
_local2.materials = _local1.materials.clone();
};
if (this.geometry){
_local2.geometry = this.geometry.clone(_local2);
};
_local2.copyTransform(this);
return (_local2);
}
}
}//package org.papervision3d.core.geom
Section 78
//PaperLoggerEvent (org.papervision3d.core.log.event.PaperLoggerEvent)
package org.papervision3d.core.log.event {
import flash.events.*;
import org.papervision3d.core.log.*;
public class PaperLoggerEvent extends Event {
public var paperLogVO:PaperLogVO;
public static const TYPE_LOGEVENT:String = "logEvent";
public function PaperLoggerEvent(_arg1:PaperLogVO){
super(TYPE_LOGEVENT);
this.paperLogVO = _arg1;
}
}
}//package org.papervision3d.core.log.event
Section 79
//AbstractPaperLogger (org.papervision3d.core.log.AbstractPaperLogger)
package org.papervision3d.core.log {
import org.papervision3d.core.log.event.*;
public class AbstractPaperLogger implements IPaperLogger {
public function registerWithPaperLogger(_arg1:PaperLogger):void{
_arg1.addEventListener(PaperLoggerEvent.TYPE_LOGEVENT, onLogEvent);
}
public function debug(_arg1:String, _arg2:Object=null, _arg3:Array=null):void{
}
public function 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 80
//IPaperLogger (org.papervision3d.core.log.IPaperLogger)
package org.papervision3d.core.log {
public interface IPaperLogger {
function debug(_arg1:String, _arg2:Object=null, _arg3:Array=null):void;
function log(_arg1:String, _arg2:Object=null, _arg3:Array=null):void;
function error(_arg1:String, _arg2:Object=null, _arg3:Array=null):void;
function fatal(_arg1:String, _arg2:Object=null, _arg3:Array=null):void;
function warning(_arg1:String, _arg2:Object=null, _arg3:Array=null):void;
function info(_arg1:String, _arg2:Object=null, _arg3:Array=null):void;
}
}//package org.papervision3d.core.log
Section 81
//LogLevel (org.papervision3d.core.log.LogLevel)
package org.papervision3d.core.log {
public class LogLevel {
public static const FATAL:int = 5;
public static const ERROR:int = 4;
public static const LOG:int = 0;
public static const INFO:int = 1;
public static const DEBUG:int = 2;
public static const WARNING:int = 3;
}
}//package org.papervision3d.core.log
Section 82
//PaperLogger (org.papervision3d.core.log.PaperLogger)
package org.papervision3d.core.log {
import flash.events.*;
import org.papervision3d.core.log.event.*;
public class PaperLogger extends EventDispatcher {
public var traceLogger:PaperTraceLogger;
private static var instance:PaperLogger;
public function PaperLogger(){
if (instance){
throw (new Error("Don't call the PaperLogger constructor directly"));
};
traceLogger = new PaperTraceLogger();
registerLogger(traceLogger);
}
public function registerLogger(_arg1:AbstractPaperLogger):void{
_arg1.registerWithPaperLogger(this);
}
public function _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 83
//PaperLogVO (org.papervision3d.core.log.PaperLogVO)
package org.papervision3d.core.log {
public class PaperLogVO {
public var msg:String;
public var level:int;
public var arg:Array;
public var object:Object;
public function PaperLogVO(_arg1:int, _arg2:String, _arg3:Object, _arg4:Array){
this.level = _arg1;
this.msg = _arg2;
this.object = _arg3;
this.arg = _arg4;
}
}
}//package org.papervision3d.core.log
Section 84
//PaperTraceLogger (org.papervision3d.core.log.PaperTraceLogger)
package org.papervision3d.core.log {
public class PaperTraceLogger extends AbstractPaperLogger implements IPaperLogger {
override public function 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 85
//AbstractLightShadeMaterial (org.papervision3d.core.material.AbstractLightShadeMaterial)
package org.papervision3d.core.material {
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.math.*;
import org.papervision3d.materials.utils.*;
import org.papervision3d.core.render.material.*;
import flash.utils.*;
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 86
//TriangleMaterial (org.papervision3d.core.material.TriangleMaterial)
package org.papervision3d.core.material {
import flash.display.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.core.render.command.*;
import flash.geom.*;
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 87
//ClassificationUtil (org.papervision3d.core.math.util.ClassificationUtil)
package org.papervision3d.core.math.util {
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.math.*;
public class ClassificationUtil {
public static const BACK:uint = 1;
public static const STRADDLE:uint = 3;
public static const FRONT:uint = 0;
public static const COINCIDING:uint = 2;
protected static var point:Vertex3D;
public static function classifyPoint(_arg1:Vertex3D, _arg2:Plane3D, _arg3:Number=0.01):uint{
var _local4:Number = _arg2.vertDistance(_arg1);
if (_local4 < -(_arg3)){
return (BACK);
};
if (_local4 > _arg3){
return (FRONT);
};
return (COINCIDING);
}
public static function classifyTriangle(_arg1:Triangle3D, _arg2:Plane3D, _arg3:Number=0.01):uint{
if (!_arg1){
return (null);
};
return (classifyPoints(_arg1.vertices, _arg2, _arg3));
}
public static function classifyPoints(_arg1:Array, _arg2:Plane3D, _arg3:Number=0.01):uint{
var _local6:uint;
var _local4:uint;
var _local5:uint;
for each (point in _arg1) {
_local6 = classifyPoint(point, _arg2, _arg3);
if (_local6 == FRONT){
_local4++;
} else {
if (_local6 == BACK){
_local5++;
};
};
};
if ((((_local4 > 0)) && ((_local5 == 0)))){
return (FRONT);
};
if ((((_local4 == 0)) && ((_local5 > 0)))){
return (BACK);
};
if ((((_local4 > 0)) && ((_local5 > 0)))){
return (STRADDLE);
};
return (COINCIDING);
}
}
}//package org.papervision3d.core.math.util
Section 88
//FastRectangleTools (org.papervision3d.core.math.util.FastRectangleTools)
package org.papervision3d.core.math.util {
import org.papervision3d.core.math.*;
import flash.geom.*;
public class FastRectangleTools {
public static function getRotatedBounds(_arg1:Rectangle, _arg2:Number, _arg3:Rectangle=null):Rectangle{
if (!_arg3){
_arg3 = new Rectangle();
};
_arg2 = (_arg2 * Number3D.toRADIANS);
var _local4:Number = _arg1.width;
var _local5:Number = _arg1.height;
var _local6:Number = Math.abs(Math.sin(_arg2));
var _local7:Number = Math.abs(Math.cos(_arg2));
_arg3.left = (_arg1.x - (0.5 * ((_local4 * _local7) + (_local5 * _local6))));
_arg3.right = (_arg1.x + (0.5 * ((_local4 * _local7) + (_local5 * _local6))));
_arg3.top = (_arg1.y - (0.5 * ((_local4 * _local6) + (_local5 * _local7))));
_arg3.bottom = (_arg1.y + (0.5 * ((_local4 * _local6) + (_local5 * _local7))));
return (_arg3);
}
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))))) && (!((((_arg1.bottom < _arg2.top)) || ((_arg1.top > _arg2.bottom))))))){
return (true);
};
return (false);
}
}
}//package org.papervision3d.core.math.util
Section 89
//GLU (org.papervision3d.core.math.util.GLU)
package org.papervision3d.core.math.util {
public class GLU {
public static function unProject(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Array, _arg5:Array, _arg6:Array, _arg7:Array):Boolean{
var _local8:Array = new Array(16);
var _local9:Array = new Array(4);
multMatrices(_arg4, _arg5, _local8);
if (!invertMatrix(_local8, _local8)){
return (false);
};
_local9[0] = _arg1;
_local9[1] = _arg2;
_local9[2] = _arg3;
_local9[3] = 1;
_local9[0] = ((_local9[0] - _arg6[0]) / _arg6[2]);
_local9[1] = ((_local9[1] - _arg6[1]) / _arg6[3]);
_local9[0] = ((_local9[0] * 2) - 1);
_local9[1] = ((_local9[1] * 2) - 1);
_local9[2] = ((_local9[2] * 2) - 1);
multMatrixVec(_local8, _local9, _arg7);
if (_arg7[3] == 0){
return (false);
};
_arg7[0] = (_arg7[0] / _arg7[3]);
_arg7[1] = (_arg7[1] / _arg7[3]);
_arg7[2] = (_arg7[2] / _arg7[3]);
return (true);
}
public static function scale(_arg1:Array, _arg2:Number, _arg3:Number, _arg4:Number):void{
makeIdentity(_arg1);
_arg1[0] = _arg2;
_arg1[5] = _arg3;
_arg1[10] = _arg4;
}
public static function multMatrixVec(_arg1:Array, _arg2:Array, _arg3:Array):void{
var _local4:int;
_local4 = 0;
while (_local4 < 4) {
_arg3[_local4] = ((((_arg2[0] * _arg1[int(((0 * 4) + _local4))]) + (_arg2[1] * _arg1[int(((1 * 4) + _local4))])) + (_arg2[2] * _arg1[int(((2 * 4) + _local4))])) + (_arg2[3] * _arg1[int(((3 * 4) + _local4))]));
_local4++;
};
}
public static function invertMatrix(_arg1:Array, _arg2:Array):Boolean{
var _local3:int;
var _local4:int;
var _local5:int;
var _local6:int;
var _local7:Number;
var _local8:Array = new Array(4);
_local3 = 0;
while (_local3 < 4) {
_local8[_local3] = new Array(4);
_local4 = 0;
while (_local4 < 4) {
_local8[_local3][_local4] = _arg1[((_local3 * 4) + _local4)];
_local4++;
};
_local3++;
};
makeIdentity(_arg2);
_local3 = 0;
while (_local3 < 4) {
_local6 = _local3;
_local4 = (_local3 + 1);
while (_local4 < 4) {
if (Math.abs(_local8[_local4][_local3]) > Math.abs(_local8[_local3][_local3])){
_local6 = _local4;
};
_local4++;
};
if (_local6 != _local3){
_local5 = 0;
while (_local5 < 4) {
_local7 = _local8[_local3][_local5];
_local8[_local3][_local5] = _local8[_local6][_local5];
_local8[_local6][_local5] = _local7;
_local7 = _arg2[((_local3 * 4) + _local5)];
_arg2[((_local3 * 4) + _local5)] = _arg2[((_local6 * 4) + _local5)];
_arg2[((_local6 * 4) + _local5)] = _local7;
_local5++;
};
};
if (_local8[_local3][_local3] == 0){
return (false);
};
_local7 = _local8[_local3][_local3];
_local5 = 0;
while (_local5 < 4) {
_local8[_local3][_local5] = (_local8[_local3][_local5] / _local7);
_arg2[((_local3 * 4) + _local5)] = (_arg2[((_local3 * 4) + _local5)] / _local7);
_local5++;
};
_local4 = 0;
while (_local4 < 4) {
if (_local4 != _local3){
_local7 = _local8[_local4][_local3];
_local5 = 0;
while (_local5 < 4) {
_local8[_local4][_local5] = (_local8[_local4][_local5] - (_local8[_local3][_local5] * _local7));
_arg2[((_local4 * 4) + _local5)] = (_arg2[((_local4 * 4) + _local5)] - (_arg2[((_local3 * 4) + _local5)] * _local7));
_local5++;
};
};
_local4++;
};
_local3++;
};
return (true);
}
public static function ortho(_arg1:Array, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:Number, _arg7:Number):Boolean{
var _local8:Number = ((_arg3 + _arg2) / (_arg3 - _arg2));
var _local9:Number = ((_arg4 + _arg5) / (_arg4 - _arg5));
var _local10:Number = ((_arg7 + _arg6) / (_arg7 - _arg6));
makeIdentity(_arg1);
_arg1[0] = (2 / (_arg3 - _arg2));
_arg1[5] = (2 / (_arg4 - _arg5));
_arg1[10] = (-2 / (_arg7 - _arg6));
_arg1[12] = _local8;
_arg1[13] = _local9;
_arg1[14] = _local10;
return (true);
}
public static function multMatrices(_arg1:Array, _arg2:Array, _arg3:Array):void{
var _local4:int;
var _local5:int;
_local4 = 0;
while (_local4 < 4) {
_local5 = 0;
while (_local5 < 4) {
_arg3[int(((_local4 * 4) + _local5))] = ((((_arg1[int(((_local4 * 4) + 0))] * _arg2[int(((0 * 4) + _local5))]) + (_arg1[int(((_local4 * 4) + 1))] * _arg2[int(((1 * 4) + _local5))])) + (_arg1[int(((_local4 * 4) + 2))] * _arg2[int(((2 * 4) + _local5))])) + (_arg1[int(((_local4 * 4) + 3))] * _arg2[int(((3 * 4) + _local5))]));
_local5++;
};
_local4++;
};
}
public static function perspective(_arg1:Array, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number):Boolean{
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number = ((_arg2 / 2) * (Math.PI / 180));
_local8 = (_arg5 - _arg4);
_local6 = Math.sin(_local9);
if ((((((_local8 == 0)) || ((_local6 == 0)))) || ((_arg3 == 0)))){
return (false);
};
_local7 = (Math.cos(_local9) / _local6);
makeIdentity(_arg1);
_arg1[0] = (_local7 / _arg3);
_arg1[5] = _local7;
_arg1[10] = (-((_arg5 + _arg4)) / _local8);
_arg1[11] = -1;
_arg1[14] = (-(((2 * _arg4) * _arg5)) / _local8);
_arg1[15] = 0;
return (true);
}
public static function makeIdentity(_arg1:Array):void{
_arg1[(0 + (4 * 0))] = 1;
_arg1[(0 + (4 * 1))] = 0;
_arg1[(0 + (4 * 2))] = 0;
_arg1[(0 + (4 * 3))] = 0;
_arg1[(1 + (4 * 0))] = 0;
_arg1[(1 + (4 * 1))] = 1;
_arg1[(1 + (4 * 2))] = 0;
_arg1[(1 + (4 * 3))] = 0;
_arg1[(2 + (4 * 0))] = 0;
_arg1[(2 + (4 * 1))] = 0;
_arg1[(2 + (4 * 2))] = 1;
_arg1[(2 + (4 * 3))] = 0;
_arg1[(3 + (4 * 0))] = 0;
_arg1[(3 + (4 * 1))] = 0;
_arg1[(3 + (4 * 2))] = 0;
_arg1[(3 + (4 * 3))] = 1;
}
}
}//package org.papervision3d.core.math.util
Section 90
//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 91
//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 92
//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 93
//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 + _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 94
//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 95
//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 96
//Plane3D (org.papervision3d.core.math.Plane3D)
package org.papervision3d.core.math {
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.math.util.*;
public class Plane3D {
public var d:Number;
public var normal:Number3D;
var eps:Number;// = 0.01
private static var _yUP:Number3D = new Number3D(0, 1, 0);
private static var _zUP:Number3D = new Number3D(0, 0, 1);
protected static var flipPlane:Plane3D = new (Plane3D);
;
public function Plane3D(_arg1:Number3D=null, _arg2:Number3D=null){
if (((_arg1) && (_arg2))){
this.normal = _arg1;
this.d = -(Number3D.dot(_arg1, _arg2));
} else {
this.normal = new Number3D();
this.d = 0;
};
}
public function setCoefficients(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):void{
this.normal.x = _arg1;
this.normal.y = _arg2;
this.normal.z = _arg3;
this.d = _arg4;
normalize();
}
public function setThreePoints(_arg1:Number3D, _arg2:Number3D, _arg3:Number3D):void{
var _local4:Number3D = Number3D.sub(_arg2, _arg1);
var _local5:Number3D = Number3D.sub(_arg3, _arg1);
this.normal = Number3D.cross(_local4, _local5);
this.normal.normalize();
this.d = -(Number3D.dot(normal, _arg1));
}
public function setNormalAndPoint(_arg1:Number3D, _arg2:Number3D):void{
this.normal = _arg1;
this.d = -(Number3D.dot(_arg1, _arg2));
}
public function getFlip():Plane3D{
var _local1:Plane3D = Plane3D.fromThreePoints(new Number3D(), new Number3D(), new Number3D());
_local1.normal.z = -(normal.z);
_local1.normal.y = -(normal.y);
_local1.normal.x = -(normal.x);
_local1.d = d;
return (_local1);
}
public function getTempFlip():Plane3D{
flipPlane.normal.z = -(normal.z);
flipPlane.normal.y = -(normal.y);
flipPlane.normal.x = -(normal.x);
flipPlane.d = d;
return (flipPlane);
}
public function pointOnSide(_arg1:Number3D):int{
var _local2:Number = distance(_arg1);
if (_local2 < 0){
return (ClassificationUtil.BACK);
};
if (_local2 > 0){
return (ClassificationUtil.FRONT);
};
return (ClassificationUtil.COINCIDING);
}
public function closestPointOnPlane(_arg1:Number3D, _arg2:Number3D):Number3D{
var _local3:Number = Number3D.dot(this.normal, Number3D.sub(_arg1, _arg2));
var _local4:Number3D = _arg1.clone();
_arg1.clone().x = (_local4.x - (_local3 * this.normal.x));
_local4.y = (_local4.y - (_local3 * this.normal.y));
_local4.z = (_local4.z - (_local3 * this.normal.z));
return (_local4);
}
public function normalize():void{
var _local1:Number3D = this.normal;
var _local2:Number = Math.sqrt((((_local1.x * _local1.x) + (_local1.y * _local1.y)) + (_local1.z * _local1.z)));
_local1.x = (_local1.x / _local2);
_local1.y = (_local1.y / _local2);
_local1.z = (_local1.z / _local2);
this.d = (this.d / _local2);
}
public function distance(_arg1):Number{
var _local2:Number3D = ((_arg1 is Vertex3D)) ? _arg1.toNumber3D() : _arg1;
return ((Number3D.dot(_local2, normal) + d));
}
public function isCoplanar(_arg1:Plane3D):Boolean{
return ((((((((Math.abs((normal.x - _arg1.normal.x)) < eps)) && ((Math.abs((normal.y - _arg1.normal.y)) < eps)))) && ((Math.abs((normal.z - _arg1.normal.z)) < eps)))) && ((Math.abs((d - _arg1.d)) < eps))));
}
public function getIntersectionLineNumbers(_arg1:Number3D, _arg2:Number3D):Number3D{
var _local3:Number = ((((normal.x * _arg1.x) + (normal.y * _arg1.y)) + (normal.z * _arg1.z)) - d);
var _local4:Number = ((((normal.x * _arg2.x) + (normal.y * _arg2.y)) + (normal.z * _arg2.z)) - d);
var _local5:Number = (((((normal.x * _arg2.x) + (normal.y * _arg2.y)) + (normal.z * _arg2.z)) - d) / (_local4 - _local3));
return (new Number3D((_arg2.x + ((_arg1.x - _arg2.x) * _local5)), (_arg2.y + ((_arg1.y - _arg2.y) * _local5)), (_arg2.z + ((_arg1.z - _arg2.z) * _local5))));
}
public function getIntersectionLine(_arg1:Vertex3D, _arg2:Vertex3D):Vertex3D{
var _local3:Number = ((((normal.x * _arg1.x) + (normal.y * _arg1.y)) + (normal.z * _arg1.z)) - d);
var _local4:Number = ((((normal.x * _arg2.x) + (normal.y * _arg2.y)) + (normal.z * _arg2.z)) - d);
var _local5:Number = (((((normal.x * _arg2.x) + (normal.y * _arg2.y)) + (normal.z * _arg2.z)) - d) / (_local4 - _local3));
return (new Vertex3D((_arg2.x + ((_arg1.x - _arg2.x) * _local5)), (_arg2.y + ((_arg1.y - _arg2.y) * _local5)), (_arg2.z + ((_arg1.z - _arg2.z) * _local5))));
}
public function toString():String{
return ((((((((("[a:" + normal.x) + " b:") + normal.y) + " c:") + normal.z) + " d:") + d) + "]"));
}
public function projectPoints(_arg1:Array, _arg2:Number3D=null):void{
var _local8:*;
var _local3:Number = Number3D.dot(_yUP, this.normal);
var _local4:Number3D = ((Math.abs(_local3) > 0.99)) ? _zUP : _yUP;
var _local5:Number3D = Number3D.cross(_local4, normal);
_local5.normalize();
_local4 = Number3D.cross(normal, _local5);
_local4.normalize();
var _local6:Matrix3D = new Matrix3D([_local5.x, _local4.x, normal.x, 0, _local5.y, _local4.y, normal.y, 0, _local5.z, _local4.z, normal.z, 0, 0, 0, 0, 1]);
if (_arg2){
_local6 = Matrix3D.multiply(Matrix3D.translationMatrix(_arg2.x, _arg2.y, _arg2.z), _local6);
};
var _local7:Number3D = new Number3D();
for each (_local8 in _arg1) {
_local7.x = _local8["x"];
_local7.y = _local8["y"];
_local7.z = _local8["z"];
Matrix3D.multiplyVector(_local6, _local7);
_local8["x"] = _local7.x;
_local8["y"] = _local7.y;
_local8["z"] = _local7.z;
};
}
public function clone():Plane3D{
return (Plane3D.fromCoefficients(this.normal.x, this.normal.y, this.normal.z, this.d));
}
public function isCoplanarOpposite(_arg1:Plane3D):Boolean{
flipPlane.normal.z = -(_arg1.normal.z);
flipPlane.normal.y = -(_arg1.normal.y);
flipPlane.normal.x = -(_arg1.normal.x);
flipPlane.d = _arg1.d;
return (flipPlane.isCoplanar(_arg1));
}
public function vertDistance(_arg1:Vertex3D):Number{
return (((((_arg1.x * normal.x) + (normal.y * _arg1.y)) + (_arg1.z * normal.z)) + d));
}
public static function fromNormalAndPoint(_arg1, _arg2):Plane3D{
var _local3:Number3D = ((_arg1 is Number3D)) ? _arg1 : new Number3D(_arg1.x, _arg1.y, _arg1.z);
var _local4:Number3D = ((_arg2 is Number3D)) ? _arg2 : new Number3D(_arg2.x, _arg2.y, _arg2.z);
return (new Plane3D(_local3, _local4));
}
public static function fromThreePoints(_arg1, _arg2, _arg3):Plane3D{
var _local4:Plane3D = new (Plane3D);
var _local5:Number3D = ((_arg1 is Number3D)) ? _arg1 : new Number3D(_arg1.x, _arg1.y, _arg1.z);
var _local6:Number3D = ((_arg2 is Number3D)) ? _arg2 : new Number3D(_arg2.x, _arg2.y, _arg2.z);
var _local7:Number3D = ((_arg3 is Number3D)) ? _arg3 : new Number3D(_arg3.x, _arg3.y, _arg3.z);
_local4.setThreePoints(_local5, _local6, _local7);
return (_local4);
}
public static function fromCoefficients(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Plane3D{
var _local5:Plane3D = new (Plane3D);
_local5.setCoefficients(_arg1, _arg2, _arg3, _arg4);
return (_local5);
}
}
}//package org.papervision3d.core.math
Section 97
//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 98
//pv3dview (org.papervision3d.core.ns.pv3dview)
package org.papervision3d.core.ns {
public namespace pv3dview;
}//package org.papervision3d.core.ns
Section 99
//CameraObject3D (org.papervision3d.core.proto.CameraObject3D)
package org.papervision3d.core.proto {
import org.papervision3d.core.render.data.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.math.*;
import flash.geom.*;
import org.papervision3d.core.log.*;
import org.papervision3d.core.culling.*;
import org.papervision3d.*;
import org.papervision3d.core.math.util.*;
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, _arg3:Number=0):Number3D{
var _local4:Number3D;
var _local5:Matrix3D;
var _local6:Array;
var _local7:Array;
var _local8:Array;
var _local9:Array;
var _local10:Array;
var _local11:Array;
var _local12:Number;
if (_useProjectionMatrix){
if (!viewport){
return (null);
};
_local5 = this.transform;
_local6 = [(-(viewport.width) / 2), (-(viewport.height) / 2), viewport.width, viewport.height];
_local7 = [_local5.n11, _local5.n21, _local5.n31, _local5.n41, _local5.n12, _local5.n22, _local5.n32, _local5.n42, _local5.n13, _local5.n23, _local5.n33, _local5.n43, _local5.n14, _local5.n24, _local5.n34, _local5.n44];
_local8 = new Array(16);
_local9 = new Array(4);
GLU.invertMatrix(_local7, _local7);
if (_ortho){
_local10 = new Array(16);
_local11 = new Array(16);
GLU.ortho(_local11, (viewport.width / 2), (-(viewport.width) / 2), (-(viewport.height) / 2), (viewport.height / 2), far, near);
GLU.scale(_local10, _orthoScale, _orthoScale, 1);
GLU.multMatrices(_local10, _local11, _local8);
} else {
GLU.perspective(_local8, fov, (viewport.width / viewport.height), -(near), -(far));
};
GLU.unProject(-(_arg1), _arg2, _arg3, _local7, _local8, _local6, _local9);
_local4 = new Number3D();
_local4.x = _local9[0];
_local4.y = _local9[1];
_local4.z = _local9[2];
} else {
_local12 = ((focus * zoom) / focus);
_local4 = new Number3D((_arg1 / _local12), ((yUP) ? -(_arg2) : _arg2 / _local12), 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 100
//DisplayObjectContainer3D (org.papervision3d.core.proto.DisplayObjectContainer3D)
package org.papervision3d.core.proto {
import flash.events.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.log.*;
import flash.utils.*;
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 101
//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.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 102
//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 103
//MaterialObject3D (org.papervision3d.core.proto.MaterialObject3D)
package org.papervision3d.core.proto {
import flash.display.*;
import flash.events.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.render.command.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.render.material.*;
import flash.geom.*;
import org.papervision3d.materials.*;
import flash.utils.*;
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 104
//SceneObject3D (org.papervision3d.core.proto.SceneObject3D)
package org.papervision3d.core.proto {
import org.papervision3d.objects.*;
import org.papervision3d.materials.utils.*;
public class SceneObject3D extends DisplayObjectContainer3D {
public var objects:Array;
public var materials:MaterialsList;
public function SceneObject3D(){
this.objects = new Array();
this.materials = new MaterialsList();
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 105
//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 106
//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 107
//RenderableListItem (org.papervision3d.core.render.command.RenderableListItem)
package org.papervision3d.core.render.command {
import org.papervision3d.core.render.data.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.geom.renderables.*;
import flash.geom.*;
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 108
//RenderLine (org.papervision3d.core.render.command.RenderLine)
package org.papervision3d.core.render.command {
import flash.display.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.math.*;
import flash.geom.*;
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 109
//RenderParticle (org.papervision3d.core.render.command.RenderParticle)
package org.papervision3d.core.render.command {
import flash.display.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.geom.renderables.*;
import flash.geom.*;
import org.papervision3d.materials.special.*;
public class RenderParticle extends RenderableListItem implements IRenderListItem {
public var 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 110
//RenderTriangle (org.papervision3d.core.render.command.RenderTriangle)
package org.papervision3d.core.render.command {
import flash.display.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.math.*;
import flash.geom.*;
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 111
//QuadTree (org.papervision3d.core.render.data.QuadTree)
package org.papervision3d.core.render.data {
import flash.display.*;
import org.papervision3d.core.render.command.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.clipping.draw.*;
public final class QuadTree {
private var _root:QuadTreeNode;
private var _rect:RectangleClipping;
private var _result:Array;
private var _maxlevel:uint;// = 4
private var _maxX:Number;
private var _maxY:Number;
private var _child:RenderableListItem;
private var _children:Array;
private var _minX:Number;
private var _minY:Number;
private var i:int;
private var _clip:Clipping;
private var _center:Array;
private var _except:DisplayObject3D;
public function get maxLevel():uint{
return (_maxlevel);
}
public function remove(_arg1:RenderableListItem):void{
_center = _arg1.quadrant.center;
_center.splice(_center.indexOf(_arg1), 1);
}
public function set maxLevel(_arg1:uint):void{
_maxlevel = _arg1;
if (_root){
_root.maxlevel = _maxlevel;
};
}
public function getOverlaps(_arg1:RenderableListItem, _arg2:DisplayObject3D=null):Array{
_result = [];
_minX = _arg1.minX;
_minY = _arg1.minY;
_maxX = _arg1.maxX;
_maxY = _arg1.maxY;
_except = _arg2;
getList(_arg1.quadrant);
getParent(_arg1.quadrant);
return (_result);
}
public function get clip():Clipping{
return (_clip);
}
public function render(_arg1:RenderSessionData, _arg2:Graphics):void{
_root.render(-(Infinity), _arg1, _arg2);
}
public function list():Array{
_result = [];
_minX = -1000000;
_minY = -1000000;
_maxX = 1000000;
_maxY = 1000000;
_except = null;
getList(_root);
return (_result);
}
public function getRoot():QuadTreeNode{
return (_root);
}
private function getList(_arg1:QuadTreeNode):void{
if (!_arg1){
return;
};
if (((_arg1.onlysourceFlag) && ((_except == _arg1.onlysource)))){
return;
};
if (_minX < _arg1.xdiv){
if (((_arg1.lefttopFlag) && ((_minY < _arg1.ydiv)))){
getList(_arg1.lefttop);
};
if (((_arg1.leftbottomFlag) && ((_maxY > _arg1.ydiv)))){
getList(_arg1.leftbottom);
};
};
if (_maxX > _arg1.xdiv){
if (((_arg1.righttopFlag) && ((_minY < _arg1.ydiv)))){
getList(_arg1.righttop);
};
if (((_arg1.rightbottomFlag) && ((_maxY > _arg1.ydiv)))){
getList(_arg1.rightbottom);
};
};
_children = _arg1.center;
if (_children != null){
i = _children.length;
while (i--) {
_child = _children[i];
if ((((((((((((_except == null)) || (!((_child.instance == _except))))) && ((_child.maxX > _minX)))) && ((_child.minX < _maxX)))) && ((_child.maxY > _minY)))) && ((_child.minY < _maxY)))){
_result.push(_child);
};
};
};
}
private function getParent(_arg1:QuadTreeNode=null):void{
if (!_arg1){
return;
};
_arg1 = _arg1.parent;
if ((((_arg1 == null)) || (((_arg1.onlysourceFlag) && ((_except == _arg1.onlysource)))))){
return;
};
_children = _arg1.center;
if (_children != null){
i = _children.length;
while (i--) {
_child = _children[i];
if ((((((((((((_except == null)) || (!((_child.instance == _except))))) && ((_child.maxX > _minX)))) && ((_child.minX < _maxX)))) && ((_child.maxY > _minY)))) && ((_child.minY < _maxY)))){
_result.push(_child);
};
};
};
getParent(_arg1);
}
public function add(_arg1:RenderableListItem):void{
if (_clip.check(_arg1)){
_root.push(_arg1);
};
}
public function set clip(_arg1:Clipping):void{
_clip = _arg1;
_rect = _clip.asRectangleClipping();
if (!_root){
_root = new QuadTreeNode(((_rect.minX + _rect.maxX) / 2), ((_rect.minY + _rect.maxY) / 2), (_rect.maxX - _rect.minX), (_rect.maxY - _rect.minY), 0, null, _maxlevel);
} else {
_root.reset(((_rect.minX + _rect.maxX) / 2), ((_rect.minY + _rect.maxY) / 2), (_rect.maxX - _rect.minX), (_rect.maxY - _rect.minY), _maxlevel);
};
}
}
}//package org.papervision3d.core.render.data
Section 112
//QuadTreeNode (org.papervision3d.core.render.data.QuadTreeNode)
package org.papervision3d.core.render.data {
import flash.display.*;
import org.papervision3d.core.render.command.*;
import org.papervision3d.objects.*;
import flash.geom.*;
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 113
//RenderHitData (org.papervision3d.core.render.data.RenderHitData)
package org.papervision3d.core.render.data {
import org.papervision3d.core.proto.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.geom.renderables.*;
public class RenderHitData {
public var y:Number;
public var z:Number;
public var endTime:int;// = 0
public var startTime:int;// = 0
public var displayObject3D:DisplayObject3D;
public var hasHit:Boolean;// = false
public var material:MaterialObject3D;
public var renderable:IRenderable;
public var u:Number;
public var v:Number;
public var x:Number;
public function RenderHitData():void{
}
public function clear():void{
startTime = 0;
endTime = 0;
hasHit = false;
displayObject3D = null;
material = null;
renderable = null;
u = 0;
v = 0;
x = 0;
y = 0;
z = 0;
}
public function clone():RenderHitData{
var _local1:RenderHitData = new RenderHitData();
_local1.startTime = startTime;
_local1.endTime = endTime;
_local1.hasHit = hasHit;
_local1.displayObject3D = displayObject3D;
_local1.material = material;
_local1.renderable = renderable;
_local1.u = u;
_local1.v = v;
_local1.x = x;
_local1.y = y;
_local1.z = z;
return (_local1);
}
public function toString():String{
return (((displayObject3D + " ") + renderable));
}
}
}//package org.papervision3d.core.render.data
Section 114
//RenderSessionData (org.papervision3d.core.render.data.RenderSessionData)
package org.papervision3d.core.render.data {
import flash.display.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.view.*;
import org.papervision3d.core.culling.*;
import org.papervision3d.core.render.*;
import org.papervision3d.core.clipping.*;
public class RenderSessionData {
public var container:Sprite;
public var renderer:IRenderEngine;
public var particleCuller:IParticleCuller;
public var viewPort:Viewport3D;
public var triangleCuller:ITriangleCuller;
public var clipping:DefaultClipping;
public var scene:SceneObject3D;
public var renderStatistics:RenderStatistics;
public var renderObjects:Array;
public var camera:CameraObject3D;
public var renderLayers:Array;
public var quadrantTree:QuadTree;
public var sorted:Boolean;
public function RenderSessionData():void{
this.renderStatistics = new RenderStatistics();
}
public function destroy():void{
triangleCuller = null;
particleCuller = null;
viewPort = null;
container = null;
scene = null;
camera = null;
renderer = null;
renderStatistics = null;
renderObjects = null;
renderLayers = null;
clipping = null;
quadrantTree = null;
}
public function clone():RenderSessionData{
var _local1:RenderSessionData = new RenderSessionData();
_local1.triangleCuller = triangleCuller;
_local1.particleCuller = particleCuller;
_local1.viewPort = viewPort;
_local1.container = container;
_local1.scene = scene;
_local1.camera = camera;
_local1.renderer = renderer;
_local1.renderStatistics = renderStatistics.clone();
_local1.clipping = clipping;
_local1.quadrantTree = quadrantTree;
return (_local1);
}
}
}//package org.papervision3d.core.render.data
Section 115
//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 116
//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 117
//IParticleDrawer (org.papervision3d.core.render.draw.IParticleDrawer)
package org.papervision3d.core.render.draw {
import flash.display.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.geom.renderables.*;
public interface IParticleDrawer {
function drawParticle(_arg1:Particle, _arg2:Graphics, _arg3:RenderSessionData):void;
function updateRenderRect(_arg1:Particle):void;
}
}//package org.papervision3d.core.render.draw
Section 118
//ITriangleDrawer (org.papervision3d.core.render.draw.ITriangleDrawer)
package org.papervision3d.core.render.draw {
import flash.display.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.render.command.*;
import flash.geom.*;
public interface ITriangleDrawer {
function drawTriangle(_arg1:RenderTriangle, _arg2:Graphics, _arg3:RenderSessionData, _arg4:BitmapData=null, _arg5:Matrix=null):void;
function drawRT(_arg1:RenderTriangle, _arg2:Graphics, _arg3:RenderSessionData):void;
}
}//package org.papervision3d.core.render.draw
Section 119
//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 120
//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 121
//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 122
//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 123
//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 124
//BasicProjectionPipeline (org.papervision3d.core.render.project.BasicProjectionPipeline)
package org.papervision3d.core.render.project {
import org.papervision3d.core.render.data.*;
import org.papervision3d.objects.*;
public class BasicProjectionPipeline extends ProjectionPipeline {
public function BasicProjectionPipeline(){
init();
}
protected function init():void{
}
override public function project(_arg1:RenderSessionData):void{
var _local3:DisplayObject3D;
var _local5:Number;
_arg1.camera.transformView();
var _local2:Array = _arg1.renderObjects;
var _local4:Number = _local2.length;
if (_arg1.camera.useProjectionMatrix){
for each (_local3 in _local2) {
if (_local3.visible){
if (_arg1.viewPort.viewportObjectFilter){
_local5 = _arg1.viewPort.viewportObjectFilter.testObject(_local3);
if (_local5){
projectObject(_local3, _arg1, _local5);
} else {
_arg1.renderStatistics.filteredObjects++;
};
} else {
projectObject(_local3, _arg1, 1);
};
};
};
} else {
for each (_local3 in _local2) {
if (_local3.visible){
if (_arg1.viewPort.viewportObjectFilter){
_local5 = _arg1.viewPort.viewportObjectFilter.testObject(_local3);
if (_local5){
projectObject(_local3, _arg1, _local5);
} else {
_arg1.renderStatistics.filteredObjects++;
};
} else {
projectObject(_local3, _arg1, 1);
};
};
};
};
}
protected function projectObject(_arg1:DisplayObject3D, _arg2:RenderSessionData, _arg3:Number):void{
_arg1.cullTest = _arg3;
if (_arg1.parent){
_arg1.project((_arg1.parent as DisplayObject3D), _arg2);
} else {
_arg1.project(_arg2.camera, _arg2);
};
}
}
}//package org.papervision3d.core.render.project
Section 125
//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 126
//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 127
//ShaderObjectData (org.papervision3d.core.render.shader.ShaderObjectData)
package org.papervision3d.core.render.shader {
import flash.display.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.geom.renderables.*;
import flash.geom.*;
import org.papervision3d.materials.*;
import org.papervision3d.materials.shaders.*;
import flash.utils.*;
public class ShaderObjectData {
public var shaderRenderer:ShaderRenderer;
public var triangleUVS:Dictionary;
public var renderTriangleUVS:Dictionary;
public var lightMatrices:Dictionary;
public var shadedMaterial:ShadedMaterial;
public var uvMatrices:Dictionary;
private var origin:Point;
public var 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 128
//ShaderRenderer (org.papervision3d.core.render.shader.ShaderRenderer)
package org.papervision3d.core.render.shader {
import flash.display.*;
import flash.events.*;
import org.papervision3d.core.render.data.*;
import flash.geom.*;
import org.papervision3d.materials.shaders.*;
import flash.utils.*;
public class ShaderRenderer extends EventDispatcher implements IShaderRenderer {
public var container:Sprite;
public var 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 129
//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 130
//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 131
//AbstractRenderEngine (org.papervision3d.core.render.AbstractRenderEngine)
package org.papervision3d.core.render {
import flash.events.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.view.*;
import org.papervision3d.core.render.command.*;
public class AbstractRenderEngine extends EventDispatcher implements IRenderEngine {
public function AbstractRenderEngine(_arg1:IEventDispatcher=null){
super(_arg1);
}
public function 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 132
//IRenderEngine (org.papervision3d.core.render.IRenderEngine)
package org.papervision3d.core.render {
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.view.*;
import org.papervision3d.core.render.command.*;
public interface IRenderEngine {
function addToRenderList(_arg1:RenderableListItem):int;
function removeFromRenderList(_arg1:IRenderListItem):int;
function renderScene(_arg1:SceneObject3D, _arg2:CameraObject3D, _arg3:Viewport3D):RenderStatistics;
}
}//package org.papervision3d.core.render
Section 133
//IVirtualMouseEvent (org.papervision3d.core.utils.virtualmouse.IVirtualMouseEvent)
package org.papervision3d.core.utils.virtualmouse {
public interface IVirtualMouseEvent {
}
}//package org.papervision3d.core.utils.virtualmouse
Section 134
//VirtualMouse (org.papervision3d.core.utils.virtualmouse.VirtualMouse)
package org.papervision3d.core.utils.virtualmouse {
import flash.display.*;
import flash.events.*;
import flash.geom.*;
import org.papervision3d.core.log.*;
import flash.utils.*;
public class VirtualMouse extends EventDispatcher {
private var _container:Sprite;
private var _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 = container;
};
var _local7:Point = target.globalToLocal(location);
var _local8:Point = _local4.globalToLocal(location);
if (((!((lastLocation.x == location.x))) || (!((lastLocation.y == location.y))))){
_local9 = false;
if (stage){
_local9 = (((((((location.x >= 0)) && ((location.y >= 0)))) && ((location.x <= stage.stageWidth)))) && ((location.y <= stage.stageHeight)));
};
if (((((!(_local9)) && (lastWithinStage))) && (!(disabledEvents[Event.MOUSE_LEAVE])))){
_lastEvent = new eventEvent(Event.MOUSE_LEAVE, false, false);
stage.dispatchEvent(_lastEvent);
dispatchEvent(_lastEvent);
};
if (((_local9) && (!(disabledEvents[MouseEvent.MOUSE_MOVE])))){
_lastEvent = new mouseEventEvent(MouseEvent.MOUSE_MOVE, true, false, _local8.x, _local8.y, _local4, ctrlKey, altKey, shiftKey, _mouseIsDown, delta);
_local4.dispatchEvent(_lastEvent);
dispatchEvent(_lastEvent);
};
lastWithinStage = _local9;
};
if (_local4 != target){
if (!disabledEvents[MouseEvent.MOUSE_OUT]){
_lastEvent = new mouseEventEvent(MouseEvent.MOUSE_OUT, true, false, _local7.x, _local7.y, _local4, ctrlKey, altKey, shiftKey, _mouseIsDown, delta);
target.dispatchEvent(_lastEvent);
dispatchEvent(_lastEvent);
};
if (!disabledEvents[MouseEvent.ROLL_OUT]){
_lastEvent = new mouseEventEvent(MouseEvent.ROLL_OUT, false, false, _local7.x, _local7.y, _local4, ctrlKey, altKey, shiftKey, _mouseIsDown, delta);
target.dispatchEvent(_lastEvent);
dispatchEvent(_lastEvent);
};
if (!disabledEvents[MouseEvent.MOUSE_OVER]){
_lastEvent = new mouseEventEvent(MouseEvent.MOUSE_OVER, true, false, _local8.x, _local8.y, target, ctrlKey, altKey, shiftKey, _mouseIsDown, delta);
_local4.dispatchEvent(_lastEvent);
dispatchEvent(_lastEvent);
};
if (!disabledEvents[MouseEvent.ROLL_OVER]){
_lastEvent = new mouseEventEvent(MouseEvent.ROLL_OVER, false, false, _local8.x, _local8.y, target, ctrlKey, altKey, shiftKey, _mouseIsDown, delta);
_local4.dispatchEvent(_lastEvent);
dispatchEvent(_lastEvent);
};
};
if (updateMouseDown){
if (_mouseIsDown){
if (!disabledEvents[MouseEvent.MOUSE_DOWN]){
_lastEvent = new mouseEventEvent(MouseEvent.MOUSE_DOWN, true, false, _local8.x, _local8.y, _local4, ctrlKey, altKey, shiftKey, _mouseIsDown, delta);
_local4.dispatchEvent(_lastEvent);
dispatchEvent(_lastEvent);
};
lastDownTarget = _local4;
updateMouseDown = false;
} else {
if (!disabledEvents[MouseEvent.MOUSE_UP]){
_lastEvent = new mouseEventEvent(MouseEvent.MOUSE_UP, true, false, _local8.x, _local8.y, _local4, ctrlKey, altKey, shiftKey, _mouseIsDown, delta);
_local4.dispatchEvent(_lastEvent);
dispatchEvent(_lastEvent);
};
if (((!(disabledEvents[MouseEvent.CLICK])) && ((_local4 == lastDownTarget)))){
_lastEvent = new mouseEventEvent(MouseEvent.CLICK, true, false, _local8.x, _local8.y, _local4, ctrlKey, altKey, shiftKey, _mouseIsDown, delta);
_local4.dispatchEvent(_lastEvent);
dispatchEvent(_lastEvent);
};
lastDownTarget = null;
updateMouseDown = false;
};
};
if (((((isDoubleClickEvent) && (!(disabledEvents[MouseEvent.DOUBLE_CLICK])))) && (_local4.doubleClickEnabled))){
_lastEvent = new mouseEventEvent(MouseEvent.DOUBLE_CLICK, true, false, _local8.x, _local8.y, _local4, ctrlKey, altKey, shiftKey, _mouseIsDown, delta);
_local4.dispatchEvent(_lastEvent);
dispatchEvent(_lastEvent);
};
lastLocation = location.clone();
lastMouseDown = _mouseIsDown;
target = _local4;
}
public function getLocation():Point{
return (location.clone());
}
public function lock():void{
isLocked = true;
}
public function get useNativeEvents():Boolean{
return (_useNativeEvents);
}
public function setLocation(_arg1, _arg2=null):void{
var _local3:Point;
if ((_arg1 is Point)){
_local3 = (_arg1 as Point);
location.x = _local3.x;
location.y = _local3.y;
} else {
location.x = Number(_arg1);
location.y = Number(_arg2);
};
if (!isLocked){
update();
};
}
public function unignore(_arg1:DisplayObject):void{
if ((_arg1 in ignoredInstances)){
delete ignoredInstances[_arg1];
};
}
public function doubleClick():void{
if (isLocked){
release();
} else {
click();
press();
isDoubleClickEvent = true;
release();
isDoubleClickEvent = false;
};
}
public function update():void{
dispatchEvent(new Event(UPDATE, false, false));
}
public function unlock():void{
isLocked = false;
update();
}
public function ignore(_arg1:DisplayObject):void{
ignoredInstances[_arg1] = true;
}
public function enableEvent(_arg1:String):void{
if ((_arg1 in disabledEvents)){
delete disabledEvents[_arg1];
};
}
public function press():void{
updateMouseDown = true;
_mouseIsDown = true;
if (!isLocked){
update();
};
}
public function set useNativeEvents(_arg1:Boolean):void{
if (_arg1 == _useNativeEvents){
return;
};
_useNativeEvents = _arg1;
if (_useNativeEvents){
eventEvent = VirtualMouseEvent;
mouseEventEvent = VirtualMouseMouseEvent;
} else {
eventEvent = Event;
mouseEventEvent = MouseEvent;
};
}
public function set x(_arg1:Number):void{
location.x = _arg1;
if (!isLocked){
update();
};
}
public function set y(_arg1:Number):void{
location.y = _arg1;
if (!isLocked){
update();
};
}
public function get y():Number{
return (location.y);
}
public function set stage(_arg1:Stage):void{
var _local2:Boolean;
if (_stage){
_local2 = true;
_stage.removeEventListener(KeyboardEvent.KEY_DOWN, keyHandler);
_stage.removeEventListener(KeyboardEvent.KEY_UP, keyHandler);
} else {
_local2 = false;
};
_stage = _arg1;
if (_stage){
_stage.addEventListener(KeyboardEvent.KEY_DOWN, keyHandler);
_stage.addEventListener(KeyboardEvent.KEY_UP, keyHandler);
target = _stage;
if (!_local2){
update();
};
};
}
public function get stage():Stage{
return (_stage);
}
public function get x():Number{
return (location.x);
}
}
}//package org.papervision3d.core.utils.virtualmouse
Section 135
//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 136
//VirtualMouseMouseEvent (org.papervision3d.core.utils.virtualmouse.VirtualMouseMouseEvent)
package org.papervision3d.core.utils.virtualmouse {
import flash.display.*;
import flash.events.*;
public class VirtualMouseMouseEvent extends MouseEvent implements IVirtualMouseEvent {
public function VirtualMouseMouseEvent(_arg1:String, _arg2:Boolean=false, _arg3:Boolean=false, _arg4:Number=NaN, _arg5:Number=NaN, _arg6:InteractiveObject=null, _arg7:Boolean=false, _arg8:Boolean=false, _arg9:Boolean=false, _arg10:Boolean=false, _arg11:int=0){
super(_arg1, _arg2, _arg3, _arg4, _arg5, _arg6, _arg7, _arg8, _arg9, _arg10, _arg11);
}
}
}//package org.papervision3d.core.utils.virtualmouse
Section 137
//InteractiveSceneManager (org.papervision3d.core.utils.InteractiveSceneManager)
package org.papervision3d.core.utils {
import flash.display.*;
import flash.events.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.view.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.geom.renderables.*;
import flash.geom.*;
import org.papervision3d.materials.*;
import org.papervision3d.core.utils.virtualmouse.*;
import org.papervision3d.events.*;
public class InteractiveSceneManager extends EventDispatcher {
public var currentMaterial:MaterialObject3D;
public var container:Sprite;
public var currentMousePos:Point;
public var debug:Boolean;// = false
public var mouse3D:Mouse3D;
public var enableOverOut:Boolean;// = true
public var currentDisplayObject3D:DisplayObject3D;
public var _viewportRendered:Boolean;// = false
public var virtualMouse:VirtualMouse;
public var lastMousePos:Point;
public var viewport:Viewport3D;
public var renderHitData:RenderHitData;
public var currentMouseDO3D:DisplayObject3D;// = null
public static var MOUSE_IS_DOWN:Boolean = false;
public function InteractiveSceneManager(_arg1:Viewport3D){
virtualMouse = new VirtualMouse();
mouse3D = new Mouse3D();
currentMousePos = new Point();
lastMousePos = new Point();
super();
this.viewport = _arg1;
this.container = _arg1.containerSprite;
init();
}
protected function handleMouseClick(_arg1:MouseEvent):void{
if ((_arg1 is IVirtualMouseEvent)){
return;
};
if (((renderHitData) && (renderHitData.hasHit))){
dispatchObjectEvent(InteractiveScene3DEvent.OBJECT_CLICK, currentDisplayObject3D);
};
}
protected function handleEnterFrame(_arg1:Event):void{
var _local3:MovieMaterial;
var _local2:Boolean = hasMouseMoved();
if (((_local2) || (_viewportRendered))){
updateRenderHitData();
_viewportRendered = false;
if ((_arg1 is IVirtualMouseEvent)){
return;
};
if (((virtualMouse) && (renderHitData))){
_local3 = (currentMaterial as MovieMaterial);
if (_local3){
virtualMouse.container = (_local3.movie as Sprite);
};
if (virtualMouse.container){
virtualMouse.setLocation(renderHitData.u, renderHitData.v);
};
if (((((Mouse3D.enabled) && (renderHitData))) && (renderHitData.hasHit))){
mouse3D.updatePosition(renderHitData);
};
dispatchObjectEvent(InteractiveScene3DEvent.OBJECT_MOVE, currentDisplayObject3D);
} else {
if (((renderHitData) && (renderHitData.hasHit))){
dispatchObjectEvent(InteractiveScene3DEvent.OBJECT_MOVE, currentDisplayObject3D);
};
};
};
lastMousePos.x = currentMousePos.x;
lastMousePos.y = currentMousePos.y;
}
public function updateAfterRender():void{
_viewportRendered = true;
}
public function initListeners():void{
if (viewport.interactive){
container.addEventListener(MouseEvent.MOUSE_DOWN, handleMousePress, false, 0, true);
container.addEventListener(MouseEvent.MOUSE_UP, handleMouseRelease, false, 0, true);
container.addEventListener(MouseEvent.CLICK, handleMouseClick, false, 0, true);
container.addEventListener(MouseEvent.DOUBLE_CLICK, handleMouseDoubleClick, false, 0, true);
container.stage.addEventListener(Event.ENTER_FRAME, handleEnterFrame, false, 0, true);
};
}
protected function initVirtualMouse():void{
virtualMouse.stage = container.stage;
virtualMouse.container = container;
}
protected function handleMouseOver(_arg1:DisplayObject3D):void{
if (hasMouseMoved()){
dispatchObjectEvent(InteractiveScene3DEvent.OBJECT_OVER, _arg1);
};
}
protected function resolveRenderHitData():void{
renderHitData = (viewport.hitTestPoint2D(currentMousePos) as RenderHitData);
}
public function updateRenderHitData():void{
resolveRenderHitData();
currentDisplayObject3D = renderHitData.displayObject3D;
currentMaterial = renderHitData.material;
manageOverOut();
}
protected function hasMouseMoved():Boolean{
currentMousePos.x = container.mouseX;
currentMousePos.y = container.mouseY;
return (!(currentMousePos.equals(lastMousePos)));
}
protected function dispatchObjectEvent(_arg1:String, _arg2:DisplayObject3D):void{
var _local3:Number;
var _local4:Number;
var _local5:InteractiveScene3DEvent;
if (((renderHitData) && (renderHitData.hasHit))){
_local3 = (renderHitData.u) ? renderHitData.u : 0;
_local4 = (renderHitData.v) ? renderHitData.v : 0;
_local5 = new InteractiveScene3DEvent(_arg1, _arg2, container, (renderHitData.renderable as Triangle3D), _local3, _local4, renderHitData);
_local5.renderHitData = renderHitData;
dispatchEvent(_local5);
_arg2.dispatchEvent(_local5);
} else {
dispatchEvent(new InteractiveScene3DEvent(_arg1, _arg2, container));
if (_arg2){
_arg2.dispatchEvent(new InteractiveScene3DEvent(_arg1, _arg2, container));
};
};
}
protected function handleMouseDoubleClick(_arg1:MouseEvent):void{
if ((_arg1 is IVirtualMouseEvent)){
return;
};
if (((renderHitData) && (renderHitData.hasHit))){
dispatchObjectEvent(InteractiveScene3DEvent.OBJECT_DOUBLE_CLICK, currentDisplayObject3D);
};
}
protected function handleMouseRelease(_arg1:MouseEvent):void{
if ((_arg1 is IVirtualMouseEvent)){
return;
};
MOUSE_IS_DOWN = false;
if (virtualMouse){
virtualMouse.release();
};
if (((((Mouse3D.enabled) && (renderHitData))) && (!((renderHitData.renderable == null))))){
mouse3D.updatePosition(renderHitData);
};
if (((renderHitData) && (renderHitData.hasHit))){
dispatchObjectEvent(InteractiveScene3DEvent.OBJECT_RELEASE, currentDisplayObject3D);
};
}
protected function handleAddedToStage(_arg1:Event):void{
container.removeEventListener(Event.ADDED_TO_STAGE, handleAddedToStage);
initVirtualMouse();
initListeners();
}
protected function handleMouseOut(_arg1:DisplayObject3D):void{
var _local2:MovieMaterial;
if (!hasMouseMoved()){
return;
};
if (_arg1){
_local2 = (_arg1.material as MovieMaterial);
if (_local2){
virtualMouse.exitContainer();
};
};
dispatchObjectEvent(InteractiveScene3DEvent.OBJECT_OUT, _arg1);
}
protected function manageOverOut():void{
if (!enableOverOut){
return;
};
if (((renderHitData) && (renderHitData.hasHit))){
if (((!(currentMouseDO3D)) && (currentDisplayObject3D))){
handleMouseOver(currentDisplayObject3D);
currentMouseDO3D = currentDisplayObject3D;
} else {
if (((currentMouseDO3D) && (!((currentMouseDO3D == currentDisplayObject3D))))){
handleMouseOut(currentMouseDO3D);
handleMouseOver(currentDisplayObject3D);
currentMouseDO3D = currentDisplayObject3D;
};
};
} else {
if (currentMouseDO3D != null){
handleMouseOut(currentMouseDO3D);
currentMouseDO3D = null;
};
};
}
public function destroy():void{
viewport = null;
renderHitData = null;
currentDisplayObject3D = null;
currentMaterial = null;
currentMouseDO3D = null;
virtualMouse.stage = null;
virtualMouse.container = null;
container.removeEventListener(MouseEvent.MOUSE_DOWN, handleMousePress);
container.removeEventListener(MouseEvent.MOUSE_UP, handleMouseRelease);
container.removeEventListener(MouseEvent.CLICK, handleMouseClick);
container.removeEventListener(MouseEvent.DOUBLE_CLICK, handleMouseDoubleClick);
if (container.stage){
container.stage.removeEventListener(Event.ENTER_FRAME, handleEnterFrame);
};
container = null;
}
public function init():void{
if (container){
if (container.stage){
initVirtualMouse();
initListeners();
} else {
container.addEventListener(Event.ADDED_TO_STAGE, handleAddedToStage, false, 0, true);
};
};
}
protected function handleMousePress(_arg1:MouseEvent):void{
if ((_arg1 is IVirtualMouseEvent)){
return;
};
MOUSE_IS_DOWN = true;
if (virtualMouse){
virtualMouse.press();
};
if (((((Mouse3D.enabled) && (renderHitData))) && (!((renderHitData.renderable == null))))){
mouse3D.updatePosition(renderHitData);
};
if (((renderHitData) && (renderHitData.hasHit))){
dispatchObjectEvent(InteractiveScene3DEvent.OBJECT_PRESS, currentDisplayObject3D);
};
}
}
}//package org.papervision3d.core.utils
Section 138
//Mouse3D (org.papervision3d.core.utils.Mouse3D)
package org.papervision3d.core.utils {
import org.papervision3d.core.render.data.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.math.*;
public class Mouse3D extends DisplayObject3D {
private var target:Number3D;
public static var enabled:Boolean = false;
private static var UP:Number3D = new Number3D(0, 1, 0);
public function Mouse3D():void{
target = new Number3D();
super();
}
public function updatePosition(_arg1:RenderHitData):void{
var _local3:Matrix3D;
var _local5:Number3D;
var _local6:Number3D;
var _local2:Triangle3D = (_arg1.renderable as Triangle3D);
target.x = _local2.faceNormal.x;
target.y = _local2.faceNormal.y;
target.z = _local2.faceNormal.z;
var _local4:Number3D = Number3D.sub(target, position);
_local4.normalize();
if (_local4.modulo > 0.1){
_local5 = Number3D.cross(_local4, UP);
_local5.normalize();
_local6 = Number3D.cross(_local4, _local5);
_local6.normalize();
_local3 = this.transform;
_local3.n11 = _local5.x;
_local3.n21 = _local5.y;
_local3.n31 = _local5.z;
_local3.n12 = -(_local6.x);
_local3.n22 = -(_local6.y);
_local3.n32 = -(_local6.z);
_local3.n13 = _local4.x;
_local3.n23 = _local4.y;
_local3.n33 = _local4.z;
} else {
_local3 = Matrix3D.IDENTITY;
};
this.transform = Matrix3D.multiply(_local2.instance.world, _local3);
x = _arg1.x;
y = _arg1.y;
z = _arg1.z;
}
}
}//package org.papervision3d.core.utils
Section 139
//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 140
//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 141
//InteractiveScene3DEvent (org.papervision3d.events.InteractiveScene3DEvent)
package org.papervision3d.events {
import flash.display.*;
import flash.events.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.geom.renderables.*;
public class InteractiveScene3DEvent extends Event {
public var y:Number;// = 0
public var sprite:Sprite;// = null
public var renderHitData:RenderHitData;
public var face3d:Triangle3D;// = null
public var x:Number;// = 0
public var displayObject3D:DisplayObject3D;// = null
public static const OBJECT_ADDED:String = "objectAdded";
public static const OBJECT_PRESS:String = "mousePress";
public static const OBJECT_RELEASE:String = "mouseRelease";
public static const OBJECT_CLICK:String = "mouseClick";
public static const OBJECT_RELEASE_OUTSIDE:String = "mouseReleaseOutside";
public static const OBJECT_OUT:String = "mouseOut";
public static const OBJECT_MOVE:String = "mouseMove";
public static const OBJECT_OVER:String = "mouseOver";
public static const OBJECT_DOUBLE_CLICK:String = "mouseDoubleClick";
public function InteractiveScene3DEvent(_arg1:String, _arg2:DisplayObject3D=null, _arg3:Sprite=null, _arg4:Triangle3D=null, _arg5:Number=0, _arg6:Number=0, _arg7:RenderHitData=null, _arg8:Boolean=false, _arg9:Boolean=false){
super(_arg1, _arg8, _arg9);
this.displayObject3D = _arg2;
this.sprite = _arg3;
this.face3d = _arg4;
this.x = _arg5;
this.y = _arg6;
this.renderHitData = _arg7;
}
override public function toString():String{
return (((((((("Type : " + type) + ", DO3D : ") + displayObject3D) + " Sprite : ") + sprite) + " Face : ") + face3d));
}
}
}//package org.papervision3d.events
Section 142
//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 143
//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 144
//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 145
//IShader (org.papervision3d.materials.shaders.IShader)
package org.papervision3d.materials.shaders {
import flash.display.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.render.shader.*;
public interface IShader {
function updateAfterRender(_arg1:RenderSessionData, _arg2:ShaderObjectData):void;
function destroy():void;
function renderLayer(_arg1:Triangle3D, _arg2:RenderSessionData, _arg3:ShaderObjectData):void;
function renderTri(_arg1:Triangle3D, _arg2:RenderSessionData, _arg3:ShaderObjectData, _arg4:BitmapData):void;
}
}//package org.papervision3d.materials.shaders
Section 146
//ShadedMaterial (org.papervision3d.materials.shaders.ShadedMaterial)
package org.papervision3d.materials.shaders {
import flash.display.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.render.command.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.render.material.*;
import flash.geom.*;
import org.papervision3d.core.render.shader.*;
import org.papervision3d.materials.*;
import org.papervision3d.core.log.*;
import flash.utils.*;
import org.papervision3d.core.render.draw.*;
import org.papervision3d.core.material.*;
public class ShadedMaterial extends TriangleMaterial implements ITriangleDrawer, IUpdateBeforeMaterial, IUpdateAfterMaterial {
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 147
//Shader (org.papervision3d.materials.shaders.Shader)
package org.papervision3d.materials.shaders {
import flash.display.*;
import flash.events.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.render.shader.*;
import flash.utils.*;
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 148
//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 149
//CompositeMaterial (org.papervision3d.materials.special.CompositeMaterial)
package org.papervision3d.materials.special {
import flash.display.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.core.render.command.*;
import org.papervision3d.objects.*;
import flash.geom.*;
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 150
//LineMaterial (org.papervision3d.materials.special.LineMaterial)
package org.papervision3d.materials.special {
import flash.display.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.core.render.command.*;
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 151
//ParticleMaterial (org.papervision3d.materials.special.ParticleMaterial)
package org.papervision3d.materials.special {
import flash.display.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.core.geom.renderables.*;
import flash.geom.*;
import org.papervision3d.core.log.*;
import org.papervision3d.core.render.draw.*;
public class ParticleMaterial extends MaterialObject3D implements IParticleDrawer {
public var shape:int;
public 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 152
//LightMatrix (org.papervision3d.materials.utils.LightMatrix)
package org.papervision3d.materials.utils {
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.math.*;
import org.papervision3d.*;
import org.papervision3d.lights.*;
public class LightMatrix {
private static var _targetPos:Number3D = new Number3D();
private static var _lightUp:Number3D = new Number3D();
private static var _lightSide:Number3D = new Number3D();
private static var _lightDir:Number3D = new Number3D();
private static var lightMatrix:Matrix3D = Matrix3D.IDENTITY;
private static var invMatrix:Matrix3D = Matrix3D.IDENTITY;
protected static var UP:Number3D = new Number3D(0, 1, 0);
private static var _lightPos:Number3D = new Number3D();
public static function getLightMatrix(_arg1:LightObject3D, _arg2:DisplayObject3D, _arg3:RenderSessionData, _arg4:Matrix3D):Matrix3D{
var _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();
if (!_arg2){
return (_local5);
};
_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 153
//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 154
//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 155
//RenderRecStorage (org.papervision3d.materials.utils.RenderRecStorage)
package org.papervision3d.materials.utils {
import org.papervision3d.core.geom.renderables.*;
import flash.geom.*;
public class RenderRecStorage {
public var mat:Matrix;
public var v0:Vertex3DInstance;
public var v1:Vertex3DInstance;
public var v2:Vertex3DInstance;
public function RenderRecStorage(){
v0 = new Vertex3DInstance();
v1 = new Vertex3DInstance();
v2 = new Vertex3DInstance();
mat = new Matrix();
super();
}
}
}//package org.papervision3d.materials.utils
Section 156
//BitmapMaterial (org.papervision3d.materials.BitmapMaterial)
package org.papervision3d.materials {
import flash.display.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.core.render.command.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.materials.utils.*;
import flash.geom.*;
import org.papervision3d.core.log.*;
import flash.utils.*;
import org.papervision3d.*;
import org.papervision3d.core.render.draw.*;
import org.papervision3d.core.material.*;
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 157
//MovieMaterial (org.papervision3d.materials.MovieMaterial)
package org.papervision3d.materials {
import flash.display.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.render.command.*;
import org.papervision3d.core.render.material.*;
import flash.geom.*;
import org.papervision3d.core.log.*;
import org.papervision3d.core.render.draw.*;
public class MovieMaterial extends BitmapMaterial implements ITriangleDrawer, IUpdateBeforeMaterial, IUpdateAfterMaterial {
public var movieTransparent:Boolean;
private var quality:String;
private var materialIsUsed:Boolean;// = false
private var stage:Stage;
private var autoClipRect:Rectangle;
public var allowAutoResize:Boolean;// = false
public var movie:DisplayObject;
private var movieAnimated:Boolean;
protected var recreateBitmapInSuper:Boolean;
private var userClipRect:Rectangle;
public function MovieMaterial(_arg1:DisplayObject=null, _arg2:Boolean=false, _arg3:Boolean=false, _arg4:Boolean=false, _arg5:Rectangle=null){
movieTransparent = _arg2;
this.animated = _arg3;
this.precise = _arg4;
userClipRect = _arg5;
if (_arg1){
texture = _arg1;
};
}
protected function createBitmapFromSprite(_arg1:DisplayObject):BitmapData{
movie = _arg1;
initBitmap(movie);
drawBitmap();
bitmap = super.createBitmap(bitmap);
return (bitmap);
}
public function set rect(_arg1:Rectangle):void{
userClipRect = _arg1;
createBitmapFromSprite(movie);
}
public function updateAfterRender(_arg1:RenderSessionData):void{
if ((((movieAnimated == true)) && ((materialIsUsed == true)))){
drawBitmap();
if (recreateBitmapInSuper){
bitmap = super.createBitmap(bitmap);
recreateBitmapInSuper = false;
};
};
}
public function set animated(_arg1:Boolean):void{
movieAnimated = _arg1;
}
public function drawBitmap():void{
var _local3:String;
bitmap.fillRect(bitmap.rect, fillColor);
if (((stage) && (quality))){
_local3 = stage.quality;
stage.quality = quality;
};
var _local1:Rectangle = rect;
var _local2:Matrix = new Matrix(1, 0, 0, 1, -(_local1.x), -(_local1.y));
bitmap.draw(movie, _local2, movie.transform.colorTransform, null);
if (!userClipRect){
autoClipRect = movie.getBounds(movie);
};
if (((stage) && (quality))){
stage.quality = _local3;
};
}
override public function get texture():Object{
return (this._texture);
}
public function updateBeforeRender(_arg1:RenderSessionData):void{
var _local2:int;
var _local3:int;
materialIsUsed = false;
if (movieAnimated){
if (userClipRect){
_local2 = int((userClipRect.width + 0.5));
_local3 = int((userClipRect.height + 0.5));
} else {
_local2 = int((movie.width + 0.5));
_local3 = int((movie.height + 0.5));
};
if (((allowAutoResize) && (((!((_local2 == bitmap.width))) || (!((_local3 == bitmap.height))))))){
initBitmap(movie);
recreateBitmapInSuper = true;
};
};
}
protected function initBitmap(_arg1:DisplayObject):void{
if (bitmap){
bitmap.dispose();
};
if (userClipRect){
bitmap = new BitmapData(int((userClipRect.width + 0.5)), int((userClipRect.height + 0.5)), movieTransparent, fillColor);
} else {
if ((((_arg1.width == 0)) || ((_arg1.height == 0)))){
bitmap = new BitmapData(0x0100, 0x0100, movieTransparent, fillColor);
} else {
bitmap = new BitmapData(int((_arg1.width + 0.5)), int((_arg1.height + 0.5)), movieTransparent, fillColor);
};
};
}
public function get animated():Boolean{
return (movieAnimated);
}
public function get rect():Rectangle{
var _local1:Rectangle = ((userClipRect) || (autoClipRect));
if (((!(_local1)) && (movie))){
_local1 = movie.getBounds(movie);
};
return (_local1);
}
override public function set texture(_arg1:Object):void{
if ((_arg1 is DisplayObject) == false){
PaperLogger.error("MovieMaterial.texture requires a Sprite to be passed as the object");
return;
};
bitmap = createBitmapFromSprite(DisplayObject(_arg1));
_texture = _arg1;
}
override public function drawTriangle(_arg1:RenderTriangle, _arg2:Graphics, _arg3:RenderSessionData, _arg4:BitmapData=null, _arg5:Matrix=null):void{
materialIsUsed = true;
super.drawTriangle(_arg1, _arg2, _arg3, _arg4, _arg5);
}
public function setQuality(_arg1:String, _arg2:Stage, _arg3:Boolean=true):void{
this.quality = _arg1;
this.stage = _arg2;
if (_arg3){
createBitmapFromSprite(movie);
};
}
}
}//package org.papervision3d.materials
Section 158
//WireframeMaterial (org.papervision3d.materials.WireframeMaterial)
package org.papervision3d.materials {
import flash.display.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.render.command.*;
import flash.geom.*;
import org.papervision3d.core.render.draw.*;
import org.papervision3d.core.material.*;
public class WireframeMaterial extends TriangleMaterial implements ITriangleDrawer {
public function WireframeMaterial(_arg1:Number=0xFF00FF, _arg2:Number=1, _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 159
//Cone (org.papervision3d.objects.primitives.Cone)
package org.papervision3d.objects.primitives {
import org.papervision3d.core.proto.*;
public class Cone extends Cylinder {
public function Cone(_arg1:MaterialObject3D=null, _arg2:Number=100, _arg3:Number=100, _arg4:int=8, _arg5:int=6){
super(_arg1, _arg2, _arg3, _arg4, _arg5, 0.0001);
}
}
}//package org.papervision3d.objects.primitives
Section 160
//Cube (org.papervision3d.objects.primitives.Cube)
package org.papervision3d.objects.primitives {
import org.papervision3d.core.proto.*;
import org.papervision3d.core.geom.renderables.*;
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 161
//Cylinder (org.papervision3d.objects.primitives.Cylinder)
package org.papervision3d.objects.primitives {
import org.papervision3d.core.proto.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.math.*;
import org.papervision3d.core.geom.*;
import org.papervision3d.*;
public class Cylinder extends TriangleMesh3D {
public var segmentsH:Number;
public var segmentsW:Number;
public static const DEFAULT_HEIGHT:Number = 100;
public static const DEFAULT_SEGMENTSH:Number = 6;
public static const DEFAULT_SCALE:Number = 1;
public static const DEFAULT_RADIUS:Number = 100;
public static const MIN_SEGMENTSH:Number = 1;
public static const MIN_SEGMENTSW:Number = 3;
public static const DEFAULT_SEGMENTSW:Number = 8;
public function Cylinder(_arg1:MaterialObject3D=null, _arg2:Number=100, _arg3:Number=100, _arg4:int=8, _arg5:int=6, _arg6:Number=-1, _arg7:Boolean=true, _arg8:Boolean=true){
super(_arg1, new Array(), new Array(), null);
this.segmentsW = Math.max(MIN_SEGMENTSW, ((_arg4) || (DEFAULT_SEGMENTSW)));
this.segmentsH = Math.max(MIN_SEGMENTSH, ((_arg5) || (DEFAULT_SEGMENTSH)));
if (_arg2 == 0){
_arg2 = DEFAULT_RADIUS;
};
if (_arg3 == 0){
_arg3 = DEFAULT_HEIGHT;
};
if (_arg6 == -1){
_arg6 = _arg2;
};
var _local9:Number = DEFAULT_SCALE;
buildCylinder(_arg2, _arg3, _arg6, _arg7, _arg8);
}
private function buildCylinder(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Boolean, _arg5:Boolean):void{
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local16:NumberUV;
var _local17:NumberUV;
var _local18:NumberUV;
var _local19:NumberUV;
var _local20:Vertex3D;
var _local21:Vertex3D;
var _local22:Vertex3D;
var _local23:Vertex3D;
var _local24:Number;
var _local25:Number;
var _local26:Number;
var _local27:Array;
var _local28:Vertex3D;
var _local29:Number;
var _local30:Number;
var _local31:Number;
var _local32:int;
var _local33:Boolean;
var _local34:Number;
var _local35:Number;
var _local36:Number;
var _local37:Number;
var _local38:int;
var _local39:Boolean;
var _local6:MaterialObject3D = material;
var _local10:Number = Math.max(MIN_SEGMENTSW, this.segmentsW);
var _local11:Number = Math.max(MIN_SEGMENTSH, this.segmentsH);
var _local12:Array = this.geometry.vertices;
var _local13:Array = this.geometry.faces;
var _local14:Array = new Array();
_local8 = 0;
while (_local8 < (_local11 + 1)) {
_local24 = Number((_local8 / _local11));
_local25 = ((_arg2 * (_local8 / (_local11 + 0))) - (_arg2 / 2));
_local26 = (_arg3 + ((_arg1 - _arg3) * (1 - (_local8 / _local11))));
_local27 = new Array();
_local7 = 0;
while (_local7 < _local10) {
_local29 = Number(((2 * _local7) / _local10));
_local30 = (_local26 * Math.sin((_local29 * Math.PI)));
_local31 = (_local26 * Math.cos((_local29 * Math.PI)));
_local28 = new Vertex3D(_local31, _local25, _local30);
_local12.push(_local28);
_local27.push(_local28);
_local7++;
};
_local14.push(_local27);
_local8++;
};
var _local15:int = _local14.length;
_local8 = 0;
while (_local8 < _local15) {
_local32 = _local14[_local8].length;
_local7 = 0;
while (_local7 < _local32) {
if ((((_local8 > 0)) && ((_local7 >= 0)))){
_local33 = (_local7 == (_local32 - 0));
_local20 = _local14[_local8][(_local33) ? 0 : _local7];
_local21 = _local14[_local8][(((_local7 == 0)) ? _local32 : _local7 - 1)];
_local22 = _local14[(_local8 - 1)][(((_local7 == 0)) ? _local32 : _local7 - 1)];
_local23 = _local14[(_local8 - 1)][(_local33) ? 0 : _local7];
_local34 = (_local8 / _local15);
_local35 = ((_local8 - 1) / _local15);
_local36 = ((_local7 + 1) / _local32);
_local37 = (_local7 / _local32);
_local16 = new NumberUV(_local36, _local35);
_local17 = new NumberUV(_local36, _local34);
_local18 = new NumberUV(_local37, _local34);
_local19 = new NumberUV(_local37, _local35);
_local13.push(new Triangle3D(this, [_local20, _local21, _local22], _local6, [_local17, _local18, _local19]));
_local13.push(new Triangle3D(this, [_local20, _local22, _local23], _local6, [_local17, _local19, _local16]));
};
_local7++;
};
if ((((_local8 == 0)) || ((_local8 == (_local15 - 1))))){
_local7 = 0;
while (_local7 < (_local32 - 2)) {
_local38 = Math.floor((_local7 / 2));
_local20 = _local14[_local8][_local38];
_local21 = (((_local7 % 2))==0) ? _local14[_local8][((_local32 - 2) - _local38)] : _local14[_local8][(_local38 + 1)];
_local22 = (((_local7 % 2))==0) ? _local14[_local8][((_local32 - 1) - _local38)] : _local14[_local8][((_local32 - 2) - _local38)];
_local39 = (_local8 == 0);
_local17 = new NumberUV(((_local39) ? 1 : 0 + ((_local39) ? -1 : 1 * (((_local20.x / _arg1) / 2) + 0.5))), (((_local20.z / _arg1) / 2) + 0.5));
_local18 = new NumberUV(((_local39) ? 1 : 0 + ((_local39) ? -1 : 1 * (((_local21.x / _arg1) / 2) + 0.5))), (((_local21.z / _arg1) / 2) + 0.5));
_local19 = new NumberUV(((_local39) ? 1 : 0 + ((_local39) ? -1 : 1 * (((_local22.x / _arg1) / 2) + 0.5))), (((_local22.z / _arg1) / 2) + 0.5));
if (_local8 == 0){
if (_arg5){
_local13.push(new Triangle3D(this, [_local20, _local22, _local21], _local6, [_local17, _local19, _local18]));
};
} else {
if (_arg4){
_local13.push(new Triangle3D(this, [_local20, _local21, _local22], _local6, [_local17, _local18, _local19]));
};
};
_local7++;
};
};
_local8++;
};
this.geometry.ready = true;
if (Papervision3D.useRIGHTHANDED){
this.geometry.flipFaces();
};
}
}
}//package org.papervision3d.objects.primitives
Section 162
//Sphere (org.papervision3d.objects.primitives.Sphere)
package org.papervision3d.objects.primitives {
import org.papervision3d.core.proto.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.math.*;
import org.papervision3d.core.geom.*;
import org.papervision3d.*;
public class Sphere extends TriangleMesh3D {
private var segmentsH:Number;
private var segmentsW:Number;
public static var MIN_SEGMENTSW:Number = 3;
public static var DEFAULT_SCALE:Number = 1;
public static var DEFAULT_RADIUS:Number = 100;
public static var DEFAULT_SEGMENTSH:Number = 6;
public static var MIN_SEGMENTSH:Number = 2;
public static var DEFAULT_SEGMENTSW:Number = 8;
public function Sphere(_arg1:MaterialObject3D=null, _arg2:Number=100, _arg3:int=8, _arg4:int=6){
super(_arg1, new Array(), new Array(), null);
this.segmentsW = Math.max(MIN_SEGMENTSW, ((_arg3) || (DEFAULT_SEGMENTSW)));
this.segmentsH = Math.max(MIN_SEGMENTSH, ((_arg4) || (DEFAULT_SEGMENTSH)));
if (_arg2 == 0){
_arg2 = DEFAULT_RADIUS;
};
var _local5:Number = DEFAULT_SCALE;
buildSphere(_arg2);
}
private function buildSphere(_arg1:Number):void{
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local11:Triangle3D;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Array;
var _local16:Vertex3D;
var _local17:Number;
var _local18:Number;
var _local19:Number;
var _local20:int;
var _local21:Boolean;
var _local22:Vertex3D;
var _local23:Vertex3D;
var _local24:Vertex3D;
var _local25:Vertex3D;
var _local26:Number;
var _local27:Number;
var _local28:Number;
var _local29:Number;
var _local30:NumberUV;
var _local31:NumberUV;
var _local32:NumberUV;
var _local33:NumberUV;
var _local5:Number = Math.max(3, this.segmentsW);
var _local6:Number = Math.max(2, this.segmentsH);
var _local7:Array = this.geometry.vertices;
var _local8:Array = this.geometry.faces;
var _local9:Array = new Array();
_local3 = 0;
while (_local3 < (_local6 + 1)) {
_local12 = Number((_local3 / _local6));
_local13 = (-(_arg1) * Math.cos((_local12 * Math.PI)));
_local14 = (_arg1 * Math.sin((_local12 * Math.PI)));
_local15 = new Array();
_local2 = 0;
while (_local2 < _local5) {
_local17 = Number(((2 * _local2) / _local5));
_local18 = (_local14 * Math.sin((_local17 * Math.PI)));
_local19 = (_local14 * Math.cos((_local17 * Math.PI)));
if (!(((((_local3 == 0)) || ((_local3 == _local6)))) && ((_local2 > 0)))){
_local16 = new Vertex3D(_local19, _local13, _local18);
_local7.push(_local16);
};
_local15.push(_local16);
_local2++;
};
_local9.push(_local15);
_local3++;
};
var _local10:int = _local9.length;
_local3 = 0;
while (_local3 < _local10) {
_local20 = _local9[_local3].length;
if (_local3 > 0){
_local2 = 0;
while (_local2 < _local20) {
_local21 = (_local2 == (_local20 - 1));
_local22 = _local9[_local3][(_local21) ? 0 : (_local2 + 1)];
_local23 = _local9[_local3][(_local21) ? (_local20 - 1) : _local2];
_local24 = _local9[(_local3 - 1)][(_local21) ? (_local20 - 1) : _local2];
_local25 = _local9[(_local3 - 1)][(_local21) ? 0 : (_local2 + 1)];
_local26 = (_local3 / (_local10 - 1));
_local27 = ((_local3 - 1) / (_local10 - 1));
_local28 = ((_local2 + 1) / _local20);
_local29 = (_local2 / _local20);
_local30 = new NumberUV(_local28, _local27);
_local31 = new NumberUV(_local28, _local26);
_local32 = new NumberUV(_local29, _local26);
_local33 = new NumberUV(_local29, _local27);
if (_local3 < (_local9.length - 1)){
_local8.push(new Triangle3D(this, new Array(_local22, _local23, _local24), material, new Array(_local31, _local32, _local33)));
};
if (_local3 > 1){
_local8.push(new Triangle3D(this, new Array(_local22, _local24, _local25), material, new Array(_local31, _local33, _local30)));
};
_local2++;
};
};
_local3++;
};
for each (_local11 in _local8) {
_local11.renderCommand.create = createRenderTriangle;
};
this.geometry.ready = true;
if (Papervision3D.useRIGHTHANDED){
this.geometry.flipFaces();
};
}
}
}//package org.papervision3d.objects.primitives
Section 163
//DisplayObject3D (org.papervision3d.objects.DisplayObject3D)
package org.papervision3d.objects {
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.view.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.math.*;
import org.papervision3d.materials.utils.*;
import org.papervision3d.materials.shaders.*;
import org.papervision3d.view.layer.*;
import org.papervision3d.core.log.*;
import org.papervision3d.core.data.*;
import org.papervision3d.*;
import org.papervision3d.core.material.*;
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);
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 164
//BasicRenderEngine (org.papervision3d.render.BasicRenderEngine)
package org.papervision3d.render {
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.proto.*;
import org.papervision3d.view.*;
import org.papervision3d.core.render.command.*;
import org.papervision3d.core.render.material.*;
import flash.geom.*;
import org.papervision3d.view.layer.*;
import org.papervision3d.core.render.*;
import org.papervision3d.core.clipping.*;
import org.papervision3d.core.render.project.*;
import org.papervision3d.core.render.filter.*;
import org.papervision3d.core.render.sort.*;
import org.papervision3d.events.*;
import org.papervision3d.core.utils.*;
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 165
//Scene3D (org.papervision3d.scenes.Scene3D)
package org.papervision3d.scenes {
import org.papervision3d.core.proto.*;
public class Scene3D extends SceneObject3D {
}
}//package org.papervision3d.scenes
Section 166
//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 167
//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 168
//ViewportLayer (org.papervision3d.view.layer.ViewportLayer)
package org.papervision3d.view.layer {
import flash.display.*;
import org.papervision3d.view.*;
import org.papervision3d.core.render.command.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.log.*;
import flash.utils.*;
import org.papervision3d.view.layer.util.*;
public class ViewportLayer extends Sprite {
public var layerIndex:Number;
public var layers:Dictionary;
public var 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 169
//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 170
//BitmapViewport3D (org.papervision3d.view.BitmapViewport3D)
package org.papervision3d.view {
import flash.display.*;
import flash.events.*;
import org.papervision3d.core.render.data.*;
import flash.geom.*;
import org.papervision3d.core.view.*;
public class BitmapViewport3D extends Viewport3D implements IViewport3D {
protected var bitmapTransparent:Boolean;
public var _containerBitmap:Bitmap;
protected var _fillBeforeRender:Boolean;// = true
public var bitmapData:BitmapData;
protected var bgColor:int;
public function BitmapViewport3D(_arg1:Number=640, _arg2:Number=480, _arg3:Boolean=false, _arg4:Boolean=false, _arg5:int=0, _arg6:Boolean=false, _arg7:Boolean=true){
super(_arg1, _arg2, _arg3, _arg6, true, _arg7);
this.bgColor = _arg5;
_containerBitmap = new Bitmap();
bitmapData = (_containerBitmap.bitmapData = new BitmapData(Math.round(_arg1), Math.round(_arg2), _arg4, _arg5));
scrollRect = null;
addChild(_containerBitmap);
removeChild(_containerSprite);
}
override public function get autoClipping():Boolean{
return (_autoClipping);
}
override public function set autoClipping(_arg1:Boolean):void{
}
override public function updateAfterRender(_arg1:RenderSessionData):void{
super.updateAfterRender(_arg1);
if (((!((bitmapData.width == Math.round(viewportWidth)))) || (!((bitmapData.height == Math.round(viewportHeight)))))){
bitmapData = (_containerBitmap.bitmapData = new BitmapData(Math.round(viewportWidth), Math.round(viewportHeight), bitmapTransparent, bgColor));
} else {
if (_fillBeforeRender){
bitmapData.fillRect(bitmapData.rect, bgColor);
};
};
var _local2:Matrix = new Matrix();
_local2.translate(_hWidth, _hHeight);
bitmapData.draw(_containerSprite, _local2, null, null, bitmapData.rect, false);
}
public function get fillBeforeRender():Boolean{
return (_fillBeforeRender);
}
override protected function onStageResize(_arg1:Event=null):void{
if (_autoScaleToStage){
viewportWidth = stage.stageWidth;
viewportHeight = stage.stageHeight;
};
}
public function set fillBeforeRender(_arg1:Boolean):void{
_fillBeforeRender = _arg1;
}
}
}//package org.papervision3d.view
Section 171
//Viewport3D (org.papervision3d.view.Viewport3D)
package org.papervision3d.view {
import flash.display.*;
import flash.events.*;
import org.papervision3d.core.render.data.*;
import org.papervision3d.core.render.command.*;
import org.papervision3d.objects.*;
import org.papervision3d.core.geom.renderables.*;
import flash.geom.*;
import org.papervision3d.view.layer.*;
import org.papervision3d.core.log.*;
import flash.utils.*;
import org.papervision3d.core.culling.*;
import org.papervision3d.core.view.*;
import org.papervision3d.core.render.*;
import org.papervision3d.core.utils.*;
public class Viewport3D extends Sprite implements IViewport3D {
public var interactiveSceneManager:InteractiveSceneManager;
public var lastRenderList:Array;
public var cullingRectangle:Rectangle;
protected var _interactive:Boolean;
private var stageScaleModeSet:Boolean;// = false
protected var _autoCulling:Boolean;
protected var _viewportObjectFilter:ViewportObjectFilter;
public var particleCuller:IParticleCuller;
protected var _height:Number;
protected var _width:Number;
public var lineCuller:ILineCuller;
protected var _layerInstances:Dictionary;
protected var _autoScaleToStage:Boolean;
public var triangleCuller:ITriangleCuller;
protected var _lastRenderer:IRenderEngine;
protected var _hWidth:Number;
protected var _containerSprite:ViewportBaseLayer;
protected var _hHeight:Number;
public var sizeRectangle:Rectangle;
protected var renderHitData:RenderHitData;
protected var _autoClipping:Boolean;
public function Viewport3D(_arg1:Number=640, _arg2:Number=480, _arg3:Boolean=false, _arg4:Boolean=false, _arg5:Boolean=true, _arg6:Boolean=true){
init();
this.interactive = _arg4;
this.viewportWidth = _arg1;
this.viewportHeight = _arg2;
this.autoClipping = _arg5;
this.autoCulling = _arg6;
this.autoScaleToStage = _arg3;
this._layerInstances = new Dictionary(true);
}
public function set viewportWidth(_arg1:Number):void{
_width = _arg1;
_hWidth = (_arg1 / 2);
containerSprite.x = _hWidth;
cullingRectangle.x = -(_hWidth);
cullingRectangle.width = _arg1;
sizeRectangle.width = _arg1;
if (_autoClipping){
scrollRect = sizeRectangle;
};
}
public function get autoCulling():Boolean{
return (_autoCulling);
}
protected function onStageResize(_arg1:Event=null):void{
if (_autoScaleToStage){
viewportWidth = stage.stageWidth;
viewportHeight = stage.stageHeight;
};
}
public function set autoCulling(_arg1:Boolean):void{
if (_arg1){
triangleCuller = new RectangleTriangleCuller(cullingRectangle);
particleCuller = new RectangleParticleCuller(cullingRectangle);
lineCuller = new RectangleLineCuller(cullingRectangle);
} else {
if (!_arg1){
triangleCuller = new DefaultTriangleCuller();
particleCuller = new DefaultParticleCuller();
lineCuller = new DefaultLineCuller();
};
};
_autoCulling = _arg1;
}
public function getChildLayer(_arg1:DisplayObject3D, _arg2:Boolean=true, _arg3:Boolean=true):ViewportLayer{
return (containerSprite.getChildLayer(_arg1, _arg2, _arg3));
}
protected function init():void{
this.renderHitData = new RenderHitData();
lastRenderList = new Array();
sizeRectangle = new Rectangle();
cullingRectangle = new Rectangle();
_containerSprite = new ViewportBaseLayer(this);
_containerSprite.doubleClickEnabled = true;
addChild(_containerSprite);
addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
addEventListener(Event.REMOVED_FROM_STAGE, onRemovedFromStage);
}
public function get autoClipping():Boolean{
return (_autoClipping);
}
public function updateAfterRender(_arg1:RenderSessionData):void{
var _local2:ViewportLayer;
if (interactive){
interactiveSceneManager.updateAfterRender();
};
if (_arg1.renderLayers){
for each (_local2 in _arg1.renderLayers) {
_local2.updateInfo();
_local2.sortChildLayers();
_local2.updateAfterRender();
};
} else {
containerSprite.updateInfo();
containerSprite.updateAfterRender();
};
containerSprite.sortChildLayers();
}
protected function onAddedToStage(_arg1:Event):void{
if (_autoScaleToStage){
setStageScaleMode();
};
stage.addEventListener(Event.RESIZE, onStageResize);
onStageResize();
}
public function get containerSprite():ViewportLayer{
return (_containerSprite);
}
public function set autoClipping(_arg1:Boolean):void{
if (_arg1){
scrollRect = sizeRectangle;
} else {
scrollRect = null;
};
_autoClipping = _arg1;
}
protected function setStageScaleMode():void{
if (!stageScaleModeSet){
PaperLogger.info("Viewport autoScaleToStage : Papervision has changed the Stage scale mode.");
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
stageScaleModeSet = true;
};
}
public function accessLayerFor(_arg1:RenderableListItem, _arg2:Boolean=false):ViewportLayer{
var _local3:DisplayObject3D;
if (_arg1.renderableInstance){
_local3 = _arg1.renderableInstance.instance;
_local3 = (_local3.parentContainer) ? _local3.parentContainer : _local3;
if (containerSprite.layers[_local3]){
if (_arg2){
_local3.container = containerSprite.layers[_local3];
};
return (containerSprite.layers[_local3]);
} else {
if (_local3.useOwnContainer){
return (containerSprite.getChildLayer(_local3, true, true));
};
};
};
return (containerSprite);
}
public function get viewportWidth():Number{
return (_width);
}
public function set interactive(_arg1:Boolean):void{
if (_arg1 != _interactive){
if (((_interactive) && (interactiveSceneManager))){
interactiveSceneManager.destroy();
interactiveSceneManager = null;
};
_interactive = _arg1;
if (_arg1){
interactiveSceneManager = new InteractiveSceneManager(this);
};
};
}
public function set viewportObjectFilter(_arg1:ViewportObjectFilter):void{
_viewportObjectFilter = _arg1;
}
public function set autoScaleToStage(_arg1:Boolean):void{
_autoScaleToStage = _arg1;
if (((_arg1) && (!((stage == null))))){
setStageScaleMode();
onStageResize();
};
}
public function set viewportHeight(_arg1:Number):void{
_height = _arg1;
_hHeight = (_arg1 / 2);
containerSprite.y = _hHeight;
cullingRectangle.y = -(_hHeight);
cullingRectangle.height = _arg1;
sizeRectangle.height = _arg1;
if (_autoClipping){
scrollRect = sizeRectangle;
};
}
public function updateBeforeRender(_arg1:RenderSessionData):void{
var _local2:ViewportLayer;
lastRenderList.length = 0;
if (_arg1.renderLayers){
for each (_local2 in _arg1.renderLayers) {
_local2.updateBeforeRender();
};
} else {
_containerSprite.updateBeforeRender();
};
_layerInstances = new Dictionary(true);
}
public function hitTestMouse():RenderHitData{
var _local1:Point = new Point(containerSprite.mouseX, containerSprite.mouseY);
return (hitTestPoint2D(_local1));
}
public function get interactive():Boolean{
return (_interactive);
}
public function get autoScaleToStage():Boolean{
return (_autoScaleToStage);
}
public function hitTestPointObject(_arg1:Point, _arg2:DisplayObject3D):RenderHitData{
var _local3:RenderableListItem;
var _local4:RenderHitData;
var _local5:IRenderListItem;
var _local6:uint;
if (interactive){
_local4 = new RenderHitData();
_local6 = lastRenderList.length;
while ((_local5 = lastRenderList[--_local6])) {
if ((_local5 is RenderableListItem)){
_local3 = (_local5 as RenderableListItem);
if ((_local3.renderableInstance is Triangle3D)){
if (Triangle3D(_local3.renderableInstance).instance != _arg2){
continue;
};
} else {
continue;
};
_local4 = _local3.hitTestPoint2D(_arg1, _local4);
if (_local4.hasHit){
return (_local4);
};
};
};
};
return (new RenderHitData());
}
public function hitTestPoint2D(_arg1:Point):RenderHitData{
var _local2:RenderableListItem;
var _local3:RenderHitData;
var _local4:IRenderListItem;
var _local5:uint;
renderHitData.clear();
if (interactive){
_local3 = renderHitData;
_local5 = lastRenderList.length;
while ((_local4 = lastRenderList[--_local5])) {
if ((_local4 is RenderableListItem)){
_local2 = (_local4 as RenderableListItem);
_local3 = _local2.hitTestPoint2D(_arg1, _local3);
if (_local3.hasHit){
return (_local3);
};
};
};
};
return (renderHitData);
}
protected function onRemovedFromStage(_arg1:Event):void{
stage.removeEventListener(Event.RESIZE, onStageResize);
}
public function get viewportHeight():Number{
return (_height);
}
public function destroy():void{
if (interactiveSceneManager){
interactiveSceneManager.destroy();
interactiveSceneManager = null;
};
lastRenderList = null;
}
public function get viewportObjectFilter():ViewportObjectFilter{
return (_viewportObjectFilter);
}
}
}//package org.papervision3d.view
Section 172
//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 = "March 12th, 2009";
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 = "2.0.0";
public static var usePERCENT:Boolean = false;
}
}//package org.papervision3d
Section 173
//hPCM_SndBack_001 (hPCM_SndBack_001)
package {
import flash.media.*;
public dynamic class hPCM_SndBack_001 extends Sound {
}
}//package
Section 174
//hSound_FarShoot (hSound_FarShoot)
package {
import flash.media.*;
public dynamic class hSound_FarShoot extends Sound {
}
}//package
Section 175
//hSound_HitShoot (hSound_HitShoot)
package {
import flash.media.*;
public dynamic class hSound_HitShoot extends Sound {
}
}//package
Section 176
//hSound_NearShoot (hSound_NearShoot)
package {
import flash.media.*;
public dynamic class hSound_NearShoot extends Sound {
}
}//package
Section 177
//hTestTexture (hTestTexture)
package {
import flash.display.*;
public dynamic class hTestTexture extends BitmapData {
public function hTestTexture(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package