mirror of
https://github.com/MapMakersAndProgrammers/alternativa-editor-mod.git
synced 2025-10-26 09:49:06 -07:00
a3d5 as swc + bug fixes
This commit is contained in:
Binary file not shown.
BIN
libs/Alternativa3D.swc
Normal file
BIN
libs/Alternativa3D.swc
Normal file
Binary file not shown.
@@ -2,8 +2,7 @@
|
||||
<s:TitleWindow xmlns:fx="http://ns.adobe.com/mxml/2009"
|
||||
xmlns:s="library://ns.adobe.com/flex/spark"
|
||||
xmlns:mx="library://ns.adobe.com/flex/mx"
|
||||
width="300" height="200" title="Resizable Title Window"
|
||||
addedToStage="onAddedToStage(event)">
|
||||
width="300" height="200">
|
||||
|
||||
<fx:Script>
|
||||
<![CDATA[
|
||||
@@ -22,10 +21,6 @@
|
||||
|
||||
private var _defaultResizeHandler:Group;
|
||||
|
||||
private function init():void {
|
||||
partAdded("resizeHandle", resizeHandle);
|
||||
}
|
||||
|
||||
private function resizeHandle_mouseDownHandler(event:MouseEvent):void {
|
||||
if (enabled && !clickOffset) {
|
||||
clickOffset = new Point(event.stageX, event.stageY);
|
||||
@@ -75,25 +70,6 @@
|
||||
path.fill = new SolidColor(0x000000);
|
||||
return path;
|
||||
}
|
||||
|
||||
override protected function partAdded(partName:String, instance:Object):void {
|
||||
super.partAdded(partName, instance);
|
||||
if (partName == "resizeHandle" && instance is Group) {
|
||||
resizeHandle = instance as Group;
|
||||
resizeHandle.addEventListener(MouseEvent.MOUSE_DOWN, resizeHandle_mouseDownHandler);
|
||||
}
|
||||
}
|
||||
|
||||
override protected function partRemoved(partName:String, instance:Object):void {
|
||||
if (instance == resizeHandle) {
|
||||
resizeHandle.removeEventListener(MouseEvent.MOUSE_DOWN, resizeHandle_mouseDownHandler);
|
||||
}
|
||||
super.partRemoved(partName, instance);
|
||||
}
|
||||
|
||||
private function onAddedToStage(event:Event):void {
|
||||
init();
|
||||
}
|
||||
]]>
|
||||
</fx:Script>
|
||||
|
||||
|
||||
@@ -567,7 +567,6 @@ package alternativa.editor
|
||||
|
||||
private function onEnterFrame(param1:Event) : void
|
||||
{
|
||||
return;
|
||||
this.cursorScene.containerController.yawLeft(this.keyMapper.keyPressed(0));
|
||||
this.cursorScene.containerController.yawRight(this.keyMapper.keyPressed(1));
|
||||
this.cursorScene.containerController.pitchDown(this.keyMapper.keyPressed(6));
|
||||
|
||||
@@ -150,7 +150,10 @@ package alternativa.editor.prop
|
||||
protected function initBitmapData() : void
|
||||
{
|
||||
this._material = Mesh(this._object).surfaces.peek().material;
|
||||
this.bitmapData = TextureMaterial(this._material).texture.bitmapData;
|
||||
if(_material is TextureMaterial)
|
||||
{
|
||||
this.bitmapData = TextureMaterial(this._material).texture.bitmapData;
|
||||
}
|
||||
}
|
||||
|
||||
public function calculate() : void
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
package alternativa.engine3d
|
||||
{
|
||||
public namespace alternativa3d = "http://alternativaplatform.com/en/alternativa3d";
|
||||
}
|
||||
|
||||
@@ -1,569 +0,0 @@
|
||||
package alternativa.engine3d.controllers
|
||||
{
|
||||
import alternativa.engine3d.*;
|
||||
import alternativa.engine3d.core.Object3D;
|
||||
import alternativa.engine3d.core.Scene3D;
|
||||
import alternativa.engine3d.physics.EllipsoidCollider;
|
||||
import alternativa.types.Map;
|
||||
import alternativa.types.Point3D;
|
||||
import alternativa.utils.ObjectUtils;
|
||||
import flash.display.DisplayObject;
|
||||
import flash.events.KeyboardEvent;
|
||||
import flash.events.MouseEvent;
|
||||
import flash.utils.getTimer;
|
||||
|
||||
use namespace alternativa3d;
|
||||
|
||||
public class ObjectController
|
||||
{
|
||||
public static const ACTION_FORWARD:String = "ACTION_FORWARD";
|
||||
|
||||
public static const ACTION_BACK:String = "ACTION_BACK";
|
||||
|
||||
public static const ACTION_LEFT:String = "ACTION_LEFT";
|
||||
|
||||
public static const ACTION_RIGHT:String = "ACTION_RIGHT";
|
||||
|
||||
public static const ACTION_UP:String = "ACTION_UP";
|
||||
|
||||
public static const ACTION_DOWN:String = "ACTION_DOWN";
|
||||
|
||||
public static const ACTION_PITCH_UP:String = "ACTION_PITCH_UP";
|
||||
|
||||
public static const ACTION_PITCH_DOWN:String = "ACTION_PITCH_DOWN";
|
||||
|
||||
public static const ACTION_YAW_LEFT:String = "ACTION_YAW_LEFT";
|
||||
|
||||
public static const ACTION_YAW_RIGHT:String = "ACTION_YAW_RIGHT";
|
||||
|
||||
public static const ACTION_ACCELERATE:String = "ACTION_ACCELERATE";
|
||||
|
||||
public static const ACTION_MOUSE_LOOK:String = "ACTION_MOUSE_LOOK";
|
||||
|
||||
protected var _forward:Boolean;
|
||||
|
||||
protected var _back:Boolean;
|
||||
|
||||
protected var _left:Boolean;
|
||||
|
||||
protected var _right:Boolean;
|
||||
|
||||
protected var _up:Boolean;
|
||||
|
||||
protected var _down:Boolean;
|
||||
|
||||
protected var _pitchUp:Boolean;
|
||||
|
||||
protected var _pitchDown:Boolean;
|
||||
|
||||
protected var _yawLeft:Boolean;
|
||||
|
||||
protected var _yawRight:Boolean;
|
||||
|
||||
protected var _accelerate:Boolean;
|
||||
|
||||
protected var _mouseLookActive:Boolean;
|
||||
|
||||
protected var startMouseCoords:Point3D;
|
||||
|
||||
protected var _enabled:Boolean = true;
|
||||
|
||||
protected var _eventsSource:DisplayObject;
|
||||
|
||||
protected var keyBindings:Map;
|
||||
|
||||
protected var actionBindings:Map;
|
||||
|
||||
protected var _keyboardEnabled:Boolean;
|
||||
|
||||
protected var _mouseEnabled:Boolean;
|
||||
|
||||
protected var _mouseSensitivity:Number = 1;
|
||||
|
||||
protected var _mouseSensitivityY:Number = 0.008726646259971648;
|
||||
|
||||
protected var _mouseSensitivityX:Number = 0.008726646259971648;
|
||||
|
||||
protected var _mouseCoefficientY:Number;
|
||||
|
||||
protected var _mouseCoefficientX:Number;
|
||||
|
||||
protected var _pitchSpeed:Number = 1;
|
||||
|
||||
protected var _yawSpeed:Number = 1;
|
||||
|
||||
protected var _speed:Number = 100;
|
||||
|
||||
protected var _speedMultiplier:Number = 2;
|
||||
|
||||
protected var _object:Object3D;
|
||||
|
||||
protected var lastFrameTime:uint;
|
||||
|
||||
protected var _coords:Point3D;
|
||||
|
||||
protected var _isMoving:Boolean;
|
||||
|
||||
protected var _collider:EllipsoidCollider;
|
||||
|
||||
public var checkCollisions:Boolean;
|
||||
|
||||
public var onStartMoving:Function;
|
||||
|
||||
public var onStopMoving:Function;
|
||||
|
||||
private var _displacement:Point3D;
|
||||
|
||||
public function ObjectController(param1:DisplayObject)
|
||||
{
|
||||
this.startMouseCoords = new Point3D();
|
||||
this.keyBindings = new Map();
|
||||
this.actionBindings = new Map();
|
||||
this._mouseCoefficientY = this._mouseSensitivity * this._mouseSensitivityY;
|
||||
this._mouseCoefficientX = this._mouseSensitivity * this._mouseSensitivityX;
|
||||
this._coords = new Point3D();
|
||||
this._collider = new EllipsoidCollider();
|
||||
this._displacement = new Point3D();
|
||||
super();
|
||||
if(param1 == null)
|
||||
{
|
||||
throw new ArgumentError(ObjectUtils.getClassName(this) + ": eventsSourceObject is null");
|
||||
}
|
||||
this._eventsSource = param1;
|
||||
this.actionBindings[ACTION_FORWARD] = this.moveForward;
|
||||
this.actionBindings[ACTION_BACK] = this.moveBack;
|
||||
this.actionBindings[ACTION_LEFT] = this.moveLeft;
|
||||
this.actionBindings[ACTION_RIGHT] = this.moveRight;
|
||||
this.actionBindings[ACTION_UP] = this.moveUp;
|
||||
this.actionBindings[ACTION_DOWN] = this.moveDown;
|
||||
this.actionBindings[ACTION_PITCH_UP] = this.pitchUp;
|
||||
this.actionBindings[ACTION_PITCH_DOWN] = this.pitchDown;
|
||||
this.actionBindings[ACTION_YAW_LEFT] = this.yawLeft;
|
||||
this.actionBindings[ACTION_YAW_RIGHT] = this.yawRight;
|
||||
this.actionBindings[ACTION_ACCELERATE] = this.accelerate;
|
||||
this.actionBindings[ACTION_MOUSE_LOOK] = this.setMouseLook;
|
||||
this.keyboardEnabled = true;
|
||||
this.mouseEnabled = true;
|
||||
}
|
||||
|
||||
public function get enabled() : Boolean
|
||||
{
|
||||
return this._enabled;
|
||||
}
|
||||
|
||||
public function set enabled(param1:Boolean) : void
|
||||
{
|
||||
this._enabled = param1;
|
||||
if(this._enabled)
|
||||
{
|
||||
if(this._mouseEnabled)
|
||||
{
|
||||
this.registerMouseListeners();
|
||||
}
|
||||
if(this._keyboardEnabled)
|
||||
{
|
||||
this.registerKeyboardListeners();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(this._mouseEnabled)
|
||||
{
|
||||
this.unregisterMouseListeners();
|
||||
this.setMouseLook(false);
|
||||
}
|
||||
if(this._keyboardEnabled)
|
||||
{
|
||||
this.unregisterKeyboardListeners();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function get coords() : Point3D
|
||||
{
|
||||
return this._coords.clone();
|
||||
}
|
||||
|
||||
public function set coords(param1:Point3D) : void
|
||||
{
|
||||
this._coords.copy(param1);
|
||||
this.setObjectCoords();
|
||||
}
|
||||
|
||||
public function readCoords(param1:Point3D) : void
|
||||
{
|
||||
param1.copy(this._coords);
|
||||
}
|
||||
|
||||
public function get object() : Object3D
|
||||
{
|
||||
return this._object;
|
||||
}
|
||||
|
||||
public function set object(param1:Object3D) : void
|
||||
{
|
||||
this._object = param1;
|
||||
this._collider.scene = this._object == null ? null : this._object.scene;
|
||||
this.setObjectCoords();
|
||||
}
|
||||
|
||||
public function get collider() : EllipsoidCollider
|
||||
{
|
||||
return this._collider;
|
||||
}
|
||||
|
||||
public function moveForward(param1:Boolean) : void
|
||||
{
|
||||
this._forward = param1;
|
||||
}
|
||||
|
||||
public function moveBack(param1:Boolean) : void
|
||||
{
|
||||
this._back = param1;
|
||||
}
|
||||
|
||||
public function moveLeft(param1:Boolean) : void
|
||||
{
|
||||
this._left = param1;
|
||||
}
|
||||
|
||||
public function moveRight(param1:Boolean) : void
|
||||
{
|
||||
this._right = param1;
|
||||
}
|
||||
|
||||
public function moveUp(param1:Boolean) : void
|
||||
{
|
||||
this._up = param1;
|
||||
}
|
||||
|
||||
public function moveDown(param1:Boolean) : void
|
||||
{
|
||||
this._down = param1;
|
||||
}
|
||||
|
||||
public function pitchUp(param1:Boolean) : void
|
||||
{
|
||||
this._pitchUp = param1;
|
||||
}
|
||||
|
||||
public function pitchDown(param1:Boolean) : void
|
||||
{
|
||||
this._pitchDown = param1;
|
||||
}
|
||||
|
||||
public function yawLeft(param1:Boolean) : void
|
||||
{
|
||||
this._yawLeft = param1;
|
||||
}
|
||||
|
||||
public function yawRight(param1:Boolean) : void
|
||||
{
|
||||
this._yawRight = param1;
|
||||
}
|
||||
|
||||
public function accelerate(param1:Boolean) : void
|
||||
{
|
||||
this._accelerate = param1;
|
||||
}
|
||||
|
||||
public function get pitchSpeed() : Number
|
||||
{
|
||||
return this._pitchSpeed;
|
||||
}
|
||||
|
||||
public function set pitchSpeed(param1:Number) : void
|
||||
{
|
||||
this._pitchSpeed = param1;
|
||||
}
|
||||
|
||||
public function get yawSpeed() : Number
|
||||
{
|
||||
return this._yawSpeed;
|
||||
}
|
||||
|
||||
public function set yawSpeed(param1:Number) : void
|
||||
{
|
||||
this._yawSpeed = param1;
|
||||
}
|
||||
|
||||
public function get speed() : Number
|
||||
{
|
||||
return this._speed;
|
||||
}
|
||||
|
||||
public function set speed(param1:Number) : void
|
||||
{
|
||||
this._speed = param1 < 0 ? -param1 : param1;
|
||||
}
|
||||
|
||||
public function get speedMultiplier() : Number
|
||||
{
|
||||
return this._speedMultiplier;
|
||||
}
|
||||
|
||||
public function set speedMultiplier(param1:Number) : void
|
||||
{
|
||||
this._speedMultiplier = param1;
|
||||
}
|
||||
|
||||
public function get mouseSensitivity() : Number
|
||||
{
|
||||
return this._mouseSensitivity;
|
||||
}
|
||||
|
||||
public function set mouseSensitivity(param1:Number) : void
|
||||
{
|
||||
this._mouseSensitivity = param1;
|
||||
this._mouseCoefficientY = this._mouseSensitivity * this._mouseSensitivityY;
|
||||
this._mouseCoefficientX = this._mouseSensitivity * this._mouseSensitivityX;
|
||||
}
|
||||
|
||||
public function get mouseSensitivityY() : Number
|
||||
{
|
||||
return this._mouseSensitivityY;
|
||||
}
|
||||
|
||||
public function set mouseSensitivityY(param1:Number) : void
|
||||
{
|
||||
this._mouseSensitivityY = param1;
|
||||
this._mouseCoefficientY = this._mouseSensitivity * this._mouseSensitivityY;
|
||||
}
|
||||
|
||||
public function get mouseSensitivityX() : Number
|
||||
{
|
||||
return this._mouseSensitivityX;
|
||||
}
|
||||
|
||||
public function set mouseSensitivityX(param1:Number) : void
|
||||
{
|
||||
this._mouseSensitivityX = param1;
|
||||
this._mouseCoefficientX = this._mouseSensitivity * this._mouseSensitivityX;
|
||||
}
|
||||
|
||||
public function setMouseLook(param1:Boolean) : void
|
||||
{
|
||||
if(this._mouseLookActive != param1)
|
||||
{
|
||||
this._mouseLookActive = param1;
|
||||
if(this._mouseLookActive)
|
||||
{
|
||||
this.startMouseLook();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.stopMouseLook();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function startMouseLook() : void
|
||||
{
|
||||
this.startMouseCoords.x = this._eventsSource.stage.mouseX;
|
||||
this.startMouseCoords.y = this._eventsSource.stage.mouseY;
|
||||
}
|
||||
|
||||
protected function stopMouseLook() : void
|
||||
{
|
||||
}
|
||||
|
||||
public function processInput() : void
|
||||
{
|
||||
if(!this._enabled || this._object == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var loc1:Number = getTimer() - this.lastFrameTime;
|
||||
if(loc1 == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
this.lastFrameTime += loc1;
|
||||
if(loc1 > 100)
|
||||
{
|
||||
loc1 = 100;
|
||||
}
|
||||
loc1 /= 1000;
|
||||
this.rotateObject(loc1);
|
||||
this.getDisplacement(loc1,this._displacement);
|
||||
this.applyDisplacement(loc1,this._displacement);
|
||||
if(this._object.alternativa3d::changeRotationOrScaleOperation.alternativa3d::queued || this._object.alternativa3d::changeCoordsOperation.alternativa3d::queued)
|
||||
{
|
||||
if(!this._isMoving)
|
||||
{
|
||||
this._isMoving = true;
|
||||
if(this.onStartMoving != null)
|
||||
{
|
||||
this.onStartMoving.call(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(this._isMoving)
|
||||
{
|
||||
this._isMoving = false;
|
||||
if(this.onStopMoving != null)
|
||||
{
|
||||
this.onStopMoving.call(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function rotateObject(param1:Number) : void
|
||||
{
|
||||
}
|
||||
|
||||
protected function getDisplacement(param1:Number, param2:Point3D) : void
|
||||
{
|
||||
}
|
||||
|
||||
protected function applyDisplacement(param1:Number, param2:Point3D) : void
|
||||
{
|
||||
}
|
||||
|
||||
public function bindKey(param1:uint, param2:String) : void
|
||||
{
|
||||
var loc3:Function = this.actionBindings[param2];
|
||||
if(loc3 != null)
|
||||
{
|
||||
this.keyBindings[param1] = loc3;
|
||||
}
|
||||
}
|
||||
|
||||
public function unbindKey(param1:uint) : void
|
||||
{
|
||||
this.keyBindings.remove(param1);
|
||||
}
|
||||
|
||||
public function unbindAll() : void
|
||||
{
|
||||
this.keyBindings.clear();
|
||||
}
|
||||
|
||||
public function setDefaultBindings() : void
|
||||
{
|
||||
}
|
||||
|
||||
public function get keyboardEnabled() : Boolean
|
||||
{
|
||||
return this._keyboardEnabled;
|
||||
}
|
||||
|
||||
public function set keyboardEnabled(param1:Boolean) : void
|
||||
{
|
||||
if(this._keyboardEnabled != param1)
|
||||
{
|
||||
this._keyboardEnabled = param1;
|
||||
if(this._keyboardEnabled)
|
||||
{
|
||||
if(this._enabled)
|
||||
{
|
||||
this.registerKeyboardListeners();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.unregisterKeyboardListeners();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function onKeyboardEvent(param1:KeyboardEvent) : void
|
||||
{
|
||||
var loc2:Function = this.keyBindings[param1.keyCode];
|
||||
if(loc2 != null)
|
||||
{
|
||||
loc2.call(this,param1.type == KeyboardEvent.KEY_DOWN);
|
||||
}
|
||||
}
|
||||
|
||||
protected function registerKeyboardListeners() : void
|
||||
{
|
||||
this._eventsSource.addEventListener(KeyboardEvent.KEY_DOWN,this.onKeyboardEvent);
|
||||
this._eventsSource.addEventListener(KeyboardEvent.KEY_UP,this.onKeyboardEvent);
|
||||
}
|
||||
|
||||
protected function unregisterKeyboardListeners() : void
|
||||
{
|
||||
this.clearCommandFlags();
|
||||
this._eventsSource.removeEventListener(KeyboardEvent.KEY_DOWN,this.onKeyboardEvent);
|
||||
this._eventsSource.removeEventListener(KeyboardEvent.KEY_UP,this.onKeyboardEvent);
|
||||
}
|
||||
|
||||
public function get mouseEnabled() : Boolean
|
||||
{
|
||||
return this._mouseEnabled;
|
||||
}
|
||||
|
||||
public function set mouseEnabled(param1:Boolean) : void
|
||||
{
|
||||
if(this._mouseEnabled != param1)
|
||||
{
|
||||
this._mouseEnabled = param1;
|
||||
if(this._mouseEnabled)
|
||||
{
|
||||
if(this._enabled)
|
||||
{
|
||||
this.registerMouseListeners();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.unregisterMouseListeners();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function registerMouseListeners() : void
|
||||
{
|
||||
this._eventsSource.addEventListener(MouseEvent.MOUSE_DOWN,this.onMouseDown);
|
||||
}
|
||||
|
||||
protected function unregisterMouseListeners() : void
|
||||
{
|
||||
this._eventsSource.removeEventListener(MouseEvent.MOUSE_DOWN,this.onMouseDown);
|
||||
this._eventsSource.stage.removeEventListener(MouseEvent.MOUSE_UP,this.onMouseUp);
|
||||
}
|
||||
|
||||
private function onMouseDown(param1:MouseEvent) : void
|
||||
{
|
||||
this.setMouseLook(true);
|
||||
this._eventsSource.stage.addEventListener(MouseEvent.MOUSE_UP,this.onMouseUp);
|
||||
}
|
||||
|
||||
private function onMouseUp(param1:MouseEvent) : void
|
||||
{
|
||||
this.setMouseLook(false);
|
||||
this._eventsSource.stage.removeEventListener(MouseEvent.MOUSE_UP,this.onMouseUp);
|
||||
}
|
||||
|
||||
protected function setObjectCoords() : void
|
||||
{
|
||||
if(this._object != null)
|
||||
{
|
||||
this._object.coords = this._coords;
|
||||
}
|
||||
}
|
||||
|
||||
public function get accelerated() : Boolean
|
||||
{
|
||||
return this._accelerate;
|
||||
}
|
||||
|
||||
protected function clearCommandFlags() : void
|
||||
{
|
||||
this._forward = false;
|
||||
this._back = false;
|
||||
this._left = false;
|
||||
this._right = false;
|
||||
this._up = false;
|
||||
this._down = false;
|
||||
this._pitchUp = false;
|
||||
this._pitchDown = false;
|
||||
this._yawLeft = false;
|
||||
this._yawRight = false;
|
||||
this._accelerate = false;
|
||||
this._mouseLookActive = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,482 +0,0 @@
|
||||
package alternativa.engine3d.controllers
|
||||
{
|
||||
import alternativa.engine3d.alternativa3d;
|
||||
import alternativa.engine3d.core.Camera3D;
|
||||
import alternativa.engine3d.core.Mesh;
|
||||
import alternativa.engine3d.core.Object3D;
|
||||
import alternativa.engine3d.physics.Collision;
|
||||
import alternativa.types.Matrix3D;
|
||||
import alternativa.types.Point3D;
|
||||
import alternativa.utils.KeyboardUtils;
|
||||
import alternativa.utils.MathUtils;
|
||||
import flash.display.DisplayObject;
|
||||
|
||||
use namespace alternativa3d;
|
||||
|
||||
public class WalkController extends ObjectController
|
||||
{
|
||||
public var gravity:Number = 0;
|
||||
|
||||
public var jumpSpeed:Number = 0;
|
||||
|
||||
private var _groundMesh:Mesh;
|
||||
|
||||
public var speedThreshold:Number = 1;
|
||||
|
||||
public var maxPitch:Number = 1.5707963267948966;
|
||||
|
||||
public var minPitch:Number = -1.5707963267948966;
|
||||
|
||||
private var _airControlCoefficient:Number = 1;
|
||||
|
||||
private var _currentSpeed:Number = 0;
|
||||
|
||||
private var minGroundCos:Number;
|
||||
|
||||
private var destination:Point3D;
|
||||
|
||||
private var collision:Collision;
|
||||
|
||||
private var _objectZPosition:Number = 0.5;
|
||||
|
||||
private var _flyMode:Boolean;
|
||||
|
||||
private var _onGround:Boolean;
|
||||
|
||||
private var _jumpLocked:Boolean;
|
||||
|
||||
private var velocity:Point3D;
|
||||
|
||||
private var tmpVelocity:Point3D;
|
||||
|
||||
private var controlsActive:Boolean;
|
||||
|
||||
private var inJump:Boolean;
|
||||
|
||||
private var startRotX:Number;
|
||||
|
||||
private var startRotZ:Number;
|
||||
|
||||
private var prevMouseCoords:Point3D;
|
||||
|
||||
private var currentMouseCoords:Point3D;
|
||||
|
||||
public function WalkController(param1:DisplayObject, param2:Object3D = null)
|
||||
{
|
||||
this.minGroundCos = Math.cos(MathUtils.toRadian(70));
|
||||
this.destination = new Point3D();
|
||||
this.collision = new Collision();
|
||||
this.velocity = new Point3D();
|
||||
this.tmpVelocity = new Point3D();
|
||||
this.prevMouseCoords = new Point3D();
|
||||
this.currentMouseCoords = new Point3D();
|
||||
super(param1);
|
||||
this.object = param2;
|
||||
}
|
||||
|
||||
public function get groundMesh() : Mesh
|
||||
{
|
||||
return this._groundMesh;
|
||||
}
|
||||
|
||||
public function lookAt(param1:Point3D) : void
|
||||
{
|
||||
if(_object == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var loc2:Number = param1.x - _object.x;
|
||||
var loc3:Number = param1.y - _object.y;
|
||||
var loc4:Number = param1.z - _object.z;
|
||||
_object.rotationX = Math.atan2(loc4,Math.sqrt(loc2 * loc2 + loc3 * loc3)) - (_object is Camera3D ? MathUtils.DEG90 : 0);
|
||||
_object.rotationY = 0;
|
||||
_object.rotationZ = -Math.atan2(loc2,loc3);
|
||||
}
|
||||
|
||||
public function get airControlCoefficient() : Number
|
||||
{
|
||||
return this._airControlCoefficient;
|
||||
}
|
||||
|
||||
public function set airControlCoefficient(param1:Number) : void
|
||||
{
|
||||
this._airControlCoefficient = param1 > 0 ? param1 : -param1;
|
||||
}
|
||||
|
||||
public function get maxGroundAngle() : Number
|
||||
{
|
||||
return Math.acos(this.minGroundCos);
|
||||
}
|
||||
|
||||
public function set maxGroundAngle(param1:Number) : void
|
||||
{
|
||||
this.minGroundCos = Math.cos(param1);
|
||||
}
|
||||
|
||||
public function get objectZPosition() : Number
|
||||
{
|
||||
return this._objectZPosition;
|
||||
}
|
||||
|
||||
public function set objectZPosition(param1:Number) : void
|
||||
{
|
||||
this._objectZPosition = param1;
|
||||
this.setObjectCoords();
|
||||
}
|
||||
|
||||
public function get flyMode() : Boolean
|
||||
{
|
||||
return this._flyMode;
|
||||
}
|
||||
|
||||
public function set flyMode(param1:Boolean) : void
|
||||
{
|
||||
this._flyMode = param1;
|
||||
}
|
||||
|
||||
public function get onGround() : Boolean
|
||||
{
|
||||
return this._onGround;
|
||||
}
|
||||
|
||||
public function get currentSpeed() : Number
|
||||
{
|
||||
return this._currentSpeed;
|
||||
}
|
||||
|
||||
override public function setDefaultBindings() : void
|
||||
{
|
||||
unbindAll();
|
||||
bindKey(KeyboardUtils.W,ACTION_FORWARD);
|
||||
bindKey(KeyboardUtils.S,ACTION_BACK);
|
||||
bindKey(KeyboardUtils.A,ACTION_LEFT);
|
||||
bindKey(KeyboardUtils.D,ACTION_RIGHT);
|
||||
bindKey(KeyboardUtils.SPACE,ACTION_UP);
|
||||
bindKey(KeyboardUtils.Z,ACTION_DOWN);
|
||||
bindKey(KeyboardUtils.UP,ACTION_PITCH_UP);
|
||||
bindKey(KeyboardUtils.DOWN,ACTION_PITCH_DOWN);
|
||||
bindKey(KeyboardUtils.LEFT,ACTION_YAW_LEFT);
|
||||
bindKey(KeyboardUtils.RIGHT,ACTION_YAW_RIGHT);
|
||||
bindKey(KeyboardUtils.SHIFT,ACTION_ACCELERATE);
|
||||
bindKey(KeyboardUtils.M,ACTION_MOUSE_LOOK);
|
||||
}
|
||||
|
||||
override protected function rotateObject(param1:Number) : void
|
||||
{
|
||||
var loc2:Number = NaN;
|
||||
if(_mouseLookActive)
|
||||
{
|
||||
this.prevMouseCoords.copy(this.currentMouseCoords);
|
||||
this.currentMouseCoords.x = _eventsSource.stage.mouseX;
|
||||
this.currentMouseCoords.y = _eventsSource.stage.mouseY;
|
||||
if(!this.prevMouseCoords.equals(this.currentMouseCoords))
|
||||
{
|
||||
_object.rotationZ = this.startRotZ + (startMouseCoords.x - this.currentMouseCoords.x) * _mouseCoefficientX;
|
||||
loc2 = this.startRotX + (startMouseCoords.y - this.currentMouseCoords.y) * _mouseCoefficientY;
|
||||
if(_object is Camera3D)
|
||||
{
|
||||
_object.rotationX = (loc2 > this.maxPitch ? this.maxPitch : (loc2 < this.minPitch ? this.minPitch : loc2)) - MathUtils.DEG90;
|
||||
}
|
||||
else
|
||||
{
|
||||
_object.rotationX = loc2 > this.maxPitch ? this.maxPitch : (loc2 < this.minPitch ? this.minPitch : loc2);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(_yawLeft)
|
||||
{
|
||||
_object.rotationZ += _yawSpeed * param1;
|
||||
}
|
||||
else if(_yawRight)
|
||||
{
|
||||
_object.rotationZ -= _yawSpeed * param1;
|
||||
}
|
||||
loc2 = NaN;
|
||||
if(_pitchUp)
|
||||
{
|
||||
loc2 = _object.rotationX + _pitchSpeed * param1;
|
||||
}
|
||||
else if(_pitchDown)
|
||||
{
|
||||
loc2 = _object.rotationX - _pitchSpeed * param1;
|
||||
}
|
||||
if(!isNaN(loc2))
|
||||
{
|
||||
if(_object is Camera3D)
|
||||
{
|
||||
_object.rotationX = loc2 > 0 ? 0 : (loc2 < -Math.PI ? -Math.PI : loc2);
|
||||
}
|
||||
else
|
||||
{
|
||||
_object.rotationX = loc2 > MathUtils.DEG90 ? MathUtils.DEG90 : (loc2 < -MathUtils.DEG90 ? -MathUtils.DEG90 : loc2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override protected function getDisplacement(param1:Number, param2:Point3D) : void
|
||||
{
|
||||
var loc4:Number = NaN;
|
||||
var loc5:Number = NaN;
|
||||
var loc6:Number = NaN;
|
||||
var loc7:Number = NaN;
|
||||
var loc9:Matrix3D = null;
|
||||
var loc10:Number = NaN;
|
||||
var loc11:Number = NaN;
|
||||
var loc12:Number = NaN;
|
||||
var loc13:Number = NaN;
|
||||
var loc3:Number = 0;
|
||||
if(checkCollisions && !this._flyMode)
|
||||
{
|
||||
param2.x = 0;
|
||||
param2.y = 0;
|
||||
param2.z = -0.5 * this.gravity * param1 * param1;
|
||||
if(_collider.getCollision(_coords,param2,this.collision))
|
||||
{
|
||||
loc3 = this.collision.normal.z;
|
||||
this._groundMesh = this.collision.face.alternativa3d::_mesh;
|
||||
}
|
||||
else
|
||||
{
|
||||
this._groundMesh = null;
|
||||
}
|
||||
}
|
||||
this._onGround = loc3 > this.minGroundCos;
|
||||
if(this._onGround && this.inJump)
|
||||
{
|
||||
this.inJump = false;
|
||||
if(!_up)
|
||||
{
|
||||
this._jumpLocked = false;
|
||||
}
|
||||
}
|
||||
this.controlsActive = _forward || _back || _right || _left;
|
||||
if(this.flyMode || this.gravity == 0)
|
||||
{
|
||||
this.controlsActive = this.controlsActive || (_up || _down);
|
||||
}
|
||||
if(this.controlsActive)
|
||||
{
|
||||
if(this._flyMode)
|
||||
{
|
||||
this.tmpVelocity.x = 0;
|
||||
this.tmpVelocity.y = 0;
|
||||
this.tmpVelocity.z = 0;
|
||||
if(_forward)
|
||||
{
|
||||
this.tmpVelocity.y = 1;
|
||||
}
|
||||
else if(_back)
|
||||
{
|
||||
this.tmpVelocity.y = -1;
|
||||
}
|
||||
if(_right)
|
||||
{
|
||||
this.tmpVelocity.x = 1;
|
||||
}
|
||||
else if(_left)
|
||||
{
|
||||
this.tmpVelocity.x = -1;
|
||||
}
|
||||
if(_up)
|
||||
{
|
||||
this.tmpVelocity.z = 1;
|
||||
}
|
||||
else if(_down)
|
||||
{
|
||||
this.tmpVelocity.z = -1;
|
||||
}
|
||||
loc9 = _object.alternativa3d::_transformation;
|
||||
loc5 = this.tmpVelocity.x;
|
||||
if(_object is Camera3D)
|
||||
{
|
||||
loc6 = -this.tmpVelocity.z;
|
||||
loc7 = this.tmpVelocity.y;
|
||||
}
|
||||
else
|
||||
{
|
||||
loc6 = this.tmpVelocity.y;
|
||||
loc7 = this.tmpVelocity.z;
|
||||
}
|
||||
this.velocity.x += (loc5 * loc9.a + loc6 * loc9.b + loc7 * loc9.c) * _speed;
|
||||
this.velocity.y += (loc5 * loc9.e + loc6 * loc9.f + loc7 * loc9.g) * _speed;
|
||||
this.velocity.z += (loc5 * loc9.i + loc6 * loc9.j + loc7 * loc9.k) * _speed;
|
||||
}
|
||||
else
|
||||
{
|
||||
loc10 = _object.rotationZ;
|
||||
loc11 = Math.cos(loc10);
|
||||
loc12 = Math.sin(loc10);
|
||||
loc13 = _speed;
|
||||
if(this.gravity != 0 && !this._onGround)
|
||||
{
|
||||
loc13 *= this._airControlCoefficient;
|
||||
}
|
||||
if(_forward)
|
||||
{
|
||||
this.velocity.x -= loc13 * loc12;
|
||||
this.velocity.y += loc13 * loc11;
|
||||
}
|
||||
else if(_back)
|
||||
{
|
||||
this.velocity.x += loc13 * loc12;
|
||||
this.velocity.y -= loc13 * loc11;
|
||||
}
|
||||
if(_right)
|
||||
{
|
||||
this.velocity.x += loc13 * loc11;
|
||||
this.velocity.y += loc13 * loc12;
|
||||
}
|
||||
else if(_left)
|
||||
{
|
||||
this.velocity.x -= loc13 * loc11;
|
||||
this.velocity.y -= loc13 * loc12;
|
||||
}
|
||||
if(this.gravity == 0)
|
||||
{
|
||||
if(_up)
|
||||
{
|
||||
this.velocity.z += _speed;
|
||||
}
|
||||
else if(_down)
|
||||
{
|
||||
this.velocity.z -= _speed;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
loc4 = 1 / Math.pow(3,param1 * 10);
|
||||
if(this._flyMode || this.gravity == 0)
|
||||
{
|
||||
this.velocity.x *= loc4;
|
||||
this.velocity.y *= loc4;
|
||||
this.velocity.z *= loc4;
|
||||
}
|
||||
else if(this._onGround)
|
||||
{
|
||||
this.velocity.x *= loc4;
|
||||
this.velocity.y *= loc4;
|
||||
if(this.velocity.z < 0)
|
||||
{
|
||||
this.velocity.z *= loc4;
|
||||
}
|
||||
}
|
||||
else if(loc3 > 0 && this.velocity.z > 0)
|
||||
{
|
||||
this.velocity.z = 0;
|
||||
}
|
||||
}
|
||||
if(this._onGround && _up && !this.inJump && !this._jumpLocked)
|
||||
{
|
||||
this.velocity.z = this.jumpSpeed;
|
||||
this.inJump = true;
|
||||
this._onGround = false;
|
||||
this._jumpLocked = true;
|
||||
loc3 = 0;
|
||||
}
|
||||
if(!(this._flyMode || this._onGround))
|
||||
{
|
||||
this.velocity.z -= this.gravity * param1;
|
||||
}
|
||||
var loc8:Number = _accelerate ? _speed * _speedMultiplier : _speed;
|
||||
if(this._flyMode || this.gravity == 0)
|
||||
{
|
||||
loc4 = this.velocity.length;
|
||||
if(loc4 > loc8)
|
||||
{
|
||||
this.velocity.length = loc8;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
loc4 = Math.sqrt(this.velocity.x * this.velocity.x + this.velocity.y * this.velocity.y);
|
||||
if(loc4 > loc8)
|
||||
{
|
||||
this.velocity.x *= loc8 / loc4;
|
||||
this.velocity.y *= loc8 / loc4;
|
||||
}
|
||||
if(loc3 > 0 && this.velocity.z > 0)
|
||||
{
|
||||
this.velocity.z = 0;
|
||||
}
|
||||
}
|
||||
param2.x = this.velocity.x * param1;
|
||||
param2.y = this.velocity.y * param1;
|
||||
param2.z = this.velocity.z * param1;
|
||||
}
|
||||
|
||||
override protected function applyDisplacement(param1:Number, param2:Point3D) : void
|
||||
{
|
||||
if(checkCollisions)
|
||||
{
|
||||
_collider.calculateDestination(_coords,param2,this.destination);
|
||||
param2.x = this.destination.x - _coords.x;
|
||||
param2.y = this.destination.y - _coords.y;
|
||||
param2.z = this.destination.z - _coords.z;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.destination.x = _coords.x + param2.x;
|
||||
this.destination.y = _coords.y + param2.y;
|
||||
this.destination.z = _coords.z + param2.z;
|
||||
}
|
||||
this.velocity.x = param2.x / param1;
|
||||
this.velocity.y = param2.y / param1;
|
||||
this.velocity.z = param2.z / param1;
|
||||
_coords.x = this.destination.x;
|
||||
_coords.y = this.destination.y;
|
||||
_coords.z = this.destination.z;
|
||||
this.setObjectCoords();
|
||||
var loc3:Number = Math.sqrt(this.velocity.x * this.velocity.x + this.velocity.y * this.velocity.y + this.velocity.z * this.velocity.z);
|
||||
if(loc3 < this.speedThreshold)
|
||||
{
|
||||
this.velocity.x = 0;
|
||||
this.velocity.y = 0;
|
||||
this.velocity.z = 0;
|
||||
this._currentSpeed = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
this._currentSpeed = loc3;
|
||||
}
|
||||
}
|
||||
|
||||
override protected function setObjectCoords() : void
|
||||
{
|
||||
if(_object != null)
|
||||
{
|
||||
_object.x = _coords.x;
|
||||
_object.y = _coords.y;
|
||||
_object.z = _coords.z + (2 * this._objectZPosition - 1) * _collider.radiusZ;
|
||||
}
|
||||
}
|
||||
|
||||
override protected function startMouseLook() : void
|
||||
{
|
||||
super.startMouseLook();
|
||||
this.startRotX = _object is Camera3D ? _object.rotationX + MathUtils.DEG90 : _object.rotationX;
|
||||
this.startRotZ = _object.rotationZ;
|
||||
}
|
||||
|
||||
override public function set enabled(param1:Boolean) : void
|
||||
{
|
||||
super.enabled = param1;
|
||||
if(!param1)
|
||||
{
|
||||
this.velocity.reset();
|
||||
this._currentSpeed = 0;
|
||||
}
|
||||
}
|
||||
|
||||
override public function moveUp(param1:Boolean) : void
|
||||
{
|
||||
super.moveUp(param1);
|
||||
if(!this.inJump && !param1)
|
||||
{
|
||||
this._jumpLocked = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,91 +0,0 @@
|
||||
package alternativa.engine3d.core
|
||||
{
|
||||
import alternativa.engine3d.alternativa3d;
|
||||
import alternativa.types.Point3D;
|
||||
import alternativa.types.Set;
|
||||
|
||||
use namespace alternativa3d;
|
||||
|
||||
public final class BSPNode
|
||||
{
|
||||
private static var collector:Array = new Array();
|
||||
|
||||
alternativa3d var splitter:Splitter;
|
||||
|
||||
alternativa3d var frontSector:Sector;
|
||||
|
||||
alternativa3d var backSector:Sector;
|
||||
|
||||
alternativa3d var isSprite:Boolean;
|
||||
|
||||
alternativa3d var parent:BSPNode;
|
||||
|
||||
alternativa3d var front:BSPNode;
|
||||
|
||||
alternativa3d var back:BSPNode;
|
||||
|
||||
alternativa3d var normal:Point3D;
|
||||
|
||||
alternativa3d var offset:Number;
|
||||
|
||||
alternativa3d var mobility:int = 2147483647;
|
||||
|
||||
alternativa3d var primitive:PolyPrimitive;
|
||||
|
||||
alternativa3d var backPrimitives:Set;
|
||||
|
||||
alternativa3d var frontPrimitives:Set;
|
||||
|
||||
public function BSPNode()
|
||||
{
|
||||
this.alternativa3d::normal = new Point3D();
|
||||
super();
|
||||
}
|
||||
|
||||
alternativa3d static function create(param1:PolyPrimitive) : BSPNode
|
||||
{
|
||||
var loc2:BSPNode = null;
|
||||
var loc3:SplitterPrimitive = null;
|
||||
loc2 = collector.pop();
|
||||
if(loc2 == null)
|
||||
{
|
||||
loc2 = new BSPNode();
|
||||
}
|
||||
loc2.alternativa3d::primitive = param1;
|
||||
param1.alternativa3d::node = loc2;
|
||||
if(param1.alternativa3d::face == null)
|
||||
{
|
||||
loc3 = param1 as SplitterPrimitive;
|
||||
if(loc3 == null)
|
||||
{
|
||||
loc2.alternativa3d::normal.x = 0;
|
||||
loc2.alternativa3d::normal.y = 0;
|
||||
loc2.alternativa3d::normal.z = 0;
|
||||
loc2.alternativa3d::offset = 0;
|
||||
loc2.alternativa3d::isSprite = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
loc2.alternativa3d::splitter = loc3.alternativa3d::splitter;
|
||||
loc2.alternativa3d::normal.copy(loc3.alternativa3d::splitter.alternativa3d::normal);
|
||||
loc2.alternativa3d::offset = loc3.alternativa3d::splitter.alternativa3d::offset;
|
||||
loc2.alternativa3d::isSprite = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
loc2.alternativa3d::normal.copy(param1.alternativa3d::face.alternativa3d::globalNormal);
|
||||
loc2.alternativa3d::offset = param1.alternativa3d::face.alternativa3d::globalOffset;
|
||||
loc2.alternativa3d::isSprite = false;
|
||||
}
|
||||
loc2.alternativa3d::mobility = param1.mobility;
|
||||
return loc2;
|
||||
}
|
||||
|
||||
alternativa3d static function destroy(param1:BSPNode) : void
|
||||
{
|
||||
collector.push(param1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,698 +0,0 @@
|
||||
package alternativa.engine3d.core
|
||||
{
|
||||
import alternativa.engine3d.*;
|
||||
import alternativa.types.Matrix3D;
|
||||
import alternativa.types.Point3D;
|
||||
import alternativa.types.Set;
|
||||
import flash.events.Event;
|
||||
import flash.events.EventDispatcher;
|
||||
import flash.events.IEventDispatcher;
|
||||
import flash.geom.Matrix;
|
||||
import flash.geom.Point;
|
||||
|
||||
use namespace alternativa3d;
|
||||
|
||||
public final class Face implements IEventDispatcher
|
||||
{
|
||||
private static const uvThreshold:Number = 1 / 2880;
|
||||
|
||||
alternativa3d var calculateNormalOperation:Operation;
|
||||
|
||||
alternativa3d var calculateBaseUVOperation:Operation;
|
||||
|
||||
alternativa3d var calculateUVOperation:Operation;
|
||||
|
||||
alternativa3d var updatePrimitiveOperation:Operation;
|
||||
|
||||
alternativa3d var updateMaterialOperation:Operation;
|
||||
|
||||
alternativa3d var _mesh:Mesh;
|
||||
|
||||
alternativa3d var _surface:Surface;
|
||||
|
||||
alternativa3d var _vertices:Array;
|
||||
|
||||
alternativa3d var _verticesCount:uint;
|
||||
|
||||
alternativa3d var primitive:PolyPrimitive;
|
||||
|
||||
alternativa3d var _aUV:Point;
|
||||
|
||||
alternativa3d var _bUV:Point;
|
||||
|
||||
alternativa3d var _cUV:Point;
|
||||
|
||||
alternativa3d var uvMatrixBase:Matrix;
|
||||
|
||||
alternativa3d var uvMatrix:Matrix3D;
|
||||
|
||||
alternativa3d var orthoTextureMatrix:Matrix;
|
||||
|
||||
alternativa3d var globalNormal:Point3D;
|
||||
|
||||
alternativa3d var globalOffset:Number;
|
||||
|
||||
public var mouseEnabled:Boolean = true;
|
||||
|
||||
private var dispatcher:EventDispatcher;
|
||||
|
||||
public function Face(param1:Array)
|
||||
{
|
||||
var loc3:Vertex = null;
|
||||
this.alternativa3d::calculateNormalOperation = new Operation("calculateNormal",this,this.calculateNormal,Operation.alternativa3d::FACE_CALCULATE_NORMAL);
|
||||
this.alternativa3d::calculateBaseUVOperation = new Operation("calculateBaseUV",this,this.calculateBaseUV,Operation.alternativa3d::FACE_CALCULATE_BASE_UV);
|
||||
this.alternativa3d::calculateUVOperation = new Operation("calculateUV",this,this.calculateUV,Operation.alternativa3d::FACE_CALCULATE_UV);
|
||||
this.alternativa3d::updatePrimitiveOperation = new Operation("updatePrimitive",this,this.updatePrimitive,Operation.alternativa3d::FACE_UPDATE_PRIMITIVE);
|
||||
this.alternativa3d::updateMaterialOperation = new Operation("updateMaterial",this,this.updateMaterial,Operation.alternativa3d::FACE_UPDATE_MATERIAL);
|
||||
this.alternativa3d::globalNormal = new Point3D();
|
||||
super();
|
||||
this.alternativa3d::_vertices = param1;
|
||||
this.alternativa3d::_verticesCount = param1.length;
|
||||
this.alternativa3d::primitive = PolyPrimitive.alternativa3d::create();
|
||||
this.alternativa3d::primitive.alternativa3d::face = this;
|
||||
this.alternativa3d::primitive.alternativa3d::num = this.alternativa3d::_verticesCount;
|
||||
var loc2:uint = 0;
|
||||
while(loc2 < this.alternativa3d::_verticesCount)
|
||||
{
|
||||
loc3 = param1[loc2];
|
||||
this.alternativa3d::primitive.alternativa3d::points.push(loc3.alternativa3d::globalCoords);
|
||||
loc3.alternativa3d::addToFace(this);
|
||||
loc2++;
|
||||
}
|
||||
this.alternativa3d::calculateNormalOperation.alternativa3d::addSequel(this.alternativa3d::updatePrimitiveOperation);
|
||||
this.alternativa3d::calculateNormalOperation.alternativa3d::addSequel(this.alternativa3d::calculateUVOperation);
|
||||
this.alternativa3d::calculateBaseUVOperation.alternativa3d::addSequel(this.alternativa3d::calculateUVOperation);
|
||||
this.alternativa3d::calculateUVOperation.alternativa3d::addSequel(this.alternativa3d::updateMaterialOperation);
|
||||
}
|
||||
|
||||
private function calculateNormal() : void
|
||||
{
|
||||
var loc1:Vertex = this.alternativa3d::_vertices[0];
|
||||
var loc2:Point3D = loc1.alternativa3d::globalCoords;
|
||||
loc1 = this.alternativa3d::_vertices[1];
|
||||
var loc3:Point3D = loc1.alternativa3d::globalCoords;
|
||||
var loc4:Number = loc3.x - loc2.x;
|
||||
var loc5:Number = loc3.y - loc2.y;
|
||||
var loc6:Number = loc3.z - loc2.z;
|
||||
loc1 = this.alternativa3d::_vertices[2];
|
||||
var loc7:Point3D = loc1.alternativa3d::globalCoords;
|
||||
var loc8:Number = loc7.x - loc2.x;
|
||||
var loc9:Number = loc7.y - loc2.y;
|
||||
var loc10:Number = loc7.z - loc2.z;
|
||||
this.alternativa3d::globalNormal.x = loc10 * loc5 - loc9 * loc6;
|
||||
this.alternativa3d::globalNormal.y = loc8 * loc6 - loc10 * loc4;
|
||||
this.alternativa3d::globalNormal.z = loc9 * loc4 - loc8 * loc5;
|
||||
this.alternativa3d::globalNormal.normalize();
|
||||
}
|
||||
|
||||
private function updatePrimitive() : void
|
||||
{
|
||||
var loc1:Vertex = this.alternativa3d::_vertices[0];
|
||||
this.alternativa3d::globalOffset = loc1.alternativa3d::globalCoords.x * this.alternativa3d::globalNormal.x + loc1.alternativa3d::globalCoords.y * this.alternativa3d::globalNormal.y + loc1.alternativa3d::globalCoords.z * this.alternativa3d::globalNormal.z;
|
||||
this.removePrimitive(this.alternativa3d::primitive);
|
||||
this.alternativa3d::primitive.mobility = this.alternativa3d::_mesh.alternativa3d::inheritedMobility;
|
||||
this.alternativa3d::_mesh.alternativa3d::_scene.alternativa3d::addPrimitives.push(this.alternativa3d::primitive);
|
||||
}
|
||||
|
||||
private function removePrimitive(param1:PolyPrimitive) : void
|
||||
{
|
||||
if(param1.alternativa3d::backFragment != null)
|
||||
{
|
||||
this.removePrimitive(param1.alternativa3d::backFragment);
|
||||
this.removePrimitive(param1.alternativa3d::frontFragment);
|
||||
param1.alternativa3d::backFragment = null;
|
||||
param1.alternativa3d::frontFragment = null;
|
||||
if(param1 != this.alternativa3d::primitive)
|
||||
{
|
||||
param1.alternativa3d::parent = null;
|
||||
param1.alternativa3d::sibling = null;
|
||||
PolyPrimitive.alternativa3d::destroy(param1);
|
||||
}
|
||||
}
|
||||
else if(param1.alternativa3d::node != null)
|
||||
{
|
||||
this.alternativa3d::_mesh.alternativa3d::_scene.alternativa3d::removeBSPPrimitive(param1);
|
||||
}
|
||||
}
|
||||
|
||||
private function updateMaterial() : void
|
||||
{
|
||||
if(!this.alternativa3d::updatePrimitiveOperation.alternativa3d::queued)
|
||||
{
|
||||
this.changePrimitive(this.alternativa3d::primitive);
|
||||
}
|
||||
}
|
||||
|
||||
private function changePrimitive(param1:PolyPrimitive) : void
|
||||
{
|
||||
if(param1.alternativa3d::backFragment != null)
|
||||
{
|
||||
this.changePrimitive(param1.alternativa3d::backFragment);
|
||||
this.changePrimitive(param1.alternativa3d::frontFragment);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.alternativa3d::_mesh.alternativa3d::_scene.alternativa3d::changedPrimitives[param1] = true;
|
||||
}
|
||||
}
|
||||
|
||||
private function calculateBaseUV() : void
|
||||
{
|
||||
var loc1:Number = NaN;
|
||||
var loc2:Number = NaN;
|
||||
var loc3:Number = NaN;
|
||||
var loc4:Number = NaN;
|
||||
var loc5:Number = NaN;
|
||||
var loc6:Number = NaN;
|
||||
if(this.alternativa3d::_aUV != null && this.alternativa3d::_bUV != null && this.alternativa3d::_cUV != null)
|
||||
{
|
||||
loc1 = this.alternativa3d::_bUV.x - this.alternativa3d::_aUV.x;
|
||||
loc2 = this.alternativa3d::_bUV.y - this.alternativa3d::_aUV.y;
|
||||
loc3 = this.alternativa3d::_cUV.x - this.alternativa3d::_aUV.x;
|
||||
loc4 = this.alternativa3d::_cUV.y - this.alternativa3d::_aUV.y;
|
||||
loc5 = loc1 * loc4 - loc2 * loc3;
|
||||
if(loc5 < uvThreshold && loc5 > -uvThreshold)
|
||||
{
|
||||
if(loc1 < uvThreshold && loc1 > -uvThreshold && loc2 < uvThreshold && loc2 > -uvThreshold)
|
||||
{
|
||||
if(loc3 < uvThreshold && loc3 > -uvThreshold && loc4 < uvThreshold && loc4 > -uvThreshold)
|
||||
{
|
||||
loc1 = uvThreshold;
|
||||
loc4 = uvThreshold;
|
||||
}
|
||||
else
|
||||
{
|
||||
loc6 = Math.sqrt(loc3 * loc3 + loc4 * loc4);
|
||||
loc1 = uvThreshold * loc4 / loc6;
|
||||
loc2 = -uvThreshold * loc3 / loc6;
|
||||
}
|
||||
}
|
||||
else if(loc3 < uvThreshold && loc3 > -uvThreshold && loc4 < uvThreshold && loc4 > -uvThreshold)
|
||||
{
|
||||
loc6 = Math.sqrt(loc1 * loc1 + loc2 * loc2);
|
||||
loc3 = -uvThreshold * loc2 / loc6;
|
||||
loc4 = uvThreshold * loc1 / loc6;
|
||||
}
|
||||
else
|
||||
{
|
||||
loc6 = Math.sqrt(loc1 * loc1 + loc2 * loc2);
|
||||
loc3 += uvThreshold * loc2 / loc6;
|
||||
loc4 -= uvThreshold * loc1 / loc6;
|
||||
}
|
||||
loc5 = loc1 * loc4 - loc2 * loc3;
|
||||
}
|
||||
if(this.alternativa3d::uvMatrixBase == null)
|
||||
{
|
||||
this.alternativa3d::uvMatrixBase = new Matrix();
|
||||
this.alternativa3d::orthoTextureMatrix = new Matrix();
|
||||
}
|
||||
this.alternativa3d::uvMatrixBase.a = loc4 / loc5;
|
||||
this.alternativa3d::uvMatrixBase.b = -loc2 / loc5;
|
||||
this.alternativa3d::uvMatrixBase.c = -loc3 / loc5;
|
||||
this.alternativa3d::uvMatrixBase.d = loc1 / loc5;
|
||||
this.alternativa3d::uvMatrixBase.tx = -(this.alternativa3d::uvMatrixBase.a * this.alternativa3d::_aUV.x + this.alternativa3d::uvMatrixBase.c * this.alternativa3d::_aUV.y);
|
||||
this.alternativa3d::uvMatrixBase.ty = -(this.alternativa3d::uvMatrixBase.b * this.alternativa3d::_aUV.x + this.alternativa3d::uvMatrixBase.d * this.alternativa3d::_aUV.y);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.alternativa3d::uvMatrixBase = null;
|
||||
this.alternativa3d::orthoTextureMatrix = null;
|
||||
}
|
||||
}
|
||||
|
||||
private function calculateUV() : void
|
||||
{
|
||||
var loc1:Point3D = null;
|
||||
var loc2:Point3D = null;
|
||||
var loc3:Point3D = null;
|
||||
var loc4:Number = NaN;
|
||||
var loc5:Number = NaN;
|
||||
var loc6:Number = NaN;
|
||||
var loc7:Number = NaN;
|
||||
var loc8:Number = NaN;
|
||||
var loc9:Number = NaN;
|
||||
var loc10:Number = NaN;
|
||||
var loc11:Number = NaN;
|
||||
var loc12:Number = NaN;
|
||||
var loc13:Number = NaN;
|
||||
var loc14:Number = NaN;
|
||||
var loc15:Number = NaN;
|
||||
var loc16:Number = NaN;
|
||||
var loc17:Number = NaN;
|
||||
var loc18:Number = NaN;
|
||||
var loc19:Number = NaN;
|
||||
var loc20:Number = NaN;
|
||||
var loc21:Number = NaN;
|
||||
var loc22:Number = NaN;
|
||||
if(this.alternativa3d::uvMatrixBase != null)
|
||||
{
|
||||
if(this.alternativa3d::uvMatrix == null)
|
||||
{
|
||||
this.alternativa3d::uvMatrix = new Matrix3D();
|
||||
}
|
||||
loc1 = this.alternativa3d::_vertices[0].globalCoords;
|
||||
loc2 = this.alternativa3d::_vertices[1].globalCoords;
|
||||
loc3 = this.alternativa3d::_vertices[2].globalCoords;
|
||||
loc4 = loc2.x - loc1.x;
|
||||
loc5 = loc2.y - loc1.y;
|
||||
loc6 = loc2.z - loc1.z;
|
||||
loc7 = loc3.x - loc1.x;
|
||||
loc8 = loc3.y - loc1.y;
|
||||
loc9 = loc3.z - loc1.z;
|
||||
this.alternativa3d::uvMatrix.a = loc4 * this.alternativa3d::uvMatrixBase.a + loc7 * this.alternativa3d::uvMatrixBase.b;
|
||||
this.alternativa3d::uvMatrix.b = loc4 * this.alternativa3d::uvMatrixBase.c + loc7 * this.alternativa3d::uvMatrixBase.d;
|
||||
this.alternativa3d::uvMatrix.c = this.alternativa3d::globalNormal.x;
|
||||
this.alternativa3d::uvMatrix.d = loc4 * this.alternativa3d::uvMatrixBase.tx + loc7 * this.alternativa3d::uvMatrixBase.ty + loc1.x;
|
||||
this.alternativa3d::uvMatrix.e = loc5 * this.alternativa3d::uvMatrixBase.a + loc8 * this.alternativa3d::uvMatrixBase.b;
|
||||
this.alternativa3d::uvMatrix.f = loc5 * this.alternativa3d::uvMatrixBase.c + loc8 * this.alternativa3d::uvMatrixBase.d;
|
||||
this.alternativa3d::uvMatrix.g = this.alternativa3d::globalNormal.y;
|
||||
this.alternativa3d::uvMatrix.h = loc5 * this.alternativa3d::uvMatrixBase.tx + loc8 * this.alternativa3d::uvMatrixBase.ty + loc1.y;
|
||||
this.alternativa3d::uvMatrix.i = loc6 * this.alternativa3d::uvMatrixBase.a + loc9 * this.alternativa3d::uvMatrixBase.b;
|
||||
this.alternativa3d::uvMatrix.j = loc6 * this.alternativa3d::uvMatrixBase.c + loc9 * this.alternativa3d::uvMatrixBase.d;
|
||||
this.alternativa3d::uvMatrix.k = this.alternativa3d::globalNormal.z;
|
||||
this.alternativa3d::uvMatrix.l = loc6 * this.alternativa3d::uvMatrixBase.tx + loc9 * this.alternativa3d::uvMatrixBase.ty + loc1.z;
|
||||
loc10 = this.alternativa3d::uvMatrix.a;
|
||||
loc11 = this.alternativa3d::uvMatrix.b;
|
||||
loc12 = this.alternativa3d::uvMatrix.c;
|
||||
loc13 = this.alternativa3d::uvMatrix.d;
|
||||
loc14 = this.alternativa3d::uvMatrix.e;
|
||||
loc15 = this.alternativa3d::uvMatrix.f;
|
||||
loc16 = this.alternativa3d::uvMatrix.g;
|
||||
loc17 = this.alternativa3d::uvMatrix.h;
|
||||
loc18 = this.alternativa3d::uvMatrix.i;
|
||||
loc19 = this.alternativa3d::uvMatrix.j;
|
||||
loc20 = this.alternativa3d::uvMatrix.k;
|
||||
loc21 = this.alternativa3d::uvMatrix.l;
|
||||
loc22 = -loc12 * loc15 * loc18 + loc11 * loc16 * loc18 + loc12 * loc14 * loc19 - loc10 * loc16 * loc19 - loc11 * loc14 * loc20 + loc10 * loc15 * loc20;
|
||||
if(loc22 != 0)
|
||||
{
|
||||
this.alternativa3d::uvMatrix.a = (-loc16 * loc19 + loc15 * loc20) / loc22;
|
||||
this.alternativa3d::uvMatrix.b = (loc12 * loc19 - loc11 * loc20) / loc22;
|
||||
this.alternativa3d::uvMatrix.c = (-loc12 * loc15 + loc11 * loc16) / loc22;
|
||||
this.alternativa3d::uvMatrix.d = (loc13 * loc16 * loc19 - loc12 * loc17 * loc19 - loc13 * loc15 * loc20 + loc11 * loc17 * loc20 + loc12 * loc15 * loc21 - loc11 * loc16 * loc21) / loc22;
|
||||
this.alternativa3d::uvMatrix.e = (loc16 * loc18 - loc14 * loc20) / loc22;
|
||||
this.alternativa3d::uvMatrix.f = (-loc12 * loc18 + loc10 * loc20) / loc22;
|
||||
this.alternativa3d::uvMatrix.g = (loc12 * loc14 - loc10 * loc16) / loc22;
|
||||
this.alternativa3d::uvMatrix.h = (loc12 * loc17 * loc18 - loc13 * loc16 * loc18 + loc13 * loc14 * loc20 - loc10 * loc17 * loc20 - loc12 * loc14 * loc21 + loc10 * loc16 * loc21) / loc22;
|
||||
this.alternativa3d::uvMatrix.i = (-loc15 * loc18 + loc14 * loc19) / loc22;
|
||||
this.alternativa3d::uvMatrix.j = (loc11 * loc18 - loc10 * loc19) / loc22;
|
||||
this.alternativa3d::uvMatrix.k = (-loc11 * loc14 + loc10 * loc15) / loc22;
|
||||
this.alternativa3d::uvMatrix.l = (loc13 * loc15 * loc18 - loc11 * loc17 * loc18 - loc13 * loc14 * loc19 + loc10 * loc17 * loc19 + loc11 * loc14 * loc21 - loc10 * loc15 * loc21) / loc22;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.alternativa3d::uvMatrix = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.alternativa3d::uvMatrix = null;
|
||||
}
|
||||
}
|
||||
|
||||
public function get vertices() : Array
|
||||
{
|
||||
return new Array().concat(this.alternativa3d::_vertices);
|
||||
}
|
||||
|
||||
public function get verticesCount() : uint
|
||||
{
|
||||
return this.alternativa3d::_verticesCount;
|
||||
}
|
||||
|
||||
public function get mesh() : Mesh
|
||||
{
|
||||
return this.alternativa3d::_mesh;
|
||||
}
|
||||
|
||||
public function get surface() : Surface
|
||||
{
|
||||
return this.alternativa3d::_surface;
|
||||
}
|
||||
|
||||
public function get id() : Object
|
||||
{
|
||||
return this.alternativa3d::_mesh != null ? this.alternativa3d::_mesh.getFaceId(this) : null;
|
||||
}
|
||||
|
||||
public function get aUV() : Point
|
||||
{
|
||||
return this.alternativa3d::_aUV != null ? this.alternativa3d::_aUV.clone() : null;
|
||||
}
|
||||
|
||||
public function get bUV() : Point
|
||||
{
|
||||
return this.alternativa3d::_bUV != null ? this.alternativa3d::_bUV.clone() : null;
|
||||
}
|
||||
|
||||
public function get cUV() : Point
|
||||
{
|
||||
return this.alternativa3d::_cUV != null ? this.alternativa3d::_cUV.clone() : null;
|
||||
}
|
||||
|
||||
public function set aUV(param1:Point) : void
|
||||
{
|
||||
if(this.alternativa3d::_aUV != null)
|
||||
{
|
||||
if(param1 != null)
|
||||
{
|
||||
if(!this.alternativa3d::_aUV.equals(param1))
|
||||
{
|
||||
this.alternativa3d::_aUV.x = param1.x;
|
||||
this.alternativa3d::_aUV.y = param1.y;
|
||||
if(this.alternativa3d::_mesh != null)
|
||||
{
|
||||
this.alternativa3d::_mesh.alternativa3d::addOperationToScene(this.alternativa3d::calculateBaseUVOperation);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.alternativa3d::_aUV = null;
|
||||
if(this.alternativa3d::_mesh != null)
|
||||
{
|
||||
this.alternativa3d::_mesh.alternativa3d::addOperationToScene(this.alternativa3d::calculateBaseUVOperation);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(param1 != null)
|
||||
{
|
||||
this.alternativa3d::_aUV = param1.clone();
|
||||
if(this.alternativa3d::_mesh != null)
|
||||
{
|
||||
this.alternativa3d::_mesh.alternativa3d::addOperationToScene(this.alternativa3d::calculateBaseUVOperation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function set bUV(param1:Point) : void
|
||||
{
|
||||
if(this.alternativa3d::_bUV != null)
|
||||
{
|
||||
if(param1 != null)
|
||||
{
|
||||
if(!this.alternativa3d::_bUV.equals(param1))
|
||||
{
|
||||
this.alternativa3d::_bUV.x = param1.x;
|
||||
this.alternativa3d::_bUV.y = param1.y;
|
||||
if(this.alternativa3d::_mesh != null)
|
||||
{
|
||||
this.alternativa3d::_mesh.alternativa3d::addOperationToScene(this.alternativa3d::calculateBaseUVOperation);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.alternativa3d::_bUV = null;
|
||||
if(this.alternativa3d::_mesh != null)
|
||||
{
|
||||
this.alternativa3d::_mesh.alternativa3d::addOperationToScene(this.alternativa3d::calculateBaseUVOperation);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(param1 != null)
|
||||
{
|
||||
this.alternativa3d::_bUV = param1.clone();
|
||||
if(this.alternativa3d::_mesh != null)
|
||||
{
|
||||
this.alternativa3d::_mesh.alternativa3d::addOperationToScene(this.alternativa3d::calculateBaseUVOperation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function set cUV(param1:Point) : void
|
||||
{
|
||||
if(this.alternativa3d::_cUV != null)
|
||||
{
|
||||
if(param1 != null)
|
||||
{
|
||||
if(!this.alternativa3d::_cUV.equals(param1))
|
||||
{
|
||||
this.alternativa3d::_cUV.x = param1.x;
|
||||
this.alternativa3d::_cUV.y = param1.y;
|
||||
if(this.alternativa3d::_mesh != null)
|
||||
{
|
||||
this.alternativa3d::_mesh.alternativa3d::addOperationToScene(this.alternativa3d::calculateBaseUVOperation);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.alternativa3d::_cUV = null;
|
||||
if(this.alternativa3d::_mesh != null)
|
||||
{
|
||||
this.alternativa3d::_mesh.alternativa3d::addOperationToScene(this.alternativa3d::calculateBaseUVOperation);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(param1 != null)
|
||||
{
|
||||
this.alternativa3d::_cUV = param1.clone();
|
||||
if(this.alternativa3d::_mesh != null)
|
||||
{
|
||||
this.alternativa3d::_mesh.alternativa3d::addOperationToScene(this.alternativa3d::calculateBaseUVOperation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function get normal() : Point3D
|
||||
{
|
||||
var loc12:Number = NaN;
|
||||
var loc1:Point3D = new Point3D();
|
||||
var loc2:Vertex = this.alternativa3d::_vertices[0];
|
||||
var loc3:Point3D = loc2.coords;
|
||||
loc2 = this.alternativa3d::_vertices[1];
|
||||
var loc4:Point3D = loc2.coords;
|
||||
var loc5:Number = loc4.x - loc3.x;
|
||||
var loc6:Number = loc4.y - loc3.y;
|
||||
var loc7:Number = loc4.z - loc3.z;
|
||||
loc2 = this.alternativa3d::_vertices[2];
|
||||
var loc8:Point3D = loc2.coords;
|
||||
var loc9:Number = loc8.x - loc3.x;
|
||||
var loc10:Number = loc8.y - loc3.y;
|
||||
var loc11:Number = loc8.z - loc3.z;
|
||||
loc1.x = loc11 * loc6 - loc10 * loc7;
|
||||
loc1.y = loc9 * loc7 - loc11 * loc5;
|
||||
loc1.z = loc10 * loc5 - loc9 * loc6;
|
||||
if(loc1.x != 0 || loc1.y != 0 || loc1.z != 0)
|
||||
{
|
||||
loc12 = Math.sqrt(loc1.x * loc1.x + loc1.y * loc1.y + loc1.z * loc1.z);
|
||||
loc1.x /= loc12;
|
||||
loc1.y /= loc12;
|
||||
loc1.z /= loc12;
|
||||
}
|
||||
return loc1;
|
||||
}
|
||||
|
||||
public function getUV(param1:Point3D) : Point
|
||||
{
|
||||
return this.alternativa3d::getUVFast(param1,this.normal);
|
||||
}
|
||||
|
||||
alternativa3d function getUVFast(param1:Point3D, param2:Point3D) : Point
|
||||
{
|
||||
var loc3:uint = 0;
|
||||
if(this.alternativa3d::_aUV == null || this.alternativa3d::_bUV == null || this.alternativa3d::_cUV == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if((param2.x < 0 ? -param2.x : param2.x) > (param2.y < 0 ? -param2.y : param2.y))
|
||||
{
|
||||
if((param2.x < 0 ? -param2.x : param2.x) > (param2.z < 0 ? -param2.z : param2.z))
|
||||
{
|
||||
loc3 = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
loc3 = 2;
|
||||
}
|
||||
}
|
||||
else if((param2.y < 0 ? -param2.y : param2.y) > (param2.z < 0 ? -param2.z : param2.z))
|
||||
{
|
||||
loc3 = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
loc3 = 2;
|
||||
}
|
||||
var loc4:Vertex = this.alternativa3d::_vertices[0];
|
||||
var loc5:Point3D = loc4.alternativa3d::_coords;
|
||||
loc4 = this.alternativa3d::_vertices[1];
|
||||
var loc6:Point3D = loc4.alternativa3d::_coords;
|
||||
loc4 = this.alternativa3d::_vertices[2];
|
||||
var loc7:Point3D = loc4.alternativa3d::_coords;
|
||||
var loc8:Number = loc3 == 0 ? loc6.y - loc5.y : loc6.x - loc5.x;
|
||||
var loc9:Number = loc3 == 2 ? loc6.y - loc5.y : loc6.z - loc5.z;
|
||||
var loc10:Number = loc3 == 0 ? loc7.y - loc5.y : loc7.x - loc5.x;
|
||||
var loc11:Number = loc3 == 2 ? loc7.y - loc5.y : loc7.z - loc5.z;
|
||||
var loc12:Number = loc8 * loc11 - loc10 * loc9;
|
||||
var loc13:Number = loc3 == 0 ? param1.y - loc5.y : param1.x - loc5.x;
|
||||
var loc14:Number = loc3 == 2 ? param1.y - loc5.y : param1.z - loc5.z;
|
||||
var loc15:Number = (loc13 * loc11 - loc10 * loc14) / loc12;
|
||||
var loc16:Number = (loc8 * loc14 - loc13 * loc9) / loc12;
|
||||
var loc17:Number = this.alternativa3d::_bUV.x - this.alternativa3d::_aUV.x;
|
||||
var loc18:Number = this.alternativa3d::_bUV.y - this.alternativa3d::_aUV.y;
|
||||
var loc19:Number = this.alternativa3d::_cUV.x - this.alternativa3d::_aUV.x;
|
||||
var loc20:Number = this.alternativa3d::_cUV.y - this.alternativa3d::_aUV.y;
|
||||
return new Point(this.alternativa3d::_aUV.x + loc17 * loc15 + loc19 * loc16,this.alternativa3d::_aUV.y + loc18 * loc15 + loc20 * loc16);
|
||||
}
|
||||
|
||||
public function get edgeJoinedFaces() : Set
|
||||
{
|
||||
var loc3:Vertex = null;
|
||||
var loc4:Vertex = null;
|
||||
var loc5:* = undefined;
|
||||
var loc6:Face = null;
|
||||
var loc1:Set = new Set(true);
|
||||
var loc2:uint = 0;
|
||||
while(loc2 < this.alternativa3d::_verticesCount)
|
||||
{
|
||||
loc3 = this.alternativa3d::_vertices[loc2];
|
||||
loc4 = this.alternativa3d::_vertices[loc2 < this.alternativa3d::_verticesCount - 1 ? loc2 + 1 : 0];
|
||||
for(loc5 in loc3.alternativa3d::_faces)
|
||||
{
|
||||
loc6 = loc5;
|
||||
if(loc6 != this && loc6.alternativa3d::_vertices.indexOf(loc4) >= 0)
|
||||
{
|
||||
loc1[loc6] = true;
|
||||
}
|
||||
}
|
||||
loc2++;
|
||||
}
|
||||
return loc1;
|
||||
}
|
||||
|
||||
alternativa3d function removeVertices() : void
|
||||
{
|
||||
var loc2:Vertex = null;
|
||||
var loc1:uint = 0;
|
||||
while(loc1 < this.alternativa3d::_verticesCount)
|
||||
{
|
||||
loc2 = this.alternativa3d::_vertices.pop();
|
||||
loc2.alternativa3d::removeFromFace(this);
|
||||
loc1++;
|
||||
}
|
||||
this.alternativa3d::primitive.alternativa3d::points.length = 0;
|
||||
this.alternativa3d::_verticesCount = 0;
|
||||
}
|
||||
|
||||
alternativa3d function addToScene(param1:Scene3D) : void
|
||||
{
|
||||
param1.alternativa3d::addOperation(this.alternativa3d::calculateNormalOperation);
|
||||
param1.alternativa3d::addOperation(this.alternativa3d::calculateBaseUVOperation);
|
||||
this.alternativa3d::updatePrimitiveOperation.alternativa3d::addSequel(param1.alternativa3d::calculateBSPOperation);
|
||||
this.alternativa3d::updateMaterialOperation.alternativa3d::addSequel(param1.alternativa3d::changePrimitivesOperation);
|
||||
}
|
||||
|
||||
alternativa3d function removeFromScene(param1:Scene3D) : void
|
||||
{
|
||||
param1.alternativa3d::removeOperation(this.alternativa3d::calculateBaseUVOperation);
|
||||
param1.alternativa3d::removeOperation(this.alternativa3d::calculateNormalOperation);
|
||||
param1.alternativa3d::removeOperation(this.alternativa3d::updatePrimitiveOperation);
|
||||
param1.alternativa3d::removeOperation(this.alternativa3d::updateMaterialOperation);
|
||||
this.removePrimitive(this.alternativa3d::primitive);
|
||||
param1.alternativa3d::addOperation(param1.alternativa3d::calculateBSPOperation);
|
||||
this.alternativa3d::updatePrimitiveOperation.alternativa3d::removeSequel(param1.alternativa3d::calculateBSPOperation);
|
||||
this.alternativa3d::updateMaterialOperation.alternativa3d::removeSequel(param1.alternativa3d::changePrimitivesOperation);
|
||||
}
|
||||
|
||||
alternativa3d function addToMesh(param1:Mesh) : void
|
||||
{
|
||||
param1.alternativa3d::changeCoordsOperation.alternativa3d::addSequel(this.alternativa3d::updatePrimitiveOperation);
|
||||
param1.alternativa3d::changeCoordsOperation.alternativa3d::addSequel(this.alternativa3d::calculateUVOperation);
|
||||
param1.alternativa3d::changeRotationOrScaleOperation.alternativa3d::addSequel(this.alternativa3d::calculateNormalOperation);
|
||||
param1.alternativa3d::calculateMobilityOperation.alternativa3d::addSequel(this.alternativa3d::updatePrimitiveOperation);
|
||||
this.alternativa3d::_mesh = param1;
|
||||
}
|
||||
|
||||
alternativa3d function removeFromMesh(param1:Mesh) : void
|
||||
{
|
||||
param1.alternativa3d::changeCoordsOperation.alternativa3d::removeSequel(this.alternativa3d::updatePrimitiveOperation);
|
||||
param1.alternativa3d::changeCoordsOperation.alternativa3d::removeSequel(this.alternativa3d::calculateUVOperation);
|
||||
param1.alternativa3d::changeRotationOrScaleOperation.alternativa3d::removeSequel(this.alternativa3d::calculateNormalOperation);
|
||||
param1.alternativa3d::calculateMobilityOperation.alternativa3d::removeSequel(this.alternativa3d::updatePrimitiveOperation);
|
||||
this.alternativa3d::_mesh = null;
|
||||
}
|
||||
|
||||
alternativa3d function addToSurface(param1:Surface) : void
|
||||
{
|
||||
param1.alternativa3d::changeMaterialOperation.alternativa3d::addSequel(this.alternativa3d::updateMaterialOperation);
|
||||
if(this.alternativa3d::_mesh != null && (this.alternativa3d::_surface != null && this.alternativa3d::_surface.alternativa3d::_material != param1.alternativa3d::_material || this.alternativa3d::_surface == null && param1.alternativa3d::_material != null))
|
||||
{
|
||||
this.alternativa3d::_mesh.alternativa3d::addOperationToScene(this.alternativa3d::updateMaterialOperation);
|
||||
}
|
||||
this.alternativa3d::_surface = param1;
|
||||
}
|
||||
|
||||
alternativa3d function removeFromSurface(param1:Surface) : void
|
||||
{
|
||||
param1.alternativa3d::changeMaterialOperation.alternativa3d::removeSequel(this.alternativa3d::updateMaterialOperation);
|
||||
if(param1.alternativa3d::_material != null)
|
||||
{
|
||||
this.alternativa3d::_mesh.alternativa3d::addOperationToScene(this.alternativa3d::updateMaterialOperation);
|
||||
}
|
||||
this.alternativa3d::_surface = null;
|
||||
}
|
||||
|
||||
public function toString() : String
|
||||
{
|
||||
var loc3:Vertex = null;
|
||||
var loc1:String = "[Face ID:" + this.id + (this.alternativa3d::_verticesCount > 0 ? " vertices:" : "");
|
||||
var loc2:uint = 0;
|
||||
while(loc2 < this.alternativa3d::_verticesCount)
|
||||
{
|
||||
loc3 = this.alternativa3d::_vertices[loc2];
|
||||
loc1 += loc3.id + (loc2 < this.alternativa3d::_verticesCount - 1 ? ", " : "");
|
||||
loc2++;
|
||||
}
|
||||
return loc1 + "]";
|
||||
}
|
||||
|
||||
public function addEventListener(param1:String, param2:Function, param3:Boolean = false, param4:int = 0, param5:Boolean = false) : void
|
||||
{
|
||||
if(this.dispatcher == null)
|
||||
{
|
||||
this.dispatcher = new EventDispatcher(this);
|
||||
}
|
||||
param3 = false;
|
||||
this.dispatcher.addEventListener(param1,param2,param3,param4,param5);
|
||||
}
|
||||
|
||||
public function dispatchEvent(param1:Event) : Boolean
|
||||
{
|
||||
if(this.dispatcher != null)
|
||||
{
|
||||
this.dispatcher.dispatchEvent(param1);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function hasEventListener(param1:String) : Boolean
|
||||
{
|
||||
if(this.dispatcher != null)
|
||||
{
|
||||
return this.dispatcher.hasEventListener(param1);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function removeEventListener(param1:String, param2:Function, param3:Boolean = false) : void
|
||||
{
|
||||
if(this.dispatcher != null)
|
||||
{
|
||||
param3 = false;
|
||||
this.dispatcher.removeEventListener(param1,param2,param3);
|
||||
}
|
||||
}
|
||||
|
||||
public function willTrigger(param1:String) : Boolean
|
||||
{
|
||||
if(this.dispatcher != null)
|
||||
{
|
||||
return this.dispatcher.willTrigger(param1);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,738 +0,0 @@
|
||||
package alternativa.engine3d.core
|
||||
{
|
||||
import alternativa.engine3d.*;
|
||||
import alternativa.engine3d.errors.FaceExistsError;
|
||||
import alternativa.engine3d.errors.FaceNeedMoreVerticesError;
|
||||
import alternativa.engine3d.errors.FaceNotFoundError;
|
||||
import alternativa.engine3d.errors.InvalidIDError;
|
||||
import alternativa.engine3d.errors.SurfaceExistsError;
|
||||
import alternativa.engine3d.errors.SurfaceNotFoundError;
|
||||
import alternativa.engine3d.errors.VertexExistsError;
|
||||
import alternativa.engine3d.errors.VertexNotFoundError;
|
||||
import alternativa.engine3d.materials.SurfaceMaterial;
|
||||
import alternativa.types.Map;
|
||||
import alternativa.utils.ObjectUtils;
|
||||
import flash.geom.Point;
|
||||
|
||||
use namespace alternativa3d;
|
||||
|
||||
public class Mesh extends Object3D
|
||||
{
|
||||
private static var counter:uint = 0;
|
||||
|
||||
private var vertexIDCounter:uint = 0;
|
||||
|
||||
private var faceIDCounter:uint = 0;
|
||||
|
||||
private var surfaceIDCounter:uint = 0;
|
||||
|
||||
alternativa3d var _vertices:Map;
|
||||
|
||||
alternativa3d var _faces:Map;
|
||||
|
||||
alternativa3d var _surfaces:Map;
|
||||
|
||||
public function Mesh(param1:String = null)
|
||||
{
|
||||
this.alternativa3d::_vertices = new Map();
|
||||
this.alternativa3d::_faces = new Map();
|
||||
this.alternativa3d::_surfaces = new Map();
|
||||
super(param1);
|
||||
}
|
||||
|
||||
public function createVertex(param1:Number = 0, param2:Number = 0, param3:Number = 0, param4:Object = null) : Vertex
|
||||
{
|
||||
if(param4 != null)
|
||||
{
|
||||
if(this.alternativa3d::_vertices[param4] != undefined)
|
||||
{
|
||||
if(this.alternativa3d::_vertices[param4] is Vertex)
|
||||
{
|
||||
throw new VertexExistsError(param4,this);
|
||||
}
|
||||
throw new InvalidIDError(param4,this);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while(this.alternativa3d::_vertices[this.vertexIDCounter] != undefined)
|
||||
{
|
||||
++this.vertexIDCounter;
|
||||
}
|
||||
param4 = this.vertexIDCounter;
|
||||
}
|
||||
var loc5:Vertex = new Vertex(param1,param2,param3);
|
||||
if(alternativa3d::_scene != null)
|
||||
{
|
||||
loc5.alternativa3d::addToScene(alternativa3d::_scene);
|
||||
}
|
||||
loc5.alternativa3d::addToMesh(this);
|
||||
this.alternativa3d::_vertices[param4] = loc5;
|
||||
return loc5;
|
||||
}
|
||||
|
||||
public function removeVertex(param1:Object) : Vertex
|
||||
{
|
||||
var loc2:* = param1 is Vertex;
|
||||
if(param1 == null)
|
||||
{
|
||||
throw new VertexNotFoundError(null,this);
|
||||
}
|
||||
if(loc2)
|
||||
{
|
||||
if(Vertex(param1).alternativa3d::_mesh != this)
|
||||
{
|
||||
throw new VertexNotFoundError(param1,this);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(this.alternativa3d::_vertices[param1] == undefined)
|
||||
{
|
||||
throw new VertexNotFoundError(param1,this);
|
||||
}
|
||||
if(!(this.alternativa3d::_vertices[param1] is Vertex))
|
||||
{
|
||||
throw new InvalidIDError(param1,this);
|
||||
}
|
||||
}
|
||||
var loc3:Vertex = loc2 ? Vertex(param1) : this.alternativa3d::_vertices[param1];
|
||||
var loc4:Object = loc2 ? this.getVertexId(Vertex(param1)) : param1;
|
||||
if(alternativa3d::_scene != null)
|
||||
{
|
||||
loc3.alternativa3d::removeFromScene(alternativa3d::_scene);
|
||||
}
|
||||
loc3.alternativa3d::removeFromMesh(this);
|
||||
delete this.alternativa3d::_vertices[loc4];
|
||||
return loc3;
|
||||
}
|
||||
|
||||
public function createFace(param1:Array, param2:Object = null) : Face
|
||||
{
|
||||
var loc5:Vertex = null;
|
||||
if(param1 == null)
|
||||
{
|
||||
throw new FaceNeedMoreVerticesError(this);
|
||||
}
|
||||
if(param2 != null)
|
||||
{
|
||||
if(this.alternativa3d::_faces[param2] != undefined)
|
||||
{
|
||||
if(this.alternativa3d::_faces[param2] is Face)
|
||||
{
|
||||
throw new FaceExistsError(param2,this);
|
||||
}
|
||||
throw new InvalidIDError(param2,this);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while(this.alternativa3d::_faces[this.faceIDCounter] != undefined)
|
||||
{
|
||||
++this.faceIDCounter;
|
||||
}
|
||||
param2 = this.faceIDCounter;
|
||||
}
|
||||
var loc3:uint = param1.length;
|
||||
if(loc3 < 3)
|
||||
{
|
||||
throw new FaceNeedMoreVerticesError(this,loc3);
|
||||
}
|
||||
var loc4:Array = new Array();
|
||||
var loc6:uint = 0;
|
||||
while(loc6 < loc3)
|
||||
{
|
||||
if(param1[loc6] is Vertex)
|
||||
{
|
||||
loc5 = param1[loc6];
|
||||
if(loc5.alternativa3d::_mesh != this)
|
||||
{
|
||||
throw new VertexNotFoundError(param1[loc6],this);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(this.alternativa3d::_vertices[param1[loc6]] == null)
|
||||
{
|
||||
throw new VertexNotFoundError(param1[loc6],this);
|
||||
}
|
||||
if(!(this.alternativa3d::_vertices[param1[loc6]] is Vertex))
|
||||
{
|
||||
throw new InvalidIDError(param1[loc6],this);
|
||||
}
|
||||
loc5 = this.alternativa3d::_vertices[param1[loc6]];
|
||||
}
|
||||
loc4.push(loc5);
|
||||
loc6++;
|
||||
}
|
||||
var loc7:Face = new Face(loc4);
|
||||
if(alternativa3d::_scene != null)
|
||||
{
|
||||
loc7.alternativa3d::addToScene(alternativa3d::_scene);
|
||||
}
|
||||
loc7.alternativa3d::addToMesh(this);
|
||||
this.alternativa3d::_faces[param2] = loc7;
|
||||
return loc7;
|
||||
}
|
||||
|
||||
public function removeFace(param1:Object) : Face
|
||||
{
|
||||
var loc2:* = param1 is Face;
|
||||
if(param1 == null)
|
||||
{
|
||||
throw new FaceNotFoundError(null,this);
|
||||
}
|
||||
if(loc2)
|
||||
{
|
||||
if(Face(param1).alternativa3d::_mesh != this)
|
||||
{
|
||||
throw new FaceNotFoundError(param1,this);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(this.alternativa3d::_faces[param1] == undefined)
|
||||
{
|
||||
throw new FaceNotFoundError(param1,this);
|
||||
}
|
||||
if(!(this.alternativa3d::_faces[param1] is Face))
|
||||
{
|
||||
throw new InvalidIDError(param1,this);
|
||||
}
|
||||
}
|
||||
var loc3:Face = loc2 ? Face(param1) : this.alternativa3d::_faces[param1];
|
||||
var loc4:Object = loc2 ? this.getFaceId(Face(param1)) : param1;
|
||||
loc3.alternativa3d::removeVertices();
|
||||
if(loc3.alternativa3d::_surface != null)
|
||||
{
|
||||
loc3.alternativa3d::_surface.alternativa3d::_faces.remove(loc3);
|
||||
loc3.alternativa3d::removeFromSurface(loc3.alternativa3d::_surface);
|
||||
}
|
||||
if(alternativa3d::_scene != null)
|
||||
{
|
||||
loc3.alternativa3d::removeFromScene(alternativa3d::_scene);
|
||||
}
|
||||
loc3.alternativa3d::removeFromMesh(this);
|
||||
delete this.alternativa3d::_faces[loc4];
|
||||
return loc3;
|
||||
}
|
||||
|
||||
public function createSurface(param1:Array = null, param2:Object = null) : Surface
|
||||
{
|
||||
var loc4:uint = 0;
|
||||
var loc5:uint = 0;
|
||||
if(param2 != null)
|
||||
{
|
||||
if(this.alternativa3d::_surfaces[param2] != undefined)
|
||||
{
|
||||
if(this.alternativa3d::_surfaces[param2] is Surface)
|
||||
{
|
||||
throw new SurfaceExistsError(param2,this);
|
||||
}
|
||||
throw new InvalidIDError(param2,this);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while(this.alternativa3d::_surfaces[this.surfaceIDCounter] != undefined)
|
||||
{
|
||||
++this.surfaceIDCounter;
|
||||
}
|
||||
param2 = this.surfaceIDCounter;
|
||||
}
|
||||
var loc3:Surface = new Surface();
|
||||
if(alternativa3d::_scene != null)
|
||||
{
|
||||
loc3.alternativa3d::addToScene(alternativa3d::_scene);
|
||||
}
|
||||
loc3.alternativa3d::addToMesh(this);
|
||||
this.alternativa3d::_surfaces[param2] = loc3;
|
||||
if(param1 != null)
|
||||
{
|
||||
loc4 = param1.length;
|
||||
loc5 = 0;
|
||||
while(loc5 < loc4)
|
||||
{
|
||||
loc3.addFace(param1[loc5]);
|
||||
loc5++;
|
||||
}
|
||||
}
|
||||
return loc3;
|
||||
}
|
||||
|
||||
public function removeSurface(param1:Object) : Surface
|
||||
{
|
||||
var loc2:* = param1 is Surface;
|
||||
if(param1 == null)
|
||||
{
|
||||
throw new SurfaceNotFoundError(null,this);
|
||||
}
|
||||
if(loc2)
|
||||
{
|
||||
if(Surface(param1).alternativa3d::_mesh != this)
|
||||
{
|
||||
throw new SurfaceNotFoundError(param1,this);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(this.alternativa3d::_surfaces[param1] == undefined)
|
||||
{
|
||||
throw new SurfaceNotFoundError(param1,this);
|
||||
}
|
||||
if(!(this.alternativa3d::_surfaces[param1] is Surface))
|
||||
{
|
||||
throw new InvalidIDError(param1,this);
|
||||
}
|
||||
}
|
||||
var loc3:Surface = loc2 ? Surface(param1) : this.alternativa3d::_surfaces[param1];
|
||||
var loc4:Object = loc2 ? this.getSurfaceId(Surface(param1)) : param1;
|
||||
if(alternativa3d::_scene != null)
|
||||
{
|
||||
loc3.alternativa3d::removeFromScene(alternativa3d::_scene);
|
||||
}
|
||||
loc3.alternativa3d::removeFaces();
|
||||
loc3.alternativa3d::removeFromMesh(this);
|
||||
delete this.alternativa3d::_surfaces[loc4];
|
||||
return loc3;
|
||||
}
|
||||
|
||||
public function moveAllFacesToSurface(param1:Object = null, param2:Boolean = false) : Surface
|
||||
{
|
||||
var loc3:Surface = null;
|
||||
var loc4:Object = null;
|
||||
var loc5:Face = null;
|
||||
var loc6:Map = null;
|
||||
var loc7:* = undefined;
|
||||
var loc8:Surface = null;
|
||||
if(param1 is Surface)
|
||||
{
|
||||
if(param1._mesh != this)
|
||||
{
|
||||
throw new SurfaceNotFoundError(param1,this);
|
||||
}
|
||||
loc3 = Surface(param1);
|
||||
}
|
||||
else if(this.alternativa3d::_surfaces[param1] == undefined)
|
||||
{
|
||||
loc3 = this.createSurface(null,param1);
|
||||
loc4 = param1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!(this.alternativa3d::_surfaces[param1] is Surface))
|
||||
{
|
||||
throw new InvalidIDError(param1,this);
|
||||
}
|
||||
loc3 = this.alternativa3d::_surfaces[param1];
|
||||
}
|
||||
for each(loc5 in this.alternativa3d::_faces)
|
||||
{
|
||||
if(loc5.alternativa3d::_surface != loc3)
|
||||
{
|
||||
loc3.addFace(loc5);
|
||||
}
|
||||
}
|
||||
if(param2)
|
||||
{
|
||||
if(loc4 == null)
|
||||
{
|
||||
loc4 = this.getSurfaceId(loc3);
|
||||
}
|
||||
loc6 = new Map();
|
||||
loc6[loc4] = loc3;
|
||||
delete this.alternativa3d::_surfaces[loc4];
|
||||
for(loc7 in this.alternativa3d::_surfaces)
|
||||
{
|
||||
loc8 = this.alternativa3d::_surfaces[loc7];
|
||||
if(alternativa3d::_scene != null)
|
||||
{
|
||||
loc8.alternativa3d::removeFromScene(alternativa3d::_scene);
|
||||
}
|
||||
loc8.alternativa3d::removeFromMesh(this);
|
||||
delete this.alternativa3d::_surfaces[loc7];
|
||||
}
|
||||
this.alternativa3d::_surfaces = loc6;
|
||||
}
|
||||
return loc3;
|
||||
}
|
||||
|
||||
public function setMaterialToSurface(param1:SurfaceMaterial, param2:Object) : void
|
||||
{
|
||||
var loc3:* = param2 is Surface;
|
||||
if(param2 == null)
|
||||
{
|
||||
throw new SurfaceNotFoundError(null,this);
|
||||
}
|
||||
if(loc3)
|
||||
{
|
||||
if(Surface(param2).alternativa3d::_mesh != this)
|
||||
{
|
||||
throw new SurfaceNotFoundError(param2,this);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(this.alternativa3d::_surfaces[param2] == undefined)
|
||||
{
|
||||
throw new SurfaceNotFoundError(param2,this);
|
||||
}
|
||||
if(!(this.alternativa3d::_surfaces[param2] is Surface))
|
||||
{
|
||||
throw new InvalidIDError(param2,this);
|
||||
}
|
||||
}
|
||||
var loc4:Surface = loc3 ? Surface(param2) : this.alternativa3d::_surfaces[param2];
|
||||
loc4.material = param1;
|
||||
}
|
||||
|
||||
public function cloneMaterialToAllSurfaces(param1:SurfaceMaterial) : void
|
||||
{
|
||||
var loc2:Surface = null;
|
||||
for each(loc2 in this.alternativa3d::_surfaces)
|
||||
{
|
||||
loc2.material = param1 != null ? SurfaceMaterial(param1.clone()) : null;
|
||||
}
|
||||
}
|
||||
|
||||
public function setUVsToFace(param1:Point, param2:Point, param3:Point, param4:Object) : void
|
||||
{
|
||||
var loc5:* = param4 is Face;
|
||||
if(param4 == null)
|
||||
{
|
||||
throw new FaceNotFoundError(null,this);
|
||||
}
|
||||
if(loc5)
|
||||
{
|
||||
if(Face(param4).alternativa3d::_mesh != this)
|
||||
{
|
||||
throw new FaceNotFoundError(param4,this);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(this.alternativa3d::_faces[param4] == undefined)
|
||||
{
|
||||
throw new FaceNotFoundError(param4,this);
|
||||
}
|
||||
if(!(this.alternativa3d::_faces[param4] is Face))
|
||||
{
|
||||
throw new InvalidIDError(param4,this);
|
||||
}
|
||||
}
|
||||
var loc6:Face = loc5 ? Face(param4) : this.alternativa3d::_faces[param4];
|
||||
loc6.aUV = param1;
|
||||
loc6.bUV = param2;
|
||||
loc6.cUV = param3;
|
||||
}
|
||||
|
||||
public function get vertices() : Map
|
||||
{
|
||||
return this.alternativa3d::_vertices.clone();
|
||||
}
|
||||
|
||||
public function get faces() : Map
|
||||
{
|
||||
return this.alternativa3d::_faces.clone();
|
||||
}
|
||||
|
||||
public function get surfaces() : Map
|
||||
{
|
||||
return this.alternativa3d::_surfaces.clone();
|
||||
}
|
||||
|
||||
public function getVertexById(param1:Object) : Vertex
|
||||
{
|
||||
if(param1 == null)
|
||||
{
|
||||
throw new VertexNotFoundError(null,this);
|
||||
}
|
||||
if(this.alternativa3d::_vertices[param1] == undefined)
|
||||
{
|
||||
throw new VertexNotFoundError(param1,this);
|
||||
}
|
||||
if(this.alternativa3d::_vertices[param1] is Vertex)
|
||||
{
|
||||
return this.alternativa3d::_vertices[param1];
|
||||
}
|
||||
throw new InvalidIDError(param1,this);
|
||||
}
|
||||
|
||||
public function getVertexId(param1:Vertex) : Object
|
||||
{
|
||||
var loc2:Object = null;
|
||||
if(param1 == null)
|
||||
{
|
||||
throw new VertexNotFoundError(null,this);
|
||||
}
|
||||
if(param1.alternativa3d::_mesh != this)
|
||||
{
|
||||
throw new VertexNotFoundError(param1,this);
|
||||
}
|
||||
for(loc2 in this.alternativa3d::_vertices)
|
||||
{
|
||||
if(this.alternativa3d::_vertices[loc2] == param1)
|
||||
{
|
||||
return loc2;
|
||||
}
|
||||
}
|
||||
throw new VertexNotFoundError(param1,this);
|
||||
}
|
||||
|
||||
public function hasVertex(param1:Object) : Boolean
|
||||
{
|
||||
if(param1 == null)
|
||||
{
|
||||
throw new VertexNotFoundError(null,this);
|
||||
}
|
||||
if(param1 is Vertex)
|
||||
{
|
||||
return param1._mesh == this;
|
||||
}
|
||||
if(this.alternativa3d::_vertices[param1] != undefined)
|
||||
{
|
||||
if(this.alternativa3d::_vertices[param1] is Vertex)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
throw new InvalidIDError(param1,this);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getFaceById(param1:Object) : Face
|
||||
{
|
||||
if(param1 == null)
|
||||
{
|
||||
throw new FaceNotFoundError(null,this);
|
||||
}
|
||||
if(this.alternativa3d::_faces[param1] == undefined)
|
||||
{
|
||||
throw new FaceNotFoundError(param1,this);
|
||||
}
|
||||
if(this.alternativa3d::_faces[param1] is Face)
|
||||
{
|
||||
return this.alternativa3d::_faces[param1];
|
||||
}
|
||||
throw new InvalidIDError(param1,this);
|
||||
}
|
||||
|
||||
public function getFaceId(param1:Face) : Object
|
||||
{
|
||||
var loc2:Object = null;
|
||||
if(param1 == null)
|
||||
{
|
||||
throw new FaceNotFoundError(null,this);
|
||||
}
|
||||
if(param1.alternativa3d::_mesh != this)
|
||||
{
|
||||
throw new FaceNotFoundError(param1,this);
|
||||
}
|
||||
for(loc2 in this.alternativa3d::_faces)
|
||||
{
|
||||
if(this.alternativa3d::_faces[loc2] == param1)
|
||||
{
|
||||
return loc2;
|
||||
}
|
||||
}
|
||||
throw new FaceNotFoundError(param1,this);
|
||||
}
|
||||
|
||||
public function hasFace(param1:Object) : Boolean
|
||||
{
|
||||
if(param1 == null)
|
||||
{
|
||||
throw new FaceNotFoundError(null,this);
|
||||
}
|
||||
if(param1 is Face)
|
||||
{
|
||||
return param1._mesh == this;
|
||||
}
|
||||
if(this.alternativa3d::_faces[param1] != undefined)
|
||||
{
|
||||
if(this.alternativa3d::_faces[param1] is Face)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
throw new InvalidIDError(param1,this);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getSurfaceById(param1:Object) : Surface
|
||||
{
|
||||
if(param1 == null)
|
||||
{
|
||||
throw new SurfaceNotFoundError(null,this);
|
||||
}
|
||||
if(this.alternativa3d::_surfaces[param1] == undefined)
|
||||
{
|
||||
throw new SurfaceNotFoundError(param1,this);
|
||||
}
|
||||
if(this.alternativa3d::_surfaces[param1] is Surface)
|
||||
{
|
||||
return this.alternativa3d::_surfaces[param1];
|
||||
}
|
||||
throw new InvalidIDError(param1,this);
|
||||
}
|
||||
|
||||
public function getSurfaceId(param1:Surface) : Object
|
||||
{
|
||||
var loc2:Object = null;
|
||||
if(param1 == null)
|
||||
{
|
||||
throw new SurfaceNotFoundError(null,this);
|
||||
}
|
||||
if(param1.alternativa3d::_mesh != this)
|
||||
{
|
||||
throw new SurfaceNotFoundError(param1,this);
|
||||
}
|
||||
for(loc2 in this.alternativa3d::_surfaces)
|
||||
{
|
||||
if(this.alternativa3d::_surfaces[loc2] == param1)
|
||||
{
|
||||
return loc2;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function hasSurface(param1:Object) : Boolean
|
||||
{
|
||||
if(param1 == null)
|
||||
{
|
||||
throw new SurfaceNotFoundError(null,this);
|
||||
}
|
||||
if(param1 is Surface)
|
||||
{
|
||||
return param1._mesh == this;
|
||||
}
|
||||
if(this.alternativa3d::_surfaces[param1] != undefined)
|
||||
{
|
||||
if(this.alternativa3d::_surfaces[param1] is Surface)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
throw new InvalidIDError(param1,this);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
override alternativa3d function setScene(param1:Scene3D) : void
|
||||
{
|
||||
var loc2:Vertex = null;
|
||||
var loc3:Face = null;
|
||||
var loc4:Surface = null;
|
||||
if(alternativa3d::_scene != param1)
|
||||
{
|
||||
if(param1 != null)
|
||||
{
|
||||
for each(loc2 in this.alternativa3d::_vertices)
|
||||
{
|
||||
loc2.alternativa3d::addToScene(param1);
|
||||
}
|
||||
for each(loc3 in this.alternativa3d::_faces)
|
||||
{
|
||||
loc3.alternativa3d::addToScene(param1);
|
||||
}
|
||||
for each(loc4 in this.alternativa3d::_surfaces)
|
||||
{
|
||||
loc4.alternativa3d::addToScene(param1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for each(loc2 in this.alternativa3d::_vertices)
|
||||
{
|
||||
loc2.alternativa3d::removeFromScene(alternativa3d::_scene);
|
||||
}
|
||||
for each(loc3 in this.alternativa3d::_faces)
|
||||
{
|
||||
loc3.alternativa3d::removeFromScene(alternativa3d::_scene);
|
||||
}
|
||||
for each(loc4 in this.alternativa3d::_surfaces)
|
||||
{
|
||||
loc4.alternativa3d::removeFromScene(alternativa3d::_scene);
|
||||
}
|
||||
}
|
||||
}
|
||||
super.alternativa3d::setScene(param1);
|
||||
}
|
||||
|
||||
override protected function defaultName() : String
|
||||
{
|
||||
return "mesh" + ++counter;
|
||||
}
|
||||
|
||||
override public function toString() : String
|
||||
{
|
||||
return "[" + ObjectUtils.getClassName(this) + " " + alternativa3d::_name + " vertices: " + this.alternativa3d::_vertices.length + " faces: " + this.alternativa3d::_faces.length + "]";
|
||||
}
|
||||
|
||||
override protected function createEmptyObject() : Object3D
|
||||
{
|
||||
return new Mesh();
|
||||
}
|
||||
|
||||
override protected function clonePropertiesFrom(param1:Object3D) : void
|
||||
{
|
||||
var loc3:* = undefined;
|
||||
var loc4:int = 0;
|
||||
var loc5:int = 0;
|
||||
var loc7:Map = null;
|
||||
var loc8:Vertex = null;
|
||||
var loc9:Face = null;
|
||||
var loc10:Array = null;
|
||||
var loc11:Face = null;
|
||||
var loc12:Surface = null;
|
||||
var loc13:Array = null;
|
||||
var loc14:Surface = null;
|
||||
var loc15:SurfaceMaterial = null;
|
||||
super.clonePropertiesFrom(param1);
|
||||
var loc2:Mesh = Mesh(param1);
|
||||
var loc6:Map = new Map(true);
|
||||
for(loc3 in loc2.alternativa3d::_vertices)
|
||||
{
|
||||
loc8 = loc2.alternativa3d::_vertices[loc3];
|
||||
loc6[loc8] = this.createVertex(loc8.x,loc8.y,loc8.z,loc3);
|
||||
}
|
||||
loc7 = new Map(true);
|
||||
for(loc3 in loc2.alternativa3d::_faces)
|
||||
{
|
||||
loc9 = loc2.alternativa3d::_faces[loc3];
|
||||
loc4 = int(loc9.alternativa3d::_vertices.length);
|
||||
loc10 = new Array(loc4);
|
||||
loc5 = 0;
|
||||
while(loc5 < loc4)
|
||||
{
|
||||
loc10[loc5] = loc6[loc9.alternativa3d::_vertices[loc5]];
|
||||
loc5++;
|
||||
}
|
||||
loc11 = this.createFace(loc10,loc3);
|
||||
loc11.aUV = loc9.alternativa3d::_aUV;
|
||||
loc11.bUV = loc9.alternativa3d::_bUV;
|
||||
loc11.cUV = loc9.alternativa3d::_cUV;
|
||||
loc7[loc9] = loc11;
|
||||
}
|
||||
for(loc3 in loc2.alternativa3d::_surfaces)
|
||||
{
|
||||
loc12 = loc2.alternativa3d::_surfaces[loc3];
|
||||
loc13 = loc12.alternativa3d::_faces.toArray();
|
||||
loc4 = int(loc13.length);
|
||||
loc5 = 0;
|
||||
while(loc5 < loc4)
|
||||
{
|
||||
loc13[loc5] = loc7[loc13[loc5]];
|
||||
loc5++;
|
||||
}
|
||||
loc14 = this.createSurface(loc13,loc3);
|
||||
loc15 = loc12.material;
|
||||
if(loc15 != null)
|
||||
{
|
||||
loc14.material = SurfaceMaterial(loc15.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,661 +0,0 @@
|
||||
package alternativa.engine3d.core
|
||||
{
|
||||
import alternativa.engine3d.alternativa3d;
|
||||
import alternativa.engine3d.errors.Object3DHierarchyError;
|
||||
import alternativa.engine3d.errors.Object3DNotFoundError;
|
||||
import alternativa.types.Matrix3D;
|
||||
import alternativa.types.Point3D;
|
||||
import alternativa.types.Set;
|
||||
import alternativa.utils.ObjectUtils;
|
||||
import flash.events.Event;
|
||||
import flash.events.EventDispatcher;
|
||||
import flash.events.IEventDispatcher;
|
||||
|
||||
use namespace alternativa3d;
|
||||
|
||||
public class Object3D implements IEventDispatcher
|
||||
{
|
||||
alternativa3d static var matrix1:Matrix3D = new Matrix3D();
|
||||
|
||||
alternativa3d static var matrix2:Matrix3D = new Matrix3D();
|
||||
|
||||
private static var counter:uint = 0;
|
||||
|
||||
alternativa3d var changeRotationOrScaleOperation:Operation;
|
||||
|
||||
alternativa3d var changeCoordsOperation:Operation;
|
||||
|
||||
alternativa3d var calculateTransformationOperation:Operation;
|
||||
|
||||
alternativa3d var calculateMobilityOperation:Operation;
|
||||
|
||||
alternativa3d var _name:String;
|
||||
|
||||
alternativa3d var _scene:Scene3D;
|
||||
|
||||
alternativa3d var _parent:Object3D;
|
||||
|
||||
alternativa3d var _children:Set;
|
||||
|
||||
alternativa3d var _mobility:int = 0;
|
||||
|
||||
alternativa3d var inheritedMobility:int;
|
||||
|
||||
alternativa3d var _coords:Point3D;
|
||||
|
||||
alternativa3d var _rotationX:Number = 0;
|
||||
|
||||
alternativa3d var _rotationY:Number = 0;
|
||||
|
||||
alternativa3d var _rotationZ:Number = 0;
|
||||
|
||||
alternativa3d var _scaleX:Number = 1;
|
||||
|
||||
alternativa3d var _scaleY:Number = 1;
|
||||
|
||||
alternativa3d var _scaleZ:Number = 1;
|
||||
|
||||
alternativa3d var _transformation:Matrix3D;
|
||||
|
||||
alternativa3d var globalCoords:Point3D;
|
||||
|
||||
public var mouseEnabled:Boolean = true;
|
||||
|
||||
private var dispatcher:EventDispatcher;
|
||||
|
||||
public function Object3D(param1:String = null)
|
||||
{
|
||||
this.alternativa3d::changeRotationOrScaleOperation = new Operation("changeRotationOrScale",this);
|
||||
this.alternativa3d::changeCoordsOperation = new Operation("changeCoords",this);
|
||||
this.alternativa3d::calculateTransformationOperation = new Operation("calculateTransformation",this,this.alternativa3d::calculateTransformation,Operation.alternativa3d::OBJECT_CALCULATE_TRANSFORMATION);
|
||||
this.alternativa3d::calculateMobilityOperation = new Operation("calculateMobility",this,this.calculateMobility,Operation.alternativa3d::OBJECT_CALCULATE_MOBILITY);
|
||||
this.alternativa3d::_children = new Set();
|
||||
this.alternativa3d::_coords = new Point3D();
|
||||
this.alternativa3d::_transformation = new Matrix3D();
|
||||
this.alternativa3d::globalCoords = new Point3D();
|
||||
super();
|
||||
this.alternativa3d::_name = param1 != null ? param1 : this.defaultName();
|
||||
this.alternativa3d::changeRotationOrScaleOperation.alternativa3d::addSequel(this.alternativa3d::calculateTransformationOperation);
|
||||
this.alternativa3d::changeCoordsOperation.alternativa3d::addSequel(this.alternativa3d::calculateTransformationOperation);
|
||||
}
|
||||
|
||||
alternativa3d function calculateTransformation() : void
|
||||
{
|
||||
if(this.alternativa3d::changeRotationOrScaleOperation.alternativa3d::queued)
|
||||
{
|
||||
this.alternativa3d::_transformation.toTransform(this.alternativa3d::_coords.x,this.alternativa3d::_coords.y,this.alternativa3d::_coords.z,this.alternativa3d::_rotationX,this.alternativa3d::_rotationY,this.alternativa3d::_rotationZ,this.alternativa3d::_scaleX,this.alternativa3d::_scaleY,this.alternativa3d::_scaleZ);
|
||||
if(this.alternativa3d::_parent != null)
|
||||
{
|
||||
this.alternativa3d::_transformation.combine(this.alternativa3d::_parent.alternativa3d::_transformation);
|
||||
}
|
||||
this.alternativa3d::globalCoords.x = this.alternativa3d::_transformation.d;
|
||||
this.alternativa3d::globalCoords.y = this.alternativa3d::_transformation.h;
|
||||
this.alternativa3d::globalCoords.z = this.alternativa3d::_transformation.l;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.alternativa3d::globalCoords.copy(this.alternativa3d::_coords);
|
||||
if(this.alternativa3d::_parent != null)
|
||||
{
|
||||
this.alternativa3d::globalCoords.transform(this.alternativa3d::_parent.alternativa3d::_transformation);
|
||||
}
|
||||
this.alternativa3d::_transformation.offset(this.alternativa3d::globalCoords.x,this.alternativa3d::globalCoords.y,this.alternativa3d::globalCoords.z);
|
||||
}
|
||||
}
|
||||
|
||||
private function calculateMobility() : void
|
||||
{
|
||||
this.alternativa3d::inheritedMobility = (this.alternativa3d::_parent != null ? this.alternativa3d::_parent.alternativa3d::inheritedMobility : 0) + this.alternativa3d::_mobility;
|
||||
}
|
||||
|
||||
public function addChild(param1:Object3D) : Object3D
|
||||
{
|
||||
var loc2:Object3D = null;
|
||||
if(param1 == null)
|
||||
{
|
||||
throw new Object3DHierarchyError(null,this);
|
||||
}
|
||||
if(param1.alternativa3d::_parent == this)
|
||||
{
|
||||
return param1;
|
||||
}
|
||||
if(param1 == this)
|
||||
{
|
||||
throw new Object3DHierarchyError(this,this);
|
||||
}
|
||||
if(param1.alternativa3d::_scene == this.alternativa3d::_scene)
|
||||
{
|
||||
loc2 = this.alternativa3d::_parent;
|
||||
while(loc2 != null)
|
||||
{
|
||||
if(param1 == loc2)
|
||||
{
|
||||
throw new Object3DHierarchyError(param1,this);
|
||||
}
|
||||
loc2 = loc2.alternativa3d::_parent;
|
||||
}
|
||||
}
|
||||
if(param1.alternativa3d::_parent != null)
|
||||
{
|
||||
param1.alternativa3d::_parent.alternativa3d::_children.remove(param1);
|
||||
}
|
||||
else if(param1.alternativa3d::_scene != null && param1.alternativa3d::_scene.alternativa3d::_root == param1)
|
||||
{
|
||||
param1.alternativa3d::_scene.root = null;
|
||||
}
|
||||
this.alternativa3d::_children.add(param1);
|
||||
param1.alternativa3d::setParent(this);
|
||||
param1.alternativa3d::setLevel((this.alternativa3d::calculateTransformationOperation.alternativa3d::priority & 0xFFFFFF) + 1);
|
||||
param1.alternativa3d::setScene(this.alternativa3d::_scene);
|
||||
return param1;
|
||||
}
|
||||
|
||||
public function removeChild(param1:Object3D) : Object3D
|
||||
{
|
||||
if(param1 == null)
|
||||
{
|
||||
throw new Object3DNotFoundError(null,this);
|
||||
}
|
||||
if(param1.alternativa3d::_parent != this)
|
||||
{
|
||||
throw new Object3DNotFoundError(param1,this);
|
||||
}
|
||||
this.alternativa3d::_children.remove(param1);
|
||||
param1.alternativa3d::setParent(null);
|
||||
param1.alternativa3d::setScene(null);
|
||||
return param1;
|
||||
}
|
||||
|
||||
alternativa3d function setParent(param1:Object3D) : void
|
||||
{
|
||||
if(this.alternativa3d::_parent != null)
|
||||
{
|
||||
this.removeParentSequels();
|
||||
}
|
||||
this.alternativa3d::_parent = param1;
|
||||
if(param1 != null)
|
||||
{
|
||||
this.addParentSequels();
|
||||
}
|
||||
}
|
||||
|
||||
alternativa3d function setScene(param1:Scene3D) : void
|
||||
{
|
||||
var loc2:* = undefined;
|
||||
var loc3:Object3D = null;
|
||||
if(this.alternativa3d::_scene != param1)
|
||||
{
|
||||
if(this.alternativa3d::_scene != null)
|
||||
{
|
||||
this.removeFromScene(this.alternativa3d::_scene);
|
||||
}
|
||||
if(param1 != null)
|
||||
{
|
||||
this.addToScene(param1);
|
||||
}
|
||||
this.alternativa3d::_scene = param1;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.alternativa3d::addOperationToScene(this.alternativa3d::changeRotationOrScaleOperation);
|
||||
this.alternativa3d::addOperationToScene(this.alternativa3d::calculateMobilityOperation);
|
||||
}
|
||||
for(loc2 in this.alternativa3d::_children)
|
||||
{
|
||||
loc3 = loc2;
|
||||
loc3.alternativa3d::setScene(this.alternativa3d::_scene);
|
||||
}
|
||||
}
|
||||
|
||||
alternativa3d function setLevel(param1:uint) : void
|
||||
{
|
||||
var loc2:* = undefined;
|
||||
var loc3:Object3D = null;
|
||||
this.alternativa3d::calculateTransformationOperation.alternativa3d::priority = this.alternativa3d::calculateTransformationOperation.alternativa3d::priority & 4278190080 | param1;
|
||||
this.alternativa3d::calculateMobilityOperation.alternativa3d::priority = this.alternativa3d::calculateMobilityOperation.alternativa3d::priority & 4278190080 | param1;
|
||||
for(loc2 in this.alternativa3d::_children)
|
||||
{
|
||||
loc3 = loc2;
|
||||
loc3.alternativa3d::setLevel(param1 + 1);
|
||||
}
|
||||
}
|
||||
|
||||
private function addParentSequels() : void
|
||||
{
|
||||
this.alternativa3d::_parent.alternativa3d::changeCoordsOperation.alternativa3d::addSequel(this.alternativa3d::changeCoordsOperation);
|
||||
this.alternativa3d::_parent.alternativa3d::changeRotationOrScaleOperation.alternativa3d::addSequel(this.alternativa3d::changeRotationOrScaleOperation);
|
||||
this.alternativa3d::_parent.alternativa3d::calculateMobilityOperation.alternativa3d::addSequel(this.alternativa3d::calculateMobilityOperation);
|
||||
}
|
||||
|
||||
private function removeParentSequels() : void
|
||||
{
|
||||
this.alternativa3d::_parent.alternativa3d::changeCoordsOperation.alternativa3d::removeSequel(this.alternativa3d::changeCoordsOperation);
|
||||
this.alternativa3d::_parent.alternativa3d::changeRotationOrScaleOperation.alternativa3d::removeSequel(this.alternativa3d::changeRotationOrScaleOperation);
|
||||
this.alternativa3d::_parent.alternativa3d::calculateMobilityOperation.alternativa3d::removeSequel(this.alternativa3d::calculateMobilityOperation);
|
||||
}
|
||||
|
||||
protected function addToScene(param1:Scene3D) : void
|
||||
{
|
||||
param1.alternativa3d::addOperation(this.alternativa3d::changeRotationOrScaleOperation);
|
||||
param1.alternativa3d::addOperation(this.alternativa3d::calculateMobilityOperation);
|
||||
}
|
||||
|
||||
protected function removeFromScene(param1:Scene3D) : void
|
||||
{
|
||||
param1.alternativa3d::removeOperation(this.alternativa3d::changeRotationOrScaleOperation);
|
||||
param1.alternativa3d::removeOperation(this.alternativa3d::changeCoordsOperation);
|
||||
param1.alternativa3d::removeOperation(this.alternativa3d::calculateMobilityOperation);
|
||||
}
|
||||
|
||||
public function get name() : String
|
||||
{
|
||||
return this.alternativa3d::_name;
|
||||
}
|
||||
|
||||
public function set name(param1:String) : void
|
||||
{
|
||||
this.alternativa3d::_name = param1;
|
||||
}
|
||||
|
||||
public function get scene() : Scene3D
|
||||
{
|
||||
return this.alternativa3d::_scene;
|
||||
}
|
||||
|
||||
public function get parent() : Object3D
|
||||
{
|
||||
return this.alternativa3d::_parent;
|
||||
}
|
||||
|
||||
public function get children() : Set
|
||||
{
|
||||
return this.alternativa3d::_children.clone();
|
||||
}
|
||||
|
||||
public function get mobility() : int
|
||||
{
|
||||
return this.alternativa3d::_mobility;
|
||||
}
|
||||
|
||||
public function set mobility(param1:int) : void
|
||||
{
|
||||
if(this.alternativa3d::_mobility != param1)
|
||||
{
|
||||
this.alternativa3d::_mobility = param1;
|
||||
this.alternativa3d::addOperationToScene(this.alternativa3d::calculateMobilityOperation);
|
||||
}
|
||||
}
|
||||
|
||||
public function get x() : Number
|
||||
{
|
||||
return this.alternativa3d::_coords.x;
|
||||
}
|
||||
|
||||
public function get y() : Number
|
||||
{
|
||||
return this.alternativa3d::_coords.y;
|
||||
}
|
||||
|
||||
public function get z() : Number
|
||||
{
|
||||
return this.alternativa3d::_coords.z;
|
||||
}
|
||||
|
||||
public function set x(param1:Number) : void
|
||||
{
|
||||
if(this.alternativa3d::_coords.x != param1)
|
||||
{
|
||||
this.alternativa3d::_coords.x = param1;
|
||||
this.alternativa3d::addOperationToScene(this.alternativa3d::changeCoordsOperation);
|
||||
}
|
||||
}
|
||||
|
||||
public function set y(param1:Number) : void
|
||||
{
|
||||
if(this.alternativa3d::_coords.y != param1)
|
||||
{
|
||||
this.alternativa3d::_coords.y = param1;
|
||||
this.alternativa3d::addOperationToScene(this.alternativa3d::changeCoordsOperation);
|
||||
}
|
||||
}
|
||||
|
||||
public function set z(param1:Number) : void
|
||||
{
|
||||
if(this.alternativa3d::_coords.z != param1)
|
||||
{
|
||||
this.alternativa3d::_coords.z = param1;
|
||||
this.alternativa3d::addOperationToScene(this.alternativa3d::changeCoordsOperation);
|
||||
}
|
||||
}
|
||||
|
||||
public function get coords() : Point3D
|
||||
{
|
||||
return this.alternativa3d::_coords.clone();
|
||||
}
|
||||
|
||||
public function set coords(param1:Point3D) : void
|
||||
{
|
||||
if(!this.alternativa3d::_coords.equals(param1))
|
||||
{
|
||||
this.alternativa3d::_coords.copy(param1);
|
||||
this.alternativa3d::addOperationToScene(this.alternativa3d::changeCoordsOperation);
|
||||
}
|
||||
}
|
||||
|
||||
public function get rotationX() : Number
|
||||
{
|
||||
return this.alternativa3d::_rotationX;
|
||||
}
|
||||
|
||||
public function get rotationY() : Number
|
||||
{
|
||||
return this.alternativa3d::_rotationY;
|
||||
}
|
||||
|
||||
public function get rotationZ() : Number
|
||||
{
|
||||
return this.alternativa3d::_rotationZ;
|
||||
}
|
||||
|
||||
public function set rotationX(param1:Number) : void
|
||||
{
|
||||
if(this.alternativa3d::_rotationX != param1)
|
||||
{
|
||||
this.alternativa3d::_rotationX = param1;
|
||||
this.alternativa3d::addOperationToScene(this.alternativa3d::changeRotationOrScaleOperation);
|
||||
}
|
||||
}
|
||||
|
||||
public function set rotationY(param1:Number) : void
|
||||
{
|
||||
if(this.alternativa3d::_rotationY != param1)
|
||||
{
|
||||
this.alternativa3d::_rotationY = param1;
|
||||
this.alternativa3d::addOperationToScene(this.alternativa3d::changeRotationOrScaleOperation);
|
||||
}
|
||||
}
|
||||
|
||||
public function set rotationZ(param1:Number) : void
|
||||
{
|
||||
if(this.alternativa3d::_rotationZ != param1)
|
||||
{
|
||||
this.alternativa3d::_rotationZ = param1;
|
||||
this.alternativa3d::addOperationToScene(this.alternativa3d::changeRotationOrScaleOperation);
|
||||
}
|
||||
}
|
||||
|
||||
public function get scaleX() : Number
|
||||
{
|
||||
return this.alternativa3d::_scaleX;
|
||||
}
|
||||
|
||||
public function get scaleY() : Number
|
||||
{
|
||||
return this.alternativa3d::_scaleY;
|
||||
}
|
||||
|
||||
public function get scaleZ() : Number
|
||||
{
|
||||
return this.alternativa3d::_scaleZ;
|
||||
}
|
||||
|
||||
public function set scaleX(param1:Number) : void
|
||||
{
|
||||
if(this.alternativa3d::_scaleX != param1)
|
||||
{
|
||||
this.alternativa3d::_scaleX = param1;
|
||||
this.alternativa3d::addOperationToScene(this.alternativa3d::changeRotationOrScaleOperation);
|
||||
}
|
||||
}
|
||||
|
||||
public function set scaleY(param1:Number) : void
|
||||
{
|
||||
if(this.alternativa3d::_scaleY != param1)
|
||||
{
|
||||
this.alternativa3d::_scaleY = param1;
|
||||
this.alternativa3d::addOperationToScene(this.alternativa3d::changeRotationOrScaleOperation);
|
||||
}
|
||||
}
|
||||
|
||||
public function set scaleZ(param1:Number) : void
|
||||
{
|
||||
if(this.alternativa3d::_scaleZ != param1)
|
||||
{
|
||||
this.alternativa3d::_scaleZ = param1;
|
||||
this.alternativa3d::addOperationToScene(this.alternativa3d::changeRotationOrScaleOperation);
|
||||
}
|
||||
}
|
||||
|
||||
public function toString() : String
|
||||
{
|
||||
return "[" + ObjectUtils.getClassName(this) + " " + this.alternativa3d::_name + "]";
|
||||
}
|
||||
|
||||
protected function defaultName() : String
|
||||
{
|
||||
return "object" + ++counter;
|
||||
}
|
||||
|
||||
alternativa3d function addOperationToScene(param1:Operation) : void
|
||||
{
|
||||
if(this.alternativa3d::_scene != null)
|
||||
{
|
||||
this.alternativa3d::_scene.alternativa3d::addOperation(param1);
|
||||
}
|
||||
}
|
||||
|
||||
alternativa3d function removeOperationFromScene(param1:Operation) : void
|
||||
{
|
||||
if(this.alternativa3d::_scene != null)
|
||||
{
|
||||
this.alternativa3d::_scene.alternativa3d::removeOperation(param1);
|
||||
}
|
||||
}
|
||||
|
||||
protected function createEmptyObject() : Object3D
|
||||
{
|
||||
return new Object3D();
|
||||
}
|
||||
|
||||
protected function clonePropertiesFrom(param1:Object3D) : void
|
||||
{
|
||||
this.alternativa3d::_name = param1.alternativa3d::_name;
|
||||
this.alternativa3d::_mobility = param1.alternativa3d::_mobility;
|
||||
this.alternativa3d::_coords.x = param1.alternativa3d::_coords.x;
|
||||
this.alternativa3d::_coords.y = param1.alternativa3d::_coords.y;
|
||||
this.alternativa3d::_coords.z = param1.alternativa3d::_coords.z;
|
||||
this.alternativa3d::_rotationX = param1.alternativa3d::_rotationX;
|
||||
this.alternativa3d::_rotationY = param1.alternativa3d::_rotationY;
|
||||
this.alternativa3d::_rotationZ = param1.alternativa3d::_rotationZ;
|
||||
this.alternativa3d::_scaleX = param1.alternativa3d::_scaleX;
|
||||
this.alternativa3d::_scaleY = param1.alternativa3d::_scaleY;
|
||||
this.alternativa3d::_scaleZ = param1.alternativa3d::_scaleZ;
|
||||
}
|
||||
|
||||
public function clone() : Object3D
|
||||
{
|
||||
var loc2:* = undefined;
|
||||
var loc3:Object3D = null;
|
||||
var loc1:Object3D = this.createEmptyObject();
|
||||
loc1.clonePropertiesFrom(this);
|
||||
for(loc2 in this.alternativa3d::_children)
|
||||
{
|
||||
loc3 = loc2;
|
||||
loc1.addChild(loc3.clone());
|
||||
}
|
||||
return loc1;
|
||||
}
|
||||
|
||||
public function getChildByName(param1:String, param2:Boolean = false) : Object3D
|
||||
{
|
||||
var loc3:* = undefined;
|
||||
var loc4:Object3D = null;
|
||||
for(loc3 in this.alternativa3d::_children)
|
||||
{
|
||||
loc4 = loc3;
|
||||
if(loc4.alternativa3d::_name == param1)
|
||||
{
|
||||
return loc4;
|
||||
}
|
||||
}
|
||||
if(param2)
|
||||
{
|
||||
for(loc3 in this.alternativa3d::_children)
|
||||
{
|
||||
loc4 = loc3;
|
||||
loc4 = loc4.getChildByName(param1,true);
|
||||
if(loc4 != null)
|
||||
{
|
||||
return loc4;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function localToGlobal(param1:Point3D, param2:Point3D = null) : Point3D
|
||||
{
|
||||
if(this.alternativa3d::_scene == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if(param2 == null)
|
||||
{
|
||||
param2 = param1.clone();
|
||||
}
|
||||
if(this.alternativa3d::_parent == null)
|
||||
{
|
||||
return param2;
|
||||
}
|
||||
this.alternativa3d::getTransformation(alternativa3d::matrix2);
|
||||
param2.transform(alternativa3d::matrix2);
|
||||
return param2;
|
||||
}
|
||||
|
||||
public function globalToLocal(param1:Point3D, param2:Point3D = null) : Point3D
|
||||
{
|
||||
if(this.alternativa3d::_scene == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if(param2 == null)
|
||||
{
|
||||
param2 = param1.clone();
|
||||
}
|
||||
if(this.alternativa3d::_parent == null)
|
||||
{
|
||||
return param2;
|
||||
}
|
||||
this.alternativa3d::getTransformation(alternativa3d::matrix2);
|
||||
alternativa3d::matrix2.invert();
|
||||
param2.transform(alternativa3d::matrix2);
|
||||
return param2;
|
||||
}
|
||||
|
||||
public function get transformation() : Matrix3D
|
||||
{
|
||||
if(this.alternativa3d::_scene == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var loc1:Matrix3D = new Matrix3D();
|
||||
this.alternativa3d::getTransformation(loc1);
|
||||
return loc1;
|
||||
}
|
||||
|
||||
public function addEventListener(param1:String, param2:Function, param3:Boolean = false, param4:int = 0, param5:Boolean = false) : void
|
||||
{
|
||||
if(this.dispatcher == null)
|
||||
{
|
||||
this.dispatcher = new EventDispatcher(this);
|
||||
}
|
||||
param3 = false;
|
||||
this.dispatcher.addEventListener(param1,param2,param3,param4,param5);
|
||||
}
|
||||
|
||||
public function dispatchEvent(param1:Event) : Boolean
|
||||
{
|
||||
if(this.dispatcher != null)
|
||||
{
|
||||
this.dispatcher.dispatchEvent(param1);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function hasEventListener(param1:String) : Boolean
|
||||
{
|
||||
if(this.dispatcher != null)
|
||||
{
|
||||
return this.dispatcher.hasEventListener(param1);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function removeEventListener(param1:String, param2:Function, param3:Boolean = false) : void
|
||||
{
|
||||
if(this.dispatcher != null)
|
||||
{
|
||||
param3 = false;
|
||||
this.dispatcher.removeEventListener(param1,param2,param3);
|
||||
}
|
||||
}
|
||||
|
||||
public function willTrigger(param1:String) : Boolean
|
||||
{
|
||||
if(this.dispatcher != null)
|
||||
{
|
||||
return this.dispatcher.willTrigger(param1);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
alternativa3d function getTransformation(param1:Matrix3D) : Boolean
|
||||
{
|
||||
var loc3:Object3D = null;
|
||||
var loc2:Object3D = this.alternativa3d::_scene.alternativa3d::_root;
|
||||
var loc4:Object3D = this;
|
||||
do
|
||||
{
|
||||
if(loc4.alternativa3d::changeCoordsOperation.alternativa3d::queued || loc4.alternativa3d::changeRotationOrScaleOperation.alternativa3d::queued)
|
||||
{
|
||||
loc3 = loc4.alternativa3d::_parent;
|
||||
}
|
||||
}
|
||||
while(loc4 = loc4.alternativa3d::_parent, loc4 != loc2);
|
||||
|
||||
if(loc3 != null)
|
||||
{
|
||||
param1.toTransform(this.alternativa3d::_coords.x,this.alternativa3d::_coords.y,this.alternativa3d::_coords.z,this.alternativa3d::_rotationX,this.alternativa3d::_rotationY,this.alternativa3d::_rotationZ,this.alternativa3d::_scaleX,this.alternativa3d::_scaleY,this.alternativa3d::_scaleZ);
|
||||
loc4 = this;
|
||||
while(true)
|
||||
{
|
||||
loc4 = loc4.alternativa3d::_parent;
|
||||
if(loc4 == loc3)
|
||||
{
|
||||
break;
|
||||
}
|
||||
alternativa3d::matrix1.toTransform(loc4.alternativa3d::_coords.x,loc4.alternativa3d::_coords.y,loc4.alternativa3d::_coords.z,loc4.alternativa3d::_rotationX,loc4.alternativa3d::_rotationY,loc4.alternativa3d::_rotationZ,loc4.alternativa3d::_scaleX,loc4.alternativa3d::_scaleY,loc4.alternativa3d::_scaleZ);
|
||||
param1.combine(alternativa3d::matrix1);
|
||||
}
|
||||
if(loc3 != loc2)
|
||||
{
|
||||
param1.combine(loc3.alternativa3d::_transformation);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
param1.copy(this.alternativa3d::_transformation);
|
||||
return false;
|
||||
}
|
||||
|
||||
public function forEach(param1:Function) : void
|
||||
{
|
||||
var loc2:* = undefined;
|
||||
param1.call(this,this);
|
||||
for(loc2 in this.alternativa3d::_children)
|
||||
{
|
||||
Object3D(loc2).forEach(param1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,156 +0,0 @@
|
||||
package alternativa.engine3d.core
|
||||
{
|
||||
import alternativa.engine3d.*;
|
||||
import alternativa.types.Set;
|
||||
|
||||
use namespace alternativa3d;
|
||||
|
||||
public class Operation
|
||||
{
|
||||
alternativa3d static const OBJECT_CALCULATE_TRANSFORMATION:uint = 16777216;
|
||||
|
||||
alternativa3d static const OBJECT_CALCULATE_MOBILITY:uint = 33554432;
|
||||
|
||||
alternativa3d static const VERTEX_CALCULATE_COORDS:uint = 50331648;
|
||||
|
||||
alternativa3d static const FACE_CALCULATE_BASE_UV:uint = 67108864;
|
||||
|
||||
alternativa3d static const FACE_CALCULATE_NORMAL:uint = 83886080;
|
||||
|
||||
alternativa3d static const FACE_CALCULATE_UV:uint = 100663296;
|
||||
|
||||
alternativa3d static const FACE_UPDATE_PRIMITIVE:uint = 117440512;
|
||||
|
||||
alternativa3d static const SECTOR_UPDATE:uint = 134217728;
|
||||
|
||||
alternativa3d static const SPLITTER_UPDATE:uint = 150994944;
|
||||
|
||||
alternativa3d static const SCENE_CALCULATE_BSP:uint = 167772160;
|
||||
|
||||
alternativa3d static const SECTOR_FIND_NODE:uint = 184549376;
|
||||
|
||||
alternativa3d static const SPLITTER_CHANGE_STATE:uint = 201326592;
|
||||
|
||||
alternativa3d static const SECTOR_CHANGE_VISIBLE:uint = 218103808;
|
||||
|
||||
alternativa3d static const FACE_UPDATE_MATERIAL:uint = 234881024;
|
||||
|
||||
alternativa3d static const SPRITE_UPDATE_MATERIAL:uint = 251658240;
|
||||
|
||||
alternativa3d static const CAMERA_CALCULATE_MATRIX:uint = 268435456;
|
||||
|
||||
alternativa3d static const CAMERA_CALCULATE_PLANES:uint = 285212672;
|
||||
|
||||
alternativa3d static const CAMERA_RENDER:uint = 301989888;
|
||||
|
||||
alternativa3d static const SCENE_CLEAR_PRIMITIVES:uint = 318767104;
|
||||
|
||||
alternativa3d var object:Object;
|
||||
|
||||
alternativa3d var method:Function;
|
||||
|
||||
alternativa3d var name:String;
|
||||
|
||||
private var sequel:Operation;
|
||||
|
||||
private var sequels:Set;
|
||||
|
||||
alternativa3d var priority:uint;
|
||||
|
||||
alternativa3d var queued:Boolean = false;
|
||||
|
||||
public function Operation(param1:String, param2:Object = null, param3:Function = null, param4:uint = 0)
|
||||
{
|
||||
super();
|
||||
this.alternativa3d::object = param2;
|
||||
this.alternativa3d::method = param3;
|
||||
this.alternativa3d::name = param1;
|
||||
this.alternativa3d::priority = param4;
|
||||
}
|
||||
|
||||
alternativa3d function addSequel(param1:Operation) : void
|
||||
{
|
||||
if(this.sequel == null)
|
||||
{
|
||||
if(this.sequels == null)
|
||||
{
|
||||
this.sequel = param1;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.sequels[param1] = true;
|
||||
}
|
||||
}
|
||||
else if(this.sequel != param1)
|
||||
{
|
||||
this.sequels = new Set(true);
|
||||
this.sequels[this.sequel] = true;
|
||||
this.sequels[param1] = true;
|
||||
this.sequel = null;
|
||||
}
|
||||
}
|
||||
|
||||
alternativa3d function removeSequel(param1:Operation) : void
|
||||
{
|
||||
var loc2:* = undefined;
|
||||
var loc3:Boolean = false;
|
||||
if(this.sequel == null)
|
||||
{
|
||||
if(this.sequels != null)
|
||||
{
|
||||
delete this.sequels[param1];
|
||||
loc3 = false;
|
||||
for(loc2 in this.sequels)
|
||||
{
|
||||
if(loc3)
|
||||
{
|
||||
loc3 = false;
|
||||
break;
|
||||
}
|
||||
loc3 = true;
|
||||
}
|
||||
if(loc3)
|
||||
{
|
||||
this.sequel = loc2;
|
||||
this.sequels = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(this.sequel == param1)
|
||||
{
|
||||
this.sequel = null;
|
||||
}
|
||||
}
|
||||
|
||||
alternativa3d function collectSequels(param1:Array) : void
|
||||
{
|
||||
var loc2:* = undefined;
|
||||
var loc3:Operation = null;
|
||||
if(this.sequel == null)
|
||||
{
|
||||
for(loc2 in this.sequels)
|
||||
{
|
||||
loc3 = loc2;
|
||||
if(!loc3.alternativa3d::queued)
|
||||
{
|
||||
param1.push(loc3);
|
||||
loc3.alternativa3d::queued = true;
|
||||
loc3.alternativa3d::collectSequels(param1);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(!this.sequel.alternativa3d::queued)
|
||||
{
|
||||
param1.push(this.sequel);
|
||||
this.sequel.alternativa3d::queued = true;
|
||||
this.sequel.alternativa3d::collectSequels(param1);
|
||||
}
|
||||
}
|
||||
|
||||
public function toString() : String
|
||||
{
|
||||
return "[Operation " + (this.alternativa3d::priority >>> 24) + "/" + (this.alternativa3d::priority & 0xFFFFFF) + " " + this.alternativa3d::object + "." + this.alternativa3d::name + "]";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,73 +0,0 @@
|
||||
package alternativa.engine3d.core
|
||||
{
|
||||
import alternativa.engine3d.alternativa3d;
|
||||
|
||||
use namespace alternativa3d;
|
||||
|
||||
public class PolyPrimitive
|
||||
{
|
||||
private static var collector:Array = new Array();
|
||||
|
||||
alternativa3d var num:uint;
|
||||
|
||||
alternativa3d var points:Array;
|
||||
|
||||
alternativa3d var face:Face;
|
||||
|
||||
alternativa3d var parent:PolyPrimitive;
|
||||
|
||||
alternativa3d var sibling:PolyPrimitive;
|
||||
|
||||
alternativa3d var backFragment:PolyPrimitive;
|
||||
|
||||
alternativa3d var frontFragment:PolyPrimitive;
|
||||
|
||||
alternativa3d var node:BSPNode;
|
||||
|
||||
alternativa3d var splits:uint;
|
||||
|
||||
alternativa3d var disbalance:int;
|
||||
|
||||
public var splitQuality:Number;
|
||||
|
||||
public var mobility:int;
|
||||
|
||||
public function PolyPrimitive()
|
||||
{
|
||||
this.alternativa3d::points = new Array();
|
||||
super();
|
||||
}
|
||||
|
||||
alternativa3d static function create() : PolyPrimitive
|
||||
{
|
||||
var loc1:PolyPrimitive = null;
|
||||
loc1 = collector.pop();
|
||||
if(loc1 != null)
|
||||
{
|
||||
return loc1;
|
||||
}
|
||||
return new PolyPrimitive();
|
||||
}
|
||||
|
||||
alternativa3d static function destroy(param1:PolyPrimitive) : void
|
||||
{
|
||||
param1.alternativa3d::face = null;
|
||||
param1.alternativa3d::points.length = 0;
|
||||
collector.push(param1);
|
||||
}
|
||||
|
||||
alternativa3d function createFragment() : PolyPrimitive
|
||||
{
|
||||
var loc1:PolyPrimitive = alternativa3d::create();
|
||||
loc1.alternativa3d::face = this.alternativa3d::face;
|
||||
loc1.mobility = this.mobility;
|
||||
return loc1;
|
||||
}
|
||||
|
||||
public function toString() : String
|
||||
{
|
||||
return "[Primitive " + this.alternativa3d::face.alternativa3d::_mesh.alternativa3d::_name + "]";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,253 +0,0 @@
|
||||
package alternativa.engine3d.core
|
||||
{
|
||||
import alternativa.engine3d.alternativa3d;
|
||||
import alternativa.types.Point3D;
|
||||
import alternativa.types.Set;
|
||||
|
||||
use namespace alternativa3d;
|
||||
|
||||
public class Sector
|
||||
{
|
||||
private static var counter:uint = 0;
|
||||
|
||||
alternativa3d var updateOperation:Operation;
|
||||
|
||||
alternativa3d var findNodeOperation:Operation;
|
||||
|
||||
alternativa3d var changeVisibleOperation:Operation;
|
||||
|
||||
alternativa3d var _visible:Set;
|
||||
|
||||
private var x:Number;
|
||||
|
||||
private var y:Number;
|
||||
|
||||
private var z:Number;
|
||||
|
||||
alternativa3d var _scene:Scene3D;
|
||||
|
||||
private var _node:BSPNode;
|
||||
|
||||
public var name:String;
|
||||
|
||||
public function Sector(param1:Number = 0, param2:Number = 0, param3:Number = 0, param4:String = null)
|
||||
{
|
||||
this.alternativa3d::updateOperation = new Operation("removeSector",this,this.removeFromBSP,Operation.alternativa3d::SECTOR_UPDATE);
|
||||
this.alternativa3d::findNodeOperation = new Operation("addSector",this,this.addToBSP,Operation.alternativa3d::SECTOR_FIND_NODE);
|
||||
this.alternativa3d::changeVisibleOperation = new Operation("changeSectorVisibility",this,this.changeVisible,Operation.alternativa3d::SECTOR_CHANGE_VISIBLE);
|
||||
this.alternativa3d::_visible = new Set();
|
||||
super();
|
||||
this.name = param4 != null ? param4 : "sector" + ++counter;
|
||||
this.x = param1;
|
||||
this.y = param2;
|
||||
this.z = param3;
|
||||
this.alternativa3d::_visible[this] = true;
|
||||
this.alternativa3d::updateOperation.alternativa3d::addSequel(this.alternativa3d::findNodeOperation);
|
||||
this.alternativa3d::findNodeOperation.alternativa3d::addSequel(this.alternativa3d::changeVisibleOperation);
|
||||
}
|
||||
|
||||
public function addVisible(param1:Sector, ... rest) : void
|
||||
{
|
||||
var loc5:Sector = null;
|
||||
param1.alternativa3d::_visible[this] = true;
|
||||
this.alternativa3d::_visible[param1] = true;
|
||||
param1.alternativa3d::markToChange();
|
||||
var loc3:int = int(rest.length);
|
||||
var loc4:int = 0;
|
||||
while(loc4 < loc3)
|
||||
{
|
||||
loc5 = rest[loc4];
|
||||
loc5.alternativa3d::_visible[this] = true;
|
||||
this.alternativa3d::_visible[loc5] = true;
|
||||
loc5.alternativa3d::markToChange();
|
||||
loc4++;
|
||||
}
|
||||
this.alternativa3d::markToChange();
|
||||
}
|
||||
|
||||
public function removeVisible(param1:Sector, ... rest) : void
|
||||
{
|
||||
var loc5:Sector = null;
|
||||
if(Boolean(this.alternativa3d::_visible[param1]) && param1 != this)
|
||||
{
|
||||
delete param1.alternativa3d::_visible[this];
|
||||
param1.alternativa3d::markToChange();
|
||||
delete this.alternativa3d::_visible[param1];
|
||||
this.alternativa3d::markToChange();
|
||||
}
|
||||
var loc3:int = int(rest.length);
|
||||
var loc4:int = 0;
|
||||
while(loc4 < loc3)
|
||||
{
|
||||
loc5 = rest[loc4];
|
||||
if(Boolean(this.alternativa3d::_visible[loc5]) && loc5 != this)
|
||||
{
|
||||
delete loc5.alternativa3d::_visible[this];
|
||||
loc5.alternativa3d::markToChange();
|
||||
delete this.alternativa3d::_visible[loc5];
|
||||
this.alternativa3d::markToChange();
|
||||
}
|
||||
loc4++;
|
||||
}
|
||||
}
|
||||
|
||||
public function isVisible(param1:Sector) : Boolean
|
||||
{
|
||||
return this.alternativa3d::_visible[param1];
|
||||
}
|
||||
|
||||
public function toString() : String
|
||||
{
|
||||
var loc2:Sector = null;
|
||||
var loc4:* = undefined;
|
||||
var loc1:String = "[Sector " + this.name + " X:" + this.x.toFixed(3) + " Y:" + this.y.toFixed(3) + " Z:" + this.z.toFixed(3);
|
||||
var loc3:String = "";
|
||||
for(loc4 in this.alternativa3d::_visible)
|
||||
{
|
||||
if(loc4 != this)
|
||||
{
|
||||
if(loc2 == null)
|
||||
{
|
||||
loc2 = loc4;
|
||||
loc3 = loc2.name;
|
||||
}
|
||||
else
|
||||
{
|
||||
loc2 = loc4;
|
||||
loc3 += " " + loc2.name;
|
||||
}
|
||||
}
|
||||
}
|
||||
return loc2 == null ? loc1 + "]" : loc1 + " visible:[" + loc3 + "]]";
|
||||
}
|
||||
|
||||
alternativa3d function addToScene(param1:Scene3D) : void
|
||||
{
|
||||
this.alternativa3d::_scene = param1;
|
||||
param1.alternativa3d::updateSplittersOperation.alternativa3d::addSequel(this.alternativa3d::updateOperation);
|
||||
this.alternativa3d::changeVisibleOperation.alternativa3d::addSequel(param1.alternativa3d::changePrimitivesOperation);
|
||||
param1.alternativa3d::addOperation(this.alternativa3d::findNodeOperation);
|
||||
}
|
||||
|
||||
alternativa3d function removeFromScene(param1:Scene3D) : void
|
||||
{
|
||||
param1.alternativa3d::updateSplittersOperation.alternativa3d::removeSequel(this.alternativa3d::updateOperation);
|
||||
this.alternativa3d::changeVisibleOperation.alternativa3d::removeSequel(param1.alternativa3d::changePrimitivesOperation);
|
||||
param1.alternativa3d::removeOperation(this.alternativa3d::findNodeOperation);
|
||||
param1.alternativa3d::removeOperation(this.alternativa3d::changeVisibleOperation);
|
||||
this.removeFromBSP();
|
||||
this.alternativa3d::_scene = null;
|
||||
}
|
||||
|
||||
alternativa3d function setLevel(param1:int) : void
|
||||
{
|
||||
this.alternativa3d::findNodeOperation.alternativa3d::priority = this.alternativa3d::findNodeOperation.alternativa3d::priority & 4278190080 | param1;
|
||||
}
|
||||
|
||||
alternativa3d function markToChange() : void
|
||||
{
|
||||
if(this.alternativa3d::_scene != null)
|
||||
{
|
||||
this.alternativa3d::_scene.alternativa3d::addOperation(this.alternativa3d::changeVisibleOperation);
|
||||
}
|
||||
}
|
||||
|
||||
private function removeFromBSP() : void
|
||||
{
|
||||
if(this._node != null)
|
||||
{
|
||||
if(this._node.alternativa3d::frontSector == this)
|
||||
{
|
||||
this._node.alternativa3d::frontSector = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
this._node.alternativa3d::backSector = null;
|
||||
}
|
||||
this._node = null;
|
||||
}
|
||||
}
|
||||
|
||||
private function addToBSP() : void
|
||||
{
|
||||
this.findSectorNode(this.alternativa3d::_scene.alternativa3d::bsp);
|
||||
}
|
||||
|
||||
private function findSectorNode(param1:BSPNode) : void
|
||||
{
|
||||
var loc2:Point3D = null;
|
||||
if(param1 != null && param1.alternativa3d::splitter != null)
|
||||
{
|
||||
loc2 = param1.alternativa3d::normal;
|
||||
if(this.x * loc2.x + this.y * loc2.y + this.z * loc2.z - param1.alternativa3d::offset >= 0)
|
||||
{
|
||||
if(param1.alternativa3d::front == null || param1.alternativa3d::front.alternativa3d::splitter == null)
|
||||
{
|
||||
if(param1.alternativa3d::frontSector == null)
|
||||
{
|
||||
param1.alternativa3d::frontSector = this;
|
||||
this._node = param1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.findSectorNode(param1.alternativa3d::front);
|
||||
}
|
||||
}
|
||||
else if(param1.alternativa3d::back == null || param1.alternativa3d::back.alternativa3d::splitter == null)
|
||||
{
|
||||
if(param1.alternativa3d::backSector == null)
|
||||
{
|
||||
param1.alternativa3d::backSector = this;
|
||||
this._node = param1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.findSectorNode(param1.alternativa3d::back);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function changeVisible() : void
|
||||
{
|
||||
if(this._node != null)
|
||||
{
|
||||
if(this._node.alternativa3d::frontSector == this)
|
||||
{
|
||||
this.changeNode(this._node.alternativa3d::front);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.changeNode(this._node.alternativa3d::back);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function changeNode(param1:BSPNode) : void
|
||||
{
|
||||
var loc2:* = undefined;
|
||||
if(param1 != null)
|
||||
{
|
||||
if(param1.alternativa3d::primitive != null)
|
||||
{
|
||||
this.alternativa3d::_scene.alternativa3d::changedPrimitives[param1.alternativa3d::primitive] = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
for(loc2 in param1.alternativa3d::frontPrimitives)
|
||||
{
|
||||
this.alternativa3d::_scene.alternativa3d::changedPrimitives[loc2] = true;
|
||||
}
|
||||
for(loc2 in param1.alternativa3d::backPrimitives)
|
||||
{
|
||||
this.alternativa3d::_scene.alternativa3d::changedPrimitives[loc2] = true;
|
||||
}
|
||||
}
|
||||
this.changeNode(param1.alternativa3d::back);
|
||||
this.changeNode(param1.alternativa3d::front);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,227 +0,0 @@
|
||||
package alternativa.engine3d.core
|
||||
{
|
||||
import alternativa.engine3d.alternativa3d;
|
||||
import alternativa.engine3d.errors.SplitterNeedMoreVerticesError;
|
||||
import alternativa.types.Matrix3D;
|
||||
import alternativa.types.Point3D;
|
||||
|
||||
use namespace alternativa3d;
|
||||
|
||||
public class Splitter
|
||||
{
|
||||
private static var counter:uint = 0;
|
||||
|
||||
alternativa3d var changeStateOperation:Operation;
|
||||
|
||||
alternativa3d var updatePrimitiveOperation:Operation;
|
||||
|
||||
alternativa3d var _open:Boolean = true;
|
||||
|
||||
alternativa3d var primitive:SplitterPrimitive;
|
||||
|
||||
alternativa3d var normal:Point3D;
|
||||
|
||||
alternativa3d var offset:Number;
|
||||
|
||||
alternativa3d var _scene:Scene3D;
|
||||
|
||||
public var name:String;
|
||||
|
||||
public function Splitter(param1:Array, param2:String = null)
|
||||
{
|
||||
this.alternativa3d::changeStateOperation = new Operation("changeSplitterState",this,this.changeState,Operation.alternativa3d::SPLITTER_CHANGE_STATE);
|
||||
this.alternativa3d::updatePrimitiveOperation = new Operation("updateSplitter",this,this.updatePrimitive,Operation.alternativa3d::SPLITTER_UPDATE);
|
||||
this.alternativa3d::normal = new Point3D();
|
||||
super();
|
||||
var loc3:int = int(param1.length);
|
||||
if(loc3 < 3)
|
||||
{
|
||||
throw new SplitterNeedMoreVerticesError(loc3);
|
||||
}
|
||||
this.alternativa3d::primitive = SplitterPrimitive.alternativa3d::create();
|
||||
this.alternativa3d::primitive.mobility = int.MIN_VALUE;
|
||||
this.alternativa3d::primitive.alternativa3d::splitter = this;
|
||||
var loc4:int = 0;
|
||||
while(loc4 < loc3)
|
||||
{
|
||||
this.alternativa3d::primitive.alternativa3d::points[loc4] = Point3D(param1[loc4]).clone();
|
||||
loc4++;
|
||||
}
|
||||
this.alternativa3d::primitive.alternativa3d::num = loc3;
|
||||
this.calculatePlane();
|
||||
this.name = param2 != null ? param2 : "splitter" + ++counter;
|
||||
}
|
||||
|
||||
public static function createFromFace(param1:Face, param2:String = null) : Splitter
|
||||
{
|
||||
var loc5:int = 0;
|
||||
var loc6:Matrix3D = null;
|
||||
var loc7:Point3D = null;
|
||||
var loc3:Array = param1.alternativa3d::_vertices;
|
||||
var loc4:Array = new Array();
|
||||
if(param1.alternativa3d::_mesh != null && param1.alternativa3d::_mesh.alternativa3d::_scene != null)
|
||||
{
|
||||
loc6 = Object3D.alternativa3d::matrix2;
|
||||
param1.alternativa3d::_mesh.alternativa3d::getTransformation(loc6);
|
||||
loc5 = 0;
|
||||
while(loc5 < param1.alternativa3d::_verticesCount)
|
||||
{
|
||||
loc7 = Vertex(loc3[loc5]).alternativa3d::_coords.clone();
|
||||
loc7.transform(loc6);
|
||||
loc4[loc5] = loc7;
|
||||
loc5++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
loc5 = 0;
|
||||
while(loc5 < param1.alternativa3d::_verticesCount)
|
||||
{
|
||||
loc4[loc5] = Vertex(loc3[loc5]).alternativa3d::_coords;
|
||||
loc5++;
|
||||
}
|
||||
}
|
||||
return new Splitter(loc4,param2);
|
||||
}
|
||||
|
||||
public function get vertices() : Array
|
||||
{
|
||||
var loc1:Array = new Array().concat(this.alternativa3d::primitive.alternativa3d::points);
|
||||
var loc2:int = 0;
|
||||
while(loc2 < this.alternativa3d::primitive.alternativa3d::num)
|
||||
{
|
||||
loc1[loc2] = Point3D(loc1[loc2]).clone();
|
||||
loc2++;
|
||||
}
|
||||
return loc1;
|
||||
}
|
||||
|
||||
public function get open() : Boolean
|
||||
{
|
||||
return this.alternativa3d::_open;
|
||||
}
|
||||
|
||||
public function set open(param1:Boolean) : void
|
||||
{
|
||||
if(this.alternativa3d::_open != param1)
|
||||
{
|
||||
this.alternativa3d::_open = param1;
|
||||
if(this.alternativa3d::_scene != null)
|
||||
{
|
||||
this.alternativa3d::_scene.alternativa3d::addOperation(this.alternativa3d::changeStateOperation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function toString() : String
|
||||
{
|
||||
return "[Splitter " + this.name + (this.alternativa3d::_open ? " open]" : " closed]");
|
||||
}
|
||||
|
||||
alternativa3d function addToScene(param1:Scene3D) : void
|
||||
{
|
||||
this.alternativa3d::_scene = param1;
|
||||
this.alternativa3d::changeStateOperation.alternativa3d::addSequel(this.alternativa3d::_scene.alternativa3d::changePrimitivesOperation);
|
||||
this.alternativa3d::_scene.alternativa3d::updateBSPOperation.alternativa3d::addSequel(this.alternativa3d::updatePrimitiveOperation);
|
||||
}
|
||||
|
||||
alternativa3d function removeFromScene(param1:Scene3D) : void
|
||||
{
|
||||
this.alternativa3d::changeStateOperation.alternativa3d::removeSequel(param1.alternativa3d::changePrimitivesOperation);
|
||||
param1.alternativa3d::updateBSPOperation.alternativa3d::removeSequel(this.alternativa3d::updatePrimitiveOperation);
|
||||
param1.alternativa3d::removeOperation(this.alternativa3d::changeStateOperation);
|
||||
this.removePrimitive(this.alternativa3d::primitive);
|
||||
this.alternativa3d::_scene = null;
|
||||
}
|
||||
|
||||
private function calculatePlane() : void
|
||||
{
|
||||
var loc1:Point3D = this.alternativa3d::primitive.alternativa3d::points[0];
|
||||
var loc2:Point3D = this.alternativa3d::primitive.alternativa3d::points[1];
|
||||
var loc3:Number = loc2.x - loc1.x;
|
||||
var loc4:Number = loc2.y - loc1.y;
|
||||
var loc5:Number = loc2.z - loc1.z;
|
||||
var loc6:Point3D = this.alternativa3d::primitive.alternativa3d::points[2];
|
||||
var loc7:Number = loc6.x - loc1.x;
|
||||
var loc8:Number = loc6.y - loc1.y;
|
||||
var loc9:Number = loc6.z - loc1.z;
|
||||
this.alternativa3d::normal.x = loc9 * loc4 - loc8 * loc5;
|
||||
this.alternativa3d::normal.y = loc7 * loc5 - loc9 * loc3;
|
||||
this.alternativa3d::normal.z = loc8 * loc3 - loc7 * loc4;
|
||||
this.alternativa3d::normal.normalize();
|
||||
this.alternativa3d::offset = loc1.x * this.alternativa3d::normal.x + loc1.y * this.alternativa3d::normal.y + loc1.z * this.alternativa3d::normal.z;
|
||||
}
|
||||
|
||||
private function updatePrimitive() : void
|
||||
{
|
||||
this.removePrimitive(this.alternativa3d::primitive);
|
||||
}
|
||||
|
||||
private function changeState() : void
|
||||
{
|
||||
this.changePrimitiveNode(this.alternativa3d::primitive);
|
||||
}
|
||||
|
||||
private function changePrimitiveNode(param1:PolyPrimitive) : void
|
||||
{
|
||||
if(param1.alternativa3d::backFragment == null)
|
||||
{
|
||||
this.changePrimitivesInNode(param1.alternativa3d::node.alternativa3d::back);
|
||||
this.changePrimitivesInNode(param1.alternativa3d::node.alternativa3d::front);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.changePrimitiveNode(param1.alternativa3d::backFragment);
|
||||
this.changePrimitiveNode(param1.alternativa3d::frontFragment);
|
||||
}
|
||||
}
|
||||
|
||||
private function changePrimitivesInNode(param1:BSPNode) : void
|
||||
{
|
||||
var loc2:* = undefined;
|
||||
if(param1 != null)
|
||||
{
|
||||
if(param1.alternativa3d::primitive != null)
|
||||
{
|
||||
this.alternativa3d::_scene.alternativa3d::changedPrimitives[param1.alternativa3d::primitive] = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
for(loc2 in param1.alternativa3d::frontPrimitives)
|
||||
{
|
||||
this.alternativa3d::_scene.alternativa3d::changedPrimitives[loc2] = true;
|
||||
}
|
||||
for(loc2 in param1.alternativa3d::backPrimitives)
|
||||
{
|
||||
this.alternativa3d::_scene.alternativa3d::changedPrimitives[loc2] = true;
|
||||
}
|
||||
}
|
||||
this.changePrimitivesInNode(param1.alternativa3d::back);
|
||||
this.changePrimitivesInNode(param1.alternativa3d::front);
|
||||
}
|
||||
}
|
||||
|
||||
private function removePrimitive(param1:PolyPrimitive) : void
|
||||
{
|
||||
if(param1.alternativa3d::backFragment != null)
|
||||
{
|
||||
this.removePrimitive(param1.alternativa3d::backFragment);
|
||||
this.removePrimitive(param1.alternativa3d::frontFragment);
|
||||
param1.alternativa3d::backFragment = null;
|
||||
param1.alternativa3d::frontFragment = null;
|
||||
}
|
||||
else if(param1.alternativa3d::node != null)
|
||||
{
|
||||
param1.alternativa3d::node.alternativa3d::splitter = null;
|
||||
this.alternativa3d::_scene.alternativa3d::removeBSPPrimitive(param1);
|
||||
}
|
||||
if(param1 != this.alternativa3d::primitive)
|
||||
{
|
||||
param1.alternativa3d::parent = null;
|
||||
param1.alternativa3d::sibling = null;
|
||||
SplitterPrimitive.alternativa3d::destroy(param1 as SplitterPrimitive);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
package alternativa.engine3d.core
|
||||
{
|
||||
import alternativa.engine3d.alternativa3d;
|
||||
|
||||
use namespace alternativa3d;
|
||||
|
||||
public class SplitterPrimitive extends PolyPrimitive
|
||||
{
|
||||
private static var collector:Array = new Array();
|
||||
|
||||
alternativa3d var splitter:Splitter;
|
||||
|
||||
public function SplitterPrimitive()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
alternativa3d static function create() : SplitterPrimitive
|
||||
{
|
||||
var loc1:SplitterPrimitive = null;
|
||||
loc1 = collector.pop();
|
||||
if(loc1 != null)
|
||||
{
|
||||
return loc1;
|
||||
}
|
||||
return new SplitterPrimitive();
|
||||
}
|
||||
|
||||
alternativa3d static function destroy(param1:SplitterPrimitive) : void
|
||||
{
|
||||
param1.alternativa3d::splitter = null;
|
||||
param1.alternativa3d::points.length = 0;
|
||||
collector.push(param1);
|
||||
}
|
||||
|
||||
override alternativa3d function createFragment() : PolyPrimitive
|
||||
{
|
||||
var loc1:SplitterPrimitive = alternativa3d::create();
|
||||
loc1.alternativa3d::splitter = this.alternativa3d::splitter;
|
||||
loc1.mobility = mobility;
|
||||
return loc1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,163 +0,0 @@
|
||||
package alternativa.engine3d.core
|
||||
{
|
||||
import alternativa.engine3d.*;
|
||||
import alternativa.engine3d.materials.SpriteMaterial;
|
||||
|
||||
use namespace alternativa3d;
|
||||
|
||||
public class Sprite3D extends Object3D
|
||||
{
|
||||
private static var counter:uint = 0;
|
||||
|
||||
alternativa3d var updateMaterialOperation:Operation;
|
||||
|
||||
alternativa3d var primitive:SpritePrimitive;
|
||||
|
||||
alternativa3d var _material:SpriteMaterial;
|
||||
|
||||
alternativa3d var _materialScale:Number;
|
||||
|
||||
public function Sprite3D(param1:String = null)
|
||||
{
|
||||
this.alternativa3d::updateMaterialOperation = new Operation("updateSpriteMaterial",this,this.updateMaterial,Operation.alternativa3d::SPRITE_UPDATE_MATERIAL);
|
||||
super(param1);
|
||||
this.alternativa3d::primitive = new SpritePrimitive();
|
||||
this.alternativa3d::primitive.alternativa3d::sprite = this;
|
||||
this.alternativa3d::primitive.alternativa3d::points = [this.alternativa3d::globalCoords];
|
||||
this.alternativa3d::primitive.alternativa3d::num = 1;
|
||||
this.alternativa3d::primitive.mobility = int.MAX_VALUE;
|
||||
}
|
||||
|
||||
override alternativa3d function calculateTransformation() : void
|
||||
{
|
||||
var loc1:Number = NaN;
|
||||
var loc2:Number = NaN;
|
||||
var loc3:Number = NaN;
|
||||
var loc4:Number = NaN;
|
||||
var loc5:Number = NaN;
|
||||
var loc6:Number = NaN;
|
||||
var loc7:Number = NaN;
|
||||
var loc8:Number = NaN;
|
||||
var loc9:Number = NaN;
|
||||
super.alternativa3d::calculateTransformation();
|
||||
this.updatePrimitive();
|
||||
if(alternativa3d::changeRotationOrScaleOperation.alternativa3d::queued)
|
||||
{
|
||||
loc1 = Number(alternativa3d::_transformation.a);
|
||||
loc2 = Number(alternativa3d::_transformation.b);
|
||||
loc3 = Number(alternativa3d::_transformation.c);
|
||||
loc4 = Number(alternativa3d::_transformation.e);
|
||||
loc5 = Number(alternativa3d::_transformation.f);
|
||||
loc6 = Number(alternativa3d::_transformation.g);
|
||||
loc7 = Number(alternativa3d::_transformation.i);
|
||||
loc8 = Number(alternativa3d::_transformation.j);
|
||||
loc9 = Number(alternativa3d::_transformation.k);
|
||||
this.alternativa3d::_materialScale = (Math.sqrt(loc1 * loc1 + loc4 * loc4 + loc7 * loc7) + Math.sqrt(loc2 * loc2 + loc5 * loc5 + loc8 * loc8) + Math.sqrt(loc3 * loc3 + loc6 * loc6 + loc9 * loc9)) / 3;
|
||||
}
|
||||
}
|
||||
|
||||
private function updatePrimitive() : void
|
||||
{
|
||||
if(this.alternativa3d::primitive.alternativa3d::node != null)
|
||||
{
|
||||
alternativa3d::_scene.alternativa3d::removeBSPPrimitive(this.alternativa3d::primitive);
|
||||
}
|
||||
alternativa3d::_scene.alternativa3d::addPrimitives.push(this.alternativa3d::primitive);
|
||||
}
|
||||
|
||||
private function updateMaterial() : void
|
||||
{
|
||||
if(!alternativa3d::calculateTransformationOperation.alternativa3d::queued)
|
||||
{
|
||||
alternativa3d::_scene.alternativa3d::changedPrimitives[this.alternativa3d::primitive] = true;
|
||||
}
|
||||
}
|
||||
|
||||
override protected function addToScene(param1:Scene3D) : void
|
||||
{
|
||||
super.addToScene(param1);
|
||||
alternativa3d::calculateTransformationOperation.alternativa3d::addSequel(param1.alternativa3d::calculateBSPOperation);
|
||||
this.alternativa3d::updateMaterialOperation.alternativa3d::addSequel(param1.alternativa3d::changePrimitivesOperation);
|
||||
if(this.alternativa3d::_material != null)
|
||||
{
|
||||
this.alternativa3d::_material.alternativa3d::addToScene(param1);
|
||||
}
|
||||
}
|
||||
|
||||
override protected function removeFromScene(param1:Scene3D) : void
|
||||
{
|
||||
param1.alternativa3d::removeOperation(this.alternativa3d::updateMaterialOperation);
|
||||
if(this.alternativa3d::primitive.alternativa3d::node != null)
|
||||
{
|
||||
param1.alternativa3d::removeBSPPrimitive(this.alternativa3d::primitive);
|
||||
}
|
||||
param1.alternativa3d::addOperation(param1.alternativa3d::calculateBSPOperation);
|
||||
alternativa3d::calculateTransformationOperation.alternativa3d::removeSequel(param1.alternativa3d::calculateBSPOperation);
|
||||
this.alternativa3d::updateMaterialOperation.alternativa3d::removeSequel(param1.alternativa3d::changePrimitivesOperation);
|
||||
if(this.alternativa3d::_material != null)
|
||||
{
|
||||
this.alternativa3d::_material.alternativa3d::removeFromScene(param1);
|
||||
}
|
||||
super.removeFromScene(param1);
|
||||
}
|
||||
|
||||
alternativa3d function addMaterialChangedOperationToScene() : void
|
||||
{
|
||||
if(alternativa3d::_scene != null)
|
||||
{
|
||||
alternativa3d::_scene.alternativa3d::addOperation(this.alternativa3d::updateMaterialOperation);
|
||||
}
|
||||
}
|
||||
|
||||
public function get material() : SpriteMaterial
|
||||
{
|
||||
return this.alternativa3d::_material;
|
||||
}
|
||||
|
||||
public function set material(param1:SpriteMaterial) : void
|
||||
{
|
||||
if(this.alternativa3d::_material != param1)
|
||||
{
|
||||
if(this.alternativa3d::_material != null)
|
||||
{
|
||||
this.alternativa3d::_material.alternativa3d::removeFromSprite(this);
|
||||
if(alternativa3d::_scene != null)
|
||||
{
|
||||
this.alternativa3d::_material.alternativa3d::removeFromScene(alternativa3d::_scene);
|
||||
}
|
||||
}
|
||||
if(param1 != null)
|
||||
{
|
||||
if(param1.alternativa3d::_sprite != null)
|
||||
{
|
||||
param1.alternativa3d::_sprite.material = null;
|
||||
}
|
||||
param1.alternativa3d::addToSprite(this);
|
||||
if(alternativa3d::_scene != null)
|
||||
{
|
||||
param1.alternativa3d::addToScene(alternativa3d::_scene);
|
||||
}
|
||||
}
|
||||
this.alternativa3d::_material = param1;
|
||||
this.alternativa3d::addMaterialChangedOperationToScene();
|
||||
}
|
||||
}
|
||||
|
||||
override protected function defaultName() : String
|
||||
{
|
||||
return "sprite" + ++counter;
|
||||
}
|
||||
|
||||
override protected function createEmptyObject() : Object3D
|
||||
{
|
||||
return new Sprite3D();
|
||||
}
|
||||
|
||||
override protected function clonePropertiesFrom(param1:Object3D) : void
|
||||
{
|
||||
super.clonePropertiesFrom(param1);
|
||||
this.material = (param1 as Sprite3D).material.clone() as SpriteMaterial;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
package alternativa.engine3d.core
|
||||
{
|
||||
import alternativa.engine3d.alternativa3d;
|
||||
|
||||
use namespace alternativa3d;
|
||||
|
||||
public class SpritePrimitive extends PolyPrimitive
|
||||
{
|
||||
alternativa3d var sprite:Sprite3D;
|
||||
|
||||
alternativa3d var screenDepth:Number;
|
||||
|
||||
public function SpritePrimitive()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
override public function toString() : String
|
||||
{
|
||||
return "[SpritePrimitive " + this.alternativa3d::sprite.toString() + "]";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,298 +0,0 @@
|
||||
package alternativa.engine3d.core
|
||||
{
|
||||
import alternativa.engine3d.*;
|
||||
import alternativa.engine3d.errors.FaceExistsError;
|
||||
import alternativa.engine3d.errors.FaceNotFoundError;
|
||||
import alternativa.engine3d.errors.InvalidIDError;
|
||||
import alternativa.engine3d.materials.SurfaceMaterial;
|
||||
import alternativa.types.Set;
|
||||
import flash.events.Event;
|
||||
import flash.events.EventDispatcher;
|
||||
import flash.events.IEventDispatcher;
|
||||
|
||||
use namespace alternativa3d;
|
||||
|
||||
public class Surface implements IEventDispatcher
|
||||
{
|
||||
alternativa3d var changeFacesOperation:Operation;
|
||||
|
||||
alternativa3d var changeMaterialOperation:Operation;
|
||||
|
||||
alternativa3d var _mesh:Mesh;
|
||||
|
||||
alternativa3d var _material:SurfaceMaterial;
|
||||
|
||||
alternativa3d var _faces:Set;
|
||||
|
||||
public var mouseEnabled:Boolean = true;
|
||||
|
||||
private var dispatcher:EventDispatcher;
|
||||
|
||||
public function Surface()
|
||||
{
|
||||
this.alternativa3d::changeFacesOperation = new Operation("changeFaces",this);
|
||||
this.alternativa3d::changeMaterialOperation = new Operation("changeMaterial",this);
|
||||
this.alternativa3d::_faces = new Set();
|
||||
super();
|
||||
}
|
||||
|
||||
public function addFace(param1:Object) : void
|
||||
{
|
||||
var loc2:* = param1 is Face;
|
||||
if(this.alternativa3d::_mesh == null)
|
||||
{
|
||||
throw new FaceNotFoundError(param1,this);
|
||||
}
|
||||
if(param1 == null)
|
||||
{
|
||||
throw new FaceNotFoundError(null,this);
|
||||
}
|
||||
if(loc2)
|
||||
{
|
||||
if(Face(param1).alternativa3d::_mesh != this.alternativa3d::_mesh)
|
||||
{
|
||||
throw new FaceNotFoundError(param1,this);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(this.alternativa3d::_mesh.alternativa3d::_faces[param1] == undefined)
|
||||
{
|
||||
throw new FaceNotFoundError(param1,this);
|
||||
}
|
||||
if(!(this.alternativa3d::_mesh.alternativa3d::_faces[param1] is Face))
|
||||
{
|
||||
throw new InvalidIDError(param1,this);
|
||||
}
|
||||
}
|
||||
var loc3:Face = loc2 ? Face(param1) : this.alternativa3d::_mesh.alternativa3d::_faces[param1];
|
||||
if(this.alternativa3d::_faces.has(loc3))
|
||||
{
|
||||
throw new FaceExistsError(loc3,this);
|
||||
}
|
||||
if(loc3.alternativa3d::_surface != null)
|
||||
{
|
||||
loc3.alternativa3d::_surface.alternativa3d::_faces.remove(loc3);
|
||||
loc3.alternativa3d::removeFromSurface(loc3.alternativa3d::_surface);
|
||||
}
|
||||
this.alternativa3d::_faces.add(loc3);
|
||||
loc3.alternativa3d::addToSurface(this);
|
||||
this.alternativa3d::_mesh.alternativa3d::addOperationToScene(this.alternativa3d::changeFacesOperation);
|
||||
}
|
||||
|
||||
public function removeFace(param1:Object) : void
|
||||
{
|
||||
var loc2:* = param1 is Face;
|
||||
if(this.alternativa3d::_mesh == null)
|
||||
{
|
||||
throw new FaceNotFoundError(param1,this);
|
||||
}
|
||||
if(param1 == null)
|
||||
{
|
||||
throw new FaceNotFoundError(null,this);
|
||||
}
|
||||
if(loc2)
|
||||
{
|
||||
if(Face(param1).alternativa3d::_mesh != this.alternativa3d::_mesh)
|
||||
{
|
||||
throw new FaceNotFoundError(param1,this);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(this.alternativa3d::_mesh.alternativa3d::_faces[param1] == undefined)
|
||||
{
|
||||
throw new FaceNotFoundError(param1,this);
|
||||
}
|
||||
if(!(this.alternativa3d::_mesh.alternativa3d::_faces[param1] is Face))
|
||||
{
|
||||
throw new InvalidIDError(param1,this);
|
||||
}
|
||||
}
|
||||
var loc3:Face = loc2 ? Face(param1) : this.alternativa3d::_mesh.alternativa3d::_faces[param1];
|
||||
if(!this.alternativa3d::_faces.has(loc3))
|
||||
{
|
||||
throw new FaceNotFoundError(loc3,this);
|
||||
}
|
||||
this.alternativa3d::_faces.remove(loc3);
|
||||
loc3.alternativa3d::removeFromSurface(this);
|
||||
this.alternativa3d::_mesh.alternativa3d::addOperationToScene(this.alternativa3d::changeFacesOperation);
|
||||
}
|
||||
|
||||
public function get material() : SurfaceMaterial
|
||||
{
|
||||
return this.alternativa3d::_material;
|
||||
}
|
||||
|
||||
public function set material(param1:SurfaceMaterial) : void
|
||||
{
|
||||
if(this.alternativa3d::_material != param1)
|
||||
{
|
||||
if(this.alternativa3d::_material != null)
|
||||
{
|
||||
this.alternativa3d::_material.alternativa3d::removeFromSurface(this);
|
||||
if(this.alternativa3d::_mesh != null)
|
||||
{
|
||||
this.alternativa3d::_material.alternativa3d::removeFromMesh(this.alternativa3d::_mesh);
|
||||
if(this.alternativa3d::_mesh.alternativa3d::_scene != null)
|
||||
{
|
||||
this.alternativa3d::_material.alternativa3d::removeFromScene(this.alternativa3d::_mesh.alternativa3d::_scene);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(param1 != null)
|
||||
{
|
||||
if(param1.alternativa3d::_surface != null)
|
||||
{
|
||||
param1.alternativa3d::_surface.material = null;
|
||||
}
|
||||
param1.alternativa3d::addToSurface(this);
|
||||
if(this.alternativa3d::_mesh != null)
|
||||
{
|
||||
param1.alternativa3d::addToMesh(this.alternativa3d::_mesh);
|
||||
if(this.alternativa3d::_mesh.alternativa3d::_scene != null)
|
||||
{
|
||||
param1.alternativa3d::addToScene(this.alternativa3d::_mesh.alternativa3d::_scene);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.alternativa3d::_material = param1;
|
||||
this.alternativa3d::addMaterialChangedOperationToScene();
|
||||
}
|
||||
}
|
||||
|
||||
public function get faces() : Set
|
||||
{
|
||||
return this.alternativa3d::_faces.clone();
|
||||
}
|
||||
|
||||
public function get mesh() : Mesh
|
||||
{
|
||||
return this.alternativa3d::_mesh;
|
||||
}
|
||||
|
||||
public function get id() : Object
|
||||
{
|
||||
return this.alternativa3d::_mesh != null ? this.alternativa3d::_mesh.getSurfaceId(this) : null;
|
||||
}
|
||||
|
||||
alternativa3d function addToScene(param1:Scene3D) : void
|
||||
{
|
||||
if(this.alternativa3d::_material != null)
|
||||
{
|
||||
this.alternativa3d::_material.alternativa3d::addToScene(param1);
|
||||
}
|
||||
}
|
||||
|
||||
alternativa3d function removeFromScene(param1:Scene3D) : void
|
||||
{
|
||||
param1.alternativa3d::removeOperation(this.alternativa3d::changeFacesOperation);
|
||||
param1.alternativa3d::removeOperation(this.alternativa3d::changeMaterialOperation);
|
||||
if(this.alternativa3d::_material != null)
|
||||
{
|
||||
this.alternativa3d::_material.alternativa3d::removeFromScene(param1);
|
||||
}
|
||||
}
|
||||
|
||||
alternativa3d function addToMesh(param1:Mesh) : void
|
||||
{
|
||||
if(this.alternativa3d::_material != null)
|
||||
{
|
||||
this.alternativa3d::_material.alternativa3d::addToMesh(param1);
|
||||
}
|
||||
this.alternativa3d::_mesh = param1;
|
||||
}
|
||||
|
||||
alternativa3d function removeFromMesh(param1:Mesh) : void
|
||||
{
|
||||
if(this.alternativa3d::_material != null)
|
||||
{
|
||||
this.alternativa3d::_material.alternativa3d::removeFromMesh(param1);
|
||||
}
|
||||
this.alternativa3d::_mesh = null;
|
||||
}
|
||||
|
||||
alternativa3d function removeFaces() : void
|
||||
{
|
||||
var loc1:* = undefined;
|
||||
var loc2:Face = null;
|
||||
for(loc1 in this.alternativa3d::_faces)
|
||||
{
|
||||
loc2 = loc1;
|
||||
this.alternativa3d::_faces.remove(loc2);
|
||||
loc2.alternativa3d::removeFromSurface(this);
|
||||
}
|
||||
}
|
||||
|
||||
alternativa3d function addMaterialChangedOperationToScene() : void
|
||||
{
|
||||
if(this.alternativa3d::_mesh != null)
|
||||
{
|
||||
this.alternativa3d::_mesh.alternativa3d::addOperationToScene(this.alternativa3d::changeMaterialOperation);
|
||||
}
|
||||
}
|
||||
|
||||
public function toString() : String
|
||||
{
|
||||
var loc4:* = undefined;
|
||||
var loc5:Face = null;
|
||||
var loc1:uint = this.alternativa3d::_faces.length;
|
||||
var loc2:String = "[Surface ID:" + this.id + (loc1 > 0 ? " faces:" : "");
|
||||
var loc3:uint = 0;
|
||||
for(loc4 in this.alternativa3d::_faces)
|
||||
{
|
||||
loc5 = loc4;
|
||||
loc2 += loc5.id + (loc3 < loc1 - 1 ? ", " : "");
|
||||
loc3++;
|
||||
}
|
||||
return loc2 + "]";
|
||||
}
|
||||
|
||||
public function addEventListener(param1:String, param2:Function, param3:Boolean = false, param4:int = 0, param5:Boolean = false) : void
|
||||
{
|
||||
if(this.dispatcher == null)
|
||||
{
|
||||
this.dispatcher = new EventDispatcher(this);
|
||||
}
|
||||
param3 = false;
|
||||
this.dispatcher.addEventListener(param1,param2,param3,param4,param5);
|
||||
}
|
||||
|
||||
public function dispatchEvent(param1:Event) : Boolean
|
||||
{
|
||||
if(this.dispatcher != null)
|
||||
{
|
||||
this.dispatcher.dispatchEvent(param1);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function hasEventListener(param1:String) : Boolean
|
||||
{
|
||||
if(this.dispatcher != null)
|
||||
{
|
||||
return this.dispatcher.hasEventListener(param1);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function removeEventListener(param1:String, param2:Function, param3:Boolean = false) : void
|
||||
{
|
||||
if(this.dispatcher != null)
|
||||
{
|
||||
param3 = false;
|
||||
this.dispatcher.removeEventListener(param1,param2,param3);
|
||||
}
|
||||
}
|
||||
|
||||
public function willTrigger(param1:String) : Boolean
|
||||
{
|
||||
if(this.dispatcher != null)
|
||||
{
|
||||
return this.dispatcher.willTrigger(param1);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,175 +0,0 @@
|
||||
package alternativa.engine3d.core
|
||||
{
|
||||
import alternativa.engine3d.alternativa3d;
|
||||
import alternativa.types.Point3D;
|
||||
import alternativa.types.Set;
|
||||
|
||||
use namespace alternativa3d;
|
||||
|
||||
public final class Vertex
|
||||
{
|
||||
alternativa3d var changeCoordsOperation:Operation;
|
||||
|
||||
alternativa3d var calculateCoordsOperation:Operation;
|
||||
|
||||
alternativa3d var _mesh:Mesh;
|
||||
|
||||
alternativa3d var _coords:Point3D;
|
||||
|
||||
alternativa3d var _faces:Set;
|
||||
|
||||
alternativa3d var globalCoords:Point3D;
|
||||
|
||||
public function Vertex(param1:Number = 0, param2:Number = 0, param3:Number = 0)
|
||||
{
|
||||
this.alternativa3d::changeCoordsOperation = new Operation("changeCoords",this);
|
||||
this.alternativa3d::calculateCoordsOperation = new Operation("calculateCoords",this,this.calculateCoords,Operation.alternativa3d::VERTEX_CALCULATE_COORDS);
|
||||
this.alternativa3d::_faces = new Set();
|
||||
this.alternativa3d::globalCoords = new Point3D();
|
||||
super();
|
||||
this.alternativa3d::_coords = new Point3D(param1,param2,param3);
|
||||
this.alternativa3d::changeCoordsOperation.alternativa3d::addSequel(this.alternativa3d::calculateCoordsOperation);
|
||||
}
|
||||
|
||||
private function calculateCoords() : void
|
||||
{
|
||||
this.alternativa3d::globalCoords.copy(this.alternativa3d::_coords);
|
||||
this.alternativa3d::globalCoords.transform(this.alternativa3d::_mesh.alternativa3d::_transformation);
|
||||
}
|
||||
|
||||
public function set x(param1:Number) : void
|
||||
{
|
||||
if(this.alternativa3d::_coords.x != param1)
|
||||
{
|
||||
this.alternativa3d::_coords.x = param1;
|
||||
if(this.alternativa3d::_mesh != null)
|
||||
{
|
||||
this.alternativa3d::_mesh.alternativa3d::addOperationToScene(this.alternativa3d::changeCoordsOperation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function set y(param1:Number) : void
|
||||
{
|
||||
if(this.alternativa3d::_coords.y != param1)
|
||||
{
|
||||
this.alternativa3d::_coords.y = param1;
|
||||
if(this.alternativa3d::_mesh != null)
|
||||
{
|
||||
this.alternativa3d::_mesh.alternativa3d::addOperationToScene(this.alternativa3d::changeCoordsOperation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function set z(param1:Number) : void
|
||||
{
|
||||
if(this.alternativa3d::_coords.z != param1)
|
||||
{
|
||||
this.alternativa3d::_coords.z = param1;
|
||||
if(this.alternativa3d::_mesh != null)
|
||||
{
|
||||
this.alternativa3d::_mesh.alternativa3d::addOperationToScene(this.alternativa3d::changeCoordsOperation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function set coords(param1:Point3D) : void
|
||||
{
|
||||
if(!this.alternativa3d::_coords.equals(param1))
|
||||
{
|
||||
this.alternativa3d::_coords.copy(param1);
|
||||
if(this.alternativa3d::_mesh != null)
|
||||
{
|
||||
this.alternativa3d::_mesh.alternativa3d::addOperationToScene(this.alternativa3d::changeCoordsOperation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function get x() : Number
|
||||
{
|
||||
return this.alternativa3d::_coords.x;
|
||||
}
|
||||
|
||||
public function get y() : Number
|
||||
{
|
||||
return this.alternativa3d::_coords.y;
|
||||
}
|
||||
|
||||
public function get z() : Number
|
||||
{
|
||||
return this.alternativa3d::_coords.z;
|
||||
}
|
||||
|
||||
public function get coords() : Point3D
|
||||
{
|
||||
return this.alternativa3d::_coords.clone();
|
||||
}
|
||||
|
||||
public function get mesh() : Mesh
|
||||
{
|
||||
return this.alternativa3d::_mesh;
|
||||
}
|
||||
|
||||
public function get faces() : Set
|
||||
{
|
||||
return this.alternativa3d::_faces.clone();
|
||||
}
|
||||
|
||||
public function get id() : Object
|
||||
{
|
||||
return this.alternativa3d::_mesh != null ? this.alternativa3d::_mesh.getVertexId(this) : null;
|
||||
}
|
||||
|
||||
alternativa3d function addToScene(param1:Scene3D) : void
|
||||
{
|
||||
param1.alternativa3d::addOperation(this.alternativa3d::calculateCoordsOperation);
|
||||
}
|
||||
|
||||
alternativa3d function removeFromScene(param1:Scene3D) : void
|
||||
{
|
||||
param1.alternativa3d::removeOperation(this.alternativa3d::calculateCoordsOperation);
|
||||
param1.alternativa3d::removeOperation(this.alternativa3d::changeCoordsOperation);
|
||||
}
|
||||
|
||||
alternativa3d function addToMesh(param1:Mesh) : void
|
||||
{
|
||||
param1.alternativa3d::changeCoordsOperation.alternativa3d::addSequel(this.alternativa3d::calculateCoordsOperation);
|
||||
param1.alternativa3d::changeRotationOrScaleOperation.alternativa3d::addSequel(this.alternativa3d::calculateCoordsOperation);
|
||||
this.alternativa3d::_mesh = param1;
|
||||
}
|
||||
|
||||
alternativa3d function removeFromMesh(param1:Mesh) : void
|
||||
{
|
||||
var loc2:* = undefined;
|
||||
var loc3:Face = null;
|
||||
param1.alternativa3d::changeCoordsOperation.alternativa3d::removeSequel(this.alternativa3d::calculateCoordsOperation);
|
||||
param1.alternativa3d::changeRotationOrScaleOperation.alternativa3d::removeSequel(this.alternativa3d::calculateCoordsOperation);
|
||||
for(loc2 in this.alternativa3d::_faces)
|
||||
{
|
||||
loc3 = loc2;
|
||||
param1.removeFace(loc3);
|
||||
}
|
||||
this.alternativa3d::_mesh = null;
|
||||
}
|
||||
|
||||
alternativa3d function addToFace(param1:Face) : void
|
||||
{
|
||||
this.alternativa3d::changeCoordsOperation.alternativa3d::addSequel(param1.alternativa3d::calculateUVOperation);
|
||||
this.alternativa3d::changeCoordsOperation.alternativa3d::addSequel(param1.alternativa3d::calculateNormalOperation);
|
||||
this.alternativa3d::_faces.add(param1);
|
||||
}
|
||||
|
||||
alternativa3d function removeFromFace(param1:Face) : void
|
||||
{
|
||||
this.alternativa3d::changeCoordsOperation.alternativa3d::removeSequel(param1.alternativa3d::calculateUVOperation);
|
||||
this.alternativa3d::changeCoordsOperation.alternativa3d::removeSequel(param1.alternativa3d::calculateNormalOperation);
|
||||
this.alternativa3d::_faces.remove(param1);
|
||||
}
|
||||
|
||||
public function toString() : String
|
||||
{
|
||||
return "[Vertex ID:" + this.id + " " + this.alternativa3d::_coords.x.toFixed(2) + ", " + this.alternativa3d::_coords.y.toFixed(2) + ", " + this.alternativa3d::_coords.z.toFixed(2) + "]";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
package alternativa.engine3d.display
|
||||
{
|
||||
import alternativa.engine3d.alternativa3d;
|
||||
import alternativa.engine3d.core.PolyPrimitive;
|
||||
import alternativa.engine3d.materials.Material;
|
||||
import flash.display.Graphics;
|
||||
import flash.display.Sprite;
|
||||
|
||||
use namespace alternativa3d;
|
||||
|
||||
public class Skin extends Sprite
|
||||
{
|
||||
private static var collector:Array = new Array();
|
||||
|
||||
alternativa3d var gfx:Graphics;
|
||||
|
||||
alternativa3d var nextSkin:Skin;
|
||||
|
||||
alternativa3d var primitive:PolyPrimitive;
|
||||
|
||||
alternativa3d var material:Material;
|
||||
|
||||
public function Skin()
|
||||
{
|
||||
this.alternativa3d::gfx = graphics;
|
||||
super();
|
||||
}
|
||||
|
||||
alternativa3d static function createSkin() : Skin
|
||||
{
|
||||
var loc1:Skin = null;
|
||||
loc1 = collector.pop();
|
||||
if(loc1 != null)
|
||||
{
|
||||
return loc1;
|
||||
}
|
||||
return new Skin();
|
||||
}
|
||||
|
||||
alternativa3d static function destroySkin(param1:Skin) : void
|
||||
{
|
||||
collector.push(param1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,796 +0,0 @@
|
||||
package alternativa.engine3d.display
|
||||
{
|
||||
import alternativa.engine3d.*;
|
||||
import alternativa.engine3d.core.Camera3D;
|
||||
import alternativa.engine3d.core.Face;
|
||||
import alternativa.engine3d.core.Object3D;
|
||||
import alternativa.engine3d.core.Sprite3D;
|
||||
import alternativa.engine3d.core.SpritePrimitive;
|
||||
import alternativa.engine3d.core.Surface;
|
||||
import alternativa.engine3d.events.MouseEvent3D;
|
||||
import alternativa.types.Matrix3D;
|
||||
import alternativa.types.Point3D;
|
||||
import flash.display.Sprite;
|
||||
import flash.events.Event;
|
||||
import flash.events.MouseEvent;
|
||||
import flash.geom.Point;
|
||||
|
||||
use namespace alternativa3d;
|
||||
|
||||
public class View extends Sprite
|
||||
{
|
||||
alternativa3d var canvas:Sprite;
|
||||
|
||||
private var _camera:Camera3D;
|
||||
|
||||
alternativa3d var _width:Number;
|
||||
|
||||
alternativa3d var _height:Number;
|
||||
|
||||
alternativa3d var _interactive:Boolean;
|
||||
|
||||
private var faceUnderPoint:Face;
|
||||
|
||||
private var objectUnderPoint:Object3D;
|
||||
|
||||
private var lastMouseEvent:MouseEvent;
|
||||
|
||||
private var stagePoint:Point;
|
||||
|
||||
private var currentFace:Face;
|
||||
|
||||
private var currentSurface:Surface;
|
||||
|
||||
private var currentObject:Object3D;
|
||||
|
||||
private var pressedFace:Face;
|
||||
|
||||
private var pressedSurface:Surface;
|
||||
|
||||
private var pressedObject:Object3D;
|
||||
|
||||
private var lineVector:Point3D;
|
||||
|
||||
private var linePoint:Point3D;
|
||||
|
||||
private var globalCursor3DCoords:Point3D;
|
||||
|
||||
private var localCursor3DCoords:Point3D;
|
||||
|
||||
private var uvPoint:Point;
|
||||
|
||||
private var inverseMatrix:Matrix3D;
|
||||
|
||||
public function View(param1:Camera3D = null, param2:Number = 0, param3:Number = 0)
|
||||
{
|
||||
this.stagePoint = new Point();
|
||||
this.lineVector = new Point3D();
|
||||
this.linePoint = new Point3D();
|
||||
this.globalCursor3DCoords = new Point3D();
|
||||
this.localCursor3DCoords = new Point3D();
|
||||
this.uvPoint = new Point();
|
||||
this.inverseMatrix = new Matrix3D();
|
||||
super();
|
||||
this.alternativa3d::canvas = new Sprite();
|
||||
this.alternativa3d::canvas.mouseEnabled = false;
|
||||
this.alternativa3d::canvas.mouseChildren = false;
|
||||
this.alternativa3d::canvas.tabEnabled = false;
|
||||
this.alternativa3d::canvas.tabChildren = false;
|
||||
addChild(this.alternativa3d::canvas);
|
||||
this.camera = param1;
|
||||
this.width = param2;
|
||||
this.height = param3;
|
||||
addEventListener(Event.REMOVED_FROM_STAGE,this.onRemovedFromStage);
|
||||
}
|
||||
|
||||
public function get camera() : Camera3D
|
||||
{
|
||||
return this._camera;
|
||||
}
|
||||
|
||||
public function set camera(param1:Camera3D) : void
|
||||
{
|
||||
var loc2:Skin = null;
|
||||
var loc3:Skin = null;
|
||||
if(this._camera != param1)
|
||||
{
|
||||
if(this._camera != null)
|
||||
{
|
||||
this._camera.alternativa3d::removeFromView(this);
|
||||
}
|
||||
if(param1 != null)
|
||||
{
|
||||
if(param1.alternativa3d::_view != null)
|
||||
{
|
||||
param1.alternativa3d::_view.camera = null;
|
||||
}
|
||||
param1.alternativa3d::addToView(this);
|
||||
}
|
||||
else if(this.alternativa3d::canvas.numChildren > 0)
|
||||
{
|
||||
loc2 = Skin(this.alternativa3d::canvas.getChildAt(0));
|
||||
while(loc2 != null)
|
||||
{
|
||||
loc3 = loc2.alternativa3d::nextSkin;
|
||||
this.alternativa3d::canvas.removeChild(loc2);
|
||||
if(loc2.alternativa3d::material != null)
|
||||
{
|
||||
loc2.alternativa3d::material.alternativa3d::clear(loc2);
|
||||
}
|
||||
loc2.alternativa3d::nextSkin = null;
|
||||
loc2.alternativa3d::primitive = null;
|
||||
loc2.alternativa3d::material = null;
|
||||
Skin.alternativa3d::destroySkin(loc2);
|
||||
loc2 = loc3;
|
||||
}
|
||||
}
|
||||
this._camera = param1;
|
||||
}
|
||||
}
|
||||
|
||||
override public function get width() : Number
|
||||
{
|
||||
return this.alternativa3d::_width;
|
||||
}
|
||||
|
||||
override public function set width(param1:Number) : void
|
||||
{
|
||||
if(this.alternativa3d::_width != param1)
|
||||
{
|
||||
this.alternativa3d::_width = param1;
|
||||
this.alternativa3d::canvas.x = this.alternativa3d::_width * 0.5;
|
||||
if(this._camera != null)
|
||||
{
|
||||
this.camera.alternativa3d::addOperationToScene(this.camera.alternativa3d::calculatePlanesOperation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override public function get height() : Number
|
||||
{
|
||||
return this.alternativa3d::_height;
|
||||
}
|
||||
|
||||
override public function set height(param1:Number) : void
|
||||
{
|
||||
if(this.alternativa3d::_height != param1)
|
||||
{
|
||||
this.alternativa3d::_height = param1;
|
||||
this.alternativa3d::canvas.y = this.alternativa3d::_height * 0.5;
|
||||
if(this._camera != null)
|
||||
{
|
||||
this.camera.alternativa3d::addOperationToScene(this.camera.alternativa3d::calculatePlanesOperation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getObjectUnderPoint(param1:Point) : Object
|
||||
{
|
||||
var loc4:Skin = null;
|
||||
if(stage == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var loc2:Point = localToGlobal(param1);
|
||||
var loc3:Array = stage.getObjectsUnderPoint(loc2);
|
||||
var loc5:int = int(loc3.length - 1);
|
||||
while(loc5 >= 0)
|
||||
{
|
||||
loc4 = loc3[loc5] as Skin;
|
||||
if(loc4 != null && loc4.parent.parent == this)
|
||||
{
|
||||
return loc4.alternativa3d::primitive.alternativa3d::face != null ? loc4.alternativa3d::primitive.alternativa3d::face : (loc4.alternativa3d::primitive as SpritePrimitive).alternativa3d::sprite;
|
||||
}
|
||||
loc5--;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
override public function getObjectsUnderPoint(param1:Point) : Array
|
||||
{
|
||||
var loc7:Skin = null;
|
||||
if(stage == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var loc2:Point = localToGlobal(param1);
|
||||
var loc3:Array = stage.getObjectsUnderPoint(loc2);
|
||||
var loc4:Array = new Array();
|
||||
var loc5:uint = loc3.length;
|
||||
var loc6:uint = 0;
|
||||
while(loc6 < loc5)
|
||||
{
|
||||
loc7 = loc3[loc6] as Skin;
|
||||
if(loc7 != null && loc7.parent.parent == this)
|
||||
{
|
||||
if(loc7.alternativa3d::primitive.alternativa3d::face != null)
|
||||
{
|
||||
loc4.push(loc7.alternativa3d::primitive.alternativa3d::face);
|
||||
}
|
||||
else
|
||||
{
|
||||
loc4.push((loc7.alternativa3d::primitive as SpritePrimitive).alternativa3d::sprite);
|
||||
}
|
||||
}
|
||||
loc6++;
|
||||
}
|
||||
return loc4;
|
||||
}
|
||||
|
||||
public function projectPoint(param1:Point3D) : Point3D
|
||||
{
|
||||
var loc4:Number = NaN;
|
||||
if(this._camera == null || this._camera.alternativa3d::_scene == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var loc2:Matrix3D = Object3D.alternativa3d::matrix2;
|
||||
var loc3:Number = this._camera.alternativa3d::_focalLength;
|
||||
if(this._camera.alternativa3d::getTransformation(loc2))
|
||||
{
|
||||
loc2.invert();
|
||||
if(this._camera.alternativa3d::_orthographic)
|
||||
{
|
||||
loc4 = this._camera.zoom;
|
||||
loc2.scale(loc4,loc4,loc4);
|
||||
}
|
||||
}
|
||||
else if(this._camera.alternativa3d::_orthographic && this._camera.alternativa3d::calculateMatrixOperation.alternativa3d::queued)
|
||||
{
|
||||
loc2.invert();
|
||||
loc4 = this._camera.zoom;
|
||||
loc2.scale(loc4,loc4,loc4);
|
||||
}
|
||||
else
|
||||
{
|
||||
loc2 = this._camera.alternativa3d::cameraMatrix;
|
||||
}
|
||||
if(!this._camera.alternativa3d::_orthographic && this._camera.alternativa3d::calculatePlanesOperation.alternativa3d::queued)
|
||||
{
|
||||
loc3 = 0.5 * Math.sqrt(this.alternativa3d::_height * this.alternativa3d::_height + this.alternativa3d::_width * this.alternativa3d::_width) / Math.tan(0.5 * this._camera.alternativa3d::_fov);
|
||||
}
|
||||
var loc5:Number = loc2.a * param1.x + loc2.b * param1.y + loc2.c * param1.z + loc2.d;
|
||||
var loc6:Number = loc2.e * param1.x + loc2.f * param1.y + loc2.g * param1.z + loc2.h;
|
||||
var loc7:Number = loc2.i * param1.x + loc2.j * param1.y + loc2.k * param1.z + loc2.l;
|
||||
if(this._camera.alternativa3d::_orthographic)
|
||||
{
|
||||
return new Point3D(loc5 + (this.alternativa3d::_width >> 1),loc6 + (this.alternativa3d::_height >> 1),loc7);
|
||||
}
|
||||
return new Point3D(loc5 * loc3 / loc7 + (this.alternativa3d::_width >> 1),loc6 * loc3 / loc7 + (this.alternativa3d::_height >> 1),loc7);
|
||||
}
|
||||
|
||||
public function get interactive() : Boolean
|
||||
{
|
||||
return this.alternativa3d::_interactive;
|
||||
}
|
||||
|
||||
public function set interactive(param1:Boolean) : void
|
||||
{
|
||||
if(this.alternativa3d::_interactive == param1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
this.alternativa3d::_interactive = param1;
|
||||
if(this.alternativa3d::_interactive)
|
||||
{
|
||||
addEventListener(MouseEvent.MOUSE_DOWN,this.onMouseEvent);
|
||||
addEventListener(MouseEvent.MOUSE_UP,this.onMouseEvent);
|
||||
addEventListener(MouseEvent.MOUSE_MOVE,this.onMouseEvent);
|
||||
addEventListener(MouseEvent.MOUSE_WHEEL,this.onMouseEvent);
|
||||
addEventListener(MouseEvent.MOUSE_OUT,this.onMouseEvent);
|
||||
}
|
||||
else
|
||||
{
|
||||
removeEventListener(MouseEvent.MOUSE_DOWN,this.onMouseEvent);
|
||||
removeEventListener(MouseEvent.MOUSE_UP,this.onMouseEvent);
|
||||
removeEventListener(MouseEvent.MOUSE_MOVE,this.onMouseEvent);
|
||||
removeEventListener(MouseEvent.MOUSE_WHEEL,this.onMouseEvent);
|
||||
removeEventListener(MouseEvent.MOUSE_OUT,this.onMouseEvent);
|
||||
if(stage != null)
|
||||
{
|
||||
stage.removeEventListener(MouseEvent.MOUSE_UP,this.stageMouseUp);
|
||||
}
|
||||
this.pressedFace = this.currentFace = null;
|
||||
this.pressedSurface = this.currentSurface = null;
|
||||
this.pressedObject = this.currentObject = null;
|
||||
}
|
||||
}
|
||||
|
||||
public function projectViewPointToPlane(param1:Point, param2:Point3D, param3:Number, param4:Point3D = null) : Point3D
|
||||
{
|
||||
if(this._camera == null || this._camera.alternativa3d::_scene == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if(param4 == null)
|
||||
{
|
||||
param4 = new Point3D();
|
||||
}
|
||||
this.calculateRayOriginAndVector(param1.x - (this.alternativa3d::_width >> 1),param1.y - (this.alternativa3d::_height >> 1),this.linePoint,this.lineVector,true);
|
||||
if(!this.calculateLineAndPlaneIntersection(this.linePoint,this.lineVector,param2,param3,param4))
|
||||
{
|
||||
param4.reset(NaN,NaN,NaN);
|
||||
}
|
||||
return param4;
|
||||
}
|
||||
|
||||
public function get3DCoords(param1:Point, param2:Number, param3:Point3D = null) : Point3D
|
||||
{
|
||||
var loc4:Number = NaN;
|
||||
if(this._camera == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if(param3 == null)
|
||||
{
|
||||
param3 = new Point3D();
|
||||
}
|
||||
if(this._camera.alternativa3d::_orthographic)
|
||||
{
|
||||
param3.x = (param1.x - (this.alternativa3d::_width >> 1)) / this.camera.alternativa3d::_zoom;
|
||||
param3.y = (param1.y - (this.alternativa3d::_height >> 1)) / this.camera.alternativa3d::_zoom;
|
||||
}
|
||||
else
|
||||
{
|
||||
loc4 = param2 / this._camera.focalLength;
|
||||
param3.x = (param1.x - (this.alternativa3d::_width >> 1)) * loc4;
|
||||
param3.y = (param1.y - (this.alternativa3d::_height >> 1)) * loc4;
|
||||
}
|
||||
param3.z = param2;
|
||||
return param3;
|
||||
}
|
||||
|
||||
private function onRemovedFromStage(param1:Event) : void
|
||||
{
|
||||
this.interactive = false;
|
||||
}
|
||||
|
||||
private function stageMouseUp(param1:MouseEvent) : void
|
||||
{
|
||||
if(stage == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
this.pressedFace = null;
|
||||
this.pressedSurface = null;
|
||||
this.pressedObject = null;
|
||||
stage.removeEventListener(MouseEvent.MOUSE_UP,this.stageMouseUp);
|
||||
}
|
||||
|
||||
private function getInteractiveObjectUnderPoint(param1:Number, param2:Number) : void
|
||||
{
|
||||
var loc4:Skin = null;
|
||||
var loc6:Sprite3D = null;
|
||||
if(stage == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
this.faceUnderPoint = null;
|
||||
this.objectUnderPoint = null;
|
||||
this.stagePoint.x = param1;
|
||||
this.stagePoint.y = param2;
|
||||
var loc3:Array = stage.getObjectsUnderPoint(this.stagePoint);
|
||||
var loc5:int = int(loc3.length - 1);
|
||||
while(loc5 >= 0)
|
||||
{
|
||||
loc4 = loc3[loc5] as Skin;
|
||||
if(loc4 != null && loc4.parent.parent == this)
|
||||
{
|
||||
if(loc4.alternativa3d::primitive.alternativa3d::face != null)
|
||||
{
|
||||
if(loc4.alternativa3d::primitive.alternativa3d::face.alternativa3d::_mesh.mouseEnabled)
|
||||
{
|
||||
this.faceUnderPoint = loc4.alternativa3d::primitive.alternativa3d::face;
|
||||
this.objectUnderPoint = this.faceUnderPoint.alternativa3d::_mesh;
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
loc6 = (loc4.alternativa3d::primitive as SpritePrimitive).alternativa3d::sprite;
|
||||
if(loc6.mouseEnabled)
|
||||
{
|
||||
this.objectUnderPoint = loc6;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
loc5--;
|
||||
}
|
||||
}
|
||||
|
||||
private function getInteractiveObjectPointProperties(param1:Number, param2:Number) : void
|
||||
{
|
||||
var loc3:Point3D = null;
|
||||
var loc4:Number = NaN;
|
||||
var loc5:Point = null;
|
||||
if(this.objectUnderPoint == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
this.calculateRayOriginAndVector(param1,param2,this.linePoint,this.lineVector);
|
||||
if(this.faceUnderPoint != null)
|
||||
{
|
||||
loc3 = this.faceUnderPoint.alternativa3d::globalNormal;
|
||||
loc4 = this.faceUnderPoint.alternativa3d::globalOffset;
|
||||
}
|
||||
else
|
||||
{
|
||||
loc3 = this.lineVector.clone();
|
||||
loc3.invert();
|
||||
this.globalCursor3DCoords.copy(this.objectUnderPoint.alternativa3d::_coords);
|
||||
this.globalCursor3DCoords.transform(this.objectUnderPoint.alternativa3d::_transformation);
|
||||
loc4 = this.globalCursor3DCoords.dot(loc3);
|
||||
}
|
||||
this.calculateLineAndPlaneIntersection(this.linePoint,this.lineVector,loc3,loc4,this.globalCursor3DCoords);
|
||||
this.inverseMatrix.copy((this.faceUnderPoint != null ? this.faceUnderPoint.alternativa3d::_mesh : this.objectUnderPoint)._transformation);
|
||||
this.inverseMatrix.invert();
|
||||
this.localCursor3DCoords.copy(this.globalCursor3DCoords);
|
||||
this.localCursor3DCoords.transform(this.inverseMatrix);
|
||||
if(this.faceUnderPoint != null)
|
||||
{
|
||||
loc5 = this.faceUnderPoint.getUV(this.localCursor3DCoords);
|
||||
if(loc5 != null)
|
||||
{
|
||||
this.uvPoint.x = loc5.x;
|
||||
this.uvPoint.y = loc5.y;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.uvPoint.x = NaN;
|
||||
this.uvPoint.y = NaN;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function createSimpleMouseEvent3D(param1:String, param2:Object3D, param3:Surface, param4:Face) : MouseEvent3D
|
||||
{
|
||||
var loc5:Boolean = this.lastMouseEvent == null ? false : this.lastMouseEvent.altKey;
|
||||
var loc6:Boolean = this.lastMouseEvent == null ? false : this.lastMouseEvent.ctrlKey;
|
||||
var loc7:Boolean = this.lastMouseEvent == null ? false : this.lastMouseEvent.shiftKey;
|
||||
var loc8:int = this.lastMouseEvent == null ? 0 : this.lastMouseEvent.delta;
|
||||
return new MouseEvent3D(param1,this,param2,param3,param4,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,loc5,loc6,loc7,loc8);
|
||||
}
|
||||
|
||||
private function createFullMouseEvent3D(param1:String, param2:Object3D, param3:Surface, param4:Face) : MouseEvent3D
|
||||
{
|
||||
var loc5:Boolean = this.lastMouseEvent == null ? false : this.lastMouseEvent.altKey;
|
||||
var loc6:Boolean = this.lastMouseEvent == null ? false : this.lastMouseEvent.ctrlKey;
|
||||
var loc7:Boolean = this.lastMouseEvent == null ? false : this.lastMouseEvent.shiftKey;
|
||||
var loc8:int = this.lastMouseEvent == null ? 0 : this.lastMouseEvent.delta;
|
||||
return new MouseEvent3D(param1,this,param2,param3,param4,this.globalCursor3DCoords.x,this.globalCursor3DCoords.y,this.globalCursor3DCoords.z,this.localCursor3DCoords.x,this.localCursor3DCoords.y,this.localCursor3DCoords.z,this.uvPoint.x,this.uvPoint.y,loc5,loc6,loc7,loc8);
|
||||
}
|
||||
|
||||
private function onMouseEvent(param1:MouseEvent) : void
|
||||
{
|
||||
if(stage == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
this.lastMouseEvent = param1;
|
||||
this.getInteractiveObjectUnderPoint(stage.mouseX,stage.mouseY);
|
||||
this.getInteractiveObjectPointProperties(mouseX - (this.alternativa3d::_width >> 1),mouseY - (this.alternativa3d::_height >> 1));
|
||||
switch(param1.type)
|
||||
{
|
||||
case MouseEvent.MOUSE_MOVE:
|
||||
this.processMouseMove();
|
||||
break;
|
||||
case MouseEvent.MOUSE_OUT:
|
||||
stage.addEventListener(MouseEvent.MOUSE_UP,this.stageMouseUp);
|
||||
this.alternativa3d::checkMouseOverOut();
|
||||
break;
|
||||
case MouseEvent.MOUSE_DOWN:
|
||||
this.processMouseDown();
|
||||
break;
|
||||
case MouseEvent.MOUSE_UP:
|
||||
this.processMouseUp();
|
||||
break;
|
||||
case MouseEvent.MOUSE_WHEEL:
|
||||
this.processMouseWheel();
|
||||
}
|
||||
this.lastMouseEvent = null;
|
||||
}
|
||||
|
||||
private function processMouseDown() : void
|
||||
{
|
||||
var loc1:MouseEvent3D = null;
|
||||
if(this.objectUnderPoint == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if(this.faceUnderPoint != null)
|
||||
{
|
||||
this.currentFace = this.faceUnderPoint;
|
||||
this.currentSurface = this.faceUnderPoint.alternativa3d::_surface;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.currentFace = null;
|
||||
this.currentSurface = null;
|
||||
}
|
||||
this.currentObject = this.pressedObject = this.objectUnderPoint;
|
||||
if(this.currentFace != null && this.currentFace.mouseEnabled)
|
||||
{
|
||||
this.pressedFace = this.currentFace;
|
||||
loc1 = this.createFullMouseEvent3D(MouseEvent3D.MOUSE_DOWN,this.currentObject,this.currentSurface,this.currentFace);
|
||||
this.currentFace.dispatchEvent(loc1);
|
||||
}
|
||||
if(this.currentSurface != null && this.currentSurface.mouseEnabled)
|
||||
{
|
||||
this.pressedSurface = this.currentSurface;
|
||||
loc1 = this.createFullMouseEvent3D(MouseEvent3D.MOUSE_DOWN,this.currentObject,this.currentSurface,this.currentFace);
|
||||
this.currentSurface.dispatchEvent(loc1);
|
||||
}
|
||||
loc1 = this.createFullMouseEvent3D(MouseEvent3D.MOUSE_DOWN,this.currentObject,this.currentSurface,this.currentFace);
|
||||
this.currentObject.dispatchEvent(loc1);
|
||||
}
|
||||
|
||||
private function processMouseUp() : void
|
||||
{
|
||||
var loc1:MouseEvent3D = null;
|
||||
if(this.objectUnderPoint == null)
|
||||
{
|
||||
this.pressedFace = null;
|
||||
this.pressedSurface = null;
|
||||
this.pressedObject = null;
|
||||
return;
|
||||
}
|
||||
if(this.faceUnderPoint != null)
|
||||
{
|
||||
this.currentFace = this.faceUnderPoint;
|
||||
this.currentSurface = this.faceUnderPoint.alternativa3d::_surface;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.currentFace = null;
|
||||
this.currentSurface = null;
|
||||
}
|
||||
this.currentObject = this.objectUnderPoint;
|
||||
if(this.currentFace != null && this.currentFace.mouseEnabled)
|
||||
{
|
||||
loc1 = this.createFullMouseEvent3D(MouseEvent3D.MOUSE_UP,this.currentObject,this.currentSurface,this.currentFace);
|
||||
this.currentFace.dispatchEvent(loc1);
|
||||
}
|
||||
if(this.currentSurface != null && this.currentSurface.mouseEnabled)
|
||||
{
|
||||
loc1 = this.createFullMouseEvent3D(MouseEvent3D.MOUSE_UP,this.currentObject,this.currentSurface,this.currentFace);
|
||||
this.currentSurface.dispatchEvent(loc1);
|
||||
}
|
||||
loc1 = this.createFullMouseEvent3D(MouseEvent3D.MOUSE_UP,this.currentObject,this.currentSurface,this.currentFace);
|
||||
this.currentObject.dispatchEvent(loc1);
|
||||
if(this.currentFace != null && this.currentFace == this.pressedFace && this.currentFace.mouseEnabled)
|
||||
{
|
||||
loc1 = this.createFullMouseEvent3D(MouseEvent3D.CLICK,this.currentObject,this.currentSurface,this.currentFace);
|
||||
this.currentFace.dispatchEvent(loc1);
|
||||
}
|
||||
if(this.currentSurface != null && this.currentSurface == this.pressedSurface && this.currentSurface.mouseEnabled)
|
||||
{
|
||||
loc1 = this.createFullMouseEvent3D(MouseEvent3D.CLICK,this.currentObject,this.currentSurface,this.currentFace);
|
||||
this.currentSurface.dispatchEvent(loc1);
|
||||
}
|
||||
if(this.currentObject == this.pressedObject)
|
||||
{
|
||||
loc1 = this.createFullMouseEvent3D(MouseEvent3D.CLICK,this.currentObject,this.currentSurface,this.currentFace);
|
||||
this.currentObject.dispatchEvent(loc1);
|
||||
}
|
||||
this.pressedFace = null;
|
||||
this.pressedSurface = null;
|
||||
this.pressedObject = null;
|
||||
}
|
||||
|
||||
private function processMouseWheel() : void
|
||||
{
|
||||
var loc1:MouseEvent3D = null;
|
||||
if(this.objectUnderPoint == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if(this.faceUnderPoint != null)
|
||||
{
|
||||
this.currentFace = this.faceUnderPoint;
|
||||
this.currentSurface = this.faceUnderPoint.alternativa3d::_surface;
|
||||
if(this.currentFace.mouseEnabled)
|
||||
{
|
||||
loc1 = this.createFullMouseEvent3D(MouseEvent3D.MOUSE_WHEEL,this.currentObject,this.currentSurface,this.currentFace);
|
||||
this.currentFace.dispatchEvent(loc1);
|
||||
}
|
||||
if(this.currentSurface.mouseEnabled)
|
||||
{
|
||||
loc1 = this.createFullMouseEvent3D(MouseEvent3D.MOUSE_WHEEL,this.currentObject,this.currentSurface,this.currentFace);
|
||||
this.currentSurface.dispatchEvent(loc1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.currentFace = null;
|
||||
this.currentSurface = null;
|
||||
}
|
||||
this.currentObject = this.objectUnderPoint;
|
||||
loc1 = this.createFullMouseEvent3D(MouseEvent3D.MOUSE_WHEEL,this.currentObject,this.currentSurface,this.currentFace);
|
||||
this.currentObject.dispatchEvent(loc1);
|
||||
}
|
||||
|
||||
alternativa3d function checkMouseOverOut(param1:Boolean = false) : void
|
||||
{
|
||||
var loc2:MouseEvent3D = null;
|
||||
var loc3:Surface = null;
|
||||
var loc4:Boolean = false;
|
||||
var loc5:Boolean = false;
|
||||
var loc6:Boolean = false;
|
||||
if(stage == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if(param1)
|
||||
{
|
||||
this.getInteractiveObjectUnderPoint(stage.mouseX,stage.mouseY);
|
||||
this.getInteractiveObjectPointProperties(mouseX - (this.alternativa3d::_width >> 1),mouseY - (this.alternativa3d::_height >> 1));
|
||||
}
|
||||
if(this.objectUnderPoint == null)
|
||||
{
|
||||
if(this.currentFace != null)
|
||||
{
|
||||
if(this.currentFace.mouseEnabled)
|
||||
{
|
||||
loc2 = this.createSimpleMouseEvent3D(MouseEvent3D.MOUSE_OUT,this.currentObject,this.currentSurface,this.currentFace);
|
||||
this.currentFace.dispatchEvent(loc2);
|
||||
}
|
||||
if(this.currentSurface.mouseEnabled)
|
||||
{
|
||||
loc2 = this.createSimpleMouseEvent3D(MouseEvent3D.MOUSE_OUT,this.currentObject,this.currentSurface,this.currentFace);
|
||||
this.currentSurface.dispatchEvent(loc2);
|
||||
}
|
||||
}
|
||||
if(this.currentObject != null)
|
||||
{
|
||||
loc2 = this.createSimpleMouseEvent3D(MouseEvent3D.MOUSE_OUT,this.currentObject,this.currentSurface,this.currentFace);
|
||||
this.currentObject.dispatchEvent(loc2);
|
||||
}
|
||||
this.currentFace = null;
|
||||
this.currentSurface = null;
|
||||
this.currentObject = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(this.faceUnderPoint != null)
|
||||
{
|
||||
loc3 = this.faceUnderPoint.alternativa3d::_surface;
|
||||
}
|
||||
if(this.faceUnderPoint != this.currentFace)
|
||||
{
|
||||
if(this.currentFace != null && this.currentFace.mouseEnabled)
|
||||
{
|
||||
loc2 = this.createSimpleMouseEvent3D(MouseEvent3D.MOUSE_OUT,this.currentObject,this.currentSurface,this.currentFace);
|
||||
this.currentFace.dispatchEvent(loc2);
|
||||
}
|
||||
loc4 = true;
|
||||
if(loc3 != this.currentSurface)
|
||||
{
|
||||
if(this.currentSurface != null && this.currentSurface.mouseEnabled)
|
||||
{
|
||||
loc2 = this.createSimpleMouseEvent3D(MouseEvent3D.MOUSE_OUT,this.currentObject,this.currentSurface,this.currentFace);
|
||||
this.currentSurface.dispatchEvent(loc2);
|
||||
}
|
||||
loc5 = true;
|
||||
}
|
||||
}
|
||||
if(this.objectUnderPoint != this.currentObject)
|
||||
{
|
||||
if(this.currentObject != null)
|
||||
{
|
||||
loc2 = this.createSimpleMouseEvent3D(MouseEvent3D.MOUSE_OUT,this.currentObject,this.currentSurface,this.currentFace);
|
||||
this.currentObject.dispatchEvent(loc2);
|
||||
}
|
||||
loc6 = true;
|
||||
}
|
||||
this.currentFace = this.faceUnderPoint;
|
||||
this.currentSurface = loc3;
|
||||
this.currentObject = this.objectUnderPoint;
|
||||
if(this.currentFace != null)
|
||||
{
|
||||
if(loc4 && this.currentFace.mouseEnabled)
|
||||
{
|
||||
loc2 = this.createFullMouseEvent3D(MouseEvent3D.MOUSE_OVER,this.currentObject,this.currentSurface,this.currentFace);
|
||||
this.currentFace.dispatchEvent(loc2);
|
||||
}
|
||||
if(loc5 && this.currentSurface.mouseEnabled)
|
||||
{
|
||||
loc2 = this.createFullMouseEvent3D(MouseEvent3D.MOUSE_OVER,this.currentObject,this.currentSurface,this.currentFace);
|
||||
this.currentSurface.dispatchEvent(loc2);
|
||||
}
|
||||
}
|
||||
if(loc6)
|
||||
{
|
||||
loc2 = this.createFullMouseEvent3D(MouseEvent3D.MOUSE_OVER,this.currentObject,this.currentSurface,this.currentFace);
|
||||
this.currentObject.dispatchEvent(loc2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function processMouseMove() : void
|
||||
{
|
||||
var loc1:MouseEvent3D = null;
|
||||
this.alternativa3d::checkMouseOverOut();
|
||||
if(this.currentFace != null)
|
||||
{
|
||||
if(this.currentFace.mouseEnabled)
|
||||
{
|
||||
loc1 = this.createFullMouseEvent3D(MouseEvent3D.MOUSE_MOVE,this.currentObject,this.currentSurface,this.currentFace);
|
||||
this.currentFace.dispatchEvent(loc1);
|
||||
}
|
||||
if(this.currentSurface.mouseEnabled)
|
||||
{
|
||||
loc1 = this.createFullMouseEvent3D(MouseEvent3D.MOUSE_MOVE,this.currentObject,this.currentSurface,this.currentFace);
|
||||
this.currentSurface.dispatchEvent(loc1);
|
||||
}
|
||||
}
|
||||
if(this.currentObject != null)
|
||||
{
|
||||
loc1 = this.createFullMouseEvent3D(MouseEvent3D.MOUSE_MOVE,this.currentObject,this.currentSurface,this.currentFace);
|
||||
this.currentObject.dispatchEvent(loc1);
|
||||
}
|
||||
}
|
||||
|
||||
private function calculateLineAndPlaneIntersection(param1:Point3D, param2:Point3D, param3:Point3D, param4:Number, param5:Point3D) : Boolean
|
||||
{
|
||||
var loc6:Number = param3.x * param2.x + param3.y * param2.y + param3.z * param2.z;
|
||||
if(loc6 < 1e-8 && loc6 > -1e-8)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var loc7:Number = (param4 - param1.x * param3.x - param1.y * param3.y - param1.z * param3.z) / loc6;
|
||||
param5.x = param1.x + loc7 * param2.x;
|
||||
param5.y = param1.y + loc7 * param2.y;
|
||||
param5.z = param1.z + loc7 * param2.z;
|
||||
return true;
|
||||
}
|
||||
|
||||
private function calculateRayOriginAndVector(param1:Number, param2:Number, param3:Point3D, param4:Point3D, param5:Boolean = false) : void
|
||||
{
|
||||
var loc6:Number = NaN;
|
||||
var loc7:Number = NaN;
|
||||
var loc8:Number = NaN;
|
||||
var loc9:Matrix3D = null;
|
||||
if(param5)
|
||||
{
|
||||
loc9 = Object3D.alternativa3d::matrix2;
|
||||
this._camera.alternativa3d::getTransformation(loc9);
|
||||
}
|
||||
else
|
||||
{
|
||||
loc9 = this._camera.alternativa3d::_transformation;
|
||||
}
|
||||
if(this._camera.alternativa3d::_orthographic)
|
||||
{
|
||||
loc6 = param1 / this._camera.zoom;
|
||||
loc7 = param2 / this._camera.zoom;
|
||||
param3.x = loc9.a * loc6 + loc9.b * loc7 + loc9.d;
|
||||
param3.y = loc9.e * loc6 + loc9.f * loc7 + loc9.h;
|
||||
param3.z = loc9.i * loc6 + loc9.j * loc7 + loc9.l;
|
||||
loc7 = 0;
|
||||
loc6 = 0;
|
||||
loc8 = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
param3.x = loc9.d;
|
||||
param3.y = loc9.h;
|
||||
param3.z = loc9.l;
|
||||
loc6 = param1;
|
||||
loc7 = param2;
|
||||
if(param5)
|
||||
{
|
||||
loc8 = this._camera.focalLength;
|
||||
}
|
||||
else
|
||||
{
|
||||
loc8 = this._camera.alternativa3d::_focalLength;
|
||||
}
|
||||
}
|
||||
this.lineVector.x = loc6 * loc9.a + loc7 * loc9.b + loc8 * loc9.c;
|
||||
this.lineVector.y = loc6 * loc9.e + loc7 * loc9.f + loc8 * loc9.g;
|
||||
this.lineVector.z = loc6 * loc9.i + loc7 * loc9.j + loc8 * loc9.k;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
package alternativa.engine3d.errors
|
||||
{
|
||||
public class Engine3DError extends Error
|
||||
{
|
||||
public var source:Object;
|
||||
|
||||
public function Engine3DError(param1:String = "", param2:Object = null)
|
||||
{
|
||||
super(param1);
|
||||
this.source = param2;
|
||||
this.name = "Engine3DError";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
package alternativa.engine3d.errors
|
||||
{
|
||||
import alternativa.engine3d.core.Face;
|
||||
import alternativa.engine3d.core.Mesh;
|
||||
import alternativa.engine3d.core.Surface;
|
||||
import alternativa.utils.TextUtils;
|
||||
|
||||
public class FaceExistsError extends ObjectExistsError
|
||||
{
|
||||
public function FaceExistsError(param1:Object = null, param2:Object = null)
|
||||
{
|
||||
var loc3:* = null;
|
||||
if(param2 is Mesh)
|
||||
{
|
||||
loc3 = "Mesh ";
|
||||
}
|
||||
else if(param2 is Surface)
|
||||
{
|
||||
loc3 = "Surface ";
|
||||
}
|
||||
if(param1 is Face)
|
||||
{
|
||||
loc3 += "%1. Face %2 already exists.";
|
||||
}
|
||||
else
|
||||
{
|
||||
loc3 += "%1. Face with ID \'%2\' already exists.";
|
||||
}
|
||||
super(TextUtils.insertVars(loc3,param2,param1),param1,param2);
|
||||
this.name = "FaceExistsError";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
package alternativa.engine3d.errors
|
||||
{
|
||||
import alternativa.engine3d.core.Mesh;
|
||||
import alternativa.utils.TextUtils;
|
||||
|
||||
public class FaceNeedMoreVerticesError extends Engine3DError
|
||||
{
|
||||
public var count:uint;
|
||||
|
||||
public function FaceNeedMoreVerticesError(param1:Mesh = null, param2:uint = 0)
|
||||
{
|
||||
super(TextUtils.insertVars("Mesh %1. %2 vertices not enough for face creation.",param1,param2),param1);
|
||||
this.count = param2;
|
||||
this.name = "FaceNeedMoreVerticesError";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
package alternativa.engine3d.errors
|
||||
{
|
||||
import alternativa.engine3d.core.Face;
|
||||
import alternativa.engine3d.core.Mesh;
|
||||
import alternativa.utils.TextUtils;
|
||||
|
||||
public class FaceNotFoundError extends ObjectNotFoundError
|
||||
{
|
||||
public function FaceNotFoundError(param1:Object = null, param2:Object = null)
|
||||
{
|
||||
var loc3:* = null;
|
||||
if(param2 is Mesh)
|
||||
{
|
||||
loc3 = "Mesh ";
|
||||
}
|
||||
else
|
||||
{
|
||||
loc3 = "Surface ";
|
||||
}
|
||||
if(param1 is Face)
|
||||
{
|
||||
loc3 += "%1. Face %2 not found.";
|
||||
}
|
||||
else
|
||||
{
|
||||
loc3 += "%1. Face with ID \'%2\' not found.";
|
||||
}
|
||||
super(TextUtils.insertVars(loc3,param2,param1),param1,param2);
|
||||
this.name = "FaceNotFoundError";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
package alternativa.engine3d.errors
|
||||
{
|
||||
import alternativa.engine3d.core.Mesh;
|
||||
import alternativa.engine3d.core.Surface;
|
||||
import alternativa.utils.TextUtils;
|
||||
|
||||
public class InvalidIDError extends Engine3DError
|
||||
{
|
||||
public var id:Object;
|
||||
|
||||
public function InvalidIDError(param1:Object = null, param2:Object = null)
|
||||
{
|
||||
var loc3:String = null;
|
||||
if(param2 is Mesh)
|
||||
{
|
||||
loc3 = "Mesh %2. ";
|
||||
}
|
||||
else if(param2 is Surface)
|
||||
{
|
||||
loc3 = "Surface %2. ";
|
||||
}
|
||||
super(TextUtils.insertVars(loc3 + "ID %1 is reserved and cannot be used",[param1,param2]),param2);
|
||||
this.id = param1;
|
||||
this.name = "InvalidIDError";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
package alternativa.engine3d.errors
|
||||
{
|
||||
import alternativa.engine3d.core.Object3D;
|
||||
import alternativa.utils.TextUtils;
|
||||
|
||||
public class Object3DHierarchyError extends Engine3DError
|
||||
{
|
||||
public var object:Object3D;
|
||||
|
||||
public function Object3DHierarchyError(param1:Object3D = null, param2:Object3D = null)
|
||||
{
|
||||
super(TextUtils.insertVars("Object3D %1. Object %2 cannot be added",param2,param1),param2);
|
||||
this.object = param1;
|
||||
this.name = "Object3DHierarchyError";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
package alternativa.engine3d.errors
|
||||
{
|
||||
import alternativa.engine3d.core.Object3D;
|
||||
import alternativa.utils.TextUtils;
|
||||
|
||||
public class Object3DNotFoundError extends ObjectNotFoundError
|
||||
{
|
||||
public function Object3DNotFoundError(param1:Object3D = null, param2:Object3D = null)
|
||||
{
|
||||
super(TextUtils.insertVars("Object3D %1. Object %2 not in child list",param2,param1),param1,param2);
|
||||
this.name = "Object3DNotFoundError";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
package alternativa.engine3d.errors
|
||||
{
|
||||
public class ObjectExistsError extends Engine3DError
|
||||
{
|
||||
public var object:Object;
|
||||
|
||||
public function ObjectExistsError(param1:String = "", param2:Object = null, param3:Object = null)
|
||||
{
|
||||
super(param1,param3);
|
||||
this.object = param2;
|
||||
this.name = "ObjectExistsError";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
package alternativa.engine3d.errors
|
||||
{
|
||||
public class ObjectNotFoundError extends Engine3DError
|
||||
{
|
||||
public var object:Object;
|
||||
|
||||
public function ObjectNotFoundError(param1:String = "", param2:Object = null, param3:Object = null)
|
||||
{
|
||||
super(param1,param3);
|
||||
this.object = param2;
|
||||
this.name = "ObjectNotFoundError";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
package alternativa.engine3d.errors
|
||||
{
|
||||
import alternativa.engine3d.core.Scene3D;
|
||||
import alternativa.engine3d.core.Sector;
|
||||
import alternativa.utils.TextUtils;
|
||||
|
||||
public class SectorInOtherSceneError extends Engine3DError
|
||||
{
|
||||
public function SectorInOtherSceneError(param1:Sector = null, param2:Scene3D = null)
|
||||
{
|
||||
super(TextUtils.insertVars("%1. Sector %2 is aready situated in the other scene",param2,param1),param2);
|
||||
this.name = "SectorInOtherSceneError";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
package alternativa.engine3d.errors
|
||||
{
|
||||
import alternativa.engine3d.core.Scene3D;
|
||||
import alternativa.engine3d.core.Splitter;
|
||||
import alternativa.utils.TextUtils;
|
||||
|
||||
public class SplitterInOtherSceneError extends Engine3DError
|
||||
{
|
||||
public function SplitterInOtherSceneError(param1:Splitter = null, param2:Scene3D = null)
|
||||
{
|
||||
super(TextUtils.insertVars("%1. Splitter %2 is aready situated in the other scene",param2,param1),param2);
|
||||
this.name = "SplitterInOtherSceneError";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
package alternativa.engine3d.errors
|
||||
{
|
||||
import alternativa.utils.TextUtils;
|
||||
|
||||
public class SplitterNeedMoreVerticesError extends Engine3DError
|
||||
{
|
||||
public var count:uint;
|
||||
|
||||
public function SplitterNeedMoreVerticesError(param1:uint = 0)
|
||||
{
|
||||
super(TextUtils.insertVars("%1 points not enough for splitter creation.",param1),null);
|
||||
this.count = param1;
|
||||
this.name = "SplitterNeedMoreVerticesError";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
package alternativa.engine3d.errors
|
||||
{
|
||||
import alternativa.engine3d.core.Mesh;
|
||||
import alternativa.utils.TextUtils;
|
||||
|
||||
public class SurfaceExistsError extends ObjectExistsError
|
||||
{
|
||||
public function SurfaceExistsError(param1:Object = null, param2:Mesh = null)
|
||||
{
|
||||
super(TextUtils.insertVars("Mesh %1. Surface with ID \'%2\' already exists.",param2,param1),param1,param2);
|
||||
this.name = "SurfaceExistsError";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
package alternativa.engine3d.errors
|
||||
{
|
||||
import alternativa.engine3d.core.Mesh;
|
||||
import alternativa.engine3d.core.Surface;
|
||||
import alternativa.utils.TextUtils;
|
||||
|
||||
public class SurfaceNotFoundError extends ObjectNotFoundError
|
||||
{
|
||||
public function SurfaceNotFoundError(param1:Object = null, param2:Mesh = null)
|
||||
{
|
||||
if(param2 == null)
|
||||
{
|
||||
}
|
||||
if(param1 is Surface)
|
||||
{
|
||||
message = "Mesh %1. Surface %2 not found.";
|
||||
}
|
||||
else
|
||||
{
|
||||
message = "Mesh %1. Surface with ID \'%2\' not found.";
|
||||
}
|
||||
super(TextUtils.insertVars(message,param2,param1),param1,param2);
|
||||
this.name = "SurfaceNotFoundError";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
package alternativa.engine3d.errors
|
||||
{
|
||||
import alternativa.engine3d.core.Mesh;
|
||||
import alternativa.utils.TextUtils;
|
||||
|
||||
public class VertexExistsError extends ObjectExistsError
|
||||
{
|
||||
public function VertexExistsError(param1:Object = null, param2:Mesh = null)
|
||||
{
|
||||
super(TextUtils.insertVars("Mesh %1. Vertex with ID \'%2\' already exists.",param2,param1),param1,param2);
|
||||
this.name = "VertexExistsError";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
package alternativa.engine3d.errors
|
||||
{
|
||||
import alternativa.engine3d.core.Mesh;
|
||||
import alternativa.engine3d.core.Vertex;
|
||||
import alternativa.utils.TextUtils;
|
||||
|
||||
public class VertexNotFoundError extends ObjectNotFoundError
|
||||
{
|
||||
public function VertexNotFoundError(param1:Object = null, param2:Mesh = null)
|
||||
{
|
||||
if(param1 is Vertex)
|
||||
{
|
||||
message = "Mesh %1. Vertex %2 not found.";
|
||||
}
|
||||
else
|
||||
{
|
||||
message = "Mesh %1. Vertex with ID \'%2\' not found.";
|
||||
}
|
||||
super(TextUtils.insertVars(message,param2,param1),param1,param2);
|
||||
this.name = "VertexNotFoundError";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,89 +0,0 @@
|
||||
package alternativa.engine3d.events
|
||||
{
|
||||
import alternativa.engine3d.core.Face;
|
||||
import alternativa.engine3d.core.Object3D;
|
||||
import alternativa.engine3d.core.Surface;
|
||||
import alternativa.engine3d.display.View;
|
||||
import flash.events.Event;
|
||||
|
||||
public class MouseEvent3D extends Event
|
||||
{
|
||||
public static const CLICK:String = "click";
|
||||
|
||||
public static const MOUSE_DOWN:String = "mouseDown";
|
||||
|
||||
public static const MOUSE_UP:String = "mouseUp";
|
||||
|
||||
public static const MOUSE_OVER:String = "mouseOver";
|
||||
|
||||
public static const MOUSE_OUT:String = "mouseOut";
|
||||
|
||||
public static const MOUSE_MOVE:String = "mouseMove";
|
||||
|
||||
public static const MOUSE_WHEEL:String = "mouseWheel";
|
||||
|
||||
public var object:Object3D;
|
||||
|
||||
public var surface:Surface;
|
||||
|
||||
public var face:Face;
|
||||
|
||||
public var view:View;
|
||||
|
||||
public var globalX:Number;
|
||||
|
||||
public var globalY:Number;
|
||||
|
||||
public var globalZ:Number;
|
||||
|
||||
public var localX:Number;
|
||||
|
||||
public var localY:Number;
|
||||
|
||||
public var localZ:Number;
|
||||
|
||||
public var u:Number;
|
||||
|
||||
public var v:Number;
|
||||
|
||||
public var altKey:Boolean;
|
||||
|
||||
public var ctrlKey:Boolean;
|
||||
|
||||
public var shiftKey:Boolean;
|
||||
|
||||
public var delta:int;
|
||||
|
||||
public function MouseEvent3D(param1:String, param2:View, param3:Object3D, param4:Surface, param5:Face, param6:Number = NaN, param7:Number = NaN, param8:Number = NaN, param9:Number = NaN, param10:Number = NaN, param11:Number = NaN, param12:Number = NaN, param13:Number = NaN, param14:Boolean = false, param15:Boolean = false, param16:Boolean = false, param17:int = 0)
|
||||
{
|
||||
super(param1);
|
||||
this.view = param2;
|
||||
this.object = param3;
|
||||
this.surface = param4;
|
||||
this.face = param5;
|
||||
this.globalX = param6;
|
||||
this.globalY = param7;
|
||||
this.globalZ = param8;
|
||||
this.localX = param9;
|
||||
this.localY = param10;
|
||||
this.localZ = param11;
|
||||
this.u = param12;
|
||||
this.v = param13;
|
||||
this.altKey = param14;
|
||||
this.ctrlKey = param15;
|
||||
this.shiftKey = param16;
|
||||
this.delta = param17;
|
||||
}
|
||||
|
||||
override public function toString() : String
|
||||
{
|
||||
return formatToString("MouseEvent3D","object","surface","face","globalX","globalY","globalZ","localX","localY","localZ","u","v","delta","altKey","ctrlKey","shiftKey");
|
||||
}
|
||||
|
||||
override public function clone() : Event
|
||||
{
|
||||
return new MouseEvent3D(type,this.view,this.object,this.surface,this.face,this.globalX,this.globalY,this.globalZ,this.localX,this.localY,this.localZ,this.u,this.v,this.altKey,this.ctrlKey,this.shiftKey,this.delta);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,160 +0,0 @@
|
||||
package alternativa.engine3d.loaders
|
||||
{
|
||||
import alternativa.engine3d.core.Object3D;
|
||||
import alternativa.engine3d.loaders.events.LoaderEvent;
|
||||
import alternativa.engine3d.loaders.events.LoaderProgressEvent;
|
||||
import flash.events.ErrorEvent;
|
||||
import flash.events.Event;
|
||||
import flash.events.EventDispatcher;
|
||||
import flash.events.IOErrorEvent;
|
||||
import flash.events.ProgressEvent;
|
||||
import flash.events.SecurityErrorEvent;
|
||||
import flash.net.URLLoader;
|
||||
import flash.net.URLLoaderDataFormat;
|
||||
import flash.net.URLRequest;
|
||||
import flash.system.LoaderContext;
|
||||
import flash.utils.ByteArray;
|
||||
|
||||
public class Loader3D extends EventDispatcher
|
||||
{
|
||||
protected var loaderState:int = 0;
|
||||
|
||||
protected var baseURL:String;
|
||||
|
||||
protected var loaderContext:LoaderContext;
|
||||
|
||||
protected var _content:Object3D;
|
||||
|
||||
private var mainLoader:URLLoader;
|
||||
|
||||
public function Loader3D()
|
||||
{
|
||||
super(this);
|
||||
}
|
||||
|
||||
final public function get content() : Object3D
|
||||
{
|
||||
return this._content;
|
||||
}
|
||||
|
||||
final public function load(param1:String, param2:LoaderContext = null) : void
|
||||
{
|
||||
this.baseURL = param1.substring(0,param1.lastIndexOf("/") + 1);
|
||||
this.loaderContext = param2;
|
||||
if(this.mainLoader == null)
|
||||
{
|
||||
this.mainLoader = new URLLoader();
|
||||
this.mainLoader.dataFormat = URLLoaderDataFormat.BINARY;
|
||||
this.mainLoader.addEventListener(Event.COMPLETE,this.onMainLoadingComplete);
|
||||
this.mainLoader.addEventListener(ProgressEvent.PROGRESS,this.onMainLoadingProgress);
|
||||
this.mainLoader.addEventListener(IOErrorEvent.IO_ERROR,this.onMainLoadingError);
|
||||
this.mainLoader.addEventListener(SecurityErrorEvent.SECURITY_ERROR,this.onMainLoadingError);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.close();
|
||||
}
|
||||
this._content = null;
|
||||
this.setState(Loader3DState.LOADING_MAIN);
|
||||
this.mainLoader.load(new URLRequest(param1));
|
||||
if(hasEventListener(LoaderEvent.LOADING_START))
|
||||
{
|
||||
dispatchEvent(new LoaderEvent(LoaderEvent.LOADING_START,LoadingStage.MAIN_FILE));
|
||||
}
|
||||
}
|
||||
|
||||
final public function loadBytes(param1:ByteArray, param2:String = null, param3:LoaderContext = null) : void
|
||||
{
|
||||
if(param2 == null)
|
||||
{
|
||||
param2 = "";
|
||||
}
|
||||
else if(param2.length > 0 && param2.charAt(param2.length - 1) != "/")
|
||||
{
|
||||
param2 += "/";
|
||||
}
|
||||
this.baseURL = param2;
|
||||
this.loaderContext = param3;
|
||||
this.close();
|
||||
this._content = null;
|
||||
this.parse(param1);
|
||||
}
|
||||
|
||||
final public function close() : void
|
||||
{
|
||||
if(this.loaderState == Loader3DState.LOADING_MAIN)
|
||||
{
|
||||
this.mainLoader.close();
|
||||
}
|
||||
this.closeInternal();
|
||||
this.clean();
|
||||
this.setState(Loader3DState.IDLE);
|
||||
}
|
||||
|
||||
final public function unload() : void
|
||||
{
|
||||
if(this.loaderState != Loader3DState.IDLE)
|
||||
{
|
||||
return;
|
||||
}
|
||||
this._content = null;
|
||||
this.unloadInternal();
|
||||
}
|
||||
|
||||
protected function closeInternal() : void
|
||||
{
|
||||
}
|
||||
|
||||
protected function unloadInternal() : void
|
||||
{
|
||||
}
|
||||
|
||||
protected function setState(param1:int) : void
|
||||
{
|
||||
this.loaderState = param1;
|
||||
}
|
||||
|
||||
protected function parse(param1:ByteArray) : void
|
||||
{
|
||||
}
|
||||
|
||||
protected function onMainLoadingError(param1:ErrorEvent) : void
|
||||
{
|
||||
this.setState(Loader3DState.IDLE);
|
||||
dispatchEvent(param1);
|
||||
}
|
||||
|
||||
final protected function complete() : void
|
||||
{
|
||||
this.setState(Loader3DState.IDLE);
|
||||
this.clean();
|
||||
if(hasEventListener(Event.COMPLETE))
|
||||
{
|
||||
dispatchEvent(new Event(Event.COMPLETE));
|
||||
}
|
||||
}
|
||||
|
||||
protected function clean() : void
|
||||
{
|
||||
}
|
||||
|
||||
private function onMainLoadingComplete(param1:Event) : void
|
||||
{
|
||||
this.setState(Loader3DState.IDLE);
|
||||
if(hasEventListener(LoaderEvent.LOADING_COMPLETE))
|
||||
{
|
||||
dispatchEvent(new LoaderEvent(LoaderEvent.LOADING_COMPLETE,LoadingStage.MAIN_FILE));
|
||||
}
|
||||
this.parse(this.mainLoader.data);
|
||||
}
|
||||
|
||||
private function onMainLoadingProgress(param1:ProgressEvent) : void
|
||||
{
|
||||
if(hasEventListener(LoaderProgressEvent.LOADING_PROGRESS))
|
||||
{
|
||||
dispatchEvent(new LoaderProgressEvent(LoaderProgressEvent.LOADING_PROGRESS,LoadingStage.MAIN_FILE,1,0,param1.bytesLoaded,param1.bytesTotal));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,195 +0,0 @@
|
||||
package alternativa.engine3d.loaders
|
||||
{
|
||||
import alternativa.engine3d.alternativa3d;
|
||||
import alternativa.engine3d.core.Mesh;
|
||||
import alternativa.engine3d.core.Object3D;
|
||||
import alternativa.engine3d.core.Surface;
|
||||
import alternativa.engine3d.loaders.events.LoaderEvent;
|
||||
import alternativa.engine3d.loaders.events.LoaderProgressEvent;
|
||||
import alternativa.engine3d.materials.TextureMaterial;
|
||||
import alternativa.types.Texture;
|
||||
import flash.events.Event;
|
||||
import flash.events.IOErrorEvent;
|
||||
import flash.utils.ByteArray;
|
||||
|
||||
use namespace alternativa3d;
|
||||
|
||||
public class Loader3DS extends Loader3D
|
||||
{
|
||||
public var loadMaterials:Boolean = true;
|
||||
|
||||
private var bitmapLoader:TextureMapsBatchLoader;
|
||||
|
||||
private var parser:Parser3DS;
|
||||
|
||||
public function Loader3DS()
|
||||
{
|
||||
super();
|
||||
this.parser = new Parser3DS();
|
||||
}
|
||||
|
||||
public function get repeat() : Boolean
|
||||
{
|
||||
return this.parser.repeat;
|
||||
}
|
||||
|
||||
public function set repeat(param1:Boolean) : void
|
||||
{
|
||||
this.parser.repeat = param1;
|
||||
}
|
||||
|
||||
public function get smooth() : Boolean
|
||||
{
|
||||
return this.parser.smooth;
|
||||
}
|
||||
|
||||
public function set smooth(param1:Boolean) : void
|
||||
{
|
||||
this.parser.smooth = param1;
|
||||
}
|
||||
|
||||
public function get blendMode() : String
|
||||
{
|
||||
return this.parser.blendMode;
|
||||
}
|
||||
|
||||
public function set blendMode(param1:String) : void
|
||||
{
|
||||
this.parser.blendMode = param1;
|
||||
}
|
||||
|
||||
public function get precision() : Number
|
||||
{
|
||||
return this.parser.precision;
|
||||
}
|
||||
|
||||
public function set precision(param1:Number) : void
|
||||
{
|
||||
this.parser.precision = param1;
|
||||
}
|
||||
|
||||
public function get scale() : Number
|
||||
{
|
||||
return this.parser.scale;
|
||||
}
|
||||
|
||||
public function set scale(param1:Number) : void
|
||||
{
|
||||
this.parser.scale = param1;
|
||||
}
|
||||
|
||||
public function get mobility() : int
|
||||
{
|
||||
return this.parser.mobility;
|
||||
}
|
||||
|
||||
public function set mobility(param1:int) : void
|
||||
{
|
||||
this.parser.mobility = param1;
|
||||
}
|
||||
|
||||
override protected function closeInternal() : void
|
||||
{
|
||||
super.closeInternal();
|
||||
if(loaderState == Loader3DState.LOADING_TEXTURE)
|
||||
{
|
||||
this.bitmapLoader.close();
|
||||
}
|
||||
}
|
||||
|
||||
override protected function unloadInternal() : void
|
||||
{
|
||||
if(this.bitmapLoader != null)
|
||||
{
|
||||
this.bitmapLoader.unload();
|
||||
}
|
||||
}
|
||||
|
||||
override protected function parse(param1:ByteArray) : void
|
||||
{
|
||||
this.parser.parse(param1);
|
||||
_content = this.parser.content;
|
||||
if(this.loadMaterials && this.parser.textureMaterials != null)
|
||||
{
|
||||
this.loadTextures();
|
||||
}
|
||||
else
|
||||
{
|
||||
complete();
|
||||
}
|
||||
}
|
||||
|
||||
private function loadTextures() : void
|
||||
{
|
||||
if(this.bitmapLoader == null)
|
||||
{
|
||||
this.bitmapLoader = new TextureMapsBatchLoader();
|
||||
this.bitmapLoader.addEventListener(LoaderEvent.LOADING_START,this.onTextureLoadingStart);
|
||||
this.bitmapLoader.addEventListener(LoaderEvent.LOADING_COMPLETE,this.onTextureLoadingComplete);
|
||||
this.bitmapLoader.addEventListener(LoaderProgressEvent.LOADING_PROGRESS,this.onTextureLoadingProgress);
|
||||
this.bitmapLoader.addEventListener(Event.COMPLETE,this.onTextureMaterialsLoadingComplete);
|
||||
this.bitmapLoader.addEventListener(IOErrorEvent.IO_ERROR,this.onTextureLoadingError);
|
||||
}
|
||||
setState(Loader3DState.LOADING_TEXTURE);
|
||||
this.bitmapLoader.load(baseURL,this.parser.textureMaterials,loaderContext);
|
||||
}
|
||||
|
||||
private function onTextureLoadingError(param1:IOErrorEvent) : void
|
||||
{
|
||||
dispatchEvent(param1);
|
||||
}
|
||||
|
||||
private function onTextureLoadingStart(param1:LoaderEvent) : void
|
||||
{
|
||||
if(hasEventListener(param1.type))
|
||||
{
|
||||
dispatchEvent(param1);
|
||||
}
|
||||
}
|
||||
|
||||
private function onTextureLoadingComplete(param1:LoaderEvent) : void
|
||||
{
|
||||
if(hasEventListener(param1.type))
|
||||
{
|
||||
dispatchEvent(param1);
|
||||
}
|
||||
}
|
||||
|
||||
private function onTextureLoadingProgress(param1:LoaderProgressEvent) : void
|
||||
{
|
||||
if(hasEventListener(param1.type))
|
||||
{
|
||||
dispatchEvent(param1);
|
||||
}
|
||||
}
|
||||
|
||||
private function onTextureMaterialsLoadingComplete(param1:Event) : void
|
||||
{
|
||||
this.parser.content.forEach(this.setTextures);
|
||||
complete();
|
||||
}
|
||||
|
||||
private function setTextures(param1:Object3D) : void
|
||||
{
|
||||
var loc3:String = null;
|
||||
var loc4:TextureMapsInfo = null;
|
||||
var loc5:Texture = null;
|
||||
var loc6:Surface = null;
|
||||
var loc2:Mesh = param1 as Mesh;
|
||||
if(loc2 != null)
|
||||
{
|
||||
for(loc3 in loc2.alternativa3d::_surfaces)
|
||||
{
|
||||
loc4 = this.parser.textureMaterials[loc3];
|
||||
if(loc4 != null)
|
||||
{
|
||||
loc5 = new Texture(this.bitmapLoader.textures[loc3],loc4.diffuseMapFileName);
|
||||
loc6 = loc2.alternativa3d::_surfaces[loc3];
|
||||
TextureMaterial(loc6.material).texture = loc5;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
package alternativa.engine3d.loaders
|
||||
{
|
||||
public final class Loader3DState
|
||||
{
|
||||
public static const IDLE:int = 0;
|
||||
|
||||
public static const LOADING_MAIN:int = 1;
|
||||
|
||||
public static const LOADING_TEXTURE:int = 2;
|
||||
|
||||
public static const LOADING_LIBRARY:int = 3;
|
||||
|
||||
public function Loader3DState()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
package alternativa.engine3d.loaders
|
||||
{
|
||||
public final class LoadingStage
|
||||
{
|
||||
public static const MAIN_FILE:int = 0;
|
||||
|
||||
public static const TEXTURE:int = 1;
|
||||
|
||||
public static const MATERIAL_LIBRARY:int = 2;
|
||||
|
||||
public function LoadingStage()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,180 +0,0 @@
|
||||
package alternativa.engine3d.loaders
|
||||
{
|
||||
import alternativa.engine3d.loaders.events.LoaderEvent;
|
||||
import alternativa.engine3d.loaders.events.LoaderProgressEvent;
|
||||
import alternativa.types.Map;
|
||||
import flash.display.BitmapData;
|
||||
import flash.events.Event;
|
||||
import flash.events.EventDispatcher;
|
||||
import flash.events.IOErrorEvent;
|
||||
import flash.events.ProgressEvent;
|
||||
import flash.system.LoaderContext;
|
||||
|
||||
public class TextureMapsBatchLoader extends EventDispatcher
|
||||
{
|
||||
public static var stubBitmapData:BitmapData;
|
||||
|
||||
private var loader:TextureMapsLoader;
|
||||
|
||||
private var loaderContext:LoaderContext;
|
||||
|
||||
private var baseUrl:String;
|
||||
|
||||
private var batch:Map;
|
||||
|
||||
private var materialNames:Array;
|
||||
|
||||
private var totalFiles:int;
|
||||
|
||||
private var currFileIndex:int;
|
||||
|
||||
private var materialIndex:int;
|
||||
|
||||
private var _textures:Map;
|
||||
|
||||
public function TextureMapsBatchLoader()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function get textures() : Map
|
||||
{
|
||||
return this._textures;
|
||||
}
|
||||
|
||||
private function getStubBitmapData() : BitmapData
|
||||
{
|
||||
var loc1:uint = 0;
|
||||
var loc2:uint = 0;
|
||||
var loc3:uint = 0;
|
||||
if(stubBitmapData == null)
|
||||
{
|
||||
loc1 = 20;
|
||||
stubBitmapData = new BitmapData(loc1,loc1,false,0);
|
||||
loc2 = 0;
|
||||
while(loc2 < loc1)
|
||||
{
|
||||
loc3 = 0;
|
||||
while(loc3 < loc1)
|
||||
{
|
||||
stubBitmapData.setPixel(!!(loc2 % 2) ? int(loc3) : loc3 + 1,loc2,16711935);
|
||||
loc3 += 2;
|
||||
}
|
||||
loc2++;
|
||||
}
|
||||
}
|
||||
return stubBitmapData;
|
||||
}
|
||||
|
||||
public function close() : void
|
||||
{
|
||||
if(this.loader != null)
|
||||
{
|
||||
this.loader.close();
|
||||
}
|
||||
}
|
||||
|
||||
private function clean() : void
|
||||
{
|
||||
this.loaderContext = null;
|
||||
this.batch = null;
|
||||
this.materialNames = null;
|
||||
}
|
||||
|
||||
public function unload() : void
|
||||
{
|
||||
this._textures = null;
|
||||
}
|
||||
|
||||
public function load(param1:String, param2:Map, param3:LoaderContext) : void
|
||||
{
|
||||
var loc4:String = null;
|
||||
var loc5:TextureMapsInfo = null;
|
||||
this.baseUrl = param1;
|
||||
this.batch = param2;
|
||||
this.loaderContext = param3;
|
||||
if(this.loader == null)
|
||||
{
|
||||
this.loader = new TextureMapsLoader();
|
||||
this.loader.addEventListener(LoaderEvent.LOADING_START,this.onTextureLoadingStart);
|
||||
this.loader.addEventListener(LoaderEvent.LOADING_COMPLETE,this.onTextureLoadingComplete);
|
||||
this.loader.addEventListener(ProgressEvent.PROGRESS,this.onProgress);
|
||||
this.loader.addEventListener(Event.COMPLETE,this.onMaterialTexturesLoadingComplete);
|
||||
this.loader.addEventListener(IOErrorEvent.IO_ERROR,this.onMaterialTexturesLoadingComplete);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.close();
|
||||
}
|
||||
this.totalFiles = 0;
|
||||
this.materialNames = new Array();
|
||||
for(loc4 in param2)
|
||||
{
|
||||
this.materialNames.push(loc4);
|
||||
loc5 = param2[loc4];
|
||||
this.totalFiles += loc5.opacityMapFileName == null ? 1 : 2;
|
||||
}
|
||||
this.currFileIndex = 0;
|
||||
this.materialIndex = 0;
|
||||
this._textures = new Map();
|
||||
this.loadNextTextureFile();
|
||||
}
|
||||
|
||||
private function loadNextTextureFile() : void
|
||||
{
|
||||
var loc1:TextureMapsInfo = this.batch[this.materialNames[this.materialIndex]];
|
||||
this.loader.load(this.baseUrl + loc1.diffuseMapFileName,loc1.opacityMapFileName == null ? null : this.baseUrl + loc1.opacityMapFileName,this.loaderContext);
|
||||
}
|
||||
|
||||
private function onTextureLoadingStart(param1:Event) : void
|
||||
{
|
||||
dispatchEvent(param1);
|
||||
}
|
||||
|
||||
private function onTextureLoadingComplete(param1:Event) : void
|
||||
{
|
||||
dispatchEvent(param1);
|
||||
++this.currFileIndex;
|
||||
}
|
||||
|
||||
private function onProgress(param1:ProgressEvent) : void
|
||||
{
|
||||
dispatchEvent(new LoaderProgressEvent(LoaderProgressEvent.LOADING_PROGRESS,LoadingStage.TEXTURE,this.totalFiles,this.currFileIndex,param1.bytesLoaded,param1.bytesTotal));
|
||||
}
|
||||
|
||||
private function onMaterialTexturesLoadingComplete(param1:Event) : void
|
||||
{
|
||||
var loc2:IOErrorEvent = null;
|
||||
var loc3:TextureMapsInfo = null;
|
||||
if(param1 is IOErrorEvent)
|
||||
{
|
||||
this._textures.add(this.materialNames[this.materialIndex],this.getStubBitmapData());
|
||||
loc2 = IOErrorEvent(param1);
|
||||
loc3 = this.batch[this.materialNames[this.materialIndex]];
|
||||
if(loc3.diffuseMapFileName)
|
||||
{
|
||||
loc2.text += this.baseUrl + loc3.diffuseMapFileName;
|
||||
}
|
||||
if(loc3.opacityMapFileName)
|
||||
{
|
||||
loc2.text += this.baseUrl + loc3.opacityMapFileName;
|
||||
}
|
||||
dispatchEvent(loc2);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._textures.add(this.materialNames[this.materialIndex],this.loader.bitmapData);
|
||||
}
|
||||
if(++this.materialIndex == this.materialNames.length)
|
||||
{
|
||||
this.clean();
|
||||
dispatchEvent(new Event(Event.COMPLETE));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.loadNextTextureFile();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
package alternativa.engine3d.loaders
|
||||
{
|
||||
public class TextureMapsInfo
|
||||
{
|
||||
public var diffuseMapFileName:String;
|
||||
|
||||
public var opacityMapFileName:String;
|
||||
|
||||
public function TextureMapsInfo(param1:String = null, param2:String = null)
|
||||
{
|
||||
super();
|
||||
this.diffuseMapFileName = param1;
|
||||
this.opacityMapFileName = param2;
|
||||
}
|
||||
|
||||
public function toString() : String
|
||||
{
|
||||
return "[Object TextureMapsInfo, diffuseMapFileName:" + this.diffuseMapFileName + ", opacityMapFileName: " + this.opacityMapFileName + "]";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,155 +0,0 @@
|
||||
package alternativa.engine3d.loaders
|
||||
{
|
||||
import alternativa.engine3d.loaders.events.LoaderEvent;
|
||||
import flash.display.Bitmap;
|
||||
import flash.display.BitmapData;
|
||||
import flash.display.BitmapDataChannel;
|
||||
import flash.display.BlendMode;
|
||||
import flash.display.Loader;
|
||||
import flash.events.Event;
|
||||
import flash.events.EventDispatcher;
|
||||
import flash.events.IOErrorEvent;
|
||||
import flash.events.ProgressEvent;
|
||||
import flash.geom.Matrix;
|
||||
import flash.geom.Point;
|
||||
import flash.net.URLRequest;
|
||||
import flash.system.LoaderContext;
|
||||
|
||||
public class TextureMapsLoader extends EventDispatcher
|
||||
{
|
||||
private static const STATE_IDLE:int = 0;
|
||||
|
||||
private static const STATE_LOADING_DIFFUSE_MAP:int = 1;
|
||||
|
||||
private static const STATE_LOADING_ALPHA_MAP:int = 2;
|
||||
|
||||
private var _bitmapData:BitmapData;
|
||||
|
||||
private var bitmapLoader:Loader;
|
||||
|
||||
private var alphaTextureUrl:String;
|
||||
|
||||
private var loaderContext:LoaderContext;
|
||||
|
||||
private var loaderState:int = 0;
|
||||
|
||||
public function TextureMapsLoader(param1:String = null, param2:String = null, param3:LoaderContext = null)
|
||||
{
|
||||
super();
|
||||
if(param1 != null)
|
||||
{
|
||||
this.load(param1,param2,param3);
|
||||
}
|
||||
}
|
||||
|
||||
public function load(param1:String, param2:String = null, param3:LoaderContext = null) : void
|
||||
{
|
||||
this.alphaTextureUrl = param2;
|
||||
this.loaderContext = param3;
|
||||
if(this.bitmapLoader == null)
|
||||
{
|
||||
this.bitmapLoader = new Loader();
|
||||
this.bitmapLoader.contentLoaderInfo.addEventListener(Event.OPEN,this.onOpen);
|
||||
this.bitmapLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,this.onComplete);
|
||||
this.bitmapLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,this.onProgress);
|
||||
this.bitmapLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,this.onLoadError);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.close();
|
||||
}
|
||||
this.startLoading(STATE_LOADING_DIFFUSE_MAP,param1);
|
||||
}
|
||||
|
||||
private function onOpen(param1:Event) : void
|
||||
{
|
||||
dispatchEvent(new LoaderEvent(LoaderEvent.LOADING_START,LoadingStage.TEXTURE));
|
||||
}
|
||||
|
||||
private function onProgress(param1:Event) : void
|
||||
{
|
||||
dispatchEvent(param1);
|
||||
}
|
||||
|
||||
private function startLoading(param1:int, param2:String) : void
|
||||
{
|
||||
this.loaderState = param1;
|
||||
this.bitmapLoader.load(new URLRequest(param2),this.loaderContext);
|
||||
}
|
||||
|
||||
private function onComplete(param1:Event) : void
|
||||
{
|
||||
var loc2:BitmapData = null;
|
||||
var loc3:BitmapData = null;
|
||||
dispatchEvent(new LoaderEvent(LoaderEvent.LOADING_COMPLETE,LoadingStage.TEXTURE));
|
||||
switch(this.loaderState)
|
||||
{
|
||||
case STATE_LOADING_DIFFUSE_MAP:
|
||||
this._bitmapData = Bitmap(this.bitmapLoader.content).bitmapData;
|
||||
if(this.alphaTextureUrl != null)
|
||||
{
|
||||
this.startLoading(STATE_LOADING_ALPHA_MAP,this.alphaTextureUrl);
|
||||
break;
|
||||
}
|
||||
this.complete();
|
||||
break;
|
||||
case STATE_LOADING_ALPHA_MAP:
|
||||
loc2 = this._bitmapData;
|
||||
this._bitmapData = new BitmapData(this._bitmapData.width,this._bitmapData.height,true,0);
|
||||
this._bitmapData.copyPixels(loc2,loc2.rect,new Point());
|
||||
loc3 = Bitmap(this.bitmapLoader.content).bitmapData;
|
||||
if(this._bitmapData.width != loc3.width || this._bitmapData.height != loc3.height)
|
||||
{
|
||||
loc2.draw(loc3,new Matrix(this._bitmapData.width / loc3.width,0,0,this._bitmapData.height / loc3.height),null,BlendMode.NORMAL,null,true);
|
||||
loc3.dispose();
|
||||
loc3 = loc2;
|
||||
}
|
||||
this._bitmapData.copyChannel(loc3,loc3.rect,new Point(),BitmapDataChannel.RED,BitmapDataChannel.ALPHA);
|
||||
loc3.dispose();
|
||||
this.complete();
|
||||
}
|
||||
}
|
||||
|
||||
private function onLoadError(param1:IOErrorEvent) : void
|
||||
{
|
||||
this.loaderState = STATE_IDLE;
|
||||
dispatchEvent(param1);
|
||||
}
|
||||
|
||||
private function complete() : void
|
||||
{
|
||||
this.loaderState = STATE_IDLE;
|
||||
this.bitmapLoader.unload();
|
||||
dispatchEvent(new Event(Event.COMPLETE));
|
||||
}
|
||||
|
||||
public function get bitmapData() : BitmapData
|
||||
{
|
||||
return this._bitmapData;
|
||||
}
|
||||
|
||||
public function close() : void
|
||||
{
|
||||
if(this.loaderState != STATE_IDLE)
|
||||
{
|
||||
this.loaderState = STATE_IDLE;
|
||||
this.bitmapLoader.close();
|
||||
}
|
||||
this.unload();
|
||||
}
|
||||
|
||||
public function unload() : void
|
||||
{
|
||||
if(this.loaderState == STATE_IDLE)
|
||||
{
|
||||
if(this.bitmapLoader != null)
|
||||
{
|
||||
this.bitmapLoader.unload();
|
||||
}
|
||||
this.loaderContext = null;
|
||||
this._bitmapData = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
package alternativa.engine3d.loaders.events
|
||||
{
|
||||
import flash.events.Event;
|
||||
|
||||
public class LoaderEvent extends Event
|
||||
{
|
||||
public static const LOADING_START:String = "loadingStart";
|
||||
|
||||
public static const LOADING_COMPLETE:String = "loadingComplete";
|
||||
|
||||
private var _loadingStage:int;
|
||||
|
||||
public function LoaderEvent(param1:String, param2:int)
|
||||
{
|
||||
super(param1);
|
||||
this._loadingStage = param2;
|
||||
}
|
||||
|
||||
public function get loadingStage() : int
|
||||
{
|
||||
return this._loadingStage;
|
||||
}
|
||||
|
||||
override public function clone() : Event
|
||||
{
|
||||
return new LoaderEvent(type,this._loadingStage);
|
||||
}
|
||||
|
||||
override public function toString() : String
|
||||
{
|
||||
return "[LoaderEvent type=\"" + type + "\", loadingStage=" + this._loadingStage + "]";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
package alternativa.engine3d.loaders.events
|
||||
{
|
||||
import flash.events.Event;
|
||||
import flash.events.ProgressEvent;
|
||||
|
||||
public class LoaderProgressEvent extends ProgressEvent
|
||||
{
|
||||
public static const LOADING_PROGRESS:String = "loadingProgress";
|
||||
|
||||
private var _loadingStage:int;
|
||||
|
||||
private var _totalItems:int;
|
||||
|
||||
private var _currentItem:int;
|
||||
|
||||
public function LoaderProgressEvent(param1:String, param2:int, param3:int, param4:int, param5:uint = 0, param6:uint = 0)
|
||||
{
|
||||
super(param1,false,false,param5,param6);
|
||||
this._loadingStage = param2;
|
||||
this._totalItems = param3;
|
||||
this._currentItem = param4;
|
||||
}
|
||||
|
||||
public function get loadingStage() : int
|
||||
{
|
||||
return this._loadingStage;
|
||||
}
|
||||
|
||||
public function get totalItems() : int
|
||||
{
|
||||
return this._totalItems;
|
||||
}
|
||||
|
||||
public function get currentItem() : int
|
||||
{
|
||||
return this._currentItem;
|
||||
}
|
||||
|
||||
override public function clone() : Event
|
||||
{
|
||||
return new LoaderProgressEvent(type,this._loadingStage,this._totalItems,this._currentItem,bytesLoaded,bytesTotal);
|
||||
}
|
||||
|
||||
override public function toString() : String
|
||||
{
|
||||
return "[LoaderProgressEvent type=\"" + type + "\", loadingStage=" + this._loadingStage + ", totalItems=" + this._totalItems + ", currentItem=" + this._currentItem + ", bytesTotal=" + bytesTotal + ", bytesLoaded=" + bytesLoaded + "]";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
package alternativa.engine3d.materials
|
||||
{
|
||||
public final class DrawPoint
|
||||
{
|
||||
public var x:Number;
|
||||
|
||||
public var y:Number;
|
||||
|
||||
public var z:Number;
|
||||
|
||||
public var u:Number;
|
||||
|
||||
public var v:Number;
|
||||
|
||||
public function DrawPoint(param1:Number, param2:Number, param3:Number, param4:Number = 0, param5:Number = 0)
|
||||
{
|
||||
super();
|
||||
this.x = param1;
|
||||
this.y = param2;
|
||||
this.z = param3;
|
||||
this.u = param4;
|
||||
this.v = param5;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,131 +0,0 @@
|
||||
package alternativa.engine3d.materials
|
||||
{
|
||||
import alternativa.engine3d.*;
|
||||
import alternativa.engine3d.core.Camera3D;
|
||||
import alternativa.engine3d.display.Skin;
|
||||
import flash.display.Graphics;
|
||||
|
||||
use namespace alternativa3d;
|
||||
|
||||
public class FillMaterial extends SurfaceMaterial
|
||||
{
|
||||
alternativa3d var _color:uint;
|
||||
|
||||
alternativa3d var _wireThickness:Number;
|
||||
|
||||
alternativa3d var _wireColor:uint;
|
||||
|
||||
public function FillMaterial(param1:uint, param2:Number = 1, param3:String = "normal", param4:Number = -1, param5:uint = 0)
|
||||
{
|
||||
super(param2,param3);
|
||||
this.alternativa3d::_color = param1;
|
||||
this.alternativa3d::_wireThickness = param4;
|
||||
this.alternativa3d::_wireColor = param5;
|
||||
}
|
||||
|
||||
override alternativa3d function draw(param1:Camera3D, param2:Skin, param3:uint, param4:Array) : void
|
||||
{
|
||||
var loc5:uint = 0;
|
||||
var loc6:DrawPoint = null;
|
||||
var loc8:Number = NaN;
|
||||
param2.alpha = alternativa3d::_alpha;
|
||||
param2.blendMode = alternativa3d::_blendMode;
|
||||
var loc7:Graphics = param2.alternativa3d::gfx;
|
||||
if(param1.alternativa3d::_orthographic)
|
||||
{
|
||||
loc7.beginFill(this.alternativa3d::_color);
|
||||
if(this.alternativa3d::_wireThickness >= 0)
|
||||
{
|
||||
loc7.lineStyle(this.alternativa3d::_wireThickness,this.alternativa3d::_wireColor);
|
||||
}
|
||||
loc6 = param4[0];
|
||||
loc7.moveTo(loc6.x,loc6.y);
|
||||
loc5 = 1;
|
||||
while(loc5 < param3)
|
||||
{
|
||||
loc6 = param4[loc5];
|
||||
loc7.lineTo(loc6.x,loc6.y);
|
||||
loc5++;
|
||||
}
|
||||
if(this.alternativa3d::_wireThickness >= 0)
|
||||
{
|
||||
loc6 = param4[0];
|
||||
loc7.lineTo(loc6.x,loc6.y);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
loc7.beginFill(this.alternativa3d::_color);
|
||||
if(this.alternativa3d::_wireThickness >= 0)
|
||||
{
|
||||
loc7.lineStyle(this.alternativa3d::_wireThickness,this.alternativa3d::_wireColor);
|
||||
}
|
||||
loc6 = param4[0];
|
||||
loc8 = param1.alternativa3d::_focalLength / loc6.z;
|
||||
loc7.moveTo(loc6.x * loc8,loc6.y * loc8);
|
||||
loc5 = 1;
|
||||
while(loc5 < param3)
|
||||
{
|
||||
loc6 = param4[loc5];
|
||||
loc8 = param1.alternativa3d::_focalLength / loc6.z;
|
||||
loc7.lineTo(loc6.x * loc8,loc6.y * loc8);
|
||||
loc5++;
|
||||
}
|
||||
if(this.alternativa3d::_wireThickness >= 0)
|
||||
{
|
||||
loc6 = param4[0];
|
||||
loc8 = param1.alternativa3d::_focalLength / loc6.z;
|
||||
loc7.lineTo(loc6.x * loc8,loc6.y * loc8);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function get color() : uint
|
||||
{
|
||||
return this.alternativa3d::_color;
|
||||
}
|
||||
|
||||
public function set color(param1:uint) : void
|
||||
{
|
||||
if(this.alternativa3d::_color != param1)
|
||||
{
|
||||
this.alternativa3d::_color = param1;
|
||||
markToChange();
|
||||
}
|
||||
}
|
||||
|
||||
public function get wireThickness() : Number
|
||||
{
|
||||
return this.alternativa3d::_wireThickness;
|
||||
}
|
||||
|
||||
public function set wireThickness(param1:Number) : void
|
||||
{
|
||||
if(this.alternativa3d::_wireThickness != param1)
|
||||
{
|
||||
this.alternativa3d::_wireThickness = param1;
|
||||
markToChange();
|
||||
}
|
||||
}
|
||||
|
||||
public function get wireColor() : uint
|
||||
{
|
||||
return this.alternativa3d::_wireColor;
|
||||
}
|
||||
|
||||
public function set wireColor(param1:uint) : void
|
||||
{
|
||||
if(this.alternativa3d::_wireColor != param1)
|
||||
{
|
||||
this.alternativa3d::_wireColor = param1;
|
||||
markToChange();
|
||||
}
|
||||
}
|
||||
|
||||
override public function clone() : Material
|
||||
{
|
||||
return new FillMaterial(this.alternativa3d::_color,alternativa3d::_alpha,alternativa3d::_blendMode,this.alternativa3d::_wireThickness,this.alternativa3d::_wireColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
package alternativa.engine3d.materials
|
||||
{
|
||||
import alternativa.engine3d.alternativa3d;
|
||||
import alternativa.engine3d.display.Skin;
|
||||
|
||||
use namespace alternativa3d;
|
||||
|
||||
public class Material
|
||||
{
|
||||
alternativa3d var _alpha:Number;
|
||||
|
||||
alternativa3d var _blendMode:String;
|
||||
|
||||
public function Material(param1:Number, param2:String)
|
||||
{
|
||||
super();
|
||||
this.alternativa3d::_alpha = param1;
|
||||
this.alternativa3d::_blendMode = param2;
|
||||
}
|
||||
|
||||
public function get alpha() : Number
|
||||
{
|
||||
return this.alternativa3d::_alpha;
|
||||
}
|
||||
|
||||
public function set alpha(param1:Number) : void
|
||||
{
|
||||
if(this.alternativa3d::_alpha != param1)
|
||||
{
|
||||
this.alternativa3d::_alpha = param1;
|
||||
this.markToChange();
|
||||
}
|
||||
}
|
||||
|
||||
public function get blendMode() : String
|
||||
{
|
||||
return this.alternativa3d::_blendMode;
|
||||
}
|
||||
|
||||
public function set blendMode(param1:String) : void
|
||||
{
|
||||
if(this.alternativa3d::_blendMode != param1)
|
||||
{
|
||||
this.alternativa3d::_blendMode = param1;
|
||||
this.markToChange();
|
||||
}
|
||||
}
|
||||
|
||||
protected function markToChange() : void
|
||||
{
|
||||
}
|
||||
|
||||
alternativa3d function clear(param1:Skin) : void
|
||||
{
|
||||
param1.alternativa3d::gfx.clear();
|
||||
}
|
||||
|
||||
public function clone() : Material
|
||||
{
|
||||
return new Material(this.alternativa3d::_alpha,this.alternativa3d::_blendMode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,68 +0,0 @@
|
||||
package alternativa.engine3d.materials
|
||||
{
|
||||
import alternativa.engine3d.alternativa3d;
|
||||
import alternativa.engine3d.core.Camera3D;
|
||||
import alternativa.engine3d.core.Scene3D;
|
||||
import alternativa.engine3d.core.Sprite3D;
|
||||
import alternativa.engine3d.display.Skin;
|
||||
|
||||
use namespace alternativa3d;
|
||||
|
||||
public class SpriteMaterial extends Material
|
||||
{
|
||||
alternativa3d var _sprite:Sprite3D;
|
||||
|
||||
public function SpriteMaterial(param1:Number = 1, param2:String = "normal")
|
||||
{
|
||||
super(param1,param2);
|
||||
}
|
||||
|
||||
public function get sprite() : Sprite3D
|
||||
{
|
||||
return this.alternativa3d::_sprite;
|
||||
}
|
||||
|
||||
alternativa3d function addToScene(param1:Scene3D) : void
|
||||
{
|
||||
}
|
||||
|
||||
alternativa3d function removeFromScene(param1:Scene3D) : void
|
||||
{
|
||||
}
|
||||
|
||||
alternativa3d function addToSprite(param1:Sprite3D) : void
|
||||
{
|
||||
this.alternativa3d::_sprite = param1;
|
||||
}
|
||||
|
||||
alternativa3d function removeFromSprite(param1:Sprite3D) : void
|
||||
{
|
||||
this.alternativa3d::_sprite = null;
|
||||
}
|
||||
|
||||
alternativa3d function canDraw(param1:Camera3D) : Boolean
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
alternativa3d function draw(param1:Camera3D, param2:Skin) : void
|
||||
{
|
||||
param2.alpha = alternativa3d::_alpha;
|
||||
param2.blendMode = alternativa3d::_blendMode;
|
||||
}
|
||||
|
||||
override protected function markToChange() : void
|
||||
{
|
||||
if(this.alternativa3d::_sprite != null)
|
||||
{
|
||||
this.alternativa3d::_sprite.alternativa3d::addMaterialChangedOperationToScene();
|
||||
}
|
||||
}
|
||||
|
||||
override public function clone() : Material
|
||||
{
|
||||
return new SpriteMaterial(alternativa3d::_alpha,alternativa3d::_blendMode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,185 +0,0 @@
|
||||
package alternativa.engine3d.materials
|
||||
{
|
||||
import alternativa.engine3d.alternativa3d;
|
||||
import alternativa.engine3d.core.Camera3D;
|
||||
import alternativa.engine3d.display.Skin;
|
||||
import alternativa.types.Matrix3D;
|
||||
import alternativa.types.Texture;
|
||||
import alternativa.types.alternativatypes;
|
||||
import flash.geom.Matrix;
|
||||
import flash.geom.Rectangle;
|
||||
|
||||
use namespace alternativa3d;
|
||||
use namespace alternativatypes;
|
||||
|
||||
public class SpriteTextureMaterial extends SpriteMaterial
|
||||
{
|
||||
private static var drawRect:Rectangle = new Rectangle();
|
||||
|
||||
private static var textureMatrix:Matrix = new Matrix();
|
||||
|
||||
alternativa3d var _texture:Texture;
|
||||
|
||||
alternativa3d var _smooth:Boolean;
|
||||
|
||||
alternativa3d var _originX:Number;
|
||||
|
||||
alternativa3d var _originY:Number;
|
||||
|
||||
public function SpriteTextureMaterial(param1:Texture, param2:Number = 1, param3:Boolean = false, param4:String = "normal", param5:Number = 0.5, param6:Number = 0.5)
|
||||
{
|
||||
super(param2,param4);
|
||||
this.alternativa3d::_texture = param1;
|
||||
this.alternativa3d::_smooth = param3;
|
||||
this.alternativa3d::_originX = param5;
|
||||
this.alternativa3d::_originY = param6;
|
||||
}
|
||||
|
||||
override alternativa3d function canDraw(param1:Camera3D) : Boolean
|
||||
{
|
||||
var loc9:Number = NaN;
|
||||
var loc10:Number = NaN;
|
||||
var loc13:Number = NaN;
|
||||
if(this.alternativa3d::_texture == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var loc2:Matrix3D = param1.alternativa3d::cameraMatrix;
|
||||
var loc3:Number = Number(alternativa3d::_sprite.alternativa3d::globalCoords.x);
|
||||
var loc4:Number = Number(alternativa3d::_sprite.alternativa3d::globalCoords.y);
|
||||
var loc5:Number = Number(alternativa3d::_sprite.alternativa3d::globalCoords.z);
|
||||
var loc6:Number = loc2.a * loc3 + loc2.b * loc4 + loc2.c * loc5 + loc2.d;
|
||||
var loc7:Number = loc2.e * loc3 + loc2.f * loc4 + loc2.g * loc5 + loc2.h;
|
||||
var loc8:Number = loc2.i * loc3 + loc2.j * loc4 + loc2.k * loc5 + loc2.l;
|
||||
if(param1.alternativa3d::_orthographic)
|
||||
{
|
||||
if(param1.alternativa3d::_nearClipping && loc8 < param1.alternativa3d::_nearClippingDistance || param1.alternativa3d::_farClipping && loc8 > param1.alternativa3d::_farClippingDistance)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
loc9 = this.alternativa3d::_texture.alternativatypes::_width * param1.alternativa3d::_zoom * alternativa3d::_sprite.alternativa3d::_materialScale;
|
||||
loc10 = this.alternativa3d::_texture.alternativatypes::_height * param1.alternativa3d::_zoom * alternativa3d::_sprite.alternativa3d::_materialScale;
|
||||
loc3 = loc6 - loc9 * this.alternativa3d::_originX;
|
||||
loc4 = loc7 - loc10 * this.alternativa3d::_originY;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(loc8 <= 0 || param1.alternativa3d::_nearClipping && loc8 < param1.alternativa3d::_nearClippingDistance || param1.alternativa3d::_farClipping && loc8 > param1.alternativa3d::_farClippingDistance)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
loc13 = param1.alternativa3d::_focalLength / loc8;
|
||||
loc9 = this.alternativa3d::_texture.alternativatypes::_width * loc13 * alternativa3d::_sprite.alternativa3d::_materialScale;
|
||||
loc10 = this.alternativa3d::_texture.alternativatypes::_height * loc13 * alternativa3d::_sprite.alternativa3d::_materialScale;
|
||||
loc3 = loc6 * loc13 - loc9 * this.alternativa3d::_originX;
|
||||
loc4 = loc7 * loc13 - loc10 * this.alternativa3d::_originY;
|
||||
}
|
||||
var loc11:Number = param1.alternativa3d::_view.alternativa3d::_width * 0.5;
|
||||
var loc12:Number = param1.alternativa3d::_view.alternativa3d::_height * 0.5;
|
||||
if(param1.alternativa3d::_viewClipping && (loc3 >= loc11 || loc4 >= loc12 || loc3 + loc9 <= -loc11 || loc4 + loc10 <= -loc12))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
textureMatrix.a = loc9 / this.alternativa3d::_texture.alternativatypes::_width;
|
||||
textureMatrix.d = loc10 / this.alternativa3d::_texture.alternativatypes::_height;
|
||||
textureMatrix.tx = loc3;
|
||||
textureMatrix.ty = loc4;
|
||||
if(param1.alternativa3d::_viewClipping)
|
||||
{
|
||||
if(loc3 < -loc11)
|
||||
{
|
||||
loc9 -= -loc11 - loc3;
|
||||
loc3 = -loc11;
|
||||
}
|
||||
if(loc3 + loc9 > loc11)
|
||||
{
|
||||
loc9 = loc11 - loc3;
|
||||
}
|
||||
if(loc4 < -loc12)
|
||||
{
|
||||
loc10 -= -loc12 - loc4;
|
||||
loc4 = -loc12;
|
||||
}
|
||||
if(loc4 + loc10 > loc12)
|
||||
{
|
||||
loc10 = loc12 - loc4;
|
||||
}
|
||||
}
|
||||
drawRect.x = loc3;
|
||||
drawRect.y = loc4;
|
||||
drawRect.width = loc9;
|
||||
drawRect.height = loc10;
|
||||
return true;
|
||||
}
|
||||
|
||||
override alternativa3d function draw(param1:Camera3D, param2:Skin) : void
|
||||
{
|
||||
param2.alpha = alternativa3d::_alpha;
|
||||
param2.blendMode = alternativa3d::_blendMode;
|
||||
param2.alternativa3d::gfx.beginBitmapFill(this.alternativa3d::_texture.alternativatypes::_bitmapData,textureMatrix,false,this.alternativa3d::_smooth);
|
||||
param2.alternativa3d::gfx.drawRect(drawRect.x,drawRect.y,drawRect.width,drawRect.height);
|
||||
}
|
||||
|
||||
public function get texture() : Texture
|
||||
{
|
||||
return this.alternativa3d::_texture;
|
||||
}
|
||||
|
||||
public function set texture(param1:Texture) : void
|
||||
{
|
||||
if(this.alternativa3d::_texture != param1)
|
||||
{
|
||||
this.alternativa3d::_texture = param1;
|
||||
markToChange();
|
||||
}
|
||||
}
|
||||
|
||||
public function get smooth() : Boolean
|
||||
{
|
||||
return this.alternativa3d::_smooth;
|
||||
}
|
||||
|
||||
public function set smooth(param1:Boolean) : void
|
||||
{
|
||||
if(this.alternativa3d::_smooth != param1)
|
||||
{
|
||||
this.alternativa3d::_smooth = param1;
|
||||
markToChange();
|
||||
}
|
||||
}
|
||||
|
||||
public function get originX() : Number
|
||||
{
|
||||
return this.alternativa3d::_originX;
|
||||
}
|
||||
|
||||
public function set originX(param1:Number) : void
|
||||
{
|
||||
if(this.alternativa3d::_originX != param1)
|
||||
{
|
||||
this.alternativa3d::_originX = param1;
|
||||
markToChange();
|
||||
}
|
||||
}
|
||||
|
||||
public function get originY() : Number
|
||||
{
|
||||
return this.alternativa3d::_originY;
|
||||
}
|
||||
|
||||
public function set originY(param1:Number) : void
|
||||
{
|
||||
if(this.alternativa3d::_originY != param1)
|
||||
{
|
||||
this.alternativa3d::_originY = param1;
|
||||
markToChange();
|
||||
}
|
||||
}
|
||||
|
||||
override public function clone() : Material
|
||||
{
|
||||
return new SpriteTextureMaterial(this.alternativa3d::_texture,alternativa3d::_alpha,this.alternativa3d::_smooth,alternativa3d::_blendMode,this.alternativa3d::_originX,this.alternativa3d::_originY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,80 +0,0 @@
|
||||
package alternativa.engine3d.materials
|
||||
{
|
||||
import alternativa.engine3d.alternativa3d;
|
||||
import alternativa.engine3d.core.Camera3D;
|
||||
import alternativa.engine3d.core.Mesh;
|
||||
import alternativa.engine3d.core.PolyPrimitive;
|
||||
import alternativa.engine3d.core.Scene3D;
|
||||
import alternativa.engine3d.core.Surface;
|
||||
import alternativa.engine3d.display.Skin;
|
||||
|
||||
use namespace alternativa3d;
|
||||
|
||||
public class SurfaceMaterial extends Material
|
||||
{
|
||||
alternativa3d var _surface:Surface;
|
||||
|
||||
alternativa3d var useUV:Boolean = false;
|
||||
|
||||
public function SurfaceMaterial(param1:Number = 1, param2:String = "normal")
|
||||
{
|
||||
super(param1,param2);
|
||||
}
|
||||
|
||||
public function get surface() : Surface
|
||||
{
|
||||
return this.alternativa3d::_surface;
|
||||
}
|
||||
|
||||
alternativa3d function addToScene(param1:Scene3D) : void
|
||||
{
|
||||
}
|
||||
|
||||
alternativa3d function removeFromScene(param1:Scene3D) : void
|
||||
{
|
||||
}
|
||||
|
||||
alternativa3d function addToMesh(param1:Mesh) : void
|
||||
{
|
||||
}
|
||||
|
||||
alternativa3d function removeFromMesh(param1:Mesh) : void
|
||||
{
|
||||
}
|
||||
|
||||
alternativa3d function addToSurface(param1:Surface) : void
|
||||
{
|
||||
this.alternativa3d::_surface = param1;
|
||||
}
|
||||
|
||||
alternativa3d function removeFromSurface(param1:Surface) : void
|
||||
{
|
||||
this.alternativa3d::_surface = null;
|
||||
}
|
||||
|
||||
override protected function markToChange() : void
|
||||
{
|
||||
if(this.alternativa3d::_surface != null)
|
||||
{
|
||||
this.alternativa3d::_surface.alternativa3d::addMaterialChangedOperationToScene();
|
||||
}
|
||||
}
|
||||
|
||||
alternativa3d function canDraw(param1:PolyPrimitive) : Boolean
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
alternativa3d function draw(param1:Camera3D, param2:Skin, param3:uint, param4:Array) : void
|
||||
{
|
||||
param2.alpha = alternativa3d::_alpha;
|
||||
param2.blendMode = alternativa3d::_blendMode;
|
||||
}
|
||||
|
||||
override public function clone() : Material
|
||||
{
|
||||
return new SurfaceMaterial(alternativa3d::_alpha,alternativa3d::_blendMode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,526 +0,0 @@
|
||||
package alternativa.engine3d.materials
|
||||
{
|
||||
import alternativa.engine3d.*;
|
||||
import alternativa.engine3d.core.Camera3D;
|
||||
import alternativa.engine3d.core.Face;
|
||||
import alternativa.engine3d.core.PolyPrimitive;
|
||||
import alternativa.engine3d.display.Skin;
|
||||
import alternativa.types.*;
|
||||
import flash.display.BitmapData;
|
||||
import flash.display.Graphics;
|
||||
import flash.geom.Matrix;
|
||||
|
||||
use namespace alternativa3d;
|
||||
use namespace alternativatypes;
|
||||
|
||||
public class TextureMaterial extends SurfaceMaterial
|
||||
{
|
||||
private static var stubBitmapData:BitmapData;
|
||||
|
||||
private static var stubMatrix:Matrix;
|
||||
|
||||
private var gfx:Graphics;
|
||||
|
||||
private var textureMatrix:Matrix;
|
||||
|
||||
private var focalLength:Number;
|
||||
|
||||
private var distortion:Number;
|
||||
|
||||
alternativa3d var _texture:Texture;
|
||||
|
||||
alternativa3d var _repeat:Boolean;
|
||||
|
||||
alternativa3d var _smooth:Boolean;
|
||||
|
||||
alternativa3d var _precision:Number;
|
||||
|
||||
alternativa3d var _wireThickness:Number;
|
||||
|
||||
alternativa3d var _wireColor:uint;
|
||||
|
||||
public function TextureMaterial(param1:Texture, param2:Number = 1, param3:Boolean = true, param4:Boolean = false, param5:String = "normal", param6:Number = -1, param7:uint = 0, param8:Number = 10)
|
||||
{
|
||||
this.textureMatrix = new Matrix();
|
||||
super(param2,param5);
|
||||
this.alternativa3d::_texture = param1;
|
||||
this.alternativa3d::_repeat = param3;
|
||||
this.alternativa3d::_smooth = param4;
|
||||
this.alternativa3d::_wireThickness = param6;
|
||||
this.alternativa3d::_wireColor = param7;
|
||||
this.alternativa3d::_precision = param8;
|
||||
alternativa3d::useUV = true;
|
||||
}
|
||||
|
||||
override alternativa3d function canDraw(param1:PolyPrimitive) : Boolean
|
||||
{
|
||||
return this.alternativa3d::_texture != null;
|
||||
}
|
||||
|
||||
override alternativa3d function draw(param1:Camera3D, param2:Skin, param3:uint, param4:Array) : void
|
||||
{
|
||||
var loc5:uint = 0;
|
||||
var loc6:DrawPoint = null;
|
||||
var loc7:Number = NaN;
|
||||
var loc8:Face = null;
|
||||
var loc9:uint = 0;
|
||||
var loc10:uint = 0;
|
||||
var loc11:uint = 0;
|
||||
var loc12:uint = 0;
|
||||
var loc13:* = false;
|
||||
var loc14:DrawPoint = null;
|
||||
var loc15:DrawPoint = null;
|
||||
var loc16:DrawPoint = null;
|
||||
var loc17:Number = NaN;
|
||||
var loc18:Number = NaN;
|
||||
var loc19:Number = NaN;
|
||||
var loc20:Number = NaN;
|
||||
var loc21:Number = NaN;
|
||||
var loc22:Number = NaN;
|
||||
var loc23:Number = NaN;
|
||||
var loc24:Number = NaN;
|
||||
var loc25:Number = NaN;
|
||||
var loc26:Number = NaN;
|
||||
var loc27:Number = NaN;
|
||||
param2.alpha = alternativa3d::_alpha;
|
||||
param2.blendMode = alternativa3d::_blendMode;
|
||||
this.gfx = param2.alternativa3d::gfx;
|
||||
if(param2.alternativa3d::primitive.alternativa3d::face.alternativa3d::uvMatrixBase == null)
|
||||
{
|
||||
if(stubBitmapData == null)
|
||||
{
|
||||
stubBitmapData = new BitmapData(2,2,false,0);
|
||||
stubBitmapData.setPixel(0,0,16711935);
|
||||
stubBitmapData.setPixel(1,1,16711935);
|
||||
stubMatrix = new Matrix(10,0,0,10,0,0);
|
||||
}
|
||||
this.gfx.beginBitmapFill(stubBitmapData,stubMatrix);
|
||||
if(param1.alternativa3d::_orthographic)
|
||||
{
|
||||
if(this.alternativa3d::_wireThickness >= 0)
|
||||
{
|
||||
this.gfx.lineStyle(this.alternativa3d::_wireThickness,this.alternativa3d::_wireColor);
|
||||
}
|
||||
loc6 = param4[0];
|
||||
this.gfx.moveTo(loc6.x,loc6.y);
|
||||
loc5 = 1;
|
||||
while(loc5 < param3)
|
||||
{
|
||||
loc6 = param4[loc5];
|
||||
this.gfx.lineTo(loc6.x,loc6.y);
|
||||
loc5++;
|
||||
}
|
||||
if(this.alternativa3d::_wireThickness >= 0)
|
||||
{
|
||||
loc6 = param4[0];
|
||||
this.gfx.lineTo(loc6.x,loc6.y);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(this.alternativa3d::_wireThickness >= 0)
|
||||
{
|
||||
this.gfx.lineStyle(this.alternativa3d::_wireThickness,this.alternativa3d::_wireColor);
|
||||
}
|
||||
loc6 = param4[0];
|
||||
loc7 = param1.alternativa3d::_focalLength / loc6.z;
|
||||
this.gfx.moveTo(loc6.x * loc7,loc6.y * loc7);
|
||||
loc5 = 1;
|
||||
while(loc5 < param3)
|
||||
{
|
||||
loc6 = param4[loc5];
|
||||
loc7 = param1.alternativa3d::_focalLength / loc6.z;
|
||||
this.gfx.lineTo(loc6.x * loc7,loc6.y * loc7);
|
||||
loc5++;
|
||||
}
|
||||
if(this.alternativa3d::_wireThickness >= 0)
|
||||
{
|
||||
loc6 = param4[0];
|
||||
loc7 = param1.alternativa3d::_focalLength / loc6.z;
|
||||
this.gfx.lineTo(loc6.x * loc7,loc6.y * loc7);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
if(param1.alternativa3d::_orthographic)
|
||||
{
|
||||
loc8 = param2.alternativa3d::primitive.alternativa3d::face;
|
||||
if(!param1.alternativa3d::uvMatricesCalculated[loc8])
|
||||
{
|
||||
param1.alternativa3d::calculateUVMatrix(loc8,this.alternativa3d::_texture.alternativatypes::_width,this.alternativa3d::_texture.alternativatypes::_height);
|
||||
}
|
||||
this.gfx.beginBitmapFill(this.alternativa3d::_texture.alternativatypes::_bitmapData,loc8.alternativa3d::orthoTextureMatrix,this.alternativa3d::_repeat,this.alternativa3d::_smooth);
|
||||
if(this.alternativa3d::_wireThickness >= 0)
|
||||
{
|
||||
this.gfx.lineStyle(this.alternativa3d::_wireThickness,this.alternativa3d::_wireColor);
|
||||
}
|
||||
loc6 = param4[0];
|
||||
this.gfx.moveTo(loc6.x,loc6.y);
|
||||
loc5 = 1;
|
||||
while(loc5 < param3)
|
||||
{
|
||||
loc6 = param4[loc5];
|
||||
this.gfx.lineTo(loc6.x,loc6.y);
|
||||
loc5++;
|
||||
}
|
||||
if(this.alternativa3d::_wireThickness >= 0)
|
||||
{
|
||||
loc6 = param4[0];
|
||||
this.gfx.lineTo(loc6.x,loc6.y);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.focalLength = param1.alternativa3d::_focalLength;
|
||||
this.distortion = param1.alternativa3d::focalDistortion * this.alternativa3d::_precision;
|
||||
loc9 = 0;
|
||||
loc10 = param3 - 1;
|
||||
loc11 = 1;
|
||||
loc12 = loc10 > 0 ? loc10 - 1 : param3 - 1;
|
||||
loc13 = true;
|
||||
loc14 = param4[loc10];
|
||||
loc16 = param4[loc9];
|
||||
if(this.alternativa3d::_precision > 0)
|
||||
{
|
||||
loc17 = loc14.x / loc14.z;
|
||||
loc18 = loc14.y / loc14.z;
|
||||
loc21 = loc16.x / loc16.z;
|
||||
loc22 = loc16.y / loc16.z;
|
||||
loc23 = (loc16.x + loc14.x) / (loc16.z + loc14.z) - 0.5 * (loc21 + loc17);
|
||||
loc24 = (loc16.y + loc14.y) / (loc16.z + loc14.z) - 0.5 * (loc22 + loc18);
|
||||
loc27 = loc23 * loc23 + loc24 * loc24;
|
||||
while(loc9 != loc12)
|
||||
{
|
||||
if(loc13)
|
||||
{
|
||||
loc14 = param4[loc9];
|
||||
loc15 = param4[loc11];
|
||||
loc16 = param4[loc10];
|
||||
loc19 = loc17;
|
||||
loc20 = loc18;
|
||||
loc17 = loc21;
|
||||
loc18 = loc22;
|
||||
loc21 = loc19;
|
||||
loc22 = loc20;
|
||||
loc19 = loc15.x / loc15.z;
|
||||
loc20 = loc15.y / loc15.z;
|
||||
loc23 = (loc15.x + loc16.x) / (loc15.z + loc16.z) - 0.5 * (loc19 + loc21);
|
||||
loc24 = (loc15.y + loc16.y) / (loc15.z + loc16.z) - 0.5 * (loc20 + loc22);
|
||||
loc26 = loc23 * loc23 + loc24 * loc24;
|
||||
loc9 = loc11;
|
||||
loc11 = loc9 < param3 - 1 ? uint(loc9 + 1) : 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
loc14 = param4[loc12];
|
||||
loc15 = param4[loc10];
|
||||
loc16 = param4[loc9];
|
||||
loc17 = loc19;
|
||||
loc18 = loc20;
|
||||
loc19 = loc21;
|
||||
loc20 = loc22;
|
||||
loc21 = loc17;
|
||||
loc22 = loc18;
|
||||
loc17 = loc14.x / loc14.z;
|
||||
loc18 = loc14.y / loc14.z;
|
||||
loc23 = (loc16.x + loc14.x) / (loc16.z + loc14.z) - 0.5 * (loc21 + loc17);
|
||||
loc24 = (loc16.y + loc14.y) / (loc16.z + loc14.z) - 0.5 * (loc22 + loc18);
|
||||
loc27 = loc23 * loc23 + loc24 * loc24;
|
||||
loc10 = loc12;
|
||||
loc12 = loc10 > 0 ? loc10 - 1 : param3 - 1;
|
||||
}
|
||||
if((loc19 - loc17) * (loc22 - loc18) - (loc20 - loc18) * (loc21 - loc17) < -param1.alternativa3d::focalDistortion)
|
||||
{
|
||||
loc23 = (loc14.x + loc15.x) / (loc14.z + loc15.z) - 0.5 * (loc17 + loc19);
|
||||
loc24 = (loc14.y + loc15.y) / (loc14.z + loc15.z) - 0.5 * (loc18 + loc20);
|
||||
loc25 = loc23 * loc23 + loc24 * loc24;
|
||||
this.bisection(loc14.x,loc14.y,loc14.z,loc14.u,loc14.v,loc15.x,loc15.y,loc15.z,loc15.u,loc15.v,loc16.x,loc16.y,loc16.z,loc16.u,loc16.v,loc25,loc26,loc27);
|
||||
}
|
||||
loc13 = !loc13;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
loc17 = this.focalLength * loc14.x / loc14.z;
|
||||
loc18 = this.focalLength * loc14.y / loc14.z;
|
||||
loc21 = this.focalLength * loc16.x / loc16.z;
|
||||
loc22 = this.focalLength * loc16.y / loc16.z;
|
||||
while(loc9 != loc12)
|
||||
{
|
||||
if(loc13)
|
||||
{
|
||||
loc14 = param4[loc9];
|
||||
loc15 = param4[loc11];
|
||||
loc16 = param4[loc10];
|
||||
loc19 = loc17;
|
||||
loc20 = loc18;
|
||||
loc17 = loc21;
|
||||
loc18 = loc22;
|
||||
loc21 = loc19;
|
||||
loc22 = loc20;
|
||||
loc19 = this.focalLength * loc15.x / loc15.z;
|
||||
loc20 = this.focalLength * loc15.y / loc15.z;
|
||||
loc9 = loc11;
|
||||
loc11 = loc9 < param3 - 1 ? uint(loc9 + 1) : 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
loc14 = param4[loc12];
|
||||
loc15 = param4[loc10];
|
||||
loc16 = param4[loc9];
|
||||
loc17 = loc19;
|
||||
loc18 = loc20;
|
||||
loc19 = loc21;
|
||||
loc20 = loc22;
|
||||
loc21 = loc17;
|
||||
loc22 = loc18;
|
||||
loc17 = this.focalLength * loc14.x / loc14.z;
|
||||
loc18 = this.focalLength * loc14.y / loc14.z;
|
||||
loc10 = loc12;
|
||||
loc12 = loc10 > 0 ? loc10 - 1 : param3 - 1;
|
||||
}
|
||||
this.drawTriangle(loc17,loc18,loc14.u,loc14.v,loc19,loc20,loc15.u,loc15.v,loc21,loc22,loc16.u,loc16.v);
|
||||
loc13 = !loc13;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function bisection(param1:Number, param2:Number, param3:Number, param4:Number, param5:Number, param6:Number, param7:Number, param8:Number, param9:Number, param10:Number, param11:Number, param12:Number, param13:Number, param14:Number, param15:Number, param16:Number, param17:Number, param18:Number) : void
|
||||
{
|
||||
var loc19:Number = NaN;
|
||||
var loc20:Number = NaN;
|
||||
var loc21:Number = NaN;
|
||||
var loc22:Number = NaN;
|
||||
var loc23:Number = NaN;
|
||||
var loc24:Number = NaN;
|
||||
var loc25:Number = NaN;
|
||||
var loc26:Number = NaN;
|
||||
var loc27:Number = NaN;
|
||||
var loc28:Number = NaN;
|
||||
if(param16 > param17)
|
||||
{
|
||||
if(param16 > param18)
|
||||
{
|
||||
if(param16 > this.distortion)
|
||||
{
|
||||
loc19 = 0.5 * (param1 + param6);
|
||||
loc20 = 0.5 * (param2 + param7);
|
||||
loc21 = 0.5 * (param3 + param8);
|
||||
loc22 = 0.5 * (param4 + param9);
|
||||
loc23 = 0.5 * (param5 + param10);
|
||||
loc24 = (param1 + loc19) / (param3 + loc21) - 0.5 * (param1 / param3 + loc19 / loc21);
|
||||
loc25 = (param2 + loc20) / (param3 + loc21) - 0.5 * (param2 / param3 + loc20 / loc21);
|
||||
loc26 = loc24 * loc24 + loc25 * loc25;
|
||||
loc24 = (param6 + loc19) / (param8 + loc21) - 0.5 * (param6 / param8 + loc19 / loc21);
|
||||
loc25 = (param7 + loc20) / (param8 + loc21) - 0.5 * (param7 / param8 + loc20 / loc21);
|
||||
loc27 = loc24 * loc24 + loc25 * loc25;
|
||||
loc24 = (param11 + loc19) / (param13 + loc21) - 0.5 * (param11 / param13 + loc19 / loc21);
|
||||
loc25 = (param12 + loc20) / (param13 + loc21) - 0.5 * (param12 / param13 + loc20 / loc21);
|
||||
loc28 = loc24 * loc24 + loc25 * loc25;
|
||||
this.bisection(loc19,loc20,loc21,loc22,loc23,param11,param12,param13,param14,param15,param1,param2,param3,param4,param5,loc28,param18,loc26);
|
||||
this.bisection(loc19,loc20,loc21,loc22,loc23,param6,param7,param8,param9,param10,param11,param12,param13,param14,param15,loc27,param17,loc28);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if(param18 > this.distortion)
|
||||
{
|
||||
loc19 = 0.5 * (param11 + param1);
|
||||
loc20 = 0.5 * (param12 + param2);
|
||||
loc21 = 0.5 * (param13 + param3);
|
||||
loc22 = 0.5 * (param14 + param4);
|
||||
loc23 = 0.5 * (param15 + param5);
|
||||
loc24 = (param1 + loc19) / (param3 + loc21) - 0.5 * (param1 / param3 + loc19 / loc21);
|
||||
loc25 = (param2 + loc20) / (param3 + loc21) - 0.5 * (param2 / param3 + loc20 / loc21);
|
||||
loc26 = loc24 * loc24 + loc25 * loc25;
|
||||
loc24 = (param6 + loc19) / (param8 + loc21) - 0.5 * (param6 / param8 + loc19 / loc21);
|
||||
loc25 = (param7 + loc20) / (param8 + loc21) - 0.5 * (param7 / param8 + loc20 / loc21);
|
||||
loc27 = loc24 * loc24 + loc25 * loc25;
|
||||
loc24 = (param11 + loc19) / (param13 + loc21) - 0.5 * (param11 / param13 + loc19 / loc21);
|
||||
loc25 = (param12 + loc20) / (param13 + loc21) - 0.5 * (param12 / param13 + loc20 / loc21);
|
||||
loc28 = loc24 * loc24 + loc25 * loc25;
|
||||
this.bisection(loc19,loc20,loc21,loc22,loc23,param6,param7,param8,param9,param10,param11,param12,param13,param14,param15,loc27,param17,loc28);
|
||||
this.bisection(loc19,loc20,loc21,loc22,loc23,param1,param2,param3,param4,param5,param6,param7,param8,param9,param10,loc26,param16,loc27);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if(param17 > param18)
|
||||
{
|
||||
if(param17 > this.distortion)
|
||||
{
|
||||
loc19 = 0.5 * (param6 + param11);
|
||||
loc20 = 0.5 * (param7 + param12);
|
||||
loc21 = 0.5 * (param8 + param13);
|
||||
loc22 = 0.5 * (param9 + param14);
|
||||
loc23 = 0.5 * (param10 + param15);
|
||||
loc24 = (param1 + loc19) / (param3 + loc21) - 0.5 * (param1 / param3 + loc19 / loc21);
|
||||
loc25 = (param2 + loc20) / (param3 + loc21) - 0.5 * (param2 / param3 + loc20 / loc21);
|
||||
loc26 = loc24 * loc24 + loc25 * loc25;
|
||||
loc24 = (param6 + loc19) / (param8 + loc21) - 0.5 * (param6 / param8 + loc19 / loc21);
|
||||
loc25 = (param7 + loc20) / (param8 + loc21) - 0.5 * (param7 / param8 + loc20 / loc21);
|
||||
loc27 = loc24 * loc24 + loc25 * loc25;
|
||||
loc24 = (param11 + loc19) / (param13 + loc21) - 0.5 * (param11 / param13 + loc19 / loc21);
|
||||
loc25 = (param12 + loc20) / (param13 + loc21) - 0.5 * (param12 / param13 + loc20 / loc21);
|
||||
loc28 = loc24 * loc24 + loc25 * loc25;
|
||||
this.bisection(loc19,loc20,loc21,loc22,loc23,param1,param2,param3,param4,param5,param6,param7,param8,param9,param10,loc26,param16,loc27);
|
||||
this.bisection(loc19,loc20,loc21,loc22,loc23,param11,param12,param13,param14,param15,param1,param2,param3,param4,param5,loc28,param18,loc26);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if(param18 > this.distortion)
|
||||
{
|
||||
loc19 = 0.5 * (param11 + param1);
|
||||
loc20 = 0.5 * (param12 + param2);
|
||||
loc21 = 0.5 * (param13 + param3);
|
||||
loc22 = 0.5 * (param14 + param4);
|
||||
loc23 = 0.5 * (param15 + param5);
|
||||
loc24 = (param1 + loc19) / (param3 + loc21) - 0.5 * (param1 / param3 + loc19 / loc21);
|
||||
loc25 = (param2 + loc20) / (param3 + loc21) - 0.5 * (param2 / param3 + loc20 / loc21);
|
||||
loc26 = loc24 * loc24 + loc25 * loc25;
|
||||
loc24 = (param6 + loc19) / (param8 + loc21) - 0.5 * (param6 / param8 + loc19 / loc21);
|
||||
loc25 = (param7 + loc20) / (param8 + loc21) - 0.5 * (param7 / param8 + loc20 / loc21);
|
||||
loc27 = loc24 * loc24 + loc25 * loc25;
|
||||
loc24 = (param11 + loc19) / (param13 + loc21) - 0.5 * (param11 / param13 + loc19 / loc21);
|
||||
loc25 = (param12 + loc20) / (param13 + loc21) - 0.5 * (param12 / param13 + loc20 / loc21);
|
||||
loc28 = loc24 * loc24 + loc25 * loc25;
|
||||
this.bisection(loc19,loc20,loc21,loc22,loc23,param6,param7,param8,param9,param10,param11,param12,param13,param14,param15,loc27,param17,loc28);
|
||||
this.bisection(loc19,loc20,loc21,loc22,loc23,param1,param2,param3,param4,param5,param6,param7,param8,param9,param10,loc26,param16,loc27);
|
||||
return;
|
||||
}
|
||||
var loc29:Number = this.focalLength / param3;
|
||||
var loc30:Number = this.focalLength / param8;
|
||||
var loc31:Number = this.focalLength / param13;
|
||||
this.drawTriangle(param1 * loc29,param2 * loc29,param4,param5,param6 * loc30,param7 * loc30,param9,param10,param11 * loc31,param12 * loc31,param14,param15);
|
||||
}
|
||||
|
||||
private function drawTriangle(param1:Number, param2:Number, param3:Number, param4:Number, param5:Number, param6:Number, param7:Number, param8:Number, param9:Number, param10:Number, param11:Number, param12:Number) : void
|
||||
{
|
||||
var loc13:Number = param5 - param1;
|
||||
var loc14:Number = param6 - param2;
|
||||
var loc15:Number = param9 - param1;
|
||||
var loc16:Number = param10 - param2;
|
||||
var loc17:Number = param7 - param3;
|
||||
var loc18:Number = param8 - param4;
|
||||
var loc19:Number = param11 - param3;
|
||||
var loc20:Number = param12 - param4;
|
||||
var loc21:Number = loc17 * loc20 - loc18 * loc19;
|
||||
var loc22:Number = this.alternativa3d::_texture.alternativatypes::_width;
|
||||
var loc23:Number = this.alternativa3d::_texture.alternativatypes::_height;
|
||||
this.textureMatrix.a = (loc20 * loc13 - loc18 * loc15) / loc21;
|
||||
this.textureMatrix.b = (loc20 * loc14 - loc18 * loc16) / loc21;
|
||||
this.textureMatrix.c = (loc19 * loc13 - loc17 * loc15) / loc21;
|
||||
this.textureMatrix.d = (loc19 * loc14 - loc17 * loc16) / loc21;
|
||||
this.textureMatrix.tx = (param4 - 1) * this.textureMatrix.c - param3 * this.textureMatrix.a + param1;
|
||||
this.textureMatrix.ty = (param4 - 1) * this.textureMatrix.d - param3 * this.textureMatrix.b + param2;
|
||||
this.textureMatrix.a /= loc22;
|
||||
this.textureMatrix.b /= loc22;
|
||||
this.textureMatrix.c /= loc23;
|
||||
this.textureMatrix.d /= loc23;
|
||||
this.gfx.beginBitmapFill(this.alternativa3d::_texture.alternativatypes::_bitmapData,this.textureMatrix,this.alternativa3d::_repeat,this.alternativa3d::_smooth);
|
||||
if(this.alternativa3d::_wireThickness >= 0)
|
||||
{
|
||||
this.gfx.lineStyle(this.alternativa3d::_wireThickness,this.alternativa3d::_wireColor);
|
||||
}
|
||||
this.gfx.moveTo(param1,param2);
|
||||
this.gfx.lineTo(param5,param6);
|
||||
this.gfx.lineTo(param9,param10);
|
||||
if(this.alternativa3d::_wireThickness >= 0)
|
||||
{
|
||||
this.gfx.lineTo(param1,param2);
|
||||
}
|
||||
}
|
||||
|
||||
public function get texture() : Texture
|
||||
{
|
||||
return this.alternativa3d::_texture;
|
||||
}
|
||||
|
||||
public function set texture(param1:Texture) : void
|
||||
{
|
||||
if(this.alternativa3d::_texture != param1)
|
||||
{
|
||||
this.alternativa3d::_texture = param1;
|
||||
markToChange();
|
||||
}
|
||||
}
|
||||
|
||||
public function get repeat() : Boolean
|
||||
{
|
||||
return this.alternativa3d::_repeat;
|
||||
}
|
||||
|
||||
public function set repeat(param1:Boolean) : void
|
||||
{
|
||||
if(this.alternativa3d::_repeat != param1)
|
||||
{
|
||||
this.alternativa3d::_repeat = param1;
|
||||
markToChange();
|
||||
}
|
||||
}
|
||||
|
||||
public function get smooth() : Boolean
|
||||
{
|
||||
return this.alternativa3d::_smooth;
|
||||
}
|
||||
|
||||
public function set smooth(param1:Boolean) : void
|
||||
{
|
||||
if(this.alternativa3d::_smooth != param1)
|
||||
{
|
||||
this.alternativa3d::_smooth = param1;
|
||||
if(alternativa3d::_surface != null)
|
||||
{
|
||||
alternativa3d::_surface.alternativa3d::addMaterialChangedOperationToScene();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function get wireThickness() : Number
|
||||
{
|
||||
return this.alternativa3d::_wireThickness;
|
||||
}
|
||||
|
||||
public function set wireThickness(param1:Number) : void
|
||||
{
|
||||
if(this.alternativa3d::_wireThickness != param1)
|
||||
{
|
||||
this.alternativa3d::_wireThickness = param1;
|
||||
markToChange();
|
||||
}
|
||||
}
|
||||
|
||||
public function get wireColor() : uint
|
||||
{
|
||||
return this.alternativa3d::_wireColor;
|
||||
}
|
||||
|
||||
public function set wireColor(param1:uint) : void
|
||||
{
|
||||
if(this.alternativa3d::_wireColor != param1)
|
||||
{
|
||||
this.alternativa3d::_wireColor = param1;
|
||||
markToChange();
|
||||
}
|
||||
}
|
||||
|
||||
public function get precision() : Number
|
||||
{
|
||||
return this.alternativa3d::_precision;
|
||||
}
|
||||
|
||||
public function set precision(param1:Number) : void
|
||||
{
|
||||
if(this.alternativa3d::_precision != param1)
|
||||
{
|
||||
this.alternativa3d::_precision = param1;
|
||||
markToChange();
|
||||
}
|
||||
}
|
||||
|
||||
override public function clone() : Material
|
||||
{
|
||||
return new TextureMaterial(this.alternativa3d::_texture,alternativa3d::_alpha,this.alternativa3d::_repeat,this.alternativa3d::_smooth,alternativa3d::_blendMode,this.alternativa3d::_wireThickness,this.alternativa3d::_wireColor,this.alternativa3d::_precision);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
package alternativa.engine3d.materials
|
||||
{
|
||||
public class TextureMaterialPrecision
|
||||
{
|
||||
public static const NONE:Number = -1;
|
||||
|
||||
public static const VERY_LOW:Number = 50;
|
||||
|
||||
public static const LOW:Number = 25;
|
||||
|
||||
public static const MEDIUM:Number = 10;
|
||||
|
||||
public static const HIGH:Number = 6;
|
||||
|
||||
public static const VERY_HIGH:Number = 3;
|
||||
|
||||
public static const BEST:Number = 1;
|
||||
|
||||
public function TextureMaterialPrecision()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,101 +0,0 @@
|
||||
package alternativa.engine3d.materials
|
||||
{
|
||||
import alternativa.engine3d.*;
|
||||
import alternativa.engine3d.core.Camera3D;
|
||||
import alternativa.engine3d.core.PolyPrimitive;
|
||||
import alternativa.engine3d.display.Skin;
|
||||
import flash.display.Graphics;
|
||||
|
||||
use namespace alternativa3d;
|
||||
|
||||
public class WireMaterial extends SurfaceMaterial
|
||||
{
|
||||
alternativa3d var _color:uint;
|
||||
|
||||
alternativa3d var _thickness:Number;
|
||||
|
||||
public function WireMaterial(param1:Number = 0, param2:uint = 0, param3:Number = 1, param4:String = "normal")
|
||||
{
|
||||
super(param3,param4);
|
||||
this.alternativa3d::_color = param2;
|
||||
this.alternativa3d::_thickness = param1;
|
||||
}
|
||||
|
||||
override alternativa3d function canDraw(param1:PolyPrimitive) : Boolean
|
||||
{
|
||||
return this.alternativa3d::_thickness >= 0;
|
||||
}
|
||||
|
||||
override alternativa3d function draw(param1:Camera3D, param2:Skin, param3:uint, param4:Array) : void
|
||||
{
|
||||
var loc5:uint = 0;
|
||||
var loc6:DrawPoint = null;
|
||||
var loc8:Number = NaN;
|
||||
param2.alpha = alternativa3d::_alpha;
|
||||
param2.blendMode = alternativa3d::_blendMode;
|
||||
var loc7:Graphics = param2.alternativa3d::gfx;
|
||||
if(param1.alternativa3d::_orthographic)
|
||||
{
|
||||
loc7.lineStyle(this.alternativa3d::_thickness,this.alternativa3d::_color);
|
||||
loc6 = param4[param3 - 1];
|
||||
loc7.moveTo(loc6.x,loc6.y);
|
||||
loc5 = 0;
|
||||
while(loc5 < param3)
|
||||
{
|
||||
loc6 = param4[loc5];
|
||||
loc7.lineTo(loc6.x,loc6.y);
|
||||
loc5++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
loc7.lineStyle(this.alternativa3d::_thickness,this.alternativa3d::_color);
|
||||
loc6 = param4[param3 - 1];
|
||||
loc8 = param1.alternativa3d::_focalLength / loc6.z;
|
||||
loc7.moveTo(loc6.x * loc8,loc6.y * loc8);
|
||||
loc5 = 0;
|
||||
while(loc5 < param3)
|
||||
{
|
||||
loc6 = param4[loc5];
|
||||
loc8 = param1.alternativa3d::_focalLength / loc6.z;
|
||||
loc7.lineTo(loc6.x * loc8,loc6.y * loc8);
|
||||
loc5++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function get color() : uint
|
||||
{
|
||||
return this.alternativa3d::_color;
|
||||
}
|
||||
|
||||
public function set color(param1:uint) : void
|
||||
{
|
||||
if(this.alternativa3d::_color != param1)
|
||||
{
|
||||
this.alternativa3d::_color = param1;
|
||||
markToChange();
|
||||
}
|
||||
}
|
||||
|
||||
public function get thickness() : Number
|
||||
{
|
||||
return this.alternativa3d::_thickness;
|
||||
}
|
||||
|
||||
public function set thickness(param1:Number) : void
|
||||
{
|
||||
if(this.alternativa3d::_thickness != param1)
|
||||
{
|
||||
this.alternativa3d::_thickness = param1;
|
||||
markToChange();
|
||||
}
|
||||
}
|
||||
|
||||
override public function clone() : Material
|
||||
{
|
||||
return new WireMaterial(this.alternativa3d::_thickness,this.alternativa3d::_color,alternativa3d::_alpha,alternativa3d::_blendMode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
package alternativa.engine3d.physics
|
||||
{
|
||||
import alternativa.engine3d.core.Face;
|
||||
import alternativa.types.Point3D;
|
||||
|
||||
public class Collision
|
||||
{
|
||||
public var face:Face;
|
||||
|
||||
public var normal:Point3D;
|
||||
|
||||
public var offset:Number;
|
||||
|
||||
public var point:Point3D;
|
||||
|
||||
public function Collision()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
package alternativa.engine3d.physics
|
||||
{
|
||||
import alternativa.engine3d.alternativa3d;
|
||||
import alternativa.engine3d.core.BSPNode;
|
||||
|
||||
use namespace alternativa3d;
|
||||
|
||||
public class CollisionPlane
|
||||
{
|
||||
private static var collector:Array = new Array();
|
||||
|
||||
public var node:BSPNode;
|
||||
|
||||
public var infront:Boolean;
|
||||
|
||||
public var sourceOffset:Number;
|
||||
|
||||
public var destinationOffset:Number;
|
||||
|
||||
public function CollisionPlane()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
alternativa3d static function createCollisionPlane(param1:BSPNode, param2:Boolean, param3:Number, param4:Number) : CollisionPlane
|
||||
{
|
||||
var loc5:CollisionPlane = collector.pop();
|
||||
if(loc5 == null)
|
||||
{
|
||||
loc5 = new CollisionPlane();
|
||||
}
|
||||
loc5.node = param1;
|
||||
loc5.infront = param2;
|
||||
loc5.sourceOffset = param3;
|
||||
loc5.destinationOffset = param4;
|
||||
return loc5;
|
||||
}
|
||||
|
||||
alternativa3d static function destroyCollisionPlane(param1:CollisionPlane) : void
|
||||
{
|
||||
param1.node = null;
|
||||
collector.push(param1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
package alternativa.engine3d.physics
|
||||
{
|
||||
public class CollisionSetMode
|
||||
{
|
||||
public static const EXCLUDE:int = 1;
|
||||
|
||||
public static const INCLUDE:int = 2;
|
||||
|
||||
public function CollisionSetMode()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,948 +0,0 @@
|
||||
package alternativa.engine3d.physics
|
||||
{
|
||||
import alternativa.engine3d.*;
|
||||
import alternativa.engine3d.core.BSPNode;
|
||||
import alternativa.engine3d.core.PolyPrimitive;
|
||||
import alternativa.engine3d.core.Scene3D;
|
||||
import alternativa.types.Point3D;
|
||||
import alternativa.types.Set;
|
||||
import alternativa.utils.ObjectUtils;
|
||||
|
||||
use namespace alternativa3d;
|
||||
|
||||
public class EllipsoidCollider
|
||||
{
|
||||
private static const MAX_COLLISIONS:uint = 50;
|
||||
|
||||
private var _radius:Number = 100;
|
||||
|
||||
private var _radius2:Number;
|
||||
|
||||
private var _radiusX:Number;
|
||||
|
||||
private var _radiusY:Number;
|
||||
|
||||
private var _radiusZ:Number;
|
||||
|
||||
private var _radiusX2:Number;
|
||||
|
||||
private var _radiusY2:Number;
|
||||
|
||||
private var _radiusZ2:Number;
|
||||
|
||||
private var _scaleX:Number = 1;
|
||||
|
||||
private var _scaleY:Number = 1;
|
||||
|
||||
private var _scaleZ:Number = 1;
|
||||
|
||||
private var _scaleX2:Number = 1;
|
||||
|
||||
private var _scaleY2:Number = 1;
|
||||
|
||||
private var _scaleZ2:Number = 1;
|
||||
|
||||
private var collisionSource:Point3D;
|
||||
|
||||
private var currentDisplacement:Point3D;
|
||||
|
||||
private var collisionDestination:Point3D;
|
||||
|
||||
private var collisionPlanes:Array;
|
||||
|
||||
private var collisionPrimitive:PolyPrimitive;
|
||||
|
||||
private var collisionPrimitiveNearest:PolyPrimitive;
|
||||
|
||||
private var collisionPlanePoint:Point3D;
|
||||
|
||||
private var collisionPrimitiveNearestLengthSqr:Number;
|
||||
|
||||
private var collisionPrimitivePoint:Point3D;
|
||||
|
||||
private var collisionNormal:Point3D;
|
||||
|
||||
private var collisionPoint:Point3D;
|
||||
|
||||
private var collisionOffset:Number;
|
||||
|
||||
private var currentCoords:Point3D;
|
||||
|
||||
private var collision:Collision;
|
||||
|
||||
private var collisionRadius:Number;
|
||||
|
||||
private var radiusVector:Point3D;
|
||||
|
||||
private var p1:Point3D;
|
||||
|
||||
private var p2:Point3D;
|
||||
|
||||
private var localCollisionPlanePoint:Point3D;
|
||||
|
||||
private var useSimpleAlgorithm:Boolean = true;
|
||||
|
||||
public var scene:Scene3D;
|
||||
|
||||
public var offsetThreshold:Number = 0.0001;
|
||||
|
||||
public var collisionSet:Set;
|
||||
|
||||
private var _collisionSetMode:int = 1;
|
||||
|
||||
public function EllipsoidCollider(param1:Scene3D = null, param2:Number = 100, param3:Number = 100, param4:Number = 100)
|
||||
{
|
||||
this._radius2 = this._radius * this._radius;
|
||||
this._radiusX = this._radius;
|
||||
this._radiusY = this._radius;
|
||||
this._radiusZ = this._radius;
|
||||
this._radiusX2 = this._radiusX * this._radiusX;
|
||||
this._radiusY2 = this._radiusY * this._radiusY;
|
||||
this._radiusZ2 = this._radiusZ * this._radiusZ;
|
||||
this.currentDisplacement = new Point3D();
|
||||
this.collisionDestination = new Point3D();
|
||||
this.collisionPlanes = new Array();
|
||||
this.collisionPlanePoint = new Point3D();
|
||||
this.collisionPrimitivePoint = new Point3D();
|
||||
this.collisionNormal = new Point3D();
|
||||
this.collisionPoint = new Point3D();
|
||||
this.currentCoords = new Point3D();
|
||||
this.collision = new Collision();
|
||||
this.radiusVector = new Point3D();
|
||||
this.p1 = new Point3D();
|
||||
this.p2 = new Point3D();
|
||||
this.localCollisionPlanePoint = new Point3D();
|
||||
super();
|
||||
this.scene = param1;
|
||||
this.radiusX = param2;
|
||||
this.radiusY = param3;
|
||||
this.radiusZ = param4;
|
||||
}
|
||||
|
||||
public function get collisionSetMode() : int
|
||||
{
|
||||
return this._collisionSetMode;
|
||||
}
|
||||
|
||||
public function set collisionSetMode(param1:int) : void
|
||||
{
|
||||
if(param1 != CollisionSetMode.EXCLUDE && param1 != CollisionSetMode.INCLUDE)
|
||||
{
|
||||
throw ArgumentError(ObjectUtils.getClassName(this) + ".collisionSetMode invalid value");
|
||||
}
|
||||
this._collisionSetMode = param1;
|
||||
}
|
||||
|
||||
public function get radiusX() : Number
|
||||
{
|
||||
return this._radiusX;
|
||||
}
|
||||
|
||||
public function set radiusX(param1:Number) : void
|
||||
{
|
||||
this._radiusX = param1 >= 0 ? param1 : -param1;
|
||||
this._radiusX2 = this._radiusX * this._radiusX;
|
||||
this.calculateScales();
|
||||
}
|
||||
|
||||
public function get radiusY() : Number
|
||||
{
|
||||
return this._radiusY;
|
||||
}
|
||||
|
||||
public function set radiusY(param1:Number) : void
|
||||
{
|
||||
this._radiusY = param1 >= 0 ? param1 : -param1;
|
||||
this._radiusY2 = this._radiusY * this._radiusY;
|
||||
this.calculateScales();
|
||||
}
|
||||
|
||||
public function get radiusZ() : Number
|
||||
{
|
||||
return this._radiusZ;
|
||||
}
|
||||
|
||||
public function set radiusZ(param1:Number) : void
|
||||
{
|
||||
this._radiusZ = param1 >= 0 ? param1 : -param1;
|
||||
this._radiusZ2 = this._radiusZ * this._radiusZ;
|
||||
this.calculateScales();
|
||||
}
|
||||
|
||||
private function calculateScales() : void
|
||||
{
|
||||
this._radius = this._radiusX;
|
||||
if(this._radiusY > this._radius)
|
||||
{
|
||||
this._radius = this._radiusY;
|
||||
}
|
||||
if(this._radiusZ > this._radius)
|
||||
{
|
||||
this._radius = this._radiusZ;
|
||||
}
|
||||
this._radius2 = this._radius * this._radius;
|
||||
this._scaleX = this._radiusX / this._radius;
|
||||
this._scaleY = this._radiusY / this._radius;
|
||||
this._scaleZ = this._radiusZ / this._radius;
|
||||
this._scaleX2 = this._scaleX * this._scaleX;
|
||||
this._scaleY2 = this._scaleY * this._scaleY;
|
||||
this._scaleZ2 = this._scaleZ * this._scaleZ;
|
||||
this.useSimpleAlgorithm = this._radiusX == this._radiusY && this._radiusX == this._radiusZ;
|
||||
}
|
||||
|
||||
public function calculateDestination(param1:Point3D, param2:Point3D, param3:Point3D) : void
|
||||
{
|
||||
if(param2.x < this.offsetThreshold && param2.x > -this.offsetThreshold && param2.y < this.offsetThreshold && param2.y > -this.offsetThreshold && param2.z < this.offsetThreshold && param2.z > -this.offsetThreshold)
|
||||
{
|
||||
param3.x = param1.x;
|
||||
param3.y = param1.y;
|
||||
param3.z = param1.z;
|
||||
return;
|
||||
}
|
||||
this.currentCoords.x = param1.x;
|
||||
this.currentCoords.y = param1.y;
|
||||
this.currentCoords.z = param1.z;
|
||||
this.currentDisplacement.x = param2.x;
|
||||
this.currentDisplacement.y = param2.y;
|
||||
this.currentDisplacement.z = param2.z;
|
||||
param3.x = param1.x + this.currentDisplacement.x;
|
||||
param3.y = param1.y + this.currentDisplacement.y;
|
||||
param3.z = param1.z + this.currentDisplacement.z;
|
||||
if(this.useSimpleAlgorithm)
|
||||
{
|
||||
this.calculateDestinationS(param1,param3);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.calculateDestinationE(param1,param3);
|
||||
}
|
||||
}
|
||||
|
||||
private function calculateDestinationS(param1:Point3D, param2:Point3D) : void
|
||||
{
|
||||
var loc4:Boolean = false;
|
||||
var loc5:Number = NaN;
|
||||
var loc3:uint = 0;
|
||||
do
|
||||
{
|
||||
loc4 = this.getCollision(this.currentCoords,this.currentDisplacement,this.collision);
|
||||
if(loc4)
|
||||
{
|
||||
loc5 = this._radius + this.offsetThreshold + this.collision.offset - param2.x * this.collision.normal.x - param2.y * this.collision.normal.y - param2.z * this.collision.normal.z;
|
||||
param2.x += this.collision.normal.x * loc5;
|
||||
param2.y += this.collision.normal.y * loc5;
|
||||
param2.z += this.collision.normal.z * loc5;
|
||||
this.currentCoords.x = this.collision.point.x + this.collision.normal.x * (this._radius + this.offsetThreshold);
|
||||
this.currentCoords.y = this.collision.point.y + this.collision.normal.y * (this._radius + this.offsetThreshold);
|
||||
this.currentCoords.z = this.collision.point.z + this.collision.normal.z * (this._radius + this.offsetThreshold);
|
||||
this.currentDisplacement.x = param2.x - this.currentCoords.x;
|
||||
this.currentDisplacement.y = param2.y - this.currentCoords.y;
|
||||
this.currentDisplacement.z = param2.z - this.currentCoords.z;
|
||||
if(this.currentDisplacement.x < this.offsetThreshold && this.currentDisplacement.x > -this.offsetThreshold && this.currentDisplacement.y < this.offsetThreshold && this.currentDisplacement.y > -this.offsetThreshold && this.currentDisplacement.z < this.offsetThreshold && this.currentDisplacement.z > -this.offsetThreshold)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
while(loc4 && ++loc3 < MAX_COLLISIONS);
|
||||
|
||||
if(loc3 == MAX_COLLISIONS)
|
||||
{
|
||||
param2.x = param1.x;
|
||||
param2.y = param1.y;
|
||||
param2.z = param1.z;
|
||||
}
|
||||
}
|
||||
|
||||
private function calculateDestinationE(param1:Point3D, param2:Point3D) : void
|
||||
{
|
||||
var loc4:Boolean = false;
|
||||
var loc5:Number = NaN;
|
||||
var loc3:uint = 0;
|
||||
do
|
||||
{
|
||||
loc4 = this.getCollision(this.currentCoords,this.currentDisplacement,this.collision);
|
||||
if(loc4)
|
||||
{
|
||||
loc5 = this.collisionRadius + this.offsetThreshold + this.collision.offset - param2.x * this.collision.normal.x - param2.y * this.collision.normal.y - param2.z * this.collision.normal.z;
|
||||
param2.x += this.collision.normal.x * loc5;
|
||||
param2.y += this.collision.normal.y * loc5;
|
||||
param2.z += this.collision.normal.z * loc5;
|
||||
this.collisionRadius = (this.collisionRadius + this.offsetThreshold) / this.collisionRadius;
|
||||
this.currentCoords.x = this.collision.point.x - this.collisionRadius * this.radiusVector.x;
|
||||
this.currentCoords.y = this.collision.point.y - this.collisionRadius * this.radiusVector.y;
|
||||
this.currentCoords.z = this.collision.point.z - this.collisionRadius * this.radiusVector.z;
|
||||
this.currentDisplacement.x = param2.x - this.currentCoords.x;
|
||||
this.currentDisplacement.y = param2.y - this.currentCoords.y;
|
||||
this.currentDisplacement.z = param2.z - this.currentCoords.z;
|
||||
if(this.currentDisplacement.x < this.offsetThreshold && this.currentDisplacement.x > -this.offsetThreshold && this.currentDisplacement.y < this.offsetThreshold && this.currentDisplacement.y > -this.offsetThreshold && this.currentDisplacement.z < this.offsetThreshold && this.currentDisplacement.z > -this.offsetThreshold)
|
||||
{
|
||||
param2.x = this.currentCoords.x;
|
||||
param2.y = this.currentCoords.y;
|
||||
param2.z = this.currentCoords.z;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
while(loc4 && ++loc3 < MAX_COLLISIONS);
|
||||
|
||||
if(loc3 == MAX_COLLISIONS)
|
||||
{
|
||||
param2.x = param1.x;
|
||||
param2.y = param1.y;
|
||||
param2.z = param1.z;
|
||||
}
|
||||
}
|
||||
|
||||
public function getCollision(param1:Point3D, param2:Point3D, param3:Collision) : Boolean
|
||||
{
|
||||
var loc4:CollisionPlane = null;
|
||||
if(this.scene == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
this.collisionSource = param1;
|
||||
this.currentDisplacement.x = param2.x;
|
||||
this.currentDisplacement.y = param2.y;
|
||||
this.currentDisplacement.z = param2.z;
|
||||
this.collisionDestination.x = this.collisionSource.x + this.currentDisplacement.x;
|
||||
this.collisionDestination.y = this.collisionSource.y + this.currentDisplacement.y;
|
||||
this.collisionDestination.z = this.collisionSource.z + this.currentDisplacement.z;
|
||||
this.collectPotentialCollisionPlanes(this.scene.alternativa3d::bsp);
|
||||
this.collisionPlanes.sortOn("sourceOffset",Array.NUMERIC | Array.DESCENDING);
|
||||
if(this.useSimpleAlgorithm)
|
||||
{
|
||||
while(true)
|
||||
{
|
||||
loc4 = this.collisionPlanes.pop();
|
||||
if(loc4 == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if(this.collisionPrimitive == null)
|
||||
{
|
||||
this.calculateCollisionWithPlaneS(loc4);
|
||||
}
|
||||
CollisionPlane.alternativa3d::destroyCollisionPlane(loc4);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while(true)
|
||||
{
|
||||
loc4 = this.collisionPlanes.pop();
|
||||
if(loc4 == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if(this.collisionPrimitive == null)
|
||||
{
|
||||
this.calculateCollisionWithPlaneE(loc4);
|
||||
}
|
||||
CollisionPlane.alternativa3d::destroyCollisionPlane(loc4);
|
||||
}
|
||||
}
|
||||
var loc5:* = this.collisionPrimitive != null;
|
||||
if(loc5)
|
||||
{
|
||||
param3.face = this.collisionPrimitive.alternativa3d::face;
|
||||
param3.normal = this.collisionNormal;
|
||||
param3.offset = this.collisionOffset;
|
||||
param3.point = this.collisionPoint;
|
||||
}
|
||||
this.collisionPrimitive = null;
|
||||
this.collisionSource = null;
|
||||
return loc5;
|
||||
}
|
||||
|
||||
private function collectPotentialCollisionPlanes(param1:BSPNode) : void
|
||||
{
|
||||
var loc4:CollisionPlane = null;
|
||||
if(param1 == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var loc2:Number = this.collisionSource.x * param1.alternativa3d::normal.x + this.collisionSource.y * param1.alternativa3d::normal.y + this.collisionSource.z * param1.alternativa3d::normal.z - param1.alternativa3d::offset;
|
||||
var loc3:Number = this.collisionDestination.x * param1.alternativa3d::normal.x + this.collisionDestination.y * param1.alternativa3d::normal.y + this.collisionDestination.z * param1.alternativa3d::normal.z - param1.alternativa3d::offset;
|
||||
if(loc2 >= 0)
|
||||
{
|
||||
this.collectPotentialCollisionPlanes(param1.alternativa3d::front);
|
||||
if(loc3 < this._radius && !param1.alternativa3d::isSprite)
|
||||
{
|
||||
if(param1.alternativa3d::splitter == null)
|
||||
{
|
||||
loc4 = CollisionPlane.alternativa3d::createCollisionPlane(param1,true,loc2,loc3);
|
||||
this.collisionPlanes.push(loc4);
|
||||
}
|
||||
this.collectPotentialCollisionPlanes(param1.alternativa3d::back);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.collectPotentialCollisionPlanes(param1.alternativa3d::back);
|
||||
if(loc3 > -this._radius)
|
||||
{
|
||||
if(param1.alternativa3d::backPrimitives != null)
|
||||
{
|
||||
loc4 = CollisionPlane.alternativa3d::createCollisionPlane(param1,false,-loc2,-loc3);
|
||||
this.collisionPlanes.push(loc4);
|
||||
}
|
||||
this.collectPotentialCollisionPlanes(param1.alternativa3d::front);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function calculateCollisionWithPlaneS(param1:CollisionPlane) : void
|
||||
{
|
||||
var loc3:* = undefined;
|
||||
var loc4:Number = NaN;
|
||||
var loc5:Number = NaN;
|
||||
var loc6:Number = NaN;
|
||||
var loc7:Number = NaN;
|
||||
var loc8:Number = NaN;
|
||||
var loc9:Number = NaN;
|
||||
var loc10:Number = NaN;
|
||||
var loc11:Number = NaN;
|
||||
var loc12:Number = NaN;
|
||||
var loc13:Number = NaN;
|
||||
var loc14:Number = NaN;
|
||||
var loc15:Number = NaN;
|
||||
var loc16:Number = NaN;
|
||||
this.collisionPlanePoint.copy(this.collisionSource);
|
||||
var loc2:Point3D = param1.node.alternativa3d::normal;
|
||||
if(param1.sourceOffset <= this._radius)
|
||||
{
|
||||
if(param1.infront)
|
||||
{
|
||||
this.collisionPlanePoint.x -= loc2.x * param1.sourceOffset;
|
||||
this.collisionPlanePoint.y -= loc2.y * param1.sourceOffset;
|
||||
this.collisionPlanePoint.z -= loc2.z * param1.sourceOffset;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.collisionPlanePoint.x += loc2.x * param1.sourceOffset;
|
||||
this.collisionPlanePoint.y += loc2.y * param1.sourceOffset;
|
||||
this.collisionPlanePoint.z += loc2.z * param1.sourceOffset;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
loc4 = (param1.sourceOffset - this._radius) / (param1.sourceOffset - param1.destinationOffset);
|
||||
this.collisionPlanePoint.x = this.collisionSource.x + this.currentDisplacement.x * loc4;
|
||||
this.collisionPlanePoint.y = this.collisionSource.y + this.currentDisplacement.y * loc4;
|
||||
this.collisionPlanePoint.z = this.collisionSource.z + this.currentDisplacement.z * loc4;
|
||||
if(param1.infront)
|
||||
{
|
||||
this.collisionPlanePoint.x -= loc2.x * this._radius;
|
||||
this.collisionPlanePoint.y -= loc2.y * this._radius;
|
||||
this.collisionPlanePoint.z -= loc2.z * this._radius;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.collisionPlanePoint.x += loc2.x * this._radius;
|
||||
this.collisionPlanePoint.y += loc2.y * this._radius;
|
||||
this.collisionPlanePoint.z += loc2.z * this._radius;
|
||||
}
|
||||
}
|
||||
this.collisionPrimitiveNearestLengthSqr = Number.MAX_VALUE;
|
||||
this.collisionPrimitiveNearest = null;
|
||||
if(param1.infront)
|
||||
{
|
||||
loc3 = param1.node.alternativa3d::primitive;
|
||||
if(loc3 != null)
|
||||
{
|
||||
if(this._collisionSetMode == CollisionSetMode.EXCLUDE && (this.collisionSet == null || !(Boolean(this.collisionSet[loc3.face._mesh]) || Boolean(this.collisionSet[loc3.face._surface]))) || this._collisionSetMode == CollisionSetMode.INCLUDE && this.collisionSet != null && (this.collisionSet[loc3.face._mesh] || this.collisionSet[loc3.face._surface]))
|
||||
{
|
||||
this.calculateCollisionWithPrimitiveS(param1.node.alternativa3d::primitive);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(loc3 in param1.node.alternativa3d::frontPrimitives)
|
||||
{
|
||||
if(this._collisionSetMode == CollisionSetMode.EXCLUDE && (this.collisionSet == null || !(Boolean(this.collisionSet[loc3.face._mesh]) || Boolean(this.collisionSet[loc3.face._surface]))) || this._collisionSetMode == CollisionSetMode.INCLUDE && this.collisionSet != null && (this.collisionSet[loc3.face._mesh] || this.collisionSet[loc3.face._surface]))
|
||||
{
|
||||
this.calculateCollisionWithPrimitiveS(loc3);
|
||||
if(this.collisionPrimitive != null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(loc3 in param1.node.alternativa3d::backPrimitives)
|
||||
{
|
||||
if(this._collisionSetMode == CollisionSetMode.EXCLUDE && (this.collisionSet == null || !(Boolean(this.collisionSet[loc3.face._mesh]) || Boolean(this.collisionSet[loc3.face._surface]))) || this._collisionSetMode == CollisionSetMode.INCLUDE && this.collisionSet != null && (this.collisionSet[loc3.face._mesh] || this.collisionSet[loc3.face._surface]))
|
||||
{
|
||||
this.calculateCollisionWithPrimitiveS(loc3);
|
||||
if(this.collisionPrimitive != null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(this.collisionPrimitive != null)
|
||||
{
|
||||
if(param1.infront)
|
||||
{
|
||||
this.collisionNormal.x = loc2.x;
|
||||
this.collisionNormal.y = loc2.y;
|
||||
this.collisionNormal.z = loc2.z;
|
||||
this.collisionOffset = param1.node.alternativa3d::offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.collisionNormal.x = -loc2.x;
|
||||
this.collisionNormal.y = -loc2.y;
|
||||
this.collisionNormal.z = -loc2.z;
|
||||
this.collisionOffset = -param1.node.alternativa3d::offset;
|
||||
}
|
||||
this.collisionPoint.x = this.collisionPlanePoint.x;
|
||||
this.collisionPoint.y = this.collisionPlanePoint.y;
|
||||
this.collisionPoint.z = this.collisionPlanePoint.z;
|
||||
}
|
||||
else
|
||||
{
|
||||
loc5 = this.collisionSource.x - this.collisionPrimitivePoint.x;
|
||||
loc6 = this.collisionSource.y - this.collisionPrimitivePoint.y;
|
||||
loc7 = this.collisionSource.z - this.collisionPrimitivePoint.z;
|
||||
if(loc5 * this.currentDisplacement.x + loc6 * this.currentDisplacement.y + loc7 * this.currentDisplacement.z <= 0)
|
||||
{
|
||||
loc8 = Math.sqrt(this.currentDisplacement.x * this.currentDisplacement.x + this.currentDisplacement.y * this.currentDisplacement.y + this.currentDisplacement.z * this.currentDisplacement.z);
|
||||
loc9 = -this.currentDisplacement.x / loc8;
|
||||
loc10 = -this.currentDisplacement.y / loc8;
|
||||
loc11 = -this.currentDisplacement.z / loc8;
|
||||
loc12 = loc5 * loc5 + loc6 * loc6 + loc7 * loc7;
|
||||
loc13 = loc5 * loc9 + loc6 * loc10 + loc7 * loc11;
|
||||
loc14 = this._radius2 - loc12 + loc13 * loc13;
|
||||
if(loc14 > 0)
|
||||
{
|
||||
loc15 = loc13 - Math.sqrt(loc14);
|
||||
if(loc15 < loc8)
|
||||
{
|
||||
this.collisionPoint.x = this.collisionPrimitivePoint.x;
|
||||
this.collisionPoint.y = this.collisionPrimitivePoint.y;
|
||||
this.collisionPoint.z = this.collisionPrimitivePoint.z;
|
||||
loc16 = Math.sqrt(loc12);
|
||||
this.collisionNormal.x = loc5 / loc16;
|
||||
this.collisionNormal.y = loc6 / loc16;
|
||||
this.collisionNormal.z = loc7 / loc16;
|
||||
this.collisionOffset = this.collisionPoint.x * this.collisionNormal.x + this.collisionPoint.y * this.collisionNormal.y + this.collisionPoint.z * this.collisionNormal.z;
|
||||
this.collisionPrimitive = this.collisionPrimitiveNearest;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function calculateCollisionWithPrimitiveS(param1:PolyPrimitive) : void
|
||||
{
|
||||
var loc7:Point3D = null;
|
||||
var loc8:Point3D = null;
|
||||
var loc9:Number = NaN;
|
||||
var loc10:Number = NaN;
|
||||
var loc11:Number = NaN;
|
||||
var loc12:Number = NaN;
|
||||
var loc13:Number = NaN;
|
||||
var loc14:Number = NaN;
|
||||
var loc15:Number = NaN;
|
||||
var loc16:Number = NaN;
|
||||
var loc17:Number = NaN;
|
||||
var loc18:Number = NaN;
|
||||
var loc19:Number = NaN;
|
||||
var loc20:Number = NaN;
|
||||
var loc21:Number = NaN;
|
||||
var loc22:Number = NaN;
|
||||
var loc23:Number = NaN;
|
||||
var loc24:Number = NaN;
|
||||
var loc25:Number = NaN;
|
||||
var loc2:uint = param1.alternativa3d::num;
|
||||
var loc3:Array = param1.alternativa3d::points;
|
||||
var loc4:Point3D = param1.alternativa3d::face.alternativa3d::globalNormal;
|
||||
var loc5:Boolean = true;
|
||||
var loc6:uint = 0;
|
||||
while(loc6 < loc2)
|
||||
{
|
||||
loc7 = loc3[loc6];
|
||||
loc8 = loc3[loc6 < loc2 - 1 ? loc6 + 1 : 0];
|
||||
loc9 = loc8.x - loc7.x;
|
||||
loc10 = loc8.y - loc7.y;
|
||||
loc11 = loc8.z - loc7.z;
|
||||
loc12 = this.collisionPlanePoint.x - loc7.x;
|
||||
loc13 = this.collisionPlanePoint.y - loc7.y;
|
||||
loc14 = this.collisionPlanePoint.z - loc7.z;
|
||||
loc15 = loc13 * loc11 - loc14 * loc10;
|
||||
loc16 = loc14 * loc9 - loc12 * loc11;
|
||||
loc17 = loc12 * loc10 - loc13 * loc9;
|
||||
if(loc15 * loc4.x + loc16 * loc4.y + loc17 * loc4.z > 0)
|
||||
{
|
||||
loc5 = false;
|
||||
loc18 = loc9 * loc9 + loc10 * loc10 + loc11 * loc11;
|
||||
loc19 = (loc15 * loc15 + loc16 * loc16 + loc17 * loc17) / loc18;
|
||||
if(loc19 < this.collisionPrimitiveNearestLengthSqr)
|
||||
{
|
||||
loc20 = Math.sqrt(loc18);
|
||||
loc21 = loc9 / loc20;
|
||||
loc22 = loc10 / loc20;
|
||||
loc23 = loc11 / loc20;
|
||||
loc24 = loc21 * loc12 + loc22 * loc13 + loc23 * loc14;
|
||||
if(loc24 < 0)
|
||||
{
|
||||
loc25 = loc12 * loc12 + loc13 * loc13 + loc14 * loc14;
|
||||
if(loc25 < this.collisionPrimitiveNearestLengthSqr)
|
||||
{
|
||||
this.collisionPrimitiveNearestLengthSqr = loc25;
|
||||
this.collisionPrimitivePoint.x = loc7.x;
|
||||
this.collisionPrimitivePoint.y = loc7.y;
|
||||
this.collisionPrimitivePoint.z = loc7.z;
|
||||
this.collisionPrimitiveNearest = param1;
|
||||
}
|
||||
}
|
||||
else if(loc24 > loc20)
|
||||
{
|
||||
loc12 = this.collisionPlanePoint.x - loc8.x;
|
||||
loc13 = this.collisionPlanePoint.y - loc8.y;
|
||||
loc14 = this.collisionPlanePoint.z - loc8.z;
|
||||
loc25 = loc12 * loc12 + loc13 * loc13 + loc14 * loc14;
|
||||
if(loc25 < this.collisionPrimitiveNearestLengthSqr)
|
||||
{
|
||||
this.collisionPrimitiveNearestLengthSqr = loc25;
|
||||
this.collisionPrimitivePoint.x = loc8.x;
|
||||
this.collisionPrimitivePoint.y = loc8.y;
|
||||
this.collisionPrimitivePoint.z = loc8.z;
|
||||
this.collisionPrimitiveNearest = param1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.collisionPrimitiveNearestLengthSqr = loc19;
|
||||
this.collisionPrimitivePoint.x = loc7.x + loc21 * loc24;
|
||||
this.collisionPrimitivePoint.y = loc7.y + loc22 * loc24;
|
||||
this.collisionPrimitivePoint.z = loc7.z + loc23 * loc24;
|
||||
this.collisionPrimitiveNearest = param1;
|
||||
}
|
||||
}
|
||||
}
|
||||
loc6++;
|
||||
}
|
||||
if(loc5)
|
||||
{
|
||||
this.collisionPrimitive = param1;
|
||||
}
|
||||
}
|
||||
|
||||
private function calculateCollisionWithPlaneE(param1:CollisionPlane) : void
|
||||
{
|
||||
var loc14:* = undefined;
|
||||
var loc15:Number = NaN;
|
||||
var loc16:Boolean = false;
|
||||
var loc17:Number = NaN;
|
||||
var loc18:Number = NaN;
|
||||
var loc19:Number = NaN;
|
||||
var loc20:Number = NaN;
|
||||
var loc21:Number = NaN;
|
||||
var loc22:Number = NaN;
|
||||
var loc23:Number = NaN;
|
||||
var loc24:Number = NaN;
|
||||
var loc2:Number = param1.node.alternativa3d::normal.x;
|
||||
var loc3:Number = param1.node.alternativa3d::normal.y;
|
||||
var loc4:Number = param1.node.alternativa3d::normal.z;
|
||||
var loc5:Number = this.currentDisplacement.x * loc2 + this.currentDisplacement.y * loc3 + this.currentDisplacement.z * loc4;
|
||||
if(param1.infront)
|
||||
{
|
||||
loc5 = -loc5;
|
||||
}
|
||||
if(loc5 < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var loc6:Number = this._radius / Math.sqrt(loc2 * loc2 * this._scaleX2 + loc3 * loc3 * this._scaleY2 + loc4 * loc4 * this._scaleZ2);
|
||||
var loc7:Number = loc6 * loc2 * this._scaleX2;
|
||||
var loc8:Number = loc6 * loc3 * this._scaleY2;
|
||||
var loc9:Number = loc6 * loc4 * this._scaleZ2;
|
||||
var loc10:Number = this.collisionSource.x + loc7;
|
||||
var loc11:Number = this.collisionSource.y + loc8;
|
||||
var loc12:Number = this.collisionSource.z + loc9;
|
||||
var loc13:Number = loc10 * loc2 + loc11 * loc3 + loc12 * loc4 - param1.node.alternativa3d::offset;
|
||||
if(!param1.infront)
|
||||
{
|
||||
loc13 = -loc13;
|
||||
}
|
||||
if(loc13 > param1.sourceOffset)
|
||||
{
|
||||
loc10 = this.collisionSource.x - loc7;
|
||||
loc11 = this.collisionSource.y - loc8;
|
||||
loc12 = this.collisionSource.z - loc9;
|
||||
loc13 = loc10 * loc2 + loc11 * loc3 + loc12 * loc4 - param1.node.alternativa3d::offset;
|
||||
if(!param1.infront)
|
||||
{
|
||||
loc13 = -loc13;
|
||||
}
|
||||
}
|
||||
if(loc13 > loc5)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if(loc13 <= 0)
|
||||
{
|
||||
if(param1.infront)
|
||||
{
|
||||
this.collisionPlanePoint.x = loc10 - loc2 * loc13;
|
||||
this.collisionPlanePoint.y = loc11 - loc3 * loc13;
|
||||
this.collisionPlanePoint.z = loc12 - loc4 * loc13;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.collisionPlanePoint.x = loc10 + loc2 * loc13;
|
||||
this.collisionPlanePoint.y = loc11 + loc3 * loc13;
|
||||
this.collisionPlanePoint.z = loc12 + loc4 * loc13;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
loc15 = loc13 / loc5;
|
||||
this.collisionPlanePoint.x = loc10 + this.currentDisplacement.x * loc15;
|
||||
this.collisionPlanePoint.y = loc11 + this.currentDisplacement.y * loc15;
|
||||
this.collisionPlanePoint.z = loc12 + this.currentDisplacement.z * loc15;
|
||||
}
|
||||
this.collisionPrimitiveNearestLengthSqr = Number.MAX_VALUE;
|
||||
this.collisionPrimitiveNearest = null;
|
||||
if(param1.infront)
|
||||
{
|
||||
loc14 = param1.node.alternativa3d::primitive;
|
||||
if(loc14 != null)
|
||||
{
|
||||
if(this._collisionSetMode == CollisionSetMode.EXCLUDE && (this.collisionSet == null || !(Boolean(this.collisionSet[loc14.face._mesh]) || Boolean(this.collisionSet[loc14.face._surface]))) || this._collisionSetMode == CollisionSetMode.INCLUDE && this.collisionSet != null && (this.collisionSet[loc14.face._mesh] || this.collisionSet[loc14.face._surface]))
|
||||
{
|
||||
this.calculateCollisionWithPrimitiveE(loc14);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(loc14 in param1.node.alternativa3d::frontPrimitives)
|
||||
{
|
||||
if(this._collisionSetMode == CollisionSetMode.EXCLUDE && (this.collisionSet == null || !(Boolean(this.collisionSet[loc14.face._mesh]) || Boolean(this.collisionSet[loc14.face._surface]))) || this._collisionSetMode == CollisionSetMode.INCLUDE && this.collisionSet != null && (this.collisionSet[loc14.face._mesh] || this.collisionSet[loc14.face._surface]))
|
||||
{
|
||||
this.calculateCollisionWithPrimitiveE(loc14);
|
||||
if(this.collisionPrimitive != null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(loc14 in param1.node.alternativa3d::backPrimitives)
|
||||
{
|
||||
if(this._collisionSetMode == CollisionSetMode.EXCLUDE && (this.collisionSet == null || !(Boolean(this.collisionSet[loc14.face._mesh]) || Boolean(this.collisionSet[loc14.face._surface]))) || this._collisionSetMode == CollisionSetMode.INCLUDE && this.collisionSet != null && (this.collisionSet[loc14.face._mesh] || this.collisionSet[loc14.face._surface]))
|
||||
{
|
||||
this.calculateCollisionWithPrimitiveE(loc14);
|
||||
if(this.collisionPrimitive != null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(this.collisionPrimitive != null)
|
||||
{
|
||||
if(param1.infront)
|
||||
{
|
||||
this.collisionNormal.x = loc2;
|
||||
this.collisionNormal.y = loc3;
|
||||
this.collisionNormal.z = loc4;
|
||||
this.collisionOffset = param1.node.alternativa3d::offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.collisionNormal.x = -loc2;
|
||||
this.collisionNormal.y = -loc3;
|
||||
this.collisionNormal.z = -loc4;
|
||||
this.collisionOffset = -param1.node.alternativa3d::offset;
|
||||
}
|
||||
this.collisionRadius = loc7 * this.collisionNormal.x + loc8 * this.collisionNormal.y + loc9 * this.collisionNormal.z;
|
||||
if(this.collisionRadius < 0)
|
||||
{
|
||||
this.collisionRadius = -this.collisionRadius;
|
||||
}
|
||||
this.radiusVector.x = loc10 - this.collisionSource.x;
|
||||
this.radiusVector.y = loc11 - this.collisionSource.y;
|
||||
this.radiusVector.z = loc12 - this.collisionSource.z;
|
||||
this.collisionPoint.x = this.collisionPlanePoint.x;
|
||||
this.collisionPoint.y = this.collisionPlanePoint.y;
|
||||
this.collisionPoint.z = this.collisionPlanePoint.z;
|
||||
}
|
||||
else
|
||||
{
|
||||
loc10 = this.collisionPrimitivePoint.x;
|
||||
loc11 = this.collisionPrimitivePoint.y;
|
||||
loc12 = this.collisionPrimitivePoint.z;
|
||||
loc17 = loc10 * loc10 + loc11 * loc11 + loc12 * loc12;
|
||||
if(loc17 < this._radius2)
|
||||
{
|
||||
loc6 = this._radius / Math.sqrt(loc17);
|
||||
loc10 *= loc6 * this._scaleX;
|
||||
loc11 *= loc6 * this._scaleY;
|
||||
loc12 *= loc6 * this._scaleZ;
|
||||
loc16 = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
loc18 = -this.currentDisplacement.x / this._scaleX;
|
||||
loc19 = -this.currentDisplacement.y / this._scaleY;
|
||||
loc20 = -this.currentDisplacement.z / this._scaleZ;
|
||||
loc21 = loc18 * loc18 + loc19 * loc19 + loc20 * loc20;
|
||||
loc22 = 2 * (loc10 * loc18 + loc11 * loc19 + loc12 * loc20);
|
||||
loc23 = loc17 - this._radius2;
|
||||
loc24 = loc22 * loc22 - 4 * loc21 * loc23;
|
||||
if(loc24 >= 0)
|
||||
{
|
||||
loc15 = -0.5 * (loc22 + Math.sqrt(loc24)) / loc21;
|
||||
if(loc15 >= 0 && loc15 <= 1)
|
||||
{
|
||||
loc10 = (loc10 + loc15 * loc18) * this._scaleX;
|
||||
loc11 = (loc11 + loc15 * loc19) * this._scaleY;
|
||||
loc12 = (loc12 + loc15 * loc20) * this._scaleZ;
|
||||
loc16 = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(loc16)
|
||||
{
|
||||
this.collisionNormal.x = -loc10 / this._scaleX2;
|
||||
this.collisionNormal.y = -loc11 / this._scaleY2;
|
||||
this.collisionNormal.z = -loc12 / this._scaleZ2;
|
||||
this.collisionNormal.normalize();
|
||||
this.collisionRadius = loc10 * this.collisionNormal.x + loc11 * this.collisionNormal.y + loc12 * this.collisionNormal.z;
|
||||
if(this.collisionRadius < 0)
|
||||
{
|
||||
this.collisionRadius = -this.collisionRadius;
|
||||
}
|
||||
this.radiusVector.x = loc10;
|
||||
this.radiusVector.y = loc11;
|
||||
this.radiusVector.z = loc12;
|
||||
this.collisionPoint.x = this.collisionPrimitivePoint.x * this._scaleX + this.currentCoords.x;
|
||||
this.collisionPoint.y = this.collisionPrimitivePoint.y * this._scaleY + this.currentCoords.y;
|
||||
this.collisionPoint.z = this.collisionPrimitivePoint.z * this._scaleZ + this.currentCoords.z;
|
||||
this.collisionOffset = this.collisionPoint.x * this.collisionNormal.x + this.collisionPoint.y * this.collisionNormal.y + this.collisionPoint.z * this.collisionNormal.z;
|
||||
this.collisionPrimitive = this.collisionPrimitiveNearest;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function calculateCollisionWithPrimitiveE(param1:PolyPrimitive) : void
|
||||
{
|
||||
var loc6:Point3D = null;
|
||||
var loc9:Number = NaN;
|
||||
var loc10:Number = NaN;
|
||||
var loc11:Number = NaN;
|
||||
var loc12:Number = NaN;
|
||||
var loc13:Number = NaN;
|
||||
var loc14:Number = NaN;
|
||||
var loc15:Number = NaN;
|
||||
var loc16:Number = NaN;
|
||||
var loc17:Number = NaN;
|
||||
var loc18:Number = NaN;
|
||||
var loc19:Number = NaN;
|
||||
var loc20:Number = NaN;
|
||||
var loc21:Number = NaN;
|
||||
var loc22:Number = NaN;
|
||||
var loc23:Number = NaN;
|
||||
var loc24:Number = NaN;
|
||||
var loc25:Number = NaN;
|
||||
var loc2:uint = param1.alternativa3d::num;
|
||||
var loc3:Array = param1.alternativa3d::points;
|
||||
var loc4:Point3D = param1.alternativa3d::face.alternativa3d::globalNormal;
|
||||
var loc5:Boolean = true;
|
||||
var loc7:Point3D = loc3[loc2 - 1];
|
||||
this.p2.x = (loc7.x - this.currentCoords.x) / this._scaleX;
|
||||
this.p2.y = (loc7.y - this.currentCoords.y) / this._scaleY;
|
||||
this.p2.z = (loc7.z - this.currentCoords.z) / this._scaleZ;
|
||||
this.localCollisionPlanePoint.x = (this.collisionPlanePoint.x - this.currentCoords.x) / this._scaleX;
|
||||
this.localCollisionPlanePoint.y = (this.collisionPlanePoint.y - this.currentCoords.y) / this._scaleY;
|
||||
this.localCollisionPlanePoint.z = (this.collisionPlanePoint.z - this.currentCoords.z) / this._scaleZ;
|
||||
var loc8:uint = 0;
|
||||
while(loc8 < loc2)
|
||||
{
|
||||
loc6 = loc7;
|
||||
loc7 = loc3[loc8];
|
||||
this.p1.x = this.p2.x;
|
||||
this.p1.y = this.p2.y;
|
||||
this.p1.z = this.p2.z;
|
||||
this.p2.x = (loc7.x - this.currentCoords.x) / this._scaleX;
|
||||
this.p2.y = (loc7.y - this.currentCoords.y) / this._scaleY;
|
||||
this.p2.z = (loc7.z - this.currentCoords.z) / this._scaleZ;
|
||||
loc9 = this.p2.x - this.p1.x;
|
||||
loc10 = this.p2.y - this.p1.y;
|
||||
loc11 = this.p2.z - this.p1.z;
|
||||
loc12 = this.localCollisionPlanePoint.x - this.p1.x;
|
||||
loc13 = this.localCollisionPlanePoint.y - this.p1.y;
|
||||
loc14 = this.localCollisionPlanePoint.z - this.p1.z;
|
||||
loc15 = loc13 * loc11 - loc14 * loc10;
|
||||
loc16 = loc14 * loc9 - loc12 * loc11;
|
||||
loc17 = loc12 * loc10 - loc13 * loc9;
|
||||
if(loc15 * loc4.x + loc16 * loc4.y + loc17 * loc4.z > 0)
|
||||
{
|
||||
loc5 = false;
|
||||
loc18 = loc9 * loc9 + loc10 * loc10 + loc11 * loc11;
|
||||
loc19 = (loc15 * loc15 + loc16 * loc16 + loc17 * loc17) / loc18;
|
||||
if(loc19 < this.collisionPrimitiveNearestLengthSqr)
|
||||
{
|
||||
loc20 = Math.sqrt(loc18);
|
||||
loc21 = loc9 / loc20;
|
||||
loc22 = loc10 / loc20;
|
||||
loc23 = loc11 / loc20;
|
||||
loc24 = loc21 * loc12 + loc22 * loc13 + loc23 * loc14;
|
||||
if(loc24 < 0)
|
||||
{
|
||||
loc25 = loc12 * loc12 + loc13 * loc13 + loc14 * loc14;
|
||||
if(loc25 < this.collisionPrimitiveNearestLengthSqr)
|
||||
{
|
||||
this.collisionPrimitiveNearestLengthSqr = loc25;
|
||||
this.collisionPrimitivePoint.x = this.p1.x;
|
||||
this.collisionPrimitivePoint.y = this.p1.y;
|
||||
this.collisionPrimitivePoint.z = this.p1.z;
|
||||
this.collisionPrimitiveNearest = param1;
|
||||
}
|
||||
}
|
||||
else if(loc24 > loc20)
|
||||
{
|
||||
loc12 = this.localCollisionPlanePoint.x - this.p2.x;
|
||||
loc13 = this.localCollisionPlanePoint.y - this.p2.y;
|
||||
loc14 = this.localCollisionPlanePoint.z - this.p2.z;
|
||||
loc25 = loc12 * loc12 + loc13 * loc13 + loc14 * loc14;
|
||||
if(loc25 < this.collisionPrimitiveNearestLengthSqr)
|
||||
{
|
||||
this.collisionPrimitiveNearestLengthSqr = loc25;
|
||||
this.collisionPrimitivePoint.x = this.p2.x;
|
||||
this.collisionPrimitivePoint.y = this.p2.y;
|
||||
this.collisionPrimitivePoint.z = this.p2.z;
|
||||
this.collisionPrimitiveNearest = param1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.collisionPrimitiveNearestLengthSqr = loc19;
|
||||
this.collisionPrimitivePoint.x = this.p1.x + loc21 * loc24;
|
||||
this.collisionPrimitivePoint.y = this.p1.y + loc22 * loc24;
|
||||
this.collisionPrimitivePoint.z = this.p1.z + loc23 * loc24;
|
||||
this.collisionPrimitiveNearest = param1;
|
||||
}
|
||||
}
|
||||
}
|
||||
loc8++;
|
||||
}
|
||||
if(loc5)
|
||||
{
|
||||
this.collisionPrimitive = param1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,381 +0,0 @@
|
||||
package alternativa.engine3d.primitives
|
||||
{
|
||||
import alternativa.engine3d.core.Mesh;
|
||||
import alternativa.engine3d.core.Object3D;
|
||||
import alternativa.engine3d.core.Surface;
|
||||
import flash.geom.Point;
|
||||
|
||||
public class Box extends Mesh
|
||||
{
|
||||
private static var counter:uint = 0;
|
||||
|
||||
public function Box(param1:Number = 100, param2:Number = 100, param3:Number = 100, param4:uint = 1, param5:uint = 1, param6:uint = 1, param7:Boolean = false, param8:Boolean = false)
|
||||
{
|
||||
var loc15:int = 0;
|
||||
var loc16:int = 0;
|
||||
var loc17:int = 0;
|
||||
var loc27:String = null;
|
||||
var loc28:Point = null;
|
||||
var loc29:Point = null;
|
||||
super();
|
||||
if(param4 == 0 || param5 == 0 || param6 == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
param1 = param1 < 0 ? 0 : param1;
|
||||
param2 = param2 < 0 ? 0 : param2;
|
||||
param3 = param3 < 0 ? 0 : param3;
|
||||
var loc9:Number = param1 / 2;
|
||||
var loc10:Number = param2 / 2;
|
||||
var loc11:Number = param3 / 2;
|
||||
var loc12:Number = param1 / param4;
|
||||
var loc13:Number = param2 / param5;
|
||||
var loc14:Number = param3 / param6;
|
||||
loc15 = 0;
|
||||
while(loc15 <= param4)
|
||||
{
|
||||
loc16 = 0;
|
||||
while(loc16 <= param5)
|
||||
{
|
||||
loc17 = 0;
|
||||
while(loc17 <= param6)
|
||||
{
|
||||
if(loc15 == 0 || loc15 == param4 || loc16 == 0 || loc16 == param5 || loc17 == 0 || loc17 == param6)
|
||||
{
|
||||
createVertex(loc15 * loc12 - loc9,loc16 * loc13 - loc10,loc17 * loc14 - loc11,loc15 + "_" + loc16 + "_" + loc17);
|
||||
}
|
||||
loc17++;
|
||||
}
|
||||
loc16++;
|
||||
}
|
||||
loc15++;
|
||||
}
|
||||
var loc18:Surface = createSurface(null,"front");
|
||||
var loc19:Surface = createSurface(null,"back");
|
||||
var loc20:Surface = createSurface(null,"left");
|
||||
var loc21:Surface = createSurface(null,"right");
|
||||
var loc22:Surface = createSurface(null,"top");
|
||||
var loc23:Surface = createSurface(null,"bottom");
|
||||
var loc24:Number = 1 / param4;
|
||||
var loc25:Number = 1 / param5;
|
||||
var loc26:Number = 1 / param6;
|
||||
loc16 = 0;
|
||||
while(loc16 < param5)
|
||||
{
|
||||
loc15 = 0;
|
||||
while(loc15 < param4)
|
||||
{
|
||||
loc27 = "top_" + loc15 + "_" + loc16;
|
||||
if(param7)
|
||||
{
|
||||
if(param8)
|
||||
{
|
||||
loc28 = new Point(loc15 * loc24,(param5 - loc16) * loc25);
|
||||
loc29 = new Point((loc15 + 1) * loc24,(param5 - loc16 - 1) * loc25);
|
||||
createFace([loc15 + "_" + loc16 + "_" + param6,loc15 + "_" + (loc16 + 1) + "_" + param6,loc15 + 1 + "_" + (loc16 + 1) + "_" + param6],loc27 + ":1");
|
||||
setUVsToFace(loc28,new Point(loc15 * loc24,(param5 - loc16 - 1) * loc25),loc29,loc27 + ":1");
|
||||
createFace([loc15 + 1 + "_" + (loc16 + 1) + "_" + param6,loc15 + 1 + "_" + loc16 + "_" + param6,loc15 + "_" + loc16 + "_" + param6],loc27 + ":0");
|
||||
setUVsToFace(loc29,new Point((loc15 + 1) * loc24,(param5 - loc16) * loc25),loc28,loc27 + ":0");
|
||||
}
|
||||
else
|
||||
{
|
||||
createFace([loc15 + "_" + loc16 + "_" + param6,loc15 + "_" + (loc16 + 1) + "_" + param6,loc15 + 1 + "_" + (loc16 + 1) + "_" + param6,loc15 + 1 + "_" + loc16 + "_" + param6],loc27);
|
||||
setUVsToFace(new Point(loc15 * loc24,(param5 - loc16) * loc25),new Point(loc15 * loc24,(param5 - loc16 - 1) * loc25),new Point((loc15 + 1) * loc24,(param5 - loc16 - 1) * loc25),loc27);
|
||||
}
|
||||
}
|
||||
else if(param8)
|
||||
{
|
||||
loc28 = new Point(loc15 * loc24,loc16 * loc25);
|
||||
loc29 = new Point((loc15 + 1) * loc24,(loc16 + 1) * loc25);
|
||||
createFace([loc15 + "_" + loc16 + "_" + param6,loc15 + 1 + "_" + loc16 + "_" + param6,loc15 + 1 + "_" + (loc16 + 1) + "_" + param6],loc27 + ":0");
|
||||
setUVsToFace(loc28,new Point((loc15 + 1) * loc24,loc16 * loc25),loc29,loc27 + ":0");
|
||||
createFace([loc15 + 1 + "_" + (loc16 + 1) + "_" + param6,loc15 + "_" + (loc16 + 1) + "_" + param6,loc15 + "_" + loc16 + "_" + param6],loc27 + ":1");
|
||||
setUVsToFace(loc29,new Point(loc15 * loc24,(loc16 + 1) * loc25),loc28,loc27 + ":1");
|
||||
}
|
||||
else
|
||||
{
|
||||
createFace([loc15 + "_" + loc16 + "_" + param6,loc15 + 1 + "_" + loc16 + "_" + param6,loc15 + 1 + "_" + (loc16 + 1) + "_" + param6,loc15 + "_" + (loc16 + 1) + "_" + param6],loc27);
|
||||
setUVsToFace(new Point(loc15 * loc24,loc16 * loc25),new Point((loc15 + 1) * loc24,loc16 * loc25),new Point((loc15 + 1) * loc24,(loc16 + 1) * loc25),loc27);
|
||||
}
|
||||
if(param8)
|
||||
{
|
||||
loc22.addFace(loc27 + ":0");
|
||||
loc22.addFace(loc27 + ":1");
|
||||
}
|
||||
else
|
||||
{
|
||||
loc22.addFace(loc27);
|
||||
}
|
||||
loc15++;
|
||||
}
|
||||
loc16++;
|
||||
}
|
||||
loc16 = 0;
|
||||
while(loc16 < param5)
|
||||
{
|
||||
loc15 = 0;
|
||||
while(loc15 < param4)
|
||||
{
|
||||
loc27 = "bottom_" + loc15 + "_" + loc16;
|
||||
if(param7)
|
||||
{
|
||||
if(param8)
|
||||
{
|
||||
loc28 = new Point((param4 - loc15) * loc24,(param5 - loc16) * loc25);
|
||||
loc29 = new Point((param4 - loc15 - 1) * loc24,(param5 - loc16 - 1) * loc25);
|
||||
createFace([loc15 + "_" + loc16 + "_" + 0,loc15 + 1 + "_" + loc16 + "_" + 0,loc15 + 1 + "_" + (loc16 + 1) + "_" + 0],loc27 + ":0");
|
||||
setUVsToFace(loc28,new Point((param4 - loc15 - 1) * loc24,(param5 - loc16) * loc25),loc29,loc27 + ":0");
|
||||
createFace([loc15 + 1 + "_" + (loc16 + 1) + "_" + 0,loc15 + "_" + (loc16 + 1) + "_" + 0,loc15 + "_" + loc16 + "_" + 0],loc27 + ":1");
|
||||
setUVsToFace(loc29,new Point((param4 - loc15) * loc24,(param5 - loc16 - 1) * loc25),loc28,loc27 + ":1");
|
||||
}
|
||||
else
|
||||
{
|
||||
createFace([loc15 + "_" + loc16 + "_" + 0,loc15 + 1 + "_" + loc16 + "_" + 0,loc15 + 1 + "_" + (loc16 + 1) + "_" + 0,loc15 + "_" + (loc16 + 1) + "_" + 0],loc27);
|
||||
setUVsToFace(new Point((param4 - loc15) * loc24,(param5 - loc16) * loc25),new Point((param4 - loc15 - 1) * loc24,(param5 - loc16) * loc25),new Point((param4 - loc15 - 1) * loc24,(param5 - loc16 - 1) * loc25),loc27);
|
||||
}
|
||||
}
|
||||
else if(param8)
|
||||
{
|
||||
loc28 = new Point((param4 - loc15) * loc24,loc16 * loc25);
|
||||
loc29 = new Point((param4 - loc15 - 1) * loc24,(loc16 + 1) * loc25);
|
||||
createFace([loc15 + "_" + loc16 + "_" + 0,loc15 + "_" + (loc16 + 1) + "_" + 0,loc15 + 1 + "_" + (loc16 + 1) + "_" + 0],loc27 + ":1");
|
||||
setUVsToFace(loc28,new Point((param4 - loc15) * loc24,(loc16 + 1) * loc25),loc29,loc27 + ":1");
|
||||
createFace([loc15 + 1 + "_" + (loc16 + 1) + "_" + 0,loc15 + 1 + "_" + loc16 + "_" + 0,loc15 + "_" + loc16 + "_" + 0],loc27 + ":0");
|
||||
setUVsToFace(loc29,new Point((param4 - loc15 - 1) * loc24,loc16 * loc25),loc28,loc27 + ":0");
|
||||
}
|
||||
else
|
||||
{
|
||||
createFace([loc15 + "_" + loc16 + "_" + 0,loc15 + "_" + (loc16 + 1) + "_" + 0,loc15 + 1 + "_" + (loc16 + 1) + "_" + 0,loc15 + 1 + "_" + loc16 + "_" + 0],loc27);
|
||||
setUVsToFace(new Point((param4 - loc15) * loc24,loc16 * loc25),new Point((param4 - loc15) * loc24,(loc16 + 1) * loc25),new Point((param4 - loc15 - 1) * loc24,(loc16 + 1) * loc25),loc27);
|
||||
}
|
||||
if(param8)
|
||||
{
|
||||
loc23.addFace(loc27 + ":0");
|
||||
loc23.addFace(loc27 + ":1");
|
||||
}
|
||||
else
|
||||
{
|
||||
loc23.addFace(loc27);
|
||||
}
|
||||
loc15++;
|
||||
}
|
||||
loc16++;
|
||||
}
|
||||
loc17 = 0;
|
||||
while(loc17 < param6)
|
||||
{
|
||||
loc15 = 0;
|
||||
while(loc15 < param4)
|
||||
{
|
||||
loc27 = "front_" + loc15 + "_" + loc17;
|
||||
if(param7)
|
||||
{
|
||||
if(param8)
|
||||
{
|
||||
loc28 = new Point((param4 - loc15) * loc24,loc17 * loc26);
|
||||
loc29 = new Point((param4 - loc15 - 1) * loc24,(loc17 + 1) * loc26);
|
||||
createFace([loc15 + "_" + 0 + "_" + loc17,loc15 + "_" + 0 + "_" + (loc17 + 1),loc15 + 1 + "_" + 0 + "_" + (loc17 + 1)],loc27 + ":1");
|
||||
setUVsToFace(loc28,new Point((param4 - loc15) * loc24,(loc17 + 1) * loc26),loc29,loc27 + ":1");
|
||||
createFace([loc15 + 1 + "_" + 0 + "_" + (loc17 + 1),loc15 + 1 + "_" + 0 + "_" + loc17,loc15 + "_" + 0 + "_" + loc17],loc27 + ":0");
|
||||
setUVsToFace(loc29,new Point((param4 - loc15 - 1) * loc24,loc17 * loc26),loc28,loc27 + ":0");
|
||||
}
|
||||
else
|
||||
{
|
||||
createFace([loc15 + "_" + 0 + "_" + loc17,loc15 + "_" + 0 + "_" + (loc17 + 1),loc15 + 1 + "_" + 0 + "_" + (loc17 + 1),loc15 + 1 + "_" + 0 + "_" + loc17],loc27);
|
||||
setUVsToFace(new Point((param4 - loc15) * loc24,loc17 * loc26),new Point((param4 - loc15) * loc24,(loc17 + 1) * loc26),new Point((param4 - loc15 - 1) * loc24,(loc17 + 1) * loc26),loc27);
|
||||
}
|
||||
}
|
||||
else if(param8)
|
||||
{
|
||||
loc28 = new Point(loc15 * loc24,loc17 * loc26);
|
||||
loc29 = new Point((loc15 + 1) * loc24,(loc17 + 1) * loc26);
|
||||
createFace([loc15 + "_" + 0 + "_" + loc17,loc15 + 1 + "_" + 0 + "_" + loc17,loc15 + 1 + "_" + 0 + "_" + (loc17 + 1)],loc27 + ":0");
|
||||
setUVsToFace(loc28,new Point((loc15 + 1) * loc24,loc17 * loc26),loc29,loc27 + ":0");
|
||||
createFace([loc15 + 1 + "_" + 0 + "_" + (loc17 + 1),loc15 + "_" + 0 + "_" + (loc17 + 1),loc15 + "_" + 0 + "_" + loc17],loc27 + ":1");
|
||||
setUVsToFace(loc29,new Point(loc15 * loc24,(loc17 + 1) * loc26),loc28,loc27 + ":1");
|
||||
}
|
||||
else
|
||||
{
|
||||
createFace([loc15 + "_" + 0 + "_" + loc17,loc15 + 1 + "_" + 0 + "_" + loc17,loc15 + 1 + "_" + 0 + "_" + (loc17 + 1),loc15 + "_" + 0 + "_" + (loc17 + 1)],loc27);
|
||||
setUVsToFace(new Point(loc15 * loc24,loc17 * loc26),new Point((loc15 + 1) * loc24,loc17 * loc26),new Point((loc15 + 1) * loc24,(loc17 + 1) * loc26),loc27);
|
||||
}
|
||||
if(param8)
|
||||
{
|
||||
loc18.addFace(loc27 + ":0");
|
||||
loc18.addFace(loc27 + ":1");
|
||||
}
|
||||
else
|
||||
{
|
||||
loc18.addFace(loc27);
|
||||
}
|
||||
loc15++;
|
||||
}
|
||||
loc17++;
|
||||
}
|
||||
loc17 = 0;
|
||||
while(loc17 < param6)
|
||||
{
|
||||
loc15 = 0;
|
||||
while(loc15 < param4)
|
||||
{
|
||||
loc27 = "back_" + loc15 + "_" + loc17;
|
||||
if(param7)
|
||||
{
|
||||
if(param8)
|
||||
{
|
||||
loc28 = new Point(loc15 * loc24,(loc17 + 1) * loc26);
|
||||
loc29 = new Point((loc15 + 1) * loc24,loc17 * loc26);
|
||||
createFace([loc15 + "_" + param5 + "_" + (loc17 + 1),loc15 + "_" + param5 + "_" + loc17,loc15 + 1 + "_" + param5 + "_" + loc17],loc27 + ":0");
|
||||
setUVsToFace(loc28,new Point(loc15 * loc24,loc17 * loc26),loc29,loc27 + ":0");
|
||||
createFace([loc15 + 1 + "_" + param5 + "_" + loc17,loc15 + 1 + "_" + param5 + "_" + (loc17 + 1),loc15 + "_" + param5 + "_" + (loc17 + 1)],loc27 + ":1");
|
||||
setUVsToFace(loc29,new Point((loc15 + 1) * loc24,(loc17 + 1) * loc26),loc28,loc27 + ":1");
|
||||
}
|
||||
else
|
||||
{
|
||||
createFace([loc15 + "_" + param5 + "_" + loc17,loc15 + 1 + "_" + param5 + "_" + loc17,loc15 + 1 + "_" + param5 + "_" + (loc17 + 1),loc15 + "_" + param5 + "_" + (loc17 + 1)],loc27);
|
||||
setUVsToFace(new Point(loc15 * loc24,loc17 * loc26),new Point((loc15 + 1) * loc24,loc17 * loc26),new Point((loc15 + 1) * loc24,(loc17 + 1) * loc26),loc27);
|
||||
}
|
||||
}
|
||||
else if(param8)
|
||||
{
|
||||
loc28 = new Point((param4 - loc15) * loc24,(loc17 + 1) * loc26);
|
||||
loc29 = new Point((param4 - loc15 - 1) * loc24,loc17 * loc26);
|
||||
createFace([loc15 + "_" + param5 + "_" + loc17,loc15 + "_" + param5 + "_" + (loc17 + 1),loc15 + 1 + "_" + param5 + "_" + loc17],loc27 + ":0");
|
||||
setUVsToFace(new Point((param4 - loc15) * loc24,loc17 * loc26),loc28,loc29,loc27 + ":0");
|
||||
createFace([loc15 + "_" + param5 + "_" + (loc17 + 1),loc15 + 1 + "_" + param5 + "_" + (loc17 + 1),loc15 + 1 + "_" + param5 + "_" + loc17],loc27 + ":1");
|
||||
setUVsToFace(loc28,new Point((param4 - loc15 - 1) * loc24,(loc17 + 1) * loc26),loc29,loc27 + ":1");
|
||||
}
|
||||
else
|
||||
{
|
||||
createFace([loc15 + "_" + param5 + "_" + loc17,loc15 + "_" + param5 + "_" + (loc17 + 1),loc15 + 1 + "_" + param5 + "_" + (loc17 + 1),loc15 + 1 + "_" + param5 + "_" + loc17],loc27);
|
||||
setUVsToFace(new Point((param4 - loc15) * loc24,loc17 * loc26),new Point((param4 - loc15) * loc24,(loc17 + 1) * loc26),new Point((param4 - loc15 - 1) * loc24,(loc17 + 1) * loc26),loc27);
|
||||
}
|
||||
if(param8)
|
||||
{
|
||||
loc19.addFace(loc27 + ":0");
|
||||
loc19.addFace(loc27 + ":1");
|
||||
}
|
||||
else
|
||||
{
|
||||
loc19.addFace(loc27);
|
||||
}
|
||||
loc15++;
|
||||
}
|
||||
loc17++;
|
||||
}
|
||||
loc16 = 0;
|
||||
while(loc16 < param5)
|
||||
{
|
||||
loc17 = 0;
|
||||
while(loc17 < param6)
|
||||
{
|
||||
loc27 = "left_" + loc16 + "_" + loc17;
|
||||
if(param7)
|
||||
{
|
||||
if(param8)
|
||||
{
|
||||
loc28 = new Point(loc16 * loc25,(loc17 + 1) * loc26);
|
||||
loc29 = new Point((loc16 + 1) * loc25,loc17 * loc26);
|
||||
createFace([0 + "_" + loc16 + "_" + (loc17 + 1),0 + "_" + loc16 + "_" + loc17,0 + "_" + (loc16 + 1) + "_" + loc17],loc27 + ":0");
|
||||
setUVsToFace(loc28,new Point(loc16 * loc25,loc17 * loc26),loc29,loc27 + ":0");
|
||||
createFace([0 + "_" + (loc16 + 1) + "_" + loc17,0 + "_" + (loc16 + 1) + "_" + (loc17 + 1),0 + "_" + loc16 + "_" + (loc17 + 1)],loc27 + ":1");
|
||||
setUVsToFace(loc29,new Point((loc16 + 1) * loc25,(loc17 + 1) * loc26),loc28,loc27 + ":1");
|
||||
}
|
||||
else
|
||||
{
|
||||
createFace([0 + "_" + loc16 + "_" + loc17,0 + "_" + (loc16 + 1) + "_" + loc17,0 + "_" + (loc16 + 1) + "_" + (loc17 + 1),0 + "_" + loc16 + "_" + (loc17 + 1)],loc27);
|
||||
setUVsToFace(new Point(loc16 * loc25,loc17 * loc26),new Point((loc16 + 1) * loc25,loc17 * loc26),new Point((loc16 + 1) * loc25,(loc17 + 1) * loc26),loc27);
|
||||
}
|
||||
}
|
||||
else if(param8)
|
||||
{
|
||||
loc28 = new Point((param5 - loc16 - 1) * loc25,loc17 * loc26);
|
||||
loc29 = new Point((param5 - loc16) * loc25,(loc17 + 1) * loc26);
|
||||
createFace([0 + "_" + (loc16 + 1) + "_" + loc17,0 + "_" + loc16 + "_" + loc17,0 + "_" + loc16 + "_" + (loc17 + 1)],loc27 + ":0");
|
||||
setUVsToFace(loc28,new Point((param5 - loc16) * loc25,loc17 * loc26),loc29,loc27 + ":0");
|
||||
createFace([0 + "_" + loc16 + "_" + (loc17 + 1),0 + "_" + (loc16 + 1) + "_" + (loc17 + 1),0 + "_" + (loc16 + 1) + "_" + loc17],loc27 + ":1");
|
||||
setUVsToFace(loc29,new Point((param5 - loc16 - 1) * loc25,(loc17 + 1) * loc26),loc28,loc27 + ":1");
|
||||
}
|
||||
else
|
||||
{
|
||||
createFace([0 + "_" + loc16 + "_" + loc17,0 + "_" + loc16 + "_" + (loc17 + 1),0 + "_" + (loc16 + 1) + "_" + (loc17 + 1),0 + "_" + (loc16 + 1) + "_" + loc17],loc27);
|
||||
setUVsToFace(new Point((param5 - loc16) * loc25,loc17 * loc26),new Point((param5 - loc16) * loc25,(loc17 + 1) * loc26),new Point((param5 - loc16 - 1) * loc25,(loc17 + 1) * loc26),loc27);
|
||||
}
|
||||
if(param8)
|
||||
{
|
||||
loc20.addFace(loc27 + ":0");
|
||||
loc20.addFace(loc27 + ":1");
|
||||
}
|
||||
else
|
||||
{
|
||||
loc20.addFace(loc27);
|
||||
}
|
||||
loc17++;
|
||||
}
|
||||
loc16++;
|
||||
}
|
||||
loc16 = 0;
|
||||
while(loc16 < param5)
|
||||
{
|
||||
loc17 = 0;
|
||||
while(loc17 < param6)
|
||||
{
|
||||
loc27 = "right_" + loc16 + "_" + loc17;
|
||||
if(param7)
|
||||
{
|
||||
if(param8)
|
||||
{
|
||||
loc28 = new Point((param5 - loc16) * loc25,loc17 * loc26);
|
||||
loc29 = new Point((param5 - loc16 - 1) * loc25,(loc17 + 1) * loc26);
|
||||
createFace([param4 + "_" + loc16 + "_" + loc17,param4 + "_" + loc16 + "_" + (loc17 + 1),param4 + "_" + (loc16 + 1) + "_" + (loc17 + 1)],loc27 + ":1");
|
||||
setUVsToFace(loc28,new Point((param5 - loc16) * loc25,(loc17 + 1) * loc26),loc29,loc27 + ":1");
|
||||
createFace([param4 + "_" + (loc16 + 1) + "_" + (loc17 + 1),param4 + "_" + (loc16 + 1) + "_" + loc17,param4 + "_" + loc16 + "_" + loc17],loc27 + ":0");
|
||||
setUVsToFace(loc29,new Point((param5 - loc16 - 1) * loc25,loc17 * loc26),loc28,loc27 + ":0");
|
||||
}
|
||||
else
|
||||
{
|
||||
createFace([param4 + "_" + loc16 + "_" + loc17,param4 + "_" + loc16 + "_" + (loc17 + 1),param4 + "_" + (loc16 + 1) + "_" + (loc17 + 1),param4 + "_" + (loc16 + 1) + "_" + loc17],loc27);
|
||||
setUVsToFace(new Point((param5 - loc16) * loc25,loc17 * loc26),new Point((param5 - loc16) * loc25,(loc17 + 1) * loc26),new Point((param5 - loc16 - 1) * loc25,(loc17 + 1) * loc26),loc27);
|
||||
}
|
||||
}
|
||||
else if(param8)
|
||||
{
|
||||
loc28 = new Point(loc16 * loc25,loc17 * loc26);
|
||||
loc29 = new Point((loc16 + 1) * loc25,(loc17 + 1) * loc26);
|
||||
createFace([param4 + "_" + loc16 + "_" + loc17,param4 + "_" + (loc16 + 1) + "_" + loc17,param4 + "_" + (loc16 + 1) + "_" + (loc17 + 1)],loc27 + ":0");
|
||||
setUVsToFace(loc28,new Point((loc16 + 1) * loc25,loc17 * loc26),loc29,loc27 + ":0");
|
||||
createFace([param4 + "_" + (loc16 + 1) + "_" + (loc17 + 1),param4 + "_" + loc16 + "_" + (loc17 + 1),param4 + "_" + loc16 + "_" + loc17],loc27 + ":1");
|
||||
setUVsToFace(loc29,new Point(loc16 * loc25,(loc17 + 1) * loc26),loc28,loc27 + ":1");
|
||||
}
|
||||
else
|
||||
{
|
||||
createFace([param4 + "_" + loc16 + "_" + loc17,param4 + "_" + (loc16 + 1) + "_" + loc17,param4 + "_" + (loc16 + 1) + "_" + (loc17 + 1),param4 + "_" + loc16 + "_" + (loc17 + 1)],loc27);
|
||||
setUVsToFace(new Point(loc16 * loc25,loc17 * loc26),new Point((loc16 + 1) * loc25,loc17 * loc26),new Point((loc16 + 1) * loc25,(loc17 + 1) * loc26),loc27);
|
||||
}
|
||||
if(param8)
|
||||
{
|
||||
loc21.addFace(loc27 + ":0");
|
||||
loc21.addFace(loc27 + ":1");
|
||||
}
|
||||
else
|
||||
{
|
||||
loc21.addFace(loc27);
|
||||
}
|
||||
loc17++;
|
||||
}
|
||||
loc16++;
|
||||
}
|
||||
}
|
||||
|
||||
override protected function createEmptyObject() : Object3D
|
||||
{
|
||||
return new Box(0,0,0,0);
|
||||
}
|
||||
|
||||
override protected function defaultName() : String
|
||||
{
|
||||
return "box" + ++counter;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,115 +0,0 @@
|
||||
package alternativa.engine3d.primitives
|
||||
{
|
||||
import alternativa.engine3d.*;
|
||||
import alternativa.engine3d.core.Mesh;
|
||||
import alternativa.engine3d.core.Object3D;
|
||||
import alternativa.engine3d.core.Surface;
|
||||
import flash.geom.Point;
|
||||
|
||||
use namespace alternativa3d;
|
||||
|
||||
public class Plane extends Mesh
|
||||
{
|
||||
private static var counter:uint = 0;
|
||||
|
||||
public function Plane(param1:Number = 100, param2:Number = 100, param3:uint = 1, param4:uint = 1, param5:Boolean = true, param6:Boolean = false, param7:Boolean = false)
|
||||
{
|
||||
var loc14:int = 0;
|
||||
var loc15:int = 0;
|
||||
var loc17:Surface = null;
|
||||
var loc18:Surface = null;
|
||||
super();
|
||||
if(param3 == 0 || param4 == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
param1 = param1 < 0 ? 0 : param1;
|
||||
param2 = param2 < 0 ? 0 : param2;
|
||||
var loc8:Number = param1 / 2;
|
||||
var loc9:Number = param2 / 2;
|
||||
var loc10:Number = param1 / param3;
|
||||
var loc11:Number = param2 / param4;
|
||||
var loc12:Number = 1 / param3;
|
||||
var loc13:Number = 1 / param4;
|
||||
var loc16:Array = new Array();
|
||||
loc15 = 0;
|
||||
while(loc15 <= param4)
|
||||
{
|
||||
loc16[loc15] = new Array();
|
||||
loc14 = 0;
|
||||
while(loc14 <= param3)
|
||||
{
|
||||
loc16[loc15][loc14] = new Point(loc14 * loc12,loc15 * loc13);
|
||||
createVertex(loc14 * loc10 - loc8,loc15 * loc11 - loc9,0,loc14 + "_" + loc15);
|
||||
loc14++;
|
||||
}
|
||||
loc15++;
|
||||
}
|
||||
if(param5 || !param6)
|
||||
{
|
||||
loc17 = createSurface(null,"front");
|
||||
}
|
||||
if(param5 || param6)
|
||||
{
|
||||
loc18 = createSurface(null,"back");
|
||||
}
|
||||
loc15 = 0;
|
||||
while(loc15 < param4)
|
||||
{
|
||||
loc14 = 0;
|
||||
while(loc14 < param3)
|
||||
{
|
||||
if(param5 || !param6)
|
||||
{
|
||||
if(param7)
|
||||
{
|
||||
createFace([loc14 + "_" + loc15,loc14 + 1 + "_" + loc15,loc14 + 1 + "_" + (loc15 + 1)],"front" + loc14 + "_" + loc15 + ":0");
|
||||
setUVsToFace(loc16[loc15][loc14],loc16[loc15][loc14 + 1],loc16[loc15 + 1][loc14 + 1],"front" + loc14 + "_" + loc15 + ":0");
|
||||
createFace([loc14 + 1 + "_" + (loc15 + 1),loc14 + "_" + (loc15 + 1),loc14 + "_" + loc15],"front" + loc14 + "_" + loc15 + ":1");
|
||||
setUVsToFace(loc16[loc15 + 1][loc14 + 1],loc16[loc15 + 1][loc14],loc16[loc15][loc14],"front" + loc14 + "_" + loc15 + ":1");
|
||||
loc17.addFace("front" + loc14 + "_" + loc15 + ":0");
|
||||
loc17.addFace("front" + loc14 + "_" + loc15 + ":1");
|
||||
}
|
||||
else
|
||||
{
|
||||
createFace([loc14 + "_" + loc15,loc14 + 1 + "_" + loc15,loc14 + 1 + "_" + (loc15 + 1),loc14 + "_" + (loc15 + 1)],"front" + loc14 + "_" + loc15);
|
||||
setUVsToFace(loc16[loc15][loc14],loc16[loc15][loc14 + 1],loc16[loc15 + 1][loc14 + 1],"front" + loc14 + "_" + loc15);
|
||||
loc17.addFace("front" + loc14 + "_" + loc15);
|
||||
}
|
||||
}
|
||||
if(param5 || param6)
|
||||
{
|
||||
if(param7)
|
||||
{
|
||||
createFace([loc14 + "_" + loc15,loc14 + "_" + (loc15 + 1),loc14 + 1 + "_" + (loc15 + 1)],"back" + loc14 + "_" + loc15 + ":0");
|
||||
setUVsToFace(loc16[param4 - loc15][loc14],loc16[param4 - loc15 - 1][loc14],loc16[param4 - loc15 - 1][loc14 + 1],"back" + loc14 + "_" + loc15 + ":0");
|
||||
createFace([loc14 + 1 + "_" + (loc15 + 1),loc14 + 1 + "_" + loc15,loc14 + "_" + loc15],"back" + loc14 + "_" + loc15 + ":1");
|
||||
setUVsToFace(loc16[param4 - loc15 - 1][loc14 + 1],loc16[param4 - loc15][loc14 + 1],loc16[param4 - loc15][loc14],"back" + loc14 + "_" + loc15 + ":1");
|
||||
loc18.addFace("back" + loc14 + "_" + loc15 + ":0");
|
||||
loc18.addFace("back" + loc14 + "_" + loc15 + ":1");
|
||||
}
|
||||
else
|
||||
{
|
||||
createFace([loc14 + "_" + loc15,loc14 + "_" + (loc15 + 1),loc14 + 1 + "_" + (loc15 + 1),loc14 + 1 + "_" + loc15],"back" + loc14 + "_" + loc15);
|
||||
setUVsToFace(loc16[param4 - loc15][loc14],loc16[param4 - loc15 - 1][loc14],loc16[param4 - loc15 - 1][loc14 + 1],"back" + loc14 + "_" + loc15);
|
||||
loc18.addFace("back" + loc14 + "_" + loc15);
|
||||
}
|
||||
}
|
||||
loc14++;
|
||||
}
|
||||
loc15++;
|
||||
}
|
||||
}
|
||||
|
||||
override protected function createEmptyObject() : Object3D
|
||||
{
|
||||
return new Plane(0,0,0);
|
||||
}
|
||||
|
||||
override protected function defaultName() : String
|
||||
{
|
||||
return "plane" + ++counter;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user